summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2010-11-01 01:35:04 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2010-11-01 01:35:04 -0700
commit6130e39b18b5f53902e4eab14f6d5cdde5219563 (patch)
tree0db0628479a1b750e9af1f66cb8379ebd0913d31 /src
parentf0e77f6797c0504b0da25a56152b707d3357f386 (diff)
downloadabc-6130e39b18b5f53902e4eab14f6d5cdde5219563.tar.gz
abc-6130e39b18b5f53902e4eab14f6d5cdde5219563.tar.bz2
abc-6130e39b18b5f53902e4eab14f6d5cdde5219563.zip
initial commit of public abc
Diffstat (limited to 'src')
-rw-r--r--src/aig/aig/aig.h67
-rw-r--r--src/aig/aig/aigCanon.c10
-rw-r--r--src/aig/aig/aigCheck.c5
-rw-r--r--src/aig/aig/aigCuts.c7
-rw-r--r--src/aig/aig/aigDfs.c36
-rw-r--r--src/aig/aig/aigDup.c204
-rw-r--r--src/aig/aig/aigFact.c454
-rw-r--r--src/aig/aig/aigFanout.c5
-rw-r--r--src/aig/aig/aigFrames.c5
-rw-r--r--src/aig/aig/aigInter.c9
-rw-r--r--src/aig/aig/aigMan.c97
-rw-r--r--src/aig/aig/aigMem.c21
-rw-r--r--src/aig/aig/aigMffc.c13
-rw-r--r--src/aig/aig/aigObj.c7
-rw-r--r--src/aig/aig/aigOper.c175
-rw-r--r--src/aig/aig/aigOrder.c5
-rw-r--r--src/aig/aig/aigPart.c148
-rw-r--r--src/aig/aig/aigPartReg.c35
-rw-r--r--src/aig/aig/aigPartSat.c35
-rw-r--r--src/aig/aig/aigRepr.c20
-rw-r--r--src/aig/aig/aigRet.c71
-rw-r--r--src/aig/aig/aigRetF.c5
-rw-r--r--src/aig/aig/aigScl.c28
-rw-r--r--src/aig/aig/aigShow.c9
-rw-r--r--src/aig/aig/aigSplit.c316
-rw-r--r--src/aig/aig/aigTable.c5
-rw-r--r--src/aig/aig/aigTest.c6
-rw-r--r--src/aig/aig/aigTiming.c11
-rw-r--r--src/aig/aig/aigTruth.c17
-rw-r--r--src/aig/aig/aigTsim.c9
-rw-r--r--src/aig/aig/aigUtil.c199
-rw-r--r--src/aig/aig/aigWin.c9
-rw-r--r--src/aig/aig/aig_.c5
-rw-r--r--src/aig/aig/module.make1
-rw-r--r--src/aig/bar/bar.c11
-rw-r--r--src/aig/bar/bar.h16
-rw-r--r--src/aig/bbl/bblif.c13
-rw-r--r--src/aig/bbl/bblif.h16
-rw-r--r--src/aig/bbr/bbr.h23
-rw-r--r--src/aig/bbr/bbrCex.c11
-rw-r--r--src/aig/bbr/bbrImage.c7
-rw-r--r--src/aig/bbr/bbrNtbdd.c7
-rw-r--r--src/aig/bbr/bbrReach.c165
-rw-r--r--src/aig/bbr/bbr_.c5
-rw-r--r--src/aig/bdc/bdc.h17
-rw-r--r--src/aig/bdc/bdcCore.c11
-rw-r--r--src/aig/bdc/bdcDec.c5
-rw-r--r--src/aig/bdc/bdcInt.h20
-rw-r--r--src/aig/bdc/bdcTable.c5
-rw-r--r--src/aig/bdc/bdc_.c5
-rw-r--r--src/aig/cec/cec.c5
-rw-r--r--src/aig/cec/cec.h50
-rw-r--r--src/aig/cec/cecCec.c124
-rw-r--r--src/aig/cec/cecChoice.c106
-rw-r--r--src/aig/cec/cecClass.c48
-rw-r--r--src/aig/cec/cecCore.c73
-rw-r--r--src/aig/cec/cecCorr.c114
-rw-r--r--src/aig/cec/cecCorr_updated.c7
-rw-r--r--src/aig/cec/cecInt.h26
-rw-r--r--src/aig/cec/cecIso.c11
-rw-r--r--src/aig/cec/cecMan.c45
-rw-r--r--src/aig/cec/cecPat.c19
-rw-r--r--src/aig/cec/cecSeq.c71
-rw-r--r--src/aig/cec/cecSim.c5
-rw-r--r--src/aig/cec/cecSolve.c75
-rw-r--r--src/aig/cec/cecSweep.c11
-rw-r--r--src/aig/cec/cecSynth.c380
-rw-r--r--src/aig/cec/module.make1
-rw-r--r--src/aig/cgt/cgt.h16
-rw-r--r--src/aig/cgt/cgtAig.c63
-rw-r--r--src/aig/cgt/cgtCore.c23
-rw-r--r--src/aig/cgt/cgtDecide.c23
-rw-r--r--src/aig/cgt/cgtInt.h16
-rw-r--r--src/aig/cgt/cgtMan.c5
-rw-r--r--src/aig/cgt/cgtSat.c5
-rw-r--r--src/aig/cnf/cnf.h21
-rw-r--r--src/aig/cnf/cnfCore.c58
-rw-r--r--src/aig/cnf/cnfCut.c5
-rw-r--r--src/aig/cnf/cnfData.c9
-rw-r--r--src/aig/cnf/cnfMan.c52
-rw-r--r--src/aig/cnf/cnfMap.c7
-rw-r--r--src/aig/cnf/cnfPost.c7
-rw-r--r--src/aig/cnf/cnfUtil.c11
-rw-r--r--src/aig/cnf/cnfWrite.c48
-rw-r--r--src/aig/cnf/cnf_.c5
-rw-r--r--src/aig/csw/csw.h16
-rw-r--r--src/aig/csw/cswCore.c5
-rw-r--r--src/aig/csw/cswCut.c7
-rw-r--r--src/aig/csw/cswInt.h16
-rw-r--r--src/aig/csw/cswMan.c5
-rw-r--r--src/aig/csw/cswTable.c5
-rw-r--r--src/aig/csw/csw_.c5
-rw-r--r--src/aig/dar/dar.h18
-rw-r--r--src/aig/dar/darBalance.c56
-rw-r--r--src/aig/dar/darCore.c11
-rw-r--r--src/aig/dar/darCut.c9
-rw-r--r--src/aig/dar/darData.c7
-rw-r--r--src/aig/dar/darInt.h19
-rw-r--r--src/aig/dar/darLib.c322
-rw-r--r--src/aig/dar/darMan.c39
-rw-r--r--src/aig/dar/darPrec.c25
-rw-r--r--src/aig/dar/darRefact.c27
-rw-r--r--src/aig/dar/darResub.c5
-rw-r--r--src/aig/dar/darScript.c120
-rw-r--r--src/aig/dar/dar_.c5
-rw-r--r--src/aig/dch/dch.h20
-rw-r--r--src/aig/dch/dchAig.c15
-rw-r--r--src/aig/dch/dchChoice.c71
-rw-r--r--src/aig/dch/dchClass.c35
-rw-r--r--src/aig/dch/dchCnf.c15
-rw-r--r--src/aig/dch/dchCore.c23
-rw-r--r--src/aig/dch/dchInt.h19
-rw-r--r--src/aig/dch/dchMan.c39
-rw-r--r--src/aig/dch/dchSat.c5
-rw-r--r--src/aig/dch/dchSim.c13
-rw-r--r--src/aig/dch/dchSimSat.c17
-rw-r--r--src/aig/dch/dchSweep.c5
-rw-r--r--src/aig/deco/deco.h25
-rw-r--r--src/aig/fra/fra.h42
-rw-r--r--src/aig/fra/fraBmc.c11
-rw-r--r--src/aig/fra/fraCec.c16
-rw-r--r--src/aig/fra/fraClass.c45
-rw-r--r--src/aig/fra/fraClau.c11
-rw-r--r--src/aig/fra/fraClaus.c21
-rw-r--r--src/aig/fra/fraCnf.c15
-rw-r--r--src/aig/fra/fraCore.c9
-rw-r--r--src/aig/fra/fraHot.c23
-rw-r--r--src/aig/fra/fraImp.c25
-rw-r--r--src/aig/fra/fraInd.c19
-rw-r--r--src/aig/fra/fraIndVer.c9
-rw-r--r--src/aig/fra/fraLcr.c51
-rw-r--r--src/aig/fra/fraMan.c5
-rw-r--r--src/aig/fra/fraPart.c23
-rw-r--r--src/aig/fra/fraSat.c7
-rw-r--r--src/aig/fra/fraSec.c35
-rw-r--r--src/aig/fra/fraSim.c69
-rw-r--r--src/aig/fra/fra_.c5
-rw-r--r--src/aig/fsim/fsim.h16
-rw-r--r--src/aig/fsim/fsimCore.c5
-rw-r--r--src/aig/fsim/fsimFront.c5
-rw-r--r--src/aig/fsim/fsimInt.h16
-rw-r--r--src/aig/fsim/fsimMan.c5
-rw-r--r--src/aig/fsim/fsimSim.c16
-rw-r--r--src/aig/fsim/fsimSwitch.c5
-rw-r--r--src/aig/fsim/fsimTsim.c5
-rw-r--r--src/aig/gia/gia.c5
-rw-r--r--src/aig/gia/gia.h300
-rw-r--r--src/aig/gia/giaAbs.c553
-rw-r--r--src/aig/gia/giaAbs.h89
-rw-r--r--src/aig/gia/giaAig.c247
-rw-r--r--src/aig/gia/giaAig.h22
-rw-r--r--src/aig/gia/giaAiger.c99
-rw-r--r--src/aig/gia/giaAiger_new.c1251
-rw-r--r--src/aig/gia/giaAiger_old.c1255
-rw-r--r--src/aig/gia/giaBidec.c308
-rw-r--r--src/aig/gia/giaCSat.c7
-rw-r--r--src/aig/gia/giaCSatOld.c5
-rw-r--r--src/aig/gia/giaCTas.c1788
-rw-r--r--src/aig/gia/giaCTas2.c208
-rw-r--r--src/aig/gia/giaCof.c11
-rw-r--r--src/aig/gia/giaConstr.c5
-rw-r--r--src/aig/gia/giaDfs.c104
-rw-r--r--src/aig/gia/giaDup.c227
-rw-r--r--src/aig/gia/giaEmbed.c10
-rw-r--r--src/aig/gia/giaEnable.c7
-rw-r--r--src/aig/gia/giaEquiv.c97
-rw-r--r--src/aig/gia/giaEra.c561
-rw-r--r--src/aig/gia/giaEra2.c1954
-rw-r--r--src/aig/gia/giaFanout.c5
-rw-r--r--src/aig/gia/giaForce.c10
-rw-r--r--src/aig/gia/giaFrames.c13
-rw-r--r--src/aig/gia/giaFront.c7
-rw-r--r--src/aig/gia/giaGiarf.c1077
-rw-r--r--src/aig/gia/giaGlitch.c5
-rw-r--r--src/aig/gia/giaHash.c27
-rw-r--r--src/aig/gia/giaHcd.c686
-rw-r--r--src/aig/gia/giaIf.c (renamed from src/aig/gia/giaMap.c)260
-rw-r--r--src/aig/gia/giaMan.c85
-rw-r--r--src/aig/gia/giaMem.c598
-rw-r--r--src/aig/gia/giaPat.c5
-rw-r--r--src/aig/gia/giaProp.c5
-rw-r--r--src/aig/gia/giaReparam.c201
-rw-r--r--src/aig/gia/giaRetime.c13
-rw-r--r--src/aig/gia/giaSat.c5
-rw-r--r--src/aig/gia/giaScl.c9
-rw-r--r--src/aig/gia/giaShrink.c151
-rw-r--r--src/aig/gia/giaSim.c95
-rw-r--r--src/aig/gia/giaSort.c5
-rw-r--r--src/aig/gia/giaSpeedup.c810
-rw-r--r--src/aig/gia/giaSupMin.c165
-rw-r--r--src/aig/gia/giaSwitch.c39
-rw-r--r--src/aig/gia/giaTsim.c24
-rw-r--r--src/aig/gia/giaUtil.c428
-rw-r--r--src/aig/gia/module.make8
-rw-r--r--src/aig/hop/cudd2.c5
-rw-r--r--src/aig/hop/cudd2.h16
-rw-r--r--src/aig/hop/hop.h28
-rw-r--r--src/aig/hop/hopBalance.c43
-rw-r--r--src/aig/hop/hopCheck.c5
-rw-r--r--src/aig/hop/hopDfs.c15
-rw-r--r--src/aig/hop/hopMan.c7
-rw-r--r--src/aig/hop/hopMem.c7
-rw-r--r--src/aig/hop/hopObj.c7
-rw-r--r--src/aig/hop/hopOper.c7
-rw-r--r--src/aig/hop/hopTable.c5
-rw-r--r--src/aig/hop/hopTruth.c7
-rw-r--r--src/aig/hop/hopUtil.c23
-rw-r--r--src/aig/hop/hop_.c5
-rw-r--r--src/aig/int/int.h19
-rw-r--r--src/aig/int/intContain.c10
-rw-r--r--src/aig/int/intCore.c24
-rw-r--r--src/aig/int/intCtrex.c9
-rw-r--r--src/aig/int/intDup.c31
-rw-r--r--src/aig/int/intFrames.c14
-rw-r--r--src/aig/int/intInt.h16
-rw-r--r--src/aig/int/intInter.c5
-rw-r--r--src/aig/int/intM114.c9
-rw-r--r--src/aig/int/intM114p.c8
-rw-r--r--src/aig/int/intMan.c5
-rw-r--r--src/aig/int/intUtil.c9
-rw-r--r--src/aig/ioa/ioa.h18
-rw-r--r--src/aig/ioa/ioaReadAig.c23
-rw-r--r--src/aig/ioa/ioaUtil.c5
-rw-r--r--src/aig/ioa/ioaWriteAig.c179
-rw-r--r--src/aig/ivy/attr.h16
-rw-r--r--src/aig/ivy/ivy.h33
-rw-r--r--src/aig/ivy/ivyBalance.c37
-rw-r--r--src/aig/ivy/ivyCanon.c5
-rw-r--r--src/aig/ivy/ivyCheck.c5
-rw-r--r--src/aig/ivy/ivyCut.c21
-rw-r--r--src/aig/ivy/ivyCutTrav.c47
-rw-r--r--src/aig/ivy/ivyDfs.c11
-rw-r--r--src/aig/ivy/ivyDsd.c15
-rw-r--r--src/aig/ivy/ivyFanout.c5
-rw-r--r--src/aig/ivy/ivyFastMap.c23
-rw-r--r--src/aig/ivy/ivyFraig.c39
-rw-r--r--src/aig/ivy/ivyHaig.c19
-rw-r--r--src/aig/ivy/ivyMan.c13
-rw-r--r--src/aig/ivy/ivyMem.c7
-rw-r--r--src/aig/ivy/ivyMulti.c13
-rw-r--r--src/aig/ivy/ivyMulti8.c5
-rw-r--r--src/aig/ivy/ivyObj.c5
-rw-r--r--src/aig/ivy/ivyOper.c7
-rw-r--r--src/aig/ivy/ivyResyn.c5
-rw-r--r--src/aig/ivy/ivyRwr.c51
-rw-r--r--src/aig/ivy/ivyRwrAlg.c27
-rw-r--r--src/aig/ivy/ivySeq.c39
-rw-r--r--src/aig/ivy/ivyShow.c9
-rw-r--r--src/aig/ivy/ivyTable.c5
-rw-r--r--src/aig/ivy/ivyUtil.c5
-rw-r--r--src/aig/ivy/ivy_.c5
-rw-r--r--src/aig/kit/cloud.c5
-rw-r--r--src/aig/kit/cloud.h17
-rw-r--r--src/aig/kit/kit.h70
-rw-r--r--src/aig/kit/kitAig.c13
-rw-r--r--src/aig/kit/kitBdd.c11
-rw-r--r--src/aig/kit/kitCloud.c34
-rw-r--r--src/aig/kit/kitDec.c343
-rw-r--r--src/aig/kit/kitDsd.c265
-rw-r--r--src/aig/kit/kitFactor.c5
-rw-r--r--src/aig/kit/kitGraph.c5
-rw-r--r--src/aig/kit/kitHop.c13
-rw-r--r--src/aig/kit/kitIsop.c5
-rw-r--r--src/aig/kit/kitPla.c191
-rw-r--r--src/aig/kit/kitSop.c7
-rw-r--r--src/aig/kit/kitTruth.c403
-rw-r--r--src/aig/kit/kit_.c5
-rw-r--r--src/aig/live/liveness.c2575
-rw-r--r--src/aig/live/liveness_old.c1756
-rw-r--r--src/aig/live/liveness_sim.c848
-rw-r--r--src/aig/live/ltl_parser.c838
-rw-r--r--src/aig/live/module.make3
-rw-r--r--src/aig/llb/llb.c (renamed from src/base/abci/abc_.c)14
-rw-r--r--src/aig/llb/llb.h92
-rw-r--r--src/aig/llb/llbCex.c (renamed from src/aig/nwk2/nwk_.c)19
-rw-r--r--src/aig/llb/llbCluster.c357
-rw-r--r--src/aig/llb/llbConstr.c313
-rw-r--r--src/aig/llb/llbCore.c219
-rw-r--r--src/aig/llb/llbFlow.c639
-rw-r--r--src/aig/llb/llbHint.c226
-rw-r--r--src/aig/llb/llbInt.h162
-rw-r--r--src/aig/llb/llbMan.c189
-rw-r--r--src/aig/llb/llbMatrix.c430
-rw-r--r--src/aig/llb/llbPart.c474
-rw-r--r--src/aig/llb/llbPivot.c254
-rw-r--r--src/aig/llb/llbReach.c620
-rw-r--r--src/aig/llb/llbSched.c257
-rw-r--r--src/aig/llb/module.make11
-rw-r--r--src/aig/mem/mem.c23
-rw-r--r--src/aig/mem/mem.h15
-rw-r--r--src/aig/mfx/mfx.h18
-rw-r--r--src/aig/mfx/mfxCore.c11
-rw-r--r--src/aig/mfx/mfxDiv.c15
-rw-r--r--src/aig/mfx/mfxInt.h16
-rw-r--r--src/aig/mfx/mfxInter.c11
-rw-r--r--src/aig/mfx/mfxMan.c5
-rw-r--r--src/aig/mfx/mfxResub.c21
-rw-r--r--src/aig/mfx/mfxSat.c7
-rw-r--r--src/aig/mfx/mfxStrash.c41
-rw-r--r--src/aig/mfx/mfxWin.c5
-rw-r--r--src/aig/mfx/mfx_.c5
-rw-r--r--src/aig/ntl/ntl.h33
-rw-r--r--src/aig/ntl/ntlCheck.c7
-rw-r--r--src/aig/ntl/ntlCore.c32
-rw-r--r--src/aig/ntl/ntlEc.c16
-rw-r--r--src/aig/ntl/ntlExtract.c93
-rw-r--r--src/aig/ntl/ntlFraig.c56
-rw-r--r--src/aig/ntl/ntlInsert.c31
-rw-r--r--src/aig/ntl/ntlMan.c69
-rw-r--r--src/aig/ntl/ntlMap.c21
-rw-r--r--src/aig/ntl/ntlNames.c471
-rw-r--r--src/aig/ntl/ntlObj.c9
-rw-r--r--src/aig/ntl/ntlReadBlif.c412
-rw-r--r--src/aig/ntl/ntlSweep.c5
-rw-r--r--src/aig/ntl/ntlTable.c13
-rw-r--r--src/aig/ntl/ntlTime.c7
-rw-r--r--src/aig/ntl/ntlUtil.c33
-rw-r--r--src/aig/ntl/ntlWriteBlif.c49
-rw-r--r--src/aig/ntl/ntl_.c5
-rw-r--r--src/aig/ntl/ntlnwk.h113
-rw-r--r--src/aig/nwk/nwk.h42
-rw-r--r--src/aig/nwk/nwkAig.c13
-rw-r--r--src/aig/nwk/nwkBidec.c7
-rw-r--r--src/aig/nwk/nwkCheck.c5
-rw-r--r--src/aig/nwk/nwkDfs.c5
-rw-r--r--src/aig/nwk/nwkFanio.c7
-rw-r--r--src/aig/nwk/nwkFlow.c11
-rw-r--r--src/aig/nwk/nwkFlow_depth.c9
-rw-r--r--src/aig/nwk/nwkMan.c25
-rw-r--r--src/aig/nwk/nwkMap.c41
-rw-r--r--src/aig/nwk/nwkMerge.c18
-rw-r--r--src/aig/nwk/nwkMerge.h16
-rw-r--r--src/aig/nwk/nwkObj.c9
-rw-r--r--src/aig/nwk/nwkSpeedup.c62
-rw-r--r--src/aig/nwk/nwkStrash.c19
-rw-r--r--src/aig/nwk/nwkTiming.c27
-rw-r--r--src/aig/nwk/nwkUtil.c11
-rw-r--r--src/aig/nwk/nwk_.c5
-rw-r--r--src/aig/nwk2/module.make7
-rw-r--r--src/aig/nwk2/nwk.h278
-rw-r--r--src/aig/nwk2/nwkCheck.c73
-rw-r--r--src/aig/nwk2/nwkDfs.c659
-rw-r--r--src/aig/nwk2/nwkFanio.c309
-rw-r--r--src/aig/nwk2/nwkMan.c239
-rw-r--r--src/aig/nwk2/nwkMerge.c993
-rw-r--r--src/aig/nwk2/nwkMerge.h149
-rw-r--r--src/aig/nwk2/nwkObj.c199
-rw-r--r--src/aig/nwk2/nwkUtil.c515
-rw-r--r--src/aig/rwt/rwt.h25
-rw-r--r--src/aig/rwt/rwtDec.c7
-rw-r--r--src/aig/rwt/rwtMan.c7
-rw-r--r--src/aig/rwt/rwtUtil.c549
-rw-r--r--src/aig/saig/module.make5
-rw-r--r--src/aig/saig/saig.h111
-rw-r--r--src/aig/saig/saigAbs.c910
-rw-r--r--src/aig/saig/saigAbs2.c237
-rw-r--r--src/aig/saig/saigBmc.c917
-rw-r--r--src/aig/saig/saigBmc2.c937
-rw-r--r--src/aig/saig/saigBmc3.c1227
-rw-r--r--src/aig/saig/saigCone.c9
-rw-r--r--src/aig/saig/saigConstr.c384
-rw-r--r--src/aig/saig/saigConstr2.c1001
-rw-r--r--src/aig/saig/saigDup.c24
-rw-r--r--src/aig/saig/saigHaig.c17
-rw-r--r--src/aig/saig/saigInd.c212
-rw-r--r--src/aig/saig/saigIoa.c8
-rw-r--r--src/aig/saig/saigMiter.c40
-rw-r--r--src/aig/saig/saigPba.c752
-rw-r--r--src/aig/saig/saigPhase.c56
-rw-r--r--src/aig/saig/saigRetFwd.c5
-rw-r--r--src/aig/saig/saigRetMin.c38
-rw-r--r--src/aig/saig/saigRetStep.c5
-rw-r--r--src/aig/saig/saigScl.c5
-rw-r--r--src/aig/saig/saigSimExt.c249
-rw-r--r--src/aig/saig/saigSimFast.c10
-rw-r--r--src/aig/saig/saigSimMv.c45
-rw-r--r--src/aig/saig/saigSimSeq.c17
-rw-r--r--src/aig/saig/saigStrSim.c49
-rw-r--r--src/aig/saig/saigSwitch.c8
-rw-r--r--src/aig/saig/saigSynch.c39
-rw-r--r--src/aig/saig/saigTrans.c44
-rw-r--r--src/aig/saig/saigWnd.c51
-rw-r--r--src/aig/saig/saig_.c5
-rw-r--r--src/aig/ssw/module.make2
-rw-r--r--src/aig/ssw/ssw.h51
-rw-r--r--src/aig/ssw/sswAig.c22
-rw-r--r--src/aig/ssw/sswBmc.c9
-rw-r--r--src/aig/ssw/sswClass.c114
-rw-r--r--src/aig/ssw/sswCnf.c15
-rw-r--r--src/aig/ssw/sswConstr.c635
-rw-r--r--src/aig/ssw/sswCore.c225
-rw-r--r--src/aig/ssw/sswDyn.c19
-rw-r--r--src/aig/ssw/sswFilter.c492
-rw-r--r--src/aig/ssw/sswInt.h38
-rw-r--r--src/aig/ssw/sswIslands.c31
-rw-r--r--src/aig/ssw/sswLcorr.c13
-rw-r--r--src/aig/ssw/sswMan.c29
-rw-r--r--src/aig/ssw/sswPairs.c13
-rw-r--r--src/aig/ssw/sswPart.c22
-rw-r--r--src/aig/ssw/sswSat.c39
-rw-r--r--src/aig/ssw/sswSemi.c11
-rw-r--r--src/aig/ssw/sswSim.c48
-rw-r--r--src/aig/ssw/sswSimSat.c37
-rw-r--r--src/aig/ssw/sswSweep.c51
-rw-r--r--src/aig/ssw/sswUnique.c11
-rw-r--r--src/aig/tim/tim.c86
-rw-r--r--src/aig/tim/tim.h18
-rw-r--r--src/base/abc/abc.h232
-rw-r--r--src/base/abc/abcAig.c52
-rw-r--r--src/base/abc/abcBlifMv.c59
-rw-r--r--src/base/abc/abcCheck.c79
-rw-r--r--src/base/abc/abcDfs.c46
-rw-r--r--src/base/abc/abcFanio.c9
-rw-r--r--src/base/abc/abcFunc.c100
-rw-r--r--src/base/abc/abcHie.c15
-rw-r--r--src/base/abc/abcInt.h8
-rw-r--r--src/base/abc/abcLatch.c41
-rw-r--r--src/base/abc/abcLib.c35
-rw-r--r--src/base/abc/abcMinBase.c31
-rw-r--r--src/base/abc/abcNames.c69
-rw-r--r--src/base/abc/abcNetlist.c25
-rw-r--r--src/base/abc/abcNtk.c188
-rw-r--r--src/base/abc/abcObj.c135
-rw-r--r--src/base/abc/abcRefs.c19
-rw-r--r--src/base/abc/abcShow.c119
-rw-r--r--src/base/abc/abcSop.c25
-rw-r--r--src/base/abc/abcUtil.c61
-rw-r--r--src/base/abc/abc_.c5
-rw-r--r--src/base/abci/abc.c10887
-rw-r--r--src/base/abci/abcAbc8.c24
-rw-r--r--src/base/abci/abcAttach.c15
-rw-r--r--src/base/abci/abcAuto.c5
-rw-r--r--src/base/abci/abcBalance.c62
-rw-r--r--src/base/abci/abcBidec.c14
-rw-r--r--src/base/abci/abcBm.c2047
-rw-r--r--src/base/abci/abcBmc.c7
-rw-r--r--src/base/abci/abcCas.c5
-rw-r--r--src/base/abci/abcCascade.c284
-rw-r--r--src/base/abci/abcCollapse.c (renamed from src/base/abci/abcClpBdd.c)9
-rw-r--r--src/base/abci/abcCut.c31
-rw-r--r--src/base/abci/abcDar.c588
-rw-r--r--src/base/abci/abcDebug.c8
-rw-r--r--src/base/abci/abcDprove2.c405
-rw-r--r--src/base/abci/abcDress.c5
-rw-r--r--src/base/abci/abcDress2.c435
-rw-r--r--src/base/abci/abcDsd.c49
-rw-r--r--src/base/abci/abcEspresso.c5
-rw-r--r--src/base/abci/abcExtract.c5
-rw-r--r--src/base/abci/abcFlop.c (renamed from src/base/abci/abcClpSop.c)29
-rw-r--r--src/base/abci/abcFpga.c13
-rw-r--r--src/base/abci/abcFpgaFast.c17
-rw-r--r--src/base/abci/abcFraig.c73
-rw-r--r--src/base/abci/abcFxu.c25
-rw-r--r--src/base/abci/abcGen.c13
-rw-r--r--src/base/abci/abcHaig.c59
-rw-r--r--src/base/abci/abcIf.c130
-rw-r--r--src/base/abci/abcIfMux.c422
-rw-r--r--src/base/abci/abcIvy.c52
-rw-r--r--src/base/abci/abcLog.c215
-rw-r--r--src/base/abci/abcLut.c39
-rw-r--r--src/base/abci/abcLutmin.c61
-rw-r--r--src/base/abci/abcMap.c25
-rw-r--r--src/base/abci/abcMeasure.c13
-rw-r--r--src/base/abci/abcMerge.c15
-rw-r--r--src/base/abci/abcMini.c9
-rw-r--r--src/base/abci/abcMiter.c59
-rw-r--r--src/base/abci/abcMulti.c27
-rw-r--r--src/base/abci/abcMv.c5
-rw-r--r--src/base/abci/abcNtbdd.c33
-rw-r--r--src/base/abci/abcOdc.c40
-rw-r--r--src/base/abci/abcOrder.c9
-rw-r--r--src/base/abci/abcPart.c103
-rw-r--r--src/base/abci/abcPlace.c11
-rw-r--r--src/base/abci/abcPrint.c81
-rw-r--r--src/base/abci/abcProve.c13
-rw-r--r--src/base/abci/abcQbf.c5
-rw-r--r--src/base/abci/abcQuant.c41
-rw-r--r--src/base/abci/abcReach.c5
-rw-r--r--src/base/abci/abcRec.c17
-rw-r--r--src/base/abci/abcReconv.c47
-rw-r--r--src/base/abci/abcRefactor.c23
-rw-r--r--src/base/abci/abcRenode.c5
-rw-r--r--src/base/abci/abcReorder.c12
-rw-r--r--src/base/abci/abcRestruct.c95
-rw-r--r--src/base/abci/abcResub.c193
-rw-r--r--src/base/abci/abcRewrite.c27
-rw-r--r--src/base/abci/abcRr.c54
-rw-r--r--src/base/abci/abcSat.c49
-rw-r--r--src/base/abci/abcScorr.c454
-rw-r--r--src/base/abci/abcSense.c26
-rw-r--r--src/base/abci/abcSpeedup.c (renamed from src/base/abci/abcDelay.c)74
-rw-r--r--src/base/abci/abcStrash.c124
-rw-r--r--src/base/abci/abcSweep.c56
-rw-r--r--src/base/abci/abcSymm.c8
-rw-r--r--src/base/abci/abcTiming.c35
-rw-r--r--src/base/abci/abcUnate.c5
-rw-r--r--src/base/abci/abcUnreach.c15
-rw-r--r--src/base/abci/abcVerify.c97
-rw-r--r--src/base/abci/abcXsim.c15
-rw-r--r--src/base/abci/fahout cut.c357
-rw-r--r--src/base/abci/module.make12
-rw-r--r--src/base/cmd/cmd.c92
-rw-r--r--src/base/cmd/cmd.h30
-rw-r--r--src/base/cmd/cmdAlias.c6
-rw-r--r--src/base/cmd/cmdApi.c19
-rw-r--r--src/base/cmd/cmdFlag.c10
-rw-r--r--src/base/cmd/cmdHist.c8
-rw-r--r--src/base/cmd/cmdInt.h14
-rw-r--r--src/base/cmd/cmdLoad.c226
-rw-r--r--src/base/cmd/cmdPlugin.c629
-rw-r--r--src/base/cmd/cmdUtils.c60
-rw-r--r--src/base/cmd/module.make2
-rw-r--r--src/base/io/io.c279
-rw-r--r--src/base/io/ioAbc.h26
-rw-r--r--src/base/io/ioInt.h8
-rw-r--r--src/base/io/ioReadAiger.c27
-rw-r--r--src/base/io/ioReadBaf.c15
-rw-r--r--src/base/io/ioReadBblif.c15
-rw-r--r--src/base/io/ioReadBench.c61
-rw-r--r--src/base/io/ioReadBlif.c113
-rw-r--r--src/base/io/ioReadBlifAig.c77
-rw-r--r--src/base/io/ioReadBlifMv.c380
-rw-r--r--src/base/io/ioReadDsd.c13
-rw-r--r--src/base/io/ioReadEdif.c103
-rw-r--r--src/base/io/ioReadEqn.c31
-rw-r--r--src/base/io/ioReadPla.c45
-rw-r--r--src/base/io/ioReadVerilog.c10
-rw-r--r--src/base/io/ioUtil.c83
-rw-r--r--src/base/io/ioWriteAiger.c12
-rw-r--r--src/base/io/ioWriteBaf.c15
-rw-r--r--src/base/io/ioWriteBblif.c11
-rw-r--r--src/base/io/ioWriteBench.c11
-rw-r--r--src/base/io/ioWriteBlif.c169
-rw-r--r--src/base/io/ioWriteBlifMv.c59
-rw-r--r--src/base/io/ioWriteBook.c99
-rw-r--r--src/base/io/ioWriteCnf.c7
-rw-r--r--src/base/io/ioWriteDot.c67
-rw-r--r--src/base/io/ioWriteEqn.c9
-rw-r--r--src/base/io/ioWriteGml.c5
-rw-r--r--src/base/io/ioWriteList.c5
-rw-r--r--src/base/io/ioWritePla.c11
-rw-r--r--src/base/io/ioWriteSmv.c265
-rw-r--r--src/base/io/ioWriteVerilog.c19
-rw-r--r--src/base/io/module.make3
-rw-r--r--src/base/main/libSupport.c16
-rw-r--r--src/base/main/main.c115
-rw-r--r--src/base/main/main.h46
-rw-r--r--src/base/main/mainFrame.c115
-rw-r--r--src/base/main/mainInit.c17
-rw-r--r--src/base/main/mainInt.h40
-rw-r--r--src/base/main/mainLib.c93
-rw-r--r--src/base/main/mainMC.c5
-rw-r--r--src/base/main/mainUtils.c35
-rw-r--r--src/base/main/module.make1
-rw-r--r--src/base/seq/seq.h18
-rw-r--r--src/base/seq/seqAigCore.c34
-rw-r--r--src/base/seq/seqAigIter.c5
-rw-r--r--src/base/seq/seqCreate.c13
-rw-r--r--src/base/seq/seqFpgaCore.c37
-rw-r--r--src/base/seq/seqFpgaIter.c5
-rw-r--r--src/base/seq/seqInt.h16
-rw-r--r--src/base/seq/seqLatch.c5
-rw-r--r--src/base/seq/seqMan.c7
-rw-r--r--src/base/seq/seqMapCore.c37
-rw-r--r--src/base/seq/seqMapIter.c5
-rw-r--r--src/base/seq/seqMaxMeanCycle.c7
-rw-r--r--src/base/seq/seqRetCore.c15
-rw-r--r--src/base/seq/seqRetIter.c23
-rw-r--r--src/base/seq/seqShare.c17
-rw-r--r--src/base/seq/seqUtil.c5
-rw-r--r--src/base/temp.c83
-rw-r--r--src/base/ver/ver.h16
-rw-r--r--src/base/ver/verCore.c173
-rw-r--r--src/base/ver/verFormula.c33
-rw-r--r--src/base/ver/verParse.c5
-rw-r--r--src/base/ver/verStream.c5
-rw-r--r--src/base/ver/verWords.c5
-rw-r--r--src/base/ver/ver_.c5
-rw-r--r--src/bdd/cas/cas.h16
-rw-r--r--src/bdd/cas/casCore.c19
-rw-r--r--src/bdd/cas/casDec.c5
-rw-r--r--src/bdd/cudd/cudd.h22
-rw-r--r--src/bdd/cudd/cuddAPI.c9
-rw-r--r--src/bdd/cudd/cuddAddAbs.c5
-rw-r--r--src/bdd/cudd/cuddAddApply.c5
-rw-r--r--src/bdd/cudd/cuddAddFind.c5
-rw-r--r--src/bdd/cudd/cuddAddInv.c5
-rw-r--r--src/bdd/cudd/cuddAddIte.c5
-rw-r--r--src/bdd/cudd/cuddAddNeg.c5
-rw-r--r--src/bdd/cudd/cuddAddWalsh.c5
-rw-r--r--src/bdd/cudd/cuddAndAbs.c5
-rw-r--r--src/bdd/cudd/cuddAnneal.c5
-rw-r--r--src/bdd/cudd/cuddApa.c13
-rw-r--r--src/bdd/cudd/cuddApprox.c7
-rw-r--r--src/bdd/cudd/cuddBddAbs.c5
-rw-r--r--src/bdd/cudd/cuddBddCorr.c17
-rw-r--r--src/bdd/cudd/cuddBddIte.c5
-rw-r--r--src/bdd/cudd/cuddBridge.c9
-rw-r--r--src/bdd/cudd/cuddCache.c9
-rw-r--r--src/bdd/cudd/cuddCheck.c9
-rw-r--r--src/bdd/cudd/cuddClip.c5
-rw-r--r--src/bdd/cudd/cuddCof.c5
-rw-r--r--src/bdd/cudd/cuddCompose.c5
-rw-r--r--src/bdd/cudd/cuddDecomp.c47
-rw-r--r--src/bdd/cudd/cuddEssent.c5
-rw-r--r--src/bdd/cudd/cuddExact.c5
-rw-r--r--src/bdd/cudd/cuddExport.c17
-rw-r--r--src/bdd/cudd/cuddGenCof.c21
-rw-r--r--src/bdd/cudd/cuddGenetic.c15
-rw-r--r--src/bdd/cudd/cuddGroup.c7
-rw-r--r--src/bdd/cudd/cuddHarwell.c5
-rw-r--r--src/bdd/cudd/cuddInit.c8
-rw-r--r--src/bdd/cudd/cuddInt.h21
-rw-r--r--src/bdd/cudd/cuddInteract.c5
-rw-r--r--src/bdd/cudd/cuddLCache.c15
-rw-r--r--src/bdd/cudd/cuddLevelQ.c15
-rw-r--r--src/bdd/cudd/cuddLinear.c5
-rw-r--r--src/bdd/cudd/cuddLiteral.c5
-rw-r--r--src/bdd/cudd/cuddMatMult.c5
-rw-r--r--src/bdd/cudd/cuddPriority.c5
-rw-r--r--src/bdd/cudd/cuddRead.c5
-rw-r--r--src/bdd/cudd/cuddRef.c7
-rw-r--r--src/bdd/cudd/cuddReorder.c15
-rw-r--r--src/bdd/cudd/cuddSat.c11
-rw-r--r--src/bdd/cudd/cuddSign.c7
-rw-r--r--src/bdd/cudd/cuddSolve.c5
-rw-r--r--src/bdd/cudd/cuddSplit.c11
-rw-r--r--src/bdd/cudd/cuddSubsetHB.c11
-rw-r--r--src/bdd/cudd/cuddSubsetSP.c13
-rw-r--r--src/bdd/cudd/cuddSymmetry.c5
-rw-r--r--src/bdd/cudd/cuddTable.c31
-rw-r--r--src/bdd/cudd/cuddUtil.c25
-rw-r--r--src/bdd/cudd/cuddWindow.c5
-rw-r--r--src/bdd/cudd/cuddZddCount.c9
-rw-r--r--src/bdd/cudd/cuddZddFuncs.c5
-rw-r--r--src/bdd/cudd/cuddZddGroup.c5
-rw-r--r--src/bdd/cudd/cuddZddIsop.c5
-rw-r--r--src/bdd/cudd/cuddZddLin.c5
-rw-r--r--src/bdd/cudd/cuddZddMisc.c5
-rw-r--r--src/bdd/cudd/cuddZddPort.c5
-rw-r--r--src/bdd/cudd/cuddZddReord.c7
-rw-r--r--src/bdd/cudd/cuddZddSetop.c5
-rw-r--r--src/bdd/cudd/cuddZddSymm.c5
-rw-r--r--src/bdd/cudd/cuddZddUtil.c9
-rw-r--r--src/bdd/cudd/testcudd.c5
-rw-r--r--src/bdd/dsd/dsd.h16
-rw-r--r--src/bdd/dsd/dsdApi.c5
-rw-r--r--src/bdd/dsd/dsdCheck.c5
-rw-r--r--src/bdd/dsd/dsdInt.h8
-rw-r--r--src/bdd/dsd/dsdLocal.c7
-rw-r--r--src/bdd/dsd/dsdMan.c7
-rw-r--r--src/bdd/dsd/dsdProc.c5
-rw-r--r--src/bdd/dsd/dsdTree.c9
-rw-r--r--src/bdd/epd/epd.c5
-rw-r--r--src/bdd/epd/epd.h7
-rw-r--r--src/bdd/mtr/mtr.h19
-rw-r--r--src/bdd/mtr/mtrBasic.c5
-rw-r--r--src/bdd/mtr/mtrGroup.c5
-rw-r--r--src/bdd/mtr/mtrInt.h8
-rw-r--r--src/bdd/parse/parse.h8
-rw-r--r--src/bdd/parse/parseCore.c13
-rw-r--r--src/bdd/parse/parseEqn.c15
-rw-r--r--src/bdd/parse/parseInt.h16
-rw-r--r--src/bdd/parse/parseStack.c13
-rw-r--r--src/bdd/reo/reo.h16
-rw-r--r--src/bdd/reo/reoApi.c5
-rw-r--r--src/bdd/reo/reoCore.c7
-rw-r--r--src/bdd/reo/reoProfile.c5
-rw-r--r--src/bdd/reo/reoShuffle.c5
-rw-r--r--src/bdd/reo/reoSift.c5
-rw-r--r--src/bdd/reo/reoSwap.c9
-rw-r--r--src/bdd/reo/reoTest.c5
-rw-r--r--src/bdd/reo/reoTransfer.c7
-rw-r--r--src/bdd/reo/reoUnits.c11
-rw-r--r--src/demo.c5
-rw-r--r--src/generic.c5
-rw-r--r--src/generic.h16
-rw-r--r--src/map/amap/amap.h25
-rw-r--r--src/map/amap/amapCore.c12
-rw-r--r--src/map/amap/amapGraph.c7
-rw-r--r--src/map/amap/amapInt.h32
-rw-r--r--src/map/amap/amapLib.c13
-rw-r--r--src/map/amap/amapLiberty.c5
-rw-r--r--src/map/amap/amapMan.c5
-rw-r--r--src/map/amap/amapMatch.c5
-rw-r--r--src/map/amap/amapMerge.c11
-rw-r--r--src/map/amap/amapOutput.c5
-rw-r--r--src/map/amap/amapParse.c22
-rw-r--r--src/map/amap/amapPerm.c9
-rw-r--r--src/map/amap/amapRead.c42
-rw-r--r--src/map/amap/amapRule.c23
-rw-r--r--src/map/amap/amapUniq.c25
-rw-r--r--src/map/cov/cov.h16
-rw-r--r--src/map/cov/covBuild.c21
-rw-r--r--src/map/cov/covCore.c17
-rw-r--r--src/map/cov/covInt.h15
-rw-r--r--src/map/cov/covMan.c5
-rw-r--r--src/map/cov/covMinEsop.c5
-rw-r--r--src/map/cov/covMinMan.c5
-rw-r--r--src/map/cov/covMinSop.c5
-rw-r--r--src/map/cov/covMinUtil.c5
-rw-r--r--src/map/cov/covTest.c21
-rw-r--r--src/map/fpga/fpga.c15
-rw-r--r--src/map/fpga/fpga.h16
-rw-r--r--src/map/fpga/fpgaCore.c5
-rw-r--r--src/map/fpga/fpgaCreate.c7
-rw-r--r--src/map/fpga/fpgaCut.c5
-rw-r--r--src/map/fpga/fpgaCutUtils.c5
-rw-r--r--src/map/fpga/fpgaFanout.c5
-rw-r--r--src/map/fpga/fpgaGENERIC.c5
-rw-r--r--src/map/fpga/fpgaInt.h8
-rw-r--r--src/map/fpga/fpgaLib.c5
-rw-r--r--src/map/fpga/fpgaMatch.c5
-rw-r--r--src/map/fpga/fpgaSwitch.c5
-rw-r--r--src/map/fpga/fpgaTime.c5
-rw-r--r--src/map/fpga/fpgaTruth.c11
-rw-r--r--src/map/fpga/fpgaUtils.c5
-rw-r--r--src/map/fpga/fpgaVec.c5
-rw-r--r--src/map/if/if.h75
-rw-r--r--src/map/if/ifCore.c16
-rw-r--r--src/map/if/ifCut.c49
-rw-r--r--src/map/if/ifLib.c31
-rw-r--r--src/map/if/ifMan.c33
-rw-r--r--src/map/if/ifMap.c46
-rw-r--r--src/map/if/ifReduce.c29
-rw-r--r--src/map/if/ifSeq.c45
-rw-r--r--src/map/if/ifTime.c374
-rw-r--r--src/map/if/ifTruth.c6
-rw-r--r--src/map/if/ifUtil.c71
-rw-r--r--src/map/if/if_.c5
-rw-r--r--src/map/mapper/mapper.c15
-rw-r--r--src/map/mapper/mapper.h21
-rw-r--r--src/map/mapper/mapperCanon.c5
-rw-r--r--src/map/mapper/mapperCore.c5
-rw-r--r--src/map/mapper/mapperCreate.c11
-rw-r--r--src/map/mapper/mapperCut.c5
-rw-r--r--src/map/mapper/mapperCutUtils.c5
-rw-r--r--src/map/mapper/mapperFanout.c5
-rw-r--r--src/map/mapper/mapperGENERIC.c5
-rw-r--r--src/map/mapper/mapperInt.h18
-rw-r--r--src/map/mapper/mapperLib.c7
-rw-r--r--src/map/mapper/mapperMatch.c5
-rw-r--r--src/map/mapper/mapperRefs.c5
-rw-r--r--src/map/mapper/mapperSuper.c5
-rw-r--r--src/map/mapper/mapperSwitch.c5
-rw-r--r--src/map/mapper/mapperTable.c5
-rw-r--r--src/map/mapper/mapperTime.c7
-rw-r--r--src/map/mapper/mapperTree.c7
-rw-r--r--src/map/mapper/mapperTree_old.c7
-rw-r--r--src/map/mapper/mapperTruth.c5
-rw-r--r--src/map/mapper/mapperUtils.c5
-rw-r--r--src/map/mapper/mapperVec.c5
-rw-r--r--src/map/mio/mio.c32
-rw-r--r--src/map/mio/mio.h18
-rw-r--r--src/map/mio/mioApi.c5
-rw-r--r--src/map/mio/mioFunc.c9
-rw-r--r--src/map/mio/mioInt.h8
-rw-r--r--src/map/mio/mioRead.c29
-rw-r--r--src/map/mio/mioUtils.c7
-rw-r--r--src/map/super/super.c11
-rw-r--r--src/map/super/super.h16
-rw-r--r--src/map/super/superAnd.c5
-rw-r--r--src/map/super/superGENERIC.c5
-rw-r--r--src/map/super/superGate.c18
-rw-r--r--src/map/super/superInt.h10
-rw-r--r--src/map/super/superWrite.c5
-rw-r--r--src/misc/avl/avl.c5
-rw-r--r--src/misc/avl/avl.h13
-rw-r--r--src/misc/bzlib/blocksort.c4
-rw-r--r--src/misc/bzlib/bzlib.c45
-rw-r--r--src/misc/bzlib/bzlib.h14
-rw-r--r--src/misc/bzlib/bzlib_private.h8
-rw-r--r--src/misc/bzlib/compress.c5
-rw-r--r--src/misc/bzlib/crctable.c5
-rw-r--r--src/misc/bzlib/decompress.c11
-rw-r--r--src/misc/bzlib/huffman.c5
-rw-r--r--src/misc/bzlib/randtable.c5
-rw-r--r--src/misc/espresso/cofactor.c5
-rw-r--r--src/misc/espresso/cols.c5
-rw-r--r--src/misc/espresso/compl.c5
-rw-r--r--src/misc/espresso/contain.c5
-rw-r--r--src/misc/espresso/cubehack.c5
-rw-r--r--src/misc/espresso/cubestr.c5
-rw-r--r--src/misc/espresso/cvrin.c5
-rw-r--r--src/misc/espresso/cvrm.c5
-rw-r--r--src/misc/espresso/cvrmisc.c5
-rw-r--r--src/misc/espresso/cvrout.c7
-rw-r--r--src/misc/espresso/dominate.c5
-rw-r--r--src/misc/espresso/equiv.c5
-rw-r--r--src/misc/espresso/espresso.c5
-rw-r--r--src/misc/espresso/espresso.h10
-rw-r--r--src/misc/espresso/essen.c5
-rw-r--r--src/misc/espresso/exact.c5
-rw-r--r--src/misc/espresso/expand.c5
-rw-r--r--src/misc/espresso/gasp.c5
-rw-r--r--src/misc/espresso/gimpel.c5
-rw-r--r--src/misc/espresso/globals.c5
-rw-r--r--src/misc/espresso/hack.c5
-rw-r--r--src/misc/espresso/indep.c5
-rw-r--r--src/misc/espresso/irred.c5
-rw-r--r--src/misc/espresso/main.c7
-rw-r--r--src/misc/espresso/map.c5
-rw-r--r--src/misc/espresso/matrix.c5
-rw-r--r--src/misc/espresso/mincov.c5
-rw-r--r--src/misc/espresso/opo.c5
-rw-r--r--src/misc/espresso/pair.c5
-rw-r--r--src/misc/espresso/part.c5
-rw-r--r--src/misc/espresso/primes.c5
-rw-r--r--src/misc/espresso/reduce.c5
-rw-r--r--src/misc/espresso/rows.c5
-rw-r--r--src/misc/espresso/set.c5
-rw-r--r--src/misc/espresso/setc.c5
-rw-r--r--src/misc/espresso/sharp.c5
-rw-r--r--src/misc/espresso/sminterf.c5
-rw-r--r--src/misc/espresso/solution.c5
-rw-r--r--src/misc/espresso/sparse.c5
-rw-r--r--src/misc/espresso/sparse.h8
-rw-r--r--src/misc/espresso/unate.c5
-rw-r--r--src/misc/espresso/util_old.h10
-rw-r--r--src/misc/espresso/verify.c5
-rw-r--r--src/misc/ext/ext.h57
-rw-r--r--src/misc/extra/extra.h36
-rw-r--r--src/misc/extra/extraBddAuto.c5
-rw-r--r--src/misc/extra/extraBddCas.c31
-rw-r--r--src/misc/extra/extraBddImage.c5
-rw-r--r--src/misc/extra/extraBddKmap.c6
-rw-r--r--src/misc/extra/extraBddMisc.c26
-rw-r--r--src/misc/extra/extraBddSymm.c5
-rw-r--r--src/misc/extra/extraBddUnate.c5
-rw-r--r--src/misc/extra/extraUtilBitMatrix.c5
-rw-r--r--src/misc/extra/extraUtilCanon.c603
-rw-r--r--src/misc/extra/extraUtilFile.c37
-rw-r--r--src/misc/extra/extraUtilMemory.c23
-rw-r--r--src/misc/extra/extraUtilMisc.c9
-rw-r--r--src/misc/extra/extraUtilProgress.c9
-rw-r--r--src/misc/extra/extraUtilReader.c7
-rw-r--r--src/misc/extra/extraUtilTruth.c5
-rw-r--r--src/misc/extra/extraUtilUtil.c29
-rw-r--r--src/misc/hash/hash.h8
-rw-r--r--src/misc/hash/hashFlt.h8
-rw-r--r--src/misc/hash/hashInt.h8
-rw-r--r--src/misc/hash/hashPtr.h8
-rw-r--r--src/misc/mvc/mvc.c5
-rw-r--r--src/misc/mvc/mvc.h8
-rw-r--r--src/misc/mvc/mvcApi.c5
-rw-r--r--src/misc/mvc/mvcCompare.c5
-rw-r--r--src/misc/mvc/mvcContain.c5
-rw-r--r--src/misc/mvc/mvcCover.c5
-rw-r--r--src/misc/mvc/mvcCube.c5
-rw-r--r--src/misc/mvc/mvcDivide.c5
-rw-r--r--src/misc/mvc/mvcDivisor.c7
-rw-r--r--src/misc/mvc/mvcList.c5
-rw-r--r--src/misc/mvc/mvcLits.c5
-rw-r--r--src/misc/mvc/mvcMan.c5
-rw-r--r--src/misc/mvc/mvcOpAlg.c5
-rw-r--r--src/misc/mvc/mvcOpBool.c5
-rw-r--r--src/misc/mvc/mvcPrint.c5
-rw-r--r--src/misc/mvc/mvcSort.c5
-rw-r--r--src/misc/mvc/mvcUtils.c5
-rw-r--r--src/misc/nm/nm.h16
-rw-r--r--src/misc/nm/nmApi.c7
-rw-r--r--src/misc/nm/nmInt.h16
-rw-r--r--src/misc/nm/nmTable.c5
-rw-r--r--src/misc/st/st.c241
-rw-r--r--src/misc/st/st.h50
-rw-r--r--src/misc/st/stmm.c259
-rw-r--r--src/misc/st/stmm.h39
-rw-r--r--src/misc/util/abc_global.h133
-rw-r--r--src/misc/util/module.make2
-rw-r--r--src/misc/util/utilFile.c170
-rw-r--r--src/misc/util/utilMem.c341
-rw-r--r--src/misc/util/utilMem.h73
-rw-r--r--src/misc/util/util_hack.h24
-rw-r--r--src/misc/vec/vec.h18
-rw-r--r--src/misc/vec/vecAtt.h12
-rw-r--r--src/misc/vec/vecFlt.h40
-rw-r--r--src/misc/vec/vecInt.h176
-rw-r--r--src/misc/vec/vecPtr.h144
-rw-r--r--src/misc/vec/vecStr.h111
-rw-r--r--src/misc/vec/vecVec.h55
-rw-r--r--src/misc/vec/vecWrd.h1071
-rw-r--r--src/misc/zlib/README86
-rw-r--r--src/misc/zlib/adler32.c49
-rw-r--r--src/misc/zlib/compress_.c27
-rw-r--r--src/misc/zlib/crc32.c70
-rw-r--r--src/misc/zlib/crc32.h4
-rw-r--r--src/misc/zlib/deflate.c384
-rw-r--r--src/misc/zlib/deflate.h39
-rw-r--r--src/misc/zlib/gzclose.c33
-rw-r--r--src/misc/zlib/gzguts.h147
-rw-r--r--src/misc/zlib/gzio.c1026
-rw-r--r--src/misc/zlib/gzlib.c517
-rw-r--r--src/misc/zlib/gzread.c641
-rw-r--r--src/misc/zlib/gzwrite.c520
-rw-r--r--src/misc/zlib/infback.c124
-rw-r--r--src/misc/zlib/inffast.c95
-rw-r--r--src/misc/zlib/inffast.h8
-rw-r--r--src/misc/zlib/inffixed.h4
-rw-r--r--src/misc/zlib/inflate.c339
-rw-r--r--src/misc/zlib/inflate.h35
-rw-r--r--src/misc/zlib/inftrees.c82
-rw-r--r--src/misc/zlib/inftrees.h31
-rw-r--r--src/misc/zlib/link.txt2
-rw-r--r--src/misc/zlib/module.make5
-rw-r--r--src/misc/zlib/trees.c187
-rw-r--r--src/misc/zlib/trees.h8
-rw-r--r--src/misc/zlib/uncompr.c22
-rw-r--r--src/misc/zlib/zconf.h194
-rw-r--r--src/misc/zlib/zlib.h1173
-rw-r--r--src/misc/zlib/zutil.c62
-rw-r--r--src/misc/zlib/zutil.h77
-rw-r--r--src/opt/cut/abcCut.c9
-rw-r--r--src/opt/cut/cut.h16
-rw-r--r--src/opt/cut/cutApi.c11
-rw-r--r--src/opt/cut/cutCut.c5
-rw-r--r--src/opt/cut/cutExpand.c5
-rw-r--r--src/opt/cut/cutInt.h8
-rw-r--r--src/opt/cut/cutList.h8
-rw-r--r--src/opt/cut/cutMan.c5
-rw-r--r--src/opt/cut/cutMerge.c5
-rw-r--r--src/opt/cut/cutNode.c27
-rw-r--r--src/opt/cut/cutOracle.c17
-rw-r--r--src/opt/cut/cutPre22.c7
-rw-r--r--src/opt/cut/cutSeq.c5
-rw-r--r--src/opt/cut/cutTruth.c5
-rw-r--r--src/opt/dec/dec.h25
-rw-r--r--src/opt/dec/decAbc.c53
-rw-r--r--src/opt/dec/decFactor.c17
-rw-r--r--src/opt/dec/decMan.c7
-rw-r--r--src/opt/dec/decPrint.c5
-rw-r--r--src/opt/dec/decUtil.c11
-rw-r--r--src/opt/fret/fretFlow.c13
-rw-r--r--src/opt/fret/fretInit.c21
-rw-r--r--src/opt/fret/fretMain.c17
-rw-r--r--src/opt/fret/fretTime.c39
-rw-r--r--src/opt/fret/fretime.h30
-rw-r--r--src/opt/fxu/fxu.c5
-rw-r--r--src/opt/fxu/fxu.h32
-rw-r--r--src/opt/fxu/fxuCreate.c17
-rw-r--r--src/opt/fxu/fxuHeapD.c5
-rw-r--r--src/opt/fxu/fxuHeapS.c5
-rw-r--r--src/opt/fxu/fxuInt.h8
-rw-r--r--src/opt/fxu/fxuList.c5
-rw-r--r--src/opt/fxu/fxuMatrix.c5
-rw-r--r--src/opt/fxu/fxuPair.c5
-rw-r--r--src/opt/fxu/fxuPrint.c5
-rw-r--r--src/opt/fxu/fxuReduce.c11
-rw-r--r--src/opt/fxu/fxuSelect.c5
-rw-r--r--src/opt/fxu/fxuSingle.c9
-rw-r--r--src/opt/fxu/fxuUpdate.c9
-rw-r--r--src/opt/lpk/lpk.h16
-rw-r--r--src/opt/lpk/lpkAbcDec.c23
-rw-r--r--src/opt/lpk/lpkAbcDsd.c5
-rw-r--r--src/opt/lpk/lpkAbcMux.c5
-rw-r--r--src/opt/lpk/lpkAbcUtil.c7
-rw-r--r--src/opt/lpk/lpkCore.c13
-rw-r--r--src/opt/lpk/lpkCut.c33
-rw-r--r--src/opt/lpk/lpkInt.h16
-rw-r--r--src/opt/lpk/lpkMan.c5
-rw-r--r--src/opt/lpk/lpkMap.c13
-rw-r--r--src/opt/lpk/lpkMulti.c5
-rw-r--r--src/opt/lpk/lpkMux.c33
-rw-r--r--src/opt/lpk/lpkSets.c9
-rw-r--r--src/opt/lpk/lpk_.c5
-rw-r--r--src/opt/mfs/mfs.h16
-rw-r--r--src/opt/mfs/mfsCore.c21
-rw-r--r--src/opt/mfs/mfsCore_.c5
-rw-r--r--src/opt/mfs/mfsDiv.c17
-rw-r--r--src/opt/mfs/mfsGia.c299
-rw-r--r--src/opt/mfs/mfsInt.h16
-rw-r--r--src/opt/mfs/mfsInter.c13
-rw-r--r--src/opt/mfs/mfsMan.c5
-rw-r--r--src/opt/mfs/mfsResub.c25
-rw-r--r--src/opt/mfs/mfsResub_.c5
-rw-r--r--src/opt/mfs/mfsSat.c7
-rw-r--r--src/opt/mfs/mfsStrash.c51
-rw-r--r--src/opt/mfs/mfsWin.c5
-rw-r--r--src/opt/mfs/mfs_.c5
-rw-r--r--src/opt/res/res.h16
-rw-r--r--src/opt/res/resCore.c17
-rw-r--r--src/opt/res/resDivs.c15
-rw-r--r--src/opt/res/resFilter.c27
-rw-r--r--src/opt/res/resInt.h16
-rw-r--r--src/opt/res/resSat.c49
-rw-r--r--src/opt/res/resSim.c59
-rw-r--r--src/opt/res/resSim_old.c9
-rw-r--r--src/opt/res/resStrash.c21
-rw-r--r--src/opt/res/resWin.c21
-rw-r--r--src/opt/res/res_.c5
-rw-r--r--src/opt/ret/retArea.c33
-rw-r--r--src/opt/ret/retCore.c21
-rw-r--r--src/opt/ret/retDelay.c28
-rw-r--r--src/opt/ret/retFlow.c27
-rw-r--r--src/opt/ret/retIncrem.c35
-rw-r--r--src/opt/ret/retInit.c29
-rw-r--r--src/opt/ret/retInt.h14
-rw-r--r--src/opt/ret/retLvalue.c11
-rw-r--r--src/opt/ret/ret_.c5
-rw-r--r--src/opt/rwr/rwr.h20
-rw-r--r--src/opt/rwr/rwrDec.c7
-rw-r--r--src/opt/rwr/rwrEva.c54
-rw-r--r--src/opt/rwr/rwrExp.c11
-rw-r--r--src/opt/rwr/rwrLib.c15
-rw-r--r--src/opt/rwr/rwrMan.c11
-rw-r--r--src/opt/rwr/rwrPrint.c9
-rw-r--r--src/opt/rwr/rwrTemp.c7
-rw-r--r--src/opt/rwr/rwrUtil.c791
-rw-r--r--src/opt/sim/sim.h24
-rw-r--r--src/opt/sim/simMan.c9
-rw-r--r--src/opt/sim/simSat.c5
-rw-r--r--src/opt/sim/simSeq.c5
-rw-r--r--src/opt/sim/simSupp.c49
-rw-r--r--src/opt/sim/simSwitch.c11
-rw-r--r--src/opt/sim/simSym.c5
-rw-r--r--src/opt/sim/simSymSat.c13
-rw-r--r--src/opt/sim/simSymSim.c17
-rw-r--r--src/opt/sim/simSymStr.c23
-rw-r--r--src/opt/sim/simUtils.c63
-rw-r--r--src/phys/place/libhmetis.h8
-rw-r--r--src/phys/place/place_base.c5
-rw-r--r--src/phys/place/place_base.h8
-rw-r--r--src/phys/place/place_bin.c5
-rw-r--r--src/phys/place/place_genqp.c7
-rw-r--r--src/phys/place/place_gordian.c5
-rw-r--r--src/phys/place/place_gordian.h8
-rw-r--r--src/phys/place/place_inc.c5
-rw-r--r--src/phys/place/place_io.c5
-rw-r--r--src/phys/place/place_legalize.c5
-rw-r--r--src/phys/place/place_pads.c5
-rw-r--r--src/phys/place/place_partition.c5
-rw-r--r--src/phys/place/place_qpsolver.c5
-rw-r--r--src/phys/place/place_qpsolver.h8
-rw-r--r--src/phys/place/place_test.c5
-rw-r--r--src/python/abc.sh78
-rw-r--r--src/python/abcpy_test.py54
-rw-r--r--src/python/build.txt32
-rw-r--r--src/python/module.make64
-rw-r--r--src/python/package.py124
-rw-r--r--src/python/pyabc.i330
-rw-r--r--src/python/setup.py64
-rw-r--r--src/sat/bsat/satChecker.c5
-rw-r--r--src/sat/bsat/satInter.c7
-rw-r--r--src/sat/bsat/satInterA.c10
-rw-r--r--src/sat/bsat/satInterA_mod.c5
-rw-r--r--src/sat/bsat/satInterA_old.c5
-rw-r--r--src/sat/bsat/satInterA_yu_hu.c5
-rw-r--r--src/sat/bsat/satInterB.c84
-rw-r--r--src/sat/bsat/satInterB_.c1060
-rw-r--r--src/sat/bsat/satInterB_new.c1115
-rw-r--r--src/sat/bsat/satInterB_old.c1061
-rw-r--r--src/sat/bsat/satInterP.c91
-rw-r--r--src/sat/bsat/satMem.c22
-rw-r--r--src/sat/bsat/satMem.h8
-rw-r--r--src/sat/bsat/satSolver.c197
-rw-r--r--src/sat/bsat/satSolver.h34
-rw-r--r--src/sat/bsat/satStore.c7
-rw-r--r--src/sat/bsat/satStore.h15
-rw-r--r--src/sat/bsat/satTrace.c5
-rw-r--r--src/sat/bsat/satUtil.c19
-rw-r--r--src/sat/bsat/satVec.h11
-rw-r--r--src/sat/csat/csat_apis.c29
-rw-r--r--src/sat/csat/csat_apis.h16
-rw-r--r--src/sat/fraig/fraig.h16
-rw-r--r--src/sat/fraig/fraigApi.c5
-rw-r--r--src/sat/fraig/fraigCanon.c5
-rw-r--r--src/sat/fraig/fraigChoice.c5
-rw-r--r--src/sat/fraig/fraigFanout.c5
-rw-r--r--src/sat/fraig/fraigFeed.c7
-rw-r--r--src/sat/fraig/fraigInt.h12
-rw-r--r--src/sat/fraig/fraigMan.c11
-rw-r--r--src/sat/fraig/fraigMem.c15
-rw-r--r--src/sat/fraig/fraigNode.c5
-rw-r--r--src/sat/fraig/fraigPrime.c5
-rw-r--r--src/sat/fraig/fraigSat.c14
-rw-r--r--src/sat/fraig/fraigTable.c5
-rw-r--r--src/sat/fraig/fraigUtil.c7
-rw-r--r--src/sat/fraig/fraigVec.c5
-rw-r--r--src/sat/lsat/solver.h14
-rw-r--r--src/sat/msat/msat.h36
-rw-r--r--src/sat/msat/msatActivity.c5
-rw-r--r--src/sat/msat/msatClause.c31
-rw-r--r--src/sat/msat/msatClauseVec.c5
-rw-r--r--src/sat/msat/msatInt.h37
-rw-r--r--src/sat/msat/msatMem.c21
-rw-r--r--src/sat/msat/msatOrderH.c5
-rw-r--r--src/sat/msat/msatOrderJ.c5
-rw-r--r--src/sat/msat/msatQueue.c5
-rw-r--r--src/sat/msat/msatRead.c13
-rw-r--r--src/sat/msat/msatSolverApi.c9
-rw-r--r--src/sat/msat/msatSolverCore.c13
-rw-r--r--src/sat/msat/msatSolverIo.c5
-rw-r--r--src/sat/msat/msatSolverSearch.c11
-rw-r--r--src/sat/msat/msatSort.c5
-rw-r--r--src/sat/msat/msatVec.c5
-rw-r--r--src/sat/proof/pr.c22
-rw-r--r--src/sat/proof/pr.h16
-rw-r--r--src/sat/psat/m114p.h8
-rw-r--r--src/sat/psat/m114p_types.h8
1098 files changed, 71659 insertions, 20429 deletions
diff --git a/src/aig/aig/aig.h b/src/aig/aig/aig.h
index 45b509dc..385d93b2 100644
--- a/src/aig/aig/aig.h
+++ b/src/aig/aig/aig.h
@@ -21,6 +21,7 @@
#ifndef __AIG_H__
#define __AIG_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -37,9 +38,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -105,6 +107,7 @@ struct Aig_Man_t_
int nTruePis; // the number of true primary inputs
int nTruePos; // the number of true primary outputs
int nAsserts; // the number of asserts among POs (asserts are first POs)
+ int nConstrs; // the number of constraints (model checking only)
// AIG node counters
int nObjs[AIG_OBJ_VOID];// the number of objects by type
int nCreated; // the number of created objects
@@ -148,7 +151,8 @@ struct Aig_Man_t_
Vec_Ptr_t * vMapped;
Vec_Int_t * vFlopNums;
Vec_Int_t * vFlopReprs;
- void * pSeqModel;
+ Abc_Cex_t * pSeqModel;
+ Vec_Ptr_t * pSeqModelVec; // vector of counter-examples (for sequential miters)
Aig_Man_t * pManExdc;
Vec_Ptr_t * vOnehots;
Aig_Man_t * pManHaig;
@@ -217,10 +221,12 @@ static inline Aig_Cut_t * Aig_CutNext( Aig_Cut_t * pCut ) { return
////////////////////////////////////////////////////////////////////////
static inline int Aig_IntAbs( int n ) { return (n < 0)? -n : n; }
-static inline int Aig_Float2Int( float Val ) { return *((int *)&Val); }
-static inline float Aig_Int2Float( int Num ) { return *((float *)&Num); }
-static inline int Aig_Base2Log( unsigned n ) { int r; assert( n >= 0 ); if ( n < 2 ) return n; for ( r = 0, n--; n; n >>= 1, r++ ); return r; }
-static inline int Aig_Base10Log( unsigned n ) { int r; assert( n >= 0 ); if ( n < 2 ) return n; for ( r = 0, n--; n; n /= 10, r++ ); return r; }
+//static inline int Aig_Float2Int( float Val ) { return *((int *)&Val); }
+//static inline float Aig_Int2Float( int Num ) { return *((float *)&Num); }
+static inline int Aig_Float2Int( float Val ) { union { int x; float y; } v; v.y = Val; return v.x; }
+static inline float Aig_Int2Float( int Num ) { union { int x; float y; } v; v.x = Num; return v.y; }
+static inline int Aig_Base2Log( unsigned n ) { int r; if ( n < 2 ) return n; for ( r = 0, n--; n; n >>= 1, r++ ); return r; }
+static inline int Aig_Base10Log( unsigned n ) { int r; if ( n < 2 ) return n; for ( r = 0, n--; n; n /= 10, r++ ); return r; }
static inline char * Aig_UtilStrsav( char * s ) { return s ? strcpy(ABC_ALLOC(char, strlen(s)+1), s) : NULL; }
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)); }
@@ -261,6 +267,7 @@ static inline int Aig_ManGetCost( Aig_Man_t * p ) { return p->nO
static inline int Aig_ManObjNum( Aig_Man_t * p ) { return p->nCreated - p->nDeleted; }
static inline int Aig_ManObjNumMax( Aig_Man_t * p ) { return Vec_PtrSize(p->vObjs); }
static inline int Aig_ManRegNum( Aig_Man_t * p ) { return p->nRegs; }
+static inline int Aig_ManConstrNum( Aig_Man_t * p ) { return p->nConstrs; }
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; }
@@ -284,6 +291,7 @@ static inline int Aig_ObjIsNode( Aig_Obj_t * pObj ) { return pObj-
static inline int Aig_ObjIsTerm( Aig_Obj_t * pObj ) { return pObj->Type == AIG_OBJ_PI || pObj->Type == AIG_OBJ_PO || pObj->Type == AIG_OBJ_CONST1; }
static inline int Aig_ObjIsHash( Aig_Obj_t * pObj ) { return pObj->Type == AIG_OBJ_AND || pObj->Type == AIG_OBJ_EXOR; }
static inline int Aig_ObjIsChoice( Aig_Man_t * p, Aig_Obj_t * pObj ) { return p->pEquivs && p->pEquivs[pObj->Id] && pObj->nRefs > 0; }
+static inline int Aig_ObjIsCand( Aig_Obj_t * pObj ) { return pObj->Type == AIG_OBJ_PI || pObj->Type == AIG_OBJ_AND || pObj->Type == AIG_OBJ_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; }
@@ -315,6 +323,9 @@ static inline Aig_Obj_t * Aig_ObjChild0Next( Aig_Obj_t * pObj ) { assert( !Aig
static inline Aig_Obj_t * Aig_ObjChild1Next( Aig_Obj_t * pObj ) { assert( !Aig_IsComplement(pObj) ); return Aig_ObjFanin1(pObj)? Aig_NotCond((Aig_Obj_t *)Aig_ObjFanin1(pObj)->pNext, Aig_ObjFaninC1(pObj)) : NULL; }
static inline void Aig_ObjChild0Flip( Aig_Obj_t * pObj ) { assert( !Aig_IsComplement(pObj) ); pObj->pFanin0 = Aig_Not(pObj->pFanin0); }
static inline void Aig_ObjChild1Flip( Aig_Obj_t * pObj ) { assert( !Aig_IsComplement(pObj) ); pObj->pFanin1 = Aig_Not(pObj->pFanin1); }
+static inline Aig_Obj_t * Aig_ObjCopy( Aig_Obj_t * pObj ) { assert( !Aig_IsComplement(pObj) ); return (Aig_Obj_t *)pObj->pData; }
+static inline void Aig_ObjSetCopy( Aig_Obj_t * pObj, Aig_Obj_t * pCopy ) { assert( !Aig_IsComplement(pObj) ); pObj->pData = pCopy; }
+static inline Aig_Obj_t * Aig_ObjRealCopy( Aig_Obj_t * pObj ) { return Aig_NotCond((Aig_Obj_t *)Aig_Regular(pObj)->pData, Aig_IsComplement(pObj));}
static inline int Aig_ObjLevel( Aig_Obj_t * pObj ) { assert( !Aig_IsComplement(pObj) ); return pObj->Level; }
static inline int Aig_ObjLevelNew( Aig_Obj_t * pObj ) { assert( !Aig_IsComplement(pObj) ); return Aig_ObjFanin1(pObj)? 1 + Aig_ObjIsExor(pObj) + ABC_MAX(Aig_ObjFanin0(pObj)->Level, Aig_ObjFanin1(pObj)->Level) : Aig_ObjFanin0(pObj)->Level; }
static inline int Aig_ObjSetLevel( Aig_Obj_t * pObj, int i ) { assert( !Aig_IsComplement(pObj) ); return pObj->Level = i; }
@@ -388,22 +399,22 @@ static inline void Aig_ManRecycleMemory( Aig_Man_t * p, Aig_Obj_t * pEntry )
// iterator over the primary inputs
#define Aig_ManForEachPi( p, pObj, i ) \
- Vec_PtrForEachEntry( p->vPis, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vPis, pObj, i )
// iterator over the primary outputs
#define Aig_ManForEachPo( p, pObj, i ) \
- Vec_PtrForEachEntry( p->vPos, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vPos, pObj, i )
// iterator over the assertions
#define Aig_ManForEachAssert( p, pObj, i ) \
- Vec_PtrForEachEntryStart( p->vPos, pObj, i, Aig_ManPoNum(p)-p->nAsserts )
+ Vec_PtrForEachEntryStart( Aig_Obj_t *, p->vPos, pObj, i, Aig_ManPoNum(p)-p->nAsserts )
// iterator over all objects, including those currently not used
#define Aig_ManForEachObj( p, pObj, i ) \
- Vec_PtrForEachEntry( p->vObjs, pObj, i ) if ( (pObj) == NULL ) {} else
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vObjs, pObj, i ) if ( (pObj) == NULL ) {} else
// iterator over all nodes
#define Aig_ManForEachNode( p, pObj, i ) \
- Vec_PtrForEachEntry( p->vObjs, pObj, i ) if ( (pObj) == NULL || !Aig_ObjIsNode(pObj) ) {} else
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vObjs, pObj, i ) if ( (pObj) == NULL || !Aig_ObjIsNode(pObj) ) {} else
// iterator over all nodes
#define Aig_ManForEachExor( p, pObj, i ) \
- Vec_PtrForEachEntry( p->vObjs, pObj, i ) if ( (pObj) == NULL || !Aig_ObjIsExor(pObj) ) {} else
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vObjs, pObj, i ) if ( (pObj) == NULL || !Aig_ObjIsExor(pObj) ) {} else
// iterator over the nodes whose IDs are stored in the array
#define Aig_ManForEachNodeVec( p, vIds, pObj, i ) \
for ( i = 0; i < Vec_IntSize(vIds) && ((pObj) = Aig_ManObj(p, Vec_IntEntry(vIds,i))); i++ )
@@ -429,16 +440,16 @@ static inline int Aig_ObjFanoutNext( Aig_Man_t * p, int iFan ) { assert(iF
// iterator over the primary inputs
#define Aig_ManForEachPiSeq( p, pObj, i ) \
- Vec_PtrForEachEntryStop( p->vPis, pObj, i, Aig_ManPiNum(p)-Aig_ManRegNum(p) )
+ Vec_PtrForEachEntryStop( Aig_Obj_t *, p->vPis, pObj, i, Aig_ManPiNum(p)-Aig_ManRegNum(p) )
// iterator over the latch outputs
#define Aig_ManForEachLoSeq( p, pObj, i ) \
- Vec_PtrForEachEntryStart( p->vPis, pObj, i, Aig_ManPiNum(p)-Aig_ManRegNum(p) )
+ Vec_PtrForEachEntryStart( Aig_Obj_t *, p->vPis, pObj, i, Aig_ManPiNum(p)-Aig_ManRegNum(p) )
// iterator over the primary outputs
#define Aig_ManForEachPoSeq( p, pObj, i ) \
- Vec_PtrForEachEntryStop( p->vPos, pObj, i, Aig_ManPoNum(p)-Aig_ManRegNum(p) )
+ Vec_PtrForEachEntryStop( Aig_Obj_t *, p->vPos, pObj, i, Aig_ManPoNum(p)-Aig_ManRegNum(p) )
// iterator over the latch inputs
#define Aig_ManForEachLiSeq( p, pObj, i ) \
- Vec_PtrForEachEntryStart( p->vPos, pObj, i, Aig_ManPoNum(p)-Aig_ManRegNum(p) )
+ Vec_PtrForEachEntryStart( Aig_Obj_t *, p->vPos, pObj, i, Aig_ManPoNum(p)-Aig_ManRegNum(p) )
// iterator over the latch input and outputs
#define Aig_ManForEachLiLoSeq( p, pObjLi, pObjLo, k ) \
for ( k = 0; (k < Aig_ManRegNum(p)) && (((pObjLi) = Aig_ManLi(p, k)), 1) \
@@ -475,10 +486,13 @@ extern Aig_Obj_t * Aig_Compose( Aig_Man_t * p, Aig_Obj_t * pRoot, Aig_Obj_t
extern void Aig_ObjCollectCut( Aig_Obj_t * pRoot, Vec_Ptr_t * vLeaves, Vec_Ptr_t * vNodes );
extern int Aig_ObjCollectSuper( Aig_Obj_t * pObj, Vec_Ptr_t * vSuper );
/*=== aigDup.c ==========================================================*/
+extern Aig_Obj_t * Aig_ManDupSimpleDfs_rec( Aig_Man_t * pNew, Aig_Man_t * p, Aig_Obj_t * pObj );
extern Aig_Man_t * Aig_ManDupSimple( Aig_Man_t * p );
+extern Aig_Man_t * Aig_ManDupSimpleWithHints( Aig_Man_t * p, Vec_Int_t * vHints );
extern Aig_Man_t * Aig_ManDupSimpleDfs( Aig_Man_t * p );
extern Aig_Man_t * Aig_ManDupSimpleDfsPart( Aig_Man_t * p, Vec_Ptr_t * vPis, Vec_Ptr_t * vPos );
extern Aig_Man_t * Aig_ManDupOrdered( Aig_Man_t * p );
+extern Aig_Man_t * Aig_ManDupCof( Aig_Man_t * p, int iInput, int Value );
extern Aig_Man_t * Aig_ManDupTrim( Aig_Man_t * p );
extern Aig_Man_t * Aig_ManDupExor( Aig_Man_t * p );
extern Aig_Man_t * Aig_ManDupDfs( Aig_Man_t * p );
@@ -503,7 +517,8 @@ extern Aig_Man_t * Aig_ManFrames( Aig_Man_t * pAig, int nFs, int fInit, int
extern Aig_Man_t * Aig_ManStart( int nNodesMax );
extern Aig_Man_t * Aig_ManStartFrom( Aig_Man_t * p );
extern Aig_Man_t * Aig_ManExtractMiter( Aig_Man_t * p, Aig_Obj_t * pNode1, Aig_Obj_t * pNode2 );
-extern ABC_DLL void Aig_ManStop( Aig_Man_t * p );
+extern void Aig_ManStop( Aig_Man_t * p );
+extern void Aig_ManStopP( Aig_Man_t ** p );
extern int Aig_ManCleanup( Aig_Man_t * p );
extern int Aig_ManAntiCleanup( Aig_Man_t * p );
extern int Aig_ManPiCleanup( Aig_Man_t * p );
@@ -512,6 +527,7 @@ extern void Aig_ManPrintStats( Aig_Man_t * p );
extern void Aig_ManReportImprovement( Aig_Man_t * p, Aig_Man_t * pNew );
extern void Aig_ManSetRegNum( Aig_Man_t * p, int nRegs );
extern void Aig_ManFlipFirstPo( Aig_Man_t * p );
+extern void * Aig_ManReleaseData( Aig_Man_t * p );
/*=== aigMem.c ==========================================================*/
extern void Aig_ManStartMemory( Aig_Man_t * p );
extern void Aig_ManStopMemory( Aig_Man_t * p );
@@ -620,6 +636,7 @@ extern Aig_Man_t * Aig_ManConstReduce( Aig_Man_t * p, int fVerbose );
/*=== aigUtil.c =========================================================*/
extern unsigned Aig_PrimeCudd( unsigned p );
extern void Aig_ManIncrementTravId( Aig_Man_t * p );
+extern char * Aig_TimeStamp();
extern int Aig_ManHasNoGaps( Aig_Man_t * p );
extern int Aig_ManLevels( Aig_Man_t * p );
extern void Aig_ManResetRefs( Aig_Man_t * p );
@@ -650,6 +667,10 @@ extern unsigned Aig_ManRandom( int fReset );
extern void Aig_ManRandomInfo( Vec_Ptr_t * vInfo, int iInputStart, int iWordStart, int iWordStop );
extern void Aig_NodeUnionLists( Vec_Ptr_t * vArr1, Vec_Ptr_t * vArr2, Vec_Ptr_t * vArr );
extern void Aig_NodeIntersectLists( Vec_Ptr_t * vArr1, Vec_Ptr_t * vArr2, Vec_Ptr_t * vArr );
+extern void Aig_ManSetPhase( Aig_Man_t * pAig );
+extern Vec_Ptr_t * Aig_ManMuxesCollect( Aig_Man_t * pAig );
+extern void Aig_ManMuxesDeref( Aig_Man_t * pAig, Vec_Ptr_t * vMuxes );
+extern void Aig_ManMuxesRef( Aig_Man_t * pAig, Vec_Ptr_t * vMuxes );
/*=== aigWin.c =========================================================*/
extern void Aig_ManFindCut( Aig_Obj_t * pRoot, Vec_Ptr_t * vFront, Vec_Ptr_t * vVisited, int nSizeLimit, int nFanoutLimit );
@@ -676,9 +697,11 @@ extern char * Aig_MmStepEntryFetch( Aig_MmStep_t * p, int nBytes );
extern void Aig_MmStepEntryRecycle( Aig_MmStep_t * p, char * pEntry, int nBytes );
extern int Aig_MmStepReadMemUsage( Aig_MmStep_t * p );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/aig/aig/aigCanon.c b/src/aig/aig/aigCanon.c
index 4f241842..706a9c61 100644
--- a/src/aig/aig/aigCanon.c
+++ b/src/aig/aig/aigCanon.c
@@ -21,6 +21,10 @@
#include "aig.h"
#include "kit.h"
#include "bdc.h"
+#include "ioa.h"
+
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -277,7 +281,7 @@ void Aig_RManStop( Aig_RMan_t * p )
***********************************************************************/
void Aig_RManQuit()
{
- extern void Ioa_WriteAiger( Aig_Man_t * pMan, char * pFileName, int fWriteSymbols, int fCompact );
+// extern void Ioa_WriteAiger( Aig_Man_t * pMan, char * pFileName, int fWriteSymbols, int fCompact );
char Buffer[20];
if ( s_pRMan == NULL )
return;
@@ -537,7 +541,7 @@ unsigned Aig_RManSemiCanonicize( unsigned * pOut, unsigned * pIn, int nVars, cha
***********************************************************************/
static inline Aig_Obj_t * Bdc_FunCopyHop( Bdc_Fun_t * pObj )
-{ return Aig_NotCond( Bdc_FuncCopy(Bdc_Regular(pObj)), Bdc_IsComplement(pObj) ); }
+{ return Aig_NotCond( (Aig_Obj_t *)Bdc_FuncCopy(Bdc_Regular(pObj)), Bdc_IsComplement(pObj) ); }
/**Function*************************************************************
@@ -692,3 +696,5 @@ Extra_PrintBinary( stdout, s_pRMan->pTruth, 1<<nVars ); printf( "\n\n" );
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/aig/aigCheck.c b/src/aig/aig/aigCheck.c
index 4cfdaaf1..298c5595 100644
--- a/src/aig/aig/aigCheck.c
+++ b/src/aig/aig/aigCheck.c
@@ -20,6 +20,9 @@
#include "aig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -161,3 +164,5 @@ void Aig_ManCheckPhase( Aig_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/aig/aigCuts.c b/src/aig/aig/aigCuts.c
index dc677269..6de19484 100644
--- a/src/aig/aig/aigCuts.c
+++ b/src/aig/aig/aigCuts.c
@@ -21,6 +21,9 @@
#include "aig.h"
#include "kit.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -207,7 +210,7 @@ static inline float Aig_CutFindCost2( Aig_ManCut_t * p, Aig_Cut_t * pCut )
/**Function*************************************************************
- Synopsis [Returns the next ABC_FREE cut to use.]
+ Synopsis [Returns the next free cut to use.]
Description []
@@ -667,3 +670,5 @@ Aig_ManCut_t * Aig_ComputeCuts( Aig_Man_t * pAig, int nCutsMax, int nLeafMax, in
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/aig/aigDfs.c b/src/aig/aig/aigDfs.c
index dfc35c83..6b30611a 100644
--- a/src/aig/aig/aigDfs.c
+++ b/src/aig/aig/aigDfs.c
@@ -21,6 +21,9 @@
#include "aig.h"
#include "tim.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -76,15 +79,15 @@ int Aig_ManVerifyTopoOrder( Aig_Man_t * p )
{
if ( p->pManTime )
{
- iBox = Tim_ManBoxForCi( p->pManTime, Aig_ObjPioNum(pObj) );
+ iBox = Tim_ManBoxForCi( (Tim_Man_t *)p->pManTime, Aig_ObjPioNum(pObj) );
if ( iBox >= 0 ) // this is not a true PI
{
- iTerm1 = Tim_ManBoxInputFirst( p->pManTime, iBox );
- nTerms = Tim_ManBoxInputNum( p->pManTime, iBox );
+ iTerm1 = Tim_ManBoxInputFirst( (Tim_Man_t *)p->pManTime, iBox );
+ nTerms = Tim_ManBoxInputNum( (Tim_Man_t *)p->pManTime, iBox );
for ( k = 0; k < nTerms; k++ )
{
pNext = Aig_ManPo( p, iTerm1 + k );
- assert( Tim_ManBoxForCo( p->pManTime, Aig_ObjPioNum(pNext) ) == iBox );
+ assert( Tim_ManBoxForCo( (Tim_Man_t *)p->pManTime, Aig_ObjPioNum(pNext) ) == iBox );
if ( !Aig_ObjIsTravIdCurrent(p,pNext) )
{
printf( "Box %d has input %d that is not in a topological order.\n", iBox, pNext->Id );
@@ -276,7 +279,10 @@ Vec_Ptr_t * Aig_ManDfsNodes( Aig_Man_t * p, Aig_Obj_t ** ppNodes, int nNodes )
// go through the nodes
vNodes = Vec_PtrAlloc( Aig_ManNodeNum(p) );
for ( i = 0; i < nNodes; i++ )
- Aig_ManDfs_rec( p, ppNodes[i], vNodes );
+ if ( Aig_ObjIsPo(ppNodes[i]) )
+ Aig_ManDfs_rec( p, Aig_ObjFanin0(ppNodes[i]), vNodes );
+ else
+ Aig_ManDfs_rec( p, ppNodes[i], vNodes );
return vNodes;
}
@@ -435,11 +441,11 @@ void Aig_ManChoiceLevel_rec( Aig_Man_t * p, Aig_Obj_t * pObj )
{
if ( p->pManTime )
{
- iBox = Tim_ManBoxForCi( p->pManTime, Aig_ObjPioNum(pObj) );
+ iBox = Tim_ManBoxForCi( (Tim_Man_t *)p->pManTime, Aig_ObjPioNum(pObj) );
if ( iBox >= 0 ) // this is not a true PI
{
- iTerm1 = Tim_ManBoxInputFirst( p->pManTime, iBox );
- nTerms = Tim_ManBoxInputNum( p->pManTime, iBox );
+ iTerm1 = Tim_ManBoxInputFirst( (Tim_Man_t *)p->pManTime, iBox );
+ nTerms = Tim_ManBoxInputNum( (Tim_Man_t *)p->pManTime, iBox );
for ( i = 0; i < nTerms; i++ )
{
pNext = Aig_ManPo(p, iTerm1 + i);
@@ -815,7 +821,7 @@ Aig_Obj_t * Aig_Transfer( Aig_Man_t * pSour, Aig_Man_t * pDest, Aig_Obj_t * pRoo
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) );
+ return Aig_NotCond( (Aig_Obj_t *)Aig_Regular(pRoot)->pData, Aig_IsComplement(pRoot) );
}
/**Function*************************************************************
@@ -869,7 +875,7 @@ Aig_Obj_t * Aig_Compose( Aig_Man_t * p, Aig_Obj_t * pRoot, Aig_Obj_t * pFunc, in
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) );
+ return Aig_NotCond( (Aig_Obj_t *)Aig_Regular(pRoot)->pData, Aig_IsComplement(pRoot) );
}
/**Function*************************************************************
@@ -914,7 +920,7 @@ void Aig_ObjCollectCut( Aig_Obj_t * pRoot, Vec_Ptr_t * vLeaves, Vec_Ptr_t * vNod
int i;
// collect and mark the leaves
Vec_PtrClear( vNodes );
- Vec_PtrForEachEntry( vLeaves, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vLeaves, pObj, i )
{
assert( pObj->fMarkA == 0 );
pObj->fMarkA = 1;
@@ -924,9 +930,9 @@ void Aig_ObjCollectCut( Aig_Obj_t * pRoot, Vec_Ptr_t * vLeaves, Vec_Ptr_t * vNod
// collect and mark the nodes
Aig_ObjCollectCut_rec( pRoot, vNodes );
// clean the nodes
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
pObj->fMarkA = 0;
- Vec_PtrForEachEntry( vLeaves, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vLeaves, pObj, i )
pObj->fMarkA = 0;
}
@@ -998,7 +1004,7 @@ int Aig_ObjCollectSuper( Aig_Obj_t * pObj, Vec_Ptr_t * vSuper )
RetValue = Aig_ObjCollectSuper_rec( pObj, pObj, vSuper );
assert( Vec_PtrSize(vSuper) > 1 );
// unmark the visited nodes
- Vec_PtrForEachEntry( vSuper, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vSuper, pObj, i )
Aig_Regular(pObj)->fMarkA = 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)
@@ -1012,3 +1018,5 @@ int Aig_ObjCollectSuper( Aig_Obj_t * pObj, Vec_Ptr_t * vSuper )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/aig/aigDup.c b/src/aig/aig/aigDup.c
index 90579f59..91531093 100644
--- a/src/aig/aig/aigDup.c
+++ b/src/aig/aig/aigDup.c
@@ -21,6 +21,9 @@
#include "saig.h"
#include "tim.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -52,6 +55,7 @@ Aig_Man_t * Aig_ManDupSimple( Aig_Man_t * p )
pNew->pName = Aig_UtilStrsav( p->pName );
pNew->pSpec = Aig_UtilStrsav( p->pSpec );
pNew->nAsserts = p->nAsserts;
+ pNew->nConstrs = p->nConstrs;
if ( p->vFlopNums )
pNew->vFlopNums = Vec_IntDup( p->vFlopNums );
// create the PIs
@@ -102,6 +106,57 @@ Aig_Man_t * Aig_ManDupSimple( Aig_Man_t * p )
/**Function*************************************************************
+ Synopsis [Derives AIG with hints.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Man_t * Aig_ManDupSimpleWithHints( Aig_Man_t * p, Vec_Int_t * vHints )
+{
+ Aig_Man_t * pNew;
+ Aig_Obj_t * pObj;
+ int i, Entry;
+ assert( p->pManHaig == NULL || Aig_ManBufNum(p) == 0 );
+ assert( p->nAsserts == 0 || p->nConstrs == 0 );
+ // create the new manager
+ pNew = Aig_ManStart( Aig_ManObjNumMax(p) );
+ pNew->pName = Aig_UtilStrsav( p->pName );
+ // create the PIs
+ Aig_ManCleanData( p );
+ Aig_ManConst1(p)->pData = Aig_ManConst1(pNew);
+ Aig_ManForEachPi( p, pObj, i )
+ {
+ pObj->pData = Aig_ObjCreatePi( pNew );
+ Entry = Vec_IntEntry( vHints, Aig_ObjId(pObj) );
+ if ( Entry == 0 || Entry == 1 )
+ pObj->pData = Aig_NotCond( Aig_ManConst1(pNew), Entry ); // restrict to the complement of constraint!!!
+ }
+ // duplicate internal nodes
+ Aig_ManForEachNode( p, pObj, i )
+ {
+ pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
+ Entry = Vec_IntEntry( vHints, Aig_ObjId(pObj) );
+ if ( Entry == 0 || Entry == 1 )
+ pObj->pData = Aig_NotCond( Aig_ManConst1(pNew), Entry ); // restrict to the complement of constraint!!!
+ }
+ // add the POs
+ Aig_ManForEachPo( p, pObj, i )
+ pObj->pData = Aig_ObjCreatePo( pNew, Aig_ObjChild0Copy(pObj) );
+ Aig_ManCleanup( pNew );
+ Aig_ManSetRegNum( pNew, Aig_ManRegNum(p) );
+ // check the resulting network
+ if ( !Aig_ManCheck(pNew) )
+ printf( "Llb_ManDeriveAigWithHints(): The check has failed.\n" );
+ return pNew;
+}
+
+
+/**Function*************************************************************
+
Synopsis [Duplicates the AIG manager recursively.]
Description []
@@ -114,14 +169,14 @@ Aig_Man_t * Aig_ManDupSimple( Aig_Man_t * p )
Aig_Obj_t * Aig_ManDupSimpleDfs_rec( Aig_Man_t * pNew, Aig_Man_t * p, Aig_Obj_t * pObj )
{
if ( pObj->pData )
- return pObj->pData;
+ return (Aig_Obj_t *)pObj->pData;
Aig_ManDupSimpleDfs_rec( pNew, p, Aig_ObjFanin0(pObj) );
if ( Aig_ObjIsBuf(pObj) )
- return pObj->pData = Aig_ObjChild0Copy(pObj);
+ return (Aig_Obj_t *)(pObj->pData = Aig_ObjChild0Copy(pObj));
Aig_ManDupSimpleDfs_rec( pNew, p, Aig_ObjFanin1(pObj) );
pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
- Aig_Regular(pObj->pData)->pHaig = pObj->pHaig;
- return pObj->pData;
+ Aig_Regular((Aig_Obj_t *)pObj->pData)->pHaig = pObj->pHaig;
+ return (Aig_Obj_t *)pObj->pData;
}
/**Function*************************************************************
@@ -151,6 +206,7 @@ Aig_Man_t * Aig_ManDupSimpleDfs( Aig_Man_t * p )
pNew->pName = Aig_UtilStrsav( p->pName );
pNew->pSpec = Aig_UtilStrsav( p->pSpec );
pNew->nAsserts = p->nAsserts;
+ pNew->nConstrs = p->nConstrs;
if ( p->vFlopNums )
pNew->vFlopNums = Vec_IntDup( p->vFlopNums );
// create the PIs
@@ -213,10 +269,10 @@ Aig_Man_t * Aig_ManDupSimpleDfsPart( Aig_Man_t * p, Vec_Ptr_t * vPis, Vec_Ptr_t
// create the PIs
Aig_ManCleanData( p );
Aig_ManConst1(p)->pData = Aig_ManConst1( pNew );
- Vec_PtrForEachEntry( vPis, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vPis, pObj, i )
pObj->pData = Aig_ObjCreatePi( pNew );
// duplicate internal nodes
- Vec_PtrForEachEntry( vPos, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vPos, pObj, i )
{
pObjNew = Aig_ManDupSimpleDfs_rec( pNew, p, Aig_ObjFanin0(pObj) );
pObjNew = Aig_NotCond( pObjNew, Aig_ObjFaninC0(pObj) );
@@ -250,6 +306,7 @@ Aig_Man_t * Aig_ManDupOrdered( Aig_Man_t * p )
pNew->pName = Aig_UtilStrsav( p->pName );
pNew->pSpec = Aig_UtilStrsav( p->pSpec );
pNew->nAsserts = p->nAsserts;
+ pNew->nConstrs = p->nConstrs;
if ( p->vFlopNums )
pNew->vFlopNums = Vec_IntDup( p->vFlopNums );
// create the PIs
@@ -289,7 +346,7 @@ Aig_Man_t * Aig_ManDupOrdered( Aig_Man_t * p )
Aig_ManSetRegNum( pNew, Aig_ManRegNum(p) );
// duplicate the timing manager
if ( p->pManTime )
- pNew->pManTime = Tim_ManDup( p->pManTime, 0 );
+ pNew->pManTime = Tim_ManDup( (Tim_Man_t *)p->pManTime, 0 );
// pass the HAIG manager
if ( p->pManHaig != NULL )
{
@@ -301,6 +358,86 @@ Aig_Man_t * Aig_ManDupOrdered( Aig_Man_t * p )
printf( "Aig_ManDupOrdered(): The check has failed.\n" );
return pNew;
}
+
+/**Function*************************************************************
+
+ Synopsis [Duplicates the AIG manager.]
+
+ Description [Orders nodes as follows: PIs, ANDs, POs.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Man_t * Aig_ManDupCof( Aig_Man_t * p, int iInput, int Value )
+{
+ Aig_Man_t * pNew;
+ Aig_Obj_t * pObj, * pObjNew;
+ int i;
+ assert( p->pManTime == NULL );
+ assert( p->pManHaig == NULL || Aig_ManBufNum(p) == 0 );
+ // create the new manager
+ pNew = Aig_ManStart( Aig_ManObjNumMax(p) );
+ pNew->pName = Aig_UtilStrsav( p->pName );
+ pNew->pSpec = Aig_UtilStrsav( p->pSpec );
+ pNew->nAsserts = p->nAsserts;
+ pNew->nConstrs = p->nConstrs;
+ if ( p->vFlopNums )
+ pNew->vFlopNums = Vec_IntDup( p->vFlopNums );
+ // create the PIs
+ Aig_ManCleanData( p );
+ Aig_ManConst1(p)->pData = Aig_ManConst1(pNew);
+ Aig_ManConst1(pNew)->pHaig = Aig_ManConst1(p)->pHaig;
+ Aig_ManForEachPi( p, pObj, i )
+ {
+ if ( i == iInput )
+ pObjNew = Value ? Aig_ManConst1(pNew) : Aig_ManConst0(pNew);
+ else
+ {
+ pObjNew = Aig_ObjCreatePi( pNew );
+ pObjNew->pHaig = pObj->pHaig;
+ pObjNew->Level = pObj->Level;
+ }
+ pObj->pData = pObjNew;
+ }
+ // duplicate internal nodes
+ Aig_ManForEachObj( p, pObj, i )
+ if ( Aig_ObjIsBuf(pObj) )
+ {
+ pObjNew = Aig_ObjChild0Copy(pObj);
+ Aig_Regular(pObjNew)->pHaig = pObj->pHaig;
+ pObj->pData = pObjNew;
+ }
+ else if ( Aig_ObjIsNode(pObj) )
+ {
+ pObjNew = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
+ Aig_Regular(pObjNew)->pHaig = pObj->pHaig;
+ pObj->pData = pObjNew;
+ }
+ // add the POs
+ Aig_ManForEachPo( p, pObj, i )
+ {
+ pObjNew = Aig_ObjCreatePo( pNew, Aig_ObjChild0Copy(pObj) );
+ pObjNew->pHaig = pObj->pHaig;
+ pObj->pData = pObjNew;
+ }
+// assert( Aig_ManBufNum(p) != 0 || Aig_ManNodeNum(p) == Aig_ManNodeNum(pNew) );
+ Aig_ManCleanup( pNew );
+ Aig_ManSetRegNum( pNew, Aig_ManRegNum(p) );
+ // pass the HAIG manager
+ if ( p->pManHaig != NULL )
+ {
+ pNew->pManHaig = p->pManHaig;
+ p->pManHaig = NULL;
+ }
+ // check the resulting network
+ if ( !Aig_ManCheck(pNew) )
+ printf( "Aig_ManDupSimple(): The check has failed.\n" );
+ return pNew;
+}
+
+
/**Function*************************************************************
Synopsis [Duplicates the AIG manager.]
@@ -321,6 +458,7 @@ Aig_Man_t * Aig_ManDupTrim( Aig_Man_t * p )
pNew = Aig_ManStart( Aig_ManObjNumMax(p) );
pNew->pName = Aig_UtilStrsav( p->pName );
pNew->pSpec = Aig_UtilStrsav( p->pSpec );
+ pNew->nConstrs = p->nConstrs;
// create the PIs
Aig_ManCleanData( p );
// duplicate internal nodes
@@ -370,6 +508,7 @@ Aig_Man_t * Aig_ManDupExor( Aig_Man_t * p )
pNew->pName = Aig_UtilStrsav( p->pName );
pNew->pSpec = Aig_UtilStrsav( p->pSpec );
pNew->nAsserts = p->nAsserts;
+ pNew->nConstrs = p->nConstrs;
if ( p->vFlopNums )
pNew->vFlopNums = Vec_IntDup( p->vFlopNums );
// create the PIs
@@ -407,7 +546,7 @@ Aig_Man_t * Aig_ManDupExor( Aig_Man_t * p )
Aig_ManSetRegNum( pNew, Aig_ManRegNum(p) );
// duplicate the timing manager
if ( p->pManTime )
- pNew->pManTime = Tim_ManDup( p->pManTime, 0 );
+ pNew->pManTime = Tim_ManDup( (Tim_Man_t *)p->pManTime, 0 );
// check the resulting network
if ( !Aig_ManCheck(pNew) )
printf( "Aig_ManDupExor(): The check has failed.\n" );
@@ -429,12 +568,12 @@ Aig_Obj_t * Aig_ManDupDfs_rec( Aig_Man_t * pNew, Aig_Man_t * p, Aig_Obj_t * pObj
{
Aig_Obj_t * pObjNew, * pEquivNew = NULL;
if ( pObj->pData )
- return pObj->pData;
+ return (Aig_Obj_t *)pObj->pData;
if ( p->pEquivs && Aig_ObjEquiv(p, pObj) )
pEquivNew = Aig_ManDupDfs_rec( pNew, p, Aig_ObjEquiv(p, pObj) );
Aig_ManDupDfs_rec( pNew, p, Aig_ObjFanin0(pObj) );
if ( Aig_ObjIsBuf(pObj) )
- return pObj->pData = Aig_ObjChild0Copy(pObj);
+ return (Aig_Obj_t *)(pObj->pData = Aig_ObjChild0Copy(pObj));
Aig_ManDupDfs_rec( pNew, p, Aig_ObjFanin1(pObj) );
pObjNew = Aig_Oper( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj), Aig_ObjType(pObj) );
if ( p->pManHaig != NULL )
@@ -448,7 +587,7 @@ Aig_Obj_t * Aig_ManDupDfs_rec( Aig_Man_t * pNew, Aig_Man_t * p, Aig_Obj_t * pObj
if ( pNew->pReprs )
pNew->pReprs[Aig_Regular(pEquivNew)->Id] = Aig_Regular(pObjNew);
}
- return pObj->pData = pObjNew;
+ return (Aig_Obj_t *)(pObj->pData = pObjNew);
}
/**Function*************************************************************
@@ -472,6 +611,7 @@ Aig_Man_t * Aig_ManDupDfs( Aig_Man_t * p )
pNew->pName = Aig_UtilStrsav( p->pName );
pNew->pSpec = Aig_UtilStrsav( p->pSpec );
pNew->nAsserts = p->nAsserts;
+ pNew->nConstrs = p->nConstrs;
if ( p->vFlopNums )
pNew->vFlopNums = Vec_IntDup( p->vFlopNums );
// duplicate representation of choice nodes
@@ -508,7 +648,7 @@ Aig_Man_t * Aig_ManDupDfs( Aig_Man_t * p )
Aig_ManSetRegNum( pNew, Aig_ManRegNum(p) );
// duplicate the timing manager
if ( p->pManTime )
- pNew->pManTime = Tim_ManDup( p->pManTime, 0 );
+ pNew->pManTime = Tim_ManDup( (Tim_Man_t *)p->pManTime, 0 );
// pass the HAIG manager
if ( p->pManHaig != NULL )
{
@@ -567,7 +707,7 @@ Aig_Obj_t * Aig_ManDupDfsGuided_rec( Aig_Man_t * pNew, Aig_Man_t * p, Aig_Obj_t
{
Aig_Obj_t * pObjNew, * pEquivNew = NULL;
if ( pObj->pData )
- return pObj->pData;
+ return (Aig_Obj_t *)pObj->pData;
if ( Aig_ObjIsPi(pObj) )
return NULL;
if ( p->pEquivs && Aig_ObjEquiv(p, pObj) )
@@ -575,7 +715,7 @@ Aig_Obj_t * Aig_ManDupDfsGuided_rec( Aig_Man_t * pNew, Aig_Man_t * p, Aig_Obj_t
if ( !Aig_ManDupDfsGuided_rec( pNew, p, Aig_ObjFanin0(pObj) ) )
return NULL;
if ( Aig_ObjIsBuf(pObj) )
- return pObj->pData = Aig_ObjChild0Copy(pObj);
+ return (Aig_Obj_t *)(pObj->pData = Aig_ObjChild0Copy(pObj));
if ( !Aig_ManDupDfsGuided_rec( pNew, p, Aig_ObjFanin1(pObj) ) )
return NULL;
pObjNew = Aig_Oper( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj), Aig_ObjType(pObj) );
@@ -588,7 +728,7 @@ Aig_Obj_t * Aig_ManDupDfsGuided_rec( Aig_Man_t * pNew, Aig_Man_t * p, Aig_Obj_t
if ( pNew->pReprs )
pNew->pReprs[Aig_Regular(pEquivNew)->Id] = Aig_Regular(pObjNew);
}
- return pObj->pData = pObjNew;
+ return (Aig_Obj_t *)(pObj->pData = pObjNew);
}
/**Function*************************************************************
@@ -612,6 +752,7 @@ Aig_Man_t * Aig_ManDupDfsGuided( Aig_Man_t * p, Vec_Ptr_t * vPios )
pNew->pName = Aig_UtilStrsav( p->pName );
pNew->pSpec = Aig_UtilStrsav( p->pSpec );
pNew->nAsserts = p->nAsserts;
+ pNew->nConstrs = p->nConstrs;
if ( p->vFlopNums )
pNew->vFlopNums = Vec_IntDup( p->vFlopNums );
// duplicate representation of choice nodes
@@ -630,7 +771,7 @@ Aig_Man_t * Aig_ManDupDfsGuided( Aig_Man_t * p, Vec_Ptr_t * vPios )
// duplicate internal nodes
Aig_ManConst1(p)->pData = Aig_ManConst1(pNew);
Aig_ManConst1(pNew)->pHaig = Aig_ManConst1(p)->pHaig;
- Vec_PtrForEachEntry( vPios, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vPios, pObj, i )
{
if ( Aig_ObjIsPi(pObj) )
{
@@ -654,7 +795,7 @@ Aig_Man_t * Aig_ManDupDfsGuided( Aig_Man_t * p, Vec_Ptr_t * vPios )
Aig_ManSetRegNum( pNew, Aig_ManRegNum(p) );
// duplicate the timing manager
if ( p->pManTime )
- pNew->pManTime = Tim_ManDup( p->pManTime, 0 );
+ pNew->pManTime = Tim_ManDup( (Tim_Man_t *)p->pManTime, 0 );
// check the resulting network
if ( !Aig_ManCheck(pNew) )
printf( "Aig_ManDupDfs(): The check has failed.\n" );
@@ -683,6 +824,7 @@ Aig_Man_t * Aig_ManDupLevelized( Aig_Man_t * p )
pNew->pName = Aig_UtilStrsav( p->pName );
pNew->pSpec = Aig_UtilStrsav( p->pSpec );
pNew->nAsserts = p->nAsserts;
+ pNew->nConstrs = p->nConstrs;
if ( p->vFlopNums )
pNew->vFlopNums = Vec_IntDup( p->vFlopNums );
// duplicate representation of choice nodes
@@ -708,7 +850,7 @@ Aig_Man_t * Aig_ManDupLevelized( Aig_Man_t * p )
}
// duplicate internal nodes
vLevels = Aig_ManLevelize( p );
- Vec_VecForEachEntry( vLevels, pObj, i, k )
+ Vec_VecForEachEntry( Aig_Obj_t *, vLevels, pObj, i, k )
{
pObjNew = Aig_Oper( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj), Aig_ObjType(pObj) );
Aig_Regular(pObjNew)->pHaig = pObj->pHaig;
@@ -728,7 +870,7 @@ Aig_Man_t * Aig_ManDupLevelized( Aig_Man_t * p )
Aig_ManSetRegNum( pNew, Aig_ManRegNum(p) );
// duplicate the timing manager
if ( p->pManTime )
- pNew->pManTime = Tim_ManDup( p->pManTime, 0 );
+ pNew->pManTime = Tim_ManDup( (Tim_Man_t *)p->pManTime, 0 );
// check the resulting network
if ( !Aig_ManCheck(pNew) )
printf( "Aig_ManDupLevelized(): The check has failed.\n" );
@@ -787,8 +929,8 @@ static inline Aig_Obj_t * Aig_ObjGetRepres( Aig_Man_t * p, Aig_Obj_t * pObj )
{
Aig_Obj_t * pRepr;
if ( (pRepr = Aig_ObjRepr(p, pObj)) )
- return Aig_NotCond( pRepr->pData, pObj->fPhase ^ pRepr->fPhase );
- return pObj->pData;
+ return Aig_NotCond( (Aig_Obj_t *)pRepr->pData, pObj->fPhase ^ pRepr->fPhase );
+ return (Aig_Obj_t *)pObj->pData;
}
static inline Aig_Obj_t * Aig_ObjChild0Repres( Aig_Man_t * p, Aig_Obj_t * pObj ) { return Aig_NotCond( Aig_ObjGetRepres(p, Aig_ObjFanin0(pObj)), Aig_ObjFaninC0(pObj) ); }
static inline Aig_Obj_t * Aig_ObjChild1Repres( Aig_Man_t * p, Aig_Obj_t * pObj ) { return Aig_NotCond( Aig_ObjGetRepres(p, Aig_ObjFanin1(pObj)), Aig_ObjFaninC1(pObj) ); }
@@ -813,6 +955,7 @@ Aig_Man_t * Aig_ManDupRepres( Aig_Man_t * p )
pNew = Aig_ManStart( Aig_ManObjNumMax(p) );
pNew->pName = Aig_UtilStrsav( p->pName );
pNew->pSpec = Aig_UtilStrsav( p->pSpec );
+ pNew->nConstrs = p->nConstrs;
if ( p->vFlopNums )
pNew->vFlopNums = Vec_IntDup( p->vFlopNums );
// map the const and primary inputs
@@ -855,15 +998,15 @@ Aig_Obj_t * Aig_ManDupRepres_rec( Aig_Man_t * pNew, Aig_Man_t * p, Aig_Obj_t * p
{
Aig_Obj_t * pRepr;
if ( pObj->pData )
- return pObj->pData;
+ return (Aig_Obj_t *)pObj->pData;
if ( (pRepr = Aig_ObjRepr(p, pObj)) )
{
Aig_ManDupRepres_rec( pNew, p, pRepr );
- return pObj->pData = Aig_NotCond( pRepr->pData, pRepr->fPhase ^ pObj->fPhase );
+ return (Aig_Obj_t *)(pObj->pData = Aig_NotCond( (Aig_Obj_t *)pRepr->pData, pRepr->fPhase ^ pObj->fPhase ));
}
Aig_ManDupRepres_rec( pNew, p, Aig_ObjFanin0(pObj) );
Aig_ManDupRepres_rec( pNew, p, Aig_ObjFanin1(pObj) );
- return pObj->pData = Aig_And( pNew, Aig_ObjChild0Repres(p, pObj), Aig_ObjChild1Repres(p, pObj) );
+ return (Aig_Obj_t *)(pObj->pData = Aig_And( pNew, Aig_ObjChild0Repres(p, pObj), Aig_ObjChild1Repres(p, pObj) ));
}
/**Function*************************************************************
@@ -886,6 +1029,7 @@ Aig_Man_t * Aig_ManDupRepresDfs( Aig_Man_t * p )
pNew = Aig_ManStart( Aig_ManObjNumMax(p) );
pNew->pName = Aig_UtilStrsav( p->pName );
pNew->pSpec = Aig_UtilStrsav( p->pSpec );
+ pNew->nConstrs = p->nConstrs;
if ( p->vFlopNums )
pNew->vFlopNums = Vec_IntDup( p->vFlopNums );
// map the const and primary inputs
@@ -985,6 +1129,11 @@ Aig_Man_t * Aig_ManDupOrpos( Aig_Man_t * p, int fAddRegs )
Aig_Obj_t * pObj, * pMiter;
int i;
assert( Aig_ManRegNum(p) > 0 );
+ if ( p->nConstrs > 0 )
+ {
+ printf( "The AIG manager should have no constraints.\n" );
+ return NULL;
+ }
// create the new manager
pNew = Aig_ManStart( Aig_ManObjNumMax(p) );
pNew->pName = Aig_UtilStrsav( p->pName );
@@ -1080,6 +1229,11 @@ Aig_Man_t * Aig_ManDupUnsolvedOutputs( Aig_Man_t * p, int fAddRegs )
Aig_Obj_t * pObj;
int i, nOuts = 0;
assert( Aig_ManRegNum(p) > 0 );
+ if ( p->nConstrs > 0 )
+ {
+ printf( "The AIG manager should have no constraints.\n" );
+ return NULL;
+ }
// create the new manager
pNew = Aig_ManStart( Aig_ManObjNumMax(p) );
pNew->pName = Aig_UtilStrsav( p->pName );
@@ -1120,3 +1274,5 @@ Aig_Man_t * Aig_ManDupUnsolvedOutputs( Aig_Man_t * p, int fAddRegs )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/aig/aigFact.c b/src/aig/aig/aigFact.c
index 7004618a..9c4e5689 100644
--- a/src/aig/aig/aigFact.c
+++ b/src/aig/aig/aigFact.c
@@ -19,6 +19,10 @@
***********************************************************************/
#include "aig.h"
+#include "kit.h"
+
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -116,7 +120,7 @@ int Aig_ManFindConeOverlap( Aig_Man_t * p, Vec_Ptr_t * vImplics, Aig_Obj_t * pNo
assert( !Aig_IsComplement(pNode) );
assert( !Aig_ObjIsConst1(pNode) );
Aig_ManIncrementTravId( p );
- Vec_PtrForEachEntry( vImplics, pTemp, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vImplics, pTemp, i )
Aig_ObjSetTravIdCurrent( p, Aig_Regular(pTemp) );
Aig_ManIncrementTravId( p );
return Aig_ManFindConeOverlap_rec( p, pNode );
@@ -136,13 +140,13 @@ int Aig_ManFindConeOverlap( Aig_Man_t * p, Vec_Ptr_t * vImplics, Aig_Obj_t * pNo
Aig_Obj_t * Aig_ManDeriveNewCone_rec( Aig_Man_t * p, Aig_Obj_t * pNode )
{
if ( Aig_ObjIsTravIdCurrent( p, pNode ) )
- return pNode->pData;
+ return (Aig_Obj_t *)pNode->pData;
Aig_ObjSetTravIdCurrent( p, pNode );
if ( Aig_ObjIsPi(pNode) )
- return pNode->pData = pNode;
+ return (Aig_Obj_t *)(pNode->pData = pNode);
Aig_ManDeriveNewCone_rec( p, Aig_ObjFanin0(pNode) );
Aig_ManDeriveNewCone_rec( p, Aig_ObjFanin1(pNode) );
- return pNode->pData = Aig_And( p, Aig_ObjChild0Copy(pNode), Aig_ObjChild1Copy(pNode) );
+ return (Aig_Obj_t *)(pNode->pData = Aig_And( p, Aig_ObjChild0Copy(pNode), Aig_ObjChild1Copy(pNode) ));
}
/**Function*************************************************************
@@ -163,7 +167,7 @@ Aig_Obj_t * Aig_ManDeriveNewCone( Aig_Man_t * p, Vec_Ptr_t * vImplics, Aig_Obj_t
assert( !Aig_IsComplement(pNode) );
assert( !Aig_ObjIsConst1(pNode) );
Aig_ManIncrementTravId( p );
- Vec_PtrForEachEntry( vImplics, pTemp, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vImplics, pTemp, i )
{
Aig_ObjSetTravIdCurrent( p, Aig_Regular(pTemp) );
Aig_Regular(pTemp)->pData = Aig_NotCond( Aig_ManConst1(p), Aig_IsComplement(pTemp) );
@@ -267,6 +271,446 @@ void Aig_ManFactorAlgebraicTest( Aig_Man_t * p )
*/
}
+
+
+/**Function*************************************************************
+
+ Synopsis [Determines what support variables can be cofactored.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Ptr_t * Aig_SuppMinPerform( Aig_Man_t * p, Vec_Ptr_t * vOrGate, Vec_Ptr_t * vNodes, Vec_Ptr_t * vSupp )
+{
+ Aig_Obj_t * pObj;
+ Vec_Ptr_t * vTrSupp, * vTrNode, * vCofs;
+ unsigned * uFunc, * uCare, * uFunc0, * uFunc1, * uCof;
+ int i, nWords = Aig_TruthWordNum( Vec_PtrSize(vSupp) );
+ // assign support nodes
+ vTrSupp = Vec_PtrAllocTruthTables( Vec_PtrSize(vSupp) );
+ Vec_PtrForEachEntry( Aig_Obj_t *, vSupp, pObj, i )
+ {
+ printf( "%d %d\n", Aig_ObjId(pObj), i );
+ pObj->pData = Vec_PtrEntry( vTrSupp, i );
+ }
+ // compute internal nodes
+ vTrNode = Vec_PtrAllocSimInfo( Vec_PtrSize(vNodes) + 5, nWords );
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
+ {
+ pObj->pData = uFunc = (unsigned *)Vec_PtrEntry( vTrNode, i );
+ uFunc0 = (unsigned *)Aig_ObjFanin0(pObj)->pData;
+ uFunc1 = (unsigned *)Aig_ObjFanin1(pObj)->pData;
+ Kit_TruthAndPhase( uFunc, uFunc0, uFunc1, Vec_PtrSize(vSupp), Aig_ObjFaninC0(pObj), Aig_ObjFaninC1(pObj) );
+ }
+ // uFunc contains the result of computation
+ // compute care set
+ uCare = (unsigned *)Vec_PtrEntry( vTrNode, Vec_PtrSize(vNodes) );
+ Kit_TruthClear( uCare, Vec_PtrSize(vSupp) );
+ Vec_PtrForEachEntry( Aig_Obj_t *, vOrGate, pObj, i )
+ {
+ printf( "%d %d %d - or gate\n", Aig_ObjId(Aig_Regular(pObj)), Aig_IsComplement(pObj), i );
+ Kit_TruthOrPhase( uCare, uCare, (unsigned *)Aig_Regular(pObj)->pData, Vec_PtrSize(vSupp), 0, Aig_IsComplement(pObj) );
+ }
+ // try cofactoring each variable in both polarities
+ vCofs = Vec_PtrAlloc( 10 );
+ uCof = (unsigned *)Vec_PtrEntry( vTrNode, Vec_PtrSize(vNodes)+1 );
+ Vec_PtrForEachEntry( Aig_Obj_t *, vSupp, pObj, i )
+ {
+ // consider negative cofactor
+ Kit_TruthCofactor0New( uCof, uFunc, Vec_PtrSize(vSupp), i );
+ if ( Kit_TruthIsEqualWithCare( uFunc, uCof, uCare, Vec_PtrSize(vSupp) ) )
+ {
+ Vec_PtrPush( vCofs, Aig_Not(pObj) );
+ Kit_TruthCopy( uFunc, uCof, Vec_PtrSize(vSupp) );
+ Kit_TruthCofactor0( uCare, Vec_PtrSize(vSupp), i );
+ continue;
+ }
+ // consider positive cofactor
+ Kit_TruthCofactor1New( uCof, uFunc, Vec_PtrSize(vSupp), i );
+ if ( Kit_TruthIsEqualWithCare( uFunc, uCof, uCare, Vec_PtrSize(vSupp) ) )
+ {
+ Vec_PtrPush( vCofs, pObj );
+ Kit_TruthCopy( uFunc, uCof, Vec_PtrSize(vSupp) );
+ Kit_TruthCofactor1( uCare, Vec_PtrSize(vSupp), i );
+ }
+ }
+ Vec_PtrFree( vTrNode );
+ Vec_PtrFree( vTrSupp );
+ return vCofs;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Returns the new node after cofactoring.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Obj_t * Aig_SuppMinReconstruct( Aig_Man_t * p, Vec_Ptr_t * vCofs, Vec_Ptr_t * vNodes, Vec_Ptr_t * vSupp )
+{
+ Aig_Obj_t * pObj;
+ int i;
+ // set the value of the support variables
+ Vec_PtrForEachEntry( Aig_Obj_t *, vSupp, pObj, i )
+ assert( !Aig_IsComplement(pObj) );
+ Vec_PtrForEachEntry( Aig_Obj_t *, vSupp, pObj, i )
+ pObj->pData = pObj;
+ // set the value of the cofactoring variables
+ Vec_PtrForEachEntry( Aig_Obj_t *, vCofs, pObj, i )
+ Aig_Regular(pObj)->pData = Aig_NotCond( Aig_ManConst1(p), Aig_IsComplement(pObj) );
+ // reconstruct the node
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
+ pObj->pData = Aig_And( p, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
+ return (Aig_Obj_t *)pObj->pData;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns 1 if all nodes of vOrGate are in vSupp.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Aig_SuppMinGateIsInSupport( Aig_Man_t * p, Vec_Ptr_t * vOrGate, Vec_Ptr_t * vSupp )
+{
+ Aig_Obj_t * pObj;
+ int i;
+ Aig_ManIncrementTravId( p );
+ Vec_PtrForEachEntry( Aig_Obj_t *, vSupp, pObj, i )
+ Aig_ObjSetTravIdCurrent( p, pObj );
+ Vec_PtrForEachEntry( Aig_Obj_t *, vOrGate, pObj, i )
+ if ( !Aig_ObjIsTravIdCurrent( p, Aig_Regular(pObj) ) )
+ return 0;
+ return 1;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Collects fanins of the marked nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Ptr_t * Aig_SuppMinCollectSupport( Aig_Man_t * p, Vec_Ptr_t * vNodes )
+{
+ Vec_Ptr_t * vSupp;
+ Aig_Obj_t * pObj, * pFanin;
+ int i;
+ vSupp = Vec_PtrAlloc( 4 );
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
+ {
+ assert( Aig_ObjIsTravIdCurrent(p, pObj) );
+ assert( Aig_ObjIsNode(pObj) );
+ pFanin = Aig_ObjFanin0( pObj );
+ if ( !Aig_ObjIsTravIdCurrent(p, pFanin) )
+ {
+ Aig_ObjSetTravIdCurrent( p, pFanin );
+ Vec_PtrPush( vSupp, pFanin );
+ }
+ pFanin = Aig_ObjFanin1( pObj );
+ if ( !Aig_ObjIsTravIdCurrent(p, pFanin) )
+ {
+ Aig_ObjSetTravIdCurrent( p, pFanin );
+ Vec_PtrPush( vSupp, pFanin );
+ }
+ }
+ return vSupp;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Marks the nodes in the cone with current trav ID.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Aig_SuppMinCollectCone_rec( Aig_Man_t * p, Aig_Obj_t * pObj, Vec_Ptr_t * vNodes )
+{
+ if ( Aig_ObjIsTravIdCurrent( p, pObj ) ) // visited
+ return;
+ if ( !Aig_ObjIsTravIdPrevious( p, pObj ) ) // not visited, but outside
+ return;
+ assert( Aig_ObjIsTravIdPrevious(p, pObj) ); // not visited, inside
+ assert( Aig_ObjIsNode(pObj) );
+ Aig_ObjSetTravIdCurrent( p, pObj );
+ Aig_SuppMinCollectCone_rec( p, Aig_ObjFanin0(pObj), vNodes );
+ Aig_SuppMinCollectCone_rec( p, Aig_ObjFanin1(pObj), vNodes );
+ Vec_PtrPush( vNodes, pObj );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Collects nodes with the current trav ID rooted in the node.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Ptr_t * Aig_SuppMinCollectCone( Aig_Man_t * p, Aig_Obj_t * pRoot )
+{
+ Vec_Ptr_t * vNodes;
+ assert( !Aig_IsComplement(pRoot) );
+// assert( Aig_ObjIsTravIdCurrent( p, pRoot ) );
+ vNodes = Vec_PtrAlloc( 4 );
+ Aig_ManIncrementTravId( p );
+ Aig_SuppMinCollectCone_rec( p, Aig_Regular(pRoot), vNodes );
+ return vNodes;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Marks the nodes in the cone with current trav ID.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Aig_SuppMinHighlightCone_rec( Aig_Man_t * p, Aig_Obj_t * pObj )
+{
+ int RetValue;
+ if ( Aig_ObjIsTravIdCurrent( p, pObj ) ) // visited, marks there
+ return 1;
+ if ( Aig_ObjIsTravIdPrevious( p, pObj ) ) // visited, no marks there
+ return 0;
+ Aig_ObjSetTravIdPrevious( p, pObj );
+ if ( Aig_ObjIsPi(pObj) )
+ return 0;
+ RetValue = Aig_SuppMinHighlightCone_rec( p, Aig_ObjFanin0(pObj) ) |
+ Aig_SuppMinHighlightCone_rec( p, Aig_ObjFanin1(pObj) );
+// printf( "%d %d\n", Aig_ObjId(pObj), RetValue );
+ if ( RetValue )
+ Aig_ObjSetTravIdCurrent( p, pObj );
+ return RetValue;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Marks the nodes in the cone with current trav ID.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Aig_SuppMinHighlightCone( Aig_Man_t * p, Aig_Obj_t * pRoot, Vec_Ptr_t * vOrGate )
+{
+ Aig_Obj_t * pLeaf;
+ int i, RetValue;
+ assert( !Aig_IsComplement(pRoot) );
+ Aig_ManIncrementTravId( p );
+ Aig_ManIncrementTravId( p );
+ Vec_PtrForEachEntry( Aig_Obj_t *, vOrGate, pLeaf, i )
+ Aig_ObjSetTravIdCurrent( p, Aig_Regular(pLeaf) );
+ RetValue = Aig_SuppMinHighlightCone_rec( p, pRoot );
+ Vec_PtrForEachEntry( Aig_Obj_t *, vOrGate, pLeaf, i )
+ Aig_ObjSetTravIdPrevious( p, Aig_Regular(pLeaf) );
+ return RetValue;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Collects the supergate.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Aig_SuppMinCollectSuper_rec( Aig_Obj_t * pObj, Vec_Ptr_t * vSuper )
+{
+ // if the new node is complemented or a PI, another gate begins
+ if ( Aig_IsComplement(pObj) || Aig_ObjIsPi(pObj) ) // || (Aig_ObjRefs(pObj) > 1) )
+ {
+ Vec_PtrPushUnique( vSuper, Aig_Not(pObj) );
+ return;
+ }
+ // go through the branches
+ Aig_SuppMinCollectSuper_rec( Aig_ObjChild0(pObj), vSuper );
+ Aig_SuppMinCollectSuper_rec( Aig_ObjChild1(pObj), vSuper );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Collects the supergate.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Ptr_t * Aig_SuppMinCollectSuper( Aig_Obj_t * pObj )
+{
+ Vec_Ptr_t * vSuper;
+ assert( !Aig_IsComplement(pObj) );
+ assert( !Aig_ObjIsPi(pObj) );
+ vSuper = Vec_PtrAlloc( 4 );
+ Aig_SuppMinCollectSuper_rec( Aig_ObjChild0(pObj), vSuper );
+ Aig_SuppMinCollectSuper_rec( Aig_ObjChild1(pObj), vSuper );
+ return vSuper;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the result of support minimization.]
+
+ Description [Returns internal AIG node that is equal to pFunc under
+ assignment pCond == 1, or NULL if there is no such node. status is
+ -1 if condition is not OR;
+ -2 if cone is too large or no cone;
+ -3 if no support reduction is possible.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Obj_t * Aig_ManSupportMinimization( Aig_Man_t * p, Aig_Obj_t * pCond, Aig_Obj_t * pFunc, int * pStatus )
+{
+ int nSuppMax = 16;
+ Vec_Ptr_t * vOrGate, * vNodes, * vSupp, * vCofs;
+ Aig_Obj_t * pResult;
+ int RetValue;
+ *pStatus = 0;
+ // if pCond is not OR
+ if ( !Aig_IsComplement(pCond) || Aig_ObjIsPi(Aig_Regular(pCond)) || Aig_ObjIsConst1(Aig_Regular(pCond)) )
+ {
+ *pStatus = -1;
+ return NULL;
+ }
+ // if pFunc is not a node
+ if ( !Aig_ObjIsNode(Aig_Regular(pFunc)) )
+ {
+ *pStatus = -2;
+ return NULL;
+ }
+ // collect the multi-input OR gate rooted in the condition
+ vOrGate = Aig_SuppMinCollectSuper( Aig_Regular(pCond) );
+ if ( Vec_PtrSize(vOrGate) > nSuppMax )
+ {
+ Vec_PtrFree( vOrGate );
+ *pStatus = -2;
+ return NULL;
+ }
+ // highlight the cone limited by these gates
+ RetValue = Aig_SuppMinHighlightCone( p, Aig_Regular(pFunc), vOrGate );
+ if ( RetValue == 0 ) // no overlap
+ {
+ Vec_PtrFree( vOrGate );
+ *pStatus = -2;
+ return NULL;
+ }
+ // collect the cone rooted in pFunc limited by vOrGate
+ vNodes = Aig_SuppMinCollectCone( p, Aig_Regular(pFunc) );
+ // collect the support nodes reachable from the cone
+ vSupp = Aig_SuppMinCollectSupport( p, vNodes );
+ if ( Vec_PtrSize(vSupp) > nSuppMax )
+ {
+ Vec_PtrFree( vOrGate );
+ Vec_PtrFree( vNodes );
+ Vec_PtrFree( vSupp );
+ *pStatus = -2;
+ return NULL;
+ }
+ // check if all nodes belonging to OR gate are included in the support
+ // (if this is not the case, don't-care minimization is not possible)
+ if ( !Aig_SuppMinGateIsInSupport( p, vOrGate, vSupp ) )
+ {
+ Vec_PtrFree( vOrGate );
+ Vec_PtrFree( vNodes );
+ Vec_PtrFree( vSupp );
+ *pStatus = -3;
+ return NULL;
+ }
+ // create truth tables of all nodes and find the maximal number
+ // of support varialbles that can be replaced by constants
+ vCofs = Aig_SuppMinPerform( p, vOrGate, vNodes, vSupp );
+ if ( Vec_PtrSize(vCofs) == 0 )
+ {
+ Vec_PtrFree( vCofs );
+ Vec_PtrFree( vOrGate );
+ Vec_PtrFree( vNodes );
+ Vec_PtrFree( vSupp );
+ *pStatus = -3;
+ return NULL;
+ }
+ // reconstruct the cone
+ pResult = Aig_SuppMinReconstruct( p, vCofs, vNodes, vSupp );
+ pResult = Aig_NotCond( pResult, Aig_IsComplement(pFunc) );
+ Vec_PtrFree( vCofs );
+ Vec_PtrFree( vOrGate );
+ Vec_PtrFree( vNodes );
+ Vec_PtrFree( vSupp );
+ return pResult;
+}
+/**Function*************************************************************
+
+ Synopsis [Testing procedure.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Aig_ManSupportMinimizationTest()
+{
+ Aig_Man_t * p;
+ Aig_Obj_t * pFunc, * pCond, * pRes;
+ int i, Status;
+ p = Aig_ManStart( 100 );
+ for ( i = 0; i < 5; i++ )
+ Aig_IthVar(p,i);
+ pFunc = Aig_Mux( p, Aig_IthVar(p,3), Aig_IthVar(p,1), Aig_IthVar(p,0) );
+ pFunc = Aig_Mux( p, Aig_IthVar(p,4), Aig_IthVar(p,2), pFunc );
+ pCond = Aig_Or( p, Aig_IthVar(p,3), Aig_IthVar(p,4) );
+ pRes = Aig_ManSupportMinimization( p, pCond, pFunc, &Status );
+ assert( Status == 0 );
+
+ Aig_ObjPrint( p, Aig_Regular(pRes) ); printf( "\n" );
+ Aig_ObjPrint( p, Aig_ObjFanin0(Aig_Regular(pRes)) ); printf( "\n" );
+ Aig_ObjPrint( p, Aig_ObjFanin1(Aig_Regular(pRes)) ); printf( "\n" );
+
+ Aig_ManStop( p );
+}
+
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/aig/aigFanout.c b/src/aig/aig/aigFanout.c
index a3b1e684..d6317f43 100644
--- a/src/aig/aig/aigFanout.c
+++ b/src/aig/aig/aigFanout.c
@@ -20,6 +20,9 @@
#include "aig.h"
+ABC_NAMESPACE_IMPL_START
+
+
// 0: first iFan
// 1: prev iFan0
// 2: prev iFan1
@@ -187,3 +190,5 @@ void Aig_ObjRemoveFanout( Aig_Man_t * p, Aig_Obj_t * pObj, Aig_Obj_t * pFanout )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/aig/aigFrames.c b/src/aig/aig/aigFrames.c
index f25f7a8f..fdcd14aa 100644
--- a/src/aig/aig/aigFrames.c
+++ b/src/aig/aig/aigFrames.c
@@ -20,6 +20,9 @@
#include "aig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -133,3 +136,5 @@ Aig_Man_t * Aig_ManFrames( Aig_Man_t * pAig, int nFs, int fInit, int fOuts, int
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/aig/aigInter.c b/src/aig/aig/aigInter.c
index 23c1dbf5..aa019191 100644
--- a/src/aig/aig/aigInter.c
+++ b/src/aig/aig/aigInter.c
@@ -22,6 +22,9 @@
#include "cnf.h"
#include "satStore.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -268,7 +271,7 @@ timeSat += clock() - clk;
// create the resulting manager
clk = clock();
pManInter = Inta_ManAlloc();
- pRes = Inta_ManInterpolate( pManInter, pSatCnf, vVarsAB, fVerbose );
+ pRes = (Aig_Man_t *)Inta_ManInterpolate( pManInter, (Sto_Man_t *)pSatCnf, vVarsAB, fVerbose );
Inta_ManFree( pManInter );
timeInt += clock() - clk;
/*
@@ -283,7 +286,7 @@ timeInt += clock() - clk;
}
*/
Vec_IntFree( vVarsAB );
- Sto_ManFree( pSatCnf );
+ Sto_ManFree( (Sto_Man_t *)pSatCnf );
// Ioa_WriteAiger( pRes, "inter2.aig", 0, 0 );
return pRes;
@@ -294,3 +297,5 @@ timeInt += clock() - clk;
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/aig/aigMan.c b/src/aig/aig/aigMan.c
index 01b29f5f..40fe871b 100644
--- a/src/aig/aig/aigMan.c
+++ b/src/aig/aig/aigMan.c
@@ -21,6 +21,9 @@
#include "aig.h"
#include "tim.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -118,14 +121,14 @@ Aig_Obj_t * Aig_ManDup_rec( Aig_Man_t * pNew, Aig_Man_t * p, Aig_Obj_t * pObj )
{
Aig_Obj_t * pObjNew;
if ( pObj->pData )
- return pObj->pData;
+ return (Aig_Obj_t *)pObj->pData;
Aig_ManDup_rec( pNew, p, Aig_ObjFanin0(pObj) );
if ( Aig_ObjIsBuf(pObj) )
- return pObj->pData = Aig_ObjChild0Copy(pObj);
+ return (Aig_Obj_t *)(pObj->pData = Aig_ObjChild0Copy(pObj));
Aig_ManDup_rec( pNew, p, Aig_ObjFanin1(pObj) );
pObjNew = Aig_Oper( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj), Aig_ObjType(pObj) );
Aig_Regular(pObjNew)->pHaig = pObj->pHaig;
- return pObj->pData = pObjNew;
+ return (Aig_Obj_t *)(pObj->pData = pObjNew);
}
/**Function*************************************************************
@@ -157,7 +160,7 @@ Aig_Man_t * Aig_ManExtractMiter( Aig_Man_t * p, Aig_Obj_t * pNode1, Aig_Obj_t *
Aig_ManDup_rec( pNew, p, pNode1 );
Aig_ManDup_rec( pNew, p, pNode2 );
// construct the EXOR
- pObj = Aig_Exor( pNew, pNode1->pData, pNode2->pData );
+ pObj = Aig_Exor( pNew, (Aig_Obj_t *)pNode1->pData, (Aig_Obj_t *)pNode2->pData );
pObj = Aig_NotCond( pObj, Aig_Regular(pObj)->fPhase ^ Aig_IsComplement(pObj) );
// add the PO
Aig_ObjCreatePo( pNew, pObj );
@@ -183,35 +186,33 @@ void Aig_ManStop( Aig_Man_t * p )
{
Aig_Obj_t * pObj;
int i;
- if ( p->vMapped )
- Vec_PtrFree( p->vMapped );
- // print time
if ( p->time1 ) { ABC_PRT( "time1", p->time1 ); }
if ( p->time2 ) { ABC_PRT( "time2", p->time2 ); }
- // delete timing
- if ( p->pManTime )
- Tim_ManStop( p->pManTime );
- // delete fanout
- if ( p->pFanData )
- Aig_ManFanoutStop( p );
// make sure the nodes have clean marks
Aig_ManForEachObj( p, pObj, i )
assert( !pObj->fMarkA && !pObj->fMarkB );
+ Tim_ManStopP( (Tim_Man_t **)&p->pManTime );
+ if ( p->pFanData )
+ Aig_ManFanoutStop( p );
+ if ( p->pManExdc )
+ Aig_ManStop( p->pManExdc );
// Aig_TableProfile( p );
Aig_MmFixedStop( p->pMemObjs, 0 );
- if ( p->vPis ) Vec_PtrFree( p->vPis );
- if ( p->vPos ) Vec_PtrFree( p->vPos );
- if ( p->vObjs ) Vec_PtrFree( p->vObjs );
- if ( p->vBufs ) Vec_PtrFree( p->vBufs );
- if ( p->vLevelR ) Vec_IntFree( p->vLevelR );
- if ( p->vLevels ) Vec_VecFree( p->vLevels );
- if ( p->vFlopNums) Vec_IntFree( p->vFlopNums );
- if ( p->vFlopReprs) Vec_IntFree( p->vFlopReprs );
- if ( p->pManExdc ) Aig_ManStop( p->pManExdc );
- if ( p->vOnehots ) Vec_VecFree( (Vec_Vec_t *)p->vOnehots );
- if ( p->vClockDoms) Vec_VecFree( p->vClockDoms );
- if ( p->vProbs ) Vec_IntFree( p->vProbs );
- if ( p->vCiNumsOrig)Vec_IntFree( p->vCiNumsOrig );
+ Vec_PtrFreeP( &p->vPis );
+ Vec_PtrFreeP( &p->vPos );
+ Vec_PtrFreeP( &p->vObjs );
+ Vec_PtrFreeP( &p->vBufs );
+ Vec_IntFreeP( &p->vLevelR );
+ Vec_VecFreeP( &p->vLevels );
+ Vec_IntFreeP( &p->vFlopNums );
+ Vec_IntFreeP( &p->vFlopReprs );
+ Vec_VecFreeP( (Vec_Vec_t **)&p->vOnehots );
+ Vec_VecFreeP( &p->vClockDoms );
+ Vec_IntFreeP( &p->vProbs );
+ Vec_IntFreeP( &p->vCiNumsOrig );
+ Vec_PtrFreeP( &p->vMapped );
+ if ( p->pSeqModelVec )
+ Vec_PtrFreeFree( p->pSeqModelVec );
ABC_FREE( p->pFastSim );
ABC_FREE( p->pData );
ABC_FREE( p->pSeqModel );
@@ -226,6 +227,25 @@ void Aig_ManStop( Aig_Man_t * p )
/**Function*************************************************************
+ Synopsis [Stops the AIG manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Aig_ManStopP( Aig_Man_t ** p )
+{
+ if ( *p == NULL )
+ return;
+ Aig_ManStop( *p );
+ *p = NULL;
+}
+
+/**Function*************************************************************
+
Synopsis [Removes combinational logic that does not feed into POs.]
Description [Returns the number of dangling nodes removed.]
@@ -246,7 +266,7 @@ int Aig_ManCleanup( Aig_Man_t * p )
if ( Aig_ObjIsNode(pNode) && Aig_ObjRefs(pNode) == 0 )
Vec_PtrPush( vObjs, pNode );
// recursively remove dangling nodes
- Vec_PtrForEachEntry( vObjs, pNode, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vObjs, pNode, i )
Aig_ObjDelete_rec( p, pNode, 1 );
Vec_PtrFree( vObjs );
return nNodesOld - Aig_ManNodeNum(p);
@@ -288,7 +308,7 @@ int Aig_ManPiCleanup( Aig_Man_t * p )
{
Aig_Obj_t * pObj;
int i, k = 0, nPisOld = Aig_ManPiNum(p);
- Vec_PtrForEachEntry( p->vPis, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vPis, pObj, i )
{
if ( i >= Aig_ManPiNum(p) - Aig_ManRegNum(p) )
Vec_PtrWriteEntry( p->vPis, k++, pObj );
@@ -319,7 +339,7 @@ int Aig_ManPoCleanup( Aig_Man_t * p )
{
Aig_Obj_t * pObj;
int i, k = 0, nPosOld = Aig_ManPoNum(p);
- Vec_PtrForEachEntry( p->vPos, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vPos, pObj, i )
{
if ( i >= Aig_ManPoNum(p) - Aig_ManRegNum(p) )
Vec_PtrWriteEntry( p->vPos, k++, pObj );
@@ -453,9 +473,28 @@ void Aig_ManFlipFirstPo( Aig_Man_t * p )
Aig_ObjChild0Flip( Aig_ManPo(p, 0) );
}
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void * Aig_ManReleaseData( Aig_Man_t * p )
+{
+ void * pD = p->pData;
+ p->pData = NULL;
+ return pD;
+}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/aig/aigMem.c b/src/aig/aig/aigMem.c
index c0b76ff8..a21b812d 100644
--- a/src/aig/aig/aigMem.c
+++ b/src/aig/aig/aigMem.c
@@ -20,6 +20,9 @@
#include "aig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -31,7 +34,7 @@ struct Aig_MmFixed_t_
int nEntriesAlloc; // the total number of entries allocated
int nEntriesUsed; // the number of entries in use
int nEntriesMax; // the max number of entries in use
- char * pEntriesFree; // the linked list of ABC_FREE entries
+ char * pEntriesFree; // the linked list of free entries
// this is where the memory is stored
int nChunkSize; // the size of one chunk
@@ -48,8 +51,8 @@ struct Aig_MmFlex_t_
{
// information about individual entries
int nEntriesUsed; // the number of entries allocated
- char * pCurrent; // the current pointer to ABC_FREE memory
- char * pEnd; // the first entry outside the ABC_FREE memory
+ char * pCurrent; // the current pointer to free memory
+ char * pEnd; // the first entry outside the free memory
// this is where the memory is stored
int nChunkSize; // the size of one chunk
@@ -160,7 +163,7 @@ char * Aig_MmFixedEntryFetch( Aig_MmFixed_t * p )
char * pTemp;
int i;
- // check if there are still ABC_FREE entries
+ // check if there are still free entries
if ( p->nEntriesUsed == p->nEntriesAlloc )
{ // need to allocate more entries
assert( p->pEntriesFree == NULL );
@@ -189,7 +192,7 @@ char * Aig_MmFixedEntryFetch( Aig_MmFixed_t * p )
p->nEntriesUsed++;
if ( p->nEntriesMax < p->nEntriesUsed )
p->nEntriesMax = p->nEntriesUsed;
- // return the first entry in the ABC_FREE entry list
+ // return the first entry in the free entry list
pTemp = p->pEntriesFree;
p->pEntriesFree = *((char **)pTemp);
return pTemp;
@@ -210,7 +213,7 @@ void Aig_MmFixedEntryRecycle( Aig_MmFixed_t * p, char * pEntry )
{
// decrement the counter of used entries
p->nEntriesUsed--;
- // add the entry to the linked list of ABC_FREE entries
+ // add the entry to the linked list of free entries
*((char **)pEntry) = p->pEntriesFree;
p->pEntriesFree = pEntry;
}
@@ -245,7 +248,7 @@ void Aig_MmFixedRestart( Aig_MmFixed_t * p )
}
// set the last link
*((char **)pTemp) = NULL;
- // set the ABC_FREE entry list
+ // set the free entry list
p->pEntriesFree = p->pChunks[0];
// set the correct statistics
p->nMemoryAlloc = p->nEntrySize * p->nChunkSize;
@@ -363,7 +366,7 @@ void Aig_MmFlexStop( Aig_MmFlex_t * p, int fVerbose )
char * Aig_MmFlexEntryFetch( Aig_MmFlex_t * p, int nBytes )
{
char * pTemp;
- // check if there are still ABC_FREE entries
+ // check if there are still free entries
if ( p->pCurrent == NULL || p->pCurrent + nBytes > p->pEnd )
{ // need to allocate more entries
if ( p->nChunks == p->nChunksAlloc )
@@ -591,3 +594,5 @@ int Aig_MmStepReadMemUsage( Aig_MmStep_t * p )
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/aig/aigMffc.c b/src/aig/aig/aigMffc.c
index b902e609..2f51e442 100644
--- a/src/aig/aig/aigMffc.c
+++ b/src/aig/aig/aigMffc.c
@@ -20,6 +20,9 @@
#include "aig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -237,11 +240,11 @@ int Aig_NodeMffcLabelCut( Aig_Man_t * p, Aig_Obj_t * pNode, Vec_Ptr_t * vLeaves
assert( !Aig_IsComplement(pNode) );
assert( Aig_ObjIsNode(pNode) );
Aig_ManIncrementTravId( p );
- Vec_PtrForEachEntry( vLeaves, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vLeaves, pObj, i )
pObj->nRefs++;
ConeSize1 = Aig_NodeDeref_rec( pNode, 0, NULL, NULL );
ConeSize2 = Aig_NodeRefLabel_rec( p, pNode, 0 );
- Vec_PtrForEachEntry( vLeaves, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vLeaves, pObj, i )
pObj->nRefs--;
assert( ConeSize1 == ConeSize2 );
assert( ConeSize1 > 0 );
@@ -265,7 +268,7 @@ int Aig_NodeMffcExtendCut( Aig_Man_t * p, Aig_Obj_t * pNode, Vec_Ptr_t * vLeaves
int i, LevelMax, ConeSize1, ConeSize2, ConeCur1, ConeCur2, ConeBest;
// dereference the current cut
LevelMax = 0;
- Vec_PtrForEachEntry( vLeaves, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vLeaves, pObj, i )
LevelMax = ABC_MAX( LevelMax, (int)pObj->Level );
if ( LevelMax == 0 )
return 0;
@@ -274,7 +277,7 @@ int Aig_NodeMffcExtendCut( Aig_Man_t * p, Aig_Obj_t * pNode, Vec_Ptr_t * vLeaves
// try expanding each node in the boundary
ConeBest = ABC_INFINITY;
pLeafBest = NULL;
- Vec_PtrForEachEntry( vLeaves, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vLeaves, pObj, i )
{
if ( (int)pObj->Level != LevelMax )
continue;
@@ -309,3 +312,5 @@ int Aig_NodeMffcExtendCut( Aig_Man_t * p, Aig_Obj_t * pNode, Vec_Ptr_t * vLeaves
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/aig/aigObj.c b/src/aig/aig/aigObj.c
index 9034f272..141afaaa 100644
--- a/src/aig/aig/aigObj.c
+++ b/src/aig/aig/aigObj.c
@@ -20,6 +20,9 @@
#include "aig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -441,7 +444,7 @@ int Aig_ManPropagateBuffers( Aig_Man_t * p, int fUpdateLevel )
for ( nSteps = 0; Vec_PtrSize(p->vBufs) > 0; nSteps++ )
{
// get the node with a buffer fanin
- for ( pObj = Vec_PtrEntryLast(p->vBufs); Aig_ObjIsBuf(pObj); pObj = Aig_ObjFanout0(p, pObj) );
+ for ( pObj = (Aig_Obj_t *)Vec_PtrEntryLast(p->vBufs); Aig_ObjIsBuf(pObj); pObj = Aig_ObjFanout0(p, pObj) );
// replace this node by a node without buffer
Aig_NodeFixBufferFanins( p, pObj, fUpdateLevel );
// stop if a cycle occured
@@ -549,3 +552,5 @@ void Aig_ObjReplace( Aig_Man_t * p, Aig_Obj_t * pObjOld, Aig_Obj_t * pObjNew, in
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/aig/aigOper.c b/src/aig/aig/aigOper.c
index 208e2d44..127d6ef8 100644
--- a/src/aig/aig/aigOper.c
+++ b/src/aig/aig/aigOper.c
@@ -20,6 +20,9 @@
#include "aig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -262,6 +265,48 @@ Aig_Obj_t * Aig_Or( Aig_Man_t * p, Aig_Obj_t * p0, Aig_Obj_t * p1 )
Synopsis [Implements ITE operation.]
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Obj_t * Aig_TableLookupInt( Aig_Man_t * p, Aig_Obj_t * p0, Aig_Obj_t * p1 )
+{
+ if ( p0 == p1 )
+ return p0;
+ if ( p0 == Aig_ManConst0(p) || p1 == Aig_ManConst0(p) || p0 == Aig_Not(p1) )
+ return Aig_ManConst0(p);
+ if ( p0 == Aig_ManConst1(p) )
+ return p1;
+ if ( p1 == Aig_ManConst1(p) )
+ return p0;
+ if ( Aig_Regular(p0)->Id < Aig_Regular(p1)->Id )
+ return Aig_TableLookup( p, Aig_ObjCreateGhost(p, p0, p1, AIG_OBJ_AND) );
+ return Aig_TableLookup( p, Aig_ObjCreateGhost(p, p1, p0, AIG_OBJ_AND) );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Implements ITE operation.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Obj_t * Aig_Mux2( Aig_Man_t * p, Aig_Obj_t * pC, Aig_Obj_t * p1, Aig_Obj_t * p0 )
+{
+ return Aig_Or( p, Aig_And(p, pC, p1), Aig_And(p, Aig_Not(pC), p0) );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Implements ITE operation.]
+
Description []
SideEffects []
@@ -271,46 +316,50 @@ Aig_Obj_t * Aig_Or( Aig_Man_t * p, Aig_Obj_t * p0, Aig_Obj_t * p1 )
***********************************************************************/
Aig_Obj_t * Aig_Mux( Aig_Man_t * p, Aig_Obj_t * pC, Aig_Obj_t * p1, Aig_Obj_t * p0 )
{
-/*
+ int fUseMuxCanon = 0;
Aig_Obj_t * pTempA1, * pTempA2, * pTempB1, * pTempB2, * pTemp;
int Count0, Count1;
- // consider trivial cases
- if ( p0 == Aig_Not(p1) )
+ if ( !fUseMuxCanon )
+ return Aig_Mux2( p, pC, p1, p0 );
+ if ( p0 == p1 )
+ return p0;
+ if ( p1 == Aig_Not(p0) )
return Aig_Exor( p, pC, p0 );
- // other cases can be added
+ if ( pC == Aig_ManConst0(p) )
+ return p0;
+ if ( pC == Aig_ManConst1(p) )
+ return p1;
+ if ( p0 == Aig_ManConst0(p) )
+ return Aig_And( p, pC, p1 );
+ if ( p0 == Aig_ManConst1(p) )
+ return Aig_Or( p, Aig_Not(pC), p1 );
+ if ( p1 == Aig_ManConst0(p) )
+ return Aig_And( p, Aig_Not(pC), p0 );
+ if ( p1 == Aig_ManConst1(p) )
+ return Aig_Or( p, pC, p0 );
// implement the first MUX (F = C * x1 + C' * x0)
-
- // check for constants here!!!
-
- pTempA1 = Aig_TableLookup( p, Aig_ObjCreateGhost(p, pC, p1, AIG_OBJ_AND) );
- pTempA2 = Aig_TableLookup( p, Aig_ObjCreateGhost(p, Aig_Not(pC), p0, AIG_OBJ_AND) );
+ pTempA1 = Aig_TableLookupInt( p, pC, p1 );
+ pTempA2 = Aig_TableLookupInt( p, Aig_Not(pC), p0 );
if ( pTempA1 && pTempA2 )
{
- pTemp = Aig_TableLookup( p, Aig_ObjCreateGhost(p, Aig_Not(pTempA1), Aig_Not(pTempA2), AIG_OBJ_AND) );
+ pTemp = Aig_TableLookupInt( p, Aig_Not(pTempA1), Aig_Not(pTempA2) );
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_OBJ_AND) );
- pTempB2 = Aig_TableLookup( p, Aig_ObjCreateGhost(p, Aig_Not(pC), Aig_Not(p0), AIG_OBJ_AND) );
+ pTempB1 = Aig_TableLookupInt( p, pC, Aig_Not(p1) );
+ pTempB2 = Aig_TableLookupInt( p, Aig_Not(pC), Aig_Not(p0) );
if ( pTempB1 && pTempB2 )
{
- pTemp = Aig_TableLookup( p, Aig_ObjCreateGhost(p, Aig_Not(pTempB1), Aig_Not(pTempB2), AIG_OBJ_AND) );
+ pTemp = Aig_TableLookupInt( p, Aig_Not(pTempB1), Aig_Not(pTempB2) );
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) );
+ return Aig_Or( p, Aig_And(p, pC, p1), Aig_And(p, Aig_Not(pC), p0) );
+ return Aig_Not( Aig_Or( p, Aig_And(p, pC, Aig_Not(p1)), Aig_And(p, Aig_Not(pC), Aig_Not(p0)) ) );
+// return Aig_Or( p, Aig_And(p, pC, p1), Aig_And(p, Aig_Not(pC), p0) );
}
/**Function*************************************************************
@@ -385,7 +434,7 @@ Aig_Obj_t * Aig_Miter( Aig_Man_t * p, Vec_Ptr_t * vPairs )
assert( vPairs->nSize > 0 );
assert( vPairs->nSize % 2 == 0 );
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] = Aig_Not( Aig_Exor( p, (Aig_Obj_t *)vPairs->pArray[i], (Aig_Obj_t *)vPairs->pArray[i+1] ) );
vPairs->nSize = vPairs->nSize/2;
return Aig_Not( Aig_Multi_rec( p, (Aig_Obj_t **)vPairs->pArray, vPairs->nSize, AIG_OBJ_AND ) );
}
@@ -407,7 +456,7 @@ Aig_Obj_t * Aig_MiterTwo( Aig_Man_t * p, Vec_Ptr_t * vNodes1, Vec_Ptr_t * vNodes
assert( vNodes1->nSize > 0 && vNodes1->nSize > 0 );
assert( vNodes1->nSize == vNodes2->nSize );
for ( i = 0; i < vNodes1->nSize; i++ )
- vNodes1->pArray[i] = Aig_Not( Aig_Exor( p, vNodes1->pArray[i], vNodes2->pArray[i] ) );
+ vNodes1->pArray[i] = Aig_Not( Aig_Exor( p, (Aig_Obj_t *)vNodes1->pArray[i], (Aig_Obj_t *)vNodes2->pArray[i] ) );
return Aig_Not( Aig_Multi_rec( p, (Aig_Obj_t **)vNodes1->pArray, vNodes1->nSize, AIG_OBJ_AND ) );
}
@@ -474,8 +523,84 @@ Aig_Obj_t * Aig_CreateExor( Aig_Man_t * p, int nVars )
return pFunc;
}
+/**Function*************************************************************
+
+ Synopsis [Implements ITE operation.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Aig_MuxTest()
+{
+ Vec_Ptr_t * vNodes;
+ Aig_Man_t * p;
+ Aig_Obj_t * pObj, * pFanin0, * pFanin1, * pCtrl;
+ int nNodes = 2000;
+ int i,nPIs = 20;
+// srand( time(NULL) );
+ srand( 321 );
+ vNodes = Vec_PtrAlloc( 100 );
+ // create a bunch of random MUXes
+ p = Aig_ManStart( 10000 );
+ for ( i = 0; i < nPIs; i++ )
+ Aig_IthVar(p,i);
+ for ( i = 0; i < nNodes; i++ )
+ {
+ if ( rand() % 10 == 0 )
+ pCtrl = Aig_ManConst0(p);
+ else if ( rand() % 10 == 0 )
+ pCtrl = Aig_ManConst1(p);
+ else if ( rand() % 3 == 0 || i < nPIs )
+ pCtrl = Aig_IthVar( p, rand() % nPIs );
+ else
+ pCtrl = (Aig_Obj_t *)Vec_PtrEntry(vNodes, rand() % i);
+ if ( rand() % 2 == 0 )
+ pCtrl = Aig_Not( pCtrl );
+
+ if ( rand() % 10 == 0 )
+ pFanin1 = Aig_ManConst0(p);
+ else if ( rand() % 10 == 0 )
+ pFanin1 = Aig_ManConst1(p);
+ else if ( rand() % 3 == 0 || i < nPIs )
+ pFanin1 = Aig_IthVar( p, rand() % nPIs );
+ else
+ pFanin1 = (Aig_Obj_t *)Vec_PtrEntry(vNodes, rand() % i);
+ if ( rand() % 2 == 0 )
+ pFanin1 = Aig_Not( pFanin1 );
+
+ if ( rand() % 10 == 0 )
+ pFanin0 = Aig_ManConst0(p);
+ else if ( rand() % 10 == 0 )
+ pFanin0 = Aig_ManConst1(p);
+ else if ( rand() % 3 == 0 || i < nPIs )
+ pFanin0 = Aig_IthVar( p, rand() % nPIs );
+ else
+ pFanin0 = (Aig_Obj_t *)Vec_PtrEntry(vNodes, rand() % i);
+ if ( rand() % 2 == 0 )
+ pFanin0 = Aig_Not( pFanin0 );
+
+ pObj = Aig_Mux( p, pCtrl, pFanin1, pFanin0 );
+ Vec_PtrPush( vNodes, pObj );
+ }
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
+ Aig_ObjCreatePo( p, pObj );
+ Vec_PtrFree( vNodes );
+
+ printf( "Number of nodes = %6d.\n", Aig_ManObjNum(p) );
+ Aig_ManCleanup( p );
+ printf( "Number of nodes = %6d.\n", Aig_ManObjNum(p) );
+ Aig_ManDumpBlif( p, "test1.blif", NULL, NULL );
+ Aig_ManStop( p );
+}
+
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/aig/aigOrder.c b/src/aig/aig/aigOrder.c
index 746f0f18..21bf8b8e 100644
--- a/src/aig/aig/aigOrder.c
+++ b/src/aig/aig/aigOrder.c
@@ -20,6 +20,9 @@
#include "aig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -169,3 +172,5 @@ void Aig_ObjOrderAdvance( Aig_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/aig/aigPart.c b/src/aig/aig/aigPart.c
index 6849ba70..52960cd3 100644
--- a/src/aig/aig/aigPart.c
+++ b/src/aig/aig/aigPart.c
@@ -20,6 +20,10 @@
#include "aig.h"
#include "tim.h"
+#include "fra.h"
+
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -30,10 +34,10 @@ struct Part_Man_t_
{
int nChunkSize; // the size of one chunk of memory (~1 Mb)
int nStepSize; // the step size in saving memory (~64 bytes)
- char * pFreeBuf; // the pointer to ABC_FREE memory
- int nFreeSize; // the size of remaining ABC_FREE memory
+ char * pFreeBuf; // the pointer to free memory
+ int nFreeSize; // the size of remaining free memory
Vec_Ptr_t * vMemory; // the memory allocated
- Vec_Ptr_t * vFree; // the vector of ABC_FREE pieces of memory
+ Vec_Ptr_t * vFree; // the vector of free pieces of memory
};
typedef struct Part_One_t_ Part_One_t;
@@ -91,7 +95,7 @@ void Part_ManStop( Part_Man_t * p )
{
void * pMemory;
int i;
- Vec_PtrForEachEntry( p->vMemory, pMemory, i )
+ Vec_PtrForEachEntry( void *, p->vMemory, pMemory, i )
ABC_FREE( pMemory );
Vec_PtrFree( p->vMemory );
Vec_PtrFree( p->vFree );
@@ -116,7 +120,7 @@ char * Part_ManFetch( Part_Man_t * p, int nSize )
assert( nSize > 0 );
Type = Part_SizeType( nSize, p->nStepSize );
Vec_PtrFillExtra( p->vFree, Type + 1, NULL );
- if ( (pMemory = Vec_PtrEntry( p->vFree, Type )) )
+ if ( (pMemory = (char *)Vec_PtrEntry( p->vFree, Type )) )
{
Vec_PtrWriteEntry( p->vFree, Type, Part_OneNext(pMemory) );
return pMemory;
@@ -151,7 +155,7 @@ void Part_ManRecycle( Part_Man_t * p, char * pMemory, int nSize )
int Type;
Type = Part_SizeType( nSize, p->nStepSize );
Vec_PtrFillExtra( p->vFree, Type + 1, NULL );
- Part_OneSetNext( pMemory, Vec_PtrEntry(p->vFree, Type) );
+ Part_OneSetNext( pMemory, (char *)Vec_PtrEntry(p->vFree, Type) );
Vec_PtrWriteEntry( p->vFree, Type, pMemory );
}
@@ -288,8 +292,8 @@ Vec_Ptr_t * Aig_ManSupports( Aig_Man_t * pMan )
{
if ( Aig_ObjIsNode(pObj) )
{
- pPart0 = Aig_ObjFanin0(pObj)->pData;
- pPart1 = Aig_ObjFanin1(pObj)->pData;
+ pPart0 = (Part_One_t *)Aig_ObjFanin0(pObj)->pData;
+ pPart1 = (Part_One_t *)Aig_ObjFanin1(pObj)->pData;
pObj->pData = Part_ManMergeEntry( p, pPart0, pPart1, pObj->nRefs );
assert( pPart0->nRefs > 0 );
if ( --pPart0->nRefs == 0 )
@@ -301,7 +305,7 @@ Vec_Ptr_t * Aig_ManSupports( Aig_Man_t * pMan )
}
if ( Aig_ObjIsPo(pObj) )
{
- pPart0 = Aig_ObjFanin0(pObj)->pData;
+ pPart0 = (Part_One_t *)Aig_ObjFanin0(pObj)->pData;
vSupp = Part_ManTransferEntry(pPart0);
Vec_IntPush( vSupp, (int)(long)pObj->pNext );
Vec_PtrPush( vSupports, vSupp );
@@ -369,11 +373,11 @@ Vec_Ptr_t * Aig_ManSupportsInverse( Aig_Man_t * p )
for ( i = 0; i < Aig_ManPiNum(p); i++ )
Vec_PtrPush( vSuppsInv, Vec_IntAlloc(8) );
// transforms the supports into the inverse supports
- Vec_PtrForEachEntry( vSupps, vSupp, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vSupps, vSupp, i )
{
iOut = Vec_IntPop( vSupp );
Vec_IntForEachEntry( vSupp, iIn, k )
- Vec_IntPush( Vec_PtrEntry(vSuppsInv, iIn), iOut );
+ Vec_IntPush( (Vec_Int_t *)Vec_PtrEntry(vSuppsInv, iIn), iOut );
}
Vec_VecFree( (Vec_Vec_t *)vSupps );
return vSuppsInv;
@@ -399,7 +403,7 @@ Vec_Ptr_t * Aig_ManSupportsRegisters( Aig_Man_t * p )
vSupports = Aig_ManSupports( p );
// transforms the supports into the latch dependency matrix
vMatrix = Vec_PtrStart( Aig_ManRegNum(p) );
- Vec_PtrForEachEntry( vSupports, vSupp, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vSupports, vSupp, i )
{
// skip true POs
iOut = Vec_IntPop( vSupp );
@@ -426,7 +430,7 @@ Vec_Ptr_t * Aig_ManSupportsRegisters( Aig_Man_t * p )
}
Vec_PtrFree( vSupports );
// check that all supports are used
- Vec_PtrForEachEntry( vMatrix, vSupp, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vMatrix, vSupp, i )
assert( vSupp != NULL );
return vMatrix;
}
@@ -515,13 +519,13 @@ int Aig_ManPartitionSmartFindPart( Vec_Ptr_t * vPartSuppsAll, Vec_Ptr_t * vParts
int i, nCommon, iBest;
iBest = -1;
ValueBest = 0;
- Vec_PtrForEachEntry( vPartSuppsAll, vPartSupp, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vPartSuppsAll, vPartSupp, i )
{
// vPart = Vec_PtrEntry( vPartsAll, i );
// if ( nSuppSizeLimit > 0 && Vec_IntSize(vPart) >= nSuppSizeLimit )
// continue;
// nCommon = Vec_IntTwoCountCommon( vPartSupp, vOne );
- nCommon = Aig_ManSuppCharCommon( Vec_PtrEntry(vPartSuppsBit, i), vOne );
+ nCommon = Aig_ManSuppCharCommon( (unsigned *)Vec_PtrEntry(vPartSuppsBit, i), vOne );
if ( nCommon == 0 )
continue;
if ( nCommon == Vec_IntSize(vOne) )
@@ -563,9 +567,9 @@ void Aig_ManPartitionPrint( Aig_Man_t * p, Vec_Ptr_t * vPartsAll, Vec_Ptr_t * vP
int i, nOutputs, Counter;
Counter = 0;
- Vec_PtrForEachEntry( vPartSuppsAll, vOne, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vPartSuppsAll, vOne, i )
{
- nOutputs = Vec_IntSize(Vec_PtrEntry(vPartsAll, i));
+ nOutputs = Vec_IntSize((Vec_Int_t *)Vec_PtrEntry(vPartsAll, i));
printf( "%d=(%d,%d) ", i, Vec_IntSize(vOne), nOutputs );
Counter += nOutputs;
if ( i == Vec_PtrSize(vPartsAll) - 1 )
@@ -597,7 +601,7 @@ void Aig_ManPartitionCompact( Vec_Ptr_t * vPartsAll, Vec_Ptr_t * vPartSuppsAll,
// pack smaller partitions into larger blocks
iPart = 0;
vPart = vPartSupp = NULL;
- Vec_PtrForEachEntry( vPartSuppsAll, vOne, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vPartSuppsAll, vOne, i )
{
if ( Vec_IntSize(vOne) < nSuppSizeLimit )
{
@@ -605,27 +609,27 @@ void Aig_ManPartitionCompact( Vec_Ptr_t * vPartsAll, Vec_Ptr_t * vPartSuppsAll,
{
assert( vPart == NULL );
vPartSupp = Vec_IntDup(vOne);
- vPart = Vec_PtrEntry(vPartsAll, i);
+ vPart = (Vec_Int_t *)Vec_PtrEntry(vPartsAll, i);
}
else
{
vPartSupp = Vec_IntTwoMerge( vTemp = vPartSupp, vOne );
Vec_IntFree( vTemp );
- vPart = Vec_IntTwoMerge( vTemp = vPart, Vec_PtrEntry(vPartsAll, i) );
+ vPart = Vec_IntTwoMerge( vTemp = vPart, (Vec_Int_t *)Vec_PtrEntry(vPartsAll, i) );
Vec_IntFree( vTemp );
- Vec_IntFree( Vec_PtrEntry(vPartsAll, i) );
+ Vec_IntFree( (Vec_Int_t *)Vec_PtrEntry(vPartsAll, i) );
}
if ( Vec_IntSize(vPartSupp) < nSuppSizeLimit )
continue;
}
else
- vPart = Vec_PtrEntry(vPartsAll, i);
+ vPart = (Vec_Int_t *)Vec_PtrEntry(vPartsAll, i);
// add the partition
Vec_PtrWriteEntry( vPartsAll, iPart, vPart );
vPart = NULL;
if ( vPartSupp )
{
- Vec_IntFree( Vec_PtrEntry(vPartSuppsAll, iPart) );
+ Vec_IntFree( (Vec_Int_t *)Vec_PtrEntry(vPartSuppsAll, iPart) );
Vec_PtrWriteEntry( vPartSuppsAll, iPart, vPartSupp );
vPartSupp = NULL;
}
@@ -638,7 +642,7 @@ void Aig_ManPartitionCompact( Vec_Ptr_t * vPartsAll, Vec_Ptr_t * vPartSuppsAll,
vPart = NULL;
assert( vPartSupp != NULL );
- Vec_IntFree( Vec_PtrEntry(vPartSuppsAll, iPart) );
+ Vec_IntFree( (Vec_Int_t *)Vec_PtrEntry(vPartSuppsAll, iPart) );
Vec_PtrWriteEntry( vPartSuppsAll, iPart, vPartSupp );
vPartSupp = NULL;
iPart++;
@@ -679,7 +683,7 @@ ABC_PRT( "Supps", clock() - clk );
clk = clock();
vPartsAll = Vec_PtrAlloc( 256 );
vPartSuppsAll = Vec_PtrAlloc( 256 );
- Vec_PtrForEachEntry( vSupports, vOne, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vSupports, vOne, i )
{
// get the output number
iOut = Vec_IntPop(vOne);
@@ -701,21 +705,21 @@ clk = clock();
else
{
// add output to this partition
- vPart = Vec_PtrEntry( vPartsAll, iPart );
+ vPart = (Vec_Int_t *)Vec_PtrEntry( vPartsAll, iPart );
Vec_IntPush( vPart, iOut );
// merge supports
- vPartSupp = Vec_PtrEntry( vPartSuppsAll, iPart );
+ vPartSupp = (Vec_Int_t *)Vec_PtrEntry( vPartSuppsAll, iPart );
vPartSupp = Vec_IntTwoMerge( vTemp = vPartSupp, vOne );
Vec_IntFree( vTemp );
// reinsert new support
Vec_PtrWriteEntry( vPartSuppsAll, iPart, vPartSupp );
- Aig_ManSuppCharAdd( Vec_PtrEntry(vPartSuppsBit, iPart), vOne, Aig_ManPiNum(p) );
+ Aig_ManSuppCharAdd( (unsigned *)Vec_PtrEntry(vPartSuppsBit, iPart), vOne, Aig_ManPiNum(p) );
}
}
// stop char-based support representation
- Vec_PtrForEachEntry( vPartSuppsBit, vTemp, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vPartSuppsBit, vTemp, i )
ABC_FREE( vTemp );
Vec_PtrFree( vPartSuppsBit );
@@ -728,13 +732,13 @@ ABC_PRT( "Parts", clock() - clk );
clk = clock();
// reorder partitions in the decreasing order of support sizes
// remember partition number in each partition support
- Vec_PtrForEachEntry( vPartSuppsAll, vOne, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vPartSuppsAll, vOne, i )
Vec_IntPush( vOne, i );
// sort the supports in the decreasing order
Vec_VecSort( (Vec_Vec_t *)vPartSuppsAll, 1 );
// reproduce partitions
vPartsAll2 = Vec_PtrAlloc( 256 );
- Vec_PtrForEachEntry( vPartSuppsAll, vOne, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vPartSuppsAll, vOne, i )
Vec_PtrPush( vPartsAll2, Vec_PtrEntry(vPartsAll, Vec_IntPop(vOne)) );
Vec_PtrFree( vPartsAll );
vPartsAll = vPartsAll2;
@@ -759,7 +763,7 @@ if ( fVerbose )
*pvPartSupps = vPartSuppsAll;
/*
// converts from intergers to nodes
- Vec_PtrForEachEntry( vPartsAll, vPart, iPart )
+ Vec_PtrForEachEntry( Vec_Int_t *, vPartsAll, vPart, iPart )
{
vPartPtr = Vec_PtrAlloc( Vec_IntSize(vPart) );
Vec_IntForEachEntry( vPart, iOut, i )
@@ -793,7 +797,7 @@ Vec_Ptr_t * Aig_ManPartitionSmartRegisters( Aig_Man_t * pAig, int nSuppSizeLimit
clk = clock();
vSupports = Aig_ManSupportsRegisters( pAig );
assert( Vec_PtrSize(vSupports) == Aig_ManRegNum(pAig) );
- Vec_PtrForEachEntry( vSupports, vOne, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vSupports, vOne, i )
Vec_IntPush( vOne, i );
if ( fVerbose )
{
@@ -807,7 +811,7 @@ ABC_PRT( "Supps", clock() - clk );
clk = clock();
vPartsAll = Vec_PtrAlloc( 256 );
vPartSuppsAll = Vec_PtrAlloc( 256 );
- Vec_PtrForEachEntry( vSupports, vOne, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vSupports, vOne, i )
{
// get the output number
iOut = Vec_IntPop(vOne);
@@ -829,21 +833,21 @@ clk = clock();
else
{
// add output to this partition
- vPart = Vec_PtrEntry( vPartsAll, iPart );
+ vPart = (Vec_Int_t *)Vec_PtrEntry( vPartsAll, iPart );
Vec_IntPush( vPart, iOut );
// merge supports
- vPartSupp = Vec_PtrEntry( vPartSuppsAll, iPart );
+ vPartSupp = (Vec_Int_t *)Vec_PtrEntry( vPartSuppsAll, iPart );
vPartSupp = Vec_IntTwoMerge( vTemp = vPartSupp, vOne );
Vec_IntFree( vTemp );
// reinsert new support
Vec_PtrWriteEntry( vPartSuppsAll, iPart, vPartSupp );
- Aig_ManSuppCharAdd( Vec_PtrEntry(vPartSuppsBit, iPart), vOne, Vec_PtrSize(vSupports) );
+ Aig_ManSuppCharAdd( (unsigned *)Vec_PtrEntry(vPartSuppsBit, iPart), vOne, Vec_PtrSize(vSupports) );
}
}
// stop char-based support representation
- Vec_PtrForEachEntry( vPartSuppsBit, vTemp, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vPartSuppsBit, vTemp, i )
ABC_FREE( vTemp );
Vec_PtrFree( vPartSuppsBit );
@@ -856,13 +860,13 @@ ABC_PRT( "Parts", clock() - clk );
clk = clock();
// reorder partitions in the decreasing order of support sizes
// remember partition number in each partition support
- Vec_PtrForEachEntry( vPartSuppsAll, vOne, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vPartSuppsAll, vOne, i )
Vec_IntPush( vOne, i );
// sort the supports in the decreasing order
Vec_VecSort( (Vec_Vec_t *)vPartSuppsAll, 1 );
// reproduce partitions
vPartsAll2 = Vec_PtrAlloc( 256 );
- Vec_PtrForEachEntry( vPartSuppsAll, vOne, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vPartSuppsAll, vOne, i )
Vec_PtrPush( vPartsAll2, Vec_PtrEntry(vPartsAll, Vec_IntPop(vOne)) );
Vec_PtrFree( vPartsAll );
vPartsAll = vPartsAll2;
@@ -888,7 +892,7 @@ if ( fVerbose )
/*
// converts from intergers to nodes
- Vec_PtrForEachEntry( vPartsAll, vPart, iPart )
+ Vec_PtrForEachEntry( Vec_Int_t *, vPartsAll, vPart, iPart )
{
vPartPtr = Vec_PtrAlloc( Vec_IntSize(vPart) );
Vec_IntForEachEntry( vPart, iOut, i )
@@ -919,7 +923,7 @@ Vec_Ptr_t * Aig_ManPartitionNaive( Aig_Man_t * p, int nPartSize )
nParts = (Aig_ManPoNum(p) / nPartSize) + ((Aig_ManPoNum(p) % nPartSize) > 0);
vParts = (Vec_Ptr_t *)Vec_VecStart( nParts );
Aig_ManForEachPo( p, pObj, i )
- Vec_IntPush( Vec_PtrEntry(vParts, i / nPartSize), i );
+ Vec_IntPush( (Vec_Int_t *)Vec_PtrEntry(vParts, i / nPartSize), i );
return vParts;
}
@@ -940,18 +944,18 @@ Aig_Obj_t * Aig_ManDupPart_rec( Aig_Man_t * pNew, Aig_Man_t * pOld, Aig_Obj_t *
{
assert( !Aig_IsComplement(pObj) );
if ( Aig_ObjIsTravIdCurrent(pOld, pObj) )
- return pObj->pData;
+ return (Aig_Obj_t *)pObj->pData;
Aig_ObjSetTravIdCurrent(pOld, pObj);
if ( Aig_ObjIsPi(pObj) )
{
assert( Vec_IntSize(vSuppMap) == Aig_ManPiNum(pNew) );
Vec_IntPush( vSuppMap, (int)(long)pObj->pNext );
- return pObj->pData = Aig_ObjCreatePi(pNew);
+ return (Aig_Obj_t *)(pObj->pData = Aig_ObjCreatePi(pNew));
}
assert( Aig_ObjIsNode(pObj) );
Aig_ManDupPart_rec( pNew, pOld, Aig_ObjFanin0(pObj), vSuppMap );
Aig_ManDupPart_rec( pNew, pOld, Aig_ObjFanin1(pObj), vSuppMap );
- return pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
+ return (Aig_Obj_t *)(pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) ));
}
/**Function*************************************************************
@@ -1133,7 +1137,7 @@ Vec_Ptr_t * Aig_ManSupportNodes( Aig_Man_t * p, Vec_Ptr_t * vParts )
int i, k, iOut;
Aig_ManSetPioNumbers( p );
vPartSupps = Vec_PtrAlloc( Vec_PtrSize(vParts) );
- Vec_PtrForEachEntry( vParts, vPart, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vParts, vPart, i )
{
vSupport = Vec_IntAlloc( 100 );
Aig_ManIncrementTravId( p );
@@ -1180,8 +1184,8 @@ Vec_Ptr_t * Aig_ManMiterPartitioned( Aig_Man_t * p1, Aig_Man_t * p2, int nPartSi
for ( i = 0; i < Vec_PtrSize(vParts); i++ )
{
// get partition and its support
- vPart = Vec_PtrEntry( vParts, i );
- vPartSupp = Vec_PtrEntry( vPartSupps, i );
+ vPart = (Vec_Int_t *)Vec_PtrEntry( vParts, i );
+ vPartSupp = (Vec_Int_t *)Vec_PtrEntry( vPartSupps, i );
// create the new miter
pNew = Aig_ManStart( 1000 );
// create the PIs
@@ -1221,7 +1225,7 @@ Aig_Man_t * Aig_ManChoicePartitioned( Vec_Ptr_t * vAigs, int nPartSize, int nCon
{
// extern int Cmd_CommandExecute( void * pAbc, char * sCommand );
// extern void * Abc_FrameGetGlobalFrame();
- extern Aig_Man_t * Fra_FraigChoice( Aig_Man_t * pManAig, int nConfMax, int nLevelMax );
+// extern Aig_Man_t * Fra_FraigChoice( Aig_Man_t * pManAig, int nConfMax, int nLevelMax );
Vec_Ptr_t * vPios;
Vec_Ptr_t * vOutsTotal, * vOuts;
@@ -1235,11 +1239,11 @@ Aig_Man_t * Aig_ManChoicePartitioned( Vec_Ptr_t * vAigs, int nPartSize, int nCon
// compute the total number of IDs
nIdMax = 0;
- Vec_PtrForEachEntry( vAigs, pAig, i )
+ Vec_PtrForEachEntry( Aig_Man_t *, vAigs, pAig, i )
nIdMax += Aig_ManObjNumMax(pAig);
// partition the first AIG in the array
- pAig = Vec_PtrEntry( vAigs, 0 );
+ pAig = (Aig_Man_t *)Vec_PtrEntry( vAigs, 0 );
vParts = Aig_ManPartitionSmart( pAig, nPartSize, 0, NULL );
// start the total fraiged AIG
@@ -1248,7 +1252,7 @@ Aig_Man_t * Aig_ManChoicePartitioned( Vec_Ptr_t * vAigs, int nPartSize, int nCon
vOutsTotal = Vec_PtrStart( Aig_ManPoNum(pAig) );
// set the PI numbers
- Vec_PtrForEachEntry( vAigs, pAig, i )
+ Vec_PtrForEachEntry( Aig_Man_t *, vAigs, pAig, i )
Aig_ManForEachPi( pAig, pObj, k )
pObj->pNext = (Aig_Obj_t *)(long)k;
@@ -1256,18 +1260,18 @@ Aig_Man_t * Aig_ManChoicePartitioned( Vec_Ptr_t * vAigs, int nPartSize, int nCon
// create the total fraiged AIG
vPartSupp = Vec_IntAlloc( 100 ); // maps part PI num into total PI num
- Vec_PtrForEachEntry( vParts, vPart, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vParts, vPart, i )
{
// derive the partition AIG
pAigPart = Aig_ManStart( 5000 );
// pAigPart->pName = Extra_UtilStrsav( pAigPart->pName );
Vec_IntClear( vPartSupp );
- Vec_PtrForEachEntry( vAigs, pAig, k )
+ Vec_PtrForEachEntry( Aig_Man_t *, vAigs, pAig, k )
{
vOuts = Aig_ManDupPart( pAigPart, pAig, vPart, vPartSupp, 0 );
if ( k == 0 )
{
- Vec_PtrForEachEntry( vOuts, pObj, m )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vOuts, pObj, m )
Aig_ObjCreatePo( pAigPart, pObj );
}
Vec_PtrFree( vOuts );
@@ -1275,7 +1279,7 @@ Aig_Man_t * Aig_ManChoicePartitioned( Vec_Ptr_t * vAigs, int nPartSize, int nCon
// derive the total AIG from the partitioned AIG
vOuts = Aig_ManDupPart( pAigTotal, pAigPart, vPart, vPartSupp, 1 );
// add to the outputs
- Vec_PtrForEachEntry( vOuts, pObj, k )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vOuts, pObj, k )
{
assert( Vec_PtrEntry( vOutsTotal, Vec_IntEntry(vPart,k) ) == NULL );
Vec_PtrWriteEntry( vOutsTotal, Vec_IntEntry(vPart,k), pObj );
@@ -1310,12 +1314,12 @@ Aig_Man_t * Aig_ManChoicePartitioned( Vec_Ptr_t * vAigs, int nPartSize, int nCon
// Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "set progressbar" );
// clear the PI numbers
- Vec_PtrForEachEntry( vAigs, pAig, i )
+ Vec_PtrForEachEntry( Aig_Man_t *, vAigs, pAig, i )
Aig_ManForEachPi( pAig, pObj, k )
pObj->pNext = NULL;
// add the outputs in the same order
- Vec_PtrForEachEntry( vOutsTotal, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vOutsTotal, pObj, i )
Aig_ObjCreatePo( pAigTotal, pObj );
Vec_PtrFree( vOutsTotal );
@@ -1324,14 +1328,14 @@ Aig_Man_t * Aig_ManChoicePartitioned( Vec_Ptr_t * vAigs, int nPartSize, int nCon
// create the equivalent nodes lists
Aig_ManMarkValidChoices( pAig );
// reconstruct the network
- vPios = Aig_ManOrderPios( pAig, Vec_PtrEntry(vAigs,0) );
+ vPios = Aig_ManOrderPios( pAig, (Aig_Man_t *)Vec_PtrEntry(vAigs,0) );
pAig = Aig_ManDupDfsGuided( pTemp = pAig, vPios );
Aig_ManStop( pTemp );
Vec_PtrFree( vPios );
// duplicate the timing manager
- pTemp = Vec_PtrEntry( vAigs, 0 );
+ pTemp = (Aig_Man_t *)Vec_PtrEntry( vAigs, 0 );
if ( pTemp->pManTime )
- pAig->pManTime = Tim_ManDup( pTemp->pManTime, 0 );
+ pAig->pManTime = Tim_ManDup( (Tim_Man_t *)pTemp->pManTime, 0 );
// reset levels
Aig_ManChoiceLevel( pAig );
return pAig;
@@ -1351,7 +1355,7 @@ Aig_Man_t * Aig_ManChoicePartitioned( Vec_Ptr_t * vAigs, int nPartSize, int nCon
***********************************************************************/
Aig_Man_t * Aig_ManFraigPartitioned( Aig_Man_t * pAig, int nPartSize, int nConfMax, int nLevelMax, int fVerbose )
{
- extern Aig_Man_t * Fra_FraigChoice( Aig_Man_t * pManAig, int nConfMax, int nLevelMax );
+// extern Aig_Man_t * Fra_FraigChoice( Aig_Man_t * pManAig, int nConfMax, int nLevelMax );
Aig_Man_t * pAigPart, * pAigTemp;
Vec_Int_t * vPart;
@@ -1370,7 +1374,7 @@ Aig_Man_t * Aig_ManFraigPartitioned( Aig_Man_t * pAig, int nPartSize, int nConfM
Aig_ManSetPioNumbers( pAig );
// create the total fraiged AIG
- Vec_PtrForEachEntry( vParts, vPart, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vParts, vPart, i )
{
// derive the partition AIG
pAigPart = Aig_ManDupPartAll( pAig, vPart );
@@ -1460,7 +1464,7 @@ void Aig_ManChoiceConstructiveOne( Aig_Man_t * pNew, Aig_Man_t * pPrev, Aig_Man_
Aig_ManForEachObj( pNew, pObj, i )
pObj->fMarkB = 1;
Aig_ManForEachObj( pPrev, pObj, i )
- assert( Aig_Regular(pObj->pData)->fMarkB );
+ assert( Aig_Regular((Aig_Obj_t *)pObj->pData)->fMarkB );
Aig_ManForEachObj( pNew, pObj, i )
pObj->fMarkB = 0;
// make sure the nodes of pThis point to pPrev
@@ -1484,14 +1488,14 @@ void Aig_ManChoiceConstructiveOne( Aig_Man_t * pNew, Aig_Man_t * pPrev, Aig_Man_
if ( pObj->pHaig == NULL )
continue;
// pObj->pData and pObj->pHaig->pData are equivalent
- Aig_ObjSetRepr_( pNew, Aig_Regular(pObj->pData), Aig_Regular(pObj->pHaig->pData) );
+ Aig_ObjSetRepr_( pNew, Aig_Regular((Aig_Obj_t *)pObj->pData), Aig_Regular((Aig_Obj_t *)pObj->pHaig->pData) );
}
// set the inputs of POs as equivalent
Aig_ManForEachPo( pThis, pObj, i )
{
pObjNew = Aig_ObjFanin0( Aig_ManPo(pNew,i) );
// pObjNew and Aig_ObjFanin0(pObj)->pData are equivalent
- Aig_ObjSetRepr_( pNew, pObjNew, Aig_Regular(Aig_ObjFanin0(pObj)->pData) );
+ Aig_ObjSetRepr_( pNew, pObjNew, Aig_Regular((Aig_Obj_t *)Aig_ObjFanin0(pObj)->pData) );
}
}
@@ -1548,7 +1552,7 @@ Aig_Man_t * Aig_ManChoiceConstructive( Vec_Ptr_t * vAigs, int fVerbose )
Aig_Man_t * pNew, * pThis, * pPrev, * pTemp;
int i;
// start AIG with choices
- pPrev = Vec_PtrEntry( vAigs, 0 );
+ pPrev = (Aig_Man_t *)Vec_PtrEntry( vAigs, 0 );
pNew = Aig_ManDupOrdered( pPrev );
// create room for equivalent nodes and representatives
assert( pNew->pReprs == NULL );
@@ -1556,7 +1560,7 @@ Aig_Man_t * Aig_ManChoiceConstructive( Vec_Ptr_t * vAigs, int fVerbose )
pNew->pReprs = ABC_ALLOC( Aig_Obj_t *, pNew->nReprsAlloc );
memset( pNew->pReprs, 0, sizeof(Aig_Obj_t *) * pNew->nReprsAlloc );
// add other AIGs one by one
- Vec_PtrForEachEntryStart( vAigs, pThis, i, 1 )
+ Vec_PtrForEachEntryStart( Aig_Man_t *, vAigs, pThis, i, 1 )
{
Aig_ManChoiceConstructiveOne( pNew, pPrev, pThis );
pPrev = pThis;
@@ -1566,14 +1570,14 @@ Aig_Man_t * Aig_ManChoiceConstructive( Vec_Ptr_t * vAigs, int fVerbose )
// create the equivalent nodes lists
Aig_ManMarkValidChoices( pNew );
// reconstruct the network
- vPios = Aig_ManOrderPios( pNew, Vec_PtrEntry( vAigs, 0 ) );
+ vPios = Aig_ManOrderPios( pNew, (Aig_Man_t *)Vec_PtrEntry( vAigs, 0 ) );
pNew = Aig_ManDupDfsGuided( pTemp = pNew, vPios );
Aig_ManStop( pTemp );
Vec_PtrFree( vPios );
// duplicate the timing manager
- pTemp = Vec_PtrEntry( vAigs, 0 );
+ pTemp = (Aig_Man_t *)Vec_PtrEntry( vAigs, 0 );
if ( pTemp->pManTime )
- pNew->pManTime = Tim_ManDup( pTemp->pManTime, 0 );
+ pNew->pManTime = Tim_ManDup( (Tim_Man_t *)pTemp->pManTime, 0 );
// reset levels
Aig_ManChoiceLevel( pNew );
return pNew;
@@ -1590,3 +1594,5 @@ Aig_Man_t * Aig_ManChoiceConstructive( Vec_Ptr_t * vAigs, int fVerbose )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/aig/aigPartReg.c b/src/aig/aig/aigPartReg.c
index dd10e91e..56fa80e4 100644
--- a/src/aig/aig/aigPartReg.c
+++ b/src/aig/aig/aigPartReg.c
@@ -21,6 +21,9 @@
#include "aig.h"
//#include "fra.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -127,7 +130,7 @@ int Aig_ManRegFindSeed( Aig_ManPre_t * p )
if ( p->pfUsedRegs[i] )
continue;
nRegsCur = 0;
- vRegs = Vec_PtrEntry( p->vMatrix, i );
+ vRegs = (Vec_Int_t *)Vec_PtrEntry( p->vMatrix, i );
Vec_IntForEachEntry( vRegs, iReg, k )
nRegsCur += !p->pfUsedRegs[iReg];
if ( nRegsMax < nRegsCur )
@@ -155,13 +158,13 @@ int Aig_ManRegFindBestVar( Aig_ManPre_t * p )
Vec_Int_t * vSupp;
int nNewVars, nNewVarsBest = ABC_INFINITY;
int iVarFree, iVarSupp, iVarBest = -1, i, k;
- // go through the ABC_FREE variables
+ // go through the free variables
Vec_IntForEachEntry( p->vFreeVars, iVarFree, i )
{
// if ( p->pfUsedRegs[iVarFree] )
// continue;
// get support of this variable
- vSupp = Vec_PtrEntry( p->vMatrix, iVarFree );
+ vSupp = (Vec_Int_t *)Vec_PtrEntry( p->vMatrix, iVarFree );
// count the number of new vars
nNewVars = 0;
Vec_IntForEachEntry( vSupp, iVarSupp, k )
@@ -205,7 +208,7 @@ void Aig_ManRegPartitionAdd( Aig_ManPre_t * p, int iReg )
p->pfUsedRegs[iReg] = 1;
Vec_IntPush( p->vUniques, iReg );
}
- // remove it from the ABC_FREE variables
+ // remove it from the free variables
if ( Vec_IntSize(p->vFreeVars) > 0 )
{
assert( p->pfPartVars[iReg] );
@@ -218,7 +221,7 @@ void Aig_ManRegPartitionAdd( Aig_ManPre_t * p, int iReg )
p->pfPartVars[iReg] = 1;
Vec_IntPush( p->vRegs, iReg );
// add new variables
- vSupp = Vec_PtrEntry( p->vMatrix, iReg );
+ vSupp = (Vec_Int_t *)Vec_PtrEntry( p->vMatrix, iReg );
Vec_IntForEachEntry( vSupp, iVar, i )
{
if ( p->pfPartVars[iVar] )
@@ -253,7 +256,7 @@ Vec_Ptr_t * Aig_ManRegProjectOnehots( Aig_Man_t * pAig, Aig_Man_t * pPart, Vec_P
pObj->iData = i;
// go through each group and check if registers are involved in this one
nOffset = Aig_ManPiNum(pAig)-Aig_ManRegNum(pAig);
- Vec_PtrForEachEntry( vOnehots, vGroup, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vOnehots, vGroup, i )
{
vGroupNew = NULL;
Vec_IntForEachEntry( vGroup, iReg, k )
@@ -263,7 +266,7 @@ Vec_Ptr_t * Aig_ManRegProjectOnehots( Aig_Man_t * pAig, Aig_Man_t * pPart, Vec_P
continue;
if ( vGroupNew == NULL )
vGroupNew = Vec_IntAlloc( Vec_IntSize(vGroup) );
- pObjNew = pObj->pData;
+ pObjNew = (Aig_Obj_t *)pObj->pData;
Vec_IntPush( vGroupNew, pObjNew->iData );
}
if ( vGroupNew == NULL )
@@ -284,7 +287,7 @@ Vec_Ptr_t * Aig_ManRegProjectOnehots( Aig_Man_t * pAig, Aig_Man_t * pPart, Vec_P
if ( vOnehotsPart && fVerbose )
{
printf( "Partition contains %d groups of 1-hot registers: { ", Vec_PtrSize(vOnehotsPart) );
- Vec_PtrForEachEntry( vOnehotsPart, vGroup, k )
+ Vec_PtrForEachEntry( Vec_Int_t *, vOnehotsPart, vGroup, k )
printf( "%d ", Vec_IntSize(vGroup) );
printf( "}\n" );
}
@@ -335,7 +338,7 @@ Aig_Man_t * Aig_ManRegCreatePart( Aig_Man_t * pAig, Vec_Int_t * vPart, int * pnC
nCountPis += Aig_ObjIsTravIdCurrent(pAig, pObj);
// count outputs of other registers
Aig_ManForEachLoSeq( pAig, pObj, i )
- nCountRegs += Aig_ObjIsTravIdCurrent(pAig, pObj);
+ nCountRegs += Aig_ObjIsTravIdCurrent(pAig, pObj);
if ( pnCountPis )
*pnCountPis = nCountPis;
if ( pnCountRegs )
@@ -354,11 +357,11 @@ Aig_Man_t * Aig_ManRegCreatePart( Aig_Man_t * pAig, Vec_Int_t * vPart, int * pnC
{
pObj = Aig_ManPi(pAig, nOffset+iOut);
pObj->pData = Aig_ObjCreatePi(pNew);
- Aig_ObjCreatePo( pNew, pObj->pData );
+ Aig_ObjCreatePo( pNew, (Aig_Obj_t *)pObj->pData );
Aig_ObjSetTravIdCurrent( pAig, pObj ); // added
}
// create the nodes
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
if ( Aig_ObjIsNode(pObj) )
pObj->pData = Aig_And(pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
// add real POs for the registers
@@ -377,9 +380,9 @@ Aig_Man_t * Aig_ManRegCreatePart( Aig_Man_t * pAig, Vec_Int_t * vPart, int * pnC
// map constant nodes
pMapBack[0] = 0;
// logic cones of register outputs
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
{
- pObjNew = Aig_Regular(pObj->pData);
+ pObjNew = Aig_Regular((Aig_Obj_t *)pObj->pData);
pMapBack[pObjNew->Id] = pObj->Id;
}
// map register outputs
@@ -387,7 +390,7 @@ Aig_Man_t * Aig_ManRegCreatePart( Aig_Man_t * pAig, Vec_Int_t * vPart, int * pnC
Vec_IntForEachEntry( vPart, iOut, i )
{
pObj = Aig_ManPi(pAig, nOffset+iOut);
- pObjNew = pObj->pData;
+ pObjNew = (Aig_Obj_t *)pObj->pData;
pMapBack[pObjNew->Id] = pObj->Id;
}
*ppMapBack = pMapBack;
@@ -441,7 +444,7 @@ Vec_Ptr_t * Aig_ManRegPartitionSmart( Aig_Man_t * pAig, int nPartSize )
//printf( "Part %3d Reg %3d : Free = %4d. Total = %4d. Ratio = %6.2f. Unique = %4d.\n", i, k,
// Vec_IntSize(p->vFreeVars), Vec_IntSize(p->vRegs),
// 1.0*Vec_IntSize(p->vFreeVars)/Vec_IntSize(p->vRegs), Vec_IntSize(p->vUniques) );
- // quit if there are not ABC_FREE variables
+ // quit if there are not free variables
if ( Vec_IntSize(p->vFreeVars) == 0 )
break;
}
@@ -622,3 +625,5 @@ Vec_Ptr_t * Aig_ManRegPartitionLinear( Aig_Man_t * pAig, int nPartSize )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/aig/aigPartSat.c b/src/aig/aig/aigPartSat.c
index a8c9008f..3d9152ae 100644
--- a/src/aig/aig/aigPartSat.c
+++ b/src/aig/aig/aigPartSat.c
@@ -22,6 +22,9 @@
#include "satSolver.h"
#include "cnf.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*
The node partitioners defined in this file return array of intergers
@@ -80,7 +83,7 @@ Vec_Int_t * Aig_ManPartitionLevelized( Aig_Man_t * p, int nPartSize )
int i, k, Counter = 0;
vNodes = Aig_ManLevelize( p );
vId2Part = Vec_IntStart( Aig_ManObjNumMax(p) );
- Vec_VecForEachEntryReverseReverse( vNodes, pObj, i, k )
+ Vec_VecForEachEntryReverseReverse( Aig_Obj_t *, vNodes, pObj, i, k )
Vec_IntWriteEntry( vId2Part, Aig_ObjId(pObj), Counter++/nPartSize );
Vec_VecFree( vNodes );
return vId2Part;
@@ -107,13 +110,13 @@ Vec_Int_t * Aig_ManPartitionDfs( Aig_Man_t * p, int nPartSize, int fPreorder )
if ( fPreorder )
{
vNodes = Aig_ManDfsPreorder( p, 1 );
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
Vec_IntWriteEntry( vId2Part, Aig_ObjId(pObj), Counter++/nPartSize );
}
else
{
vNodes = Aig_ManDfs( p, 1 );
- Vec_PtrForEachEntryReverse( vNodes, pObj, i )
+ Vec_PtrForEachEntryReverse( Aig_Obj_t *, vNodes, pObj, i )
Vec_IntWriteEntry( vId2Part, Aig_ObjId(pObj), Counter++/nPartSize );
}
Vec_PtrFree( vNodes );
@@ -179,7 +182,7 @@ Aig_Man_t * Aig_ManPartSplitOne( Aig_Man_t * p, Vec_Ptr_t * vNodes, Vec_Int_t **
int i;
// mark these nodes
Aig_ManIncrementTravId( p );
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
{
Aig_ObjSetTravIdCurrent( p, pObj );
pObj->pData = NULL;
@@ -187,14 +190,14 @@ Aig_Man_t * Aig_ManPartSplitOne( Aig_Man_t * p, Vec_Ptr_t * vNodes, Vec_Int_t **
// add these nodes in a DFS order
pNew = Aig_ManStart( Vec_PtrSize(vNodes) );
vPio2Id = Vec_IntAlloc( 100 );
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
Aig_ManPartSplitOne_rec( pNew, p, pObj, vPio2Id );
// add the POs
- Vec_PtrForEachEntry( vNodes, pObj, i )
- if ( Aig_ObjRefs(pObj->pData) != Aig_ObjRefs(pObj) )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
+ if ( Aig_ObjRefs((Aig_Obj_t *)pObj->pData) != Aig_ObjRefs(pObj) )
{
- assert( Aig_ObjRefs(pObj->pData) < Aig_ObjRefs(pObj) );
- Aig_ObjCreatePo( pNew, pObj->pData );
+ assert( Aig_ObjRefs((Aig_Obj_t *)pObj->pData) < Aig_ObjRefs(pObj) );
+ Aig_ObjCreatePo( pNew, (Aig_Obj_t *)pObj->pData );
Vec_IntPush( vPio2Id, Aig_ObjId(pObj) );
}
assert( Aig_ManNodeNum(pNew) == Vec_PtrSize(vNodes) );
@@ -440,7 +443,7 @@ int Aig_ManAddNewCnfToSolver( sat_solver * pSat, Aig_Man_t * pAig, Vec_Int_t * v
// remove the CNF
Cnf_DataFree( pCnf );
// constrain the solver with the literals corresponding to the original POs
- Vec_PtrForEachEntry( vPartPos, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vPartPos, pObj, i )
{
iNodeIdOld = Aig_ObjFaninId0( pObj );
iSatVarOld = Vec_IntEntry( vNode2Var, iNodeIdOld );
@@ -537,7 +540,7 @@ int Aig_ManPartitionedSat( Aig_Man_t * p, int nAlgo, int nPartSize,
// synthesize partitions
if ( fSynthesize )
- Vec_PtrForEachEntry( vAigs, pAig, i )
+ Vec_PtrForEachEntry( Aig_Man_t *, vAigs, pAig, i )
{
pAig = Dar_ManRwsat( pTemp = pAig, 0, 0 );
Vec_PtrWriteEntry( vAigs, i, pAig );
@@ -551,17 +554,17 @@ int Aig_ManPartitionedSat( Aig_Man_t * p, int nAlgo, int nPartSize,
vNode2Var = Vec_IntStart( Aig_ManObjNumMax(p) );
// add partitions, one at a time, and run the SAT solver
- Vec_PtrForEachEntry( vAigs, pAig, i )
+ Vec_PtrForEachEntry( Aig_Man_t *, vAigs, pAig, i )
{
clk = clock();
// transform polarity of the AIG
if ( fAlignPol )
- Aig_ManPartSetNodePolarity( p, pAig, Vec_VecEntry(vPio2Id,i) );
+ Aig_ManPartSetNodePolarity( p, pAig, (Vec_Int_t *)Vec_VecEntry(vPio2Id,i) );
else
Aig_ManPartResetNodePolarity( pAig );
// add CNF of this partition to the SAT solver
if ( Aig_ManAddNewCnfToSolver( pSat, pAig, vNode2Var,
- Vec_VecEntry(vPio2Id,i), Vec_VecEntry(vPart2Pos,i), fAlignPol ) )
+ (Vec_Int_t *)Vec_VecEntry(vPio2Id,i), (Vec_Ptr_t *)Vec_VecEntry(vPart2Pos,i), fAlignPol ) )
{
RetValue = 1;
break;
@@ -596,7 +599,7 @@ ABC_PRT( "Time", clock() - clk );
Aig_ManDeriveCounterExample( p, vNode2Var, pSat );
// cleanup
sat_solver_delete( pSat );
- Vec_PtrForEachEntry( vAigs, pTemp, i )
+ Vec_PtrForEachEntry( Aig_Man_t *, vAigs, pTemp, i )
Aig_ManStop( pTemp );
Vec_PtrFree( vAigs );
Vec_VecFree( vPio2Id );
@@ -610,3 +613,5 @@ ABC_PRT( "Time", clock() - clk );
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/aig/aigRepr.c b/src/aig/aig/aigRepr.c
index 2d2f2f3d..9966174f 100644
--- a/src/aig/aig/aigRepr.c
+++ b/src/aig/aig/aigRepr.c
@@ -20,6 +20,9 @@
#include "aig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -188,8 +191,8 @@ static inline Aig_Obj_t * Aig_ObjGetRepr( Aig_Man_t * p, Aig_Obj_t * pObj )
{
Aig_Obj_t * pRepr;
if ( (pRepr = Aig_ObjFindRepr(p, pObj)) )
- return Aig_NotCond( pRepr->pData, pObj->fPhase ^ pRepr->fPhase );
- return pObj->pData;
+ return Aig_NotCond( (Aig_Obj_t *)pRepr->pData, pObj->fPhase ^ pRepr->fPhase );
+ return (Aig_Obj_t *)pObj->pData;
}
static inline Aig_Obj_t * Aig_ObjChild0Repr( Aig_Man_t * p, Aig_Obj_t * pObj ) { return Aig_NotCond( Aig_ObjGetRepr(p, Aig_ObjFanin0(pObj)), Aig_ObjFaninC0(pObj) ); }
static inline Aig_Obj_t * Aig_ObjChild1Repr( Aig_Man_t * p, Aig_Obj_t * pObj ) { return Aig_NotCond( Aig_ObjGetRepr(p, Aig_ObjFanin1(pObj)), Aig_ObjFaninC1(pObj) ); }
@@ -221,7 +224,7 @@ void Aig_ManTransferRepr( Aig_Man_t * pNew, Aig_Man_t * pOld )
// go through the nodes which have representatives
Aig_ManForEachObj( pOld, pObj, k )
if ( (pRepr = Aig_ObjFindRepr(pOld, pObj)) )
- Aig_ObjSetRepr_( pNew, Aig_Regular(pRepr->pData), Aig_Regular(pObj->pData) );
+ Aig_ObjSetRepr_( pNew, Aig_Regular((Aig_Obj_t *)pRepr->pData), Aig_Regular((Aig_Obj_t *)pObj->pData) );
}
/**Function*************************************************************
@@ -239,15 +242,15 @@ Aig_Obj_t * Aig_ManDupRepr_rec( Aig_Man_t * pNew, Aig_Man_t * p, Aig_Obj_t * pOb
{
Aig_Obj_t * pRepr;
if ( pObj->pData )
- return pObj->pData;
+ return (Aig_Obj_t *)pObj->pData;
if ( (pRepr = Aig_ObjFindRepr(p, pObj)) )
{
Aig_ManDupRepr_rec( pNew, p, pRepr );
- return pObj->pData = Aig_NotCond( pRepr->pData, pRepr->fPhase ^ pObj->fPhase );
+ return (Aig_Obj_t *)(pObj->pData = Aig_NotCond( (Aig_Obj_t *)pRepr->pData, pRepr->fPhase ^ pObj->fPhase ));
}
Aig_ManDupRepr_rec( pNew, p, Aig_ObjFanin0(pObj) );
Aig_ManDupRepr_rec( pNew, p, Aig_ObjFanin1(pObj) );
- return pObj->pData = Aig_And( pNew, Aig_ObjChild0Repr(p, pObj), Aig_ObjChild1Repr(p, pObj) );
+ return (Aig_Obj_t *)(pObj->pData = Aig_And( pNew, Aig_ObjChild0Repr(p, pObj), Aig_ObjChild1Repr(p, pObj) ));
}
/**Function*************************************************************
@@ -270,6 +273,7 @@ Aig_Man_t * Aig_ManDupRepr( Aig_Man_t * p, int fOrdered )
pNew = Aig_ManStart( Aig_ManObjNumMax(p) );
pNew->pName = Aig_UtilStrsav( p->pName );
pNew->pSpec = Aig_UtilStrsav( p->pSpec );
+ pNew->nConstrs = p->nConstrs;
if ( p->vFlopNums )
pNew->vFlopNums = Vec_IntDup( p->vFlopNums );
// map the const and primary inputs
@@ -327,7 +331,7 @@ Aig_Man_t * Aig_ManDupReprBasic( Aig_Man_t * p )
Aig_ManSeqCleanupBasic( pNew );
// remove pointers to the dead nodes
Aig_ManForEachObj( p, pObj, i )
- if ( pObj->pData && Aig_ObjIsNone(pObj->pData) )
+ if ( pObj->pData && Aig_ObjIsNone((Aig_Obj_t *)pObj->pData) )
pObj->pData = NULL;
return pNew;
}
@@ -550,3 +554,5 @@ int Aig_TransferMappedClasses( Aig_Man_t * pAig, Aig_Man_t * pPart, int * pMapBa
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/aig/aigRet.c b/src/aig/aig/aigRet.c
index 6dea6503..f7774d22 100644
--- a/src/aig/aig/aigRet.c
+++ b/src/aig/aig/aigRet.c
@@ -20,6 +20,9 @@
#include "aig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -76,28 +79,28 @@ static inline Rtm_Obj_t * Rtm_ObjFanout( Rtm_Obj_t * pObj, int i ) { retur
static inline Rtm_Edg_t * Rtm_ObjEdge( Rtm_Obj_t * pObj, int i ) { return (Rtm_Edg_t *)(pObj->pFanio + 2*i + 1); }
static inline Rtm_Edg_t * Rtm_ObjFanoutEdge( Rtm_Obj_t * pObj, int i ) { return (Rtm_Edg_t *)pObj->pFanio[2*(pObj->nFanins+i) + 1]; }
-static inline Rtm_Init_t Rtm_InitNot( Rtm_Init_t Val ) { if ( Val == RTM_VAL_ZERO ) return RTM_VAL_ONE; if ( Val == RTM_VAL_ONE ) return RTM_VAL_ZERO; assert( 0 ); return -1; }
+static inline Rtm_Init_t Rtm_InitNot( Rtm_Init_t Val ) { if ( Val == RTM_VAL_ZERO ) return (Rtm_Init_t)RTM_VAL_ONE; if ( Val == RTM_VAL_ONE ) return (Rtm_Init_t)RTM_VAL_ZERO; assert( 0 ); return (Rtm_Init_t)-1; }
static inline Rtm_Init_t Rtm_InitNotCond( Rtm_Init_t Val, int c ) { return c ? Rtm_InitNot(Val) : Val; }
-static inline Rtm_Init_t Rtm_InitAnd(Rtm_Init_t ValA, Rtm_Init_t ValB ) { if ( ValA == RTM_VAL_ONE && ValB == RTM_VAL_ONE ) return RTM_VAL_ONE; if ( ValA == RTM_VAL_ZERO || ValB == RTM_VAL_ZERO ) return RTM_VAL_ZERO; assert( 0 ); return -1; }
+static inline Rtm_Init_t Rtm_InitAnd(Rtm_Init_t ValA, Rtm_Init_t ValB ) { if ( ValA == RTM_VAL_ONE && ValB == RTM_VAL_ONE ) return (Rtm_Init_t)RTM_VAL_ONE; if ( ValA == RTM_VAL_ZERO || ValB == RTM_VAL_ZERO ) return (Rtm_Init_t)RTM_VAL_ZERO; assert( 0 ); return (Rtm_Init_t)-1; }
static inline int Rtm_InitWordsNum( int nLats ) { return (nLats >> 4) + ((nLats & 15) > 0); }
static inline int Rtm_InitGetTwo( unsigned * p, int i ) { return (p[i>>4] >> ((i & 15)<<1)) & 3; }
static inline void Rtm_InitSetTwo( unsigned * p, int i, int val ) { p[i>>4] |= (val << ((i & 15)<<1)); }
static inline void Rtm_InitXorTwo( unsigned * p, int i, int val ) { p[i>>4] ^= (val << ((i & 15)<<1)); }
-static inline Rtm_Init_t Rtm_ObjGetFirst1( Rtm_Edg_t * pEdge ) { return pEdge->LData & 3; }
-static inline Rtm_Init_t Rtm_ObjGetLast1( Rtm_Edg_t * pEdge ) { return (pEdge->LData >> ((pEdge->nLats-1)<<1)) & 3; }
-static inline Rtm_Init_t Rtm_ObjGetOne1( Rtm_Edg_t * pEdge, int i ) { assert( i < (int)pEdge->nLats ); return (pEdge->LData >> (i << 1)) & 3; }
-static inline Rtm_Init_t Rtm_ObjRemFirst1( Rtm_Edg_t * pEdge ) { int Val = pEdge->LData & 3; pEdge->LData >>= 2; assert(pEdge->nLats > 0); pEdge->nLats--; return Val; }
-static inline Rtm_Init_t Rtm_ObjRemLast1( Rtm_Edg_t * pEdge ) { int Val = (pEdge->LData >> ((pEdge->nLats-1)<<1)) & 3; pEdge->LData ^= Val << ((pEdge->nLats-1)<<1); assert(pEdge->nLats > 0); pEdge->nLats--; return Val; }
+static inline Rtm_Init_t Rtm_ObjGetFirst1( Rtm_Edg_t * pEdge ) { return (Rtm_Init_t)(pEdge->LData & 3); }
+static inline Rtm_Init_t Rtm_ObjGetLast1( Rtm_Edg_t * pEdge ) { return (Rtm_Init_t)((pEdge->LData >> ((pEdge->nLats-1)<<1)) & 3); }
+static inline Rtm_Init_t Rtm_ObjGetOne1( Rtm_Edg_t * pEdge, int i ) { assert( i < (int)pEdge->nLats ); return (Rtm_Init_t)((pEdge->LData >> (i << 1)) & 3); }
+static inline Rtm_Init_t Rtm_ObjRemFirst1( Rtm_Edg_t * pEdge ) { int Val = pEdge->LData & 3; pEdge->LData >>= 2; assert(pEdge->nLats > 0); pEdge->nLats--; return (Rtm_Init_t)Val; }
+static inline Rtm_Init_t Rtm_ObjRemLast1( Rtm_Edg_t * pEdge ) { int Val = (pEdge->LData >> ((pEdge->nLats-1)<<1)) & 3; pEdge->LData ^= Val << ((pEdge->nLats-1)<<1); assert(pEdge->nLats > 0); pEdge->nLats--; return (Rtm_Init_t)Val; }
static inline void Rtm_ObjAddFirst1( Rtm_Edg_t * pEdge, Rtm_Init_t Val ) { assert( Val > 0 && Val < 4 ); pEdge->LData = (pEdge->LData << 2) | Val; pEdge->nLats++; }
static inline void Rtm_ObjAddLast1( Rtm_Edg_t * pEdge, Rtm_Init_t Val ) { assert( Val > 0 && Val < 4 ); pEdge->LData |= Val << (pEdge->nLats<<1); pEdge->nLats++; }
-static inline Rtm_Init_t Rtm_ObjGetFirst2( Rtm_Man_t * p, Rtm_Edg_t * pEdge ) { return Rtm_InitGetTwo( p->pExtra + pEdge->LData, 0 ); }
-static inline Rtm_Init_t Rtm_ObjGetLast2( Rtm_Man_t * p, Rtm_Edg_t * pEdge ) { return Rtm_InitGetTwo( p->pExtra + pEdge->LData, pEdge->nLats - 1 ); }
-static inline Rtm_Init_t Rtm_ObjGetOne2( Rtm_Man_t * p, Rtm_Edg_t * pEdge, int i ) { return Rtm_InitGetTwo( p->pExtra + pEdge->LData, i ); }
+static inline Rtm_Init_t Rtm_ObjGetFirst2( Rtm_Man_t * p, Rtm_Edg_t * pEdge ) { return (Rtm_Init_t)Rtm_InitGetTwo( p->pExtra + pEdge->LData, 0 ); }
+static inline Rtm_Init_t Rtm_ObjGetLast2( Rtm_Man_t * p, Rtm_Edg_t * pEdge ) { return (Rtm_Init_t)Rtm_InitGetTwo( p->pExtra + pEdge->LData, pEdge->nLats - 1 ); }
+static inline Rtm_Init_t Rtm_ObjGetOne2( Rtm_Man_t * p, Rtm_Edg_t * pEdge, int i ) { return (Rtm_Init_t)Rtm_InitGetTwo( p->pExtra + pEdge->LData, i ); }
static Rtm_Init_t Rtm_ObjRemFirst2( Rtm_Man_t * p, Rtm_Edg_t * pEdge );
-static inline Rtm_Init_t Rtm_ObjRemLast2( Rtm_Man_t * p, Rtm_Edg_t * pEdge ) { Rtm_Init_t Val = Rtm_ObjGetLast2( p, pEdge ); Rtm_InitXorTwo( p->pExtra + pEdge->LData, pEdge->nLats - 1, Val ); pEdge->nLats--; return Val; }
+static inline Rtm_Init_t Rtm_ObjRemLast2( Rtm_Man_t * p, Rtm_Edg_t * pEdge ) { Rtm_Init_t Val = Rtm_ObjGetLast2( p, pEdge ); Rtm_InitXorTwo( p->pExtra + pEdge->LData, pEdge->nLats - 1, Val ); pEdge->nLats--; return (Rtm_Init_t)Val; }
static void Rtm_ObjAddFirst2( Rtm_Man_t * p, Rtm_Edg_t * pEdge, Rtm_Init_t Val );
static inline void Rtm_ObjAddLast2( Rtm_Man_t * p, Rtm_Edg_t * pEdge, Rtm_Init_t Val ) { Rtm_InitSetTwo( p->pExtra + pEdge->LData, pEdge->nLats, Val ); pEdge->nLats++; }
@@ -116,13 +119,13 @@ static void Rtm_ObjAddLast( Rtm_Man_t * p, Rtm_Edg_t * pEdge, Rtm_
// iterator over the primary inputs
#define Rtm_ManForEachPi( p, pObj, i ) \
- Vec_PtrForEachEntry( p->vPis, pObj, i )
+ Vec_PtrForEachEntry( Rtm_Obj_t *, p->vPis, pObj, i )
// iterator over the primary outputs
#define Rtm_ManForEachPo( p, pObj, i ) \
- Vec_PtrForEachEntry( p->vPos, pObj, i )
+ Vec_PtrForEachEntry( Rtm_Obj_t *, p->vPos, pObj, i )
// iterator over all objects, including those currently not used
#define Rtm_ManForEachObj( p, pObj, i ) \
- Vec_PtrForEachEntry( p->vObjs, pObj, i )
+ Vec_PtrForEachEntry( Rtm_Obj_t *, p->vObjs, pObj, i )
// iterate through the fanins
#define Rtm_ObjForEachFanin( pObj, pFanin, i ) \
for ( i = 0; i < (int)(pObj)->nFanins && ((pFanin = Rtm_ObjFanin(pObj, i)), 1); i++ )
@@ -222,11 +225,11 @@ void Rtm_ObjTransferToBigger( Rtm_Man_t * p, Rtm_Edg_t * pEdge )
***********************************************************************/
Rtm_Init_t Rtm_ObjRemFirst2( Rtm_Man_t * p, Rtm_Edg_t * pEdge )
{
- Rtm_Init_t Val = 0, Temp;
+ Rtm_Init_t Val = (Rtm_Init_t)0, Temp;
unsigned * pB = p->pExtra + pEdge->LData, * pE = pB + Rtm_InitWordsNum( pEdge->nLats-- ) - 1;
while ( pE >= pB )
{
- Temp = *pE & 3;
+ Temp = (Rtm_Init_t)(*pE & 3);
*pE = (*pE >> 2) | (Val << 30);
Val = Temp;
pE--;
@@ -253,7 +256,7 @@ void Rtm_ObjAddFirst2( Rtm_Man_t * p, Rtm_Edg_t * pEdge, Rtm_Init_t Val )
assert( Val != 0 );
while ( pB < pE )
{
- Temp = *pB >> 30;
+ Temp = (Rtm_Init_t)(*pB >> 30);
*pB = (*pB << 2) | Val;
Val = Temp;
pB++;
@@ -590,7 +593,7 @@ int Rtm_ManMarkAutoFwd( Rtm_Man_t * pRtm )
Rtm_Obj_t * pObjRtm;
int i, Counter = 0;
// mark nodes reachable from the PIs
- pObjRtm = Vec_PtrEntry( pRtm->vObjs, 0 );
+ pObjRtm = (Rtm_Obj_t *)Vec_PtrEntry( pRtm->vObjs, 0 );
Rtm_ObjMarkAutoFwd_rec( pObjRtm );
Rtm_ManForEachPi( pRtm, pObjRtm, i )
Rtm_ObjMarkAutoFwd_rec( pObjRtm );
@@ -642,7 +645,7 @@ int Rtm_ManMarkAutoBwd( Rtm_Man_t * pRtm )
Rtm_Obj_t * pObjRtm;
int i, Counter = 0;
// mark nodes reachable from the PIs
- pObjRtm = Vec_PtrEntry( pRtm->vObjs, 0 );
+ pObjRtm = (Rtm_Obj_t *)Vec_PtrEntry( pRtm->vObjs, 0 );
pObjRtm->fAuto = 1;
Rtm_ManForEachPi( pRtm, pObjRtm, i )
pObjRtm->fAuto = 1;
@@ -699,15 +702,15 @@ Rtm_Man_t * Rtm_ManFromAig( Aig_Man_t * p )
pObj->pData = Rtm_ObjAlloc( pRtm, 2, pObj->nRefs );
// connect objects
Aig_ManForEachPoSeq( p, pObj, i )
- Rtm_ObjAddFanin( pObj->pData, Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0(pObj) );
+ Rtm_ObjAddFanin( (Rtm_Obj_t *)pObj->pData, (Rtm_Obj_t *)Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0(pObj) );
Aig_ManForEachLiSeq( p, pObj, i )
- Rtm_ObjAddFanin( pObj->pData, Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0(pObj) );
+ Rtm_ObjAddFanin( (Rtm_Obj_t *)pObj->pData, (Rtm_Obj_t *)Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0(pObj) );
Aig_ManForEachLiLoSeq( p, pObjLi, pObjLo, i )
- Rtm_ObjAddFanin( pObjLo->pData, pObjLi->pData, 0 );
+ Rtm_ObjAddFanin( (Rtm_Obj_t *)pObjLo->pData, (Rtm_Obj_t *)pObjLi->pData, 0 );
Aig_ManForEachNode( p, pObj, i )
{
- Rtm_ObjAddFanin( pObj->pData, Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0(pObj) );
- Rtm_ObjAddFanin( pObj->pData, Aig_ObjFanin1(pObj)->pData, Aig_ObjFaninC1(pObj) );
+ Rtm_ObjAddFanin( (Rtm_Obj_t *)pObj->pData, (Rtm_Obj_t *)Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0(pObj) );
+ Rtm_ObjAddFanin( (Rtm_Obj_t *)pObj->pData, (Rtm_Obj_t *)Aig_ObjFanin1(pObj)->pData, Aig_ObjFaninC1(pObj) );
}
return pRtm;
}
@@ -729,7 +732,7 @@ Aig_Obj_t * Rtm_ManToAig_rec( Aig_Man_t * pNew, Rtm_Man_t * pRtm, Rtm_Obj_t * pO
Aig_Obj_t * pRes, * pFanin;
int k, Val;
if ( pObjRtm->pCopy )
- return pObjRtm->pCopy;
+ return (Aig_Obj_t *)pObjRtm->pCopy;
// get the inputs
pRes = Aig_ManConst1( pNew );
Rtm_ObjForEachFaninEdge( pObjRtm, pEdge, k )
@@ -745,7 +748,7 @@ Aig_Obj_t * Rtm_ManToAig_rec( Aig_Man_t * pNew, Rtm_Man_t * pRtm, Rtm_Obj_t * pO
pFanin = Aig_NotCond( pFanin, k ? pObjRtm->fCompl1 : pObjRtm->fCompl0 );
pRes = Aig_And( pNew, pRes, pFanin );
}
- return pObjRtm->pCopy = pRes;
+ return (Aig_Obj_t *)(pObjRtm->pCopy = pRes);
}
/**Function*************************************************************
@@ -778,7 +781,7 @@ Aig_Man_t * Rtm_ManToAig( Rtm_Man_t * pRtm )
// create the new manager
pNew = Aig_ManStart( Vec_PtrSize(pRtm->vObjs) + nLatches );
// create PIs/POs and latches
- pObjRtm = Vec_PtrEntry( pRtm->vObjs, 0 );
+ pObjRtm = (Rtm_Obj_t *)Vec_PtrEntry( pRtm->vObjs, 0 );
pObjRtm->pCopy = Aig_ManConst1(pNew);
Rtm_ManForEachPi( pRtm, pObjRtm, i )
pObjRtm->pCopy = Aig_ObjCreatePi(pNew);
@@ -789,14 +792,14 @@ Aig_Man_t * Rtm_ManToAig( Rtm_Man_t * pRtm )
Rtm_ManToAig_rec( pNew, pRtm, pObjRtm, pLatches );
// create POs
Rtm_ManForEachPo( pRtm, pObjRtm, i )
- Aig_ObjCreatePo( pNew, pObjRtm->pCopy );
+ Aig_ObjCreatePo( pNew, (Aig_Obj_t *)pObjRtm->pCopy );
// connect latches
Rtm_ManForEachObj( pRtm, pObjRtm, i )
Rtm_ObjForEachFaninEdge( pObjRtm, pEdge, k )
{
if ( pEdge->nLats == 0 )
continue;
- pObjNew = Rtm_ObjFanin( pObjRtm, k )->pCopy;
+ pObjNew = (Aig_Obj_t *)Rtm_ObjFanin( pObjRtm, k )->pCopy;
for ( m = 0; m < (int)pEdge->nLats; m++ )
{
Val = Rtm_ObjGetOne( pRtm, pEdge, pEdge->nLats - 1 - m );
@@ -843,7 +846,7 @@ clk = clock();
pRtm = Rtm_ManFromAig( p );
// set registers
Aig_ManForEachLoSeq( p, pObjAig, i )
- Rtm_ObjAddFirst( pRtm, Rtm_ObjEdge(pObjAig->pData, 0), fForward? RTM_VAL_ZERO : RTM_VAL_VOID );
+ Rtm_ObjAddFirst( pRtm, Rtm_ObjEdge((Rtm_Obj_t *)pObjAig->pData, 0), fForward? RTM_VAL_ZERO : RTM_VAL_VOID );
// detect and mark the autonomous components
if ( fForward )
nAutos = Rtm_ManMarkAutoFwd( pRtm );
@@ -870,7 +873,7 @@ clk = clock();
{
Aig_ManForEachLoSeq( p, pObjAig, i )
{
- pObj = pObjAig->pData;
+ pObj = (Rtm_Obj_t *)pObjAig->pData;
if ( pObj->fAuto )
continue;
pObj->fMark = 1;
@@ -881,7 +884,7 @@ clk = clock();
{
Aig_ManForEachLiSeq( p, pObjAig, i )
{
- pObj = pObjAig->pData;
+ pObj = (Rtm_Obj_t *)pObjAig->pData;
if ( pObj->fAuto )
continue;
pObj->fMark = 1;
@@ -890,7 +893,7 @@ clk = clock();
}
// perform retiming
DegreeMax = 0;
- Vec_PtrForEachEntry( vQueue, pObj, i )
+ Vec_PtrForEachEntry( Rtm_Obj_t *, vQueue, pObj, i )
{
pObj->fMark = 0;
// retime the node
@@ -968,3 +971,5 @@ clk = clock();
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/aig/aigRetF.c b/src/aig/aig/aigRetF.c
index f045cac8..0a866c30 100644
--- a/src/aig/aig/aigRetF.c
+++ b/src/aig/aig/aigRetF.c
@@ -20,6 +20,9 @@
#include "aig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -207,3 +210,5 @@ Aig_Man_t * Aig_ManRetimeFrontier( Aig_Man_t * p, int nStepsMax )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/aig/aigScl.c b/src/aig/aig/aigScl.c
index b6331b0e..e31ab74b 100644
--- a/src/aig/aig/aigScl.c
+++ b/src/aig/aig/aigScl.c
@@ -20,6 +20,9 @@
#include "aig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -50,6 +53,7 @@ Aig_Man_t * Aig_ManRemap( Aig_Man_t * p, Vec_Ptr_t * vMap )
pNew->pName = Aig_UtilStrsav( p->pName );
pNew->pSpec = Aig_UtilStrsav( p->pSpec );
pNew->nAsserts = p->nAsserts;
+ pNew->nConstrs = p->nConstrs;
assert( p->vFlopNums == NULL || Vec_IntSize(p->vFlopNums) == p->nRegs );
if ( p->vFlopNums )
pNew->vFlopNums = Vec_IntDup( p->vFlopNums );
@@ -69,8 +73,8 @@ Aig_Man_t * Aig_ManRemap( Aig_Man_t * p, Vec_Ptr_t * vMap )
}
Aig_ManForEachPi( p, pObj, i )
{
- pObjMapped = Vec_PtrEntry( vMap, i );
- pObj->pData = Aig_NotCond( Aig_Regular(pObjMapped)->pData, Aig_IsComplement(pObjMapped) );
+ pObjMapped = (Aig_Obj_t *)Vec_PtrEntry( vMap, i );
+ pObj->pData = Aig_NotCond( (Aig_Obj_t *)Aig_Regular(pObjMapped)->pData, Aig_IsComplement(pObjMapped) );
if ( pNew->vFlopReprs && i >= nTruePis && pObj != pObjMapped )
{
Vec_IntPush( pNew->vFlopReprs, Aig_ObjPioNum(pObj) );
@@ -172,7 +176,7 @@ int Aig_ManSeqCleanup( Aig_Man_t * p )
Aig_ManForEachLiLoSeq( p, pObjLi, pObjLo, i )
pObjLo->pNext = pObjLi;
// mark the nodes reachable from these nodes
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
Aig_ManSeqCleanup_rec( p, pObj, vNodes );
assert( Vec_PtrSize(vNodes) <= Aig_ManPoNum(p) );
// clean latch output pointers
@@ -271,7 +275,7 @@ int Aig_ManSeqCleanupBasic( Aig_Man_t * p )
Aig_ManForEachLiLoSeq( p, pObjLi, pObjLo, i )
pObjLo->pNext = pObjLi;
// mark the nodes reachable from these nodes
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
Aig_ManSeqCleanup_rec( p, pObj, vNodes );
assert( Vec_PtrSize(vNodes) <= Aig_ManPoNum(p) );
// clean latch output pointers
@@ -496,7 +500,7 @@ void Aig_ManComputeSccs( Aig_Man_t * p )
vSupports = Aig_ManSupports( p );
// transforms the supports into the latch dependency matrix
vMatrix = Vec_PtrStart( Aig_ManRegNum(p) );
- Vec_PtrForEachEntry( vSupports, vSupp, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vSupports, vSupp, i )
{
// skip true POs
iOut = Vec_IntPop( vSupp );
@@ -522,11 +526,11 @@ void Aig_ManComputeSccs( Aig_Man_t * p )
vMatrix2 = Vec_PtrAlloc( Aig_ManRegNum(p) );
for ( i = 0; i < Aig_ManRegNum(p); i++ )
Vec_PtrPush( vMatrix2, Vec_IntAlloc(8) );
- Vec_PtrForEachEntry( vMatrix, vSupp, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vMatrix, vSupp, i )
{
Vec_IntForEachEntry( vSupp, iIn, k )
{
- vSupp2 = Vec_PtrEntry( vMatrix2, iIn );
+ vSupp2 = (Vec_Int_t *)Vec_PtrEntry( vMatrix2, iIn );
Vec_IntPush( vSupp2, i );
}
}
@@ -548,7 +552,7 @@ void Aig_ManComputeSccs( Aig_Man_t * p )
Vec_IntPush( vComp, iOut );
Vec_IntForEachEntry( vComp, iOut, i )
{
- vSupp = Vec_PtrEntry( vMatrix, iOut );
+ vSupp = (Vec_Int_t *)Vec_PtrEntry( vMatrix, iOut );
Vec_IntForEachEntry( vSupp, iIn, k )
{
if ( pVarsTot[iIn] )
@@ -556,7 +560,7 @@ void Aig_ManComputeSccs( Aig_Man_t * p )
pVarsTot[iIn] = 1;
Vec_IntPush( vComp, iIn );
}
- vSupp2 = Vec_PtrEntry( vMatrix2, iOut );
+ vSupp2 = (Vec_Int_t *)Vec_PtrEntry( vMatrix2, iOut );
Vec_IntForEachEntry( vSupp2, iIn, k )
{
if ( pVarsTot[iIn] )
@@ -602,14 +606,14 @@ Aig_Man_t * Aig_ManSclPart( Aig_Man_t * pAig, int fLatchConst, int fLatchEqual,
if ( pAig->vClockDoms )
{
vResult = Vec_PtrAlloc( 100 );
- Vec_PtrForEachEntry( (Vec_Ptr_t *)pAig->vClockDoms, vPart, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, (Vec_Ptr_t *)pAig->vClockDoms, vPart, i )
Vec_PtrPush( vResult, Vec_IntDup(vPart) );
}
else
vResult = Aig_ManRegPartitionSimple( pAig, 0, 0 );
Aig_ManReprStart( pAig, Aig_ManObjNumMax(pAig) );
- Vec_PtrForEachEntry( vResult, vPart, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vResult, vPart, i )
{
pTemp = Aig_ManRegCreatePart( pAig, vPart, &nCountPis, &nCountRegs, &pMapBack );
Aig_ManSetRegNum( pTemp, pTemp->nRegs );
@@ -699,3 +703,5 @@ Aig_Man_t * Aig_ManScl( Aig_Man_t * pAig, int fLatchConst, int fLatchEqual, int
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/aig/aigShow.c b/src/aig/aig/aigShow.c
index 1e9e10ac..24b122c3 100644
--- a/src/aig/aig/aigShow.c
+++ b/src/aig/aig/aigShow.c
@@ -20,6 +20,9 @@
#include "aig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -59,7 +62,7 @@ void Aig_WriteDotAig( Aig_Man_t * pMan, char * pFileName, int fHaig, Vec_Ptr_t *
// mark the nodes
if ( vBold )
- Vec_PtrForEachEntry( vBold, pNode, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vBold, pNode, i )
pNode->fMarkB = 1;
// compute levels
@@ -308,7 +311,7 @@ void Aig_WriteDotAig( Aig_Man_t * pMan, char * pFileName, int fHaig, Vec_Ptr_t *
// unmark nodes
if ( vBold )
- Vec_PtrForEachEntry( vBold, pNode, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vBold, pNode, i )
pNode->fMarkB = 0;
Aig_ManForEachPo( pMan, pNode, i )
@@ -354,3 +357,5 @@ void Aig_ManShow( Aig_Man_t * pMan, int fHaig, Vec_Ptr_t * vBold )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/aig/aigSplit.c b/src/aig/aig/aigSplit.c
new file mode 100644
index 00000000..51b4f982
--- /dev/null
+++ b/src/aig/aig/aigSplit.c
@@ -0,0 +1,316 @@
+/**CFile****************************************************************
+
+ FileName [aigSplit.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [AIG package.]
+
+ Synopsis [Splits the property output cone into a set of cofactor properties.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - April 28, 2007.]
+
+ Revision [$Id: aigSplit.c,v 1.00 2007/04/28 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "aig.h"
+#include "saig.h"
+#include "cuddInt.h"
+#include "extra.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Converts the node to MUXes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Obj_t * Aig_NodeBddToMuxes_rec( DdManager * dd, DdNode * bFunc, Aig_Man_t * pNew, st_table * tBdd2Node )
+{
+ Aig_Obj_t * pNode, * pNode0, * pNode1, * pNodeC;
+ assert( !Cudd_IsComplement(bFunc) );
+ if ( st_lookup( tBdd2Node, (char *)bFunc, (char **)&pNode ) )
+ return pNode;
+ // solve for the children nodes
+ pNode0 = Aig_NodeBddToMuxes_rec( dd, Cudd_Regular(cuddE(bFunc)), pNew, tBdd2Node );
+ pNode0 = Aig_NotCond( pNode0, Cudd_IsComplement(cuddE(bFunc)) );
+ pNode1 = Aig_NodeBddToMuxes_rec( dd, cuddT(bFunc), pNew, tBdd2Node );
+ if ( !st_lookup( tBdd2Node, (char *)Cudd_bddIthVar(dd, bFunc->index), (char **)&pNodeC ) )
+ assert( 0 );
+ // create the MUX node
+ pNode = Aig_Mux( pNew, pNodeC, pNode1, pNode0 );
+ st_insert( tBdd2Node, (char *)bFunc, (char *)pNode );
+ return pNode;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Derives AIG for the BDDs of the cofactors.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Man_t * Aig_ManConvertBddsToAigs( Aig_Man_t * p, DdManager * dd, Vec_Ptr_t * vCofs )
+{
+ DdNode * bFunc;
+ st_table * tBdd2Node;
+ Aig_Man_t * pNew;
+ Aig_Obj_t * pObj;
+ int i;
+ Aig_ManCleanData( p );
+ // generate AIG for BDD
+ pNew = Aig_ManStart( Aig_ManObjNum(p) );
+ pNew->pName = Aig_UtilStrsav( p->pName );
+ Aig_ManConst1(p)->pData = Aig_ManConst1(pNew);
+ Aig_ManForEachPi( p, pObj, i )
+ pObj->pData = Aig_ObjCreatePi( pNew );
+ // create the table mapping BDD nodes into the ABC nodes
+ tBdd2Node = st_init_table( st_ptrcmp, st_ptrhash );
+ // add the constant and the elementary vars
+ st_insert( tBdd2Node, (char *)Cudd_ReadOne(dd), (char *)Aig_ManConst1(pNew) );
+ Aig_ManForEachPi( p, pObj, i )
+ st_insert( tBdd2Node, (char *)Cudd_bddIthVar(dd, i), (char *)pObj->pData );
+ // build primary outputs for the cofactors
+ Vec_PtrForEachEntry( DdNode *, vCofs, bFunc, i )
+ {
+ if ( bFunc == Cudd_ReadLogicZero(dd) )
+ continue;
+ pObj = Aig_NodeBddToMuxes_rec( dd, Cudd_Regular(bFunc), pNew, tBdd2Node );
+ pObj = Aig_NotCond( pObj, Cudd_IsComplement(bFunc) );
+ Aig_ObjCreatePo( pNew, pObj );
+ }
+ st_free_table( tBdd2Node );
+
+ // duplicate the rest of the AIG
+ // add the POs
+ Aig_ManForEachPo( p, pObj, i )
+ {
+ if ( i == 0 )
+ continue;
+ Aig_ManDupSimpleDfs_rec( pNew, p, Aig_ObjFanin0(pObj) );
+ pObj->pData = Aig_ObjCreatePo( pNew, Aig_ObjChild0Copy(pObj) );
+ }
+ Aig_ManCleanup( pNew );
+ Aig_ManSetRegNum( pNew, Aig_ManRegNum(p) );
+ // check the resulting network
+ if ( !Aig_ManCheck(pNew) )
+ printf( "Aig_ManConvertBddsToAigs(): The check has failed.\n" );
+ return pNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the array of constraint candidates.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+DdNode * Aig_ManBuildPoBdd_rec( Aig_Man_t * p, Aig_Obj_t * pObj, DdManager * dd )
+{
+ DdNode * bBdd0, * bBdd1;
+ if ( pObj->pData != NULL )
+ return (DdNode *)pObj->pData;
+ assert( Aig_ObjIsNode(pObj) );
+ bBdd0 = Aig_ManBuildPoBdd_rec( p, Aig_ObjFanin0(pObj), dd );
+ bBdd1 = Aig_ManBuildPoBdd_rec( p, Aig_ObjFanin1(pObj), dd );
+ bBdd0 = Cudd_NotCond( bBdd0, Aig_ObjFaninC0(pObj) );
+ bBdd1 = Cudd_NotCond( bBdd1, Aig_ObjFaninC1(pObj) );
+ pObj->pData = Cudd_bddAnd( dd, bBdd0, bBdd1 ); Cudd_Ref( (DdNode *)pObj->pData );
+ return (DdNode *)pObj->pData;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Derive BDDs for the cofactors.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Ptr_t * Aig_ManCofactorBdds( Aig_Man_t * p, Vec_Ptr_t * vSubset, DdManager * dd, DdNode * bFunc )
+{
+ Vec_Ptr_t * vCofs;
+ DdNode * bCube, * bTemp, * bCof, ** pbVars;
+ int i;
+ vCofs = Vec_PtrAlloc( 100 );
+ pbVars = (DdNode **)Vec_PtrArray(vSubset);
+ for ( i = 0; i < (1 << Vec_PtrSize(vSubset)); i++ )
+ {
+ bCube = Extra_bddBitsToCube( dd, i, Vec_PtrSize(vSubset), pbVars, 1 ); Cudd_Ref( bCube );
+ bCof = Cudd_Cofactor( dd, bFunc, bCube ); Cudd_Ref( bCof );
+ bCof = Cudd_bddAnd( dd, bTemp = bCof, bCube ); Cudd_Ref( bCof );
+ Cudd_RecursiveDeref( dd, bTemp );
+ Cudd_RecursiveDeref( dd, bCube );
+ Vec_PtrPush( vCofs, bCof );
+ }
+ return vCofs;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Construct BDDs for the primary output.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+DdManager * Aig_ManBuildPoBdd( Aig_Man_t * p, DdNode ** pbFunc )
+{
+ DdManager * dd;
+ Aig_Obj_t * pObj;
+ int i;
+ assert( Saig_ManPoNum(p) == 1 );
+ Aig_ManCleanData( p );
+ dd = Cudd_Init( Aig_ManPiNum(p), 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 );
+ Cudd_AutodynEnable( dd, CUDD_REORDER_SYMM_SIFT );
+ pObj = Aig_ManConst1(p);
+ pObj->pData = Cudd_ReadOne(dd); Cudd_Ref( (DdNode *)pObj->pData );
+ Aig_ManForEachPi( p, pObj, i )
+ {
+ pObj->pData = Cudd_bddIthVar(dd, i); Cudd_Ref( (DdNode *)pObj->pData );
+ }
+ pObj = Aig_ManPo( p, 0 );
+ *pbFunc = Aig_ManBuildPoBdd_rec( p, Aig_ObjFanin0(pObj), dd ); Cudd_Ref( *pbFunc );
+ *pbFunc = Cudd_NotCond( *pbFunc, Aig_ObjFaninC0(pObj) );
+ Aig_ManForEachObj( p, pObj, i )
+ {
+ if ( pObj->pData )
+ Cudd_RecursiveDeref( dd, (DdNode *)pObj->pData );
+ }
+ Cudd_ReduceHeap( dd, CUDD_REORDER_SYMM_SIFT, 1 );
+ return dd;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Randomly selects a random subset of inputs.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Ptr_t * Aig_ManVecRandSubset( Vec_Ptr_t * vVec, int nVars )
+{
+ Vec_Ptr_t * vRes;
+ void * pEntry;
+ unsigned Rand;
+ vRes = Vec_PtrDup(vVec);
+ while ( Vec_PtrSize(vRes) > nVars )
+ {
+ Rand = Aig_ManRandom( 0 );
+ pEntry = Vec_PtrEntry( vRes, Rand % Vec_PtrSize(vRes) );
+ Vec_PtrRemove( vRes, pEntry );
+ }
+ return vRes;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Man_t * Aig_ManSplit( Aig_Man_t * p, int nVars, int fVerbose )
+{
+ Aig_Man_t * pRes;
+ Aig_Obj_t * pNode;
+ DdNode * bFunc;
+ DdManager * dd;
+ Vec_Ptr_t * vSupp, * vSubs, * vCofs;
+ int i, clk = clock();
+ if ( Saig_ManPoNum(p) != 1 )
+ {
+ printf( "Currently works only for one primary output.\n" );
+ return NULL;
+ }
+ if ( nVars < 1 )
+ {
+ printf( "The number of cofactoring variables should be a positive number.\n" );
+ return NULL;
+ }
+ if ( nVars > 16 )
+ {
+ printf( "The number of cofactoring variables should be less than 17.\n" );
+ return NULL;
+ }
+ vSupp = Aig_Support( p, Aig_ObjFanin0(Aig_ManPo(p,0)) );
+ if ( Vec_PtrSize(vSupp) == 0 )
+ {
+ printf( "Property output function is a constant.\n" );
+ Vec_PtrFree( vSupp );
+ return NULL;
+ }
+ dd = Aig_ManBuildPoBdd( p, &bFunc ); // bFunc is referenced
+ if ( fVerbose )
+ printf( "Support =%5d. BDD size =%6d. ", Vec_PtrSize(vSupp), Cudd_DagSize(bFunc) );
+ vSubs = Aig_ManVecRandSubset( vSupp, nVars );
+ // replace nodes by their BDD variables
+ Vec_PtrForEachEntry( Aig_Obj_t *, vSubs, pNode, i )
+ Vec_PtrWriteEntry( vSubs, i, pNode->pData );
+ // derive cofactors and functions
+ vCofs = Aig_ManCofactorBdds( p, vSubs, dd, bFunc );
+ pRes = Aig_ManConvertBddsToAigs( p, dd, vCofs );
+ Vec_PtrFree( vSupp );
+ Vec_PtrFree( vSubs );
+ if ( fVerbose )
+ printf( "Created %d cofactors (out of %d). ", Saig_ManPoNum(pRes), Vec_PtrSize(vCofs) );
+ if ( fVerbose )
+ Abc_PrintTime( 1, "Time", clock() - clk );
+ // dereference
+ Cudd_RecursiveDeref( dd, bFunc );
+ Vec_PtrForEachEntry( DdNode *, vCofs, bFunc, i )
+ Cudd_RecursiveDeref( dd, bFunc );
+ Vec_PtrFree( vCofs );
+ Extra_StopManager( dd );
+ return pRes;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/aig/aigTable.c b/src/aig/aig/aigTable.c
index 81635357..13826065 100644
--- a/src/aig/aig/aigTable.c
+++ b/src/aig/aig/aigTable.c
@@ -20,6 +20,9 @@
#include "aig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -269,3 +272,5 @@ void Aig_TableClear( Aig_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/aig/aigTest.c b/src/aig/aig/aigTest.c
index b97ffb03..42c81c3f 100644
--- a/src/aig/aig/aigTest.c
+++ b/src/aig/aig/aigTest.c
@@ -2,6 +2,9 @@
#include "aig.h"
+ABC_NAMESPACE_IMPL_START
+
+
void Aig_ProcedureTest()
{
Aig_Man_t * p;
@@ -32,4 +35,5 @@ void Aig_ProcedureTest()
Aig_ManDumpBlif( p, "aig_test_file.blif", NULL, NULL );
Aig_ManStop( p );
-} \ No newline at end of file
+}ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/aig/aigTiming.c b/src/aig/aig/aigTiming.c
index d0cc99e3..4ea93e29 100644
--- a/src/aig/aig/aigTiming.c
+++ b/src/aig/aig/aigTiming.c
@@ -20,6 +20,9 @@
#include "aig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -150,7 +153,7 @@ void Aig_ManStartReverseLevels( Aig_Man_t * p, int nMaxLevelIncrease )
Vec_IntFill( p->vLevelR, Aig_ManObjNumMax(p), 0 );
// compute levels in reverse topological order
vNodes = Aig_ManDfsReverse( p );
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
{
assert( pObj->fMarkA == 0 );
Aig_ObjSetReverseLevel( p, pObj, Aig_ObjReverseLevelNew(p, pObj) );
@@ -209,7 +212,7 @@ void Aig_ManUpdateLevel( Aig_Man_t * p, Aig_Obj_t * pObjNew )
Vec_VecPush( p->vLevels, LevelOld, pObjNew );
pObjNew->fMarkA = 1;
// recursively update level
- Vec_VecForEachEntryStart( p->vLevels, pTemp, Lev, k, LevelOld )
+ Vec_VecForEachEntryStart( Aig_Obj_t *, p->vLevels, pTemp, Lev, k, LevelOld )
{
pTemp->fMarkA = 0;
assert( Aig_ObjLevel(pTemp) == Lev );
@@ -261,7 +264,7 @@ void Aig_ManUpdateReverseLevel( Aig_Man_t * p, Aig_Obj_t * pObjNew )
Vec_VecPush( p->vLevels, LevelOld, pObjNew );
pObjNew->fMarkA = 1;
// recursively update level
- Vec_VecForEachEntryStart( p->vLevels, pTemp, Lev, k, LevelOld )
+ Vec_VecForEachEntryStart( Aig_Obj_t *, p->vLevels, pTemp, Lev, k, LevelOld )
{
pTemp->fMarkA = 0;
LevelOld = Aig_ObjReverseLevel(p, pTemp);
@@ -349,3 +352,5 @@ void Aig_ManVerifyReverseLevel( Aig_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/aig/aigTruth.c b/src/aig/aig/aigTruth.c
index a92f9e1d..ddcb8736 100644
--- a/src/aig/aig/aigTruth.c
+++ b/src/aig/aig/aigTruth.c
@@ -20,6 +20,9 @@
#include "aig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -43,8 +46,8 @@ unsigned * Aig_ManCutTruthOne( Aig_Obj_t * pNode, unsigned * pTruth, int nWords
{
unsigned * pTruth0, * pTruth1;
int i;
- pTruth0 = Aig_ObjFanin0(pNode)->pData;
- pTruth1 = Aig_ObjFanin1(pNode)->pData;
+ pTruth0 = (unsigned *)Aig_ObjFanin0(pNode)->pData;
+ pTruth1 = (unsigned *)Aig_ObjFanin1(pNode)->pData;
if ( Aig_ObjIsExor(pNode) )
for ( i = 0; i < nWords; i++ )
pTruth[i] = pTruth0[i] ^ pTruth1[i];
@@ -82,13 +85,13 @@ unsigned * Aig_ManCutTruth( Aig_Obj_t * pRoot, Vec_Ptr_t * vLeaves, Vec_Ptr_t *
assert( Vec_PtrSize(vNodes) <= Vec_PtrSize(vTruthStore) );
assert( Vec_PtrSize(vNodes) == 0 || pRoot == Vec_PtrEntryLast(vNodes) );
// assign elementary truth tables
- Vec_PtrForEachEntry( vLeaves, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vLeaves, pObj, i )
pObj->pData = Vec_PtrEntry( vTruthElem, i );
// compute truths for other nodes
nWords = Aig_TruthWordNum( Vec_PtrSize(vLeaves) );
- Vec_PtrForEachEntry( vNodes, pObj, i )
- pObj->pData = Aig_ManCutTruthOne( pObj, Vec_PtrEntry(vTruthStore, i), nWords );
- return pRoot->pData;
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
+ pObj->pData = Aig_ManCutTruthOne( pObj, (unsigned *)Vec_PtrEntry(vTruthStore, i), nWords );
+ return (unsigned *)pRoot->pData;
}
////////////////////////////////////////////////////////////////////////
@@ -96,3 +99,5 @@ unsigned * Aig_ManCutTruth( Aig_Obj_t * pRoot, Vec_Ptr_t * vLeaves, Vec_Ptr_t *
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/aig/aigTsim.c b/src/aig/aig/aigTsim.c
index 94797210..e3387ad1 100644
--- a/src/aig/aig/aigTsim.c
+++ b/src/aig/aig/aigTsim.c
@@ -20,6 +20,9 @@
#include "aig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -321,7 +324,7 @@ void Aig_TsiStateOrAll( Aig_Tsi_t * pTsi, unsigned * pState )
{
unsigned * pPrev;
int i, k;
- Vec_PtrForEachEntry( pTsi->vStates, pPrev, i )
+ Vec_PtrForEachEntry( unsigned *, pTsi->vStates, pPrev, i )
{
for ( k = 0; k < pTsi->nWords; k++ )
pState[k] |= pPrev[k];
@@ -423,7 +426,7 @@ Vec_Ptr_t * Aig_ManTernarySimulate( Aig_Man_t * p, int fVerbose )
return NULL;
}
// OR all the states
- pState = Vec_PtrEntry( pTsi->vStates, 0 );
+ pState = (unsigned *)Vec_PtrEntry( pTsi->vStates, 0 );
Aig_TsiStateOrAll( pTsi, pState );
// check if there are constants
fConstants = 0;
@@ -506,3 +509,5 @@ Aig_Man_t * Aig_ManConstReduce( Aig_Man_t * p, int fVerbose )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/aig/aigUtil.c b/src/aig/aig/aigUtil.c
index f51b8871..1b97fb2c 100644
--- a/src/aig/aig/aigUtil.c
+++ b/src/aig/aig/aigUtil.c
@@ -20,6 +20,8 @@
#include "aig.h"
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -84,6 +86,30 @@ void Aig_ManIncrementTravId( Aig_Man_t * p )
/**Function*************************************************************
+ Synopsis [Returns the time stamp.]
+
+ Description [The file should be closed.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+char * Aig_TimeStamp()
+{
+ static char Buffer[100];
+ char * TimeStamp;
+ time_t ltime;
+ // get the current time
+ time( &ltime );
+ TimeStamp = asctime( localtime( &ltime ) );
+ TimeStamp[ strlen(TimeStamp) - 1 ] = 0;
+ strcpy( Buffer, TimeStamp );
+ return Buffer;
+}
+
+/**Function*************************************************************
+
Synopsis [Make sure AIG has not gaps in the numeric order.]
Description []
@@ -548,10 +574,10 @@ void Aig_ObjPrintEqn( FILE * pFile, Aig_Obj_t * pObj, Vec_Vec_t * vLevels, int L
}
// AND case
Vec_VecExpand( vLevels, Level );
- vSuper = Vec_VecEntry(vLevels, Level);
+ vSuper = (Vec_Ptr_t *)Vec_VecEntry(vLevels, Level);
Aig_ObjCollectMulti( pObj, vSuper );
fprintf( pFile, "%s", (Level==0? "" : "(") );
- Vec_PtrForEachEntry( vSuper, pFanin, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vSuper, pFanin, i )
{
Aig_ObjPrintEqn( pFile, Aig_NotCond(pFanin, fCompl), vLevels, Level+1 );
if ( i < Vec_PtrSize(vSuper) - 1 )
@@ -597,10 +623,10 @@ void Aig_ObjPrintVerilog( FILE * pFile, Aig_Obj_t * pObj, Vec_Vec_t * vLevels, i
if ( Aig_ObjIsExor(pObj) )
{
Vec_VecExpand( vLevels, Level );
- vSuper = Vec_VecEntry( vLevels, Level );
+ vSuper = (Vec_Ptr_t *)Vec_VecEntry( vLevels, Level );
Aig_ObjCollectMulti( pObj, vSuper );
fprintf( pFile, "%s", (Level==0? "" : "(") );
- Vec_PtrForEachEntry( vSuper, pFanin, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vSuper, pFanin, i )
{
Aig_ObjPrintVerilog( pFile, Aig_NotCond(pFanin, (fCompl && i==0)), vLevels, Level+1 );
if ( i < Vec_PtrSize(vSuper) - 1 )
@@ -635,10 +661,10 @@ 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);
+ vSuper = (Vec_Ptr_t *)Vec_VecEntry(vLevels, Level);
Aig_ObjCollectMulti( pObj, vSuper );
fprintf( pFile, "%s", (Level==0? "" : "(") );
- Vec_PtrForEachEntry( vSuper, pFanin, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vSuper, pFanin, i )
{
Aig_ObjPrintVerilog( pFile, Aig_NotCond(pFanin, fCompl), vLevels, Level+1 );
if ( i < Vec_PtrSize(vSuper) - 1 )
@@ -702,7 +728,7 @@ void Aig_ManPrintVerbose( Aig_Man_t * p, int fHaig )
printf( " %p", pObj );
printf( "\n" );
vNodes = Aig_ManDfs( p, 0 );
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
Aig_ObjPrintVerbose( pObj, fHaig ), printf( "\n" );
printf( "\n" );
}
@@ -762,7 +788,7 @@ void Aig_ManDumpBlif( Aig_Man_t * p, char * pFileName, Vec_Ptr_t * vPiNames, Vec
pObj->iData = Counter++;
Aig_ManForEachPo( p, pObj, i )
pObj->iData = Counter++;
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
pObj->iData = Counter++;
nDigits = Aig_Base10Log( Counter );
// write the file
@@ -809,7 +835,7 @@ void Aig_ManDumpBlif( Aig_Man_t * p, char * pFileName, Vec_Ptr_t * vPiNames, Vec
if ( pConst1 )
fprintf( pFile, ".names n%0*d\n 1\n", nDigits, pConst1->iData );
Aig_ManSetPioNumbers( p );
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
{
fprintf( pFile, ".names" );
if ( vPiNames && Aig_ObjIsPi(Aig_ObjFanin0(pObj)) )
@@ -877,7 +903,7 @@ void Aig_ManDumpVerilog( Aig_Man_t * p, char * pFileName )
pObj->iData = Counter++;
Aig_ManForEachPo( p, pObj, i )
pObj->iData = Counter++;
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
pObj->iData = Counter++;
nDigits = Aig_Base10Log( Counter );
// write the file
@@ -911,14 +937,14 @@ void Aig_ManDumpVerilog( Aig_Man_t * p, char * pFileName )
fprintf( pFile, "wire n%0*d;\n", nDigits, pObjLi->iData );
}
// write nodes
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
fprintf( pFile, "wire n%0*d;\n", nDigits, pObj->iData );
if ( pConst1 )
fprintf( pFile, "wire n%0*d;\n", nDigits, pConst1->iData );
// write nodes
if ( pConst1 )
fprintf( pFile, "assign n%0*d = 1\'b1;\n", nDigits, pConst1->iData );
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
{
fprintf( pFile, "assign n%0*d = %sn%0*d & %sn%0*d;\n",
nDigits, pObj->iData,
@@ -1193,7 +1219,7 @@ void Aig_ManRandomInfo( Vec_Ptr_t * vInfo, int iInputStart, int iWordStart, int
{
unsigned * pInfo;
int i, w;
- Vec_PtrForEachEntryStart( vInfo, pInfo, i, iInputStart )
+ Vec_PtrForEachEntryStart( unsigned *, vInfo, pInfo, i, iInputStart )
for ( w = iWordStart; w < iWordStop; w++ )
pInfo[w] = Aig_ManRandom(0);
}
@@ -1278,10 +1304,15 @@ void Aig_NodeIntersectLists( Vec_Ptr_t * vArr1, Vec_Ptr_t * vArr2, Vec_Ptr_t * v
assert( vArr->nSize <= vArr2->nSize );
}
+ABC_NAMESPACE_IMPL_END
+
#include "fra.h"
#include "saig.h"
-extern void Aig_ManCounterExampleValueStart( Aig_Man_t * pAig, Fra_Cex_t * pCex );
+ABC_NAMESPACE_IMPL_START
+
+
+extern void Aig_ManCounterExampleValueStart( Aig_Man_t * pAig, Abc_Cex_t * pCex );
extern void Aig_ManCounterExampleValueStop( Aig_Man_t * pAig );
extern int Aig_ManCounterExampleValueLookup( Aig_Man_t * pAig, int Id, int iFrame );
@@ -1297,7 +1328,7 @@ extern int Aig_ManCounterExampleValueLookup( Aig_Man_t * pAig, int Id, int iFra
SeeAlso []
***********************************************************************/
-void Aig_ManCounterExampleValueStart( Aig_Man_t * pAig, Fra_Cex_t * pCex )
+void Aig_ManCounterExampleValueStart( Aig_Man_t * pAig, Abc_Cex_t * pCex )
{
Aig_Obj_t * pObj, * pObjRi, * pObjRo;
int Val0, Val1, nObjs, i, k, iBit = 0;
@@ -1313,36 +1344,36 @@ void Aig_ManCounterExampleValueStart( Aig_Man_t * pAig, Fra_Cex_t * pCex )
for ( i = 0; i <= pCex->iFrame; i++ )
{
// set constant 1 node
- Aig_InfoSetBit( pAig->pData2, nObjs * i + 0 );
+ Aig_InfoSetBit( (unsigned *)pAig->pData2, nObjs * i + 0 );
// set primary inputs according to the counter-example
Saig_ManForEachPi( pAig, pObj, k )
if ( Aig_InfoHasBit(pCex->pData, iBit++) )
- Aig_InfoSetBit( pAig->pData2, nObjs * i + Aig_ObjId(pObj) );
+ Aig_InfoSetBit( (unsigned *)pAig->pData2, nObjs * i + Aig_ObjId(pObj) );
// compute values for each node
Aig_ManForEachNode( pAig, pObj, k )
{
- Val0 = Aig_InfoHasBit( pAig->pData2, nObjs * i + Aig_ObjFaninId0(pObj) );
- Val1 = Aig_InfoHasBit( pAig->pData2, nObjs * i + Aig_ObjFaninId1(pObj) );
+ Val0 = Aig_InfoHasBit( (unsigned *)pAig->pData2, nObjs * i + Aig_ObjFaninId0(pObj) );
+ Val1 = Aig_InfoHasBit( (unsigned *)pAig->pData2, nObjs * i + Aig_ObjFaninId1(pObj) );
if ( (Val0 ^ Aig_ObjFaninC0(pObj)) & (Val1 ^ Aig_ObjFaninC1(pObj)) )
- Aig_InfoSetBit( pAig->pData2, nObjs * i + Aig_ObjId(pObj) );
+ Aig_InfoSetBit( (unsigned *)pAig->pData2, nObjs * i + Aig_ObjId(pObj) );
}
// derive values for combinational outputs
Aig_ManForEachPo( pAig, pObj, k )
{
- Val0 = Aig_InfoHasBit( pAig->pData2, nObjs * i + Aig_ObjFaninId0(pObj) );
+ Val0 = Aig_InfoHasBit( (unsigned *)pAig->pData2, nObjs * i + Aig_ObjFaninId0(pObj) );
if ( Val0 ^ Aig_ObjFaninC0(pObj) )
- Aig_InfoSetBit( pAig->pData2, nObjs * i + Aig_ObjId(pObj) );
+ Aig_InfoSetBit( (unsigned *)pAig->pData2, nObjs * i + Aig_ObjId(pObj) );
}
if ( i == pCex->iFrame )
continue;
// transfer values to the register output of the next frame
Saig_ManForEachLiLo( pAig, pObjRi, pObjRo, k )
- if ( Aig_InfoHasBit( pAig->pData2, nObjs * i + Aig_ObjId(pObjRi) ) )
- Aig_InfoSetBit( pAig->pData2, nObjs * (i+1) + Aig_ObjId(pObjRo) );
+ if ( Aig_InfoHasBit( (unsigned *)pAig->pData2, nObjs * i + Aig_ObjId(pObjRi) ) )
+ Aig_InfoSetBit( (unsigned *)pAig->pData2, nObjs * (i+1) + Aig_ObjId(pObjRo) );
}
assert( iBit == pCex->nBits );
// check that the counter-example is correct, that is, the corresponding output is asserted
- assert( Aig_InfoHasBit( pAig->pData2, nObjs * pCex->iFrame + Aig_ObjId(Aig_ManPo(pAig, pCex->iPo)) ) );
+ assert( Aig_InfoHasBit( (unsigned *)pAig->pData2, nObjs * pCex->iFrame + Aig_ObjId(Aig_ManPo(pAig, pCex->iPo)) ) );
}
/**Function*************************************************************
@@ -1379,7 +1410,7 @@ void Aig_ManCounterExampleValueStop( Aig_Man_t * pAig )
int Aig_ManCounterExampleValueLookup( Aig_Man_t * pAig, int Id, int iFrame )
{
assert( Id >= 0 && Id < Aig_ManObjNum(pAig) );
- return Aig_InfoHasBit( pAig->pData2, Aig_ManObjNum(pAig) * iFrame + Id );
+ return Aig_InfoHasBit( (unsigned *)pAig->pData2, Aig_ManObjNum(pAig) * iFrame + Id );
}
/**Function*************************************************************
@@ -1393,7 +1424,7 @@ int Aig_ManCounterExampleValueLookup( Aig_Man_t * pAig, int Id, int iFrame )
SeeAlso []
***********************************************************************/
-void Aig_ManCounterExampleValueTest( Aig_Man_t * pAig, Fra_Cex_t * pCex )
+void Aig_ManCounterExampleValueTest( Aig_Man_t * pAig, Abc_Cex_t * pCex )
{
Aig_Obj_t * pObj = Aig_ManObj( pAig, Aig_ManObjNum(pAig)/2 );
int iFrame = ABC_MAX( 0, pCex->iFrame - 1 );
@@ -1404,9 +1435,123 @@ void Aig_ManCounterExampleValueTest( Aig_Man_t * pAig, Fra_Cex_t * pCex )
Aig_ManCounterExampleValueStop( pAig );
}
+/**Function*************************************************************
+
+ Synopsis [Handle the counter-example.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Aig_ManSetPhase( Aig_Man_t * pAig )
+{
+ Aig_Obj_t * pObj;
+ int i;
+ // set the PI simulation information
+ Aig_ManConst1( pAig )->fPhase = 1;
+ Aig_ManForEachPi( pAig, pObj, i )
+ pObj->fPhase = 0;
+ // simulate internal nodes
+ Aig_ManForEachNode( pAig, pObj, i )
+ pObj->fPhase = ( Aig_ObjFanin0(pObj)->fPhase ^ Aig_ObjFaninC0(pObj) )
+ & ( Aig_ObjFanin1(pObj)->fPhase ^ Aig_ObjFaninC1(pObj) );
+ // simulate PO nodes
+ Aig_ManForEachPo( pAig, pObj, i )
+ pObj->fPhase = Aig_ObjFanin0(pObj)->fPhase ^ Aig_ObjFaninC0(pObj);
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Collects muxes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Ptr_t * Aig_ManMuxesCollect( Aig_Man_t * pAig )
+{
+ Vec_Ptr_t * vMuxes;
+ Aig_Obj_t * pObj;
+ int i;
+ vMuxes = Vec_PtrAlloc( 100 );
+ Aig_ManForEachNode( pAig, pObj, i )
+ if ( Aig_ObjIsMuxType(pObj) )
+ Vec_PtrPush( vMuxes, pObj );
+ return vMuxes;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Dereferences muxes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Aig_ManMuxesDeref( Aig_Man_t * pAig, Vec_Ptr_t * vMuxes )
+{
+ Aig_Obj_t * pObj, * pNodeT, * pNodeE, * pNodeC;
+ int i;
+ Vec_PtrForEachEntry( Aig_Obj_t *, vMuxes, pObj, i )
+ {
+ if ( Aig_ObjRecognizeExor( pObj, &pNodeT, &pNodeE ) )
+ {
+ pNodeT->nRefs--;
+ pNodeE->nRefs--;
+ }
+ else
+ {
+ pNodeC = Aig_ObjRecognizeMux( pObj, &pNodeT, &pNodeE );
+ pNodeC->nRefs--;
+ }
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [References muxes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Aig_ManMuxesRef( Aig_Man_t * pAig, Vec_Ptr_t * vMuxes )
+{
+ Aig_Obj_t * pObj, * pNodeT, * pNodeE, * pNodeC;
+ int i;
+ Vec_PtrForEachEntry( Aig_Obj_t *, vMuxes, pObj, i )
+ {
+ if ( Aig_ObjRecognizeExor( pObj, &pNodeT, &pNodeE ) )
+ {
+ pNodeT->nRefs++;
+ pNodeE->nRefs++;
+ }
+ else
+ {
+ pNodeC = Aig_ObjRecognizeMux( pObj, &pNodeT, &pNodeE );
+ pNodeC->nRefs++;
+ }
+ }
+}
+
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/aig/aigWin.c b/src/aig/aig/aigWin.c
index 0485b243..5568c9ec 100644
--- a/src/aig/aig/aigWin.c
+++ b/src/aig/aig/aigWin.c
@@ -20,6 +20,9 @@
#include "aig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -82,7 +85,7 @@ int Aig_ManFindCut_int( Vec_Ptr_t * vFront, Vec_Ptr_t * vVisited, int nSizeLimit
CostBest = 100;
pFaninBest = NULL;
//printf( "Evaluating fanins of the cut:\n" );
- Vec_PtrForEachEntry( vFront, pNode, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vFront, pNode, i )
{
CostCur = Aig_NodeGetLeafCostOne( pNode, nFanoutLimit );
//printf( " Fanin %s has cost %d.\n", Aig_ObjName(pNode), CostCur );
@@ -173,7 +176,7 @@ void Aig_ManFindCut( Aig_Obj_t * pRoot, Vec_Ptr_t * vFront, Vec_Ptr_t * vVisited
assert( Vec_PtrSize(vFront) <= nSizeLimit );
// clean the visit markings
- Vec_PtrForEachEntry( vVisited, pNode, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vVisited, pNode, i )
pNode->fMarkA = 0;
}
@@ -182,3 +185,5 @@ void Aig_ManFindCut( Aig_Obj_t * pRoot, Vec_Ptr_t * vFront, Vec_Ptr_t * vVisited
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/aig/aig_.c b/src/aig/aig/aig_.c
index b2313d35..ae0cb568 100644
--- a/src/aig/aig/aig_.c
+++ b/src/aig/aig/aig_.c
@@ -20,6 +20,9 @@
#include "aig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -46,3 +49,5 @@
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/aig/module.make b/src/aig/aig/module.make
index 5fea4341..03504138 100644
--- a/src/aig/aig/module.make
+++ b/src/aig/aig/module.make
@@ -20,6 +20,7 @@ SRC += src/aig/aig/aigCheck.c \
src/aig/aig/aigRetF.c \
src/aig/aig/aigScl.c \
src/aig/aig/aigShow.c \
+ src/aig/aig/aigSplit.c \
src/aig/aig/aigTable.c \
src/aig/aig/aigTiming.c \
src/aig/aig/aigTruth.c \
diff --git a/src/aig/bar/bar.c b/src/aig/bar/bar.c
index 2c5065cb..b5c31779 100644
--- a/src/aig/bar/bar.c
+++ b/src/aig/bar/bar.c
@@ -21,9 +21,14 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+
#include "abc_global.h"
+#include "main.h"
#include "bar.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -61,9 +66,7 @@ static void Bar_ProgressClean( Bar_Progress_t * p );
Bar_Progress_t * Bar_ProgressStart( FILE * pFile, int nItemsTotal )
{
Bar_Progress_t * p;
- void * pFrame;
- extern int Abc_FrameShowProgress( void * p );
- extern void * Abc_FrameReadGlobalFrame();
+ Abc_Frame_t * pFrame;
pFrame = Abc_FrameReadGlobalFrame();
if ( pFrame == NULL )
return NULL;
@@ -180,3 +183,5 @@ void Bar_ProgressClean( Bar_Progress_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/bar/bar.h b/src/aig/bar/bar.h
index 104c6f47..65c9ec6a 100644
--- a/src/aig/bar/bar.h
+++ b/src/aig/bar/bar.h
@@ -21,6 +21,7 @@
#ifndef __BAR_H__
#define __BAR_H__
+
#ifdef _WIN32
#define inline __inline // compatible with MS VS 6.0
#endif
@@ -33,9 +34,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
#define BAR_PROGRESS_USE 1
@@ -62,9 +64,11 @@ static inline void Bar_ProgressUpdate( Bar_Progress_t * p, int nItemsCur,
if ( BAR_PROGRESS_USE && p && (nItemsCur < *((int*)p)) ) return; Bar_ProgressUpdate_int(p, nItemsCur, pString); }
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/aig/bbl/bblif.c b/src/aig/bbl/bblif.c
index adc10b28..e68258d9 100644
--- a/src/aig/bbl/bblif.c
+++ b/src/aig/bbl/bblif.c
@@ -24,8 +24,12 @@
#include <assert.h>
#include <time.h>
+#include "abc_global.h"
#include "bblif.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -375,9 +379,10 @@ static inline void Vec_IntFillExtra( Vec_Int_t * p, int nSize, int Fill )
int i;
if ( p->nSize >= nSize )
return;
- if ( nSize < 2 * p->nSize )
- nSize = 2 * p->nSize;
- Vec_IntGrow( p, nSize );
+ if ( nSize > 2 * p->nCap )
+ Vec_IntGrow( p, nSize );
+ else if ( nSize > p->nCap )
+ Vec_IntGrow( p, 2 * p->nCap );
for ( i = p->nSize; i < nSize; i++ )
p->pArray[i] = Fill;
p->nSize = nSize;
@@ -1509,3 +1514,5 @@ void Bbl_ManSimpleDemo()
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/bbl/bblif.h b/src/aig/bbl/bblif.h
index 89c58f93..787d649f 100644
--- a/src/aig/bbl/bblif.h
+++ b/src/aig/bbl/bblif.h
@@ -21,6 +21,7 @@
#ifndef __BBLIF_H__
#define __BBLIF_H__
+
/*
This file (taken together with "bblif.c") implements a stand-alone
interface between ABC and an application that uses ABC.
@@ -186,9 +187,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
#ifdef _WIN32
#define inline __inline
@@ -269,9 +271,11 @@ extern void Bbl_ManDumpBlif( Bbl_Man_t * p, char * pFileName );
extern void Bbl_ManSimpleDemo();
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/aig/bbr/bbr.h b/src/aig/bbr/bbr.h
index e5d585ce..bb83ac95 100644
--- a/src/aig/bbr/bbr.h
+++ b/src/aig/bbr/bbr.h
@@ -21,22 +21,24 @@
#ifndef __BBR_H__
#define __BBR_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
#include <stdio.h>
-#include "cuddInt.h"
#include "aig.h"
#include "saig.h"
+#include "cuddInt.h"
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -46,7 +48,7 @@ extern "C" {
/// MACRO DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
-static inline DdNode * Aig_ObjGlobalBdd( Aig_Obj_t * pObj ) { return pObj->pData; }
+static inline DdNode * Aig_ObjGlobalBdd( Aig_Obj_t * pObj ) { return (DdNode *)pObj->pData; }
////////////////////////////////////////////////////////////////////////
/// FUNCTION DECLARATIONS ///
@@ -74,11 +76,14 @@ extern void Aig_ManFreeGlobalBdds( Aig_Man_t * p, DdManager * dd );
extern int Aig_ManSizeOfGlobalBdds( Aig_Man_t * p );
extern DdManager * Aig_ManComputeGlobalBdds( Aig_Man_t * p, int nBddSizeMax, int fDropInternal, int fReorder, int fVerbose );
/*=== bbrReach.c ==========================================================*/
-extern int Aig_ManVerifyUsingBdds( Aig_Man_t * p, int nBddMax, int nIterMax, int fPartition, int fReorder, int fReorderImage, int fVerbose, int fSilent );
+extern int Aig_ManVerifyUsingBdds( Aig_Man_t * p, Saig_ParBbr_t * pPars );
+extern void Bbr_ManSetDefaultParams( Saig_ParBbr_t * p );
+
+
+
+ABC_NAMESPACE_HEADER_END
+
-#ifdef __cplusplus
-}
-#endif
#endif
diff --git a/src/aig/bbr/bbrCex.c b/src/aig/bbr/bbrCex.c
index 947c393c..8f99ea3c 100644
--- a/src/aig/bbr/bbrCex.c
+++ b/src/aig/bbr/bbrCex.c
@@ -21,6 +21,9 @@
#include "bbr.h"
#include "ssw.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -42,11 +45,11 @@ extern DdNode * Bbr_bddComputeRangeCube( DdManager * dd, int iStart, int iStop )
SeeAlso []
***********************************************************************/
-Ssw_Cex_t * Aig_ManVerifyUsingBddsCountExample( Aig_Man_t * p, DdManager * dd,
+Abc_Cex_t * Aig_ManVerifyUsingBddsCountExample( Aig_Man_t * p, DdManager * dd,
DdNode ** pbParts, Vec_Ptr_t * vOnionRings, DdNode * bCubeFirst,
int iOutput, int fVerbose, int fSilent )
{
- Ssw_Cex_t * pCex;
+ Abc_Cex_t * pCex;
Aig_Obj_t * pObj;
Bbr_ImageTree_t * pTree;
DdNode * bCubeNs, * bState, * bImage;
@@ -96,7 +99,7 @@ Ssw_Cex_t * Aig_ManVerifyUsingBddsCountExample( Aig_Man_t * p, DdManager * dd,
}
// perform backward analysis
- Vec_PtrForEachEntryReverse( vOnionRings, bRing, v )
+ Vec_PtrForEachEntryReverse( DdNode *, vOnionRings, bRing, v )
{
// compute the next states
bImage = Bbr_bddImageCompute( pTree, bState );
@@ -166,3 +169,5 @@ Ssw_Cex_t * Aig_ManVerifyUsingBddsCountExample( Aig_Man_t * p, DdManager * dd,
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/bbr/bbrImage.c b/src/aig/bbr/bbrImage.c
index c16a8ff4..8b18d84d 100644
--- a/src/aig/bbr/bbrImage.c
+++ b/src/aig/bbr/bbrImage.c
@@ -19,7 +19,10 @@
***********************************************************************/
#include "bbr.h"
-#include "mtr.h"
+#include "mtr.h"
+
+ABC_NAMESPACE_IMPL_START
+
/*
The ideas implemented in this file are inspired by the paper:
@@ -1320,3 +1323,5 @@ DdNode * Bbr_bddImageRead2( Bbr_ImageTree2_t * pTree )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/bbr/bbrNtbdd.c b/src/aig/bbr/bbrNtbdd.c
index 05c98fe1..09456df0 100644
--- a/src/aig/bbr/bbrNtbdd.c
+++ b/src/aig/bbr/bbrNtbdd.c
@@ -21,6 +21,9 @@
#include "bbr.h"
//#include "bar.h"
+ABC_NAMESPACE_IMPL_START
+
+
typedef char ProgressBar;
////////////////////////////////////////////////////////////////////////
@@ -28,7 +31,7 @@ typedef char ProgressBar;
////////////////////////////////////////////////////////////////////////
static inline void Aig_ObjSetGlobalBdd( Aig_Obj_t * pObj, DdNode * bFunc ) { pObj->pData = bFunc; }
-static inline void Aig_ObjCleanGlobalBdd( DdManager * dd, Aig_Obj_t * pObj ) { Cudd_RecursiveDeref( dd, pObj->pData ); pObj->pData = NULL; }
+static inline void Aig_ObjCleanGlobalBdd( DdManager * dd, Aig_Obj_t * pObj ) { Cudd_RecursiveDeref( dd, (DdNode *)pObj->pData ); pObj->pData = NULL; }
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
@@ -211,3 +214,5 @@ DdManager * Aig_ManComputeGlobalBdds( Aig_Man_t * p, int nBddSizeMax, int fDropI
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/bbr/bbrReach.c b/src/aig/bbr/bbrReach.c
index 7d0e4bc0..f76c9671 100644
--- a/src/aig/bbr/bbrReach.c
+++ b/src/aig/bbr/bbrReach.c
@@ -21,11 +21,14 @@
#include "bbr.h"
#include "ssw.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
-extern void * Aig_ManVerifyUsingBddsCountExample( Aig_Man_t * p, DdManager * dd,
+extern Abc_Cex_t * Aig_ManVerifyUsingBddsCountExample( Aig_Man_t * p, DdManager * dd,
DdNode ** pbParts, Vec_Ptr_t * vOnionRings, DdNode * bCubeFirst,
int iOutput, int fVerbose, int fSilent );
@@ -33,6 +36,31 @@ extern void * Aig_ManVerifyUsingBddsCountExample( Aig_Man_t * p, DdManager * dd,
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
+/**Function*************************************************************
+
+ Synopsis [This procedure sets default resynthesis parameters.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Bbr_ManSetDefaultParams( Saig_ParBbr_t * p )
+{
+ memset( p, 0, sizeof(Saig_ParBbr_t) );
+ p->TimeLimit = 0;
+ p->nBddMax = 50000;
+ p->nIterMax = 1000;
+ p->fPartition = 1;
+ p->fReorder = 1;
+ p->fReorderImage = 1;
+ p->fVerbose = 0;
+ p->fSilent = 0;
+ p->iFrame = -1;
+}
+
/**Function********************************************************************
Synopsis [Performs the reordering-sensitive step of Extra_bddMove().]
@@ -208,7 +236,7 @@ DdNode ** Aig_ManCreatePartitions( DdManager * dd, Aig_Man_t * p, int fReorder,
SeeAlso []
***********************************************************************/
-int Aig_ManComputeReachable( DdManager * dd, Aig_Man_t * p, DdNode ** pbParts, DdNode * bInitial, DdNode ** pbOutputs, int nBddMax, int nIterMax, int fPartition, int fReorder, int fVerbose, int fSilent )
+int Aig_ManComputeReachable( DdManager * dd, Aig_Man_t * p, DdNode ** pbParts, DdNode * bInitial, DdNode ** pbOutputs, Saig_ParBbr_t * pPars, int fCheckOutputs )
{
int fInternalReorder = 0;
Bbr_ImageTree_t * pTree = NULL; // Suppress "might be used uninitialized"
@@ -217,10 +245,10 @@ int Aig_ManComputeReachable( DdManager * dd, Aig_Man_t * p, DdNode ** pbParts, D
DdNode * bCurrent;
DdNode * bNext = NULL; // Suppress "might be used uninitialized"
DdNode * bTemp;
- int i, nIters, nBddSize;
- int nThreshold = 10000;
+ Cudd_ReorderingType method;
+ int i, nIters, nBddSize, status;
+ int nThreshold = 10000, clk = clock();
Vec_Ptr_t * vOnionRings;
- int status, method;
status = Cudd_ReorderingStatus( dd, &method );
if ( status )
@@ -228,14 +256,14 @@ int Aig_ManComputeReachable( DdManager * dd, Aig_Man_t * p, DdNode ** pbParts, D
// start the image computation
bCubeCs = Bbr_bddComputeRangeCube( dd, Saig_ManPiNum(p), Saig_ManCiNum(p) ); Cudd_Ref( bCubeCs );
- if ( fPartition )
- pTree = Bbr_bddImageStart( dd, bCubeCs, Saig_ManRegNum(p), pbParts, Saig_ManRegNum(p), dd->vars+Saig_ManCiNum(p), nBddMax, fVerbose );
+ if ( pPars->fPartition )
+ pTree = Bbr_bddImageStart( dd, bCubeCs, Saig_ManRegNum(p), pbParts, Saig_ManRegNum(p), dd->vars+Saig_ManCiNum(p), pPars->nBddMax, pPars->fVerbose );
else
- pTree2 = Bbr_bddImageStart2( dd, bCubeCs, Saig_ManRegNum(p), pbParts, Saig_ManRegNum(p), dd->vars+Saig_ManCiNum(p), fVerbose );
+ pTree2 = Bbr_bddImageStart2( dd, bCubeCs, Saig_ManRegNum(p), pbParts, Saig_ManRegNum(p), dd->vars+Saig_ManCiNum(p), pPars->fVerbose );
Cudd_RecursiveDeref( dd, bCubeCs );
if ( pTree == NULL )
{
- if ( !fSilent )
+ if ( !pPars->fSilent )
printf( "BDDs blew up during qualitification scheduling. " );
return -1;
}
@@ -246,30 +274,46 @@ int Aig_ManComputeReachable( DdManager * dd, Aig_Man_t * p, DdNode ** pbParts, D
// start the onion rings
vOnionRings = Vec_PtrAlloc( 1000 );
- // perform reachability analisys
+ // perform reachability analysis
bCurrent = bInitial; Cudd_Ref( bCurrent );
bReached = bInitial; Cudd_Ref( bReached );
Vec_PtrPush( vOnionRings, bCurrent ); Cudd_Ref( bCurrent );
- for ( nIters = 1; nIters <= nIterMax; nIters++ )
+ for ( nIters = 0; nIters < pPars->nIterMax; nIters++ )
{
+ // check the runtime limit
+ if ( pPars->TimeLimit && ((float)pPars->TimeLimit <= (float)(clock()-clk)/(float)(CLOCKS_PER_SEC)) )
+ {
+ printf( "Reached timeout after image computation (%d seconds).\n", pPars->TimeLimit );
+ Vec_PtrFree( vOnionRings );
+ // undo the image tree
+ if ( pPars->fPartition )
+ Bbr_bddImageTreeDelete( pTree );
+ else
+ Bbr_bddImageTreeDelete2( pTree2 );
+ pPars->iFrame = nIters - 1;
+ return -1;
+ }
+
// compute the next states
- if ( fPartition )
+ if ( pPars->fPartition )
bNext = Bbr_bddImageCompute( pTree, bCurrent );
else
bNext = Bbr_bddImageCompute2( pTree2, bCurrent );
if ( bNext == NULL )
{
- if ( !fSilent )
+ if ( !pPars->fSilent )
printf( "BDDs blew up during image computation. " );
- if ( fPartition )
+ if ( pPars->fPartition )
Bbr_bddImageTreeDelete( pTree );
else
Bbr_bddImageTreeDelete2( pTree2 );
Vec_PtrFree( vOnionRings );
+ pPars->iFrame = nIters - 1;
return -1;
}
Cudd_Ref( bNext );
Cudd_RecursiveDeref( dd, bCurrent );
+
// remap these states into the current state vars
bNext = Cudd_bddVarMap( dd, bTemp = bNext ); Cudd_Ref( bNext );
Cudd_RecursiveDeref( dd, bTemp );
@@ -278,23 +322,24 @@ int Aig_ManComputeReachable( DdManager * dd, Aig_Man_t * p, DdNode ** pbParts, D
break;
// check the BDD size
nBddSize = Cudd_DagSize(bNext);
- if ( nBddSize > nBddMax )
+ if ( nBddSize > pPars->nBddMax )
break;
// check the result
for ( i = 0; i < Saig_ManPoNum(p); i++ )
{
- if ( !Cudd_bddLeq( dd, bNext, Cudd_Not(pbOutputs[i]) ) )
+ if ( fCheckOutputs && !Cudd_bddLeq( dd, bNext, Cudd_Not(pbOutputs[i]) ) )
{
DdNode * bIntersect;
bIntersect = Cudd_bddIntersect( dd, bNext, pbOutputs[i] ); Cudd_Ref( bIntersect );
assert( p->pSeqModel == NULL );
p->pSeqModel = Aig_ManVerifyUsingBddsCountExample( p, dd, pbParts,
- vOnionRings, bIntersect, i, fVerbose, fSilent );
+ vOnionRings, bIntersect, i, pPars->fVerbose, pPars->fSilent );
Cudd_RecursiveDeref( dd, bIntersect );
- if ( !fSilent )
+ if ( !pPars->fSilent )
printf( "Output %d was asserted in frame %d (use \"write_counter\" to dump a witness). ", i, Vec_PtrSize(vOnionRings) );
Cudd_RecursiveDeref( dd, bReached );
bReached = NULL;
+ pPars->iFrame = nIters;
break;
}
}
@@ -310,38 +355,39 @@ int Aig_ManComputeReachable( DdManager * dd, Aig_Man_t * p, DdNode ** pbParts, D
bReached = Cudd_bddOr( dd, bTemp = bReached, bNext ); Cudd_Ref( bReached );
Cudd_RecursiveDeref( dd, bTemp );
Cudd_RecursiveDeref( dd, bNext );
- if ( fVerbose )
+ if ( pPars->fVerbose )
fprintf( stdout, "Frame = %3d. BDD = %5d. ", nIters, nBddSize );
- if ( fInternalReorder && fReorder && nBddSize > nThreshold )
+ if ( fInternalReorder && pPars->fReorder && nBddSize > nThreshold )
{
- if ( fVerbose )
+ if ( pPars->fVerbose )
fprintf( stdout, "Reordering... Before = %5d. ", Cudd_DagSize(bReached) );
Cudd_ReduceHeap( dd, CUDD_REORDER_SYMM_SIFT, 100 );
Cudd_AutodynDisable( dd );
- if ( fVerbose )
+ if ( pPars->fVerbose )
fprintf( stdout, "After = %5d.\r", Cudd_DagSize(bReached) );
nThreshold *= 2;
}
- if ( fVerbose )
- fprintf( stdout, "\r" );
+ if ( pPars->fVerbose )
+// fprintf( stdout, "\r" );
+ fprintf( stdout, "\n" );
}
Cudd_RecursiveDeref( dd, bNext );
// free the onion rings
- Vec_PtrForEachEntry( vOnionRings, bTemp, i )
+ Vec_PtrForEachEntry( DdNode *, vOnionRings, bTemp, i )
Cudd_RecursiveDeref( dd, bTemp );
Vec_PtrFree( vOnionRings );
// undo the image tree
- if ( fPartition )
+ if ( pPars->fPartition )
Bbr_bddImageTreeDelete( pTree );
else
Bbr_bddImageTreeDelete2( pTree2 );
if ( bReached == NULL )
return 0; // proved reachable
// report the stats
- if ( fVerbose )
+ if ( pPars->fVerbose )
{
double nMints = Cudd_CountMinterm(dd, bReached, Saig_ManRegNum(p) );
- if ( nIters > nIterMax || Cudd_DagSize(bReached) > nBddMax )
+ if ( nIters > pPars->nIterMax || nBddSize > pPars->nBddMax )
fprintf( stdout, "Reachability analysis is stopped after %d frames.\n", nIters );
else
fprintf( stdout, "Reachability analysis completed after %d frames.\n", nIters );
@@ -350,14 +396,15 @@ int Aig_ManComputeReachable( DdManager * dd, Aig_Man_t * p, DdNode ** pbParts, D
}
//ABC_PRB( dd, bReached );
Cudd_RecursiveDeref( dd, bReached );
- if ( nIters > nIterMax || Cudd_DagSize(bReached) > nBddMax )
+ if ( nIters > pPars->nIterMax || nBddSize > pPars->nBddMax )
{
- if ( !fSilent )
+ if ( !pPars->fSilent )
printf( "Verified only for states reachable in %d frames. ", nIters );
return -1; // undecided
}
- if ( !fSilent )
+ if ( !pPars->fSilent )
printf( "The miter is proved unreachable after %d iterations. ", nIters );
+ pPars->iFrame = nIters - 1;
return 1; // unreachable
}
@@ -372,8 +419,9 @@ int Aig_ManComputeReachable( DdManager * dd, Aig_Man_t * p, DdNode ** pbParts, D
SeeAlso []
***********************************************************************/
-int Aig_ManVerifyUsingBdds_int( Aig_Man_t * p, int nBddMax, int nIterMax, int fPartition, int fReorder, int fReorderImage, int fVerbose, int fSilent )
+int Aig_ManVerifyUsingBdds_int( Aig_Man_t * p, Saig_ParBbr_t * pPars )
{
+ int fCheckOutputs = !pPars->fSkipOutCheck;
DdManager * dd;
DdNode ** pbParts, ** pbOutputs;
DdNode * bInitial, * bTemp;
@@ -383,16 +431,24 @@ int Aig_ManVerifyUsingBdds_int( Aig_Man_t * p, int nBddMax, int nIterMax, int fP
assert( Saig_ManRegNum(p) > 0 );
// compute the global BDDs of the latches
- dd = Aig_ManComputeGlobalBdds( p, nBddMax, 1, fReorder, fVerbose );
+ dd = Aig_ManComputeGlobalBdds( p, pPars->nBddMax, 1, pPars->fReorder, pPars->fVerbose );
if ( dd == NULL )
{
- if ( !fSilent )
- printf( "The number of intermediate BDD nodes exceeded the limit (%d).\n", nBddMax );
+ if ( !pPars->fSilent )
+ printf( "The number of intermediate BDD nodes exceeded the limit (%d).\n", pPars->nBddMax );
return -1;
}
- if ( fVerbose )
+ if ( pPars->fVerbose )
printf( "Shared BDD size is %6d nodes.\n", Cudd_ReadKeys(dd) - Cudd_ReadDead(dd) );
+ // check the runtime limit
+ if ( pPars->TimeLimit && ((float)pPars->TimeLimit <= (float)(clock()-clk)/(float)(CLOCKS_PER_SEC)) )
+ {
+ printf( "Reached timeout after constructing global BDDs (%d seconds).\n", pPars->TimeLimit );
+ Cudd_Quit( dd );
+ return -1;
+ }
+
// start the onion rings
vOnionRings = Vec_PtrAlloc( 1000 );
@@ -400,40 +456,40 @@ int Aig_ManVerifyUsingBdds_int( Aig_Man_t * p, int nBddMax, int nIterMax, int fP
pbOutputs = Aig_ManCreateOutputs( dd, p );
// create partitions
- pbParts = Aig_ManCreatePartitions( dd, p, fReorder, fVerbose );
+ pbParts = Aig_ManCreatePartitions( dd, p, pPars->fReorder, pPars->fVerbose );
// create the initial state and the variable map
- bInitial = Aig_ManInitStateVarMap( dd, p, fVerbose ); Cudd_Ref( bInitial );
+ bInitial = Aig_ManInitStateVarMap( dd, p, pPars->fVerbose ); Cudd_Ref( bInitial );
// set reordering
- if ( fReorderImage )
+ if ( pPars->fReorderImage )
Cudd_AutodynEnable( dd, CUDD_REORDER_SYMM_SIFT );
// check the result
RetValue = -1;
for ( i = 0; i < Saig_ManPoNum(p); i++ )
{
- if ( !Cudd_bddLeq( dd, bInitial, Cudd_Not(pbOutputs[i]) ) )
+ if ( fCheckOutputs && !Cudd_bddLeq( dd, bInitial, Cudd_Not(pbOutputs[i]) ) )
{
DdNode * bIntersect;
bIntersect = Cudd_bddIntersect( dd, bInitial, pbOutputs[i] ); Cudd_Ref( bIntersect );
assert( p->pSeqModel == NULL );
p->pSeqModel = Aig_ManVerifyUsingBddsCountExample( p, dd, pbParts,
- vOnionRings, bIntersect, i, fVerbose, fSilent );
+ vOnionRings, bIntersect, i, pPars->fVerbose, pPars->fSilent );
Cudd_RecursiveDeref( dd, bIntersect );
- if ( !fSilent )
+ if ( !pPars->fSilent )
printf( "The miter output %d is proved REACHABLE in the initial state (use \"write_counter\" to dump a witness). ", i );
RetValue = 0;
break;
}
}
// free the onion rings
- Vec_PtrForEachEntry( vOnionRings, bTemp, i )
+ Vec_PtrForEachEntry( DdNode *, vOnionRings, bTemp, i )
Cudd_RecursiveDeref( dd, bTemp );
Vec_PtrFree( vOnionRings );
// explore reachable states
if ( RetValue == -1 )
- RetValue = Aig_ManComputeReachable( dd, p, pbParts, bInitial, pbOutputs, nBddMax, nIterMax, fPartition, fReorder, fVerbose, fSilent );
+ RetValue = Aig_ManComputeReachable( dd, p, pbParts, bInitial, pbOutputs, pPars, fCheckOutputs );
// cleanup
Cudd_RecursiveDeref( dd, bInitial );
@@ -443,13 +499,13 @@ int Aig_ManVerifyUsingBdds_int( Aig_Man_t * p, int nBddMax, int nIterMax, int fP
for ( i = 0; i < Saig_ManPoNum(p); i++ )
Cudd_RecursiveDeref( dd, pbOutputs[i] );
ABC_FREE( pbOutputs );
- if ( RetValue == -1 )
+// if ( RetValue == -1 )
Cudd_Quit( dd );
- else
- Bbr_StopManager( dd );
+// else
+// Bbr_StopManager( dd );
// report the runtime
- if ( !fSilent )
+ if ( !pPars->fSilent )
{
ABC_PRT( "Time", clock() - clk );
fflush( stdout );
@@ -468,24 +524,25 @@ int Aig_ManVerifyUsingBdds_int( Aig_Man_t * p, int nBddMax, int nIterMax, int fP
SeeAlso []
***********************************************************************/
-int Aig_ManVerifyUsingBdds( Aig_Man_t * pInit, int nBddMax, int nIterMax, int fPartition, int fReorder, int fReorderImage, int fVerbose, int fSilent )
+int Aig_ManVerifyUsingBdds( Aig_Man_t * pInit, Saig_ParBbr_t * pPars )
{
- Ssw_Cex_t * pCexOld, * pCexNew;
+ Abc_Cex_t * pCexOld, * pCexNew;
Aig_Man_t * p;
Aig_Obj_t * pObj;
Vec_Int_t * vInputMap;
int i, k, Entry, iBitOld, iBitNew, RetValue;
+// pPars->fVerbose = 1;
// check if there are PIs without fanout
Saig_ManForEachPi( pInit, pObj, i )
if ( Aig_ObjRefs(pObj) == 0 )
break;
if ( i == Saig_ManPiNum(pInit) )
- return Aig_ManVerifyUsingBdds_int( pInit, nBddMax, nIterMax, fPartition, fReorder, fReorderImage, fVerbose, fSilent );
+ return Aig_ManVerifyUsingBdds_int( pInit, pPars );
// create new AIG
p = Aig_ManDupTrim( pInit );
assert( Aig_ManPiNum(p) < Aig_ManPiNum(pInit) );
assert( Aig_ManRegNum(p) == Aig_ManRegNum(pInit) );
- RetValue = Aig_ManVerifyUsingBdds_int( p, nBddMax, nIterMax, fPartition, fReorder, fReorderImage, fVerbose, fSilent );
+ RetValue = Aig_ManVerifyUsingBdds_int( p, pPars );
if ( RetValue != 0 )
{
Aig_ManStop( p );
@@ -498,7 +555,7 @@ int Aig_ManVerifyUsingBdds( Aig_Man_t * pInit, int nBddMax, int nIterMax, int fP
vInputMap = Vec_IntAlloc( Saig_ManPiNum(pInit) );
Saig_ManForEachPi( pInit, pObj, i )
if ( pObj->pData != NULL )
- Vec_IntPush( vInputMap, Aig_ObjPioNum(pObj->pData) );
+ Vec_IntPush( vInputMap, Aig_ObjPioNum((Aig_Obj_t *)pObj->pData) );
else
Vec_IntPush( vInputMap, -1 );
// create new pattern
@@ -537,3 +594,5 @@ int Aig_ManVerifyUsingBdds( Aig_Man_t * pInit, int nBddMax, int nIterMax, int fP
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/bbr/bbr_.c b/src/aig/bbr/bbr_.c
index f94c50e6..df934f7d 100644
--- a/src/aig/bbr/bbr_.c
+++ b/src/aig/bbr/bbr_.c
@@ -20,6 +20,9 @@
#include "__Int.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -45,3 +48,5 @@
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/bdc/bdc.h b/src/aig/bdc/bdc.h
index 0bdccf2b..8a240b0c 100644
--- a/src/aig/bdc/bdc.h
+++ b/src/aig/bdc/bdc.h
@@ -21,6 +21,7 @@
#ifndef __BDC_H__
#define __BDC_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -29,9 +30,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -72,12 +74,15 @@ extern int Bdc_ManNodeNum( Bdc_Man_t * p );
extern Bdc_Fun_t * Bdc_FuncFanin0( Bdc_Fun_t * p );
extern Bdc_Fun_t * Bdc_FuncFanin1( Bdc_Fun_t * p );
extern void * Bdc_FuncCopy( Bdc_Fun_t * p );
+extern int Bdc_FuncCopyInt( Bdc_Fun_t * p );
extern void Bdc_FuncSetCopy( Bdc_Fun_t * p, void * pCopy );
+extern void Bdc_FuncSetCopyInt( Bdc_Fun_t * p, int iCopy );
+
+
+
+ABC_NAMESPACE_HEADER_END
-#ifdef __cplusplus
-}
-#endif
#endif
diff --git a/src/aig/bdc/bdcCore.c b/src/aig/bdc/bdcCore.c
index fea08115..58324f81 100644
--- a/src/aig/bdc/bdcCore.c
+++ b/src/aig/bdc/bdcCore.c
@@ -20,6 +20,9 @@
#include "bdcInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -46,7 +49,9 @@ int Bdc_ManNodeNum( Bdc_Man_t * p ) { return p->nNode
Bdc_Fun_t * Bdc_FuncFanin0( Bdc_Fun_t * p ) { return p->pFan0; }
Bdc_Fun_t * Bdc_FuncFanin1( Bdc_Fun_t * p ) { return p->pFan1; }
void * Bdc_FuncCopy( Bdc_Fun_t * p ) { return p->pCopy; }
+int Bdc_FuncCopyInt( Bdc_Fun_t * p ) { return p->iCopy; }
void Bdc_FuncSetCopy( Bdc_Fun_t * p, void * pCopy ) { p->pCopy = pCopy; }
+void Bdc_FuncSetCopyInt( Bdc_Fun_t * p, int iCopy ) { p->iCopy = iCopy; }
/**Function*************************************************************
@@ -160,13 +165,13 @@ void Bdc_ManPrepare( Bdc_Man_t * p, Vec_Ptr_t * vDivs )
{
pNode = Bdc_FunNew( p );
pNode->Type = BDC_TYPE_PI;
- pNode->puFunc = Vec_PtrEntry( p->vTruths, i );
+ pNode->puFunc = (unsigned *)Vec_PtrEntry( p->vTruths, i );
pNode->uSupp = (1 << i);
Bdc_TableAdd( p, pNode );
}
// add the divisors
if ( vDivs )
- Vec_PtrForEachEntry( vDivs, puTruth, i )
+ Vec_PtrForEachEntry( unsigned *, vDivs, puTruth, i )
{
pNode = Bdc_FunNew( p );
pNode->Type = BDC_TYPE_PI;
@@ -305,3 +310,5 @@ void Bdc_ManDecomposeTest( unsigned uTruth, int nVars )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/bdc/bdcDec.c b/src/aig/bdc/bdcDec.c
index ccf6248f..61f46f17 100644
--- a/src/aig/bdc/bdcDec.c
+++ b/src/aig/bdc/bdcDec.c
@@ -20,6 +20,9 @@
#include "bdcInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -744,3 +747,5 @@ Extra_PrintBinary( stdout, pIsf->puOff, 1<<4 );printf("\n");
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/bdc/bdcInt.h b/src/aig/bdc/bdcInt.h
index 71ad8449..74630664 100644
--- a/src/aig/bdc/bdcInt.h
+++ b/src/aig/bdc/bdcInt.h
@@ -21,6 +21,7 @@
#ifndef __BDC_INT_H__
#define __BDC_INT_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -32,9 +33,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
#define BDC_SCALE 1000 // value used to compute the cost
@@ -62,7 +64,9 @@ struct Bdc_Fun_t_
unsigned uSupp; // bit mask of current support
unsigned * puFunc; // the function of the node
Bdc_Fun_t * pNext; // next function with same support
- void * pCopy; // the copy field
+ union { int iCopy; // the literal of the node (AIG)
+ void * pCopy; }; // the function of the node (BDD or AIG)
+
};
typedef struct Bdc_Isf_t_ Bdc_Isf_t;
@@ -147,9 +151,11 @@ extern void Bdc_TableAdd( Bdc_Man_t * p, Bdc_Fun_t * pFunc );
extern void Bdc_TableClear( Bdc_Man_t * p );
extern int Bdc_TableCheckContainment( Bdc_Man_t * p, Bdc_Isf_t * pIsf, unsigned * puTruth );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/aig/bdc/bdcTable.c b/src/aig/bdc/bdcTable.c
index 3a6ed126..69f35d88 100644
--- a/src/aig/bdc/bdcTable.c
+++ b/src/aig/bdc/bdcTable.c
@@ -20,6 +20,9 @@
#include "bdcInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -127,3 +130,5 @@ void Bdc_TableClear( Bdc_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/bdc/bdc_.c b/src/aig/bdc/bdc_.c
index 9d0a9462..b29d4f5e 100644
--- a/src/aig/bdc/bdc_.c
+++ b/src/aig/bdc/bdc_.c
@@ -20,6 +20,9 @@
#include "bdcInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -47,3 +50,5 @@
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/cec/cec.c b/src/aig/cec/cec.c
index 17b27ec5..6968a599 100644
--- a/src/aig/cec/cec.c
+++ b/src/aig/cec/cec.c
@@ -20,6 +20,9 @@
#include "cecInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -46,3 +49,5 @@
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/cec/cec.h b/src/aig/cec/cec.h
index 199d6939..e4547f5e 100644
--- a/src/aig/cec/cec.h
+++ b/src/aig/cec/cec.h
@@ -21,6 +21,7 @@
#ifndef __CEC_H__
#define __CEC_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -29,9 +30,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -103,8 +105,10 @@ struct Cec_ParFra_t_
// int fFirstStop; // stop on the first sat output
int fDualOut; // miter with separate outputs
int fColorDiff; // miter with separate outputs
+ int fSatSweeping; // enable SAT sweeping
int fVeryVerbose; // verbose stats
int fVerbose; // verbose stats
+ int iOutFail; // the failed output
};
// combinational equivalence checking parameters
@@ -118,6 +122,7 @@ struct Cec_ParCec_t_
int fRewriting; // enables AIG rewriting
int fVeryVerbose; // verbose stats
int fVerbose; // verbose stats
+ int iOutFail; // the number of failed output
};
// sequential register correspodence parameters
@@ -129,6 +134,8 @@ struct Cec_ParCor_t_
int nFrames; // the number of time frames
int nPrefix; // the number of time frames in the prefix
int nBTLimit; // conflict limit at a node
+ int nLevelMax; // (scorr only) the max number of levels
+ int nStepsMax; // (scorr only) the max number of induction steps
int fLatchCorr; // consider only latch outputs
int fUseRings; // use rings
int fMakeChoices; // use equilvaences as choices
@@ -138,6 +145,9 @@ struct Cec_ParCor_t_
int fVerboseFlops; // verbose stats
int fVeryVerbose; // verbose stats
int fVerbose; // verbose stats
+ // callback
+ void * pData;
+ void * pFunc;
};
// sequential register correspodence parameters
@@ -153,6 +163,23 @@ struct Cec_ParChc_t_
int fVerbose; // verbose stats
};
+// sequential synthesis parameters
+typedef struct Cec_ParSeq_t_ Cec_ParSeq_t;
+struct Cec_ParSeq_t_
+{
+ int fUseLcorr; // enables latch correspondence
+ int fUseScorr; // enables signal correspondence
+ int nBTLimit; // (scorr/lcorr) conflict limit at a node
+ int nFrames; // (scorr/lcorr) the number of timeframes
+ int nLevelMax; // (scorr only) the max number of levels
+ int fConsts; // (scl only) merging constants
+ int fEquivs; // (scl only) merging equivalences
+ int fUseMiniSat; // enables MiniSat in lcorr/scorr
+ int nMinDomSize; // the size of minimum clock domain
+ int fVeryVerbose; // verbose stats
+ int fVerbose; // verbose stats
+};
+
////////////////////////////////////////////////////////////////////////
/// MACRO DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
@@ -167,6 +194,7 @@ extern int Cec_ManVerifyTwo( Gia_Man_t * p0, Gia_Man_t * p1, int fVerb
/*=== cecChoice.c ==========================================================*/
extern Gia_Man_t * Cec_ManChoiceComputation( Gia_Man_t * pAig, Cec_ParChc_t * pPars );
/*=== cecCorr.c ==========================================================*/
+extern int Cec_ManLSCorrespondenceClasses( Gia_Man_t * pAig, Cec_ParCor_t * pPars );
extern Gia_Man_t * Cec_ManLSCorrespondence( Gia_Man_t * pAig, Cec_ParCor_t * pPars );
/*=== cecCore.c ==========================================================*/
extern void Cec_ManSatSetDefaultParams( Cec_ParSat_t * p );
@@ -180,12 +208,20 @@ extern Gia_Man_t * Cec_ManSatSweeping( Gia_Man_t * pAig, Cec_ParFra_t * pPars
extern Gia_Man_t * Cec_ManSatSolving( Gia_Man_t * pAig, Cec_ParSat_t * pPars );
extern void Cec_ManSimulation( Gia_Man_t * pAig, Cec_ParSim_t * pPars );
/*=== cecSeq.c ==========================================================*/
-extern int Cec_ManSeqResimulateCounter( Gia_Man_t * pAig, Cec_ParSim_t * pPars, Gia_Cex_t * pCex );
+extern int Cec_ManSeqResimulateCounter( Gia_Man_t * pAig, Cec_ParSim_t * pPars, Abc_Cex_t * pCex );
extern int Cec_ManSeqSemiformal( Gia_Man_t * pAig, Cec_ParSmf_t * pPars );
+extern int Cec_ManCheckNonTrivialCands( Gia_Man_t * pAig );
+/*=== cecSynth.c ==========================================================*/
+extern int Cec_SeqReadMinDomSize( Cec_ParSeq_t * p );
+extern int Cec_SeqReadVerbose( Cec_ParSeq_t * p );
+extern void Cec_SeqSynthesisSetDefaultParams( Cec_ParSeq_t * pPars );
+extern int Cec_SequentialSynthesisPart( Gia_Man_t * p, Cec_ParSeq_t * pPars );
+
+
+
+ABC_NAMESPACE_HEADER_END
+
-#ifdef __cplusplus
-}
-#endif
#endif
diff --git a/src/aig/cec/cecCec.c b/src/aig/cec/cecCec.c
index 1efa9235..0859a9ad 100644
--- a/src/aig/cec/cecCec.c
+++ b/src/aig/cec/cecCec.c
@@ -19,8 +19,12 @@
***********************************************************************/
#include "cecInt.h"
+#include "fra.h"
#include "giaAig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -44,8 +48,8 @@ void Cec_ManTransformPattern( Gia_Man_t * p, int iOut, int * pValues )
{
int i;
assert( p->pCexComb == NULL );
- p->pCexComb = (Gia_Cex_t *)ABC_CALLOC( char,
- sizeof(Gia_Cex_t) + sizeof(unsigned) * Gia_BitWordNum(Gia_ManCiNum(p)) );
+ p->pCexComb = (Abc_Cex_t *)ABC_CALLOC( char,
+ sizeof(Abc_Cex_t) + sizeof(unsigned) * Gia_BitWordNum(Gia_ManCiNum(p)) );
p->pCexComb->iPo = iOut;
p->pCexComb->nPis = Gia_ManCiNum(p);
p->pCexComb->nBits = Gia_ManCiNum(p);
@@ -65,45 +69,53 @@ void Cec_ManTransformPattern( Gia_Man_t * p, int iOut, int * pValues )
SeeAlso []
***********************************************************************/
-int Cec_ManVerifyOld( Gia_Man_t * pMiter, int fVerbose )
+int Cec_ManVerifyOld( Gia_Man_t * pMiter, int fVerbose, int * piOutFail )
{
- extern int Fra_FraigCec( Aig_Man_t ** ppAig, int nConfLimit, int fVerbose );
+// extern int Fra_FraigCec( Aig_Man_t ** ppAig, int nConfLimit, int fVerbose );
extern int Ssw_SecCexResimulate( Aig_Man_t * p, int * pModel, int * pnOutputs );
Gia_Man_t * pTemp = Gia_ManTransformMiter( pMiter );
Aig_Man_t * pMiterCec = Gia_ManToAig( pTemp, 0 );
int RetValue, iOut, nOuts, clkTotal = clock();
+ if ( piOutFail )
+ *piOutFail = -1;
Gia_ManStop( pTemp );
// run CEC on this miter
- RetValue = Fra_FraigCec( &pMiterCec, 100000, fVerbose );
+ RetValue = Fra_FraigCec( &pMiterCec, 10000000, fVerbose );
// report the miter
if ( RetValue == 1 )
{
- printf( "Networks are equivalent. " );
-ABC_PRT( "Time", clock() - clkTotal );
+ Abc_Print( 1, "Networks are equivalent. " );
+Abc_PrintTime( 1, "Time", clock() - clkTotal );
}
else if ( RetValue == 0 )
{
- printf( "Networks are NOT EQUIVALENT. " );
-ABC_PRT( "Time", clock() - clkTotal );
+ Abc_Print( 1, "Networks are NOT EQUIVALENT. " );
+Abc_PrintTime( 1, "Time", clock() - clkTotal );
if ( pMiterCec->pData == NULL )
- printf( "Counter-example is not available.\n" );
+ Abc_Print( 1, "Counter-example is not available.\n" );
else
{
- iOut = Ssw_SecCexResimulate( pMiterCec, pMiterCec->pData, &nOuts );
+ iOut = Ssw_SecCexResimulate( pMiterCec, (int *)pMiterCec->pData, &nOuts );
if ( iOut == -1 )
- printf( "Counter-example verification has failed.\n" );
+ Abc_Print( 1, "Counter-example verification has failed.\n" );
else
{
- printf( "Primary output %d has failed in frame %d.\n", iOut );
- printf( "The counter-example detected %d incorrect outputs.\n", nOuts );
+// Aig_Obj_t * pObj = Aig_ManPo(pMiterCec, iOut);
+// Aig_Obj_t * pFan = Aig_ObjFanin0(pObj);
+ Abc_Print( 1, "Primary output %d has failed", iOut );
+ if ( nOuts-1 >= 0 )
+ Abc_Print( 1, ", along with other %d incorrect outputs", nOuts-1 );
+ Abc_Print( 1, ".\n" );
+ if ( piOutFail )
+ *piOutFail = iOut;
}
- Cec_ManTransformPattern( pMiter, iOut, pMiterCec->pData );
+ Cec_ManTransformPattern( pMiter, iOut, (int *)pMiterCec->pData );
}
}
else
{
- printf( "Networks are UNDECIDED. " );
-ABC_PRT( "Time", clock() - clkTotal );
+ Abc_Print( 1, "Networks are UNDECIDED. " );
+Abc_PrintTime( 1, "Time", clock() - clkTotal );
}
fflush( stdout );
Aig_ManStop( pMiterCec );
@@ -121,13 +133,18 @@ ABC_PRT( "Time", clock() - clkTotal );
SeeAlso []
***********************************************************************/
-int Cec_ManVerify( Gia_Man_t * p, Cec_ParCec_t * pPars )
+int Cec_ManVerify( Gia_Man_t * pInit, Cec_ParCec_t * pPars )
{
- int fDumpUndecided = 1;
+ int fDumpUndecided = 0;
Cec_ParFra_t ParsFra, * pParsFra = &ParsFra;
- Gia_Man_t * pNew;
+ Gia_Man_t * p, * pNew;
int RetValue, clk = clock();
double clkTotal = clock();
+ // preprocess
+ p = Gia_ManDup( pInit );
+ Gia_ManEquivFixOutputPairs( p );
+ p = Gia_ManCleanup( pNew = p );
+ Gia_ManStop( pNew );
// sweep for equivalences
Cec_ManFraSetDefaultParams( pParsFra );
pParsFra->nItersMax = 1000;
@@ -137,27 +154,60 @@ int Cec_ManVerify( Gia_Man_t * p, Cec_ParCec_t * pPars )
pParsFra->fCheckMiter = 1;
pParsFra->fDualOut = 1;
pNew = Cec_ManSatSweeping( p, pParsFra );
+ pPars->iOutFail = pParsFra->iOutFail;
+ // update
+ pInit->pCexComb = p->pCexComb; p->pCexComb = NULL;
+ Gia_ManStop( p );
+ p = pInit;
+ // continue
if ( pNew == NULL )
{
- if ( !Gia_ManVerifyCounterExample( p, p->pCexComb, 1 ) )
- printf( "Counter-example simulation has failed.\n" );
- printf( "Networks are NOT EQUIVALENT. " );
- ABC_PRT( "Time", clock() - clk );
- return 0;
+ if ( p->pCexComb != NULL )
+ {
+ if ( p->pCexComb && !Gia_ManVerifyCounterExample( p, p->pCexComb, 1 ) )
+ Abc_Print( 1, "Counter-example simulation has failed.\n" );
+ Abc_Print( 1, "Networks are NOT EQUIVALENT. " );
+ Abc_PrintTime( 1, "Time", clock() - clk );
+ return 0;
+ }
+ p = Gia_ManDup( pInit );
+ Gia_ManEquivFixOutputPairs( p );
+ p = Gia_ManCleanup( pNew = p );
+ Gia_ManStop( pNew );
+ pNew = p;
}
if ( Gia_ManAndNum(pNew) == 0 )
{
- printf( "Networks are equivalent. " );
- ABC_PRT( "Time", clock() - clk );
+ Gia_Obj_t * pObj1, * pObj2;
+ int i;
+ Gia_ManForEachPo( pNew, pObj1, i )
+ {
+ pObj2 = Gia_ManPo( pNew, ++i );
+ if ( Gia_ObjChild0(pObj1) != Gia_ObjChild0(pObj2) )
+ {
+ Abc_Print( 1, "Networks are NOT EQUIVALENT. Outputs %d trivially differ. ", i/2 );
+ Abc_PrintTime( 1, "Time", clock() - clk );
+ Gia_ManStop( pNew );
+ pPars->iOutFail = i/2;
+ return 0;
+ }
+ }
+ Abc_Print( 1, "Networks are equivalent. " );
+ Abc_PrintTime( 1, "Time", clock() - clk );
Gia_ManStop( pNew );
return 1;
}
- printf( "Networks are UNDECIDED after the new CEC engine. " );
- ABC_PRT( "Time", clock() - clk );
+ if ( pPars->fVerbose )
+ {
+ Abc_Print( 1, "Networks are UNDECIDED after the new CEC engine. " );
+ Abc_PrintTime( 1, "Time", clock() - clk );
+ }
if ( fDumpUndecided )
{
+ ABC_FREE( pNew->pReprs );
+ ABC_FREE( pNew->pNexts );
Gia_WriteAiger( pNew, "gia_cec_undecided.aig", 0, 0 );
- printf( "The result is written into file \"%s\".\n", "gia_cec_undecided.aig" );
+ Abc_Print( 1, "The result is written into file \"%s\".\n", "gia_cec_undecided.aig" );
}
if ( pPars->TimeLimit && ((double)clock() - clkTotal)/CLOCKS_PER_SEC >= pPars->TimeLimit )
{
@@ -165,12 +215,13 @@ int Cec_ManVerify( Gia_Man_t * p, Cec_ParCec_t * pPars )
return -1;
}
// call other solver
- printf( "Calling the old CEC engine.\n" );
+ if ( pPars->fVerbose )
+ Abc_Print( 1, "Calling the old CEC engine.\n" );
fflush( stdout );
- RetValue = Cec_ManVerifyOld( pNew, pPars->fVerbose );
+ RetValue = Cec_ManVerifyOld( pNew, pPars->fVerbose, &pPars->iOutFail );
p->pCexComb = pNew->pCexComb; pNew->pCexComb = NULL;
if ( p->pCexComb && !Gia_ManVerifyCounterExample( p, p->pCexComb, 1 ) )
- printf( "Counter-example simulation has failed.\n" );
+ Abc_Print( 1, "Counter-example simulation has failed.\n" );
Gia_ManStop( pNew );
return RetValue;
}
@@ -208,7 +259,7 @@ int Cec_ManVerifyTwo( Gia_Man_t * p0, Gia_Man_t * p1, int fVerbose )
Description [Returns 1 if equivalent, 0 if counter-example, -1 if undecided.
Counter-example is returned in the first manager as pAig0->pSeqModel.
- The format is given in Gia_Cex_t (file "abc\src\aig\gia\gia.h").]
+ The format is given in Abc_Cex_t (file "abc\src\aig\gia\gia.h").]
SideEffects []
@@ -248,7 +299,6 @@ int Cec_ManVerifyTwoAigs( Aig_Man_t * pAig0, Aig_Man_t * pAig1, int fVerbose )
***********************************************************************/
Aig_Man_t * Cec_LatchCorrespondence( Aig_Man_t * pAig, int nConfs, int fUseCSat )
{
- extern int Cec_ManLSCorrespondenceClasses( Gia_Man_t * pAig, Cec_ParCor_t * pPars );
Gia_Man_t * pGia;
Cec_ParCor_t CorPars, * pCorPars = &CorPars;
Cec_ManCorSetDefaultParams( pCorPars );
@@ -275,7 +325,6 @@ Aig_Man_t * Cec_LatchCorrespondence( Aig_Man_t * pAig, int nConfs, int fUseCSat
***********************************************************************/
Aig_Man_t * Cec_SignalCorrespondence( Aig_Man_t * pAig, int nConfs, int fUseCSat )
{
- extern int Cec_ManLSCorrespondenceClasses( Gia_Man_t * pAig, Cec_ParCor_t * pPars );
Gia_Man_t * pGia;
Cec_ParCor_t CorPars, * pCorPars = &CorPars;
Cec_ManCorSetDefaultParams( pCorPars );
@@ -304,6 +353,7 @@ Aig_Man_t * Cec_FraigCombinational( Aig_Man_t * pAig, int nConfs, int fVerbose )
Gia_Man_t * pGia;
Cec_ParFra_t FraPars, * pFraPars = &FraPars;
Cec_ManFraSetDefaultParams( pFraPars );
+ pFraPars->fSatSweeping = 1;
pFraPars->nBTLimit = nConfs;
pFraPars->nItersMax = 20;
pFraPars->fVerbose = fVerbose;
@@ -319,3 +369,5 @@ Aig_Man_t * Cec_FraigCombinational( Aig_Man_t * pAig, int nConfs, int fVerbose )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/cec/cecChoice.c b/src/aig/cec/cecChoice.c
index fc316f46..076b34a2 100644
--- a/src/aig/cec/cecChoice.c
+++ b/src/aig/cec/cecChoice.c
@@ -22,6 +22,9 @@
#include "giaAig.h"
#include "dch.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -175,9 +178,9 @@ Gia_Man_t * Cec_ManCombSpecReduce( Gia_Man_t * p, Vec_Int_t ** pvOutputs, int fR
Gia_ManAppendCo( pNew, iObjNew );
Vec_IntFree( vXorLits );
Gia_ManHashStop( pNew );
-//printf( "Before sweeping = %d\n", Gia_ManAndNum(pNew) );
+//Abc_Print( 1, "Before sweeping = %d\n", Gia_ManAndNum(pNew) );
pNew = Gia_ManCleanup( pTemp = pNew );
-//printf( "After sweeping = %d\n", Gia_ManAndNum(pNew) );
+//Abc_Print( 1, "After sweeping = %d\n", Gia_ManAndNum(pNew) );
Gia_ManStop( pTemp );
return pNew;
}
@@ -219,7 +222,7 @@ int Cec_ManChoiceComputation_int( Gia_Man_t * pAig, Cec_ParChc_t * pPars )
pParsSim->fSeqSimulate = 0;
// create equivalence classes of registers
pSim = Cec_ManSimStart( pAig, pParsSim );
- Cec_ManSimClassesPrepare( pSim );
+ Cec_ManSimClassesPrepare( pSim, -1 );
Cec_ManSimClassesRefine( pSim );
// prepare SAT solving
Cec_ManSatSetDefaultParams( pParsSat );
@@ -227,7 +230,7 @@ int Cec_ManChoiceComputation_int( Gia_Man_t * pAig, Cec_ParChc_t * pPars )
pParsSat->fVerbose = pPars->fVerbose;
if ( pPars->fVerbose )
{
- printf( "Obj = %7d. And = %7d. Conf = %5d. Ring = %d. CSat = %d.\n",
+ Abc_Print( 1, "Obj = %7d. And = %7d. Conf = %5d. Ring = %d. CSat = %d.\n",
Gia_ManObjNum(pAig), Gia_ManAndNum(pAig), pPars->nBTLimit, pPars->fUseRings, pPars->fUseCSat );
Cec_ManRefinedClassPrintStats( pAig, NULL, 0, clock() - clk );
}
@@ -280,97 +283,23 @@ int Cec_ManChoiceComputation_int( Gia_Man_t * pAig, Cec_ParChc_t * pPars )
}
// check the overflow
if ( r == nItersMax )
- printf( "The refinement was not finished. The result may be incorrect.\n" );
+ Abc_Print( 1, "The refinement was not finished. The result may be incorrect.\n" );
Cec_ManSimStop( pSim );
clkTotal = clock() - clkTotal;
// report the results
if ( pPars->fVerbose )
{
- ABC_PRTP( "Srm ", clkSrm, clkTotal );
- ABC_PRTP( "Sat ", clkSat, clkTotal );
- ABC_PRTP( "Sim ", clkSim, clkTotal );
- ABC_PRTP( "Other", clkTotal-clkSat-clkSrm-clkSim, clkTotal );
- ABC_PRT( "TOTAL", clkTotal );
+ Abc_PrintTimeP( 1, "Srm ", clkSrm, clkTotal );
+ Abc_PrintTimeP( 1, "Sat ", clkSat, clkTotal );
+ Abc_PrintTimeP( 1, "Sim ", clkSim, clkTotal );
+ Abc_PrintTimeP( 1, "Other", clkTotal-clkSat-clkSrm-clkSim, clkTotal );
+ Abc_PrintTime( 1, "TOTAL", clkTotal );
}
return 0;
}
/**Function*************************************************************
- Synopsis [Duplicates the AIG in the DFS order.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Gia_ManChoiceMiter_rec( Gia_Man_t * pNew, Gia_Man_t * p, Gia_Obj_t * pObj )
-{
- if ( ~pObj->Value )
- return pObj->Value;
- Gia_ManChoiceMiter_rec( pNew, p, Gia_ObjFanin0(pObj) );
- if ( Gia_ObjIsCo(pObj) )
- return pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
- Gia_ManChoiceMiter_rec( pNew, p, Gia_ObjFanin1(pObj) );
- return pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
-}
-
-/**Function*************************************************************
-
- Synopsis [Derives the miter of several AIGs for choice computation.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Gia_Man_t * Gia_ManChoiceMiter( Vec_Ptr_t * vGias )
-{
- Gia_Man_t * pNew, * pGia, * pGia0;
- int i, k, iNode, nNodes;
- // make sure they have equal parameters
- assert( Vec_PtrSize(vGias) > 0 );
- pGia0 = Vec_PtrEntry( vGias, 0 );
- Vec_PtrForEachEntry( vGias, pGia, i )
- {
- assert( Gia_ManCiNum(pGia) == Gia_ManCiNum(pGia0) );
- assert( Gia_ManCoNum(pGia) == Gia_ManCoNum(pGia0) );
- assert( Gia_ManRegNum(pGia) == Gia_ManRegNum(pGia0) );
- Gia_ManFillValue( pGia );
- Gia_ManConst0(pGia)->Value = 0;
- }
- // start the new manager
- pNew = Gia_ManStart( Vec_PtrSize(vGias) * Gia_ManObjNum(pGia0) );
- pNew->pName = Gia_UtilStrsav( pGia0->pName );
- // create new CIs and assign them to the old manager CIs
- for ( k = 0; k < Gia_ManCiNum(pGia0); k++ )
- {
- iNode = Gia_ManAppendCi(pNew);
- Vec_PtrForEachEntry( vGias, pGia, i )
- Gia_ManCi( pGia, k )->Value = iNode;
- }
- // create internal nodes
- Gia_ManHashAlloc( pNew );
- for ( k = 0; k < Gia_ManCoNum(pGia0); k++ )
- {
- Vec_PtrForEachEntry( vGias, pGia, i )
- Gia_ManChoiceMiter_rec( pNew, pGia, Gia_ManCo( pGia, k ) );
- }
- Gia_ManHashStop( pNew );
- // check the presence of dangling nodes
- nNodes = Gia_ManHasDandling( pNew );
- assert( nNodes == 0 );
- // finalize
-// Gia_ManSetRegNum( pNew, Gia_ManRegNum(pGia0) );
- return pNew;
-}
-
-/**Function*************************************************************
-
Synopsis [Computes choices for the vector of AIGs.]
Description []
@@ -386,6 +315,7 @@ Gia_Man_t * Cec_ManChoiceComputationVec( Gia_Man_t * pGia, int nGias, Cec_ParChc
int RetValue;
// compute equivalences of the miter
// pMiter = Gia_ManChoiceMiter( vGias );
+// Gia_ManSetRegNum( pMiter, 0 );
RetValue = Cec_ManChoiceComputation_int( pGia, pPars );
// derive AIG with choices
pNew = Gia_ManEquivToChoices( pGia, nGias );
@@ -394,7 +324,7 @@ Gia_Man_t * Cec_ManChoiceComputationVec( Gia_Man_t * pGia, int nGias, Cec_ParChc
// report the results
if ( pPars->fVerbose )
{
-// printf( "NBeg = %d. NEnd = %d. (Gain = %6.2f %%). RBeg = %d. REnd = %d. (Gain = %6.2f %%).\n",
+// Abc_Print( 1, "NBeg = %d. NEnd = %d. (Gain = %6.2f %%). RBeg = %d. REnd = %d. (Gain = %6.2f %%).\n",
// Gia_ManAndNum(pAig), Gia_ManAndNum(pNew),
// 100.0*(Gia_ManAndNum(pAig)-Gia_ManAndNum(pNew))/(Gia_ManAndNum(pAig)?Gia_ManAndNum(pAig):1),
// Gia_ManRegNum(pAig), Gia_ManRegNum(pNew),
@@ -416,7 +346,7 @@ Gia_Man_t * Cec_ManChoiceComputationVec( Gia_Man_t * pGia, int nGias, Cec_ParChc
***********************************************************************/
Gia_Man_t * Cec_ManChoiceComputation( Gia_Man_t * pAig, Cec_ParChc_t * pParsChc )
{
- extern Aig_Man_t * Dar_ManChoiceNew( Aig_Man_t * pAig, Dch_Pars_t * pPars );
+// extern Aig_Man_t * Dar_ManChoiceNew( Aig_Man_t * pAig, Dch_Pars_t * pPars );
Dch_Pars_t Pars, * pPars = &Pars;
Aig_Man_t * pMan, * pManNew;
Gia_Man_t * pGia;
@@ -456,7 +386,7 @@ Aig_Man_t * Cec_ComputeChoices( Gia_Man_t * pGia, Dch_Pars_t * pPars )
Cec_ParChc_t ParsChc, * pParsChc = &ParsChc;
Aig_Man_t * pAig;
if ( pPars->fVerbose )
- ABC_PRT( "Synthesis time", pPars->timeSynth );
+ Abc_PrintTime( 1, "Synthesis time", pPars->timeSynth );
Cec_ManChcSetDefaultParams( pParsChc );
pParsChc->nBTLimit = pPars->nBTLimit;
pParsChc->fUseCSat = pPars->fUseCSat;
@@ -475,3 +405,5 @@ Aig_Man_t * Cec_ComputeChoices( Gia_Man_t * pGia, Dch_Pars_t * pPars )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/cec/cecClass.c b/src/aig/cec/cecClass.c
index 749f7f71..95414851 100644
--- a/src/aig/cec/cecClass.c
+++ b/src/aig/cec/cecClass.c
@@ -20,6 +20,9 @@
#include "cecInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -375,7 +378,7 @@ int Cec_ManSimHashKey( unsigned * pSim, int nWords, int nTableSize )
void Cec_ManSimMemRelink( Cec_ManSim_t * p )
{
unsigned * pPlace, Ent;
- pPlace = &p->MemFree;
+ pPlace = (unsigned *)&p->MemFree;
for ( Ent = p->nMems * (p->nWords + 1);
Ent + p->nWords + 1 < (unsigned)p->nWordsAlloc;
Ent += p->nWords + 1 )
@@ -518,14 +521,14 @@ void Cec_ManSimSavePattern( Cec_ManSim_t * p, int iPat )
int i;
assert( p->pCexComb == NULL );
assert( iPat >= 0 && iPat < 32 * p->nWords );
- p->pCexComb = (Gia_Cex_t *)ABC_CALLOC( char,
- sizeof(Gia_Cex_t) + sizeof(unsigned) * Gia_BitWordNum(Gia_ManCiNum(p->pAig)) );
+ p->pCexComb = (Abc_Cex_t *)ABC_CALLOC( char,
+ sizeof(Abc_Cex_t) + sizeof(unsigned) * Gia_BitWordNum(Gia_ManCiNum(p->pAig)) );
p->pCexComb->iPo = p->iOut;
p->pCexComb->nPis = Gia_ManCiNum(p->pAig);
p->pCexComb->nBits = Gia_ManCiNum(p->pAig);
for ( i = 0; i < Gia_ManCiNum(p->pAig); i++ )
{
- pInfo = Vec_PtrEntry( p->vCiSimInfo, i );
+ pInfo = (unsigned *)Vec_PtrEntry( p->vCiSimInfo, i );
if ( Gia_InfoHasBit( pInfo, iPat ) )
Gia_InfoSetBit( p->pCexComb->pData, i );
}
@@ -559,7 +562,7 @@ void Cec_ManSimFindBestPattern( Cec_ManSim_t * p )
assert( p->pBestState->nRegs == Gia_ManRegNum(p->pAig) );
for ( i = 0; i < Gia_ManRegNum(p->pAig); i++ )
{
- pInfo = Vec_PtrEntry( p->vCiSimInfo, Gia_ManPiNum(p->pAig) + i );
+ pInfo = (unsigned *)Vec_PtrEntry( p->vCiSimInfo, Gia_ManPiNum(p->pAig) + i );
if ( Gia_InfoHasBit(p->pBestState->pData, i) != Gia_InfoHasBit(pInfo, iPatBest) )
Gia_InfoXorBit( p->pBestState->pData, i );
}
@@ -591,8 +594,8 @@ int Cec_ManSimAnalyzeOutputs( Cec_ManSim_t * p )
assert( (Gia_ManPoNum(p->pAig) & 1) == 0 );
for ( i = 0; i < Gia_ManPoNum(p->pAig); i++ )
{
- pInfo = Vec_PtrEntry( p->vCoSimInfo, i );
- pInfo2 = Vec_PtrEntry( p->vCoSimInfo, ++i );
+ pInfo = (unsigned *)Vec_PtrEntry( p->vCoSimInfo, i );
+ pInfo2 = (unsigned *)Vec_PtrEntry( p->vCoSimInfo, ++i );
if ( !Cec_ManSimCompareEqual( pInfo, pInfo2, p->nWords ) )
{
if ( p->iOut == -1 )
@@ -614,7 +617,7 @@ int Cec_ManSimAnalyzeOutputs( Cec_ManSim_t * p )
{
for ( i = 0; i < Gia_ManPoNum(p->pAig); i++ )
{
- pInfo = Vec_PtrEntry( p->vCoSimInfo, i );
+ pInfo = (unsigned *)Vec_PtrEntry( p->vCoSimInfo, i );
if ( !Cec_ManSimCompareConst( pInfo, p->nWords ) )
{
if ( p->iOut == -1 )
@@ -679,7 +682,7 @@ int Cec_ManSimSimulateRound( Cec_ManSim_t * p, Vec_Ptr_t * vInfoCis, Vec_Ptr_t *
pRes = Cec_ManSimSimRef( p, i );
if ( vInfoCis )
{
- pRes0 = Vec_PtrEntry( vInfoCis, iCiId++ );
+ pRes0 = (unsigned *)Vec_PtrEntry( vInfoCis, iCiId++ );
for ( w = 1; w <= p->nWords; w++ )
pRes[w] = pRes0[w-1];
}
@@ -697,7 +700,7 @@ int Cec_ManSimSimulateRound( Cec_ManSim_t * p, Vec_Ptr_t * vInfoCis, Vec_Ptr_t *
pRes0 = Cec_ManSimSimDeref( p, Gia_ObjFaninId0(pObj,i) );
if ( vInfoCos )
{
- pRes = Vec_PtrEntry( vInfoCos, iCoId++ );
+ pRes = (unsigned *)Vec_PtrEntry( vInfoCos, iCoId++ );
if ( Gia_ObjFaninC0(pObj) )
for ( w = 1; w <= p->nWords; w++ )
pRes[w-1] = ~pRes0[w];
@@ -712,7 +715,7 @@ int Cec_ManSimSimulateRound( Cec_ManSim_t * p, Vec_Ptr_t * vInfoCis, Vec_Ptr_t *
pRes0 = Cec_ManSimSimDeref( p, Gia_ObjFaninId0(pObj,i) );
pRes1 = Cec_ManSimSimDeref( p, Gia_ObjFaninId1(pObj,i) );
-// printf( "%d,%d ", Gia_ObjValue( Gia_ObjFanin0(pObj) ), Gia_ObjValue( Gia_ObjFanin1(pObj) ) );
+// Abc_Print( 1, "%d,%d ", Gia_ObjValue( Gia_ObjFanin0(pObj) ), Gia_ObjValue( Gia_ObjFanin1(pObj) ) );
if ( Gia_ObjFaninC0(pObj) )
{
@@ -762,7 +765,7 @@ references:
assert( vInfoCos == NULL || iCoId == Gia_ManCoNum(p->pAig) );
assert( p->nMems == 1 );
if ( p->nMems != 1 )
- printf( "Cec_ManSimSimulateRound(): Memory management error!\n" );
+ Abc_Print( 1, "Cec_ManSimSimulateRound(): Memory management error!\n" );
if ( p->pPars->fVeryVerbose )
Gia_ManEquivPrintClasses( p->pAig, 0, Cec_MemUsage(p) );
if ( p->pBestState )
@@ -800,14 +803,14 @@ void Cec_ManSimCreateInfo( Cec_ManSim_t * p, Vec_Ptr_t * vInfoCis, Vec_Ptr_t * v
assert( vInfoCis && vInfoCos );
for ( i = 0; i < Gia_ManPiNum(p->pAig); i++ )
{
- pRes0 = Vec_PtrEntry( vInfoCis, i );
+ pRes0 = (unsigned *)Vec_PtrEntry( vInfoCis, i );
for ( w = 0; w < p->nWords; w++ )
pRes0[w] = Gia_ManRandom( 0 );
}
for ( i = 0; i < Gia_ManRegNum(p->pAig); i++ )
{
- pRes0 = Vec_PtrEntry( vInfoCis, Gia_ManPiNum(p->pAig) + i );
- pRes1 = Vec_PtrEntry( vInfoCos, Gia_ManPoNum(p->pAig) + i );
+ pRes0 = (unsigned *)Vec_PtrEntry( vInfoCis, Gia_ManPiNum(p->pAig) + i );
+ pRes1 = (unsigned *)Vec_PtrEntry( vInfoCos, Gia_ManPoNum(p->pAig) + i );
for ( w = 0; w < p->nWords; w++ )
pRes0[w] = pRes1[w];
}
@@ -816,7 +819,7 @@ void Cec_ManSimCreateInfo( Cec_ManSim_t * p, Vec_Ptr_t * vInfoCis, Vec_Ptr_t * v
{
for ( i = 0; i < Gia_ManCiNum(p->pAig); i++ )
{
- pRes0 = Vec_PtrEntry( vInfoCis, i );
+ pRes0 = (unsigned *)Vec_PtrEntry( vInfoCis, i );
for ( w = 0; w < p->nWords; w++ )
pRes0[w] = Gia_ManRandom( 0 );
}
@@ -834,7 +837,7 @@ void Cec_ManSimCreateInfo( Cec_ManSim_t * p, Vec_Ptr_t * vInfoCis, Vec_Ptr_t * v
SeeAlso []
***********************************************************************/
-int Cec_ManSimClassesPrepare( Cec_ManSim_t * p )
+int Cec_ManSimClassesPrepare( Cec_ManSim_t * p, int LevelMax )
{
Gia_Obj_t * pObj;
int i;
@@ -848,9 +851,16 @@ int Cec_ManSimClassesPrepare( Cec_ManSim_t * p )
if ( p->pPars->fLatchCorr )
Gia_ManForEachObj( p->pAig, pObj, i )
Gia_ObjSetRepr( p->pAig, i, GIA_VOID );
- else
+ else if ( LevelMax == -1 )
Gia_ManForEachObj( p->pAig, pObj, i )
Gia_ObjSetRepr( p->pAig, i, Gia_ObjIsAnd(pObj) ? 0 : GIA_VOID );
+ else
+ {
+ Gia_ManLevelNum( p->pAig );
+ Gia_ManForEachObj( p->pAig, pObj, i )
+ Gia_ObjSetRepr( p->pAig, i, (Gia_ObjIsAnd(pObj) && Gia_ObjLevel(p->pAig,pObj) <= LevelMax) ? 0 : GIA_VOID );
+ Vec_IntFreeP( &p->pAig->vLevels );
+ }
// if sequential simulation, set starting representative of ROs to be constant 0
if ( p->pPars->fSeqSimulate )
Gia_ManForEachRo( p->pAig, pObj, i )
@@ -906,3 +916,5 @@ int Cec_ManSimClassesRefine( Cec_ManSim_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/cec/cecCore.c b/src/aig/cec/cecCore.c
index 10c145ec..5e71dbff 100644
--- a/src/aig/cec/cecCore.c
+++ b/src/aig/cec/cecCore.c
@@ -20,6 +20,9 @@
#include "cecInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -133,8 +136,10 @@ void Cec_ManFraSetDefaultParams( Cec_ParFra_t * p )
// p->fFirstStop = 0; // stop on the first sat output
p->fDualOut = 0; // miter with separate outputs
p->fColorDiff = 0; // miter with separate outputs
+ p->fSatSweeping = 0; // enable SAT sweeping
p->fVeryVerbose = 0; // verbose stats
p->fVerbose = 0; // verbose stats
+ p->iOutFail = -1; // the failed output
}
/**Function*************************************************************
@@ -158,6 +163,7 @@ void Cec_ManCecSetDefaultParams( Cec_ParCec_t * p )
p->fRewriting = 0; // enables AIG rewriting
p->fVeryVerbose = 0; // verbose stats
p->fVerbose = 0; // verbose stats
+ p->iOutFail = -1; // the number of failed output
}
/**Function*************************************************************
@@ -178,6 +184,8 @@ void Cec_ManCorSetDefaultParams( Cec_ParCor_t * p )
p->nRounds = 15; // the number of simulation rounds
p->nFrames = 1; // the number of time frames
p->nBTLimit = 100; // conflict limit at a node
+ p->nLevelMax = -1; // (scorr only) the max number of levels
+ p->nStepsMax = -1; // (scorr only) the max number of induction steps
p->fLatchCorr = 0; // consider only latch outputs
p->fUseRings = 1; // combine classes into rings
p->fUseCSat = 1; // use circuit-based solver
@@ -249,12 +257,12 @@ int Cec_ManSimulationOne( Gia_Man_t * pAig, Cec_ParSim_t * pPars )
Cec_ManSim_t * pSim;
int RetValue = 0, clkTotal = clock();
pSim = Cec_ManSimStart( pAig, pPars );
- if ( (pAig->pReprs == NULL && (RetValue = Cec_ManSimClassesPrepare( pSim ))) ||
+ if ( (pAig->pReprs == NULL && (RetValue = Cec_ManSimClassesPrepare( pSim, -1 ))) ||
(RetValue == 0 && (RetValue = Cec_ManSimClassesRefine( pSim ))) )
- printf( "The number of failed outputs of the miter = %6d. (Words = %4d. Frames = %4d.)\n",
+ Abc_Print( 1, "The number of failed outputs of the miter = %6d. (Words = %4d. Frames = %4d.)\n",
pSim->nOuts, pPars->nWords, pPars->nFrames );
if ( pPars->fVerbose )
- ABC_PRT( "Time", clock() - clkTotal );
+ Abc_PrintTime( 1, "Time", clock() - clkTotal );
Cec_ManSimStop( pSim );
return RetValue;
}
@@ -275,7 +283,7 @@ void Cec_ManSimulation( Gia_Man_t * pAig, Cec_ParSim_t * pPars )
int r, nLitsOld, nLitsNew, nCountNoRef = 0, fStop = 0;
Gia_ManRandom( 1 );
if ( pPars->fSeqSimulate )
- printf( "Performing rounds of random simulation of %d frames with %d words.\n",
+ Abc_Print( 1, "Performing rounds of random simulation of %d frames with %d words.\n",
pPars->nRounds, pPars->nFrames, pPars->nWords );
nLitsOld = Gia_ManEquivCountLits( pAig );
for ( r = 0; r < pPars->nRounds; r++ )
@@ -301,14 +309,14 @@ void Cec_ManSimulation( Gia_Man_t * pAig, Cec_ParSim_t * pPars )
}
// if ( pPars->fVerbose )
if ( r == pPars->nRounds || fStop )
- printf( "Random simulation is stopped after %d rounds.\n", r );
+ Abc_Print( 1, "Random simulation is stopped after %d rounds.\n", r );
else
- printf( "Random simulation saturated after %d rounds.\n", r );
+ Abc_Print( 1, "Random simulation saturated after %d rounds.\n", r );
if ( pPars->fCheckMiter )
{
int nNonConsts = Cec_ManCountNonConstOutputs( pAig );
if ( nNonConsts )
- printf( "The number of POs that are not const-0 candidates = %d.\n", nNonConsts );
+ Abc_Print( 1, "The number of POs that are not const-0 candidates = %d.\n", nNonConsts );
}
}
@@ -366,7 +374,7 @@ Gia_Man_t * Cec_ManSatSweeping( Gia_Man_t * pAig, Cec_ParFra_t * pPars )
clk = clock();
if ( p->pAig->pReprs == NULL )
{
- if ( Cec_ManSimClassesPrepare(pSim) || Cec_ManSimClassesRefine(pSim) )
+ if ( Cec_ManSimClassesPrepare(pSim, -1) || Cec_ManSimClassesRefine(pSim) )
{
Gia_ManStop( p->pAig );
p->pAig = NULL;
@@ -395,19 +403,19 @@ p->timeSim += clock() - clk;
{
Gia_ManStop( pSrm );
if ( p->pPars->fVerbose )
- printf( "Considered all available candidate equivalences.\n" );
+ Abc_Print( 1, "Considered all available candidate equivalences.\n" );
if ( pPars->fDualOut && Gia_ManAndNum(p->pAig) > 0 )
{
if ( pPars->fColorDiff )
{
if ( p->pPars->fVerbose )
- printf( "Switching into reduced mode.\n" );
+ Abc_Print( 1, "Switching into reduced mode.\n" );
pPars->fColorDiff = 0;
}
else
{
if ( p->pPars->fVerbose )
- printf( "Switching into normal mode.\n" );
+ Abc_Print( 1, "Switching into normal mode.\n" );
pPars->fDualOut = 0;
}
continue;
@@ -433,14 +441,14 @@ p->timeSat += clock() - clk;
break;
if ( p->pPars->fVerbose )
{
- printf( "%3d : P =%7d. D =%7d. F =%6d. M = %7d. And =%8d. ",
+ Abc_Print( 1, "%3d : P =%7d. D =%7d. F =%6d. M = %7d. And =%8d. ",
i, p->nAllProved, p->nAllDisproved, p->nAllFailed, nMatches, Gia_ManAndNum(p->pAig) );
- ABC_PRT( "Time", clock() - clk2 );
+ Abc_PrintTime( 1, "Time", clock() - clk2 );
}
if ( Gia_ManAndNum(p->pAig) == 0 )
{
if ( p->pPars->fVerbose )
- printf( "Network after reduction is empty.\n" );
+ Abc_Print( 1, "Network after reduction is empty.\n" );
break;
}
// check resource limits
@@ -454,54 +462,63 @@ p->timeSat += clock() - clk;
{
if ( pParsSat->nBTLimit >= 10001 )
break;
+ if ( pPars->fSatSweeping )
+ {
+ if ( p->pPars->fVerbose )
+ Abc_Print( 1, "Exceeded the limit on the number of conflicts (%d).\n", pParsSat->nBTLimit );
+ break;
+ }
pParsSat->nBTLimit *= 10;
if ( p->pPars->fVerbose )
{
if ( p->pPars->fVerbose )
- printf( "Increasing conflict limit to %d.\n", pParsSat->nBTLimit );
+ Abc_Print( 1, "Increasing conflict limit to %d.\n", pParsSat->nBTLimit );
if ( fOutputResult )
{
Gia_WriteAiger( p->pAig, "gia_cec_temp.aig", 0, 0 );
- printf("The result is written into file \"%s\".\n", "gia_cec_temp.aig" );
+ Abc_Print( 1,"The result is written into file \"%s\".\n", "gia_cec_temp.aig" );
}
}
}
if ( pPars->fDualOut && pPars->fColorDiff && (Gia_ManAndNum(p->pAig) < 100000 || p->nAllProved + p->nAllDisproved < 10) )
{
if ( p->pPars->fVerbose )
- printf( "Switching into reduced mode.\n" );
+ Abc_Print( 1, "Switching into reduced mode.\n" );
pPars->fColorDiff = 0;
}
// if ( pPars->fDualOut && Gia_ManAndNum(p->pAig) < 20000 )
else if ( pPars->fDualOut && (Gia_ManAndNum(p->pAig) < 20000 || p->nAllProved + p->nAllDisproved < 10) )
{
if ( p->pPars->fVerbose )
- printf( "Switching into normal mode.\n" );
+ Abc_Print( 1, "Switching into normal mode.\n" );
pPars->fColorDiff = 0;
pPars->fDualOut = 0;
}
}
finalize:
- if ( p->pPars->fVerbose )
+ if ( p->pPars->fVerbose && p->pAig )
{
- printf( "NBeg = %d. NEnd = %d. (Gain = %6.2f %%). RBeg = %d. REnd = %d. (Gain = %6.2f %%).\n",
+ Abc_Print( 1, "NBeg = %d. NEnd = %d. (Gain = %6.2f %%). RBeg = %d. REnd = %d. (Gain = %6.2f %%).\n",
Gia_ManAndNum(pAig), Gia_ManAndNum(p->pAig),
100.0*(Gia_ManAndNum(pAig)-Gia_ManAndNum(p->pAig))/(Gia_ManAndNum(pAig)?Gia_ManAndNum(pAig):1),
Gia_ManRegNum(pAig), Gia_ManRegNum(p->pAig),
100.0*(Gia_ManRegNum(pAig)-Gia_ManRegNum(p->pAig))/(Gia_ManRegNum(pAig)?Gia_ManRegNum(pAig):1) );
- ABC_PRTP( "Sim ", p->timeSim, clock() - (int)clkTotal );
- ABC_PRTP( "Sat ", p->timeSat-pPat->timeTotalSave, clock() - (int)clkTotal );
- ABC_PRTP( "Pat ", p->timePat+pPat->timeTotalSave, clock() - (int)clkTotal );
- ABC_PRT( "Time", clock() - clkTotal );
+ Abc_PrintTimeP( 1, "Sim ", p->timeSim, clock() - (int)clkTotal );
+ Abc_PrintTimeP( 1, "Sat ", p->timeSat-pPat->timeTotalSave, clock() - (int)clkTotal );
+ Abc_PrintTimeP( 1, "Pat ", p->timePat+pPat->timeTotalSave, clock() - (int)clkTotal );
+ Abc_PrintTime( 1, "Time", (int)(clock() - clkTotal) );
}
pTemp = p->pAig; p->pAig = NULL;
if ( pTemp == NULL && pSim->iOut >= 0 )
- printf( "Disproved at least one output of the miter (zero-based number %d).\n", pSim->iOut );
+ {
+ Abc_Print( 1, "Disproved at least one output of the miter (zero-based number %d).\n", pSim->iOut );
+ pPars->iOutFail = pSim->iOut;
+ }
else if ( pSim->pCexes )
- printf( "Disproved %d outputs of the miter.\n", pSim->nOuts );
+ Abc_Print( 1, "Disproved %d outputs of the miter.\n", pSim->nOuts );
if ( fTimeOut )
- printf( "Timed out after %d seconds.\n", (int)((double)clock() - clkTotal)/CLOCKS_PER_SEC );
+ Abc_Print( 1, "Timed out after %d seconds.\n", (int)((double)clock() - clkTotal)/CLOCKS_PER_SEC );
pAig->pCexComb = pSim->pCexComb; pSim->pCexComb = NULL;
Cec_ManSimStop( pSim );
@@ -516,3 +533,5 @@ finalize:
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/cec/cecCorr.c b/src/aig/cec/cecCorr.c
index 52d2b80e..565ca47e 100644
--- a/src/aig/cec/cecCorr.c
+++ b/src/aig/cec/cecCorr.c
@@ -20,6 +20,9 @@
#include "cecInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -197,9 +200,9 @@ Gia_Man_t * Gia_ManCorrSpecReduce( Gia_Man_t * p, int nFrames, int fScorr, Vec_I
Vec_IntFree( vXorLits );
Gia_ManHashStop( pNew );
ABC_FREE( p->pCopies );
-//printf( "Before sweeping = %d\n", Gia_ManAndNum(pNew) );
+//Abc_Print( 1, "Before sweeping = %d\n", Gia_ManAndNum(pNew) );
pNew = Gia_ManCleanup( pTemp = pNew );
-//printf( "After sweeping = %d\n", Gia_ManAndNum(pNew) );
+//Abc_Print( 1, "After sweeping = %d\n", Gia_ManAndNum(pNew) );
Gia_ManStop( pTemp );
return pNew;
}
@@ -266,9 +269,9 @@ Gia_Man_t * Gia_ManCorrSpecReduceInit( Gia_Man_t * p, int nFrames, int nPrefix,
Vec_IntFree( vXorLits );
Gia_ManHashStop( pNew );
ABC_FREE( p->pCopies );
-//printf( "Before sweeping = %d\n", Gia_ManAndNum(pNew) );
+//Abc_Print( 1, "Before sweeping = %d\n", Gia_ManAndNum(pNew) );
pNew = Gia_ManCleanup( pTemp = pNew );
-//printf( "After sweeping = %d\n", Gia_ManAndNum(pNew) );
+//Abc_Print( 1, "After sweeping = %d\n", Gia_ManAndNum(pNew) );
Gia_ManStop( pTemp );
return pNew;
}
@@ -292,13 +295,13 @@ void Cec_ManStartSimInfo( Vec_Ptr_t * vInfo, int nFlops )
assert( nFlops <= Vec_PtrSize(vInfo) );
for ( k = 0; k < nFlops; k++ )
{
- pInfo = Vec_PtrEntry( vInfo, k );
+ pInfo = (unsigned *)Vec_PtrEntry( vInfo, k );
for ( w = 0; w < nWords; w++ )
pInfo[w] = 0;
}
for ( k = nFlops; k < Vec_PtrSize(vInfo); k++ )
{
- pInfo = Vec_PtrEntry( vInfo, k );
+ pInfo = (unsigned *)Vec_PtrEntry( vInfo, k );
for ( w = 0; w < nWords; w++ )
pInfo[w] = Gia_ManRandom( 0 );
}
@@ -327,20 +330,20 @@ void Gia_ManCorrRemapSimInfo( Gia_Man_t * p, Vec_Ptr_t * vInfo )
pRepr = Gia_ObjReprObj( p, Gia_ObjId(p,pObj) );
if ( pRepr == NULL || Gia_ObjFailed(p, Gia_ObjId(p,pObj)) )
continue;
- pInfoObj = Vec_PtrEntry( vInfo, i );
+ pInfoObj = (unsigned *)Vec_PtrEntry( vInfo, i );
for ( w = 0; w < nWords; w++ )
assert( pInfoObj[w] == 0 );
// skip ROs with constant representatives
if ( Gia_ObjIsConst0(pRepr) )
continue;
assert( Gia_ObjIsRo(p, pRepr) );
-// printf( "%d -> %d ", i, Gia_ObjId(p, pRepr) );
+// Abc_Print( 1, "%d -> %d ", i, Gia_ObjId(p, pRepr) );
// transfer info from the representative
- pInfoRepr = Vec_PtrEntry( vInfo, Gia_ObjCioId(pRepr) - Gia_ManPiNum(p) );
+ pInfoRepr = (unsigned *)Vec_PtrEntry( vInfo, Gia_ObjCioId(pRepr) - Gia_ManPiNum(p) );
for ( w = 0; w < nWords; w++ )
pInfoObj[w] = pInfoRepr[w];
}
-// printf( "\n" );
+// Abc_Print( 1, "\n" );
}
/**Function*************************************************************
@@ -368,7 +371,7 @@ Vec_Int_t * Gia_ManCorrCreateRemapping( Gia_Man_t * p )
// if ( pRepr == NULL || Gia_ObjIsConst0(pRepr) || Gia_ObjIsFailedPair(p, Gia_ObjId(p, pRepr), Gia_ObjId(p, pObj)) )
continue;
assert( Gia_ObjIsRo(p, pRepr) );
-// printf( "%d -> %d ", Gia_ObjId(p,pObj), Gia_ObjId(p, pRepr) );
+// Abc_Print( 1, "%d -> %d ", Gia_ObjId(p,pObj), Gia_ObjId(p, pRepr) );
// remember the pair
Vec_IntPush( vPairs, Gia_ObjCioId(pRepr) - Gia_ManPiNum(p) );
Vec_IntPush( vPairs, i );
@@ -395,8 +398,8 @@ void Gia_ManCorrPerformRemapping( Vec_Int_t * vPairs, Vec_Ptr_t * vInfo )
Vec_IntForEachEntry( vPairs, iRepr, i )
{
iObj = Vec_IntEntry( vPairs, ++i );
- pInfoObj = Vec_PtrEntry( vInfo, iObj );
- pInfoRepr = Vec_PtrEntry( vInfo, iRepr );
+ pInfoObj = (unsigned *)Vec_PtrEntry( vInfo, iObj );
+ pInfoRepr = (unsigned *)Vec_PtrEntry( vInfo, iRepr );
for ( w = 0; w < nWords; w++ )
{
assert( pInfoObj[w] == 0 );
@@ -422,16 +425,16 @@ int Cec_ManLoadCounterExamplesTry( Vec_Ptr_t * vInfo, Vec_Ptr_t * vPres, int iBi
int i;
for ( i = 0; i < nLits; i++ )
{
- pInfo = Vec_PtrEntry(vInfo, Gia_Lit2Var(pLits[i]));
- pPres = Vec_PtrEntry(vPres, Gia_Lit2Var(pLits[i]));
+ pInfo = (unsigned *)Vec_PtrEntry(vInfo, Gia_Lit2Var(pLits[i]));
+ pPres = (unsigned *)Vec_PtrEntry(vPres, Gia_Lit2Var(pLits[i]));
if ( Gia_InfoHasBit( pPres, iBit ) &&
Gia_InfoHasBit( pInfo, iBit ) == Gia_LitIsCompl(pLits[i]) )
return 0;
}
for ( i = 0; i < nLits; i++ )
{
- pInfo = Vec_PtrEntry(vInfo, Gia_Lit2Var(pLits[i]));
- pPres = Vec_PtrEntry(vPres, Gia_Lit2Var(pLits[i]));
+ pInfo = (unsigned *)Vec_PtrEntry(vInfo, Gia_Lit2Var(pLits[i]));
+ pPres = (unsigned *)Vec_PtrEntry(vPres, Gia_Lit2Var(pLits[i]));
Gia_InfoSetBit( pPres, iBit );
if ( Gia_InfoHasBit( pInfo, iBit ) == Gia_LitIsCompl(pLits[i]) )
Gia_InfoXorBit( pInfo, iBit );
@@ -506,7 +509,7 @@ int Cec_ManLoadCounterExamples2( Vec_Ptr_t * vInfo, Vec_Int_t * vCexStore, int i
// skip the output number
// iStart++;
Out = Vec_IntEntry( vCexStore, iStart++ );
-// printf( "iBit = %d. Out = %d.\n", iBit, Out );
+// Abc_Print( 1, "iBit = %d. Out = %d.\n", iBit, Out );
// get the number of items
nLits = Vec_IntEntry( vCexStore, iStart++ );
if ( nLits <= 0 )
@@ -515,14 +518,14 @@ int Cec_ManLoadCounterExamples2( Vec_Ptr_t * vInfo, Vec_Int_t * vCexStore, int i
for ( k = 0; k < nLits; k++ )
{
iLit = Vec_IntEntry( vCexStore, iStart++ );
- pInfo = Vec_PtrEntry( vInfo, Gia_Lit2Var(iLit) );
+ pInfo = (unsigned *)Vec_PtrEntry( vInfo, Gia_Lit2Var(iLit) );
if ( Gia_InfoHasBit( pInfo, iBit ) == Gia_LitIsCompl(iLit) )
Gia_InfoXorBit( pInfo, iBit );
}
if ( ++iBit == nBits )
break;
}
-// printf( "added %d bits\n", iBit-1 );
+// Abc_Print( 1, "added %d bits\n", iBit-1 );
return iStart;
}
@@ -620,7 +623,7 @@ int Gia_ManCheckRefinements( Gia_Man_t * p, Vec_Str_t * vStatus, Vec_Int_t * vOu
if ( Gia_ObjHasSameRepr(p, iRepr, iObj) )
Counter++;
// if ( Gia_ObjHasSameRepr(p, iRepr, iObj) )
-// printf( "Gia_ManCheckRefinements(): Disproved equivalence (%d,%d) is not refined!\n", iRepr, iObj );
+// Abc_Print( 1, "Gia_ManCheckRefinements(): Disproved equivalence (%d,%d) is not refined!\n", iRepr, iObj );
// if ( Gia_ObjHasSameRepr(p, iRepr, iObj) )
// Cec_ManSimClassRemoveOne( pSim, iObj );
continue;
@@ -628,7 +631,7 @@ int Gia_ManCheckRefinements( Gia_Man_t * p, Vec_Str_t * vStatus, Vec_Int_t * vOu
if ( status == -1 )
{
// if ( !Gia_ObjFailed( p, iObj ) )
-// printf( "Gia_ManCheckRefinements(): Failed equivalence is not marked as failed!\n" );
+// Abc_Print( 1, "Gia_ManCheckRefinements(): Failed equivalence is not marked as failed!\n" );
// Gia_ObjSetFailed( p, iRepr );
// Gia_ObjSetFailed( p, iObj );
// if ( fRings )
@@ -638,7 +641,7 @@ int Gia_ManCheckRefinements( Gia_Man_t * p, Vec_Str_t * vStatus, Vec_Int_t * vOu
}
}
// if ( Counter )
-// printf( "Gia_ManCheckRefinements(): Could not refine %d nodes.\n", Counter );
+// Abc_Print( 1, "Gia_ManCheckRefinements(): Could not refine %d nodes.\n", Counter );
return 1;
}
@@ -732,10 +735,10 @@ void Cec_ManRefinedClassPrintStats( Gia_Man_t * p, Vec_Str_t * vStatus, int iIte
CounterX -= Gia_ManCoNum(p);
nLits = Gia_ManCiNum(p) + Gia_ManAndNum(p) - Counter - CounterX;
if ( iIter == -1 )
- printf( "BMC : " );
+ Abc_Print( 1, "BMC : " );
else
- printf( "%3d : ", iIter );
- printf( "c =%8d cl =%7d lit =%8d ", Counter0, Counter, nLits );
+ Abc_Print( 1, "%3d : ", iIter );
+ Abc_Print( 1, "c =%8d cl =%7d lit =%8d ", Counter0, Counter, nLits );
if ( vStatus )
Vec_StrForEachEntry( vStatus, Entry, i )
{
@@ -746,8 +749,8 @@ void Cec_ManRefinedClassPrintStats( Gia_Man_t * p, Vec_Str_t * vStatus, int iIte
else if ( Entry == -1 )
nFail++;
}
- printf( "p =%6d d =%6d f =%6d ", nProve, nDispr, nFail );
- ABC_PRT( "T", Time );
+ Abc_Print( 1, "p =%6d d =%6d f =%6d ", nProve, nDispr, nFail );
+ Abc_PrintTime( 1, "T", Time );
}
/**Function*************************************************************
@@ -833,7 +836,7 @@ int Cec_ManLSCorrespondenceClasses( Gia_Man_t * pAig, Cec_ParCor_t * pPars )
{
int nIterMax = 100000;
int nAddFrames = 1; // additional timeframes to simulate
- int fRunBmcFirst = 0;
+ int fRunBmcFirst = 1;
Vec_Str_t * vStatus;
Vec_Int_t * vOutputs;
Vec_Int_t * vCexStore;
@@ -846,7 +849,7 @@ int Cec_ManLSCorrespondenceClasses( Gia_Man_t * pAig, Cec_ParCor_t * pPars )
int clk2, clk = clock();
if ( Gia_ManRegNum(pAig) == 0 )
{
- printf( "Cec_ManLatchCorrespondence(): Not a sequential AIG.\n" );
+ Abc_Print( 1, "Cec_ManLatchCorrespondence(): Not a sequential AIG.\n" );
return 0;
}
Gia_ManRandom( 1 );
@@ -861,7 +864,7 @@ int Cec_ManLSCorrespondenceClasses( Gia_Man_t * pAig, Cec_ParCor_t * pPars )
pSim = Cec_ManSimStart( pAig, pParsSim );
if ( pAig->pReprs == NULL )
{
- Cec_ManSimClassesPrepare( pSim );
+ Cec_ManSimClassesPrepare( pSim, pPars->nLevelMax );
Cec_ManSimClassesRefine( pSim );
}
// prepare SAT solving
@@ -870,7 +873,7 @@ int Cec_ManLSCorrespondenceClasses( Gia_Man_t * pAig, Cec_ParCor_t * pPars )
pParsSat->fVerbose = pPars->fVerbose;
if ( pPars->fVerbose )
{
- printf( "Obj = %7d. And = %7d. Conf = %5d. Fr = %d. Lcorr = %d. Ring = %d. CSat = %d.\n",
+ Abc_Print( 1, "Obj = %7d. And = %7d. Conf = %5d. Fr = %d. Lcorr = %d. Ring = %d. CSat = %d.\n",
Gia_ManObjNum(pAig), Gia_ManAndNum(pAig),
pPars->nBTLimit, pPars->nFrames, pPars->fLatchCorr, pPars->fUseRings, pPars->fUseCSat );
Cec_ManRefinedClassPrintStats( pAig, NULL, 0, clock() - clk );
@@ -878,9 +881,26 @@ int Cec_ManLSCorrespondenceClasses( Gia_Man_t * pAig, Cec_ParCor_t * pPars )
// check the base case
if ( fRunBmcFirst && (!pPars->fLatchCorr || pPars->nFrames > 1) )
Cec_ManLSCorrespondenceBmc( pAig, pPars, 0 );
+ if ( pPars->pFunc )
+ {
+ ((int (*)(void *))pPars->pFunc)( pPars->pData );
+ ((int (*)(void *))pPars->pFunc)( pPars->pData );
+ }
+ if ( pPars->nStepsMax == 0 )
+ {
+ Abc_Print( 1, "Stopped signal correspondence after BMC.\n" );
+ Cec_ManSimStop( pSim );
+ return 1;
+ }
// perform refinement of equivalence classes
for ( r = 0; r < nIterMax; r++ )
{
+ if ( pPars->nStepsMax == r )
+ {
+ Cec_ManSimStop( pSim );
+ Abc_Print( 1, "Stopped signal correspondence after %d refiment iterations.\n", r );
+ return 1;
+ }
clk = clock();
// perform speculative reduction
clk2 = clock();
@@ -920,12 +940,14 @@ int Cec_ManLSCorrespondenceClasses( Gia_Man_t * pAig, Cec_ParCor_t * pPars )
Vec_StrFree( vStatus );
Vec_IntFree( vOutputs );
//Gia_ManEquivPrintClasses( pAig, 1, 0 );
+ if ( pPars->pFunc )
+ ((int (*)(void *))pPars->pFunc)( pPars->pData );
}
if ( pPars->fVerbose )
Cec_ManRefinedClassPrintStats( pAig, NULL, r+1, clock() - clk );
// check the overflow
if ( r == nIterMax )
- printf( "The refinement was not finished. The result may be incorrect.\n" );
+ Abc_Print( 1, "The refinement was not finished. The result may be incorrect.\n" );
Cec_ManSimStop( pSim );
// check the base case
if ( !fRunBmcFirst && (!pPars->fLatchCorr || pPars->nFrames > 1) )
@@ -938,9 +960,9 @@ int Cec_ManLSCorrespondenceClasses( Gia_Man_t * pAig, Cec_ParCor_t * pPars )
ABC_PRTP( "Sat ", clkSat, clkTotal );
ABC_PRTP( "Sim ", clkSim, clkTotal );
ABC_PRTP( "Other", clkTotal-clkSat-clkSrm-clkSim, clkTotal );
- ABC_PRT( "TOTAL", clkTotal );
+ Abc_PrintTime( 1, "TOTAL", clkTotal );
}
- return 0;
+ return 1;
}
/**Function*************************************************************
@@ -960,7 +982,7 @@ unsigned * Cec_ManComputeInitState( Gia_Man_t * pAig, int nFrames )
unsigned * pInitState;
int i, f;
Gia_ManRandom( 1 );
-// printf( "Simulating %d timeframes.\n", nFrames );
+// Abc_Print( 1, "Simulating %d timeframes.\n", nFrames );
Gia_ManForEachRo( pAig, pObj, i )
pObj->fMark1 = 0;
for ( f = 0; f < nFrames; f++ )
@@ -981,9 +1003,9 @@ unsigned * Cec_ManComputeInitState( Gia_Man_t * pAig, int nFrames )
{
if ( pObj->fMark1 )
Gia_InfoSetBit( pInitState, i );
-// printf( "%d", pObj->fMark1 );
+// Abc_Print( 1, "%d", pObj->fMark1 );
}
-// printf( "\n" );
+// Abc_Print( 1, "\n" );
Gia_ManCleanMark1( pAig );
return pInitState;
}
@@ -1007,15 +1029,15 @@ void Cec_ManPrintFlopEquivs( Gia_Man_t * p )
Gia_ManForEachRo( p, pObj, i )
{
if ( Gia_ObjIsConst(p, Gia_ObjId(p, pObj)) )
- printf( "Original flop %s is proved equivalent to constant.\n", Vec_PtrEntry(p->vNamesIn, Gia_ObjCioId(pObj)) );
+ Abc_Print( 1, "Original flop %s is proved equivalent to constant.\n", Vec_PtrEntry(p->vNamesIn, Gia_ObjCioId(pObj)) );
else if ( (pRepr = Gia_ObjReprObj(p, Gia_ObjId(p, pObj))) )
{
if ( Gia_ObjIsCi(pRepr) )
- printf( "Original flop %s is proved equivalent to flop %s.\n",
+ Abc_Print( 1, "Original flop %s is proved equivalent to flop %s.\n",
Vec_PtrEntry( p->vNamesIn, Gia_ObjCioId(pObj) ),
Vec_PtrEntry( p->vNamesIn, Gia_ObjCioId(pRepr) ) );
else
- printf( "Original flop %s is proved equivalent to internal node %d.\n",
+ Abc_Print( 1, "Original flop %s is proved equivalent to internal node %d.\n",
Vec_PtrEntry( p->vNamesIn, Gia_ObjCioId(pObj) ), Gia_ObjId(p, pRepr) );
}
}
@@ -1046,7 +1068,7 @@ Gia_Man_t * Cec_ManLSCorrespondence( Gia_Man_t * pAig, Cec_ParCor_t * pPars )
{
// compute the cycles AIG
pInitState = Cec_ManComputeInitState( pAig, pPars->nPrefix );
- pTemp = Gia_ManDupFlip( pAig, pInitState );
+ pTemp = Gia_ManDupFlip( pAig, (int *)pInitState );
ABC_FREE( pInitState );
// compute classes of this AIG
RetValue = Cec_ManLSCorrespondenceClasses( pTemp, pPars );
@@ -1086,19 +1108,19 @@ Gia_Man_t * Cec_ManLSCorrespondence( Gia_Man_t * pAig, Cec_ParCor_t * pPars )
// report the results
if ( pPars->fVerbose )
{
- printf( "NBeg = %d. NEnd = %d. (Gain = %6.2f %%). RBeg = %d. REnd = %d. (Gain = %6.2f %%).\n",
+ Abc_Print( 1, "NBeg = %d. NEnd = %d. (Gain = %6.2f %%). RBeg = %d. REnd = %d. (Gain = %6.2f %%).\n",
Gia_ManAndNum(pAig), Gia_ManAndNum(pNew),
100.0*(Gia_ManAndNum(pAig)-Gia_ManAndNum(pNew))/(Gia_ManAndNum(pAig)?Gia_ManAndNum(pAig):1),
Gia_ManRegNum(pAig), Gia_ManRegNum(pNew),
100.0*(Gia_ManRegNum(pAig)-Gia_ManRegNum(pNew))/(Gia_ManRegNum(pAig)?Gia_ManRegNum(pAig):1) );
}
if ( pPars->nPrefix && (Gia_ManAndNum(pNew) < Gia_ManAndNum(pAig) || Gia_ManRegNum(pNew) < Gia_ManRegNum(pAig)) )
- printf( "The reduced AIG was produced using %d-th invariants and will not verify.\n", pPars->nPrefix );
+ Abc_Print( 1, "The reduced AIG was produced using %d-th invariants and will not verify.\n", pPars->nPrefix );
// print verbose info about equivalences
if ( pPars->fVerboseFlops )
{
if ( pAig->vNamesIn == NULL )
- printf( "Flop output names are not available. Use command \"&get -n\".\n" );
+ Abc_Print( 1, "Flop output names are not available. Use command \"&get -n\".\n" );
else
Cec_ManPrintFlopEquivs( pAig );
}
@@ -1110,3 +1132,5 @@ Gia_Man_t * Cec_ManLSCorrespondence( Gia_Man_t * pAig, Cec_ParCor_t * pPars )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/cec/cecCorr_updated.c b/src/aig/cec/cecCorr_updated.c
index dbe81d81..8ce1bd74 100644
--- a/src/aig/cec/cecCorr_updated.c
+++ b/src/aig/cec/cecCorr_updated.c
@@ -20,6 +20,9 @@
#include "cecInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -970,7 +973,7 @@ int Cec_ManLSCorrespondenceClasses( Gia_Man_t * pAig, Cec_ParCor_t * pPars )
ABC_PRTP( "Other", clkTotal-clkSat-clkSrm-clkSim, clkTotal );
ABC_PRT( "TOTAL", clkTotal );
}
- return 0;
+ return 1;
}
/**Function*************************************************************
@@ -1020,3 +1023,5 @@ Gia_Man_t * Cec_ManLSCorrespondence( Gia_Man_t * pAig, Cec_ParCor_t * pPars )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/cec/cecInt.h b/src/aig/cec/cecInt.h
index 73f108ba..6216eae2 100644
--- a/src/aig/cec/cecInt.h
+++ b/src/aig/cec/cecInt.h
@@ -21,6 +21,7 @@
#ifndef __CEC_INT_H__
#define __CEC_INT_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -34,9 +35,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -128,8 +130,8 @@ struct Cec_ManSim_t_
void ** pCexes; // counter-examples for each output
int iOut; // first failed output
int nOuts; // the number of failed outputs
- Gia_Cex_t * pCexComb; // counter-example for the first failed output
- Gia_Cex_t * pBestState; // the state that led to most of the refinements
+ Abc_Cex_t * pCexComb; // counter-example for the first failed output
+ Abc_Cex_t * pBestState; // the state that led to most of the refinements
// scoring simulation patterns
int * pScores; // counters of refinement for each pattern
// temporaries
@@ -170,7 +172,7 @@ struct Cec_ManFra_t_
extern void Cec_ManRefinedClassPrintStats( Gia_Man_t * p, Vec_Str_t * vStatus, int iIter, int Time );
/*=== cecClass.c ============================================================*/
extern int Cec_ManSimClassRemoveOne( Cec_ManSim_t * p, int i );
-extern int Cec_ManSimClassesPrepare( Cec_ManSim_t * p );
+extern int Cec_ManSimClassesPrepare( Cec_ManSim_t * p, int LevelMax );
extern int Cec_ManSimClassesRefine( Cec_ManSim_t * p );
extern int Cec_ManSimSimulateRound( Cec_ManSim_t * p, Vec_Ptr_t * vInfoCis, Vec_Ptr_t * vInfoCos );
/*=== cecIso.c ============================================================*/
@@ -192,8 +194,8 @@ extern Vec_Ptr_t * Cec_ManPatCollectPatterns( Cec_ManPat_t * pMan, int
extern Vec_Ptr_t * Cec_ManPatPackPatterns( Vec_Int_t * vCexStore, int nInputs, int nRegs, int nWordsInit );
/*=== cecSeq.c ============================================================*/
extern int Cec_ManSeqResimulate( Cec_ManSim_t * p, Vec_Ptr_t * vInfo );
-extern int Cec_ManSeqResimulateInfo( Gia_Man_t * pAig, Vec_Ptr_t * vSimInfo, Gia_Cex_t * pBestState, int fCheckMiter );
-extern void Cec_ManSeqDeriveInfoInitRandom( Vec_Ptr_t * vInfo, Gia_Man_t * pAig, Gia_Cex_t * pCex );
+extern int Cec_ManSeqResimulateInfo( Gia_Man_t * pAig, Vec_Ptr_t * vSimInfo, Abc_Cex_t * pBestState, int fCheckMiter );
+extern void Cec_ManSeqDeriveInfoInitRandom( Vec_Ptr_t * vInfo, Gia_Man_t * pAig, Abc_Cex_t * pCex );
extern int Cec_ManCountNonConstOutputs( Gia_Man_t * pAig );
extern int Cec_ManCheckNonTrivialCands( Gia_Man_t * pAig );
/*=== cecSolve.c ============================================================*/
@@ -209,9 +211,11 @@ extern Vec_Int_t * Cec_ManSatReadCex( Cec_ManSat_t * p );
extern Gia_Man_t * Cec_ManFraSpecReduction( Cec_ManFra_t * p );
extern int Cec_ManFraClassesUpdate( Cec_ManFra_t * p, Cec_ManSim_t * pSim, Cec_ManPat_t * pPat, Gia_Man_t * pNew );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/aig/cec/cecIso.c b/src/aig/cec/cecIso.c
index d9aa5240..ec237fe5 100644
--- a/src/aig/cec/cecIso.c
+++ b/src/aig/cec/cecIso.c
@@ -20,6 +20,9 @@
#include "cecInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -348,13 +351,13 @@ int * Cec_ManDetectIsomorphism( Gia_Man_t * p )
{
if ( (Gia_ObjIsHead(p,pIso[i]) && Gia_ObjRepr(p,i)==pIso[i]) ||
(Gia_ObjIsClass(p,pIso[i]) && Gia_ObjRepr(p,i)==Gia_ObjRepr(p,pIso[i])) )
- printf( "1" );
+ Abc_Print( 1, "1" );
else
- printf( "0" );
+ Abc_Print( 1, "0" );
}
*/
}
- printf( "Computed %d pairs of structurally equivalent nodes.\n", Counter );
+ Abc_Print( 1, "Computed %d pairs of structurally equivalent nodes.\n", Counter );
// p->pIso = pIso;
// Cec_ManTransformClasses( p );
@@ -368,3 +371,5 @@ int * Cec_ManDetectIsomorphism( Gia_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/cec/cecMan.c b/src/aig/cec/cecMan.c
index 70396cca..f03ec701 100644
--- a/src/aig/cec/cecMan.c
+++ b/src/aig/cec/cecMan.c
@@ -20,6 +20,9 @@
#include "cecInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -70,21 +73,21 @@ Cec_ManSat_t * Cec_ManSatCreate( Gia_Man_t * pAig, Cec_ParSat_t * pPars )
***********************************************************************/
void Cec_ManSatPrintStats( Cec_ManSat_t * p )
{
- printf( "CO = %8d ", Gia_ManCoNum(p->pAig) );
- printf( "AND = %8d ", Gia_ManAndNum(p->pAig) );
- printf( "Conf = %5d ", p->pPars->nBTLimit );
- printf( "MinVar = %5d ", p->pPars->nSatVarMax );
- printf( "MinCalls = %5d\n", p->pPars->nCallsRecycle );
- printf( "Unsat calls %6d (%6.2f %%) Ave conf = %8.1f ",
+ Abc_Print( 1, "CO = %8d ", Gia_ManCoNum(p->pAig) );
+ Abc_Print( 1, "AND = %8d ", Gia_ManAndNum(p->pAig) );
+ Abc_Print( 1, "Conf = %5d ", p->pPars->nBTLimit );
+ Abc_Print( 1, "MinVar = %5d ", p->pPars->nSatVarMax );
+ Abc_Print( 1, "MinCalls = %5d\n", p->pPars->nCallsRecycle );
+ Abc_Print( 1, "Unsat calls %6d (%6.2f %%) Ave conf = %8.1f ",
p->nSatUnsat, p->nSatTotal? 100.0*p->nSatUnsat/p->nSatTotal : 0.0, p->nSatUnsat? 1.0*p->nConfUnsat/p->nSatUnsat :0.0 );
- ABC_PRTP( "Time", p->timeSatUnsat, p->timeTotal );
- printf( "Sat calls %6d (%6.2f %%) Ave conf = %8.1f ",
+ Abc_PrintTimeP( 1, "Time", p->timeSatUnsat, p->timeTotal );
+ Abc_Print( 1, "Sat calls %6d (%6.2f %%) Ave conf = %8.1f ",
p->nSatSat, p->nSatTotal? 100.0*p->nSatSat/p->nSatTotal : 0.0, p->nSatSat? 1.0*p->nConfSat/p->nSatSat : 0.0 );
- ABC_PRTP( "Time", p->timeSatSat, p->timeTotal );
- printf( "Undef calls %6d (%6.2f %%) Ave conf = %8.1f ",
+ Abc_PrintTimeP( 1, "Time", p->timeSatSat, p->timeTotal );
+ Abc_Print( 1, "Undef calls %6d (%6.2f %%) Ave conf = %8.1f ",
p->nSatUndec, p->nSatTotal? 100.0*p->nSatUndec/p->nSatTotal : 0.0, p->nSatUndec? 1.0*p->nConfUndec/p->nSatUndec : 0.0 );
- ABC_PRTP( "Time", p->timeSatUndec, p->timeTotal );
- ABC_PRT( "Total time", p->timeTotal );
+ Abc_PrintTimeP( 1, "Time", p->timeSatUndec, p->timeTotal );
+ Abc_PrintTime( 1, "Total time", p->timeTotal );
}
/**Function*************************************************************
@@ -146,18 +149,18 @@ Cec_ManPat_t * Cec_ManPatStart()
***********************************************************************/
void Cec_ManPatPrintStats( Cec_ManPat_t * p )
{
- printf( "Latest: P = %8d. L = %10d. Lm = %10d. Ave = %6.1f. MEM =%6.2f Mb\n",
+ Abc_Print( 1, "Latest: P = %8d. L = %10d. Lm = %10d. Ave = %6.1f. MEM =%6.2f Mb\n",
p->nPats, p->nPatLits, p->nPatLitsMin, 1.0 * p->nPatLitsMin/p->nPats,
1.0*(Vec_StrSize(p->vStorage)-p->iStart)/(1<<20) );
- printf( "Total: P = %8d. L = %10d. Lm = %10d. Ave = %6.1f. MEM =%6.2f Mb\n",
+ Abc_Print( 1, "Total: P = %8d. L = %10d. Lm = %10d. Ave = %6.1f. MEM =%6.2f Mb\n",
p->nPatsAll, p->nPatLitsAll, p->nPatLitsMinAll, 1.0 * p->nPatLitsMinAll/p->nPatsAll,
1.0*Vec_StrSize(p->vStorage)/(1<<20) );
- ABC_PRTP( "Finding ", p->timeFind, p->timeTotal );
- ABC_PRTP( "Shrinking", p->timeShrink, p->timeTotal );
- ABC_PRTP( "Verifying", p->timeVerify, p->timeTotal );
- ABC_PRTP( "Sorting ", p->timeSort, p->timeTotal );
- ABC_PRTP( "Packing ", p->timePack, p->timeTotal );
- ABC_PRT( "TOTAL ", p->timeTotal );
+ Abc_PrintTimeP( 1, "Finding ", p->timeFind, p->timeTotal );
+ Abc_PrintTimeP( 1, "Shrinking", p->timeShrink, p->timeTotal );
+ Abc_PrintTimeP( 1, "Verifying", p->timeVerify, p->timeTotal );
+ Abc_PrintTimeP( 1, "Sorting ", p->timeSort, p->timeTotal );
+ Abc_PrintTimeP( 1, "Packing ", p->timePack, p->timeTotal );
+ Abc_PrintTime( 1, "TOTAL ", p->timeTotal );
}
/**Function*************************************************************
@@ -290,3 +293,5 @@ void Cec_ManFraStop( Cec_ManFra_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/cec/cecPat.c b/src/aig/cec/cecPat.c
index 8537fe4a..82c12ea9 100644
--- a/src/aig/cec/cecPat.c
+++ b/src/aig/cec/cecPat.c
@@ -20,6 +20,9 @@
#include "cecInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -296,7 +299,7 @@ void Cec_ManPatVerifyPattern( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vPat
Value = Cec_ManPatComputePattern3_rec( p, Gia_ObjFanin0(pObj) );
Value = Gia_XsimNotCond( Value, Gia_ObjFaninC0(pObj) );
if ( Value != GIA_ONE )
- printf( "Cec_ManPatVerifyPattern(): Verification failed.\n" );
+ Abc_Print( 1, "Cec_ManPatVerifyPattern(): Verification failed.\n" );
assert( Value == GIA_ONE );
}
@@ -412,16 +415,16 @@ int Cec_ManPatCollectTry( Vec_Ptr_t * vInfo, Vec_Ptr_t * vPres, int iBit, int *
int i;
for ( i = 0; i < nLits; i++ )
{
- pInfo = Vec_PtrEntry(vInfo, Gia_Lit2Var(pLits[i]));
- pPres = Vec_PtrEntry(vPres, Gia_Lit2Var(pLits[i]));
+ pInfo = (unsigned *)Vec_PtrEntry(vInfo, Gia_Lit2Var(pLits[i]));
+ pPres = (unsigned *)Vec_PtrEntry(vPres, Gia_Lit2Var(pLits[i]));
if ( Gia_InfoHasBit( pPres, iBit ) &&
Gia_InfoHasBit( pInfo, iBit ) == Gia_LitIsCompl(pLits[i]) )
return 0;
}
for ( i = 0; i < nLits; i++ )
{
- pInfo = Vec_PtrEntry(vInfo, Gia_Lit2Var(pLits[i]));
- pPres = Vec_PtrEntry(vPres, Gia_Lit2Var(pLits[i]));
+ pInfo = (unsigned *)Vec_PtrEntry(vInfo, Gia_Lit2Var(pLits[i]));
+ pPres = (unsigned *)Vec_PtrEntry(vPres, Gia_Lit2Var(pLits[i]));
Gia_InfoSetBit( pPres, iBit );
if ( Gia_InfoHasBit( pInfo, iBit ) == Gia_LitIsCompl(pLits[i]) )
Gia_InfoXorBit( pInfo, iBit );
@@ -478,7 +481,7 @@ Vec_Ptr_t * Cec_ManPatCollectPatterns( Cec_ManPat_t * pMan, int nInputs, int nW
pMan->iStart = iStartOld;
if ( pMan->fVerbose )
{
- printf( "Total = %5d. Max used = %5d. Full = %5d. Series = %d. ",
+ Abc_Print( 1, "Total = %5d. Max used = %5d. Full = %5d. Series = %d. ",
nPatterns, kMax, nWordsInit*32, pMan->nSeries );
ABC_PRT( "Time", clock() - clk );
Cec_ManPatPrintStats( pMan );
@@ -551,7 +554,7 @@ Vec_Ptr_t * Cec_ManPatPackPatterns( Vec_Int_t * vCexStore, int nInputs, int nReg
nBits *= 2;
}
}
-// printf( "packed %d patterns into %d vectors (out of %d)\n", nPatterns, kMax, nBits );
+// Abc_Print( 1, "packed %d patterns into %d vectors (out of %d)\n", nPatterns, kMax, nBits );
Vec_PtrFree( vPres );
Vec_IntFree( vPat );
return vInfo;
@@ -562,3 +565,5 @@ Vec_Ptr_t * Cec_ManPatPackPatterns( Vec_Int_t * vCexStore, int nInputs, int nReg
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/cec/cecSeq.c b/src/aig/cec/cecSeq.c
index 49f2a018..b91e8523 100644
--- a/src/aig/cec/cecSeq.c
+++ b/src/aig/cec/cecSeq.c
@@ -20,6 +20,9 @@
#include "cecInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -39,7 +42,7 @@
SeeAlso []
***********************************************************************/
-void Cec_ManSeqDeriveInfoFromCex( Vec_Ptr_t * vInfo, Gia_Man_t * pAig, Gia_Cex_t * pCex )
+void Cec_ManSeqDeriveInfoFromCex( Vec_Ptr_t * vInfo, Gia_Man_t * pAig, Abc_Cex_t * pCex )
{
unsigned * pInfo;
int k, i, w, nWords;
@@ -56,14 +59,14 @@ void Cec_ManSeqDeriveInfoFromCex( Vec_Ptr_t * vInfo, Gia_Man_t * pAig, Gia_Cex_t
*/
for ( k = 0; k < Gia_ManRegNum(pAig); k++ )
{
- pInfo = Vec_PtrEntry( vInfo, k );
+ pInfo = (unsigned *)Vec_PtrEntry( vInfo, k );
for ( w = 0; w < nWords; w++ )
pInfo[w] = 0;
}
for ( i = pCex->nRegs; i < pCex->nBits; i++ )
{
- pInfo = Vec_PtrEntry( vInfo, k++ );
+ pInfo = (unsigned *)Vec_PtrEntry( vInfo, k++ );
for ( w = 0; w < nWords; w++ )
pInfo[w] = Gia_ManRandom(0);
// set simulation pattern and make sure it is second (first will be erased during simulation)
@@ -72,7 +75,7 @@ void Cec_ManSeqDeriveInfoFromCex( Vec_Ptr_t * vInfo, Gia_Man_t * pAig, Gia_Cex_t
}
for ( ; k < Vec_PtrSize(vInfo); k++ )
{
- pInfo = Vec_PtrEntry( vInfo, k );
+ pInfo = (unsigned *)Vec_PtrEntry( vInfo, k );
for ( w = 0; w < nWords; w++ )
pInfo[w] = Gia_ManRandom(0);
}
@@ -89,7 +92,7 @@ void Cec_ManSeqDeriveInfoFromCex( Vec_Ptr_t * vInfo, Gia_Man_t * pAig, Gia_Cex_t
SeeAlso []
***********************************************************************/
-void Cec_ManSeqDeriveInfoInitRandom( Vec_Ptr_t * vInfo, Gia_Man_t * pAig, Gia_Cex_t * pCex )
+void Cec_ManSeqDeriveInfoInitRandom( Vec_Ptr_t * vInfo, Gia_Man_t * pAig, Abc_Cex_t * pCex )
{
unsigned * pInfo;
int k, w, nWords;
@@ -98,14 +101,14 @@ void Cec_ManSeqDeriveInfoInitRandom( Vec_Ptr_t * vInfo, Gia_Man_t * pAig, Gia_Ce
assert( Gia_ManRegNum(pAig) <= Vec_PtrSize(vInfo) );
for ( k = 0; k < Gia_ManRegNum(pAig); k++ )
{
- pInfo = Vec_PtrEntry( vInfo, k );
+ pInfo = (unsigned *)Vec_PtrEntry( vInfo, k );
for ( w = 0; w < nWords; w++ )
pInfo[w] = (pCex && Gia_InfoHasBit(pCex->pData, k))? ~0 : 0;
}
for ( ; k < Vec_PtrSize(vInfo); k++ )
{
- pInfo = Vec_PtrEntry( vInfo, k );
+ pInfo = (unsigned *)Vec_PtrEntry( vInfo, k );
for ( w = 0; w < nWords; w++ )
pInfo[w] = Gia_ManRandom( 0 );
}
@@ -130,8 +133,8 @@ int Cec_ManSeqResimulate( Cec_ManSim_t * p, Vec_Ptr_t * vInfo )
assert( Vec_PtrSize(vInfo) == Gia_ManRegNum(p->pAig) + Gia_ManPiNum(p->pAig) * p->pPars->nFrames );
for ( k = 0; k < Gia_ManRegNum(p->pAig); k++ )
{
- pInfo0 = Vec_PtrEntry( vInfo, k );
- pInfo1 = Vec_PtrEntry( p->vCoSimInfo, Gia_ManPoNum(p->pAig) + k );
+ pInfo0 = (unsigned *)Vec_PtrEntry( vInfo, k );
+ pInfo1 = (unsigned *)Vec_PtrEntry( p->vCoSimInfo, Gia_ManPoNum(p->pAig) + k );
for ( w = 0; w < p->nWords; w++ )
pInfo1[w] = pInfo0[w];
}
@@ -139,15 +142,15 @@ int Cec_ManSeqResimulate( Cec_ManSim_t * p, Vec_Ptr_t * vInfo )
{
for ( i = 0; i < Gia_ManPiNum(p->pAig); i++ )
{
- pInfo0 = Vec_PtrEntry( vInfo, k++ );
- pInfo1 = Vec_PtrEntry( p->vCiSimInfo, i );
+ pInfo0 = (unsigned *)Vec_PtrEntry( vInfo, k++ );
+ pInfo1 = (unsigned *)Vec_PtrEntry( p->vCiSimInfo, i );
for ( w = 0; w < p->nWords; w++ )
pInfo1[w] = pInfo0[w];
}
for ( i = 0; i < Gia_ManRegNum(p->pAig); i++ )
{
- pInfo0 = Vec_PtrEntry( p->vCoSimInfo, Gia_ManPoNum(p->pAig) + i );
- pInfo1 = Vec_PtrEntry( p->vCiSimInfo, Gia_ManPiNum(p->pAig) + i );
+ pInfo0 = (unsigned *)Vec_PtrEntry( p->vCoSimInfo, Gia_ManPoNum(p->pAig) + i );
+ pInfo1 = (unsigned *)Vec_PtrEntry( p->vCiSimInfo, Gia_ManPiNum(p->pAig) + i );
for ( w = 0; w < p->nWords; w++ )
pInfo1[w] = pInfo0[w];
}
@@ -169,7 +172,7 @@ int Cec_ManSeqResimulate( Cec_ManSim_t * p, Vec_Ptr_t * vInfo )
SeeAlso []
***********************************************************************/
-int Cec_ManSeqResimulateInfo( Gia_Man_t * pAig, Vec_Ptr_t * vSimInfo, Gia_Cex_t * pBestState, int fCheckMiter )
+int Cec_ManSeqResimulateInfo( Gia_Man_t * pAig, Vec_Ptr_t * vSimInfo, Abc_Cex_t * pBestState, int fCheckMiter )
{
Cec_ParSim_t ParsSim, * pParsSim = &ParsSim;
Cec_ManSim_t * pSim;
@@ -200,33 +203,33 @@ int Cec_ManSeqResimulateInfo( Gia_Man_t * pAig, Vec_Ptr_t * vSimInfo, Gia_Cex_t
SeeAlso []
***********************************************************************/
-int Cec_ManSeqResimulateCounter( Gia_Man_t * pAig, Cec_ParSim_t * pPars, Gia_Cex_t * pCex )
+int Cec_ManSeqResimulateCounter( Gia_Man_t * pAig, Cec_ParSim_t * pPars, Abc_Cex_t * pCex )
{
Vec_Ptr_t * vSimInfo;
int RetValue, clkTotal = clock();
if ( pCex == NULL )
{
- printf( "Cec_ManSeqResimulateCounter(): Counter-example is not available.\n" );
+ Abc_Print( 1, "Cec_ManSeqResimulateCounter(): Counter-example is not available.\n" );
return -1;
}
if ( pAig->pReprs == NULL )
{
- printf( "Cec_ManSeqResimulateCounter(): Equivalence classes are not available.\n" );
+ Abc_Print( 1, "Cec_ManSeqResimulateCounter(): Equivalence classes are not available.\n" );
return -1;
}
if ( Gia_ManRegNum(pAig) == 0 )
{
- printf( "Cec_ManSeqResimulateCounter(): Not a sequential AIG.\n" );
+ Abc_Print( 1, "Cec_ManSeqResimulateCounter(): Not a sequential AIG.\n" );
return -1;
}
// if ( Gia_ManRegNum(pAig) != pCex->nRegs || Gia_ManPiNum(pAig) != pCex->nPis )
if ( Gia_ManPiNum(pAig) != pCex->nPis )
{
- printf( "Cec_ManSeqResimulateCounter(): The number of PIs in the AIG and the counter-example differ.\n" );
+ Abc_Print( 1, "Cec_ManSeqResimulateCounter(): The number of PIs in the AIG and the counter-example differ.\n" );
return -1;
}
if ( pPars->fVerbose )
- printf( "Resimulating %d timeframes.\n", pPars->nFrames + pCex->iFrame + 1 );
+ Abc_Print( 1, "Resimulating %d timeframes.\n", pPars->nFrames + pCex->iFrame + 1 );
Gia_ManRandom( 1 );
vSimInfo = Vec_PtrAllocSimInfo( Gia_ManRegNum(pAig) +
Gia_ManPiNum(pAig) * (pPars->nFrames + pCex->iFrame + 1), 1 );
@@ -240,7 +243,7 @@ int Cec_ManSeqResimulateCounter( Gia_Man_t * pAig, Cec_ParSim_t * pPars, Gia_Cex
if ( pPars->fVerbose )
ABC_PRT( "Time", clock() - clkTotal );
if ( RetValue )
- printf( "Cec_ManSeqResimulateCounter(): An output of the miter is asserted!\n" );
+ Abc_Print( 1, "Cec_ManSeqResimulateCounter(): An output of the miter is asserted!\n" );
return RetValue;
}
@@ -320,17 +323,17 @@ int Cec_ManSeqSemiformal( Gia_Man_t * pAig, Cec_ParSmf_t * pPars )
Cec_ParSat_t ParsSat, * pParsSat = &ParsSat;
Vec_Ptr_t * vSimInfo;
Vec_Str_t * vStatus;
- Gia_Cex_t * pState;
+ Abc_Cex_t * pState;
Gia_Man_t * pSrm, * pReduce, * pAux;
int r, nPats, RetValue = 0;
if ( pAig->pReprs == NULL )
{
- printf( "Cec_ManSeqSemiformal(): Equivalence classes are not available.\n" );
+ Abc_Print( 1, "Cec_ManSeqSemiformal(): Equivalence classes are not available.\n" );
return -1;
}
if ( Gia_ManRegNum(pAig) == 0 )
{
- printf( "Cec_ManSeqSemiformal(): Not a sequential AIG.\n" );
+ Abc_Print( 1, "Cec_ManSeqSemiformal(): Not a sequential AIG.\n" );
return -1;
}
Gia_ManRandom( 1 );
@@ -344,7 +347,7 @@ int Cec_ManSeqSemiformal( Gia_Man_t * pAig, Cec_ParSmf_t * pPars )
pParsSat->fVerbose = pPars->fVerbose;
if ( pParsSat->fVerbose )
{
- printf( "Starting: " );
+ Abc_Print( 1, "Starting: " );
Gia_ManEquivPrintClasses( pAig, 0, 0 );
}
// perform the given number of BMC rounds
@@ -353,7 +356,7 @@ int Cec_ManSeqSemiformal( Gia_Man_t * pAig, Cec_ParSmf_t * pPars )
{
if ( !Cec_ManCheckNonTrivialCands(pAig) )
{
- printf( "Cec_ManSeqSemiformal: There are only trivial equiv candidates left (PO drivers). Quitting.\n" );
+ Abc_Print( 1, "Cec_ManSeqSemiformal: There are only trivial equiv candidates left (PO drivers). Quitting.\n" );
break;
}
// Gia_ManPrintCounterExample( pState );
@@ -362,12 +365,12 @@ int Cec_ManSeqSemiformal( Gia_Man_t * pAig, Cec_ParSmf_t * pPars )
pSrm = Gia_ManSpecReduceInitFrames( pAig, pState, pPars->nFrames, &nFramesReal, pPars->fDualOut, pPars->nMinOutputs );
if ( pSrm == NULL )
{
- printf( "Quitting refinement because miter could not be unrolled.\n" );
+ Abc_Print( 1, "Quitting refinement because miter could not be unrolled.\n" );
break;
}
assert( Gia_ManRegNum(pSrm) == 0 && Gia_ManPiNum(pSrm) == (Gia_ManPiNum(pAig) * nFramesReal) );
if ( pPars->fVerbose )
- printf( "Unrolled for %d frames.\n", nFramesReal );
+ Abc_Print( 1, "Unrolled for %d frames.\n", nFramesReal );
// allocate room for simulation info
vSimInfo = Vec_PtrAllocSimInfo( Gia_ManRegNum(pAig) +
Gia_ManPiNum(pAig) * (nFramesReal + nAddFrames), pPars->nWords );
@@ -383,27 +386,27 @@ int Cec_ManSeqSemiformal( Gia_Man_t * pAig, Cec_ParSmf_t * pPars )
pState->iPo = -1;
if ( pPars->fVerbose )
{
- printf( "BMC = %3d ", nPats );
+ Abc_Print( 1, "BMC = %3d ", nPats );
Gia_ManEquivPrintClasses( pAig, 0, 0 );
}
// write equivalence classes
Gia_WriteAiger( pAig, "gore.aig", 0, 0 );
// reduce the model
- pReduce = Gia_ManSpecReduce( pAig, 0, 0 );
+ pReduce = Gia_ManSpecReduce( pAig, 0, 0, 0 );
if ( pReduce )
{
pReduce = Gia_ManSeqStructSweep( pAux = pReduce, 1, 1, 0 );
Gia_ManStop( pAux );
Gia_WriteAiger( pReduce, "gsrm.aig", 0, 0 );
-// printf( "Speculatively reduced model was written into file \"%s\".\n", "gsrm.aig" );
+// Abc_Print( 1, "Speculatively reduced model was written into file \"%s\".\n", "gsrm.aig" );
// Gia_ManPrintStatsShort( pReduce );
Gia_ManStop( pReduce );
}
if ( RetValue )
{
- printf( "Cec_ManSeqSemiformal(): An output of the miter is asserted. Refinement stopped.\n" );
+ Abc_Print( 1, "Cec_ManSeqSemiformal(): An output of the miter is asserted. Refinement stopped.\n" );
break;
}
// decide when to stop
@@ -417,7 +420,7 @@ int Cec_ManSeqSemiformal( Gia_Man_t * pAig, Cec_ParSmf_t * pPars )
{
int nNonConsts = Cec_ManCountNonConstOutputs( pAig );
if ( nNonConsts )
- printf( "The number of POs that are not const-0 candidates = %d.\n", nNonConsts );
+ Abc_Print( 1, "The number of POs that are not const-0 candidates = %d.\n", nNonConsts );
}
return RetValue;
}
@@ -432,3 +435,5 @@ int Cec_ManSeqSemiformal( Gia_Man_t * pAig, Cec_ParSmf_t * pPars )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/cec/cecSim.c b/src/aig/cec/cecSim.c
index 61610a46..92f8fc2e 100644
--- a/src/aig/cec/cecSim.c
+++ b/src/aig/cec/cecSim.c
@@ -20,6 +20,9 @@
#include "cecInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -46,3 +49,5 @@
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/cec/cecSolve.c b/src/aig/cec/cecSolve.c
index fa10d222..dc1b88eb 100644
--- a/src/aig/cec/cecSolve.c
+++ b/src/aig/cec/cecSolve.c
@@ -20,6 +20,9 @@
#include "cecInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -188,7 +191,7 @@ void Cec_AddClausesSuper( Cec_ManSat_t * p, Gia_Obj_t * pNode, Vec_Ptr_t * vSupe
pLits = ABC_ALLOC( int, nLits );
// suppose AND-gate is A & B = C
// add !A => !C or A + !C
- Vec_PtrForEachEntry( vSuper, pFanin, i )
+ Vec_PtrForEachEntry( Gia_Obj_t *, vSuper, pFanin, i )
{
pLits[0] = toLitCond(Cec_ObjSatNum(p,Gia_Regular(pFanin)), Gia_IsComplement(pFanin));
pLits[1] = toLitCond(Cec_ObjSatNum(p,pNode), 1);
@@ -201,7 +204,7 @@ void Cec_AddClausesSuper( Cec_ManSat_t * p, Gia_Obj_t * pNode, Vec_Ptr_t * vSupe
assert( RetValue );
}
// add A & B => C or !A + !B + C
- Vec_PtrForEachEntry( vSuper, pFanin, i )
+ Vec_PtrForEachEntry( Gia_Obj_t *, vSuper, pFanin, i )
{
pLits[i] = toLitCond(Cec_ObjSatNum(p,Gia_Regular(pFanin)), !Gia_IsComplement(pFanin));
if ( p->pPars->fPolarFlip )
@@ -320,7 +323,7 @@ void Cec_CnfNodeAddToSolver( Cec_ManSat_t * p, Gia_Obj_t * pObj )
vFrontier = Vec_PtrAlloc( 100 );
Cec_ObjAddToFrontier( p, pObj, vFrontier );
// explore nodes in the frontier
- Vec_PtrForEachEntry( vFrontier, pNode, i )
+ Vec_PtrForEachEntry( Gia_Obj_t *, vFrontier, pNode, i )
{
// create the supergate
assert( Cec_ObjSatNum(p,pNode) );
@@ -331,14 +334,14 @@ void Cec_CnfNodeAddToSolver( Cec_ManSat_t * p, Gia_Obj_t * pObj )
Vec_PtrPushUnique( p->vFanins, Gia_ObjFanin0( Gia_ObjFanin1(pNode) ) );
Vec_PtrPushUnique( p->vFanins, Gia_ObjFanin1( Gia_ObjFanin0(pNode) ) );
Vec_PtrPushUnique( p->vFanins, Gia_ObjFanin1( Gia_ObjFanin1(pNode) ) );
- Vec_PtrForEachEntry( p->vFanins, pFanin, k )
+ Vec_PtrForEachEntry( Gia_Obj_t *, p->vFanins, pFanin, k )
Cec_ObjAddToFrontier( p, Gia_Regular(pFanin), vFrontier );
Cec_AddClausesMux( p, pNode );
}
else
{
Cec_CollectSuper( pNode, fUseMuxes, p->vFanins );
- Vec_PtrForEachEntry( p->vFanins, pFanin, k )
+ Vec_PtrForEachEntry( Gia_Obj_t *, p->vFanins, pFanin, k )
Cec_ObjAddToFrontier( p, Gia_Regular(pFanin), vFrontier );
Cec_AddClausesSuper( p, pNode, p->vFanins );
}
@@ -366,7 +369,7 @@ void Cec_ManSatSolverRecycle( Cec_ManSat_t * p )
{
Gia_Obj_t * pObj;
int i;
- Vec_PtrForEachEntry( p->vUsedNodes, pObj, i )
+ Vec_PtrForEachEntry( Gia_Obj_t *, p->vUsedNodes, pObj, i )
Cec_ObjSetSatNum( p, pObj, 0 );
Vec_PtrClear( p->vUsedNodes );
// memset( p->pSatVars, 0, sizeof(int) * Gia_ManObjNumMax(p->pAigTotal) );
@@ -404,9 +407,9 @@ void Cec_SetActivityFactors_rec( Cec_ManSat_t * p, Gia_Obj_t * pObj, int LevelMi
float dActConeBumpMax = 20.0;
int iVar;
// skip visited variables
- if ( Gia_ObjIsTravIdCurrentArray(p->pAig, pObj) )
+ if ( Gia_ObjIsTravIdCurrent(p->pAig, pObj) )
return;
- Gia_ObjSetTravIdCurrentArray(p->pAig, pObj);
+ Gia_ObjSetTravIdCurrent(p->pAig, pObj);
// add the PI to the list
if ( Gia_ObjLevel(p->pAig, pObj) <= LevelMin || Gia_ObjIsCi(pObj) )
return;
@@ -440,7 +443,7 @@ int Cec_SetActivityFactors( Cec_ManSat_t * p, Gia_Obj_t * pObj )
// reset the active variables
veci_resize(&p->pSat->act_vars, 0);
// prepare for traversal
- Gia_ManIncrementTravIdArray( p->pAig );
+ Gia_ManIncrementTravId( p->pAig );
// determine the min and max level to visit
assert( dActConeRatio > 0 && dActConeRatio < 1 );
LevelMax = Gia_ObjLevel(p->pAig,pObj);
@@ -491,7 +494,7 @@ int Cec_ManSatCheckNode( Cec_ManSat_t * p, Gia_Obj_t * pObj )
clk2 = clock();
Cec_CnfNodeAddToSolver( p, pObjR );
//ABC_PRT( "cnf", clock() - clk2 );
-//printf( "%d \n", p->pSat->size );
+//Abc_Print( 1, "%d \n", p->pSat->size );
clk2 = clock();
// Cec_SetActivityFactors( p, pObjR );
@@ -529,7 +532,7 @@ p->timeSatUnsat += clock() - clk;
assert( RetValue );
p->nSatUnsat++;
p->nConfUnsat += p->pSat->stats.conflicts - nConflicts;
-//printf( "UNSAT after %d conflicts\n", p->pSat->stats.conflicts - nConflicts );
+//Abc_Print( 1, "UNSAT after %d conflicts\n", p->pSat->stats.conflicts - nConflicts );
return 1;
}
else if ( RetValue == l_True )
@@ -537,7 +540,7 @@ p->timeSatUnsat += clock() - clk;
p->timeSatSat += clock() - clk;
p->nSatSat++;
p->nConfSat += p->pSat->stats.conflicts - nConflicts;
-//printf( "SAT after %d conflicts\n", p->pSat->stats.conflicts - nConflicts );
+//Abc_Print( 1, "SAT after %d conflicts\n", p->pSat->stats.conflicts - nConflicts );
return 0;
}
else // if ( RetValue == l_Undef )
@@ -545,7 +548,7 @@ p->timeSatSat += clock() - clk;
p->timeSatUndec += clock() - clk;
p->nSatUndec++;
p->nConfUndec += p->pSat->stats.conflicts - nConflicts;
-//printf( "UNDEC after %d conflicts\n", p->pSat->stats.conflicts - nConflicts );
+//Abc_Print( 1, "UNDEC after %d conflicts\n", p->pSat->stats.conflicts - nConflicts );
return -1;
}
}
@@ -591,7 +594,7 @@ clk2 = clock();
Cec_CnfNodeAddToSolver( p, pObjR1 );
Cec_CnfNodeAddToSolver( p, pObjR2 );
//ABC_PRT( "cnf", clock() - clk2 );
-//printf( "%d \n", p->pSat->size );
+//Abc_Print( 1, "%d \n", p->pSat->size );
clk2 = clock();
// Cec_SetActivityFactors( p, pObjR1 );
@@ -633,7 +636,7 @@ p->timeSatUnsat += clock() - clk;
assert( RetValue );
p->nSatUnsat++;
p->nConfUnsat += p->pSat->stats.conflicts - nConflicts;
-//printf( "UNSAT after %d conflicts\n", p->pSat->stats.conflicts - nConflicts );
+//Abc_Print( 1, "UNSAT after %d conflicts\n", p->pSat->stats.conflicts - nConflicts );
return 1;
}
else if ( RetValue == l_True )
@@ -641,7 +644,7 @@ p->timeSatUnsat += clock() - clk;
p->timeSatSat += clock() - clk;
p->nSatSat++;
p->nConfSat += p->pSat->stats.conflicts - nConflicts;
-//printf( "SAT after %d conflicts\n", p->pSat->stats.conflicts - nConflicts );
+//Abc_Print( 1, "SAT after %d conflicts\n", p->pSat->stats.conflicts - nConflicts );
return 0;
}
else // if ( RetValue == l_Undef )
@@ -649,7 +652,7 @@ p->timeSatSat += clock() - clk;
p->timeSatUndec += clock() - clk;
p->nSatUndec++;
p->nConfUndec += p->pSat->stats.conflicts - nConflicts;
-//printf( "UNDEC after %d conflicts\n", p->pSat->stats.conflicts - nConflicts );
+//Abc_Print( 1, "UNDEC after %d conflicts\n", p->pSat->stats.conflicts - nConflicts );
return -1;
}
}
@@ -683,7 +686,7 @@ void Cec_ManSatSolve( Cec_ManPat_t * pPat, Gia_Man_t * pAig, Cec_ParSat_t * pPar
}
Gia_ManSetPhase( pAig );
Gia_ManLevelNum( pAig );
- Gia_ManResetTravIdArray( pAig );
+ Gia_ManIncrementTravId( pAig );
p = Cec_ManSatCreate( pAig, pPars );
pProgress = Bar_ProgressStart( stdout, Gia_ManPoNum(pAig) );
Gia_ManForEachCo( pAig, pObj, i )
@@ -705,7 +708,7 @@ clk2 = clock();
Gia_Man_t * pTemp = Gia_ManDupDfsCone( pAig, pObj );
Gia_WriteAiger( pTemp, "gia_hard.aig", 0, 0 );
Gia_ManStop( pTemp );
- printf( "Dumping hard cone into file \"%s\".\n", "gia_hard.aig" );
+ Abc_Print( 1, "Dumping hard cone into file \"%s\".\n", "gia_hard.aig" );
}
*/
if ( status != 0 )
@@ -759,12 +762,12 @@ Vec_Int_t * Cec_ManSatReadCex( Cec_ManSat_t * pSat )
***********************************************************************/
void Cec_ManSatSolveSeq_rec( Cec_ManSat_t * pSat, Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Ptr_t * vInfo, int iPat, int nRegs )
{
- if ( Gia_ObjIsTravIdCurrentArray(p, pObj) )
+ if ( Gia_ObjIsTravIdCurrent(p, pObj) )
return;
- Gia_ObjSetTravIdCurrentArray(p, pObj);
+ Gia_ObjSetTravIdCurrent(p, pObj);
if ( Gia_ObjIsCi(pObj) )
{
- unsigned * pInfo = Vec_PtrEntry( vInfo, nRegs + Gia_ObjCioId(pObj) );
+ unsigned * pInfo = (unsigned *)Vec_PtrEntry( vInfo, nRegs + Gia_ObjCioId(pObj) );
if ( Cec_ObjSatVarValue( pSat, pObj ) != Gia_InfoHasBit( pInfo, iPat ) )
Gia_InfoXorBit( pInfo, iPat );
pSat->nCexLits++;
@@ -799,7 +802,7 @@ Vec_Str_t * Cec_ManSatSolveSeq( Vec_Ptr_t * vPatts, Gia_Man_t * pAig, Cec_ParSat
nPatsInit = nPats = 32 * Vec_PtrReadWordsSimInfo(vPatts);
Gia_ManSetPhase( pAig );
Gia_ManLevelNum( pAig );
- Gia_ManResetTravIdArray( pAig );
+ Gia_ManIncrementTravId( pAig );
p = Cec_ManSatCreate( pAig, pPars );
vStatus = Vec_StrAlloc( Gia_ManPoNum(pAig) );
pProgress = Bar_ProgressStart( stdout, Gia_ManPoNum(pAig) );
@@ -810,18 +813,18 @@ Vec_Str_t * Cec_ManSatSolveSeq( Vec_Ptr_t * vPatts, Gia_Man_t * pAig, Cec_ParSat
{
if ( Gia_ObjFaninC0(pObj) )
{
-// printf( "Constant 1 output of SRM!!!\n" );
+// Abc_Print( 1, "Constant 1 output of SRM!!!\n" );
Vec_StrPush( vStatus, 0 );
}
else
{
-// printf( "Constant 0 output of SRM!!!\n" );
+// Abc_Print( 1, "Constant 0 output of SRM!!!\n" );
Vec_StrPush( vStatus, 1 );
}
continue;
}
status = Cec_ManSatCheckNode( p, Gia_ObjChild0(pObj) );
-//printf( "output %d status = %d\n", i, status );
+//Abc_Print( 1, "output %d status = %d\n", i, status );
Vec_StrPush( vStatus, (char)status );
if ( status != 0 )
continue;
@@ -836,7 +839,7 @@ Vec_Str_t * Cec_ManSatSolveSeq( Vec_Ptr_t * vPatts, Gia_Man_t * pAig, Cec_ParSat
if ( iPat % nPatsInit == 0 )
iPat++;
// save the pattern
- Gia_ManIncrementTravIdArray( pAig );
+ Gia_ManIncrementTravId( pAig );
// Vec_IntClear( p->vCex );
Cec_ManSatSolveSeq_rec( p, pAig, Gia_ObjFanin0(pObj), vPatts, iPat++, nRegs );
// Gia_SatVerifyPattern( pAig, pObj, p->vCex, p->vVisits );
@@ -853,7 +856,7 @@ Vec_Str_t * Cec_ManSatSolveSeq( Vec_Ptr_t * vPatts, Gia_Man_t * pAig, Cec_ParSat
Bar_ProgressStop( pProgress );
if ( pPars->fVerbose )
Cec_ManSatPrintStats( p );
-// printf( "Total number of cex literals = %d. (Ave = %d)\n", p->nCexLits, p->nCexLits/p->nSatSat );
+// Abc_Print( 1, "Total number of cex literals = %d. (Ave = %d)\n", p->nCexLits, p->nCexLits/p->nSatSat );
Cec_ManSatStop( p );
if ( pnPats )
*pnPats = iPat-1;
@@ -900,9 +903,9 @@ void Cec_ManSatAddToStore( Vec_Int_t * vCexStore, Vec_Int_t * vCex, int Out )
***********************************************************************/
void Cec_ManSatSolveMiter_rec( Cec_ManSat_t * pSat, Gia_Man_t * p, Gia_Obj_t * pObj )
{
- if ( Gia_ObjIsTravIdCurrentArray(p, pObj) )
+ if ( Gia_ObjIsTravIdCurrent(p, pObj) )
return;
- Gia_ObjSetTravIdCurrentArray(p, pObj);
+ Gia_ObjSetTravIdCurrent(p, pObj);
if ( Gia_ObjIsCi(pObj) )
{
pSat->nCexLits++;
@@ -928,7 +931,7 @@ void Cec_ManSatSolveMiter_rec( Cec_ManSat_t * pSat, Gia_Man_t * p, Gia_Obj_t * p
void Cec_ManSavePattern( Cec_ManSat_t * p, Gia_Obj_t * pObj1, Gia_Obj_t * pObj2 )
{
Vec_IntClear( p->vCex );
- Gia_ManIncrementTravIdArray( p->pAig );
+ Gia_ManIncrementTravId( p->pAig );
Cec_ManSatSolveMiter_rec( p, p->pAig, Gia_Regular(pObj1) );
if ( pObj2 )
Cec_ManSatSolveMiter_rec( p, p->pAig, Gia_Regular(pObj2) );
@@ -957,7 +960,7 @@ Vec_Int_t * Cec_ManSatSolveMiter( Gia_Man_t * pAig, Cec_ParSat_t * pPars, Vec_St
// prepare AIG
Gia_ManSetPhase( pAig );
Gia_ManLevelNum( pAig );
- Gia_ManResetTravIdArray( pAig );
+ Gia_ManIncrementTravId( pAig );
// create resulting data-structures
vStatus = Vec_StrAlloc( Gia_ManPoNum(pAig) );
vCexStore = Vec_IntAlloc( 10000 );
@@ -972,13 +975,13 @@ Vec_Int_t * Cec_ManSatSolveMiter( Gia_Man_t * pAig, Cec_ParSat_t * pPars, Vec_St
{
if ( Gia_ObjFaninC0(pObj) )
{
-// printf( "Constant 1 output of SRM!!!\n" );
+// Abc_Print( 1, "Constant 1 output of SRM!!!\n" );
Cec_ManSatAddToStore( vCexStore, p->vCex, i ); // trivial counter-example
Vec_StrPush( vStatus, 0 );
}
else
{
-// printf( "Constant 0 output of SRM!!!\n" );
+// Abc_Print( 1, "Constant 0 output of SRM!!!\n" );
Vec_StrPush( vStatus, 1 );
}
continue;
@@ -994,7 +997,7 @@ Vec_Int_t * Cec_ManSatSolveMiter( Gia_Man_t * pAig, Cec_ParSat_t * pPars, Vec_St
continue;
assert( status == 0 );
// save the pattern
-// Gia_ManIncrementTravIdArray( pAig );
+// Gia_ManIncrementTravId( pAig );
// Cec_ManSatSolveMiter_rec( p, pAig, Gia_ObjFanin0(pObj) );
Cec_ManSavePattern( p, Gia_ObjFanin0(pObj), NULL );
// Gia_SatVerifyPattern( pAig, pObj, p->vCex, p->vVisits );
@@ -1015,3 +1018,5 @@ Vec_Int_t * Cec_ManSatSolveMiter( Gia_Man_t * pAig, Cec_ParSat_t * pPars, Vec_St
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/cec/cecSweep.c b/src/aig/cec/cecSweep.c
index 1b68efe0..97f5e36a 100644
--- a/src/aig/cec/cecSweep.c
+++ b/src/aig/cec/cecSweep.c
@@ -20,6 +20,9 @@
#include "cecInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -162,8 +165,8 @@ void Cec_ManFraCreateInfo( Cec_ManSim_t * p, Vec_Ptr_t * vCiInfo, Vec_Ptr_t * vI
int i, w;
for ( i = 0; i < Gia_ManCiNum(p->pAig); i++ )
{
- pRes0 = Vec_PtrEntry( vCiInfo, i );
- pRes1 = Vec_PtrEntry( vInfo, i );
+ pRes0 = (unsigned *)Vec_PtrEntry( vCiInfo, i );
+ pRes1 = (unsigned *)Vec_PtrEntry( vInfo, i );
pRes1 += p->nWords * nSeries;
for ( w = 0; w < p->nWords; w++ )
pRes0[w] = pRes1[w];
@@ -270,7 +273,7 @@ p->timeSim += clock() - clk;
// if ( pObjOld->fMark0 == 0 )
{
if ( iRepr == Gia_ObjRepr(p->pAig, iNode) )
- printf( "Cec_ManFraClassesUpdate(): Error! Node is not refined!\n" );
+ Abc_Print( 1, "Cec_ManFraClassesUpdate(): Error! Node is not refined!\n" );
p->nAllDisproved++;
}
}
@@ -292,3 +295,5 @@ p->timeSim += clock() - clk;
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/cec/cecSynth.c b/src/aig/cec/cecSynth.c
new file mode 100644
index 00000000..52b50a43
--- /dev/null
+++ b/src/aig/cec/cecSynth.c
@@ -0,0 +1,380 @@
+/**CFile****************************************************************
+
+ FileName [cecSynth.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Combinational equivalence checking.]
+
+ Synopsis [Partitioned sequential synthesis.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: cecSynth.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "cecInt.h"
+#include "giaAig.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Populate sequential synthesis parameters.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Cec_SeqSynthesisSetDefaultParams( Cec_ParSeq_t * p )
+{
+ memset( p, 0, sizeof(Cec_ParSeq_t) );
+ p->fUseLcorr = 0; // enables latch correspondence
+ p->fUseScorr = 0; // enables signal correspondence
+ p->nBTLimit = 1000; // (scorr/lcorr) conflict limit at a node
+ p->nFrames = 1; // (scorr only) the number of timeframes
+ p->nLevelMax = -1; // (scorr only) the max number of levels
+ p->fConsts = 1; // (scl only) merging constants
+ p->fEquivs = 1; // (scl only) merging equivalences
+ p->fUseMiniSat = 0; // enables MiniSat in lcorr/scorr
+ p->nMinDomSize = 100; // the size of minimum clock domain
+ p->fVeryVerbose = 0; // verbose stats
+ p->fVerbose = 0; // verbose stats
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Cec_SeqReadMinDomSize( Cec_ParSeq_t * p )
+{
+ return p->nMinDomSize;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Cec_SeqReadVerbose( Cec_ParSeq_t * p )
+{
+ return p->fVerbose;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes partitioning of registers.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManRegCreatePart( Gia_Man_t * p, Vec_Int_t * vPart, int * pnCountPis, int * pnCountRegs, int ** ppMapBack )
+{
+ Gia_Man_t * pNew;
+ Gia_Obj_t * pObj;
+ Vec_Int_t * vNodes, * vRoots;
+ int i, iOut, nCountPis, nCountRegs;
+ int * pMapBack;
+ // collect/mark nodes/PIs in the DFS order from the roots
+ Gia_ManIncrementTravId( p );
+ vRoots = Vec_IntAlloc( Vec_IntSize(vPart) );
+ Vec_IntForEachEntry( vPart, iOut, i )
+ Vec_IntPush( vRoots, Gia_ObjId(p, Gia_ManCo(p, Gia_ManPoNum(p)+iOut)) );
+ vNodes = Gia_ManCollectNodesCis( p, Vec_IntArray(vRoots), Vec_IntSize(vRoots) );
+ Vec_IntFree( vRoots );
+ // unmark register outputs
+ Vec_IntForEachEntry( vPart, iOut, i )
+ Gia_ObjSetTravIdPrevious( p, Gia_ManCi(p, Gia_ManPiNum(p)+iOut) );
+ // count pure PIs
+ nCountPis = nCountRegs = 0;
+ Gia_ManForEachPi( p, pObj, i )
+ nCountPis += Gia_ObjIsTravIdCurrent(p, pObj);
+ // count outputs of other registers
+ Gia_ManForEachRo( p, pObj, i )
+ nCountRegs += Gia_ObjIsTravIdCurrent(p, pObj); // should be !Gia_... ???
+ if ( pnCountPis )
+ *pnCountPis = nCountPis;
+ if ( pnCountRegs )
+ *pnCountRegs = nCountRegs;
+ // clean old manager
+ Gia_ManFillValue(p);
+ Gia_ManConst0(p)->Value = 0;
+ // create the new manager
+ pNew = Gia_ManStart( Vec_IntSize(vNodes) );
+ // create the PIs
+ Gia_ManForEachCi( p, pObj, i )
+ if ( Gia_ObjIsTravIdCurrent(p, pObj) )
+ pObj->Value = Gia_ManAppendCi(pNew);
+ // add variables for the register outputs
+ // create fake POs to hold the register outputs
+ Vec_IntForEachEntry( vPart, iOut, i )
+ {
+ pObj = Gia_ManCi(p, Gia_ManPiNum(p)+iOut);
+ pObj->Value = Gia_ManAppendCi(pNew);
+ Gia_ManAppendCo( pNew, pObj->Value );
+ Gia_ObjSetTravIdCurrent( p, pObj ); // added
+ }
+ // create the nodes
+ Gia_ManForEachObjVec( vNodes, p, pObj, i )
+ if ( Gia_ObjIsAnd(pObj) )
+ pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+ // add real POs for the registers
+ Vec_IntForEachEntry( vPart, iOut, i )
+ {
+ pObj = Gia_ManCo( p, Gia_ManPoNum(p)+iOut );
+ Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
+ }
+ Gia_ManSetRegNum( pNew, Vec_IntSize(vPart) );
+ // create map
+ if ( ppMapBack )
+ {
+ pMapBack = ABC_FALLOC( int, Gia_ManObjNum(pNew) );
+ // map constant nodes
+ pMapBack[0] = 0;
+ // logic cones of register outputs
+ Gia_ManForEachObjVec( vNodes, p, pObj, i )
+ {
+// pObjNew = Aig_Regular(pObj->pData);
+// pMapBack[pObjNew->Id] = pObj->Id;
+ assert( Gia_Lit2Var(Gia_ObjValue(pObj)) >= 0 );
+ assert( Gia_Lit2Var(Gia_ObjValue(pObj)) < Gia_ManObjNum(pNew) );
+ pMapBack[ Gia_Lit2Var(Gia_ObjValue(pObj)) ] = Gia_ObjId(p, pObj);
+ }
+ // map register outputs
+ Vec_IntForEachEntry( vPart, iOut, i )
+ {
+ pObj = Gia_ManCi(p, Gia_ManPiNum(p)+iOut);
+// pObjNew = pObj->pData;
+// pMapBack[pObjNew->Id] = pObj->Id;
+ assert( Gia_Lit2Var(Gia_ObjValue(pObj)) >= 0 );
+ assert( Gia_Lit2Var(Gia_ObjValue(pObj)) < Gia_ManObjNum(pNew) );
+ pMapBack[ Gia_Lit2Var(Gia_ObjValue(pObj)) ] = Gia_ObjId(p, pObj);
+ }
+ *ppMapBack = pMapBack;
+ }
+ Vec_IntFree( vNodes );
+ return pNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Transfers the classes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_TransferMappedClasses( Gia_Man_t * pPart, int * pMapBack, int * pReprs )
+{
+ Gia_Obj_t * pObj;
+ int i, Id1, Id2, nClasses;
+ if ( pPart->pReprs == NULL )
+ return 0;
+ nClasses = 0;
+ Gia_ManForEachObj( pPart, pObj, i )
+ {
+ if ( Gia_ObjRepr(pPart, i) == GIA_VOID )
+ continue;
+ assert( i < Gia_ManObjNum(pPart) );
+ assert( Gia_ObjRepr(pPart, i) < Gia_ManObjNum(pPart) );
+ Id1 = pMapBack[ i ];
+ Id2 = pMapBack[ Gia_ObjRepr(pPart, i) ];
+ if ( Id1 == Id2 )
+ continue;
+ if ( Id1 < Id2 )
+ pReprs[Id2] = Id1;
+ else
+ pReprs[Id1] = Id2;
+ nClasses++;
+ }
+ return nClasses;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManFindRepr_rec( int * pReprs, int Id )
+{
+ if ( pReprs[Id] == 0 )
+ return 0;
+ if ( pReprs[Id] == ~0 )
+ return Id;
+ return Gia_ManFindRepr_rec( pReprs, pReprs[Id] );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Normalizes equivalences.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManNormalizeEquivalences( Gia_Man_t * p, int * pReprs )
+{
+ int i, iRepr;
+ assert( p->pReprs == NULL );
+ assert( p->pNexts == NULL );
+ p->pReprs = ABC_CALLOC( Gia_Rpr_t, Gia_ManObjNum(p) );
+ for ( i = 0; i < Gia_ManObjNum(p); i++ )
+ Gia_ObjSetRepr( p, i, GIA_VOID );
+ for ( i = 0; i < Gia_ManObjNum(p); i++ )
+ {
+ if ( pReprs[i] == ~0 )
+ continue;
+ iRepr = Gia_ManFindRepr_rec( pReprs, i );
+ Gia_ObjSetRepr( p, i, iRepr );
+ }
+ p->pNexts = Gia_ManDeriveNexts( p );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Partitioned sequential synthesis.]
+
+ Description [Returns AIG annotated with equivalence classes.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Cec_SequentialSynthesisPart( Gia_Man_t * p, Cec_ParSeq_t * pPars )
+{
+ int fPrintParts = 0;
+ char Buffer[100];
+ Gia_Man_t * pTemp;
+ Vec_Ptr_t * vParts = (Vec_Ptr_t *)p->vClockDoms;
+ Vec_Int_t * vPart;
+ int * pMapBack, * pReprs;
+ int i, nCountPis, nCountRegs;
+ int nClasses, clk = clock();
+
+ // save parameters
+ if ( fPrintParts )
+ {
+ // print partitions
+ Abc_Print( 1, "The following clock domains are used:\n" );
+ Vec_PtrForEachEntry( Vec_Int_t *, vParts, vPart, i )
+ {
+ pTemp = Gia_ManRegCreatePart( p, vPart, &nCountPis, &nCountRegs, NULL );
+ sprintf( Buffer, "part%03d.aig", i );
+ Gia_WriteAiger( pTemp, Buffer, 0, 0 );
+ Abc_Print( 1, "part%03d.aig : Reg = %4d. PI = %4d. (True = %4d. Regs = %4d.) And = %5d.\n",
+ i, Vec_IntSize(vPart), Gia_ManCiNum(pTemp)-Vec_IntSize(vPart), nCountPis, nCountRegs, Gia_ManAndNum(pTemp) );
+ Gia_ManStop( pTemp );
+ }
+ }
+
+ // perform sequential synthesis for clock domains
+ pReprs = ABC_FALLOC( int, Gia_ManObjNum(p) );
+ Vec_PtrForEachEntry( Vec_Int_t *, vParts, vPart, i )
+ {
+ pTemp = Gia_ManRegCreatePart( p, vPart, &nCountPis, &nCountRegs, &pMapBack );
+ if ( nCountPis > 0 )
+ {
+ if ( pPars->fUseScorr )
+ {
+ Cec_ParCor_t CorPars, * pCorPars = &CorPars;
+ Cec_ManCorSetDefaultParams( pCorPars );
+ pCorPars->nBTLimit = pPars->nBTLimit;
+ pCorPars->nLevelMax = pPars->nLevelMax;
+ pCorPars->fVerbose = pPars->fVeryVerbose;
+ pCorPars->fUseCSat = 1;
+ Cec_ManLSCorrespondenceClasses( pTemp, pCorPars );
+ }
+ else if ( pPars->fUseLcorr )
+ {
+ Cec_ParCor_t CorPars, * pCorPars = &CorPars;
+ Cec_ManCorSetDefaultParams( pCorPars );
+ pCorPars->fLatchCorr = 1;
+ pCorPars->nBTLimit = pPars->nBTLimit;
+ pCorPars->fVerbose = pPars->fVeryVerbose;
+ pCorPars->fUseCSat = 1;
+ Cec_ManLSCorrespondenceClasses( pTemp, pCorPars );
+ }
+ else
+ {
+// pNew = Gia_ManSeqStructSweep( pTemp, pPars->fConsts, pPars->fEquivs, pPars->fVerbose );
+// Gia_ManStop( pNew );
+ Gia_ManSeqCleanupClasses( pTemp, pPars->fConsts, pPars->fEquivs, pPars->fVerbose );
+ }
+//Abc_Print( 1, "Part equivalences = %d.\n", Gia_ManEquivCountLitsAll(pTemp) );
+ nClasses = Gia_TransferMappedClasses( pTemp, pMapBack, pReprs );
+ if ( pPars->fVerbose )
+ {
+ Abc_Print( 1, "%3d : Reg = %4d. PI = %4d. (True = %4d. Regs = %4d.) And = %5d. Cl = %5d.\n",
+ i, Vec_IntSize(vPart), Gia_ManCiNum(pTemp)-Vec_IntSize(vPart), nCountPis, nCountRegs, Gia_ManAndNum(pTemp), nClasses );
+ }
+ }
+ Gia_ManStop( pTemp );
+ ABC_FREE( pMapBack );
+ }
+
+ // generate resulting equivalences
+ Gia_ManNormalizeEquivalences( p, pReprs );
+//Abc_Print( 1, "Total equivalences = %d.\n", Gia_ManEquivCountLitsAll(p) );
+ ABC_FREE( pReprs );
+ if ( pPars->fVerbose )
+ {
+ Abc_PrintTime( 1, "Total time", clock() - clk );
+ }
+ return 1;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/cec/module.make b/src/aig/cec/module.make
index 35a18cae..42e0cd1b 100644
--- a/src/aig/cec/module.make
+++ b/src/aig/cec/module.make
@@ -9,4 +9,5 @@ SRC += src/aig/cec/cecCec.c \
src/aig/cec/cecSeq.c \
src/aig/cec/cecSim.c \
src/aig/cec/cecSolve.c \
+ src/aig/cec/cecSynth.c \
src/aig/cec/cecSweep.c
diff --git a/src/aig/cgt/cgt.h b/src/aig/cgt/cgt.h
index 8d18ea80..aa8f9338 100644
--- a/src/aig/cgt/cgt.h
+++ b/src/aig/cgt/cgt.h
@@ -21,6 +21,7 @@
#ifndef __CGT_H__
#define __CGT_H__
+
/*
The algorithm implemented in this package is based on the paper:
A. Hurst. "Automatic synthesis of clock gating logic with controlled
@@ -35,9 +36,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -70,9 +72,11 @@ extern void Cgt_SetDefaultParams( Cgt_Par_t * p );
extern Vec_Vec_t * Cgt_ClockGatingCandidates( Aig_Man_t * pAig, Aig_Man_t * pCare, Cgt_Par_t * pPars );
extern Aig_Man_t * Cgt_ClockGating( Aig_Man_t * pAig, Aig_Man_t * pCare, Cgt_Par_t * pPars );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/aig/cgt/cgtAig.c b/src/aig/cgt/cgtAig.c
index d411c25a..463c3060 100644
--- a/src/aig/cgt/cgtAig.c
+++ b/src/aig/cgt/cgtAig.c
@@ -20,6 +20,9 @@
#include "cgtInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -119,7 +122,7 @@ void Cgt_ManDetectFanout( Aig_Man_t * pAig, Aig_Obj_t * pObj, int nOdcMax, Vec_P
Cgt_ManDetectFanout_rec( pAig, pObj, nOdcMax, vFanout );
// remove those nodes whose fanout is included
k = 0;
- Vec_PtrForEachEntry( vFanout, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vFanout, pObj, i )
{
// go through the fanouts of this node
Aig_ObjForEachFanout( pAig, pObj, pFanout, iFanout, f )
@@ -130,7 +133,7 @@ void Cgt_ManDetectFanout( Aig_Man_t * pAig, Aig_Obj_t * pObj, int nOdcMax, Vec_P
Vec_PtrWriteEntry( vFanout, k++, pObj );
}
Vec_PtrShrink( vFanout, k );
- Vec_PtrSort( vFanout, Aig_ObjCompareIdIncrease );
+ Vec_PtrSort( vFanout, (int (*)(void))Aig_ObjCompareIdIncrease );
assert( Vec_PtrSize(vFanout) > 0 );
}
@@ -175,7 +178,7 @@ void Cgt_ManCollectVisited( Aig_Man_t * pAig, Vec_Ptr_t * vFanout, Vec_Ptr_t * v
int i;
Vec_PtrClear( vVisited );
Aig_ManIncrementTravId( pAig );
- Vec_PtrForEachEntry( vFanout, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vFanout, pObj, i )
Cgt_ManCollectVisited_rec( pAig, pObj, vVisited );
}
@@ -215,7 +218,7 @@ Aig_Obj_t * Cgt_ManConstructCareCondition( Cgt_Man_t * p, Aig_Man_t * pNew, Aig_
Cgt_ManDetectFanout( p->pAig, pObjLo, p->pPars->nOdcMax, p->vFanout );
Cgt_ManCollectVisited( p->pAig, p->vFanout, p->vVisited );
// add new variables if the observability condition depends on PI variables
- Vec_PtrForEachEntry( p->vVisited, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vVisited, pObj, i )
{
assert( Aig_ObjIsNode(pObj) );
if ( Saig_ObjIsPi(p->pAig, Aig_ObjFanin0(pObj)) && Vec_PtrEntry(vCopy0, Aig_ObjFaninId0(pObj)) == NULL )
@@ -232,7 +235,7 @@ Aig_Obj_t * Cgt_ManConstructCareCondition( Cgt_Man_t * p, Aig_Man_t * pNew, Aig_
}
}
// construct AIGs for the nodes
- Vec_PtrForEachEntry( p->vVisited, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vVisited, pObj, i )
{
pTemp = Aig_And( pNew, Aig_ObjChild0CopyVec(vCopy0, pObj), Aig_ObjChild1CopyVec(vCopy0, pObj) );
Vec_PtrWriteEntry( vCopy0, Aig_ObjId(pObj), pTemp );
@@ -241,9 +244,9 @@ Aig_Obj_t * Cgt_ManConstructCareCondition( Cgt_Man_t * p, Aig_Man_t * pNew, Aig_
}
// construct the care miter
pMiter = Aig_ManConst0( pNew );
- Vec_PtrForEachEntry( p->vFanout, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vFanout, pObj, i )
{
- pTemp = Aig_Exor( pNew, Vec_PtrEntry(vCopy0, Aig_ObjId(pObj)), Vec_PtrEntry(vCopy1, Aig_ObjId(pObj)) );
+ pTemp = Aig_Exor( pNew, (Aig_Obj_t *)Vec_PtrEntry(vCopy0, Aig_ObjId(pObj)), (Aig_Obj_t *)Vec_PtrEntry(vCopy1, Aig_ObjId(pObj)) );
pMiter = Aig_Or( pNew, pMiter, pTemp );
}
return pMiter;
@@ -300,7 +303,7 @@ Aig_Man_t * Cgt_ManDeriveAigForGating( Cgt_Man_t * p )
Vec_PtrWriteEntry( vCopy0, Aig_ObjId(pObjLo), Aig_ObjChild0Copy(pObjLi) );
Vec_PtrWriteEntry( vCopy1, Aig_ObjId(pObjLo), Aig_ObjChild0Copy(pObjLi) );
// compute the miter
- pMiter = Aig_Exor( pNew, pObjLo->pData, Aig_ObjChild0Copy(pObjLi) );
+ pMiter = Aig_Exor( pNew, (Aig_Obj_t *)pObjLo->pData, Aig_ObjChild0Copy(pObjLi) );
pMiter = Aig_And( pNew, pMiter, pCare );
pObjLi->pData = Aig_ObjCreatePo( pNew, pMiter );
}
@@ -312,7 +315,7 @@ Aig_Man_t * Cgt_ManDeriveAigForGating( Cgt_Man_t * p )
// construct clock-gating miters for each register input
Saig_ManForEachLiLo( p->pAig, pObjLi, pObjLo, i )
{
- pMiter = Aig_Exor( pNew, pObjLo->pData, Aig_ObjChild0Copy(pObjLi) );
+ pMiter = Aig_Exor( pNew, (Aig_Obj_t *)pObjLo->pData, Aig_ObjChild0Copy(pObjLi) );
pObjLi->pData = Aig_ObjCreatePo( pNew, pMiter );
}
}
@@ -336,19 +339,19 @@ Aig_Obj_t * Cgt_ManConstructCare_rec( Aig_Man_t * pCare, Aig_Obj_t * pObj, Aig_M
{
Aig_Obj_t * pObj0, * pObj1;
if ( Aig_ObjIsTravIdCurrent( pCare, pObj ) )
- return pObj->pData;
+ return (Aig_Obj_t *)pObj->pData;
Aig_ObjSetTravIdCurrent( pCare, pObj );
if ( Aig_ObjIsPi(pObj) )
- return pObj->pData = NULL;
+ return (Aig_Obj_t *)(pObj->pData = NULL);
pObj0 = Cgt_ManConstructCare_rec( pCare, Aig_ObjFanin0(pObj), pNew );
if ( pObj0 == NULL )
- return pObj->pData = NULL;
+ return (Aig_Obj_t *)(pObj->pData = NULL);
pObj1 = Cgt_ManConstructCare_rec( pCare, Aig_ObjFanin1(pObj), pNew );
if ( pObj1 == NULL )
- return pObj->pData = NULL;
+ return (Aig_Obj_t *)(pObj->pData = NULL);
pObj0 = Aig_NotCond( pObj0, Aig_ObjFaninC0(pObj) );
pObj1 = Aig_NotCond( pObj1, Aig_ObjFaninC1(pObj) );
- return pObj->pData = Aig_And( pNew, pObj0, pObj1 );
+ return (Aig_Obj_t *)(pObj->pData = Aig_And( pNew, pObj0, pObj1 ));
}
/**Function*************************************************************
@@ -370,16 +373,16 @@ void Cgt_ManConstructCare( Aig_Man_t * pNew, Aig_Man_t * pCare, Vec_Vec_t * vSup
// go through the PIs of the partition
// label the corresponding PIs of the care set
Aig_ManIncrementTravId( pCare );
- Vec_PtrForEachEntry( vLeaves, pLeaf, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vLeaves, pLeaf, i )
{
pPi = Aig_ManPi( pCare, Aig_ObjPioNum(pLeaf) );
Aig_ObjSetTravIdCurrent( pCare, pPi );
pPi->pData = pLeaf->pData;
}
// construct the constraints
- Vec_PtrForEachEntry( vLeaves, pLeaf, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vLeaves, pLeaf, i )
{
- vOuts = Vec_VecEntry( vSuppsInv, Aig_ObjPioNum(pLeaf) );
+ vOuts = (Vec_Int_t *)Vec_VecEntry( vSuppsInv, Aig_ObjPioNum(pLeaf) );
Vec_IntForEachEntry( vOuts, iOut, k )
{
pPo = Aig_ManPo( pCare, iOut );
@@ -411,17 +414,17 @@ void Cgt_ManConstructCare( Aig_Man_t * pNew, Aig_Man_t * pCare, Vec_Vec_t * vSup
Aig_Obj_t * Cgt_ManDupPartition_rec( Aig_Man_t * pNew, Aig_Man_t * pAig, Aig_Obj_t * pObj, Vec_Ptr_t * vLeaves )
{
if ( Aig_ObjIsTravIdCurrent(pAig, pObj) )
- return pObj->pData;
+ return (Aig_Obj_t *)pObj->pData;
Aig_ObjSetTravIdCurrent(pAig, pObj);
if ( Aig_ObjIsPi(pObj) )
{
pObj->pData = Aig_ObjCreatePi( pNew );
Vec_PtrPush( vLeaves, pObj );
- return pObj->pData;
+ return (Aig_Obj_t *)pObj->pData;
}
Cgt_ManDupPartition_rec( pNew, pAig, Aig_ObjFanin0(pObj), vLeaves );
Cgt_ManDupPartition_rec( pNew, pAig, Aig_ObjFanin1(pObj), vLeaves );
- return pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
+ return (Aig_Obj_t *)(pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) ));
}
/**Function*************************************************************
@@ -469,8 +472,8 @@ Aig_Man_t * Cgt_ManDupPartition( Aig_Man_t * pFrame, int nVarsMin, int nFlopsMin
if ( pCare )
Cgt_ManConstructCare( pNew, pCare, vSuppsInv, vLeaves );
// create POs
- Vec_PtrForEachEntry( vPos, pObj, i )
- pObj->pData = Aig_ObjCreatePo( pNew, Vec_PtrEntry(vRoots, i) );
+ Vec_PtrForEachEntry( Aig_Obj_t *, vPos, pObj, i )
+ pObj->pData = (Aig_Obj_t *)Aig_ObjCreatePo( pNew, (Aig_Obj_t *)Vec_PtrEntry(vRoots, i) );
if ( pnOutputs != NULL )
*pnOutputs = Vec_PtrSize( vPos );
Vec_PtrFree( vRoots );
@@ -496,12 +499,12 @@ Aig_Obj_t * Cgt_ManBuildClockGate( Aig_Man_t * pNew, Vec_Ptr_t * vGates )
int i;
assert( Vec_PtrSize(vGates) > 0 );
pTotal = Aig_ManConst0(pNew);
- Vec_PtrForEachEntry( vGates, pGate, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vGates, pGate, i )
{
if ( Aig_Regular(pGate)->pNext )
pGate = Aig_NotCond( Aig_Regular(pGate)->pNext, Aig_IsComplement(pGate) );
else
- pGate = Aig_NotCond( Aig_Regular(pGate)->pData, Aig_IsComplement(pGate) );
+ pGate = Aig_NotCond( (Aig_Obj_t *)Aig_Regular(pGate)->pData, Aig_IsComplement(pGate) );
pTotal = Aig_Or( pNew, pTotal, pGate );
}
return pTotal;
@@ -526,7 +529,7 @@ Aig_Man_t * Cgt_ManDeriveGatedAig( Aig_Man_t * pAig, Vec_Vec_t * vGates, int fRe
int i, k;
Aig_ManCleanNext( pAig );
// label nodes
- Vec_VecForEachEntry( vGates, pObj, i, k )
+ Vec_VecForEachEntry( Aig_Obj_t *, vGates, pObj, i, k )
{
if ( Aig_IsComplement(pObj) )
Aig_Regular(pObj)->fMarkB = 1;
@@ -549,12 +552,12 @@ Aig_Man_t * Cgt_ManDeriveGatedAig( Aig_Man_t * pAig, Vec_Vec_t * vGates, int fRe
pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
if ( pObj->fMarkA )
{
- pObj->pNext = pObj->pData;
+ pObj->pNext = (Aig_Obj_t *)pObj->pData;
pObj->pData = Aig_ManConst0(pNew);
}
else if ( pObj->fMarkB )
{
- pObj->pNext = pObj->pData;
+ pObj->pNext = (Aig_Obj_t *)pObj->pData;
pObj->pData = Aig_ManConst1(pNew);
}
}
@@ -570,14 +573,14 @@ Aig_Man_t * Cgt_ManDeriveGatedAig( Aig_Man_t * pAig, Vec_Vec_t * vGates, int fRe
pObj->pData = Aig_ObjCreatePo( pNew, Aig_ObjChild0Copy(pObj) );
Saig_ManForEachLiLo( pAig, pObjLi, pObjLo, i )
{
- vOne = Vec_VecEntry( vGates, i );
+ vOne = (Vec_Ptr_t *)Vec_VecEntry( vGates, i );
if ( Vec_PtrSize(vOne) == 0 )
pObjNew = Aig_ObjChild0Copy(pObjLi);
else
{
// pGateNew = Aig_NotCond( Aig_Regular(pGate)->pData, Aig_IsComplement(pGate) );
pGateNew = Cgt_ManBuildClockGate( pNew, vOne );
- pObjNew = Aig_Mux( pNew, pGateNew, pObjLo->pData, Aig_ObjChild0Copy(pObjLi) );
+ pObjNew = Aig_Mux( pNew, pGateNew, (Aig_Obj_t *)pObjLo->pData, Aig_ObjChild0Copy(pObjLi) );
}
pObjLi->pData = Aig_ObjCreatePo( pNew, pObjNew );
}
@@ -594,3 +597,5 @@ Aig_Man_t * Cgt_ManDeriveGatedAig( Aig_Man_t * pAig, Vec_Vec_t * vGates, int fRe
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/cgt/cgtCore.c b/src/aig/cgt/cgtCore.c
index b213297e..d4229ce6 100644
--- a/src/aig/cgt/cgtCore.c
+++ b/src/aig/cgt/cgtCore.c
@@ -21,6 +21,9 @@
#include "cgtInt.h"
#include "bar.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -68,8 +71,8 @@ int Cgt_SimulationFilter( Cgt_Man_t * p, Aig_Obj_t * pCandPart, Aig_Obj_t * pMit
{
unsigned * pInfoCand, * pInfoMiter;
int w, nWords = Aig_BitWordNum( p->nPatts );
- pInfoCand = Vec_PtrEntry( p->vPatts, Aig_ObjId(Aig_Regular(pCandPart)) );
- pInfoMiter = Vec_PtrEntry( p->vPatts, Aig_ObjId(pMiterPart) );
+ pInfoCand = (unsigned *)Vec_PtrEntry( p->vPatts, Aig_ObjId(Aig_Regular(pCandPart)) );
+ pInfoMiter = (unsigned *)Vec_PtrEntry( p->vPatts, Aig_ObjId(pMiterPart) );
// C => !M -- true is the same as C & M -- false
if ( !Aig_IsComplement(pCandPart) )
{
@@ -103,7 +106,7 @@ void Cgt_SimulationRecord( Cgt_Man_t * p )
int i;
Aig_ManForEachObj( p->pPart, pObj, i )
if ( sat_solver_var_value( p->pSat, p->pCnf->pVarNums[i] ) )
- Aig_InfoSetBit( Vec_PtrEntry(p->vPatts, i), p->nPatts );
+ Aig_InfoSetBit( (unsigned *)Vec_PtrEntry(p->vPatts, i), p->nPatts );
p->nPatts++;
if ( p->nPatts == 32 * p->nPattWords )
{
@@ -137,14 +140,14 @@ void Cgt_ClockGatingRangeCheck( Cgt_Man_t * p, int iStart, int nOutputs )
pMiter = Saig_ManLi( p->pAig, i );
Cgt_ManDetectCandidates( p->pAig, Aig_ObjFanin0(pMiter), p->pPars->nLevelMax, vNodes );
// go through the candidates of this PO
- Vec_PtrForEachEntry( vNodes, pCand, k )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pCand, k )
{
// get the corresponding nodes from the frames
- pCandFrame = pCand->pData;
- pMiterFrame = pMiter->pData;
+ pCandFrame = (Aig_Obj_t *)pCand->pData;
+ pMiterFrame = (Aig_Obj_t *)pMiter->pData;
// get the corresponding nodes from the part
- pCandPart = pCandFrame->pData;
- pMiterPart = pMiterFrame->pData;
+ pCandPart = (Aig_Obj_t *)pCandFrame->pData;
+ pMiterPart = (Aig_Obj_t *)pMiterFrame->pData;
// try direct polarity
if ( Cgt_SimulationFilter( p, pCandPart, pMiterPart ) )
{
@@ -205,7 +208,7 @@ int Cgt_ClockGatingRange( Cgt_Man_t * p, int iStart )
clk = clock();
p->pPart = Cgt_ManDupPartition( p->pFrame, p->pPars->nVarsMin, p->pPars->nFlopsMin, iStart, p->pCare, p->vSuppsInv, &nOutputs );
p->pCnf = Cnf_DeriveSimple( p->pPart, nOutputs );
- p->pSat = Cnf_DataWriteIntoSolver( p->pCnf, 1, 0 );
+ p->pSat = (sat_solver *)Cnf_DataWriteIntoSolver( p->pCnf, 1, 0 );
sat_solver_compress( p->pSat );
p->vPatts = Vec_PtrAllocSimInfo( Aig_ManObjNumMax(p->pPart), p->nPattWords );
Vec_PtrCleanSimInfo( p->vPatts, 0, p->nPattWords );
@@ -314,3 +317,5 @@ Aig_Man_t * Cgt_ClockGating( Aig_Man_t * pAig, Aig_Man_t * pCare, Cgt_Par_t * pP
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/cgt/cgtDecide.c b/src/aig/cgt/cgtDecide.c
index 3e79ff73..54a69e95 100644
--- a/src/aig/cgt/cgtDecide.c
+++ b/src/aig/cgt/cgtDecide.c
@@ -21,6 +21,9 @@
#include "cgtInt.h"
#include "sswInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -96,11 +99,11 @@ int Cgt_ManCheckGateComplete( Aig_Man_t * pAig, Vec_Vec_t * vGatesAll, Aig_Obj_t
Vec_Ptr_t * vGates;
Aig_Obj_t * pObj;
int i;
- Vec_PtrForEachEntry( vFanout, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vFanout, pObj, i )
{
if ( Saig_ObjIsPo(pAig, pObj) )
return 0;
- vGates = Vec_VecEntry( vGatesAll, Aig_ObjPioNum(pObj) - Saig_ManPoNum(pAig) );
+ vGates = (Vec_Ptr_t *)Vec_VecEntry( vGatesAll, Aig_ObjPioNum(pObj) - Saig_ManPoNum(pAig) );
if ( Vec_PtrFind( vGates, pGate ) == -1 )
return 0;
}
@@ -125,7 +128,7 @@ Vec_Ptr_t * Cgt_ManCompleteGates( Aig_Man_t * pAig, Vec_Vec_t * vGatesAll, int n
int i, k;
vFanout = Vec_PtrAlloc( 100 );
vGatesFull = Vec_PtrAlloc( 100 );
- Vec_VecForEachEntry( vGatesAll, pGate, i, k )
+ Vec_VecForEachEntry( Aig_Obj_t *, vGatesAll, pGate, i, k )
{
pGateR = Aig_Regular(pGate);
if ( pGateR->fMarkA )
@@ -136,7 +139,7 @@ Vec_Ptr_t * Cgt_ManCompleteGates( Aig_Man_t * pAig, Vec_Vec_t * vGatesAll, int n
Vec_PtrPush( vGatesFull, pGate );
}
Vec_PtrFree( vFanout );
- Vec_VecForEachEntry( vGatesAll, pGate, i, k )
+ Vec_VecForEachEntry( Aig_Obj_t *, vGatesAll, pGate, i, k )
Aig_Regular(pGate)->fMarkA = 0;
return vGatesFull;
}
@@ -197,8 +200,8 @@ Vec_Vec_t * Cgt_ManDecideSimple( Aig_Man_t * pAig, Vec_Vec_t * vGatesAll, int nO
{
nHitsMax = 0;
pCandBest = NULL;
- vCands = Vec_VecEntry( vGatesAll, i );
- Vec_PtrForEachEntry( vCands, pCand, k )
+ vCands = (Vec_Ptr_t *)Vec_VecEntry( vGatesAll, i );
+ Vec_PtrForEachEntry( Aig_Obj_t *, vCands, pCand, k )
{
// check if this is indeed a clock-gate
if ( nOdcMax == 0 && !Ssw_SmlCheckXorImplication( pSml, pObjLi, pObjLo, pCand ) )
@@ -260,15 +263,15 @@ Vec_Vec_t * Cgt_ManDecideArea( Aig_Man_t * pAig, Vec_Vec_t * vGatesAll, int nOdc
// derive and label complete gates
vCompletes = Cgt_ManCompleteGates( pAig, vGatesAll, nOdcMax, fVerbose );
// label complete gates
- Vec_PtrForEachEntry( vCompletes, pGate, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vCompletes, pGate, i )
Aig_Regular(pGate)->fMarkA = 1;
// select only complete gates
vGates = Vec_VecStart( Saig_ManRegNum(pAig) );
- Vec_VecForEachEntry( vGatesAll, pGate, i, k )
+ Vec_VecForEachEntry( Aig_Obj_t *, vGatesAll, pGate, i, k )
if ( Aig_Regular(pGate)->fMarkA )
Vec_VecPush( vGates, i, pGate );
// unlabel complete gates
- Vec_PtrForEachEntry( vCompletes, pGate, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vCompletes, pGate, i )
Aig_Regular(pGate)->fMarkA = 0;
// count the number of gated flops
Vec_VecForEachLevel( vGates, vOne, i )
@@ -294,3 +297,5 @@ Vec_Vec_t * Cgt_ManDecideArea( Aig_Man_t * pAig, Vec_Vec_t * vGatesAll, int nOdc
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/cgt/cgtInt.h b/src/aig/cgt/cgtInt.h
index 3d9823c3..8cce2381 100644
--- a/src/aig/cgt/cgtInt.h
+++ b/src/aig/cgt/cgtInt.h
@@ -21,6 +21,7 @@
#ifndef __CGT_INT_H__
#define __CGT_INT_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -34,9 +35,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -106,9 +108,11 @@ extern void Cgt_ManStop( Cgt_Man_t * p );
/*=== cgtSat.c ==========================================================*/
extern int Cgt_CheckImplication( Cgt_Man_t * p, Aig_Obj_t * pGate, Aig_Obj_t * pFlop );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/aig/cgt/cgtMan.c b/src/aig/cgt/cgtMan.c
index ddc1c5e0..7744226d 100644
--- a/src/aig/cgt/cgtMan.c
+++ b/src/aig/cgt/cgtMan.c
@@ -20,6 +20,9 @@
#include "cgtInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -172,3 +175,5 @@ void Cgt_ManStop( Cgt_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/cgt/cgtSat.c b/src/aig/cgt/cgtSat.c
index 94168978..0a2a1daa 100644
--- a/src/aig/cgt/cgtSat.c
+++ b/src/aig/cgt/cgtSat.c
@@ -20,6 +20,9 @@
#include "cgtInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -90,3 +93,5 @@ p->timeSatUndec += clock() - clk;
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/cnf/cnf.h b/src/aig/cnf/cnf.h
index f7d1d38c..7c3bf06b 100644
--- a/src/aig/cnf/cnf.h
+++ b/src/aig/cnf/cnf.h
@@ -21,6 +21,7 @@
#ifndef __CNF_H__
#define __CNF_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -39,9 +40,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -97,7 +99,7 @@ static inline int Cnf_CutLeaveNum( Cnf_Cut_t * pCut ) { return pCut-
static inline int * Cnf_CutLeaves( Cnf_Cut_t * pCut ) { return pCut->pFanins; }
static inline unsigned * Cnf_CutTruth( Cnf_Cut_t * pCut ) { return (unsigned *)(pCut->pFanins + pCut->nFanins); }
-static inline Cnf_Cut_t * Cnf_ObjBestCut( Aig_Obj_t * pObj ) { return pObj->pData; }
+static inline Cnf_Cut_t * Cnf_ObjBestCut( Aig_Obj_t * pObj ) { return (Cnf_Cut_t *)pObj->pData; }
static inline void Cnf_ObjSetBestCut( Aig_Obj_t * pObj, Cnf_Cut_t * pCut ) { pObj->pData = pCut; }
////////////////////////////////////////////////////////////////////////
@@ -121,6 +123,7 @@ static inline void Cnf_ObjSetBestCut( Aig_Obj_t * pObj, Cnf_Cut_t * pCut
////////////////////////////////////////////////////////////////////////
/*=== cnfCore.c ========================================================*/
+extern Vec_Int_t * Cnf_DeriveMappingArray( Aig_Man_t * pAig );
extern Cnf_Dat_t * Cnf_Derive( Aig_Man_t * pAig, int nOutputs );
extern Cnf_Man_t * Cnf_ManRead();
extern void Cnf_ClearMemory();
@@ -147,6 +150,7 @@ extern void * Cnf_DataWriteIntoSolver( Cnf_Dat_t * p, int nFrames, int
extern int Cnf_DataWriteOrClause( void * pSat, Cnf_Dat_t * pCnf );
extern int Cnf_DataWriteAndClauses( void * p, Cnf_Dat_t * pCnf );
extern void Cnf_DataTranformPolarity( Cnf_Dat_t * pCnf, int fTransformPos );
+extern int Cnf_DataAddXorClause( void * pSat, int iVarA, int iVarB, int iVarC );
/*=== cnfMap.c ========================================================*/
extern void Cnf_DeriveMapping( Cnf_Man_t * p );
extern int Cnf_ManMapForCnf( Cnf_Man_t * p );
@@ -160,14 +164,17 @@ extern Vec_Ptr_t * Cnf_ManScanMapping( Cnf_Man_t * p, int fCollect, int fPre
extern Vec_Int_t * Cnf_DataCollectCiSatNums( Cnf_Dat_t * pCnf, Aig_Man_t * p );
extern Vec_Int_t * Cnf_DataCollectCoSatNums( Cnf_Dat_t * pCnf, Aig_Man_t * p );
/*=== cnfWrite.c ========================================================*/
+extern Vec_Int_t * Cnf_ManWriteCnfMapping( Cnf_Man_t * p, Vec_Ptr_t * vMapped );
extern void Cnf_SopConvertToVector( char * pSop, int nCubes, Vec_Int_t * vCover );
extern Cnf_Dat_t * Cnf_ManWriteCnf( Cnf_Man_t * p, Vec_Ptr_t * vMapped, int nOutputs );
extern Cnf_Dat_t * Cnf_DeriveSimple( Aig_Man_t * p, int nOutputs );
extern Cnf_Dat_t * Cnf_DeriveSimpleForRetiming( Aig_Man_t * p );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/aig/cnf/cnfCore.c b/src/aig/cnf/cnfCore.c
index 11a7af43..85c971c2 100644
--- a/src/aig/cnf/cnfCore.c
+++ b/src/aig/cnf/cnfCore.c
@@ -20,6 +20,9 @@
#include "cnf.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -41,6 +44,59 @@ static Cnf_Man_t * s_pManCnf = NULL;
SeeAlso []
***********************************************************************/
+Vec_Int_t * Cnf_DeriveMappingArray( Aig_Man_t * pAig )
+{
+ Vec_Int_t * vResult;
+ Cnf_Man_t * p;
+ Vec_Ptr_t * vMapped;
+ Aig_MmFixed_t * pMemCuts;
+ int clk;
+ // allocate the CNF manager
+ if ( s_pManCnf == NULL )
+ s_pManCnf = Cnf_ManStart();
+ // connect the managers
+ p = s_pManCnf;
+ p->pManAig = pAig;
+
+ // generate cuts for all nodes, assign cost, and find best cuts
+clk = clock();
+ pMemCuts = Dar_ManComputeCuts( pAig, 10, 0 );
+p->timeCuts = clock() - clk;
+
+ // find the mapping
+clk = clock();
+ Cnf_DeriveMapping( p );
+p->timeMap = clock() - clk;
+// Aig_ManScanMapping( p, 1 );
+
+ // convert it into CNF
+clk = clock();
+ Cnf_ManTransferCuts( p );
+ vMapped = Cnf_ManScanMapping( p, 1, 0 );
+ vResult = Cnf_ManWriteCnfMapping( p, vMapped );
+ Vec_PtrFree( vMapped );
+ Aig_MmFixedStop( pMemCuts, 0 );
+p->timeSave = clock() - clk;
+
+ // reset reference counters
+ Aig_ManResetRefs( pAig );
+//ABC_PRT( "Cuts ", p->timeCuts );
+//ABC_PRT( "Map ", p->timeMap );
+//ABC_PRT( "Saving ", p->timeSave );
+ return vResult;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Converts AIG into the SAT solver.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
Cnf_Dat_t * Cnf_Derive( Aig_Man_t * pAig, int nOutputs )
{
Cnf_Man_t * p;
@@ -183,3 +239,5 @@ ABC_PRT( "Ext ", clock() - clk );
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/cnf/cnfCut.c b/src/aig/cnf/cnfCut.c
index 17ab0c78..d41fc1fc 100644
--- a/src/aig/cnf/cnfCut.c
+++ b/src/aig/cnf/cnfCut.c
@@ -21,6 +21,9 @@
#include "cnf.h"
#include "kit.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -369,3 +372,5 @@ Cnf_Cut_t * Cnf_CutCompose( Cnf_Man_t * p, Cnf_Cut_t * pCut, Cnf_Cut_t * pCutFan
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/cnf/cnfData.c b/src/aig/cnf/cnfData.c
index 8df93fdb..e4798688 100644
--- a/src/aig/cnf/cnfData.c
+++ b/src/aig/cnf/cnfData.c
@@ -20,13 +20,16 @@
#include "cnf.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
-static char s_Data3[81] = "!#&()*+,-.0123456789:;<=>?ABCDEFGHIJKLMNOPQRSTUVWXYZ[]abcdefghijklmnopqrstuvwxyz|";
+static const char s_Data3[82] = "!#&()*+,-.0123456789:;<=>?ABCDEFGHIJKLMNOPQRSTUVWXYZ[]abcdefghijklmnopqrstuvwxyz|";
-static char * s_Data4[] = {
+static const char * s_Data4[] = {
"! B a . 8 .B 8a K !K T Ta j 8j Tj s ( + (B +a (. +8 .B( +8a (K +K T( +T j( ",
"+j Tj( s+ E !E H Ha E. 8E H. H8 EK EK! HT HTa jE 8jE Hj sH d +d Hd g d. 8d ",
"Hd. g8 dK +dK Td gT dj +jd Hjd gs 2 !2 2B a2 5 58 5B 5a 2K 2K! T2 Ta2 5j 58",
@@ -4782,3 +4785,5 @@ int Aig_ManDeriveCnfTest2()
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/cnf/cnfMan.c b/src/aig/cnf/cnfMan.c
index f8e88b8f..762673ad 100644
--- a/src/aig/cnf/cnfMan.c
+++ b/src/aig/cnf/cnfMan.c
@@ -22,6 +22,9 @@
#include "satSolver.h"
#include "zlib.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -422,7 +425,7 @@ void * Cnf_DataWriteIntoSolver( Cnf_Dat_t * p, int nFrames, int fInit )
***********************************************************************/
int Cnf_DataWriteOrClause( void * p, Cnf_Dat_t * pCnf )
{
- sat_solver * pSat = p;
+ sat_solver * pSat = (sat_solver *)p;
Aig_Obj_t * pObj;
int i, * pLits;
pLits = ABC_ALLOC( int, Aig_ManPoNum(pCnf->pMan) );
@@ -450,7 +453,7 @@ int Cnf_DataWriteOrClause( void * p, Cnf_Dat_t * pCnf )
***********************************************************************/
int Cnf_DataWriteAndClauses( void * p, Cnf_Dat_t * pCnf )
{
- sat_solver * pSat = p;
+ sat_solver * pSat = (sat_solver *)p;
Aig_Obj_t * pObj;
int i, Lit;
Aig_ManForEachPo( pCnf->pMan, pObj, i )
@@ -498,8 +501,53 @@ void Cnf_DataTranformPolarity( Cnf_Dat_t * pCnf, int fTransformPos )
ABC_FREE( pVarToPol );
}
+/**Function*************************************************************
+
+ Synopsis [Adds constraints for the two-input AND-gate.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Cnf_DataAddXorClause( void * pSat, int iVarA, int iVarB, int iVarC )
+{
+ lit Lits[3];
+ assert( iVarA > 0 && iVarB > 0 && iVarC > 0 );
+
+ Lits[0] = toLitCond( iVarA, 1 );
+ Lits[1] = toLitCond( iVarB, 1 );
+ Lits[2] = toLitCond( iVarC, 1 );
+ if ( !sat_solver_addclause( (sat_solver *)pSat, Lits, Lits + 3 ) )
+ return 0;
+
+ Lits[0] = toLitCond( iVarA, 1 );
+ Lits[1] = toLitCond( iVarB, 0 );
+ Lits[2] = toLitCond( iVarC, 0 );
+ if ( !sat_solver_addclause( (sat_solver *)pSat, Lits, Lits + 3 ) )
+ return 0;
+
+ Lits[0] = toLitCond( iVarA, 0 );
+ Lits[1] = toLitCond( iVarB, 1 );
+ Lits[2] = toLitCond( iVarC, 0 );
+ if ( !sat_solver_addclause( (sat_solver *)pSat, Lits, Lits + 3 ) )
+ return 0;
+
+ Lits[0] = toLitCond( iVarA, 0 );
+ Lits[1] = toLitCond( iVarB, 0 );
+ Lits[2] = toLitCond( iVarC, 1 );
+ if ( !sat_solver_addclause( (sat_solver *)pSat, Lits, Lits + 3 ) )
+ return 0;
+
+ return 1;
+}
+
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/cnf/cnfMap.c b/src/aig/cnf/cnfMap.c
index 58c9b803..8907485e 100644
--- a/src/aig/cnf/cnfMap.c
+++ b/src/aig/cnf/cnfMap.c
@@ -20,6 +20,9 @@
#include "cnf.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -72,7 +75,7 @@ int Cnf_CutSuperAreaFlow( Vec_Ptr_t * vSuper, int * pAreaFlows )
Aig_Obj_t * pLeaf;
int i, nAreaFlow;
nAreaFlow = 100 * (Vec_PtrSize(vSuper) + 1);
- Vec_PtrForEachEntry( vSuper, pLeaf, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vSuper, pLeaf, i )
{
pLeaf = Aig_Regular(pLeaf);
if ( !Aig_ObjIsNode(pLeaf) )
@@ -355,3 +358,5 @@ int Cnf_ManMapForCnf( Cnf_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/cnf/cnfPost.c b/src/aig/cnf/cnfPost.c
index 988275b2..f7491889 100644
--- a/src/aig/cnf/cnfPost.c
+++ b/src/aig/cnf/cnfPost.c
@@ -20,6 +20,9 @@
#include "cnf.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -143,7 +146,7 @@ void Cnf_ManFreeCuts( Cnf_Man_t * p )
Aig_ManForEachObj( p->pManAig, pObj, i )
if ( pObj->pData )
{
- Cnf_CutFree( pObj->pData );
+ Cnf_CutFree( (Cnf_Cut_t *)pObj->pData );
pObj->pData = NULL;
}
}
@@ -231,3 +234,5 @@ void Cnf_ManPostprocess( Cnf_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/cnf/cnfUtil.c b/src/aig/cnf/cnfUtil.c
index 7da9fb47..236b6bfa 100644
--- a/src/aig/cnf/cnfUtil.c
+++ b/src/aig/cnf/cnfUtil.c
@@ -20,6 +20,9 @@
#include "cnf.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -56,7 +59,7 @@ int Aig_ManScanMapping_rec( Cnf_Man_t * p, Aig_Obj_t * pObj, Vec_Ptr_t * vMapped
Vec_Ptr_t * vSuper = Vec_PtrAlloc( 100 );
Aig_ObjCollectSuper( pObj, vSuper );
aArea = Vec_PtrSize(vSuper) + 1;
- Vec_PtrForEachEntry( vSuper, pLeaf, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vSuper, pLeaf, i )
aArea += Aig_ManScanMapping_rec( p, Aig_Regular(pLeaf), vMapped );
Vec_PtrFree( vSuper );
////////////////////////////
@@ -131,7 +134,7 @@ int Cnf_ManScanMapping_rec( Cnf_Man_t * p, Aig_Obj_t * pObj, Vec_Ptr_t * vMapped
Vec_Ptr_t * vSuper = Vec_PtrAlloc( 100 );
Aig_ObjCollectSuper( pObj, vSuper );
aArea = Vec_PtrSize(vSuper) + 1;
- Vec_PtrForEachEntry( vSuper, pLeaf, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vSuper, pLeaf, i )
aArea += Cnf_ManScanMapping_rec( p, Aig_Regular(pLeaf), vMapped, fPreorder );
Vec_PtrFree( vSuper );
////////////////////////////
@@ -139,7 +142,7 @@ int Cnf_ManScanMapping_rec( Cnf_Man_t * p, Aig_Obj_t * pObj, Vec_Ptr_t * vMapped
}
else
{
- pCutBest = pObj->pData;
+ pCutBest = (Cnf_Cut_t *)pObj->pData;
// assert( pCutBest->nFanins > 0 );
assert( pCutBest->Cost < 127 );
aArea = pCutBest->Cost;
@@ -231,3 +234,5 @@ Vec_Int_t * Cnf_DataCollectCoSatNums( Cnf_Dat_t * pCnf, Aig_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/cnf/cnfWrite.c b/src/aig/cnf/cnfWrite.c
index 638e67da..4f737305 100644
--- a/src/aig/cnf/cnfWrite.c
+++ b/src/aig/cnf/cnfWrite.c
@@ -20,6 +20,9 @@
#include "cnf.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -30,6 +33,43 @@
/**Function*************************************************************
+ Synopsis [Derives CNF mapping.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Cnf_ManWriteCnfMapping( Cnf_Man_t * p, Vec_Ptr_t * vMapped )
+{
+ Vec_Int_t * vResult;
+ Aig_Obj_t * pObj;
+ Cnf_Cut_t * pCut;
+ int i, k, nOffset;
+ nOffset = Aig_ManObjNumMax(p->pManAig);
+ vResult = Vec_IntStart( nOffset );
+ Vec_PtrForEachEntry( Aig_Obj_t *, vMapped, pObj, i )
+ {
+ assert( Aig_ObjIsNode(pObj) );
+ pCut = Cnf_ObjBestCut( pObj );
+ assert( pCut->nFanins < 5 );
+ Vec_IntWriteEntry( vResult, Aig_ObjId(pObj), nOffset );
+ Vec_IntPush( vResult, *Cnf_CutTruth(pCut) );
+ for ( k = 0; k < pCut->nFanins; k++ )
+ Vec_IntPush( vResult, pCut->pFanins[k] );
+ for ( ; k < 4; k++ )
+ Vec_IntPush( vResult, -1 );
+ nOffset += 5;
+ }
+ return vResult;
+}
+
+
+
+/**Function*************************************************************
+
Synopsis [Writes the cover into the array.]
Description []
@@ -169,7 +209,7 @@ Cnf_Dat_t * Cnf_ManWriteCnf( Cnf_Man_t * p, Vec_Ptr_t * vMapped, int nOutputs )
// count the number of literals and clauses
nLiterals = 1 + Aig_ManPoNum( p->pManAig ) + 3 * nOutputs;
nClauses = 1 + Aig_ManPoNum( p->pManAig ) + nOutputs;
- Vec_PtrForEachEntry( vMapped, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vMapped, pObj, i )
{
assert( Aig_ObjIsNode(pObj) );
pCut = Cnf_ObjBestCut( pObj );
@@ -237,7 +277,7 @@ Cnf_Dat_t * Cnf_ManWriteCnf( Cnf_Man_t * p, Vec_Ptr_t * vMapped, int nOutputs )
}
}
// assign variables to the internal nodes
- Vec_PtrForEachEntry( vMapped, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vMapped, pObj, i )
pCnf->pVarNums[pObj->Id] = Number++;
// assign variables to the PIs and constant node
Aig_ManForEachPi( p->pManAig, pObj, i )
@@ -249,7 +289,7 @@ Cnf_Dat_t * Cnf_ManWriteCnf( Cnf_Man_t * p, Vec_Ptr_t * vMapped, int nOutputs )
vSopTemp = Vec_IntAlloc( 1 << 16 );
pLits = pCnf->pClauses[0];
pClas = pCnf->pClauses;
- Vec_PtrForEachEntry( vMapped, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vMapped, pObj, i )
{
pCut = Cnf_ObjBestCut( pObj );
@@ -562,3 +602,5 @@ Cnf_Dat_t * Cnf_DeriveSimpleForRetiming( Aig_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/cnf/cnf_.c b/src/aig/cnf/cnf_.c
index 7c9ca499..acf75093 100644
--- a/src/aig/cnf/cnf_.c
+++ b/src/aig/cnf/cnf_.c
@@ -20,6 +20,9 @@
#include "cnf.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -46,3 +49,5 @@
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/csw/csw.h b/src/aig/csw/csw.h
index 3d704d5f..c1bf7a73 100644
--- a/src/aig/csw/csw.h
+++ b/src/aig/csw/csw.h
@@ -21,6 +21,7 @@
#ifndef __CSW_H__
#define __CSW_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -29,9 +30,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -53,9 +55,11 @@ extern "C" {
/*=== cnfCore.c ========================================================*/
extern Aig_Man_t * Csw_Sweep( Aig_Man_t * pAig, int nCutsMax, int nLeafMax, int fVerbose );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/aig/csw/cswCore.c b/src/aig/csw/cswCore.c
index 20893058..e1bdca00 100644
--- a/src/aig/csw/cswCore.c
+++ b/src/aig/csw/cswCore.c
@@ -20,6 +20,9 @@
#include "cswInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -92,3 +95,5 @@ p->timeOther = p->timeTotal - p->timeCuts - p->timeHash;
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/csw/cswCut.c b/src/aig/csw/cswCut.c
index 14cc3e4c..bb6677c2 100644
--- a/src/aig/csw/cswCut.c
+++ b/src/aig/csw/cswCut.c
@@ -20,6 +20,9 @@
#include "cswInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -78,7 +81,7 @@ static inline float Csw_CutFindCost2( Csw_Man_t * p, Csw_Cut_t * pCut )
/**Function*************************************************************
- Synopsis [Returns the next ABC_FREE cut to use.]
+ Synopsis [Returns the next free cut to use.]
Description []
@@ -600,3 +603,5 @@ p->timeHash += clock() - clk;
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/csw/cswInt.h b/src/aig/csw/cswInt.h
index 76c673a3..3a06f3f1 100644
--- a/src/aig/csw/cswInt.h
+++ b/src/aig/csw/cswInt.h
@@ -21,6 +21,7 @@
#ifndef __CSW_INT_H__
#define __CSW_INT_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -40,9 +41,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -145,9 +147,11 @@ extern int Csw_TableCountCuts( Csw_Man_t * p );
extern void Csw_TableCutInsert( Csw_Man_t * p, Csw_Cut_t * pCut );
extern Aig_Obj_t * Csw_TableCutLookup( Csw_Man_t * p, Csw_Cut_t * pCut );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/aig/csw/cswMan.c b/src/aig/csw/cswMan.c
index 4225402c..8b6e538b 100644
--- a/src/aig/csw/cswMan.c
+++ b/src/aig/csw/cswMan.c
@@ -20,6 +20,9 @@
#include "cswInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -123,3 +126,5 @@ void Csw_ManStop( Csw_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/csw/cswTable.c b/src/aig/csw/cswTable.c
index 87e36ae1..9bab0a01 100644
--- a/src/aig/csw/cswTable.c
+++ b/src/aig/csw/cswTable.c
@@ -20,6 +20,9 @@
#include "cswInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -159,3 +162,5 @@ Aig_Obj_t * Csw_TableCutLookup( Csw_Man_t * p, Csw_Cut_t * pCut )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/csw/csw_.c b/src/aig/csw/csw_.c
index 1c59f152..c12607d3 100644
--- a/src/aig/csw/csw_.c
+++ b/src/aig/csw/csw_.c
@@ -20,6 +20,9 @@
#include "cswInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -46,3 +49,5 @@
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/dar/dar.h b/src/aig/dar/dar.h
index 86f43a9e..0a3b5eb7 100644
--- a/src/aig/dar/dar.h
+++ b/src/aig/dar/dar.h
@@ -21,6 +21,7 @@
#ifndef __DAR_H__
#define __DAR_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -29,9 +30,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -80,6 +82,8 @@ struct Dar_RefPar_t_
/*=== darLib.c ========================================================*/
extern void Dar_LibStart();
extern void Dar_LibStop();
+extern void Dar_LibPrepare( int nSubgraphs );
+extern int Dar_LibReturnClass( unsigned uTruth );
/*=== darBalance.c ========================================================*/
extern Aig_Man_t * Dar_ManBalance( Aig_Man_t * p, int fUpdateLevel );
extern Aig_Man_t * Dar_ManBalanceXor( Aig_Man_t * pAig, int fExor, int fUpdateLevel, int fVerbose );
@@ -98,9 +102,11 @@ extern Aig_Man_t * Dar_ManCompress( Aig_Man_t * pAig, int fBalance, int fUpd
extern Aig_Man_t * Dar_ManCompress2( Aig_Man_t * pAig, int fBalance, int fUpdateLevel, int fFanout, int fPower, int fVerbose );
extern Aig_Man_t * Dar_ManChoice( Aig_Man_t * pAig, int fBalance, int fUpdateLevel, int fConstruct, int nConfMax, int nLevelMax, int fVerbose );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/aig/dar/darBalance.c b/src/aig/dar/darBalance.c
index 35da7fe2..3bfcbdaa 100644
--- a/src/aig/dar/darBalance.c
+++ b/src/aig/dar/darBalance.c
@@ -21,6 +21,9 @@
#include "darInt.h"
#include "tim.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -107,13 +110,13 @@ Vec_Ptr_t * Dar_BalanceCone( Aig_Obj_t * pObj, Vec_Vec_t * vStore, int Level )
if ( Vec_VecSize( vStore ) <= Level )
Vec_VecPush( vStore, Level, 0 );
// get the temporary array of nodes
- vNodes = Vec_VecEntry( vStore, Level );
+ vNodes = (Vec_Ptr_t *)Vec_VecEntry( vStore, Level );
Vec_PtrClear( vNodes );
// collect the nodes in the implication supergate
RetValue = Dar_BalanceCone_rec( pObj, pObj, vNodes );
assert( vNodes->nSize > 1 );
// unmark the visited nodes
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, 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)
@@ -146,19 +149,19 @@ int Dar_BalanceFindLeft( Vec_Ptr_t * vSuper )
return 0;
// set the pointer to the one before the last
Current = Vec_PtrSize(vSuper) - 2;
- pObjRight = Vec_PtrEntry( vSuper, Current );
+ pObjRight = (Aig_Obj_t *)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 );
+ pObjLeft = (Aig_Obj_t *)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 );
+ pObjLeft = (Aig_Obj_t *)Vec_PtrEntry( vSuper, Current );
assert( Aig_ObjLevel(Aig_Regular(pObjLeft)) == Aig_ObjLevel(Aig_Regular(pObjRight)) );
return Current;
}
@@ -185,14 +188,14 @@ void Dar_BalancePermute( Aig_Man_t * p, Vec_Ptr_t * vSuper, int LeftBound, int f
if ( LeftBound == RightBound )
return;
// get the two last nodes
- pObj1 = Vec_PtrEntry( vSuper, RightBound + 1 );
- pObj2 = Vec_PtrEntry( vSuper, RightBound );
+ pObj1 = (Aig_Obj_t *)Vec_PtrEntry( vSuper, RightBound + 1 );
+ pObj2 = (Aig_Obj_t *)Vec_PtrEntry( vSuper, RightBound );
if ( Aig_Regular(pObj1) == p->pConst1 || Aig_Regular(pObj2) == p->pConst1 || Aig_Regular(pObj1) == Aig_Regular(pObj2) )
return;
// find the first node that can be shared
for ( i = RightBound; i >= LeftBound; i-- )
{
- pObj3 = Vec_PtrEntry( vSuper, i );
+ pObj3 = (Aig_Obj_t *)Vec_PtrEntry( vSuper, i );
if ( Aig_Regular(pObj3) == p->pConst1 )
{
Vec_PtrWriteEntry( vSuper, i, pObj2 );
@@ -271,8 +274,8 @@ void Dar_BalancePushUniqueOrderByLevel( Vec_Ptr_t * vStore, Aig_Obj_t * pObj )
// find the p of the node
for ( i = vStore->nSize-1; i > 0; i-- )
{
- pObj1 = vStore->pArray[i ];
- pObj2 = vStore->pArray[i-1];
+ pObj1 = (Aig_Obj_t *)vStore->pArray[i ];
+ pObj2 = (Aig_Obj_t *)vStore->pArray[i-1];
if ( Aig_ObjLevel(Aig_Regular(pObj1)) <= Aig_ObjLevel(Aig_Regular(pObj2)) )
break;
vStore->pArray[i ] = pObj2;
@@ -297,7 +300,7 @@ Aig_Obj_t * Dar_BalanceBuildSuper( Aig_Man_t * p, Vec_Ptr_t * vSuper, Aig_Type_t
int LeftBound;
assert( vSuper->nSize > 1 );
// sort the new nodes by level in the decreasing order
- Vec_PtrSort( vSuper, Aig_NodeCompareLevelsDecrease );
+ Vec_PtrSort( vSuper, (int (*)(void))Aig_NodeCompareLevelsDecrease );
// balance the nodes
while ( vSuper->nSize > 1 )
{
@@ -306,11 +309,11 @@ Aig_Obj_t * Dar_BalanceBuildSuper( Aig_Man_t * p, Vec_Ptr_t * vSuper, Aig_Type_t
// find the node that can be shared (if no such node, randomize choice)
Dar_BalancePermute( p, vSuper, LeftBound, Type == AIG_OBJ_EXOR );
// pull out the last two nodes
- pObj1 = Vec_PtrPop(vSuper);
- pObj2 = Vec_PtrPop(vSuper);
+ pObj1 = (Aig_Obj_t *)Vec_PtrPop(vSuper);
+ pObj2 = (Aig_Obj_t *)Vec_PtrPop(vSuper);
Dar_BalancePushUniqueOrderByLevel( vSuper, Aig_Oper(p, pObj1, pObj2, Type) );
}
- return Vec_PtrEntry(vSuper, 0);
+ return (Aig_Obj_t *)Vec_PtrEntry(vSuper, 0);
}
/**Function*************************************************************
@@ -333,20 +336,20 @@ Aig_Obj_t * Dar_Balance_rec( Aig_Man_t * pNew, Aig_Obj_t * pObjOld, Vec_Vec_t *
assert( !Aig_ObjIsBuf(pObjOld) );
// return if the result is known
if ( pObjOld->pData )
- return pObjOld->pData;
+ return (Aig_Obj_t *)pObjOld->pData;
assert( Aig_ObjIsNode(pObjOld) );
// get the implication supergate
vSuper = Dar_BalanceCone( pObjOld, vStore, Level );
// check if supergate contains two nodes in the opposite polarity
if ( vSuper->nSize == 0 )
- return pObjOld->pData = Aig_ManConst0(pNew);
+ return (Aig_Obj_t *)(pObjOld->pData = Aig_ManConst0(pNew));
if ( Vec_PtrSize(vSuper) < 2 )
printf( "Dar_Balance_rec: Internal error!\n" );
// for each old node, derive the new well-balanced node
for ( i = 0; i < Vec_PtrSize(vSuper); i++ )
{
- pObjNew = Dar_Balance_rec( pNew, Aig_Regular(vSuper->pArray[i]), vStore, Level + 1, fUpdateLevel );
- vSuper->pArray[i] = Aig_NotCond( pObjNew, Aig_IsComplement(vSuper->pArray[i]) );
+ pObjNew = Dar_Balance_rec( pNew, Aig_Regular((Aig_Obj_t *)vSuper->pArray[i]), vStore, Level + 1, fUpdateLevel );
+ vSuper->pArray[i] = Aig_NotCond( pObjNew, Aig_IsComplement((Aig_Obj_t *)vSuper->pArray[i]) );
}
// build the supergate
pObjNew = Dar_BalanceBuildSuper( pNew, vSuper, Aig_ObjType(pObjOld), fUpdateLevel );
@@ -366,7 +369,7 @@ Aig_Obj_t * Dar_Balance_rec( Aig_Man_t * pNew, Aig_Obj_t * pObjOld, Vec_Vec_t *
}
else
Aig_Regular(pObjNew)->pHaig = pObjOld->pHaig;
- return pObjOld->pData = pObjNew;
+ return (Aig_Obj_t *)(pObjOld->pData = pObjNew);
}
/**Function*************************************************************
@@ -392,6 +395,7 @@ Aig_Man_t * Dar_ManBalance( Aig_Man_t * p, int fUpdateLevel )
pNew->pName = Aig_UtilStrsav( p->pName );
pNew->pSpec = Aig_UtilStrsav( p->pSpec );
pNew->nAsserts = p->nAsserts;
+ pNew->nConstrs = p->nConstrs;
if ( p->vFlopNums )
pNew->vFlopNums = Vec_IntDup( p->vFlopNums );
// pass the HAIG manager
@@ -407,7 +411,7 @@ Aig_Man_t * Dar_ManBalance( Aig_Man_t * p, int fUpdateLevel )
if ( p->pManTime != NULL )
{
float arrTime;
- Tim_ManIncrementTravId( p->pManTime );
+ Tim_ManIncrementTravId( (Tim_Man_t *)p->pManTime );
Aig_ManSetPioNumbers( p );
Aig_ManForEachObj( p, pObj, i )
{
@@ -420,7 +424,7 @@ Aig_Man_t * Dar_ManBalance( Aig_Man_t * p, int fUpdateLevel )
pObj->pData = pObjNew;
pObjNew->pHaig = pObj->pHaig;
// set the arrival time of the new PI
- arrTime = Tim_ManGetCiArrival( p->pManTime, Aig_ObjPioNum(pObj) );
+ arrTime = Tim_ManGetCiArrival( (Tim_Man_t *)p->pManTime, Aig_ObjPioNum(pObj) );
pObjNew->Level = (int)arrTime;
}
else if ( Aig_ObjIsPo(pObj) )
@@ -431,7 +435,7 @@ Aig_Man_t * Dar_ManBalance( Aig_Man_t * p, int fUpdateLevel )
pObjNew = Aig_NotCond( pObjNew, Aig_IsComplement(pDriver) );
// save arrival time of the output
arrTime = (float)Aig_Regular(pObjNew)->Level;
- Tim_ManSetCoArrival( p->pManTime, Aig_ObjPioNum(pObj), arrTime );
+ Tim_ManSetCoArrival( (Tim_Man_t *)p->pManTime, Aig_ObjPioNum(pObj), arrTime );
// create PO
pObjNew = Aig_ObjCreatePo( pNew, pObjNew );
pObjNew->pHaig = pObj->pHaig;
@@ -440,7 +444,7 @@ Aig_Man_t * Dar_ManBalance( Aig_Man_t * p, int fUpdateLevel )
assert( 0 );
}
Aig_ManCleanPioNumbers( p );
- pNew->pManTime = Tim_ManDup( p->pManTime, 0 );
+ pNew->pManTime = Tim_ManDup( (Tim_Man_t *)p->pManTime, 0 );
}
else
{
@@ -534,12 +538,12 @@ void Dar_BalancePrintStats( Aig_Man_t * p )
continue;
Vec_PtrClear( vSuper );
Dar_BalanceCone_rec( pObj, pObj, vSuper );
- Vec_PtrForEachEntry( vSuper, pTemp, k )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vSuper, pTemp, k )
pTemp->fMarkB = 0;
if ( Vec_PtrSize(vSuper) < 3 )
continue;
printf( " %d(", Vec_PtrSize(vSuper) );
- Vec_PtrForEachEntry( vSuper, pTemp, k )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vSuper, pTemp, k )
printf( " %d", pTemp->Level );
printf( " )" );
}
@@ -554,3 +558,5 @@ void Dar_BalancePrintStats( Aig_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/dar/darCore.c b/src/aig/dar/darCore.c
index 83b6e08e..9811757c 100644
--- a/src/aig/dar/darCore.c
+++ b/src/aig/dar/darCore.c
@@ -20,6 +20,9 @@
#include "darInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -153,7 +156,13 @@ p->timeCuts += clock() - clk;
p->GainBest = -1;
Required = pAig->vLevelR? Aig_ObjRequiredLevel(pAig, pObj) : ABC_INFINITY;
Dar_ObjForEachCut( pObj, pCut, k )
+ {
+ int nLeavesOld = pCut->nLeaves;
+ if ( pCut->nLeaves == 3 )
+ pCut->pLeaves[pCut->nLeaves++] = 0;
Dar_LibEval( p, pObj, pCut, Required );
+ pCut->nLeaves = nLeavesOld;
+ }
// check the best gain
if ( !(p->GainBest > 0 || (p->GainBest == 0 && p->pPars->fUseZeros)) )
{
@@ -308,3 +317,5 @@ Aig_MmFixed_t * Dar_ManComputeCuts( Aig_Man_t * pAig, int nCutsMax, int fVerbose
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/dar/darCut.c b/src/aig/dar/darCut.c
index 7f7b1b4c..b272b388 100644
--- a/src/aig/dar/darCut.c
+++ b/src/aig/dar/darCut.c
@@ -20,6 +20,9 @@
#include "darInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -127,7 +130,7 @@ static inline int Dar_CutFindValue( Dar_Man_t * p, Dar_Cut_t * pCut )
/**Function*************************************************************
- Synopsis [Returns the next ABC_FREE cut to use.]
+ Synopsis [Returns the next free cut to use.]
Description [Uses the cut with the smallest value.]
@@ -628,7 +631,7 @@ void Dar_ManCutsRestart( Dar_Man_t * p, Aig_Obj_t * pRoot )
Aig_Obj_t * pObj;
int i;
Dar_ObjSetCuts( Aig_ManConst1(p->pAig), NULL );
- Vec_PtrForEachEntry( p->vCutNodes, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vCutNodes, pObj, i )
if ( !Aig_ObjIsNone(pObj) )
Dar_ObjSetCuts( pObj, NULL );
Vec_PtrClear( p->vCutNodes );
@@ -745,3 +748,5 @@ Dar_Cut_t * Dar_ObjComputeCuts_rec( Dar_Man_t * p, Aig_Obj_t * pObj )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/dar/darData.c b/src/aig/dar/darData.c
index e644c92b..17963c4a 100644
--- a/src/aig/dar/darData.c
+++ b/src/aig/dar/darData.c
@@ -20,6 +20,8 @@
#include "darInt.h"
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -11145,6 +11147,9 @@ Vec_Int_t * Dar_LibReadPrios()
#include "abc.h"
+ABC_NAMESPACE_IMPL_START
+
+
/**Function*************************************************************
Synopsis [Generate arrays.]
@@ -11285,3 +11290,5 @@ void Aig_NtkGenerateArrays( Abc_Ntk_t * pNtk )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/dar/darInt.h b/src/aig/dar/darInt.h
index 0f2e8894..70831534 100644
--- a/src/aig/dar/darInt.h
+++ b/src/aig/dar/darInt.h
@@ -21,6 +21,7 @@
#ifndef __DAR_INT_H__
#define __DAR_INT_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -40,9 +41,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -104,7 +106,7 @@ struct Dar_Man_t_
int time2;
};
-static inline Dar_Cut_t * Dar_ObjCuts( Aig_Obj_t * pObj ) { return pObj->pData; }
+static inline Dar_Cut_t * Dar_ObjCuts( Aig_Obj_t * pObj ) { return (Dar_Cut_t *)pObj->pData; }
static inline void Dar_ObjSetCuts( Aig_Obj_t * pObj, Dar_Cut_t * pCuts ) { assert( !Aig_ObjIsNone(pObj) ); pObj->pData = pCuts; }
////////////////////////////////////////////////////////////////////////
@@ -144,7 +146,6 @@ extern Vec_Int_t * Dar_LibReadPrios();
/*=== darLib.c ============================================================*/
extern void Dar_LibStart();
extern void Dar_LibStop();
-extern void Dar_LibPrepare( int nSubgraphs );
extern void Dar_LibReturnCanonicals( unsigned * pCanons );
extern void Dar_LibEval( Dar_Man_t * p, Aig_Obj_t * pRoot, Dar_Cut_t * pCut, int Required );
extern Aig_Obj_t * Dar_LibBuildBest( Dar_Man_t * p );
@@ -156,9 +157,11 @@ extern void Dar_ManPrintStats( Dar_Man_t * p );
extern char ** Dar_Permutations( int n );
extern void Dar_Truth4VarNPN( unsigned short ** puCanons, char ** puPhases, char ** puPerms, unsigned char ** puMap );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/aig/dar/darLib.c b/src/aig/dar/darLib.c
index 7f9188e0..52fd36b3 100644
--- a/src/aig/dar/darLib.c
+++ b/src/aig/dar/darLib.c
@@ -19,6 +19,11 @@
***********************************************************************/
#include "darInt.h"
+#include "gia.h"
+#include "dar.h"
+
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -41,7 +46,9 @@ struct Dar_LibObj_t_ // library object (2 words)
struct Dar_LibDat_t_ // library object data
{
+ union {
Aig_Obj_t * pFunc; // the corresponding AIG node if it exists
+ int iGunc; }; // the corresponding AIG node if it exists
int Level; // level of this node after it is constructured
int TravId; // traversal ID of the library object data
float dProb; // probability of the node being 1
@@ -184,6 +191,23 @@ void Dar_LibFree( Dar_Lib_t * p )
SeeAlso []
***********************************************************************/
+int Dar_LibReturnClass( unsigned uTruth )
+{
+ return s_DarLib->pMap[uTruth & 0xffff];
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Returns canonical truth tables.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
void Dar_LibReturnCanonicals( unsigned * pCanons )
{
int Visits[222] = {0};
@@ -1005,14 +1029,310 @@ Aig_Obj_t * Dar_LibBuildBest( Dar_Man_t * p )
{
int i, Counter = 4;
for ( i = 0; i < Vec_PtrSize(p->vLeavesBest); i++ )
- s_DarLib->pDatas[i].pFunc = Vec_PtrEntry( p->vLeavesBest, i );
+ s_DarLib->pDatas[i].pFunc = (Aig_Obj_t *)Vec_PtrEntry( p->vLeavesBest, i );
Dar_LibBuildClear_rec( Dar_LibObj(s_DarLib, p->OutBest), &Counter );
return Dar_LibBuildBest_rec( p, Dar_LibObj(s_DarLib, p->OutBest) );
}
+
+
+
+
+/**Function*************************************************************
+
+ Synopsis [Matches the cut with its canonical form.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Dar2_LibCutMatch( Gia_Man_t * p, Vec_Int_t * vCutLits, unsigned uTruth )
+{
+ unsigned uPhase;
+ char * pPerm;
+ int i;
+ assert( Vec_IntSize(vCutLits) == 4 );
+ // get the fanin permutation
+ uPhase = s_DarLib->pPhases[uTruth];
+ pPerm = s_DarLib->pPerms4[ (int)s_DarLib->pPerms[uTruth] ];
+ // collect fanins with the corresponding permutation/phase
+ for ( i = 0; i < Vec_IntSize(vCutLits); i++ )
+ {
+// pFanin = Gia_ManObj( p, pCut->pLeaves[ (int)pPerm[i] ] );
+// pFanin = Gia_ManObj( p, Vec_IntEntry( vCutLits, (int)pPerm[i] ) );
+// pFanin = Gia_ObjFromLit( p, Vec_IntEntry( vCutLits, (int)pPerm[i] ) );
+ s_DarLib->pDatas[i].iGunc = Gia_LitNotCond( Vec_IntEntry(vCutLits, (int)pPerm[i]), ((uPhase >> i) & 1) );
+ s_DarLib->pDatas[i].Level = Gia_ObjLevel( p, Gia_Regular(Gia_ObjFromLit(p, s_DarLib->pDatas[i].iGunc)) );
+ }
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Assigns numbers to the nodes of one class.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Dar2_LibEvalAssignNums( Gia_Man_t * p, int Class )
+{
+ Dar_LibObj_t * pObj;
+ Dar_LibDat_t * pData, * pData0, * pData1;
+ int iFanin0, iFanin1, i, iLit;
+ for ( i = 0; i < s_DarLib->nNodes0[Class]; i++ )
+ {
+ // get one class node, assign its temporary number and set its data
+ pObj = Dar_LibObj(s_DarLib, s_DarLib->pNodes0[Class][i]);
+ pObj->Num = 4 + i;
+ assert( (int)pObj->Num < s_DarLib->nNodes0Max + 4 );
+ pData = s_DarLib->pDatas + pObj->Num;
+ pData->fMffc = 0;
+ pData->iGunc = -1;
+ pData->TravId = 0xFFFF;
+
+ // explore the fanins
+ assert( (int)Dar_LibObj(s_DarLib, pObj->Fan0)->Num < s_DarLib->nNodes0Max + 4 );
+ assert( (int)Dar_LibObj(s_DarLib, pObj->Fan1)->Num < s_DarLib->nNodes0Max + 4 );
+ pData0 = s_DarLib->pDatas + Dar_LibObj(s_DarLib, pObj->Fan0)->Num;
+ pData1 = s_DarLib->pDatas + Dar_LibObj(s_DarLib, pObj->Fan1)->Num;
+ pData->Level = 1 + ABC_MAX(pData0->Level, pData1->Level);
+ if ( pData0->iGunc == -1 || pData1->iGunc == -1 )
+ continue;
+ iFanin0 = Gia_LitNotCond( pData0->iGunc, pObj->fCompl0 );
+ iFanin1 = Gia_LitNotCond( pData1->iGunc, pObj->fCompl1 );
+ // compute the resulting literal
+ if ( iFanin0 == 0 || iFanin1 == 0 || iFanin0 == Gia_LitNot(iFanin1) )
+ iLit = 0;
+ else if ( iFanin0 == 1 || iFanin0 == iFanin1 )
+ iLit = iFanin1;
+ else if ( iFanin1 == 1 )
+ iLit = iFanin0;
+ else
+ {
+ iLit = Gia_ManHashLookup( p, Gia_ObjFromLit(p, iFanin0), Gia_ObjFromLit(p, iFanin1) );
+ if ( iLit == 0 )
+ iLit = -1;
+ }
+ pData->iGunc = iLit;
+ if ( pData->iGunc >= 0 )
+ {
+ // update the level to be more accurate
+ pData->Level = Gia_ObjLevel( p, Gia_Regular(Gia_ObjFromLit(p, pData->iGunc)) );
+ // mark the node if it is part of MFFC
+// pData->fMffc = Gia_ObjIsTravIdCurrentArray(p, Gia_Regular(pData->pGunc));
+ }
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Evaluates one cut.]
+
+ Description [Returns the best gain.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Dar2_LibEval_rec( Dar_LibObj_t * pObj, int Out )
+{
+ Dar_LibDat_t * pData;
+ int Area;
+ pData = s_DarLib->pDatas + pObj->Num;
+ if ( pData->TravId == Out )
+ return 0;
+ pData->TravId = Out;
+ if ( pObj->fTerm )
+ return 0;
+ assert( pObj->Num > 3 );
+ if ( pData->iGunc >= 0 )//&& !pData->fMffc )
+ return 0;
+ // this is a new node - get a bound on the area of its branches
+// nNodesSaved--;
+ Area = Dar2_LibEval_rec( Dar_LibObj(s_DarLib, pObj->Fan0), Out );
+// if ( Area > nNodesSaved )
+// return 0xff;
+ Area += Dar2_LibEval_rec( Dar_LibObj(s_DarLib, pObj->Fan1), Out );
+// if ( Area > nNodesSaved )
+// return 0xff;
+ return Area + 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Evaluates one cut.]
+
+ Description [Returns the best gain.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Dar2_LibEval( Gia_Man_t * p, Vec_Int_t * vCutLits, unsigned uTruth, int fKeepLevel, Vec_Int_t * vLeavesBest2 )
+{
+ int p_OutBest = -1;
+ int p_OutNumBest = -1;
+ int p_LevelBest = 1000000;
+ int p_GainBest = -1000000;
+ int p_ClassBest = -1;
+ int fTraining = 0;
+ Dar_LibObj_t * pObj;
+ int Out, k, Class, nNodesSaved, nNodesAdded, nNodesGained, clk;
+ clk = clock();
+ assert( Vec_IntSize(vCutLits) == 4 );
+ assert( (uTruth >> 16) == 0 );
+ // check if the cut exits and assigns leaves and their levels
+ if ( !Dar2_LibCutMatch(p, vCutLits, uTruth) )
+ return -1;
+ // mark MFFC of the node
+// nNodesSaved = Dar2_LibCutMarkMffc( p->pAig, pRoot, pCut->nLeaves, p->pPars->fPower? &PowerSaved : NULL );
+ nNodesSaved = 0;
+ // evaluate the cut
+ Class = s_DarLib->pMap[uTruth];
+ Dar2_LibEvalAssignNums( p, Class );
+ // profile outputs by their savings
+// p->nTotalSubgs += s_DarLib->nSubgr0[Class];
+// p->ClassSubgs[Class] += s_DarLib->nSubgr0[Class];
+ for ( Out = 0; Out < s_DarLib->nSubgr0[Class]; Out++ )
+ {
+ pObj = Dar_LibObj(s_DarLib, s_DarLib->pSubgr0[Class][Out]);
+// nNodesAdded = Dar2_LibEval_rec( pObj, Out, nNodesSaved - !p->pPars->fUseZeros, Required, p->pPars->fPower? &PowerAdded : NULL );
+ nNodesAdded = Dar2_LibEval_rec( pObj, Out );
+ nNodesGained = nNodesSaved - nNodesAdded;
+ if ( fKeepLevel )
+ {
+ if ( s_DarLib->pDatas[pObj->Num].Level > p_LevelBest ||
+ (s_DarLib->pDatas[pObj->Num].Level == p_LevelBest && nNodesGained <= p_GainBest) )
+ continue;
+ }
+ else
+ {
+ if ( nNodesGained < p_GainBest ||
+ (nNodesGained == p_GainBest && s_DarLib->pDatas[pObj->Num].Level >= p_LevelBest) )
+ continue;
+ }
+ // remember this possibility
+ Vec_IntClear( vLeavesBest2 );
+ for ( k = 0; k < Vec_IntSize(vCutLits); k++ )
+ Vec_IntPush( vLeavesBest2, s_DarLib->pDatas[k].iGunc );
+ p_OutBest = s_DarLib->pSubgr0[Class][Out];
+ p_OutNumBest = Out;
+ p_LevelBest = s_DarLib->pDatas[pObj->Num].Level;
+ p_GainBest = nNodesGained;
+ p_ClassBest = Class;
+// assert( p_LevelBest <= Required );
+ }
+//clk = clock() - clk;
+//p->ClassTimes[Class] += clk;
+//p->timeEval += clk;
+ assert( p_OutBest != -1 );
+ return p_OutBest;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Clears the fields of the nodes used i this cut.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Dar2_LibBuildClear_rec( Dar_LibObj_t * pObj, int * pCounter )
+{
+ if ( pObj->fTerm )
+ return;
+ pObj->Num = (*pCounter)++;
+ s_DarLib->pDatas[ pObj->Num ].iGunc = -1;
+ Dar2_LibBuildClear_rec( Dar_LibObj(s_DarLib, pObj->Fan0), pCounter );
+ Dar2_LibBuildClear_rec( Dar_LibObj(s_DarLib, pObj->Fan1), pCounter );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Reconstructs the best cut.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Dar2_LibBuildBest_rec( Gia_Man_t * p, Dar_LibObj_t * pObj )
+{
+ Gia_Obj_t * pNode;
+ Dar_LibDat_t * pData;
+ int iFanin0, iFanin1;
+ pData = s_DarLib->pDatas + pObj->Num;
+ if ( pData->iGunc >= 0 )
+ return pData->iGunc;
+ iFanin0 = Dar2_LibBuildBest_rec( p, Dar_LibObj(s_DarLib, pObj->Fan0) );
+ iFanin1 = Dar2_LibBuildBest_rec( p, Dar_LibObj(s_DarLib, pObj->Fan1) );
+ iFanin0 = Gia_LitNotCond( iFanin0, pObj->fCompl0 );
+ iFanin1 = Gia_LitNotCond( iFanin1, pObj->fCompl1 );
+ pData->iGunc = Gia_ManHashAnd( p, iFanin0, iFanin1 );
+ pNode = Gia_ManObj( p, Gia_Lit2Var(pData->iGunc) );
+ if ( Gia_ObjIsAnd( pNode ) )
+ Gia_ObjSetAndLevel( p, pNode );
+ Gia_ObjSetPhase( pNode );
+ return pData->iGunc;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Reconstructs the best cut.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Dar2_LibBuildBest( Gia_Man_t * p, Vec_Int_t * vLeavesBest2, int OutBest )
+{
+ int i, iLeaf, Counter = 4;
+ assert( Vec_IntSize(vLeavesBest2) == 4 );
+ Vec_IntForEachEntry( vLeavesBest2, iLeaf, i )
+ s_DarLib->pDatas[i].iGunc = iLeaf;
+ Dar2_LibBuildClear_rec( Dar_LibObj(s_DarLib, OutBest), &Counter );
+ return Dar2_LibBuildBest_rec( p, Dar_LibObj(s_DarLib, OutBest) );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Evaluate and build the new node.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Dar_LibEvalBuild( Gia_Man_t * p, Vec_Int_t * vCutLits, unsigned uTruth, int fKeepLevel, Vec_Int_t * vLeavesBest2 )
+{
+ int OutBest = Dar2_LibEval( p, vCutLits, uTruth, fKeepLevel, vLeavesBest2 );
+ return Dar2_LibBuildBest( p, vLeavesBest2, OutBest );
+}
+
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/dar/darMan.c b/src/aig/dar/darMan.c
index b11d3175..59150103 100644
--- a/src/aig/dar/darMan.c
+++ b/src/aig/dar/darMan.c
@@ -20,6 +20,8 @@
#include "darInt.h"
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -127,9 +129,46 @@ void Dar_ManPrintStats( Dar_Man_t * p )
}
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+#if 0
+
+ABC_NAMESPACE_IMPL_END
+
+#include "kit.h"
+
+ABC_NAMESPACE_IMPL_START
+
+void Dar_ManPrintScript()
+{
+ unsigned pCanons[222];
+ int i;
+ Dar_LibReturnCanonicals( pCanons );
+ for ( i = 1; i < 222; i++ )
+ {
+ Kit_DsdNtk_t * pNtk;
+ pNtk = Kit_DsdDecompose( pCanons + i, 4 );
+ printf( " \"" );
+ Kit_DsdPrint( stdout, pNtk );
+ printf( "\", /* %3d */\n", i );
+ Kit_DsdNtkFree( pNtk );
+ }
+}
+#endif
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/dar/darPrec.c b/src/aig/dar/darPrec.c
index 85a31dfc..4d164123 100644
--- a/src/aig/dar/darPrec.c
+++ b/src/aig/dar/darPrec.c
@@ -20,6 +20,9 @@
#include "darInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -130,7 +133,7 @@ void Dar_Permutations_rec( char ** pRes, int nFact, int n, char Array[] )
Description [The number of permutations in the array is n!. The number of
entries in each permutation is n. Therefore, the resulting array is a
- two-dimentional array of the size: n! x n. To ABC_FREE the resulting array,
+ two-dimentional array of the size: n! x n. To free the resulting array,
call ABC_FREE() on the pointer returned by this procedure.]
SideEffects []
@@ -297,14 +300,10 @@ void Dar_Truth4VarNPN( unsigned short ** puCanons, char ** puPhases, char ** puP
int i, k;
nFuncs = (1 << 16);
- uCanons = ABC_ALLOC( unsigned short, nFuncs );
- uPhases = ABC_ALLOC( char, nFuncs );
- uPerms = ABC_ALLOC( char, nFuncs );
- uMap = ABC_ALLOC( unsigned char, nFuncs );
- memset( uCanons, 0, sizeof(unsigned short) * nFuncs );
- memset( uPhases, 0, sizeof(char) * nFuncs );
- memset( uPerms, 0, sizeof(char) * nFuncs );
- memset( uMap, 0, sizeof(unsigned char) * nFuncs );
+ uCanons = ABC_CALLOC( unsigned short, nFuncs );
+ uPhases = ABC_CALLOC( char, nFuncs );
+ uPerms = ABC_CALLOC( char, nFuncs );
+ uMap = ABC_CALLOC( unsigned char, nFuncs );
pPerms4 = Dar_Permutations( 4 );
nClasses = 1;
@@ -330,11 +329,13 @@ void Dar_Truth4VarNPN( unsigned short ** puCanons, char ** puPhases, char ** puP
uCanons[uPerm] = uTruth;
uPhases[uPerm] = i;
uPerms[uPerm] = k;
+ uMap[uPerm] = uMap[uTruth];
uPerm = ~uPerm & 0xFFFF;
uCanons[uPerm] = uTruth;
uPhases[uPerm] = i | 16;
uPerms[uPerm] = k;
+ uMap[uPerm] = uMap[uTruth];
}
else
assert( uCanons[uPerm] == uTruth );
@@ -348,17 +349,21 @@ void Dar_Truth4VarNPN( unsigned short ** puCanons, char ** puPhases, char ** puP
uCanons[uPerm] = uTruth;
uPhases[uPerm] = i;
uPerms[uPerm] = k;
+ uMap[uPerm] = uMap[uTruth];
uPerm = ~uPerm & 0xFFFF;
uCanons[uPerm] = uTruth;
uPhases[uPerm] = i | 16;
uPerms[uPerm] = k;
+ uMap[uPerm] = uMap[uTruth];
}
else
assert( uCanons[uPerm] == uTruth );
}
}
}
+ for ( uTruth = 1; uTruth < 0xffff; uTruth++ )
+ assert( uMap[uTruth] != 0 );
uPhases[(1<<16)-1] = 16;
assert( nClasses == 222 );
ABC_FREE( pPerms4 );
@@ -385,3 +390,5 @@ void Dar_Truth4VarNPN( unsigned short ** puCanons, char ** puPhases, char ** puP
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/dar/darRefact.c b/src/aig/dar/darRefact.c
index 5f6c5520..87e2d0da 100644
--- a/src/aig/dar/darRefact.c
+++ b/src/aig/dar/darRefact.c
@@ -24,6 +24,9 @@
#include "bdc.h"
#include "bdcInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -234,8 +237,8 @@ int Dar_RefactTryGraph( Aig_Man_t * pAig, Aig_Obj_t * pRoot, Vec_Ptr_t * vCut, K
Kit_GraphForEachLeaf( pGraph, pNode, i )
{
pNode->pFunc = Vec_PtrEntry(vCut, i);
- pNode->Level = Aig_Regular(pNode->pFunc)->Level;
- assert( Aig_Regular(pNode->pFunc)->Level < (1<<24)-1 );
+ pNode->Level = Aig_Regular((Aig_Obj_t *)pNode->pFunc)->Level;
+ assert( Aig_Regular((Aig_Obj_t *)pNode->pFunc)->Level < (1<<24)-1 );
}
//printf( "Trying:\n" );
// compute the AIG size after adding the internal nodes
@@ -246,8 +249,8 @@ int Dar_RefactTryGraph( Aig_Man_t * pAig, Aig_Obj_t * pRoot, Vec_Ptr_t * vCut, K
pNode0 = Kit_GraphNode( pGraph, pNode->eEdge0.Node );
pNode1 = Kit_GraphNode( pGraph, pNode->eEdge1.Node );
// get the AIG nodes corresponding to the children
- pAnd0 = pNode0->pFunc;
- pAnd1 = pNode1->pFunc;
+ pAnd0 = (Aig_Obj_t *)pNode0->pFunc;
+ pAnd1 = (Aig_Obj_t *)pNode1->pFunc;
if ( pAnd0 && pAnd1 )
{
// if they are both present, find the resulting node
@@ -320,13 +323,13 @@ Aig_Obj_t * Dar_RefactBuildGraph( Aig_Man_t * pAig, Vec_Ptr_t * vCut, Kit_Graph_
pNode->pFunc = Vec_PtrEntry(vCut, i);
// check for a literal
if ( Kit_GraphIsVar(pGraph) )
- return Aig_NotCond( Kit_GraphVar(pGraph)->pFunc, Kit_GraphIsComplement(pGraph) );
+ return Aig_NotCond( (Aig_Obj_t *)Kit_GraphVar(pGraph)->pFunc, Kit_GraphIsComplement(pGraph) );
// build the AIG nodes corresponding to the AND gates of the graph
//printf( "Building (current number %d):\n", Aig_ManObjNumMax(pAig) );
Kit_GraphForEachNode( pGraph, pNode, i )
{
- pAnd0 = Aig_NotCond( Kit_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl );
- pAnd1 = Aig_NotCond( Kit_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl );
+ pAnd0 = Aig_NotCond( (Aig_Obj_t *)Kit_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl );
+ pAnd1 = Aig_NotCond( (Aig_Obj_t *)Kit_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl );
pNode->pFunc = Aig_And( pAig, pAnd0, pAnd1 );
/*
printf( "Checking " );
@@ -339,7 +342,7 @@ printf( "\n" );
*/
}
// complement the result if necessary
- return Aig_NotCond( pNode->pFunc, Kit_GraphIsComplement(pGraph) );
+ return Aig_NotCond( (Aig_Obj_t *)pNode->pFunc, Kit_GraphIsComplement(pGraph) );
}
/**Function*************************************************************
@@ -473,7 +476,7 @@ int Dar_ObjCutLevelAchieved( Vec_Ptr_t * vCut, int nLevelMin )
{
Aig_Obj_t * pObj;
int i;
- Vec_PtrForEachEntry( vCut, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vCut, pObj, i )
if ( !Aig_ObjIsPi(pObj) && (int)pObj->Level <= nLevelMin )
return 1;
return 0;
@@ -510,8 +513,8 @@ int Dar_ManRefactor( Aig_Man_t * pAig, Dar_RefPar_t * pPars )
// resynthesize each node once
clkStart = clock();
- vCut = Vec_VecEntry( p->vCuts, 0 );
- vCut2 = Vec_VecEntry( p->vCuts, 1 );
+ vCut = (Vec_Ptr_t *)Vec_VecEntry( p->vCuts, 0 );
+ vCut2 = (Vec_Ptr_t *)Vec_VecEntry( p->vCuts, 1 );
p->nNodesInit = Aig_ManNodeNum(pAig);
nNodesOld = Vec_PtrSize( pAig->vObjs );
// pProgress = Bar_ProgressStart( stdout, nNodesOld );
@@ -629,3 +632,5 @@ p->timeOther = p->timeTotal - p->timeCuts - p->timeEval;
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/dar/darResub.c b/src/aig/dar/darResub.c
index f819934e..44367207 100644
--- a/src/aig/dar/darResub.c
+++ b/src/aig/dar/darResub.c
@@ -20,6 +20,9 @@
#include "darInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -46,3 +49,5 @@
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/dar/darScript.c b/src/aig/dar/darScript.c
index 20f3e14a..0332f961 100644
--- a/src/aig/dar/darScript.c
+++ b/src/aig/dar/darScript.c
@@ -23,12 +23,13 @@
#include "gia.h"
#include "giaAig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
- extern void * Tim_ManDup( void * p, int fDiscrete );
-
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
@@ -83,10 +84,11 @@ Aig_Man_t * Dar_ManRwsat( Aig_Man_t * pAig, int fBalance, int fVerbose )
pParsRwr->fVerbose = fVerbose;
pParsRef->fVerbose = fVerbose;
-
+//printf( "1" );
pAig = Aig_ManDupDfs( pAig );
if ( fVerbose ) Aig_ManPrintStats( pAig );
+//printf( "2" );
// balance
if ( fBalance )
{
@@ -96,18 +98,21 @@ Aig_Man_t * Dar_ManRwsat( Aig_Man_t * pAig, int fBalance, int fVerbose )
}
//Aig_ManDumpBlif( pAig, "inter.blif", NULL, NULL );
+//printf( "3" );
// rewrite
Dar_ManRewrite( pAig, pParsRwr );
pAig = Aig_ManDupDfs( pTemp = pAig );
Aig_ManStop( pTemp );
if ( fVerbose ) Aig_ManPrintStats( pAig );
+//printf( "4" );
// refactor
Dar_ManRefactor( pAig, pParsRef );
pAig = Aig_ManDupDfs( pTemp = pAig );
Aig_ManStop( pTemp );
if ( fVerbose ) Aig_ManPrintStats( pAig );
+//printf( "5" );
// balance
if ( fBalance )
{
@@ -116,12 +121,14 @@ Aig_Man_t * Dar_ManRwsat( Aig_Man_t * pAig, int fBalance, int fVerbose )
if ( fVerbose ) Aig_ManPrintStats( pAig );
}
+//printf( "6" );
// rewrite
Dar_ManRewrite( pAig, pParsRwr );
pAig = Aig_ManDupDfs( pTemp = pAig );
Aig_ManStop( pTemp );
if ( fVerbose ) Aig_ManPrintStats( pAig );
+//printf( "7" );
return pAig;
}
@@ -369,7 +376,7 @@ Vec_Ptr_t * Dar_ManChoiceSynthesis( Aig_Man_t * pAig, int fBalance, int fUpdateL
Vec_PtrPush( vAigs, pAig );
//Aig_ManPrintStats( pAig );
- pAig = Vec_PtrEntry( vAigs, 1 );
+ pAig = (Aig_Man_t *)Vec_PtrEntry( vAigs, 1 );
Aig_ManForEachObj( pAig, pObj, i )
pObj->pHaig = pObj->pNext;
@@ -402,7 +409,7 @@ clk = clock();
// (it is also important when constructing choices)
if ( !fConstruct )
{
- pMan = Vec_PtrPop( vAigs );
+ pMan = (Aig_Man_t *)Vec_PtrPop( vAigs );
Vec_PtrPush( vAigs, Vec_PtrEntry(vAigs,0) );
Vec_PtrWriteEntry( vAigs, 0, pMan );
}
@@ -416,7 +423,7 @@ clk = clock();
pMan = Aig_ManChoiceConstructive( vAigs, fVerbose );
else
pMan = Aig_ManChoicePartitioned( vAigs, 300, nConfMax, nLevelMax, fVerbose );
- Vec_PtrForEachEntry( vAigs, pTemp, i )
+ Vec_PtrForEachEntry( Aig_Man_t *, vAigs, pTemp, i )
Aig_ManStop( pTemp );
Vec_PtrFree( vAigs );
if ( fVerbose )
@@ -430,81 +437,6 @@ ABC_PRT( "Choicing time ", clock() - clk );
/**Function*************************************************************
- Synopsis [Duplicates the AIG in the DFS order.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Dar_ManChoiceMiter_rec( Gia_Man_t * pNew, Gia_Man_t * p, Gia_Obj_t * pObj )
-{
- if ( ~pObj->Value )
- return pObj->Value;
- Dar_ManChoiceMiter_rec( pNew, p, Gia_ObjFanin0(pObj) );
- if ( Gia_ObjIsCo(pObj) )
- return pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
- Dar_ManChoiceMiter_rec( pNew, p, Gia_ObjFanin1(pObj) );
- return pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
-}
-
-/**Function*************************************************************
-
- Synopsis [Derives the miter of several AIGs for choice computation.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Gia_Man_t * Dar_ManChoiceMiter( Vec_Ptr_t * vGias )
-{
- Gia_Man_t * pNew, * pGia, * pGia0;
- int i, k, iNode, nNodes;
- // make sure they have equal parameters
- assert( Vec_PtrSize(vGias) > 0 );
- pGia0 = Vec_PtrEntry( vGias, 0 );
- Vec_PtrForEachEntry( vGias, pGia, i )
- {
- assert( Gia_ManCiNum(pGia) == Gia_ManCiNum(pGia0) );
- assert( Gia_ManCoNum(pGia) == Gia_ManCoNum(pGia0) );
- assert( Gia_ManRegNum(pGia) == Gia_ManRegNum(pGia0) );
- Gia_ManFillValue( pGia );
- Gia_ManConst0(pGia)->Value = 0;
- }
- // start the new manager
- pNew = Gia_ManStart( Vec_PtrSize(vGias) * Gia_ManObjNum(pGia0) );
- pNew->pName = Gia_UtilStrsav( pGia0->pName );
- // create new CIs and assign them to the old manager CIs
- for ( k = 0; k < Gia_ManCiNum(pGia0); k++ )
- {
- iNode = Gia_ManAppendCi(pNew);
- Vec_PtrForEachEntry( vGias, pGia, i )
- Gia_ManCi( pGia, k )->Value = iNode;
- }
- // create internal nodes
- Gia_ManHashAlloc( pNew );
- for ( k = 0; k < Gia_ManCoNum(pGia0); k++ )
- {
- Vec_PtrForEachEntry( vGias, pGia, i )
- Dar_ManChoiceMiter_rec( pNew, pGia, Gia_ManCo( pGia, k ) );
- }
- Gia_ManHashStop( pNew );
- // check the presence of dangling nodes
- nNodes = Gia_ManHasDandling( pNew );
- assert( nNodes == 0 );
- // finalize
- Gia_ManSetRegNum( pNew, Gia_ManRegNum(pGia0) );
- return pNew;
-}
-
-
-/**Function*************************************************************
-
Synopsis [Reproduces script "compress".]
Description []
@@ -606,9 +538,9 @@ Aig_Man_t * Dar_NewCompress2( Aig_Man_t * pAig, int fBalance, int fUpdateLevel,
{
// rewrite
//Dar_ManRewrite( pAig, pParsRwr );
- pParsRwr->fUpdateLevel = 0; // disable level update
+// pParsRwr->fUpdateLevel = 0; // disable level update // this change was requested in July and later disabled
Dar_ManRewrite( pAig, pParsRwr );
- pParsRwr->fUpdateLevel = fUpdateLevel; // reenable level update if needed
+// pParsRwr->fUpdateLevel = fUpdateLevel; // reenable level update if needed
pAig = Aig_ManDupDfs( pTemp = pAig );
Aig_ManStop( pTemp );
@@ -719,21 +651,21 @@ Gia_Man_t * Dar_NewChoiceSynthesis( Aig_Man_t * pAig, int fBalance, int fUpdateL
Aig_ManStop( pAig );
// swap around the first and the last
- pTemp = Vec_PtrPop( vGias );
+ pTemp = (Gia_Man_t *)Vec_PtrPop( vGias );
Vec_PtrPush( vGias, Vec_PtrEntry(vGias,0) );
Vec_PtrWriteEntry( vGias, 0, pTemp );
// Aig_Man_t * pAig;
// int i;
// printf( "Choicing will be performed with %d AIGs:\n", Vec_PtrSize(p->vAigs) );
-// Vec_PtrForEachEntry( p->vAigs, pAig, i )
+// Vec_PtrForEachEntry( Aig_Man_t *, p->vAigs, pAig, i )
// Aig_ManPrintStats( pAig );
// derive the miter
- pGia = Dar_ManChoiceMiter( vGias );
+ pGia = Gia_ManChoiceMiter( vGias );
// cleanup
- Vec_PtrForEachEntry( vGias, pTemp, i )
+ Vec_PtrForEachEntry( Gia_Man_t *, vGias, pTemp, i )
Gia_ManStop( pTemp );
Vec_PtrFree( vGias );
return pGia;
@@ -808,7 +740,7 @@ clk = clock();
pMan->pSpec = Aig_UtilStrsav( pTemp->pSpec );
// cleanup
- Vec_PtrForEachEntry( vAigs, pTemp, i )
+ Vec_PtrForEachEntry( Aig_Man_t *, vAigs, pTemp, i )
Aig_ManStop( pTemp );
Vec_PtrFree( vAigs );
@@ -834,7 +766,7 @@ if ( fVerbose )
***********************************************************************/
Aig_Man_t * Dar_ManChoiceNewAig( Aig_Man_t * pAig, Dch_Pars_t * pPars )
{
- extern Aig_Man_t * Dch_DeriveTotalAig( Vec_Ptr_t * vAigs );
+// extern Aig_Man_t * Dch_DeriveTotalAig( Vec_Ptr_t * vAigs );
extern Aig_Man_t * Dch_ComputeChoices( Aig_Man_t * pAig, Dch_Pars_t * pPars );
int fVerbose = pPars->fVerbose;
Aig_Man_t * pMan, * pTemp;
@@ -850,14 +782,14 @@ pPars->timeSynth = clock() - clk;
// swap the first and last network
// this should lead to the primary choice being "better" because of synthesis
// (it is also important when constructing choices)
- pMan = Vec_PtrPop( vAigs );
+ pMan = (Aig_Man_t *)Vec_PtrPop( vAigs );
Vec_PtrPush( vAigs, Vec_PtrEntry(vAigs,0) );
Vec_PtrWriteEntry( vAigs, 0, pMan );
// derive the total AIG
pMan = Dch_DeriveTotalAig( vAigs );
// cleanup
- Vec_PtrForEachEntry( vAigs, pTemp, i )
+ Vec_PtrForEachEntry( Aig_Man_t *, vAigs, pTemp, i )
Aig_ManStop( pTemp );
Vec_PtrFree( vAigs );
@@ -905,7 +837,7 @@ pPars->timeSynth = clock() - clk;
Aig_Man_t * Dar_ManChoiceNew( Aig_Man_t * pAig, Dch_Pars_t * pPars )
{
extern Aig_Man_t * Cec_ComputeChoices( Gia_Man_t * pGia, Dch_Pars_t * pPars );
- extern Aig_Man_t * Dch_DeriveTotalAig( Vec_Ptr_t * vAigs );
+// extern Aig_Man_t * Dch_DeriveTotalAig( Vec_Ptr_t * vAigs );
extern Aig_Man_t * Dch_ComputeChoices( Aig_Man_t * pAig, Dch_Pars_t * pPars );
int fVerbose = pPars->fVerbose;
Aig_Man_t * pMan, * pTemp;
@@ -922,7 +854,7 @@ Aig_Man_t * Dar_ManChoiceNew( Aig_Man_t * pAig, Dch_Pars_t * pPars )
// perform synthesis
clk = clock();
- pGia = Dar_NewChoiceSynthesis( Aig_ManDupDfs(pAig), 1, 1, pPars->fPower, pPars->fLightSynth, 0 );
+ pGia = Dar_NewChoiceSynthesis( Aig_ManDupDfs(pAig), 1, 1, pPars->fPower, pPars->fLightSynth, pPars->fVerbose );
pPars->timeSynth = clock() - clk;
// perform choice computation
@@ -963,3 +895,5 @@ pPars->timeSynth = clock() - clk;
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/dar/dar_.c b/src/aig/dar/dar_.c
index 12fd7d17..323abed2 100644
--- a/src/aig/dar/dar_.c
+++ b/src/aig/dar/dar_.c
@@ -20,6 +20,9 @@
#include "darInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -46,3 +49,5 @@
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/dch/dch.h b/src/aig/dch/dch.h
index 7271d256..69f340e5 100644
--- a/src/aig/dch/dch.h
+++ b/src/aig/dch/dch.h
@@ -21,6 +21,7 @@
#ifndef __DCH_H__
#define __DCH_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -29,9 +30,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -65,14 +67,20 @@ struct Dch_Pars_t_
/// FUNCTION DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
+/*=== dchAig.c ==========================================================*/
+extern Aig_Man_t * Dch_DeriveTotalAig( Vec_Ptr_t * vAigs );
/*=== dchCore.c ==========================================================*/
extern void Dch_ManSetDefaultParams( Dch_Pars_t * p );
+extern int Dch_ManReadVerbose( Dch_Pars_t * p );
extern Aig_Man_t * Dch_ComputeChoices( Aig_Man_t * pAig, Dch_Pars_t * pPars );
extern void Dch_ComputeEquivalences( Aig_Man_t * pAig, Dch_Pars_t * pPars );
+/*=== dchScript.c ==========================================================*/
+extern Aig_Man_t * Dar_ManChoiceNew( Aig_Man_t * pAig, Dch_Pars_t * pPars );
+
+
+ABC_NAMESPACE_HEADER_END
+
-#ifdef __cplusplus
-}
-#endif
#endif
diff --git a/src/aig/dch/dchAig.c b/src/aig/dch/dchAig.c
index d38a1304..91a00c63 100644
--- a/src/aig/dch/dchAig.c
+++ b/src/aig/dch/dchAig.c
@@ -20,6 +20,9 @@
#include "dchInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -67,8 +70,8 @@ Aig_Man_t * Dch_DeriveTotalAig( Vec_Ptr_t * vAigs )
assert( Vec_PtrSize(vAigs) > 0 );
// make sure they have the same number of PIs/POs
nNodes = 0;
- pAig = Vec_PtrEntry( vAigs, 0 );
- Vec_PtrForEachEntry( vAigs, pAig2, i )
+ pAig = (Aig_Man_t *)Vec_PtrEntry( vAigs, 0 );
+ Vec_PtrForEachEntry( Aig_Man_t *, vAigs, pAig2, i )
{
assert( Aig_ManPiNum(pAig) == Aig_ManPiNum(pAig2) );
assert( Aig_ManPoNum(pAig) == Aig_ManPoNum(pAig2) );
@@ -77,19 +80,19 @@ Aig_Man_t * Dch_DeriveTotalAig( Vec_Ptr_t * vAigs )
}
// map constant nodes
pAigTotal = Aig_ManStart( nNodes );
- Vec_PtrForEachEntry( vAigs, pAig2, k )
+ Vec_PtrForEachEntry( Aig_Man_t *, vAigs, pAig2, k )
Aig_ManConst1(pAig2)->pData = Aig_ManConst1(pAigTotal);
// map primary inputs
Aig_ManForEachPi( pAig, pObj, i )
{
pObjPi = Aig_ObjCreatePi( pAigTotal );
- Vec_PtrForEachEntry( vAigs, pAig2, k )
+ Vec_PtrForEachEntry( Aig_Man_t *, vAigs, pAig2, k )
Aig_ManPi( pAig2, i )->pData = pObjPi;
}
// construct the AIG in the order of POs
Aig_ManForEachPo( pAig, pObj, i )
{
- Vec_PtrForEachEntry( vAigs, pAig2, k )
+ Vec_PtrForEachEntry( Aig_Man_t *, vAigs, pAig2, k )
{
pObjPo = Aig_ManPo( pAig2, i );
Dch_DeriveTotalAig_rec( pAigTotal, Aig_ObjFanin0(pObjPo) );
@@ -112,3 +115,5 @@ Aig_Man_t * Dch_DeriveTotalAig( Vec_Ptr_t * vAigs )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/dch/dchChoice.c b/src/aig/dch/dchChoice.c
index 019f4ec4..c20d2974 100644
--- a/src/aig/dch/dchChoice.c
+++ b/src/aig/dch/dchChoice.c
@@ -20,6 +20,9 @@
#include "dchInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -204,8 +207,8 @@ void Dch_DeriveChoiceAigNode( Aig_Man_t * pAigNew, Aig_Man_t * pAigOld, Aig_Obj_
if ( pRepr == NULL )
return;
// get the corresponding new nodes
- pObjNew = Aig_Regular(pObj->pData);
- pReprNew = Aig_Regular(pRepr->pData);
+ pObjNew = Aig_Regular((Aig_Obj_t *)pObj->pData);
+ pReprNew = Aig_Regular((Aig_Obj_t *)pRepr->pData);
if ( pObjNew == pReprNew )
return;
// skip the earlier nodes
@@ -240,7 +243,7 @@ void Dch_DeriveChoiceAigNode( Aig_Man_t * pAigNew, Aig_Man_t * pAigOld, Aig_Obj_
SeeAlso []
***********************************************************************/
-Aig_Man_t * Dch_DeriveChoiceAig( Aig_Man_t * pAig )
+Aig_Man_t * Dch_DeriveChoiceAig_old( Aig_Man_t * pAig )
{
Aig_Man_t * pChoices, * pTemp;
Aig_Obj_t * pObj;
@@ -268,8 +271,70 @@ Aig_Man_t * Dch_DeriveChoiceAig( Aig_Man_t * pAig )
return pChoices;
}
+
+/**Function*************************************************************
+
+ Synopsis [Derives the AIG with choices from representatives.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Man_t * Dch_DeriveChoiceAigInt( Aig_Man_t * pAig )
+{
+ Aig_Man_t * pChoices;
+ Aig_Obj_t * pObj;
+ int i;
+ // start recording equivalences
+ pChoices = Aig_ManStart( Aig_ManObjNumMax(pAig) );
+ pChoices->pEquivs = ABC_CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(pAig) );
+ pChoices->pReprs = ABC_CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(pAig) );
+ // map constants and PIs
+ Aig_ManCleanData( pAig );
+ Aig_ManConst1(pAig)->pData = Aig_ManConst1(pChoices);
+ Aig_ManForEachPi( pAig, pObj, i )
+ pObj->pData = Aig_ObjCreatePi( pChoices );
+ // construct choices for the internal nodes
+ assert( pAig->pReprs != NULL );
+ Aig_ManForEachNode( pAig, pObj, i )
+ Dch_DeriveChoiceAigNode( pChoices, pAig, pObj );
+ Aig_ManForEachPo( pAig, pObj, i )
+ Aig_ObjCreatePo( pChoices, Aig_ObjChild0CopyRepr(pChoices, pObj) );
+ Dch_DeriveChoiceCountEquivs( pChoices );
+ return pChoices;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Derives the AIG with choices from representatives.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Man_t * Dch_DeriveChoiceAig( Aig_Man_t * pAig )
+{
+ Aig_Man_t * pChoices, * pTemp;
+ pChoices = Dch_DeriveChoiceAigInt( pAig );
+// pChoices = Dch_DeriveChoiceAigInt( pTemp = pChoices );
+// Aig_ManStop( pTemp );
+ // there is no need for cleanup
+ ABC_FREE( pChoices->pReprs );
+ pChoices = Aig_ManDupDfs( pTemp = pChoices );
+ Aig_ManStop( pTemp );
+ return pChoices;
+}
+
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/dch/dchClass.c b/src/aig/dch/dchClass.c
index 9f4bd68c..83a3bc2e 100644
--- a/src/aig/dch/dchClass.c
+++ b/src/aig/dch/dchClass.c
@@ -20,6 +20,9 @@
#include "dchInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*
The candidate equivalence classes are stored as a vector of pointers
to the array of pointers to the nodes in each class.
@@ -280,10 +283,10 @@ void Dch_ClassesPrintOne( Dch_Cla_t * p, Aig_Obj_t * pRepr )
{
Aig_Obj_t * pObj;
int i;
- printf( "{ " );
+ Abc_Print( 1, "{ " );
Dch_ClassForEachNode( p, pRepr, pObj, i )
- printf( "%d(%d,%d) ", pObj->Id, pObj->Level, Aig_SupportSize(p->pAig,pObj) );
- printf( "}\n" );
+ Abc_Print( 1, "%d(%d,%d) ", pObj->Id, pObj->Level, Aig_SupportSize(p->pAig,pObj) );
+ Abc_Print( 1, "}\n" );
}
/**Function*************************************************************
@@ -302,21 +305,21 @@ void Dch_ClassesPrint( Dch_Cla_t * p, int fVeryVerbose )
Aig_Obj_t ** ppClass;
Aig_Obj_t * pObj;
int i;
- printf( "Equivalence classes: Const1 = %5d. Class = %5d. Lit = %5d.\n",
+ Abc_Print( 1, "Equivalence classes: Const1 = %5d. Class = %5d. Lit = %5d.\n",
p->nCands1, p->nClasses, p->nLits );
if ( !fVeryVerbose )
return;
- printf( "Constants { " );
+ Abc_Print( 1, "Constants { " );
Aig_ManForEachObj( p->pAig, pObj, i )
if ( Dch_ObjIsConst1Cand( p->pAig, pObj ) )
- printf( "%d(%d,%d) ", pObj->Id, pObj->Level, Aig_SupportSize(p->pAig,pObj) );
- printf( "}\n" );
+ Abc_Print( 1, "%d(%d,%d) ", pObj->Id, pObj->Level, Aig_SupportSize(p->pAig,pObj) );
+ Abc_Print( 1, "}\n" );
Dch_ManForEachClass( p, ppClass, i )
{
- printf( "%3d (%3d) : ", i, p->pClassSizes[i] );
+ Abc_Print( 1, "%3d (%3d) : ", i, p->pClassSizes[i] );
Dch_ClassesPrintOne( p, ppClass[0] );
}
- printf( "\n" );
+ Abc_Print( 1, "\n" );
}
/**Function*************************************************************
@@ -456,20 +459,20 @@ int Dch_ClassesRefineOneClass( Dch_Cla_t * p, Aig_Obj_t * pReprOld, int fRecursi
return 0;
// get the new representative
- pReprNew = Vec_PtrEntry( p->vClassNew, 0 );
+ pReprNew = (Aig_Obj_t *)Vec_PtrEntry( p->vClassNew, 0 );
assert( Vec_PtrSize(p->vClassOld) > 0 );
assert( Vec_PtrSize(p->vClassNew) > 0 );
// create old class
pClassOld = Dch_ObjRemoveClass( p, pReprOld );
- Vec_PtrForEachEntry( p->vClassOld, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vClassOld, pObj, i )
{
pClassOld[i] = pObj;
Aig_ObjSetRepr( p->pAig, pObj, i? pReprOld : NULL );
}
// create new class
pClassNew = pClassOld + i;
- Vec_PtrForEachEntry( p->vClassNew, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vClassNew, pObj, i )
{
pClassNew[i] = pObj;
Aig_ObjSetRepr( p->pAig, pObj, i? pReprNew : NULL );
@@ -572,21 +575,21 @@ int Dch_ClassesRefineConst1Group( Dch_Cla_t * p, Vec_Ptr_t * vRoots, int fRecurs
return 0;
// collect the nodes to be refined
Vec_PtrClear( p->vClassNew );
- Vec_PtrForEachEntry( vRoots, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vRoots, pObj, i )
if ( !p->pFuncNodeIsConst( p->pManData, pObj ) )
Vec_PtrPush( p->vClassNew, pObj );
// check if there is a new class
if ( Vec_PtrSize(p->vClassNew) == 0 )
return 0;
p->nCands1 -= Vec_PtrSize(p->vClassNew);
- pReprNew = Vec_PtrEntry( p->vClassNew, 0 );
+ pReprNew = (Aig_Obj_t *)Vec_PtrEntry( p->vClassNew, 0 );
Aig_ObjSetRepr( p->pAig, pReprNew, NULL );
if ( Vec_PtrSize(p->vClassNew) == 1 )
return 1;
// create a new class composed of these nodes
ppClassNew = p->pMemClassesFree;
p->pMemClassesFree += Vec_PtrSize(p->vClassNew);
- Vec_PtrForEachEntry( p->vClassNew, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vClassNew, pObj, i )
{
ppClassNew[i] = pObj;
Aig_ObjSetRepr( p->pAig, pObj, i? pReprNew : NULL );
@@ -604,3 +607,5 @@ int Dch_ClassesRefineConst1Group( Dch_Cla_t * p, Vec_Ptr_t * vRoots, int fRecurs
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/dch/dchCnf.c b/src/aig/dch/dchCnf.c
index 81fc2f2c..4175a123 100644
--- a/src/aig/dch/dchCnf.c
+++ b/src/aig/dch/dchCnf.c
@@ -20,6 +20,9 @@
#include "dchInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -169,7 +172,7 @@ void Dch_AddClausesSuper( Dch_Man_t * p, Aig_Obj_t * pNode, Vec_Ptr_t * vSuper )
pLits = ABC_ALLOC( int, nLits );
// suppose AND-gate is A & B = C
// add !A => !C or A + !C
- Vec_PtrForEachEntry( vSuper, pFanin, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vSuper, pFanin, i )
{
pLits[0] = toLitCond(Dch_ObjSatNum(p,Aig_Regular(pFanin)), Aig_IsComplement(pFanin));
pLits[1] = toLitCond(Dch_ObjSatNum(p,pNode), 1);
@@ -182,7 +185,7 @@ void Dch_AddClausesSuper( Dch_Man_t * p, Aig_Obj_t * pNode, Vec_Ptr_t * vSuper )
assert( RetValue );
}
// add A & B => C or !A + !B + C
- Vec_PtrForEachEntry( vSuper, pFanin, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vSuper, pFanin, i )
{
pLits[i] = toLitCond(Dch_ObjSatNum(p,Aig_Regular(pFanin)), !Aig_IsComplement(pFanin));
if ( p->pPars->fPolarFlip )
@@ -293,7 +296,7 @@ void Dch_CnfNodeAddToSolver( Dch_Man_t * p, Aig_Obj_t * pObj )
vFrontier = Vec_PtrAlloc( 100 );
Dch_ObjAddToFrontier( p, pObj, vFrontier );
// explore nodes in the frontier
- Vec_PtrForEachEntry( vFrontier, pNode, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vFrontier, pNode, i )
{
// create the supergate
assert( Dch_ObjSatNum(p,pNode) );
@@ -304,14 +307,14 @@ void Dch_CnfNodeAddToSolver( Dch_Man_t * p, Aig_Obj_t * pObj )
Vec_PtrPushUnique( p->vFanins, Aig_ObjFanin0( Aig_ObjFanin1(pNode) ) );
Vec_PtrPushUnique( p->vFanins, Aig_ObjFanin1( Aig_ObjFanin0(pNode) ) );
Vec_PtrPushUnique( p->vFanins, Aig_ObjFanin1( Aig_ObjFanin1(pNode) ) );
- Vec_PtrForEachEntry( p->vFanins, pFanin, k )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vFanins, pFanin, k )
Dch_ObjAddToFrontier( p, Aig_Regular(pFanin), vFrontier );
Dch_AddClausesMux( p, pNode );
}
else
{
Dch_CollectSuper( pNode, fUseMuxes, p->vFanins );
- Vec_PtrForEachEntry( p->vFanins, pFanin, k )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vFanins, pFanin, k )
Dch_ObjAddToFrontier( p, Aig_Regular(pFanin), vFrontier );
Dch_AddClausesSuper( p, pNode, p->vFanins );
}
@@ -327,3 +330,5 @@ void Dch_CnfNodeAddToSolver( Dch_Man_t * p, Aig_Obj_t * pObj )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/dch/dchCore.c b/src/aig/dch/dchCore.c
index d38d5668..bc78682b 100644
--- a/src/aig/dch/dchCore.c
+++ b/src/aig/dch/dchCore.c
@@ -20,6 +20,9 @@
#include "dchInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -57,6 +60,22 @@ void Dch_ManSetDefaultParams( Dch_Pars_t * p )
/**Function*************************************************************
+ Synopsis [Returns verbose parameter.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Dch_ManReadVerbose( Dch_Pars_t * p )
+{
+ return p->fVerbose;
+}
+
+/**Function*************************************************************
+
Synopsis [Performs computation of AIGs with choices.]
Description [Takes several AIGs and performs choicing.]
@@ -91,7 +110,7 @@ p->timeTotal = clock() - clkTotal;
pResult = Dch_DeriveChoiceAig( pAig );
// count the number of representatives
if ( pPars->fVerbose )
- printf( "STATS: Reprs = %6d. Equivs = %6d. Choices = %6d.\n",
+ Abc_Print( 1, "STATS: Reprs = %6d. Equivs = %6d. Choices = %6d.\n",
Dch_DeriveChoiceCountReprs( pAig ),
Dch_DeriveChoiceCountEquivs( pResult ),
Aig_ManChoiceNum( pResult ) );
@@ -135,3 +154,5 @@ p->timeTotal = clock() - clkTotal;
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/dch/dchInt.h b/src/aig/dch/dchInt.h
index a419335d..6072d97b 100644
--- a/src/aig/dch/dchInt.h
+++ b/src/aig/dch/dchInt.h
@@ -21,6 +21,7 @@
#ifndef __DCH_INT_H__
#define __DCH_INT_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -33,9 +34,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -100,7 +102,7 @@ struct Dch_Man_t_
static inline int Dch_ObjSatNum( Dch_Man_t * p, Aig_Obj_t * pObj ) { return p->pSatVars[pObj->Id]; }
static inline void Dch_ObjSetSatNum( Dch_Man_t * p, Aig_Obj_t * pObj, int Num ) { p->pSatVars[pObj->Id] = Num; }
-static inline Aig_Obj_t * Dch_ObjFraig( Aig_Obj_t * pObj ) { return pObj->pData; }
+static inline Aig_Obj_t * Dch_ObjFraig( Aig_Obj_t * pObj ) { return (Aig_Obj_t *)pObj->pData; }
static inline void Dch_ObjSetFraig( Aig_Obj_t * pObj, Aig_Obj_t * pNode ) { pObj->pData = pNode; }
static inline int Dch_ObjIsConst1Cand( Aig_Man_t * pAig, Aig_Obj_t * pObj )
@@ -118,7 +120,6 @@ static inline void Dch_ObjSetConst1Cand( Aig_Man_t * pAig, Aig_Obj_t * pObj )
////////////////////////////////////////////////////////////////////////
/*=== dchAig.c ===================================================*/
-extern Aig_Man_t * Dch_DeriveTotalAig( Vec_Ptr_t * vAigs );
/*=== dchChoice.c ===================================================*/
extern int Dch_DeriveChoiceCountReprs( Aig_Man_t * pAig );
extern int Dch_DeriveChoiceCountEquivs( Aig_Man_t * pAig );
@@ -155,9 +156,11 @@ extern void Dch_ManResimulateCex2( Dch_Man_t * p, Aig_Obj_t * pObj, Aig
/*=== dchSweep.c ===================================================*/
extern void Dch_ManSweep( Dch_Man_t * p );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/aig/dch/dchMan.c b/src/aig/dch/dchMan.c
index c8bd8533..dc856309 100644
--- a/src/aig/dch/dchMan.c
+++ b/src/aig/dch/dchMan.c
@@ -20,6 +20,9 @@
#include "dchInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -74,34 +77,34 @@ Dch_Man_t * Dch_ManCreate( Aig_Man_t * pAig, Dch_Pars_t * pPars )
void Dch_ManPrintStats( Dch_Man_t * p )
{
int nNodeNum = Aig_ManNodeNum(p->pAigTotal) / 3;
- printf( "Parameters: Sim words = %d. Conf limit = %d. SAT var max = %d.\n",
+ Abc_Print( 1, "Parameters: Sim words = %d. Conf limit = %d. SAT var max = %d.\n",
p->pPars->nWords, p->pPars->nBTLimit, p->pPars->nSatVarMax );
- printf( "AIG nodes : Total = %6d. Dangling = %6d. Main = %6d. (%6.2f %%)\n",
+ Abc_Print( 1, "AIG nodes : Total = %6d. Dangling = %6d. Main = %6d. (%6.2f %%)\n",
Aig_ManNodeNum(p->pAigTotal),
Aig_ManNodeNum(p->pAigTotal)-nNodeNum,
nNodeNum,
100.0 * nNodeNum/Aig_ManNodeNum(p->pAigTotal) );
- printf( "SAT solver: Vars = %d. Max cone = %d. Recycles = %d.\n",
+ Abc_Print( 1, "SAT solver: Vars = %d. Max cone = %d. Recycles = %d.\n",
p->nSatVars, p->nConeMax, p->nRecycles );
- printf( "SAT calls : All = %6d. Unsat = %6d. Sat = %6d. Fail = %6d.\n",
+ Abc_Print( 1, "SAT calls : All = %6d. Unsat = %6d. Sat = %6d. Fail = %6d.\n",
p->nSatCalls, p->nSatCalls-p->nSatCallsSat-p->nSatFailsReal,
p->nSatCallsSat, p->nSatFailsReal );
- printf( "Choices : Lits = %6d. Reprs = %5d. Equivs = %5d. Choices = %5d.\n",
+ Abc_Print( 1, "Choices : Lits = %6d. Reprs = %5d. Equivs = %5d. Choices = %5d.\n",
p->nLits, p->nReprs, p->nEquivs, p->nChoices );
- printf( "Choicing runtime statistics:\n" );
+ Abc_Print( 1, "Choicing runtime statistics:\n" );
p->timeOther = p->timeTotal-p->timeSimInit-p->timeSimSat-p->timeSat-p->timeChoice;
- ABC_PRTP( "Sim init ", p->timeSimInit, p->timeTotal );
- ABC_PRTP( "Sim SAT ", p->timeSimSat, p->timeTotal );
- ABC_PRTP( "SAT solving", p->timeSat, p->timeTotal );
- ABC_PRTP( " sat ", p->timeSatSat, p->timeTotal );
- ABC_PRTP( " unsat ", p->timeSatUnsat, p->timeTotal );
- ABC_PRTP( " undecided", p->timeSatUndec, p->timeTotal );
- ABC_PRTP( "Choice ", p->timeChoice, p->timeTotal );
- ABC_PRTP( "Other ", p->timeOther, p->timeTotal );
- ABC_PRTP( "TOTAL ", p->timeTotal, p->timeTotal );
+ Abc_PrintTimeP( 1, "Sim init ", p->timeSimInit, p->timeTotal );
+ Abc_PrintTimeP( 1, "Sim SAT ", p->timeSimSat, p->timeTotal );
+ Abc_PrintTimeP( 1, "SAT solving", p->timeSat, p->timeTotal );
+ Abc_PrintTimeP( 1, " sat ", p->timeSatSat, p->timeTotal );
+ Abc_PrintTimeP( 1, " unsat ", p->timeSatUnsat, p->timeTotal );
+ Abc_PrintTimeP( 1, " undecided", p->timeSatUndec, p->timeTotal );
+ Abc_PrintTimeP( 1, "Choice ", p->timeChoice, p->timeTotal );
+ Abc_PrintTimeP( 1, "Other ", p->timeOther, p->timeTotal );
+ Abc_PrintTimeP( 1, "TOTAL ", p->timeTotal, p->timeTotal );
if ( p->pPars->timeSynth )
{
- ABC_PRT( "Synthesis ", p->pPars->timeSynth );
+ Abc_PrintTime( 1, "Synthesis ", p->pPars->timeSynth );
}
}
@@ -154,7 +157,7 @@ void Dch_ManSatSolverRecycle( Dch_Man_t * p )
{
Aig_Obj_t * pObj;
int i;
- Vec_PtrForEachEntry( p->vUsedNodes, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vUsedNodes, pObj, i )
Dch_ObjSetSatNum( p, pObj, 0 );
Vec_PtrClear( p->vUsedNodes );
// memset( p->pSatVars, 0, sizeof(int) * Aig_ManObjNumMax(p->pAigTotal) );
@@ -184,3 +187,5 @@ void Dch_ManSatSolverRecycle( Dch_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/dch/dchSat.c b/src/aig/dch/dchSat.c
index 6966e635..f5e346ef 100644
--- a/src/aig/dch/dchSat.c
+++ b/src/aig/dch/dchSat.c
@@ -20,6 +20,9 @@
#include "dchInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -159,3 +162,5 @@ p->timeSatUndec += clock() - clk;
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/dch/dchSim.c b/src/aig/dch/dchSim.c
index 44a96970..b2d24761 100644
--- a/src/aig/dch/dchSim.c
+++ b/src/aig/dch/dchSim.c
@@ -20,13 +20,16 @@
#include "dchInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
static inline unsigned * Dch_ObjSim( Vec_Ptr_t * vSims, Aig_Obj_t * pObj )
{
- return Vec_PtrEntry( vSims, pObj->Id );
+ return (unsigned *)Vec_PtrEntry( vSims, pObj->Id );
}
static inline unsigned Dch_ObjRandomSim()
{
@@ -82,7 +85,7 @@ int Dch_NodesAreEqualCex( void * p, Aig_Obj_t * pObj0, Aig_Obj_t * pObj1 )
***********************************************************************/
unsigned Dch_NodeHash( void * p, Aig_Obj_t * pObj )
{
- Vec_Ptr_t * vSims = p;
+ Vec_Ptr_t * vSims = (Vec_Ptr_t *)p;
static int s_FPrimes[128] = {
1009, 1049, 1093, 1151, 1201, 1249, 1297, 1361, 1427, 1459,
1499, 1559, 1607, 1657, 1709, 1759, 1823, 1877, 1933, 1997,
@@ -130,7 +133,7 @@ unsigned Dch_NodeHash( void * p, Aig_Obj_t * pObj )
***********************************************************************/
int Dch_NodeIsConst( void * p, Aig_Obj_t * pObj )
{
- Vec_Ptr_t * vSims = p;
+ Vec_Ptr_t * vSims = (Vec_Ptr_t *)p;
unsigned * pSim;
int k, nWords;
nWords = (unsigned *)Vec_PtrEntry(vSims, 1) - (unsigned *)Vec_PtrEntry(vSims, 0);
@@ -163,7 +166,7 @@ int Dch_NodeIsConst( void * p, Aig_Obj_t * pObj )
***********************************************************************/
int Dch_NodesAreEqual( void * p, Aig_Obj_t * pObj0, Aig_Obj_t * pObj1 )
{
- Vec_Ptr_t * vSims = p;
+ Vec_Ptr_t * vSims = (Vec_Ptr_t *)p;
unsigned * pSim0, * pSim1;
int k, nWords;
nWords = (unsigned *)Vec_PtrEntry(vSims, 1) - (unsigned *)Vec_PtrEntry(vSims, 0);
@@ -290,3 +293,5 @@ Dch_Cla_t * Dch_CreateCandEquivClasses( Aig_Man_t * pAig, int nWords, int fVerbo
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/dch/dchSimSat.c b/src/aig/dch/dchSimSat.c
index 4f31b928..325543d1 100644
--- a/src/aig/dch/dchSimSat.c
+++ b/src/aig/dch/dchSimSat.c
@@ -20,6 +20,9 @@
#include "dchInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -88,9 +91,9 @@ void Dch_ManCollectTfoCands( Dch_Man_t * p, Aig_Obj_t * pObj1, Aig_Obj_t * pObj2
Aig_ObjSetTravIdCurrent( p->pAigTotal, Aig_ManConst1(p->pAigTotal) );
Dch_ManCollectTfoCands_rec( p, pObj1 );
Dch_ManCollectTfoCands_rec( p, pObj2 );
- Vec_PtrSort( p->vSimRoots, Aig_ObjCompareIdIncrease );
- Vec_PtrSort( p->vSimClasses, Aig_ObjCompareIdIncrease );
- Vec_PtrForEachEntry( p->vSimClasses, pObj, i )
+ Vec_PtrSort( p->vSimRoots, (int (*)(void))Aig_ObjCompareIdIncrease );
+ Vec_PtrSort( p->vSimClasses, (int (*)(void))Aig_ObjCompareIdIncrease );
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vSimClasses, pObj, i )
pObj->fMarkA = 0;
}
@@ -185,13 +188,13 @@ void Dch_ManResimulateCex( Dch_Man_t * p, Aig_Obj_t * pObj, Aig_Obj_t * pRepr )
Dch_ManResimulateSolved_rec( p, pRepr );
p->nConeMax = ABC_MAX( p->nConeMax, p->nConeThis );
// resimulate the cone of influence of the other nodes
- Vec_PtrForEachEntry( p->vSimRoots, pRoot, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vSimRoots, pRoot, i )
Dch_ManResimulateOther_rec( p, pRoot );
// refine these nodes
RetValue1 = Dch_ClassesRefineConst1Group( p->ppClasses, p->vSimRoots, 0 );
// resimulate the cone of influence of the cand classes
RetValue2 = 0;
- Vec_PtrForEachEntry( p->vSimClasses, pRoot, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vSimClasses, pRoot, i )
{
ppClass = Dch_ClassesReadClass( p->ppClasses, pRoot, &nSize );
for ( k = 0; k < nSize; k++ )
@@ -235,7 +238,7 @@ void Dch_ManResimulateCex2( Dch_Man_t * p, Aig_Obj_t * pObj, Aig_Obj_t * pRepr )
Dch_ManResimulateSolved_rec( p, pRepr );
p->nConeMax = ABC_MAX( p->nConeMax, p->nConeThis );
// resimulate the cone of influence of the other nodes
- Vec_PtrForEachEntry( p->vSimRoots, pRoot, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vSimRoots, pRoot, i )
Dch_ManResimulateOther_rec( p, pRoot );
// refine this class
if ( Dch_ObjIsConst1Cand(p->pAigTotal, pObj) )
@@ -251,3 +254,5 @@ p->timeSimSat += clock() - clk;
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/dch/dchSweep.c b/src/aig/dch/dchSweep.c
index afaf7426..4b054be2 100644
--- a/src/aig/dch/dchSweep.c
+++ b/src/aig/dch/dchSweep.c
@@ -21,6 +21,9 @@
#include "dchInt.h"
#include "bar.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -139,3 +142,5 @@ void Dch_ManSweep( Dch_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/deco/deco.h b/src/aig/deco/deco.h
index 07afd15c..84f2e25e 100644
--- a/src/aig/deco/deco.h
+++ b/src/aig/deco/deco.h
@@ -21,6 +21,7 @@
#ifndef __DEC_H__
#define __DEC_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -29,9 +30,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -50,7 +52,8 @@ struct Dec_Node_t_
Dec_Edge_t eEdge0; // the left child of the node
Dec_Edge_t eEdge1; // the right child of the node
// other info
- void * pFunc; // the function of the node (BDD or AIG)
+ union { int iFunc; // the literal of the node (AIG)
+ void * pFunc; }; // the function of the node (BDD or AIG)
unsigned Level : 14; // the level of this node in the global AIG
// printing info
unsigned fNodeOr : 1; // marks the original OR node
@@ -166,10 +169,13 @@ static inline Dec_Edge_t Dec_IntToEdge( unsigned Edge )
SeeAlso []
***********************************************************************/
+static inline unsigned Dec_EdgeToInt_( Dec_Edge_t m ) { union { Dec_Edge_t x; unsigned y; } v; v.x = m; return v.y; }
+/*
static inline unsigned Dec_EdgeToInt_( Dec_Edge_t eEdge )
{
return *(unsigned *)&eEdge;
}
+*/
/**Function*************************************************************
@@ -182,10 +188,13 @@ static inline unsigned Dec_EdgeToInt_( Dec_Edge_t eEdge )
SeeAlso []
***********************************************************************/
+static inline Dec_Edge_t Dec_IntToEdge_( unsigned m ) { union { Dec_Edge_t x; unsigned y; } v; v.y = m; return v.x; }
+/*
static inline Dec_Edge_t Dec_IntToEdge_( unsigned Edge )
{
return *(Dec_Edge_t *)&Edge;
}
+*/
/**Function*************************************************************
@@ -691,9 +700,11 @@ static inline Dec_Edge_t Dec_GraphAddNodeMux( Dec_Graph_t * pGraph, Dec_Edge_t e
return eNode;
}
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/aig/fra/fra.h b/src/aig/fra/fra.h
index f661d2e5..b046cc47 100644
--- a/src/aig/fra/fra.h
+++ b/src/aig/fra/fra.h
@@ -21,6 +21,7 @@
#ifndef __FRA_H__
#define __FRA_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -41,9 +42,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -55,7 +57,6 @@ typedef struct Fra_Sec_t_ Fra_Sec_t;
typedef struct Fra_Man_t_ Fra_Man_t;
typedef struct Fra_Cla_t_ Fra_Cla_t;
typedef struct Fra_Sml_t_ Fra_Sml_t;
-typedef struct Fra_Cex_t_ Fra_Cex_t;
typedef struct Fra_Bmc_t_ Fra_Bmc_t;
// FRAIG parameters
@@ -180,17 +181,6 @@ struct Fra_Sml_t_
unsigned pData[0]; // simulation data for the nodes
};
-// simulation manager
-struct Fra_Cex_t_
-{
- int iPo; // the zero-based number of PO, for which verification failed
- int iFrame; // the zero-based number of the time-frame, for which verificaiton failed
- int nRegs; // the number of registers in the miter
- int nPis; // the number of primary inputs in the miter
- int nBits; // the number of words of bit data used
- unsigned pData[0]; // the cex bit data (the number of bits: nRegs + (iFrame+1) * nPis)
-};
-
// FRAIG manager
struct Fra_Man_t_
{
@@ -382,16 +372,18 @@ extern Fra_Sml_t * Fra_SmlStart( Aig_Man_t * pAig, int nPref, int nFrame
extern void Fra_SmlStop( Fra_Sml_t * p );
extern Fra_Sml_t * Fra_SmlSimulateSeq( Aig_Man_t * pAig, int nPref, int nFrames, int nWords, int fCheckMiter );
extern Fra_Sml_t * Fra_SmlSimulateComb( Aig_Man_t * pAig, int nWords );
-extern Fra_Cex_t * Fra_SmlGetCounterExample( Fra_Sml_t * p );
-extern Fra_Cex_t * Fra_SmlCopyCounterExample( Aig_Man_t * pAig, Aig_Man_t * pFrames, int * pModel );
-extern void Fra_SmlFreeCounterExample( Fra_Cex_t * p );
-extern Fra_Cex_t * Fra_SmlTrivCounterExample( Aig_Man_t * pAig, int iFrameOut );
-extern int Fra_SmlRunCounterExample( Aig_Man_t * pAig, Fra_Cex_t * p );
-extern int Fra_SmlWriteCounterExample( FILE * pFile, Aig_Man_t * pAig, Fra_Cex_t * p );
-
-#ifdef __cplusplus
-}
-#endif
+extern Abc_Cex_t * Fra_SmlGetCounterExample( Fra_Sml_t * p );
+extern Abc_Cex_t * Fra_SmlCopyCounterExample( Aig_Man_t * pAig, Aig_Man_t * pFrames, int * pModel );
+extern void Fra_SmlFreeCounterExample( Abc_Cex_t * p );
+extern Abc_Cex_t * Fra_SmlTrivCounterExample( Aig_Man_t * pAig, int iFrameOut );
+extern int Fra_SmlRunCounterExample( Aig_Man_t * pAig, Abc_Cex_t * p );
+extern int Fra_SmlWriteCounterExample( FILE * pFile, Aig_Man_t * pAig, Abc_Cex_t * p );
+extern Abc_Cex_t * Fra_SmlSimpleCounterExample( Aig_Man_t * pAig, int * pModel, int iFrame, int iPo );
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/aig/fra/fraBmc.c b/src/aig/fra/fraBmc.c
index 7b08d74d..ae9e4bc5 100644
--- a/src/aig/fra/fraBmc.c
+++ b/src/aig/fra/fraBmc.c
@@ -20,6 +20,9 @@
#include "fra.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -68,7 +71,7 @@ static inline Aig_Obj_t * Bmc_ObjChild1Frames( Aig_Obj_t * pObj, int i ) { asse
***********************************************************************/
int Fra_BmcNodesAreEqual( Aig_Obj_t * pObj0, Aig_Obj_t * pObj1 )
{
- Fra_Man_t * p = pObj0->pData;
+ Fra_Man_t * p = (Fra_Man_t *)pObj0->pData;
Aig_Obj_t * pObjFrames0, * pObjFrames1;
Aig_Obj_t * pObjFraig0, * pObjFraig1;
int i;
@@ -99,7 +102,7 @@ int Fra_BmcNodesAreEqual( Aig_Obj_t * pObj0, Aig_Obj_t * pObj1 )
***********************************************************************/
int Fra_BmcNodeIsConst( Aig_Obj_t * pObj )
{
- Fra_Man_t * p = pObj->pData;
+ Fra_Man_t * p = (Fra_Man_t *)pObj->pData;
return Fra_BmcNodesAreEqual( pObj, Aig_ManConst1(p->pManAig) );
}
@@ -421,7 +424,7 @@ void Fra_BmcPerformSimple( Aig_Man_t * pAig, int nFrames, int nBTLimit, int fRew
iOutput = Fra_FraigMiterAssertedOutput( pBmc->pAigFraig );
if ( pBmc->pAigFraig->pData )
{
- pAig->pSeqModel = Fra_SmlCopyCounterExample( pAig, pBmc->pAigFrames, pBmc->pAigFraig->pData );
+ pAig->pSeqModel = Fra_SmlCopyCounterExample( pAig, pBmc->pAigFrames, (int *)pBmc->pAigFraig->pData );
ABC_FREE( pBmc->pAigFraig->pData );
}
else if ( iOutput >= 0 )
@@ -444,3 +447,5 @@ void Fra_BmcPerformSimple( Aig_Man_t * pAig, int nFrames, int nBTLimit, int fRew
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/fra/fraCec.c b/src/aig/fra/fraCec.c
index b7a78050..037e6c70 100644
--- a/src/aig/fra/fraCec.c
+++ b/src/aig/fra/fraCec.c
@@ -21,6 +21,9 @@
#include "fra.h"
#include "cnf.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -58,7 +61,7 @@ int Fra_FraigSat( Aig_Man_t * pMan, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimi
Cnf_DataTranformPolarity( pCnf, 0 );
// convert into SAT solver
- pSat = Cnf_DataWriteIntoSolver( pCnf, 1, 0 );
+ pSat = (sat_solver *)Cnf_DataWriteIntoSolver( pCnf, 1, 0 );
if ( pSat == NULL )
{
Cnf_DataFree( pCnf );
@@ -128,8 +131,9 @@ int Fra_FraigSat( Aig_Man_t * pMan, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimi
}
else
assert( 0 );
-// ABC_PRT( "SAT sat_solver time", clock() - clk );
-// printf( "The number of conflicts = %d.\n", (int)pSat->sat_solver_stats.conflicts );
+
+// Abc_Print( 1, "The number of conflicts = %6d. ", (int)pSat->stats.conflicts );
+// Abc_PrintTime( 1, "Solving time", clock() - clk );
// if the problem is SAT, get the counterexample
if ( status == l_True )
@@ -283,7 +287,7 @@ int Fra_FraigCecPartitioned( Aig_Man_t * pMan1, Aig_Man_t * pMan2, int nConfLimi
vParts = Aig_ManMiterPartitioned( pMan1, pMan2, nPartSize, fSmart );
// solve the partitions
nOutputs = -1;
- Vec_PtrForEachEntry( vParts, pAig, i )
+ Vec_PtrForEachEntry( Aig_Man_t *, vParts, pAig, i )
{
nOutputs++;
if ( fVerbose )
@@ -319,7 +323,7 @@ int Fra_FraigCecPartitioned( Aig_Man_t * pMan1, Aig_Man_t * pMan2, int nConfLimi
fflush( stdout );
}
// free intermediate results
- Vec_PtrForEachEntry( vParts, pAig, i )
+ Vec_PtrForEachEntry( Aig_Man_t *, vParts, pAig, i )
Aig_ManStop( pAig );
Vec_PtrFree( vParts );
return RetValue;
@@ -395,3 +399,5 @@ ABC_PRT( "Time", clock() - clkTotal );
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/fra/fraClass.c b/src/aig/fra/fraClass.c
index 94cac80a..9b1ad3f2 100644
--- a/src/aig/fra/fraClass.c
+++ b/src/aig/fra/fraClass.c
@@ -20,6 +20,9 @@
#include "fra.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*
The candidate equivalence classes are stored as a vector of pointers
to the array of pointers to the nodes in each class.
@@ -124,7 +127,7 @@ void Fra_ClassesCopyReprs( Fra_Cla_t * p, Vec_Ptr_t * vFailed )
}
}
if ( vFailed )
- Vec_PtrForEachEntry( vFailed, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vFailed, pObj, i )
p->pAig->pReprs[pObj->Id] = NULL;
}
@@ -163,7 +166,7 @@ int Fra_ClassesCountLits( Fra_Cla_t * p )
Aig_Obj_t ** pClass;
int i, nNodes, nLits = 0;
nLits = Vec_PtrSize( p->vClasses1 );
- Vec_PtrForEachEntry( p->vClasses, pClass, i )
+ Vec_PtrForEachEntry( Aig_Obj_t **, p->vClasses, pClass, i )
{
nNodes = Fra_ClassCount( pClass );
assert( nNodes > 1 );
@@ -187,7 +190,7 @@ int Fra_ClassesCountPairs( Fra_Cla_t * p )
{
Aig_Obj_t ** pClass;
int i, nNodes, nPairs = 0;
- Vec_PtrForEachEntry( p->vClasses, pClass, i )
+ Vec_PtrForEachEntry( Aig_Obj_t **, p->vClasses, pClass, i )
{
nNodes = Fra_ClassCount( pClass );
assert( nNodes > 1 );
@@ -244,13 +247,13 @@ void Fra_ClassesPrint( Fra_Cla_t * p, int fVeryVerbose )
if ( fVeryVerbose )
{
- Vec_PtrForEachEntry( p->vClasses1, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vClasses1, pObj, i )
assert( Fra_ClassObjRepr(pObj) == Aig_ManConst1(p->pAig) );
printf( "Constants { " );
- Vec_PtrForEachEntry( p->vClasses1, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vClasses1, pObj, i )
printf( "%d(%d,%d) ", pObj->Id, pObj->Level, Aig_SupportSize(p->pAig,pObj) );
printf( "}\n" );
- Vec_PtrForEachEntry( p->vClasses, pClass, i )
+ Vec_PtrForEachEntry( Aig_Obj_t **, p->vClasses, pClass, i )
{
printf( "%3d (%3d) : ", i, Fra_ClassCount(pClass) );
Fra_PrintClass( p, pClass );
@@ -415,15 +418,15 @@ Aig_Obj_t ** Fra_RefineClassOne( Fra_Cla_t * p, Aig_Obj_t ** ppClass )
Vec_PtrPush( p->vClassNew, pObj );
/*
printf( "Refining class (" );
- Vec_PtrForEachEntry( p->vClassOld, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vClassOld, pObj, i )
printf( "%d,", pObj->Id );
printf( ") + (" );
- Vec_PtrForEachEntry( p->vClassNew, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vClassNew, pObj, i )
printf( "%d,", pObj->Id );
printf( ")\n" );
*/
// put the nodes back into the class memory
- Vec_PtrForEachEntry( p->vClassOld, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vClassOld, pObj, i )
{
ppClass[i] = pObj;
ppClass[Vec_PtrSize(p->vClassOld)+i] = NULL;
@@ -431,7 +434,7 @@ Aig_Obj_t ** Fra_RefineClassOne( Fra_Cla_t * p, Aig_Obj_t ** ppClass )
}
ppClass += 2*Vec_PtrSize(p->vClassOld);
// put the new nodes into the class memory
- Vec_PtrForEachEntry( p->vClassNew, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vClassNew, pObj, i )
{
ppClass[i] = pObj;
ppClass[Vec_PtrSize(p->vClassNew)+i] = NULL;
@@ -455,7 +458,7 @@ int Fra_RefineClassLastIter( Fra_Cla_t * p, Vec_Ptr_t * vClasses )
{
Aig_Obj_t ** pClass, ** pClass2;
int nRefis;
- pClass = Vec_PtrEntryLast( vClasses );
+ pClass = (Aig_Obj_t **)Vec_PtrEntryLast( vClasses );
for ( nRefis = 0; (pClass2 = Fra_RefineClassOne( p, pClass )); nRefis++ )
{
// if the original class is trivial, remove it
@@ -495,7 +498,7 @@ int Fra_ClassesRefine( Fra_Cla_t * p )
// refine the classes
nRefis = 0;
Vec_PtrClear( p->vClassesTemp );
- Vec_PtrForEachEntry( p->vClasses, pClass, i )
+ Vec_PtrForEachEntry( Aig_Obj_t **, p->vClasses, pClass, i )
{
// add the class to the new array
assert( pClass[0] != NULL );
@@ -533,7 +536,7 @@ int Fra_ClassesRefine1( Fra_Cla_t * p, int fRefineNewClass, int * pSkipped )
// collect all the nodes to be refined
k = 0;
Vec_PtrClear( p->vClassNew );
- Vec_PtrForEachEntry( p->vClasses1, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vClasses1, pObj, i )
{
if ( p->pFuncNodeIsConst( pObj ) )
Vec_PtrWriteEntry( p->vClasses1, k++, pObj );
@@ -545,19 +548,19 @@ int Fra_ClassesRefine1( Fra_Cla_t * p, int fRefineNewClass, int * pSkipped )
return 0;
/*
printf( "Refined const-1 class: {" );
- Vec_PtrForEachEntry( p->vClassNew, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vClassNew, pObj, i )
printf( " %d", pObj->Id );
printf( " }\n" );
*/
if ( Vec_PtrSize(p->vClassNew) == 1 )
{
- Fra_ClassObjSetRepr( Vec_PtrEntry(p->vClassNew,0), NULL );
+ Fra_ClassObjSetRepr( (Aig_Obj_t *)Vec_PtrEntry(p->vClassNew,0), NULL );
return 1;
}
// create a new class composed of these nodes
ppClass = p->pMemClassesFree;
p->pMemClassesFree += 2 * Vec_PtrSize(p->vClassNew);
- Vec_PtrForEachEntry( p->vClassNew, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vClassNew, pObj, i )
{
ppClass[i] = pObj;
ppClass[Vec_PtrSize(p->vClassNew)+i] = NULL;
@@ -658,7 +661,7 @@ void Fra_ClassesPostprocess( Fra_Cla_t * p )
printf( "Before: Const = %6d. Class = %6d. ", Vec_PtrSize(p->vClasses1), Vec_PtrSize(p->vClasses) );
// remove nodes from classes whose weight is less than WeightMax/Ratio
k = 0;
- Vec_PtrForEachEntry( p->vClasses1, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vClasses1, pObj, i )
{
if ( pWeights[pObj->Id] >= WeightMax/Ratio )
Vec_PtrWriteEntry( p->vClasses1, k++, pObj );
@@ -667,7 +670,7 @@ void Fra_ClassesPostprocess( Fra_Cla_t * p )
}
Vec_PtrShrink( p->vClasses1, k );
// in each class, compact the nodes
- Vec_PtrForEachEntry( p->vClasses, ppClass, i )
+ Vec_PtrForEachEntry( Aig_Obj_t **, p->vClasses, ppClass, i )
{
k = 1;
for ( c = 1; ppClass[c]; c++ )
@@ -681,7 +684,7 @@ void Fra_ClassesPostprocess( Fra_Cla_t * p )
}
// remove classes with only repr
k = 0;
- Vec_PtrForEachEntry( p->vClasses, ppClass, i )
+ Vec_PtrForEachEntry( Aig_Obj_t **, p->vClasses, ppClass, i )
if ( ppClass[1] != NULL )
Vec_PtrWriteEntry( p->vClasses, k++, ppClass );
Vec_PtrShrink( p->vClasses, k );
@@ -705,7 +708,7 @@ void Fra_ClassesSelectRepr( Fra_Cla_t * p )
Aig_Obj_t ** pClass, * pNodeMin;
int i, c, cMinSupp, nSuppSizeMin, nSuppSizeCur;
// reassign representatives in each class
- Vec_PtrForEachEntry( p->vClasses, pClass, i )
+ Vec_PtrForEachEntry( Aig_Obj_t **, p->vClasses, pClass, i )
{
// collect support sizes and find the min-support node
cMinSupp = -1;
@@ -855,3 +858,5 @@ printf( "Assert miters = %6d. Output miters = %6d.\n",
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/fra/fraClau.c b/src/aig/fra/fraClau.c
index 96d06380..490c73ff 100644
--- a/src/aig/fra/fraClau.c
+++ b/src/aig/fra/fraClau.c
@@ -22,6 +22,9 @@
#include "cnf.h"
#include "satSolver.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*
This code is inspired by the paper: Aaron Bradley and Zohar Manna,
"Checking safety by inductive generalization of counterexamples to
@@ -233,7 +236,7 @@ Cla_Man_t * Fra_ClauStart( Aig_Man_t * pMan )
Aig_ObjChild0Flip( Aig_ManPo(pFramesMain, 0) ); // complement the first output
pCnfMain = Cnf_DeriveSimple( pFramesMain, 0 );
//Cnf_DataWriteIntoFile( pCnfMain, "temp.cnf", 1 );
- p->pSatMain = Cnf_DataWriteIntoSolver( pCnfMain, 1, 0 );
+ p->pSatMain = (sat_solver *)Cnf_DataWriteIntoSolver( pCnfMain, 1, 0 );
/*
{
int i;
@@ -248,7 +251,7 @@ Cla_Man_t * Fra_ClauStart( Aig_Man_t * pMan )
pFramesTest = Aig_ManFrames( pMan, 1, 0, 0, 1, 0, NULL );
assert( Aig_ManPoNum(pFramesTest) == Aig_ManRegNum(pMan) );
pCnfTest = Cnf_DeriveSimple( pFramesTest, Aig_ManRegNum(pMan) );
- p->pSatTest = Cnf_DataWriteIntoSolver( pCnfTest, 1, 0 );
+ p->pSatTest = (sat_solver *)Cnf_DataWriteIntoSolver( pCnfTest, 1, 0 );
p->nSatVarsTestBeg = p->nSatVarsTestCur = sat_solver_nvars( p->pSatTest );
// derive one timeframe to be checked for BMC
@@ -256,7 +259,7 @@ Cla_Man_t * Fra_ClauStart( Aig_Man_t * pMan )
//Aig_ManShow( pFramesBmc, 0, NULL );
assert( Aig_ManPoNum(pFramesBmc) == Aig_ManRegNum(pMan) );
pCnfBmc = Cnf_DeriveSimple( pFramesBmc, Aig_ManRegNum(pMan) );
- p->pSatBmc = Cnf_DataWriteIntoSolver( pCnfBmc, 1, 0 );
+ p->pSatBmc = (sat_solver *)Cnf_DataWriteIntoSolver( pCnfBmc, 1, 0 );
// create variable sets
p->vSatVarsMainCs = Fra_ClauSaveInputVars( pFramesMain, pCnfMain, 2 * (Aig_ManPiNum(pMan)-Aig_ManRegNum(pMan)) );
@@ -756,3 +759,5 @@ int Fra_Clau( Aig_Man_t * pMan, int nIters, int fVerbose, int fVeryVerbose )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/fra/fraClaus.c b/src/aig/fra/fraClaus.c
index e5fe3f40..90659333 100644
--- a/src/aig/fra/fraClaus.c
+++ b/src/aig/fra/fraClaus.c
@@ -22,6 +22,9 @@
#include "cnf.h"
#include "satSolver.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -818,7 +821,7 @@ clk = clock();
int * pStart;
// reset the solver
if ( p->pSatMain ) sat_solver_delete( p->pSatMain );
- p->pSatMain = Cnf_DataWriteIntoSolver( p->pCnf, 1, 0 );
+ p->pSatMain = (sat_solver *)Cnf_DataWriteIntoSolver( p->pCnf, 1, 0 );
if ( p->pSatMain == NULL )
{
printf( "Error: Main solver is unsat.\n" );
@@ -1030,8 +1033,8 @@ void Fra_ClausSimInfoRecord( Clu_Man_t * p, int * pModel )
{
if ( pModel[i] == l_True )
{
- assert( Aig_InfoHasBit( Vec_PtrEntry(p->vCexes, i), p->nCexes ) == 0 );
- Aig_InfoSetBit( Vec_PtrEntry(p->vCexes, i), p->nCexes );
+ assert( Aig_InfoHasBit( (unsigned *)Vec_PtrEntry(p->vCexes, i), p->nCexes ) == 0 );
+ Aig_InfoSetBit( (unsigned *)Vec_PtrEntry(p->vCexes, i), p->nCexes );
}
}
p->nCexes++;
@@ -1056,7 +1059,7 @@ int Fra_ClausSimInfoCheck( Clu_Man_t * p, int * pLits, int nLits )
{
iVar = lit_var(pLits[i]) - p->nFrames * p->pCnf->nVars;
assert( iVar > 0 && iVar < p->pCnf->nVars );
- pSims[i] = Vec_PtrEntry( p->vCexes, iVar );
+ pSims[i] = (unsigned *)Vec_PtrEntry( p->vCexes, iVar );
}
nWords = p->nCexes / 32;
for ( w = 0; w < nWords; w++ )
@@ -1098,7 +1101,7 @@ int Fra_ClausInductiveClauses( Clu_Man_t * p )
// reset the solver
if ( p->pSatMain ) sat_solver_delete( p->pSatMain );
- p->pSatMain = Cnf_DataWriteIntoSolver( p->pCnf, p->nFrames+1, 0 );
+ p->pSatMain = (sat_solver *)Cnf_DataWriteIntoSolver( p->pCnf, p->nFrames+1, 0 );
if ( p->pSatMain == NULL )
{
printf( "Error: Main solver is unsat.\n" );
@@ -1516,7 +1519,7 @@ Aig_Obj_t * Fra_ClausGetLiteral( Clu_Man_t * p, int * pVar2Id, int Lit )
Aig_Obj_t * pLiteral;
int NodeId = pVar2Id[ lit_var(Lit) ];
assert( NodeId >= 0 );
- pLiteral = Aig_ManObj( p->pAig, NodeId )->pData;
+ pLiteral = (Aig_Obj_t *)Aig_ManObj( p->pAig, NodeId )->pData;
return Aig_NotCond( pLiteral, lit_sign(Lit) );
}
@@ -1705,7 +1708,7 @@ if ( fVerbose )
// check BMC
clk = clock();
- p->pSatBmc = Cnf_DataWriteIntoSolver( p->pCnf, p->nPref + p->nFrames, 1 );
+ p->pSatBmc = (sat_solver *)Cnf_DataWriteIntoSolver( p->pCnf, p->nPref + p->nFrames, 1 );
if ( p->pSatBmc == NULL )
{
printf( "Error: BMC solver is unsat.\n" );
@@ -1725,7 +1728,7 @@ if ( fVerbose )
// start the SAT solver
clk = clock();
- p->pSatMain = Cnf_DataWriteIntoSolver( p->pCnf, p->nFrames+1, 0 );
+ p->pSatMain = (sat_solver *)Cnf_DataWriteIntoSolver( p->pCnf, p->nFrames+1, 0 );
if ( p->pSatMain == NULL )
{
printf( "Error: Main solver is unsat.\n" );
@@ -1867,3 +1870,5 @@ clk = clock();
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/fra/fraCnf.c b/src/aig/fra/fraCnf.c
index 27da3fc5..5021e750 100644
--- a/src/aig/fra/fraCnf.c
+++ b/src/aig/fra/fraCnf.c
@@ -20,6 +20,9 @@
#include "fra.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -134,7 +137,7 @@ void Fra_AddClausesSuper( Fra_Man_t * p, Aig_Obj_t * pNode, Vec_Ptr_t * vSuper )
pLits = ABC_ALLOC( int, nLits );
// suppose AND-gate is A & B = C
// add !A => !C or A + !C
- Vec_PtrForEachEntry( vSuper, pFanin, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vSuper, pFanin, i )
{
pLits[0] = toLitCond(Fra_ObjSatNum(Aig_Regular(pFanin)), Aig_IsComplement(pFanin));
pLits[1] = toLitCond(Fra_ObjSatNum(pNode), 1);
@@ -142,7 +145,7 @@ void Fra_AddClausesSuper( Fra_Man_t * p, Aig_Obj_t * pNode, Vec_Ptr_t * vSuper )
assert( RetValue );
}
// add A & B => C or !A + !B + C
- Vec_PtrForEachEntry( vSuper, pFanin, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vSuper, pFanin, i )
pLits[i] = toLitCond(Fra_ObjSatNum(Aig_Regular(pFanin)), !Aig_IsComplement(pFanin));
pLits[nLits-1] = toLitCond(Fra_ObjSatNum(pNode), 0);
RetValue = sat_solver_addclause( p->pSat, pLits, pLits + nLits );
@@ -246,7 +249,7 @@ void Fra_CnfNodeAddToSolver( Fra_Man_t * p, Aig_Obj_t * pOld, Aig_Obj_t * pNew )
if ( pOld ) Fra_ObjAddToFrontier( p, pOld, vFrontier );
if ( pNew ) Fra_ObjAddToFrontier( p, pNew, vFrontier );
// explore nodes in the frontier
- Vec_PtrForEachEntry( vFrontier, pNode, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vFrontier, pNode, i )
{
// create the supergate
assert( Fra_ObjSatNum(pNode) );
@@ -258,14 +261,14 @@ void Fra_CnfNodeAddToSolver( Fra_Man_t * p, Aig_Obj_t * pOld, Aig_Obj_t * pNew )
Vec_PtrPushUnique( vFanins, Aig_ObjFanin0( Aig_ObjFanin1(pNode) ) );
Vec_PtrPushUnique( vFanins, Aig_ObjFanin1( Aig_ObjFanin0(pNode) ) );
Vec_PtrPushUnique( vFanins, Aig_ObjFanin1( Aig_ObjFanin1(pNode) ) );
- Vec_PtrForEachEntry( vFanins, pFanin, k )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vFanins, pFanin, k )
Fra_ObjAddToFrontier( p, Aig_Regular(pFanin), vFrontier );
Fra_AddClausesMux( p, pNode );
}
else
{
vFanins = Fra_CollectSuper( pNode, fUseMuxes );
- Vec_PtrForEachEntry( vFanins, pFanin, k )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vFanins, pFanin, k )
Fra_ObjAddToFrontier( p, Aig_Regular(pFanin), vFrontier );
Fra_AddClausesSuper( p, pNode, vFanins );
}
@@ -282,3 +285,5 @@ void Fra_CnfNodeAddToSolver( Fra_Man_t * p, Aig_Obj_t * pOld, Aig_Obj_t * pNew )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/fra/fraCore.c b/src/aig/fra/fraCore.c
index fad8c7bf..93c16e1e 100644
--- a/src/aig/fra/fraCore.c
+++ b/src/aig/fra/fraCore.c
@@ -20,6 +20,9 @@
#include "fra.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -198,12 +201,12 @@ void Fra_FraigVerifyCounterEx( Fra_Man_t * p, Vec_Int_t * vCex )
Aig_ManForEachPo( p->pManAig, pObj, i )
pObj->fMarkB = Aig_ObjFanin0(pObj)->fMarkB ^ Aig_ObjFaninC0(pObj);
// check if the classes hold
- Vec_PtrForEachEntry( p->pCla->vClasses1, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->pCla->vClasses1, pObj, i )
{
if ( pObj->fPhase != pObj->fMarkB )
printf( "The node %d is not constant under cex!\n", pObj->Id );
}
- Vec_PtrForEachEntry( p->pCla->vClasses, ppClass, i )
+ Vec_PtrForEachEntry( Aig_Obj_t **, p->pCla->vClasses, ppClass, i )
{
for ( c = 1; ppClass[c]; c++ )
if ( (ppClass[0]->fPhase ^ ppClass[c]->fPhase) != (ppClass[0]->fMarkB ^ ppClass[c]->fMarkB) )
@@ -483,3 +486,5 @@ Aig_Man_t * Fra_FraigEquivence( Aig_Man_t * pManAig, int nConfMax, int fProve )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/fra/fraHot.c b/src/aig/fra/fraHot.c
index c4472121..29c9c33d 100644
--- a/src/aig/fra/fraHot.c
+++ b/src/aig/fra/fraHot.c
@@ -20,6 +20,9 @@
#include "fra.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -143,8 +146,8 @@ Vec_Int_t * Fra_OneHotCompute( Fra_Man_t * p, Fra_Sml_t * pSim )
continue;
assert( i-nTruePis >= 0 );
// Aig_ManForEachLoSeq( pSim->pAig, pObj2, k )
-// Vec_PtrForEachEntryStart( pSim->pAig->vPis, pObj2, k, Aig_ManPiNum(p)-Aig_ManRegNum(p) )
- Vec_PtrForEachEntryStart( pSim->pAig->vPis, pObj2, k, i+1 )
+// Vec_PtrForEachEntryStart( Aig_Obj_t *, pSim->pAig->vPis, pObj2, k, Aig_ManPiNum(p)-Aig_ManRegNum(p) )
+ Vec_PtrForEachEntryStart( Aig_Obj_t *, pSim->pAig->vPis, pObj2, k, i+1 )
{
if ( fSkipConstEqu && Fra_OneHotNodeIsConst(pSim, pObj2) )
continue;
@@ -201,7 +204,7 @@ void Fra_OneHotAssume( Fra_Man_t * p, Vec_Int_t * vOneHots )
pObj2 = Aig_ManPi( p->pManFraig, nPiNum + Fra_LitReg(Out2) );
pLits[0] = toLitCond( Fra_ObjSatNum(pObj1), Fra_LitSign(Out1) );
pLits[1] = toLitCond( Fra_ObjSatNum(pObj2), Fra_LitSign(Out2) );
- // add contraint to solver
+ // add constraint to solver
if ( !sat_solver_addclause( p->pSat, pLits, pLits + 2 ) )
{
printf( "Fra_OneHotAssume(): Adding clause makes SAT solver unsat.\n" );
@@ -337,11 +340,11 @@ void Fra_OneHotEstimateCoverage( Fra_Man_t * p, Vec_Int_t * vOneHots )
Aig_ManRandom(1);
for ( i = 0; i < nRegs; i++ )
{
- pSim1 = Vec_PtrEntry( vSimInfo, i );
+ pSim1 = (unsigned *)Vec_PtrEntry( vSimInfo, i );
for ( w = 0; w < nSimWords; w++ )
pSim1[w] = Fra_ObjRandomSim();
}
- pSimTot = Vec_PtrEntry( vSimInfo, nRegs );
+ pSimTot = (unsigned *)Vec_PtrEntry( vSimInfo, nRegs );
// collect simulation info
memset( pSimTot, 0, sizeof(unsigned) * nSimWords );
@@ -355,8 +358,8 @@ void Fra_OneHotEstimateCoverage( Fra_Man_t * p, Vec_Int_t * vOneHots )
//Fra_LitSign(Out1)? '-': '+', Fra_LitReg(Out1),
//Fra_LitSign(Out2)? '-': '+', Fra_LitReg(Out2) );
Counter++;
- pSim1 = Vec_PtrEntry( vSimInfo, Fra_LitReg(Out1) );
- pSim2 = Vec_PtrEntry( vSimInfo, Fra_LitReg(Out2) );
+ pSim1 = (unsigned *)Vec_PtrEntry( vSimInfo, Fra_LitReg(Out1) );
+ pSim2 = (unsigned *)Vec_PtrEntry( vSimInfo, Fra_LitReg(Out2) );
if ( Fra_LitSign(Out1) && Fra_LitSign(Out2) )
for ( w = 0; w < nSimWords; w++ )
pSimTot[w] |= pSim1[w] & pSim2[w];
@@ -442,7 +445,7 @@ void Fra_OneHotAddKnownConstraint( Fra_Man_t * p, Vec_Ptr_t * vOnehots )
// these constrants should be added to different timeframes!
// (also note that PIs follow first - then registers)
//
- Vec_PtrForEachEntry( vOnehots, vGroup, k )
+ Vec_PtrForEachEntry( Vec_Int_t *, vOnehots, vGroup, k )
{
Vec_IntForEachEntry( vGroup, Out1, i )
Vec_IntForEachEntryStart( vGroup, Out2, j, i+1 )
@@ -451,7 +454,7 @@ void Fra_OneHotAddKnownConstraint( Fra_Man_t * p, Vec_Ptr_t * vOnehots )
pObj2 = Aig_ManPi( p->pManFraig, Out2 );
pLits[0] = toLitCond( Fra_ObjSatNum(pObj1), 1 );
pLits[1] = toLitCond( Fra_ObjSatNum(pObj2), 1 );
- // add contraint to solver
+ // add constraint to solver
if ( !sat_solver_addclause( p->pSat, pLits, pLits + 2 ) )
{
printf( "Fra_OneHotAddKnownConstraint(): Adding clause makes SAT solver unsat.\n" );
@@ -469,3 +472,5 @@ void Fra_OneHotAddKnownConstraint( Fra_Man_t * p, Vec_Ptr_t * vOnehots )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/fra/fraImp.c b/src/aig/fra/fraImp.c
index 716e83d5..34fa87e5 100644
--- a/src/aig/fra/fraImp.c
+++ b/src/aig/fra/fraImp.c
@@ -20,6 +20,9 @@
#include "fra.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -211,12 +214,12 @@ Vec_Ptr_t * Fra_SmlSortUsingOnes( Fra_Sml_t * p, int fLatchCorr )
// skip nodes participating in the classes
// if ( Fra_ClassObjRepr(pObj) )
// continue;
- pMemory = Vec_PtrEntry( vNodes, pnBits[i] );
+ pMemory = (int *)Vec_PtrEntry( vNodes, pnBits[i] );
pMemory[ pnNodes[pnBits[i]]++ ] = i;
}
// add 0s in the end
nTotal = 0;
- Vec_PtrForEachEntry( vNodes, pMemory, i )
+ Vec_PtrForEachEntry( int *, vNodes, pMemory, i )
{
pMemory[ pnNodes[i]++ ] = 0;
nTotal += pnNodes[i];
@@ -335,8 +338,8 @@ Vec_Int_t * Fra_ImpDerive( Fra_Man_t * p, int nImpMaxLimit, int nImpUseLimit, in
// count the total number of implications
for ( k = nSimWords * 32; k > 0; k-- )
for ( i = k - 1; i > 0; i-- )
- for ( pNodesI = Vec_PtrEntry( vNodes, i ); *pNodesI; pNodesI++ )
- for ( pNodesK = Vec_PtrEntry( vNodes, k ); *pNodesK; pNodesK++ )
+ for ( pNodesI = (int *)Vec_PtrEntry( vNodes, i ); *pNodesI; pNodesI++ )
+ for ( pNodesK = (int *)Vec_PtrEntry( vNodes, k ); *pNodesK; pNodesK++ )
nImpsTotal++;
// compute implications and their costs
@@ -347,8 +350,8 @@ Vec_Int_t * Fra_ImpDerive( Fra_Man_t * p, int nImpMaxLimit, int nImpUseLimit, in
{
// HERE WE ARE MISSING SOME POTENTIAL IMPLICATIONS (with complement!)
- for ( pNodesI = Vec_PtrEntry( vNodes, i ); *pNodesI; pNodesI++ )
- for ( pNodesK = Vec_PtrEntry( vNodes, k ); *pNodesK; pNodesK++ )
+ for ( pNodesI = (int *)Vec_PtrEntry( vNodes, i ); *pNodesI; pNodesI++ )
+ for ( pNodesK = (int *)Vec_PtrEntry( vNodes, k ); *pNodesK; pNodesK++ )
{
nImpsTried++;
if ( !Sml_NodeCheckImp(pSeq, *pNodesI, *pNodesK) )
@@ -444,7 +447,7 @@ void Fra_ImpAddToSolver( Fra_Man_t * p, Vec_Int_t * vImps, int * pSatVarNums )
Vec_IntWriteEntry( vImps, i, 0 );
break;
}
- }
+ }
if ( f < p->pPars->nFramesK )
continue;
// add constraints in each timeframe
@@ -465,7 +468,7 @@ void Fra_ImpAddToSolver( Fra_Man_t * p, Vec_Int_t * vImps, int * pSatVarNums )
// L => R L' v R (complement = L & R')
pLits[0] = 2 * Left + !fComplL;
pLits[1] = 2 * Right + fComplR;
- // add contraint to solver
+ // add constraint to solver
if ( !sat_solver_addclause( pSat, pLits, pLits + 2 ) )
{
sat_solver_delete( pSat );
@@ -712,8 +715,8 @@ void Fra_ImpRecordInManager( Fra_Man_t * p, Aig_Man_t * pNew )
pRight = Aig_ManObj( p->pManAig, Fra_ImpRight(Imp) );
// record the implication: L' + R
pMiter = Aig_Or( pNew,
- Aig_NotCond(pLeft->pData, !pLeft->fPhase),
- Aig_NotCond(pRight->pData, pRight->fPhase) );
+ Aig_NotCond((Aig_Obj_t *)pLeft->pData, !pLeft->fPhase),
+ Aig_NotCond((Aig_Obj_t *)pRight->pData, pRight->fPhase) );
Aig_ObjCreatePo( pNew, pMiter );
}
pNew->nAsserts = Aig_ManPoNum(pNew) - nPosOld;
@@ -724,3 +727,5 @@ void Fra_ImpRecordInManager( Fra_Man_t * p, Aig_Man_t * pNew )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/fra/fraInd.c b/src/aig/fra/fraInd.c
index 84b739a4..2f2d8f2d 100644
--- a/src/aig/fra/fraInd.c
+++ b/src/aig/fra/fraInd.c
@@ -21,6 +21,10 @@
#include "fra.h"
#include "cnf.h"
#include "dar.h"
+#include "saig.h"
+
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -265,7 +269,7 @@ Aig_Man_t * Fra_FraigInductionPart( Aig_Man_t * pAig, Fra_Ssw_t * pPars )
{
// divide large clock domains into separate partitions
vResult = Vec_PtrAlloc( 100 );
- Vec_PtrForEachEntry( (Vec_Ptr_t *)pAig->vClockDoms, vPart, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, (Vec_Ptr_t *)pAig->vClockDoms, vPart, i )
{
if ( nPartSize && Vec_IntSize(vPart) > nPartSize )
Aig_ManPartDivide( vResult, vPart, nPartSize, pPars->nOverSize );
@@ -281,7 +285,7 @@ Aig_Man_t * Fra_FraigInductionPart( Aig_Man_t * pAig, Fra_Ssw_t * pPars )
{
// print partitions
printf( "Simple partitioning. %d partitions are saved:\n", Vec_PtrSize(vResult) );
- Vec_PtrForEachEntry( vResult, vPart, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vResult, vPart, i )
{
sprintf( Buffer, "part%03d.aig", i );
pTemp = Aig_ManRegCreatePart( pAig, vPart, &nCountPis, &nCountRegs, NULL );
@@ -294,7 +298,7 @@ Aig_Man_t * Fra_FraigInductionPart( Aig_Man_t * pAig, Fra_Ssw_t * pPars )
// perform SSW with partitions
Aig_ManReprStart( pAig, Aig_ManObjNumMax(pAig) );
- Vec_PtrForEachEntry( vResult, vPart, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vResult, vPart, i )
{
pTemp = Aig_ManRegCreatePart( pAig, vPart, &nCountPis, &nCountRegs, &pMapBack );
// create the projection of 1-hot registers
@@ -498,7 +502,7 @@ p->timeTrav += clock() - clk2;
// Cnf_DataTranformPolarity( pCnf, 0 );
//Cnf_DataWriteIntoFile( pCnf, "temp.cnf", 1 );
- p->pSat = Cnf_DataWriteIntoSolver( pCnf, 1, 0 );
+ p->pSat = (sat_solver *)Cnf_DataWriteIntoSolver( pCnf, 1, 0 );
p->nSatVars = pCnf->nVars;
assert( p->pSat != NULL );
if ( p->pSat == NULL )
@@ -523,7 +527,7 @@ p->timeTrav += clock() - clk2;
if ( pCnf->pVarNums[pObj->Id] == -1 )
continue;
Fra_ObjSetSatNum( pObj, pCnf->pVarNums[pObj->Id] );
- Fra_ObjSetFaninVec( pObj, (void *)1 );
+ Fra_ObjSetFaninVec( pObj, (Vec_Ptr_t *)1 );
}
Cnf_DataFree( pCnf );
@@ -653,7 +657,6 @@ finish:
***********************************************************************/
int Fra_FraigInductionTest( char * pFileName, Fra_Ssw_t * pParams )
{
- extern Aig_Man_t * Saig_ManReadBlif( char * pFileName );
FILE * pFile;
char * pFilePairs;
Aig_Man_t * pMan, * pNew;
@@ -678,7 +681,7 @@ int Fra_FraigInductionTest( char * pFileName, Fra_Ssw_t * pParams )
Aig_ManPrintStats( pNew );
}
Aig_ManStop( pNew );
- pNum2Id = pMan->pData;
+ pNum2Id = (int *)pMan->pData;
// write the output file
pFilePairs = Aig_FileNameGenericAppend( pFileName, ".pairs" );
pFile = fopen( pFilePairs, "w" );
@@ -702,3 +705,5 @@ int Fra_FraigInductionTest( char * pFileName, Fra_Ssw_t * pParams )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/fra/fraIndVer.c b/src/aig/fra/fraIndVer.c
index 71faa346..32069cfb 100644
--- a/src/aig/fra/fraIndVer.c
+++ b/src/aig/fra/fraIndVer.c
@@ -21,6 +21,9 @@
#include "fra.h"
#include "cnf.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -72,7 +75,7 @@ int Fra_InvariantVerify( Aig_Man_t * pAig, int nFrames, Vec_Int_t * vClauses, Ve
}
*/
// derive initialized frames for the base case
- pSat = Cnf_DataWriteIntoSolver( pCnf, nFrames, 1 );
+ pSat = (sat_solver *)Cnf_DataWriteIntoSolver( pCnf, nFrames, 1 );
// check clauses in the base case
Beg = 0;
pStart = Vec_IntArray( vLits );
@@ -93,7 +96,7 @@ int Fra_InvariantVerify( Aig_Man_t * pAig, int nFrames, Vec_Int_t * vClauses, Ve
sat_solver_delete( pSat );
// derive initialized frames for the base case
- pSat = Cnf_DataWriteIntoSolver( pCnf, nFrames + 1, 0 );
+ pSat = (sat_solver *)Cnf_DataWriteIntoSolver( pCnf, nFrames + 1, 0 );
assert( pSat->size == 2 * pCnf->nVars );
// add clauses to the first frame
Beg = 0;
@@ -159,3 +162,5 @@ int Fra_InvariantVerify( Aig_Man_t * pAig, int nFrames, Vec_Int_t * vClauses, Ve
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/fra/fraLcr.c b/src/aig/fra/fraLcr.c
index 16912f46..b18a8fcd 100644
--- a/src/aig/fra/fraLcr.c
+++ b/src/aig/fra/fraLcr.c
@@ -20,6 +20,9 @@
#include "fra.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -197,7 +200,7 @@ void Fra_LcrAigPrepareTwo( Aig_Man_t * pAig, Fra_Man_t * p )
***********************************************************************/
int Fra_LcrNodesAreEqual( Aig_Obj_t * pObj0, Aig_Obj_t * pObj1 )
{
- Fra_Man_t * pTemp = pObj0->pData;
+ Fra_Man_t * pTemp = (Fra_Man_t *)pObj0->pData;
Fra_Lcr_t * pLcr = (Fra_Lcr_t *)pTemp->pBmc;
Aig_Man_t * pFraig;
Aig_Obj_t * pOut0, * pOut1;
@@ -215,7 +218,7 @@ int Fra_LcrNodesAreEqual( Aig_Obj_t * pObj0, Aig_Obj_t * pObj1 )
return 1;
}
assert( nPart0 == nPart1 );
- pFraig = Vec_PtrEntry( pLcr->vFraigs, nPart0 );
+ pFraig = (Aig_Man_t *)Vec_PtrEntry( pLcr->vFraigs, nPart0 );
// get the fraig outputs
pOut0 = Aig_ManPo( pFraig, pLcr->pInToOutNum[(long)pObj0->pNext] );
pOut1 = Aig_ManPo( pFraig, pLcr->pInToOutNum[(long)pObj1->pNext] );
@@ -235,7 +238,7 @@ int Fra_LcrNodesAreEqual( Aig_Obj_t * pObj0, Aig_Obj_t * pObj1 )
***********************************************************************/
int Fra_LcrNodeIsConst( Aig_Obj_t * pObj )
{
- Fra_Man_t * pTemp = pObj->pData;
+ Fra_Man_t * pTemp = (Fra_Man_t *)pObj->pData;
Fra_Lcr_t * pLcr = (Fra_Lcr_t *)pTemp->pBmc;
Aig_Man_t * pFraig;
Aig_Obj_t * pOut;
@@ -243,7 +246,7 @@ int Fra_LcrNodeIsConst( Aig_Obj_t * pObj )
assert( Aig_ObjIsPi(pObj) );
// find the partition to which these nodes belong
nPart = pLcr->pInToOutPart[(long)pObj->pNext];
- pFraig = Vec_PtrEntry( pLcr->vFraigs, nPart );
+ pFraig = (Aig_Man_t *)Vec_PtrEntry( pLcr->vFraigs, nPart );
// get the fraig outputs
pOut = Aig_ManPo( pFraig, pLcr->pInToOutNum[(long)pObj->pNext] );
return Aig_ObjFanin0(pOut) == Aig_ManConst1(pFraig);
@@ -264,14 +267,14 @@ Aig_Obj_t * Fra_LcrManDup_rec( Aig_Man_t * pNew, Aig_Man_t * p, Aig_Obj_t * pObj
{
Aig_Obj_t * pObjNew;
if ( pObj->pData )
- return pObj->pData;
+ return (Aig_Obj_t *)pObj->pData;
Fra_LcrManDup_rec( pNew, p, Aig_ObjFanin0(pObj) );
if ( Aig_ObjIsBuf(pObj) )
- return pObj->pData = Aig_ObjChild0Copy(pObj);
+ return (Aig_Obj_t *)(pObj->pData = Aig_ObjChild0Copy(pObj));
Fra_LcrManDup_rec( pNew, p, Aig_ObjFanin1(pObj) );
pObjNew = Aig_Oper( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj), Aig_ObjType(pObj) );
Aig_Regular(pObjNew)->pHaig = pObj->pHaig;
- return pObj->pData = pObjNew;
+ return (Aig_Obj_t *)(pObj->pData = pObjNew);
}
/**Function*************************************************************
@@ -308,7 +311,7 @@ Aig_Man_t * Fra_LcrDeriveAigForPartitioning( Fra_Lcr_t * pLcr )
Aig_ManCleanData( pLcr->pAig );
pNew = Aig_ManStartFrom( pLcr->pAig );
// go over the equivalence classes
- Vec_PtrForEachEntry( pLcr->pCla->vClasses, ppClass, i )
+ Vec_PtrForEachEntry( Aig_Obj_t **, pLcr->pCla->vClasses, ppClass, i )
{
pMiter = Aig_ManConst0(pNew);
for ( c = 0; ppClass[c]; c++ )
@@ -321,7 +324,7 @@ Aig_Man_t * Fra_LcrDeriveAigForPartitioning( Fra_Lcr_t * pLcr )
Aig_ObjCreatePo( pNew, pMiter );
}
// go over the constant candidates
- Vec_PtrForEachEntry( pLcr->pCla->vClasses1, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, pLcr->pCla->vClasses1, pObj, i )
{
assert( Aig_ObjIsPi(pObj) );
pObjPo = Aig_ManPo( pLcr->pAig, Offset+(long)pObj->pNext );
@@ -349,14 +352,14 @@ void Fra_LcrRemapPartitions( Vec_Ptr_t * vParts, Fra_Cla_t * pCla, int * pInToOu
int Out, Offset, i, k, c;
// compute the LO/LI offset
Offset = Aig_ManPoNum(pCla->pAig) - Aig_ManPiNum(pCla->pAig);
- Vec_PtrForEachEntry( vParts, vOne, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vParts, vOne, i )
{
vOneNew = Vec_IntAlloc( Vec_IntSize(vOne) );
Vec_IntForEachEntry( vOne, Out, k )
{
if ( Out < Vec_PtrSize(pCla->vClasses) )
{
- ppClass = Vec_PtrEntry( pCla->vClasses, Out );
+ ppClass = (Aig_Obj_t **)Vec_PtrEntry( pCla->vClasses, Out );
for ( c = 0; ppClass[c]; c++ )
{
pInToOutPart[(long)ppClass[c]->pNext] = i;
@@ -366,7 +369,7 @@ void Fra_LcrRemapPartitions( Vec_Ptr_t * vParts, Fra_Cla_t * pCla, int * pInToOu
}
else
{
- pObjPi = Vec_PtrEntry( pCla->vClasses1, Out - Vec_PtrSize(pCla->vClasses) );
+ pObjPi = (Aig_Obj_t *)Vec_PtrEntry( pCla->vClasses1, Out - Vec_PtrSize(pCla->vClasses) );
pInToOutPart[(long)pObjPi->pNext] = i;
pInToOutNum[(long)pObjPi->pNext] = Vec_IntSize(vOneNew);
Vec_IntPush( vOneNew, Offset+(long)pObjPi->pNext );
@@ -393,7 +396,7 @@ Aig_Obj_t * Fra_LcrCreatePart_rec( Fra_Cla_t * pCla, Aig_Man_t * pNew, Aig_Man_t
{
assert( !Aig_IsComplement(pObj) );
if ( Aig_ObjIsTravIdCurrent(p, pObj) )
- return pObj->pData;
+ return (Aig_Obj_t *)pObj->pData;
Aig_ObjSetTravIdCurrent(p, pObj);
if ( Aig_ObjIsPi(pObj) )
{
@@ -404,13 +407,13 @@ Aig_Obj_t * Fra_LcrCreatePart_rec( Fra_Cla_t * pCla, Aig_Man_t * pNew, Aig_Man_t
else
{
pObj->pData = Fra_LcrCreatePart_rec( pCla, pNew, p, pRepr );
- pObj->pData = Aig_NotCond( pObj->pData, pRepr->fPhase ^ pObj->fPhase );
+ pObj->pData = Aig_NotCond( (Aig_Obj_t *)pObj->pData, pRepr->fPhase ^ pObj->fPhase );
}
- return pObj->pData;
+ return (Aig_Obj_t *)pObj->pData;
}
Fra_LcrCreatePart_rec( pCla, pNew, p, Aig_ObjFanin0(pObj) );
Fra_LcrCreatePart_rec( pCla, pNew, p, Aig_ObjFanin1(pObj) );
- return pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
+ return (Aig_Obj_t *)(pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) ));
}
/**Function*************************************************************
@@ -467,12 +470,12 @@ void Fra_ClassNodesMark( Fra_Lcr_t * p )
// compute the LO/LI offset
Offset = Aig_ManPoNum(p->pCla->pAig) - Aig_ManPiNum(p->pCla->pAig);
// mark the nodes remaining in the classes
- Vec_PtrForEachEntry( p->pCla->vClasses1, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->pCla->vClasses1, pObj, i )
{
pObj = Aig_ManPo( p->pCla->pAig, Offset+(long)pObj->pNext );
pObj->fMarkA = 1;
}
- Vec_PtrForEachEntry( p->pCla->vClasses, ppClass, i )
+ Vec_PtrForEachEntry( Aig_Obj_t **, p->pCla->vClasses, ppClass, i )
{
for ( c = 0; ppClass[c]; c++ )
{
@@ -500,12 +503,12 @@ void Fra_ClassNodesUnmark( Fra_Lcr_t * p )
// compute the LO/LI offset
Offset = Aig_ManPoNum(p->pCla->pAig) - Aig_ManPiNum(p->pCla->pAig);
// mark the nodes remaining in the classes
- Vec_PtrForEachEntry( p->pCla->vClasses1, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->pCla->vClasses1, pObj, i )
{
pObj = Aig_ManPo( p->pCla->pAig, Offset+(long)pObj->pNext );
pObj->fMarkA = 0;
}
- Vec_PtrForEachEntry( p->pCla->vClasses, ppClass, i )
+ Vec_PtrForEachEntry( Aig_Obj_t **, p->pCla->vClasses, ppClass, i )
{
for ( c = 0; ppClass[c]; c++ )
{
@@ -610,12 +613,12 @@ p->timePart += clock() - clk2;
// derive AIGs for each partition
Fra_ClassNodesMark( p );
Vec_PtrClear( p->vFraigs );
- Vec_PtrForEachEntry( p->vParts, vPart, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, p->vParts, vPart, i )
{
int clk3 = clock();
if ( TimeLimit != 0.0 && clock() > TimeToStop )
{
- Vec_PtrForEachEntry( p->vFraigs, pAigPart, i )
+ Vec_PtrForEachEntry( Aig_Man_t *, p->vFraigs, pAigPart, i )
Aig_ManStop( pAigPart );
Aig_ManCleanMarkA( pAig );
Aig_ManCleanMarkB( pAig );
@@ -657,7 +660,7 @@ ABC_PRT( "Time", clock() - clk3 );
if ( Fra_ClassesRefine1( p->pCla, 0, NULL ) )
p->fRefining = 1;
// clean the fraigs
- Vec_PtrForEachEntry( p->vFraigs, pAigPart, i )
+ Vec_PtrForEachEntry( Aig_Man_t *, p->vFraigs, pAigPart, i )
Aig_ManStop( pAigPart );
// repartition if needed
@@ -702,3 +705,5 @@ finish:
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/fra/fraMan.c b/src/aig/fra/fraMan.c
index 8bdd147d..7e427e72 100644
--- a/src/aig/fra/fraMan.c
+++ b/src/aig/fra/fraMan.c
@@ -20,6 +20,9 @@
#include "fra.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -307,3 +310,5 @@ void Fra_ManPrint( Fra_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/fra/fraPart.c b/src/aig/fra/fraPart.c
index 6dfbd2e9..9556bb51 100644
--- a/src/aig/fra/fraPart.c
+++ b/src/aig/fra/fraPart.c
@@ -20,6 +20,9 @@
#include "fra.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -63,7 +66,7 @@ ABC_PRT( "Supports", clock() - clk );
// remove last entry
Aig_ManForEachPo( p, pObj, i )
{
- vSup = Vec_VecEntry( vSupps, i );
+ vSup = (Vec_Int_t *)Vec_VecEntry( vSupps, i );
Vec_IntPop( vSup );
// remember support
// pObj->pNext = (Aig_Obj_t *)vSup;
@@ -74,7 +77,7 @@ clk = clock();
vSuppsIn = Vec_VecStart( Aig_ManPiNum(p) );
Aig_ManForEachPo( p, pObj, i )
{
- vSup = Vec_VecEntry( vSupps, i );
+ vSup = (Vec_Int_t *)Vec_VecEntry( vSupps, i );
Vec_IntForEachEntry( vSup, Entry, k )
Vec_VecPush( vSuppsIn, Entry, (void *)(ABC_PTRUINT_T)i );
}
@@ -91,7 +94,7 @@ clk = clock();
{
// Bar_ProgressUpdate( pProgress, i, NULL );
// get old supports
- vSup = Vec_VecEntry( vSupps, i );
+ vSup = (Vec_Int_t *)Vec_VecEntry( vSupps, i );
if ( Vec_IntSize(vSup) < 2 )
continue;
// compute new supports
@@ -106,7 +109,7 @@ clk = clock();
// pObj = Aig_ManObj( p, Entry );
// get support of this output
// vSup2 = (Vec_Int_t *)pObj->pNext;
- vSup2 = Vec_VecEntry( vSupps, k );
+ vSup2 = (Vec_Int_t *)Vec_VecEntry( vSupps, k );
// count the number of common vars
nCommon = Vec_IntTwoCountCommon(vSup, vSup2);
if ( nCommon < 2 )
@@ -197,7 +200,7 @@ ABC_PRT( "Supports", clock() - clk );
// remove last entry
Aig_ManForEachPo( p, pObj, i )
{
- vSup = Vec_VecEntry( vSupps, i );
+ vSup = (Vec_Int_t *)Vec_VecEntry( vSupps, i );
Vec_IntPop( vSup );
// remember support
// pObj->pNext = (Aig_Obj_t *)vSup;
@@ -210,7 +213,7 @@ clk = clock();
{
if ( i == p->nAsserts )
break;
- vSup = Vec_VecEntry( vSupps, i );
+ vSup = (Vec_Int_t *)Vec_VecEntry( vSupps, i );
Vec_IntForEachEntry( vSup, Entry, k )
Vec_VecPush( vSuppsIn, Entry, (void *)(ABC_PTRUINT_T)i );
}
@@ -223,17 +226,17 @@ clk = clock();
{
if ( i % 50 != 0 )
continue;
- vSup = Vec_VecEntry( vSupps, i );
+ vSup = (Vec_Int_t *)Vec_VecEntry( vSupps, i );
memset( pSupp, 0, sizeof(char) * Aig_ManPiNum(p) );
// go through each input of this output
Vec_IntForEachEntry( vSup, Entry, k )
{
pSupp[Entry] = 1;
- vSup2 = Vec_VecEntry( vSuppsIn, Entry );
+ vSup2 = (Vec_Int_t *)Vec_VecEntry( vSuppsIn, Entry );
// go though each assert of this input
Vec_IntForEachEntry( vSup2, Entry2, m )
{
- vSup3 = Vec_VecEntry( vSupps, Entry2 );
+ vSup3 = (Vec_Int_t *)Vec_VecEntry( vSupps, Entry2 );
// go through each input of this assert
Vec_IntForEachEntry( vSup3, Entry3, n )
{
@@ -261,3 +264,5 @@ ABC_PRT( "Extension ", clock() - clk );
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/fra/fraSat.c b/src/aig/fra/fraSat.c
index 039a660f..50503670 100644
--- a/src/aig/fra/fraSat.c
+++ b/src/aig/fra/fraSat.c
@@ -21,6 +21,9 @@
#include <math.h>
#include "fra.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -512,7 +515,7 @@ int Fra_SetActivityFactors_rec( Fra_Man_t * p, Aig_Obj_t * pObj, int LevelMin, i
veci_push(&p->pSat->act_vars, Fra_ObjSatNum(pObj));
// explore the fanins
vFanins = Fra_ObjFaninVec( pObj );
- Vec_PtrForEachEntry( vFanins, pFanin, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vFanins, pFanin, i )
Counter += Fra_SetActivityFactors_rec( p, Aig_Regular(pFanin), LevelMin, LevelMax );
return 1 + Counter;
}
@@ -557,3 +560,5 @@ p->timeTrav += clock() - clk;
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/fra/fraSec.c b/src/aig/fra/fraSec.c
index ccb3e7b1..1576a70a 100644
--- a/src/aig/fra/fraSec.c
+++ b/src/aig/fra/fraSec.c
@@ -23,6 +23,10 @@
#include "int.h"
#include "ssw.h"
#include "saig.h"
+#include "bbr.h"
+
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -63,7 +67,7 @@ void Fra_SecSetDefaultParams( Fra_Sec_t * p )
p->fInterpolation = 1; // enables interpolation
p->fInterSeparate = 0; // enables interpolation for each outputs separately
p->fReachability = 1; // enables BDD based reachability
- p->fReorderImage = 0; // enables variable reordering during image computation
+ p->fReorderImage = 1; // enables variable reordering during image computation
p->fStopOnFirstFail = 1; // enables stopping after first output of a miter has failed to prove
p->fUseNewProver = 0; // enables new prover
p->fSilent = 0; // disables all output
@@ -292,7 +296,7 @@ ABC_PRT( "Time", clock() - clk );
// perform min-area retiming
if ( pParSec->fRetimeRegs && pNew->nRegs )
{
- extern Aig_Man_t * Saig_ManRetimeMinArea( Aig_Man_t * p, int nMaxIters, int fForwardOnly, int fBackwardOnly, int fInitial, int fVerbose );
+// extern Aig_Man_t * Saig_ManRetimeMinArea( Aig_Man_t * p, int nMaxIters, int fForwardOnly, int fBackwardOnly, int fInitial, int fVerbose );
clk = clock();
pNew->nTruePis = Aig_ManPiNum(pNew) - Aig_ManRegNum(pNew);
pNew->nTruePos = Aig_ManPoNum(pNew) - Aig_ManRegNum(pNew);
@@ -353,9 +357,9 @@ clk = clock();
Aig_ManSetRegNum( pNew, pNew->nRegs );
// pNew = Ssw_SignalCorrespondence( pTemp = pNew, pPars2 );
if ( Aig_ManRegNum(pNew) > 0 )
- pNew = Ssw_SignalCorrespondence( pTemp = pNew, pPars2 );
+ pNew = Ssw_SignalCorrespondence( pTemp = pNew, pPars2 );
else
- pNew = Aig_ManDupSimpleDfs( pTemp = pNew );
+ pNew = Aig_ManDupSimpleDfs( pTemp = pNew );
if ( pNew == NULL )
{
@@ -382,7 +386,7 @@ ABC_PRT( "Time", clock() - clk );
// if ( pParSec->fRetimeFirst && pNew->nRegs )
if ( pNew->nRegs )
{
- extern Aig_Man_t * Saig_ManRetimeMinArea( Aig_Man_t * p, int nMaxIters, int fForwardOnly, int fBackwardOnly, int fInitial, int fVerbose );
+// extern Aig_Man_t * Saig_ManRetimeMinArea( Aig_Man_t * p, int nMaxIters, int fForwardOnly, int fBackwardOnly, int fInitial, int fVerbose );
clk = clock();
pNew->nTruePis = Aig_ManPiNum(pNew) - Aig_ManRegNum(pNew);
pNew->nTruePos = Aig_ManPoNum(pNew) - Aig_ManRegNum(pNew);
@@ -480,7 +484,7 @@ clk = clock();
}
else if ( pParSec->fInterSeparate )
{
- Ssw_Cex_t * pCex = NULL;
+ Abc_Cex_t * pCex = NULL;
Aig_Man_t * pTemp, * pAux;
Aig_Obj_t * pObjPo;
int i, Counter = 0;
@@ -488,6 +492,8 @@ clk = clock();
{
if ( Aig_ObjFanin0(pObjPo) == Aig_ManConst1(pNew) )
continue;
+ if ( pPars->fVerbose )
+ printf( "Solving output %2d (out of %2d):\n", i, Saig_ManPoNum(pNew) );
pTemp = Aig_ManDupOneOutput( pNew, i, 1 );
pTemp = Aig_ManScl( pAux = pTemp, 1, 1, 0 );
Aig_ManStop( pAux );
@@ -537,7 +543,7 @@ clk = clock();
RetValue = Inter_ManPerformInterpolation( pNewOrpos, pPars, &Depth );
if ( pNewOrpos->pSeqModel )
{
- Ssw_Cex_t * pCex;
+ Abc_Cex_t * pCex;
pCex = pNew->pSeqModel = pNewOrpos->pSeqModel; pNewOrpos->pSeqModel = NULL;
pCex->iPo = Ssw_SmlFindOutputCounterExample( pNew, pNew->pSeqModel );
}
@@ -561,10 +567,19 @@ ABC_PRT( "Time", clock() - clk );
// try reachability analysis
if ( pParSec->fReachability && RetValue == -1 && Aig_ManRegNum(pNew) > 0 && Aig_ManRegNum(pNew) < pParSec->nBddVarsMax )
{
- extern int Aig_ManVerifyUsingBdds( Aig_Man_t * p, int nBddMax, int nIterMax, int fPartition, int fReorder, int fReorderImage, int fVerbose, int fSilent );
+ Saig_ParBbr_t Pars, * pPars = &Pars;
+ Bbr_ManSetDefaultParams( pPars );
+ pPars->TimeLimit = 0;
+ pPars->nBddMax = pParSec->nBddMax;
+ pPars->nIterMax = pParSec->nBddIterMax;
+ pPars->fPartition = 1;
+ pPars->fReorder = 1;
+ pPars->fReorderImage = 1;
+ pPars->fVerbose = 0;
+ pPars->fSilent = pParSec->fSilent;
pNew->nTruePis = Aig_ManPiNum(pNew) - Aig_ManRegNum(pNew);
pNew->nTruePos = Aig_ManPoNum(pNew) - Aig_ManRegNum(pNew);
- RetValue = Aig_ManVerifyUsingBdds( pNew, pParSec->nBddMax, pParSec->nBddIterMax, 1, 1, pParSec->fReorderImage, 0, pParSec->fSilent );
+ RetValue = Aig_ManVerifyUsingBdds( pNew, pPars );
}
finish:
@@ -645,3 +660,5 @@ ABC_PRT( "Time", clock() - clkTotal );
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/fra/fraSim.c b/src/aig/fra/fraSim.c
index 4f164e5c..25c30989 100644
--- a/src/aig/fra/fraSim.c
+++ b/src/aig/fra/fraSim.c
@@ -20,6 +20,9 @@
#include "fra.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -41,7 +44,7 @@
***********************************************************************/
int Fra_SmlNodeHash( Aig_Obj_t * pObj, int nTableSize )
{
- Fra_Man_t * p = pObj->pData;
+ Fra_Man_t * p = (Fra_Man_t *)pObj->pData;
static int s_FPrimes[128] = {
1009, 1049, 1093, 1151, 1201, 1249, 1297, 1361, 1427, 1459,
1499, 1559, 1607, 1657, 1709, 1759, 1823, 1877, 1933, 1997,
@@ -81,7 +84,7 @@ int Fra_SmlNodeHash( Aig_Obj_t * pObj, int nTableSize )
***********************************************************************/
int Fra_SmlNodeIsConst( Aig_Obj_t * pObj )
{
- Fra_Man_t * p = pObj->pData;
+ Fra_Man_t * p = (Fra_Man_t *)pObj->pData;
unsigned * pSims;
int i;
pSims = Fra_ObjSim(p->pSml, pObj->Id);
@@ -104,7 +107,7 @@ int Fra_SmlNodeIsConst( Aig_Obj_t * pObj )
***********************************************************************/
int Fra_SmlNodesAreEqual( Aig_Obj_t * pObj0, Aig_Obj_t * pObj1 )
{
- Fra_Man_t * p = pObj0->pData;
+ Fra_Man_t * p = (Fra_Man_t *)pObj0->pData;
unsigned * pSims0, * pSims1;
int i;
pSims0 = Fra_ObjSim(p->pSml, pObj0->Id);
@@ -885,12 +888,12 @@ Fra_Sml_t * Fra_SmlSimulateSeq( Aig_Man_t * pAig, int nPref, int nFrames, int nW
SeeAlso []
***********************************************************************/
-Fra_Cex_t * Fra_SmlAllocCounterExample( int nRegs, int nRealPis, int nFrames )
+Abc_Cex_t * Fra_SmlAllocCounterExample( int nRegs, int nRealPis, int nFrames )
{
- Fra_Cex_t * pCex;
+ Abc_Cex_t * pCex;
int nWords = Aig_BitWordNum( nRegs + nRealPis * nFrames );
- pCex = (Fra_Cex_t *)ABC_ALLOC( char, sizeof(Fra_Cex_t) + sizeof(unsigned) * nWords );
- memset( pCex, 0, sizeof(Fra_Cex_t) + sizeof(unsigned) * nWords );
+ pCex = (Abc_Cex_t *)ABC_ALLOC( char, sizeof(Abc_Cex_t) + sizeof(unsigned) * nWords );
+ memset( pCex, 0, sizeof(Abc_Cex_t) + sizeof(unsigned) * nWords );
pCex->nRegs = nRegs;
pCex->nPis = nRealPis;
pCex->nBits = nRegs + nRealPis * nFrames;
@@ -908,7 +911,7 @@ Fra_Cex_t * Fra_SmlAllocCounterExample( int nRegs, int nRealPis, int nFrames )
SeeAlso []
***********************************************************************/
-void Fra_SmlFreeCounterExample( Fra_Cex_t * pCex )
+void Fra_SmlFreeCounterExample( Abc_Cex_t * pCex )
{
ABC_FREE( pCex );
}
@@ -924,9 +927,9 @@ void Fra_SmlFreeCounterExample( Fra_Cex_t * pCex )
SeeAlso []
***********************************************************************/
-Fra_Cex_t * Fra_SmlGetCounterExample( Fra_Sml_t * p )
+Abc_Cex_t * Fra_SmlGetCounterExample( Fra_Sml_t * p )
{
- Fra_Cex_t * pCex;
+ Abc_Cex_t * pCex;
Aig_Obj_t * pObj;
unsigned * pSims;
int iPo, iFrame, iBit, i, k;
@@ -998,9 +1001,9 @@ Fra_Cex_t * Fra_SmlGetCounterExample( Fra_Sml_t * p )
SeeAlso []
***********************************************************************/
-Fra_Cex_t * Fra_SmlCopyCounterExample( Aig_Man_t * pAig, Aig_Man_t * pFrames, int * pModel )
+Abc_Cex_t * Fra_SmlCopyCounterExample( Aig_Man_t * pAig, Aig_Man_t * pFrames, int * pModel )
{
- Fra_Cex_t * pCex;
+ Abc_Cex_t * pCex;
Aig_Obj_t * pObj;
int i, nFrames, nTruePis, nTruePos, iPo, iFrame;
// get the number of frames
@@ -1058,9 +1061,9 @@ Fra_Cex_t * Fra_SmlCopyCounterExample( Aig_Man_t * pAig, Aig_Man_t * pFrames, in
SeeAlso []
***********************************************************************/
-Fra_Cex_t * Fra_SmlTrivCounterExample( Aig_Man_t * pAig, int iFrameOut )
+Abc_Cex_t * Fra_SmlTrivCounterExample( Aig_Man_t * pAig, int iFrameOut )
{
- Fra_Cex_t * pCex;
+ Abc_Cex_t * pCex;
int nTruePis, nTruePos, iPo, iFrame;
assert( Aig_ManRegNum(pAig) > 0 );
nTruePis = Aig_ManPiNum(pAig)-Aig_ManRegNum(pAig);
@@ -1085,7 +1088,7 @@ Fra_Cex_t * Fra_SmlTrivCounterExample( Aig_Man_t * pAig, int iFrameOut )
SeeAlso []
***********************************************************************/
-int Fra_SmlRunCounterExample( Aig_Man_t * pAig, Fra_Cex_t * p )
+int Fra_SmlRunCounterExample( Aig_Man_t * pAig, Abc_Cex_t * p )
{
Fra_Sml_t * pSml;
Aig_Obj_t * pObj;
@@ -1113,6 +1116,38 @@ int Fra_SmlRunCounterExample( Aig_Man_t * pAig, Fra_Cex_t * p )
/**Function*************************************************************
+ Synopsis [Make the trivial counter-example for the trivially asserted output.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Abc_Cex_t * Fra_SmlSimpleCounterExample( Aig_Man_t * pAig, int * pModel, int iFrame, int iPo )
+{
+ Abc_Cex_t * pCex;
+ int iBit;
+ pCex = Fra_SmlAllocCounterExample( Aig_ManRegNum(pAig), Aig_ManPiNum(pAig)-Aig_ManRegNum(pAig), iFrame + 1 );
+ pCex->iPo = iPo;
+ pCex->iFrame = iFrame;
+ for ( iBit = Aig_ManRegNum(pAig); iBit < pCex->nBits; iBit++ )
+ if ( pModel[iBit-Aig_ManRegNum(pAig)] )
+ Aig_InfoSetBit( pCex->pData, iBit );
+/*
+ if ( !Fra_SmlRunCounterExample( pAig, pCex ) )
+ {
+ printf( "Fra_SmlSimpleCounterExample(): Counter-example is invalid.\n" );
+// Fra_SmlFreeCounterExample( pCex );
+// pCex = NULL;
+ }
+*/
+ return pCex;
+}
+
+/**Function*************************************************************
+
Synopsis [Resimulates the counter-example.]
Description []
@@ -1122,7 +1157,7 @@ int Fra_SmlRunCounterExample( Aig_Man_t * pAig, Fra_Cex_t * p )
SeeAlso []
***********************************************************************/
-int Fra_SmlWriteCounterExample( FILE * pFile, Aig_Man_t * pAig, Fra_Cex_t * p )
+int Fra_SmlWriteCounterExample( FILE * pFile, Aig_Man_t * pAig, Abc_Cex_t * p )
{
Fra_Sml_t * pSml;
Aig_Obj_t * pObj;
@@ -1191,3 +1226,5 @@ int Fra_SmlWriteCounterExample( FILE * pFile, Aig_Man_t * pAig, Fra_Cex_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/fra/fra_.c b/src/aig/fra/fra_.c
index 2b601587..8e5785ec 100644
--- a/src/aig/fra/fra_.c
+++ b/src/aig/fra/fra_.c
@@ -20,6 +20,9 @@
#include "fra.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -46,3 +49,5 @@
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/fsim/fsim.h b/src/aig/fsim/fsim.h
index 4e1588a7..fabc5254 100644
--- a/src/aig/fsim/fsim.h
+++ b/src/aig/fsim/fsim.h
@@ -21,6 +21,7 @@
#ifndef __FSIM_H__
#define __FSIM_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -29,9 +30,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -85,9 +87,11 @@ extern Vec_Int_t * Fsim_ManSwitchSimulate( Aig_Man_t * pAig, Fsim_ParSwitch_t
/*=== fsimTsim.c ==========================================================*/
extern Vec_Ptr_t * Fsim_ManTerSimulate( Aig_Man_t * pAig, int fVerbose );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/aig/fsim/fsimCore.c b/src/aig/fsim/fsimCore.c
index 2a159cbe..9516f09e 100644
--- a/src/aig/fsim/fsimCore.c
+++ b/src/aig/fsim/fsimCore.c
@@ -20,6 +20,9 @@
#include "fsimInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -81,3 +84,5 @@ void Fsim_ManSetDefaultParamsSwitch( Fsim_ParSwitch_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/fsim/fsimFront.c b/src/aig/fsim/fsimFront.c
index 14906c0b..6169543c 100644
--- a/src/aig/fsim/fsimFront.c
+++ b/src/aig/fsim/fsimFront.c
@@ -20,6 +20,9 @@
#include "fsimInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -362,3 +365,5 @@ void Fsim_ManFront( Fsim_Man_t * p, int fCompressAig )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/fsim/fsimInt.h b/src/aig/fsim/fsimInt.h
index f46a9024..f5dee298 100644
--- a/src/aig/fsim/fsimInt.h
+++ b/src/aig/fsim/fsimInt.h
@@ -21,6 +21,7 @@
#ifndef __FSIM_INT_H__
#define __FSIM_INT_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -32,9 +33,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -122,9 +124,11 @@ extern Fsim_Man_t * Fsim_ManCreate( Aig_Man_t * pAig );
extern void Fsim_ManDelete( Fsim_Man_t * p );
extern void Fsim_ManTest( Aig_Man_t * pAig );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/aig/fsim/fsimMan.c b/src/aig/fsim/fsimMan.c
index 872e1604..ea0cab43 100644
--- a/src/aig/fsim/fsimMan.c
+++ b/src/aig/fsim/fsimMan.c
@@ -20,6 +20,9 @@
#include "fsimInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -205,3 +208,5 @@ void Fsim_ManTest( Aig_Man_t * pAig )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/fsim/fsimSim.c b/src/aig/fsim/fsimSim.c
index 52dedc6d..2da7db15 100644
--- a/src/aig/fsim/fsimSim.c
+++ b/src/aig/fsim/fsimSim.c
@@ -21,6 +21,9 @@
#include "fsimInt.h"
#include "ssw.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -426,9 +429,9 @@ static inline int Fsim_ManCheckPos( Fsim_Man_t * p, int * piPo, int * piPat )
SeeAlso []
***********************************************************************/
-Ssw_Cex_t * Fsim_ManGenerateCounter( Aig_Man_t * pAig, int iFrame, int iOut, int nWords, int iPat, Vec_Int_t * vCis2Ids )
+Abc_Cex_t * Fsim_ManGenerateCounter( Aig_Man_t * pAig, int iFrame, int iOut, int nWords, int iPat, Vec_Int_t * vCis2Ids )
{
- Ssw_Cex_t * p;
+ Abc_Cex_t * p;
unsigned * pData;
int f, i, w, iPioId, Counter;
p = Ssw_SmlAllocCounterExample( Aig_ManRegNum(pAig), Saig_ManPiNum(pAig), iFrame+1 );
@@ -514,7 +517,7 @@ int Fsim_ManSimulate( Aig_Man_t * pAig, Fsim_ParSim_t * pPars )
p->pDataSimCos = ABC_ALLOC( unsigned, p->nWords * p->nCos );
Fsim_ManSimInfoInit( p );
for ( i = 0; i < pPars->nIters; i++ )
- {
+ {
Fsim_ManSimulateRound( p );
if ( pPars->fVerbose )
{
@@ -530,15 +533,14 @@ int Fsim_ManSimulate( Aig_Man_t * pAig, Fsim_ParSim_t * pPars )
break;
}
if ( (clock() - clkTotal)/CLOCKS_PER_SEC >= pPars->TimeLimit )
- {
- printf( "No bug detected after %d frames with time limit %d seconds.\n", i+1, pPars->TimeLimit );
break;
- }
clk2 = clock();
if ( i < pPars->nIters - 1 )
Fsim_ManSimInfoTransfer( p );
clk2Total += clock() - clk2;
}
+ if ( pAig->pSeqModel == NULL )
+ printf( "No bug detected after %d frames with time limit %d seconds.\n", i+1, pPars->TimeLimit );
if ( pPars->fVerbose )
{
printf( "Maxcut = %8d. AigMem = %7.2f Mb. SimMem = %7.2f Mb. ",
@@ -561,3 +563,5 @@ int Fsim_ManSimulate( Aig_Man_t * pAig, Fsim_ParSim_t * pPars )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/fsim/fsimSwitch.c b/src/aig/fsim/fsimSwitch.c
index 97cb612f..3eef2d4c 100644
--- a/src/aig/fsim/fsimSwitch.c
+++ b/src/aig/fsim/fsimSwitch.c
@@ -20,6 +20,9 @@
#include "fsimInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -33,3 +36,5 @@
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/fsim/fsimTsim.c b/src/aig/fsim/fsimTsim.c
index 0de283e4..e05e6409 100644
--- a/src/aig/fsim/fsimTsim.c
+++ b/src/aig/fsim/fsimTsim.c
@@ -20,6 +20,9 @@
#include "fsimInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -408,3 +411,5 @@ Vec_Ptr_t * Fsim_ManTerSimulate( Aig_Man_t * pAig, int fVerbose )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/gia.c b/src/aig/gia/gia.c
index 4cbb1731..4fb33a9b 100644
--- a/src/aig/gia/gia.c
+++ b/src/aig/gia/gia.c
@@ -20,6 +20,9 @@
#include "gia.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -45,3 +48,5 @@
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/gia.h b/src/aig/gia/gia.h
index f023366a..3358ca76 100644
--- a/src/aig/gia/gia.h
+++ b/src/aig/gia/gia.h
@@ -21,6 +21,7 @@
#ifndef __GIA_H__
#define __GIA_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -37,9 +38,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
#define GIA_NONE 0x1FFFFFFF
#define GIA_VOID 0x0FFFFFFF
@@ -48,6 +50,10 @@ extern "C" {
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
+typedef struct Gia_MmFixed_t_ Gia_MmFixed_t;
+typedef struct Gia_MmFlex_t_ Gia_MmFlex_t;
+typedef struct Gia_MmStep_t_ Gia_MmStep_t;
+
typedef struct Gia_Rpr_t_ Gia_Rpr_t;
struct Gia_Rpr_t_
{
@@ -88,18 +94,6 @@ struct Gia_Obj_t_
// - traversal ID of the node during traversal
// - reference counter of the node (will not be used in the future)
-// sequential counter-example
-typedef struct Gia_Cex_t_ Gia_Cex_t;
-struct Gia_Cex_t_
-{
- int iPo; // the zero-based number of PO, for which verification failed
- int iFrame; // the zero-based number of the time-frame, for which verificaiton failed
- int nRegs; // the number of registers in the miter
- int nPis; // the number of primary inputs in the miter
- int nBits; // the number of words of bit data used
- unsigned pData[0]; // the cex bit data (the number of bits: nRegs + (iFrame+1) * nPis)
-};
-
// new AIG manager
typedef struct Gia_Man_t_ Gia_Man_t;
struct Gia_Man_t_
@@ -116,8 +110,10 @@ struct Gia_Man_t_
int nHTable; // hash table size
int fAddStrash; // performs additional structural hashing
int * pRefs; // the reference count
- int * pLevels; // levels of the nodes
+ int * pNodeRefs; // node references
+ Vec_Int_t * vLevels; // levels of the nodes
int nLevels; // the mamixum level
+ int nConstrs; // the number of constraints
int nTravIds; // the current traversal ID
int nFront; // frontier size
int * pReprsOld; // representatives (for CIs and ANDs)
@@ -129,9 +125,11 @@ struct Gia_Man_t_
int * pFanData; // the database to store fanout information
int nFansAlloc; // the size of fanout representation
int * pMapping; // mapping for each node
- Gia_Cex_t * pCexComb; // combinational counter-example
- Gia_Cex_t * pCexSeq; // sequential counter-example
+ Vec_Int_t * vLutConfigs; // LUT configurations
+ Abc_Cex_t * pCexComb; // combinational counter-example
+ Abc_Cex_t * pCexSeq; // sequential counter-example
int * pCopies; // intermediate copies
+ Vec_Int_t * vTruths; // used for truth table computation
Vec_Int_t * vFlopClasses; // classes of flops for retiming/merging/etc
unsigned char* pSwitching; // switching activity for each object
Gia_Plc_t * pPlacement; // placement of the objects
@@ -139,6 +137,12 @@ struct Gia_Man_t_
int nTravIdsAlloc; // the number of trav IDs allocated
Vec_Ptr_t * vNamesIn; // the input names
Vec_Ptr_t * vNamesOut; // the output names
+ Vec_Int_t * vCiNumsOrig; // original names of the CIs
+ Vec_Int_t * vCoNumsOrig; // original names of the COs
+ Vec_Vec_t * vClockDoms; // clock domains
+ Vec_Flt_t * vTiming; // arrival/required/slack
+ void * pManTime; // the timing manager
+ void * pLutLib; // LUT library
};
@@ -178,26 +182,31 @@ struct Gia_ParSim_t_
int TimeLimit; // time limit in seconds
int fCheckMiter; // check if miter outputs are non-zero
int fVerbose; // enables verbose output
+ int iOutFail; // index of the failed output
};
extern void Gia_ManSimSetDefaultParams( Gia_ParSim_t * p );
extern int Gia_ManSimSimulate( Gia_Man_t * pAig, Gia_ParSim_t * pPars );
-static inline int Gia_IntAbs( int n ) { return (n < 0)? -n : n; }
-static inline int Gia_Float2Int( float Val ) { return *((int *)&Val); }
-static inline float Gia_Int2Float( int Num ) { return *((float *)&Num); }
-static inline int Gia_Base2Log( unsigned n ) { int r; assert( n >= 0 ); if ( n < 2 ) return n; for ( r = 0, n--; n; n >>= 1, r++ ); return r; }
-static inline int Gia_Base10Log( unsigned n ) { int r; assert( n >= 0 ); if ( n < 2 ) return n; for ( r = 0, n--; n; n /= 10, r++ ); return r; }
-static inline char * Gia_UtilStrsav( char * s ) { return s ? strcpy(ABC_ALLOC(char, strlen(s)+1), s) : NULL; }
-static inline int Gia_BitWordNum( int nBits ) { return (nBits>>5) + ((nBits&31) > 0); }
-static inline int Gia_TruthWordNum( int nVars ) { return nVars <= 5 ? 1 : (1 << (nVars - 5)); }
-static inline int Gia_InfoHasBit( unsigned * p, int i ) { return (p[(i)>>5] & (1<<((i) & 31))) > 0; }
-static inline void Gia_InfoSetBit( unsigned * p, int i ) { p[(i)>>5] |= (1<<((i) & 31)); }
-static inline void Gia_InfoXorBit( unsigned * p, int i ) { p[(i)>>5] ^= (1<<((i) & 31)); }
-static inline unsigned Gia_InfoMask( int nVar ) { return (~(unsigned)0) >> (32-nVar); }
-static inline unsigned Gia_ObjCutSign( unsigned ObjId ) { return (1 << (ObjId & 31)); }
-static inline int Gia_WordHasOneBit( unsigned uWord ) { return (uWord & (uWord-1)) == 0; }
+static inline int Gia_IntAbs( int n ) { return (n < 0)? -n : n; }
+//static inline int Gia_Float2Int( float Val ) { return *((int *)&Val); }
+//static inline float Gia_Int2Float( int Num ) { return *((float *)&Num); }
+static inline int Gia_Float2Int( float Val ) { union { int x; float y; } v; v.y = Val; return v.x; }
+static inline float Gia_Int2Float( int Num ) { union { int x; float y; } v; v.x = Num; return v.y; }
+static inline int Gia_Base2Log( unsigned n ) { int r; if ( n < 2 ) return n; for ( r = 0, n--; n; n >>= 1, r++ ); return r; }
+static inline int Gia_Base10Log( unsigned n ) { int r; if ( n < 2 ) return n; for ( r = 0, n--; n; n /= 10, r++ ); return r; }
+static inline int Gia_Base16Log( unsigned n ) { int r; if ( n < 2 ) return n; for ( r = 0, n--; n; n /= 16, r++ ); return r; }
+static inline char * Gia_UtilStrsav( char * s ) { return s ? strcpy(ABC_ALLOC(char, strlen(s)+1), s) : NULL; }
+static inline int Gia_BitWordNum( int nBits ) { return (nBits>>5) + ((nBits&31) > 0); }
+static inline int Gia_TruthWordNum( int nVars ) { return nVars <= 5 ? 1 : (1 << (nVars - 5)); }
+static inline int Gia_InfoHasBit( unsigned * p, int i ) { return (p[(i)>>5] & (1<<((i) & 31))) > 0; }
+static inline void Gia_InfoSetBit( unsigned * p, int i ) { p[(i)>>5] |= (1<<((i) & 31)); }
+static inline void Gia_InfoXorBit( unsigned * p, int i ) { p[(i)>>5] ^= (1<<((i) & 31)); }
+static inline unsigned Gia_InfoMask( int nVar ) { return (~(unsigned)0) >> (32-nVar); }
+static inline unsigned Gia_ObjCutSign( unsigned ObjId ) { return (1 << (ObjId & 31)); }
+static inline int Gia_WordHasOneBit( unsigned uWord ) { return (uWord & (uWord-1)) == 0; }
+static inline int Gia_WordHasOnePair( unsigned uWord ) { return Gia_WordHasOneBit(uWord & (uWord>>1) & 0x55555555); }
static inline int Gia_WordCountOnes( unsigned uWord )
{
uWord = (uWord & 0x55555555) + ((uWord>>1) & 0x55555555);
@@ -206,7 +215,7 @@ static inline int Gia_WordCountOnes( unsigned uWord )
uWord = (uWord & 0x00FF00FF) + ((uWord>>8) & 0x00FF00FF);
return (uWord & 0x0000FFFF) + (uWord>>16);
}
-static inline int Gia_WordFindFirstBit( unsigned uWord )
+static inline int Gia_WordFindFirstBit( unsigned uWord )
{
int i;
for ( i = 0; i < 32; i++ )
@@ -215,6 +224,46 @@ static inline int Gia_WordFindFirstBit( unsigned uWord )
return -1;
}
+static inline int Gia_ManTruthIsConst0( unsigned * pIn, int nVars )
+{
+ int w;
+ for ( w = Gia_TruthWordNum(nVars)-1; w >= 0; w-- )
+ if ( pIn[w] )
+ return 0;
+ return 1;
+}
+static inline int Gia_ManTruthIsConst1( unsigned * pIn, int nVars )
+{
+ int w;
+ for ( w = Gia_TruthWordNum(nVars)-1; w >= 0; w-- )
+ if ( pIn[w] != ~(unsigned)0 )
+ return 0;
+ return 1;
+}
+static inline void Gia_ManTruthCopy( unsigned * pOut, unsigned * pIn, int nVars )
+{
+ int w;
+ for ( w = Gia_TruthWordNum(nVars)-1; w >= 0; w-- )
+ pOut[w] = pIn[w];
+}
+static inline void Gia_ManTruthClear( unsigned * pOut, int nVars )
+{
+ int w;
+ for ( w = Gia_TruthWordNum(nVars)-1; w >= 0; w-- )
+ pOut[w] = 0;
+}
+static inline void Gia_ManTruthFill( unsigned * pOut, int nVars )
+{
+ int w;
+ for ( w = Gia_TruthWordNum(nVars)-1; w >= 0; w-- )
+ pOut[w] = ~(unsigned)0;
+}
+static inline void Gia_ManTruthNot( unsigned * pOut, unsigned * pIn, int nVars )
+{
+ int w;
+ for ( w = Gia_TruthWordNum(nVars)-1; w >= 0; w-- )
+ pOut[w] = ~pIn[w];
+}
static inline int Gia_Var2Lit( int Var, int fCompl ) { return Var + Var + fCompl; }
static inline int Gia_Lit2Var( int Lit ) { return Lit >> 1; }
@@ -236,6 +285,7 @@ static inline int Gia_ManRegNum( Gia_Man_t * p ) { return p->nRegs
static inline int Gia_ManObjNum( Gia_Man_t * p ) { return p->nObjs; }
static inline int Gia_ManAndNum( Gia_Man_t * p ) { return p->nObjs - Vec_IntSize(p->vCis) - Vec_IntSize(p->vCos) - 1; }
static inline int Gia_ManCandNum( Gia_Man_t * p ) { return Gia_ManCiNum(p) + Gia_ManAndNum(p); }
+static inline int Gia_ManConstrNum( Gia_Man_t * p ) { return p->nConstrs; }
static inline Gia_Obj_t * Gia_ManConst0( Gia_Man_t * p ) { return p->pObjs; }
static inline Gia_Obj_t * Gia_ManConst1( Gia_Man_t * p ) { return Gia_Not(Gia_ManConst0(p)); }
@@ -259,6 +309,8 @@ static inline int Gia_ManObjIsConst0( Gia_Man_t * p, Gia_Obj_t * pObj){
static inline int Gia_ObjId( Gia_Man_t * p, Gia_Obj_t * pObj ) { assert( p->pObjs <= pObj && pObj < p->pObjs + p->nObjs ); return pObj - p->pObjs; }
static inline int Gia_ObjCioId( Gia_Obj_t * pObj ) { assert( Gia_ObjIsTerm(pObj) ); return pObj->iDiff1; }
static inline void Gia_ObjSetCioId( Gia_Obj_t * pObj, int v ) { assert( Gia_ObjIsTerm(pObj) ); pObj->iDiff1 = v; }
+static inline int Gia_ObjValue( Gia_Obj_t * pObj ) { return pObj->Value; }
+static inline void Gia_ObjSetValue( Gia_Obj_t * pObj, int i ) { pObj->Value = i; }
static inline int Gia_ObjPhase( Gia_Obj_t * pObj ) { return pObj->fPhase; }
static inline int Gia_ObjPhaseReal( Gia_Obj_t * pObj ) { return Gia_Regular(pObj)->fPhase ^ Gia_IsComplement(pObj); }
@@ -302,10 +354,14 @@ static inline Gia_Obj_t * Gia_ObjFromLit( Gia_Man_t * p, int iLit ) {
static inline int Gia_ObjToLit( Gia_Man_t * p, Gia_Obj_t * pObj ) { return Gia_Var2Lit( Gia_ObjId(p, Gia_Regular(pObj)), Gia_IsComplement(pObj) ); }
static inline int Gia_ObjPhaseRealLit( Gia_Man_t * p, int iLit ) { return Gia_ObjPhaseReal( Gia_ObjFromLit(p, iLit) ); }
-static inline int Gia_ObjValue( Gia_Obj_t * pObj ) { return pObj->Value; }
-static inline int Gia_ObjLevel( Gia_Man_t * p, Gia_Obj_t * pObj ) { assert(p->pLevels);return p->pLevels[Gia_ObjId(p, pObj)]; }
+static inline int Gia_ObjLevel( Gia_Man_t * p, Gia_Obj_t * pObj ) { return Vec_IntGetEntry(p->vLevels, Gia_ObjId(p,pObj)); }
+static inline int Gia_ObjLevelId( Gia_Man_t * p, int Id ) { return Vec_IntGetEntry(p->vLevels, Id); }
+static inline void Gia_ObjSetLevel( Gia_Man_t * p, Gia_Obj_t * pObj, int l ) { Vec_IntSetEntry(p->vLevels, Gia_ObjId(p,pObj), l); }
+static inline void Gia_ObjSetCoLevel( Gia_Man_t * p, Gia_Obj_t * pObj ) { assert( Gia_ObjIsCo(pObj) ); Gia_ObjSetLevel( p, pObj, Gia_ObjLevel(p,Gia_ObjFanin0(pObj)) ); }
+static inline void Gia_ObjSetAndLevel( Gia_Man_t * p, Gia_Obj_t * pObj ) { assert( Gia_ObjIsAnd(pObj) ); Gia_ObjSetLevel( p, pObj, 1+ABC_MAX(Gia_ObjLevel(p,Gia_ObjFanin0(pObj)),Gia_ObjLevel(p,Gia_ObjFanin1(pObj))) ); }
static inline int Gia_ObjRefs( Gia_Man_t * p, Gia_Obj_t * pObj ) { assert( p->pRefs); return p->pRefs[Gia_ObjId(p, pObj)]; }
+static inline int Gia_ObjRefsId( Gia_Man_t * p, int Id ) { assert( p->pRefs); return p->pRefs[Id]; }
static inline int Gia_ObjRefInc( Gia_Man_t * p, Gia_Obj_t * pObj ) { assert( p->pRefs); return p->pRefs[Gia_ObjId(p, pObj)]++; }
static inline int Gia_ObjRefDec( Gia_Man_t * p, Gia_Obj_t * pObj ) { assert( p->pRefs); return --p->pRefs[Gia_ObjId(p, pObj)]; }
static inline void Gia_ObjRefFanin0Inc(Gia_Man_t * p, Gia_Obj_t * pObj){ assert( p->pRefs); Gia_ObjRefInc(p, Gia_ObjFanin0(pObj)); }
@@ -313,37 +369,35 @@ static inline void Gia_ObjRefFanin1Inc(Gia_Man_t * p, Gia_Obj_t * pObj){
static inline void Gia_ObjRefFanin0Dec(Gia_Man_t * p, Gia_Obj_t * pObj){ assert( p->pRefs); Gia_ObjRefDec(p, Gia_ObjFanin0(pObj)); }
static inline void Gia_ObjRefFanin1Dec(Gia_Man_t * p, Gia_Obj_t * pObj){ assert( p->pRefs); Gia_ObjRefDec(p, Gia_ObjFanin1(pObj)); }
-static inline void Gia_ManResetTravId( Gia_Man_t * p ) { extern void Gia_ManCleanValue( Gia_Man_t * p ); Gia_ManCleanValue( p ); p->nTravIds = 1; }
-static inline void Gia_ManIncrementTravId( Gia_Man_t * p ) { p->nTravIds++; }
-static inline void Gia_ObjSetTravId( Gia_Obj_t * pObj, int TravId ) { pObj->Value = TravId; }
-static inline void Gia_ObjSetTravIdCurrent( Gia_Man_t * p, Gia_Obj_t * pObj ) { pObj->Value = p->nTravIds; }
-static inline void Gia_ObjSetTravIdPrevious( Gia_Man_t * p, Gia_Obj_t * pObj ) { pObj->Value = p->nTravIds - 1; }
-static inline int Gia_ObjIsTravIdCurrent( Gia_Man_t * p, Gia_Obj_t * pObj ) { return ((int)pObj->Value == p->nTravIds); }
-static inline int Gia_ObjIsTravIdPrevious( Gia_Man_t * p, Gia_Obj_t * pObj ) { return ((int)pObj->Value == p->nTravIds - 1); }
-
-static inline void Gia_ManResetTravIdArray( Gia_Man_t * p )
-{
- ABC_FREE( p->pTravIds );
- p->nTravIdsAlloc = Gia_ManObjNum(p);
- p->pTravIds = ABC_CALLOC( int, p->nTravIdsAlloc );
- p->nTravIds = 1;
-}
-static inline void Gia_ManIncrementTravIdArray( Gia_Man_t * p )
-{
- while ( p->nTravIdsAlloc < Gia_ManObjNum(p) )
- {
- p->nTravIdsAlloc *= 2;
- p->pTravIds = ABC_REALLOC( int, p->pTravIds, p->nTravIdsAlloc );
- memset( p->pTravIds + p->nTravIdsAlloc/2, 0, sizeof(int) * p->nTravIdsAlloc/2 );
- }
- p->nTravIds++;
-}
-static inline void Gia_ObjSetTravIdCurrentArray( Gia_Man_t * p, Gia_Obj_t * pObj ) { assert( Gia_ObjId(p, pObj) < p->nTravIdsAlloc ); p->pTravIds[Gia_ObjId(p, pObj)] = p->nTravIds; }
-static inline void Gia_ObjSetTravIdPreviousArray( Gia_Man_t * p, Gia_Obj_t * pObj ) { assert( Gia_ObjId(p, pObj) < p->nTravIdsAlloc ); p->pTravIds[Gia_ObjId(p, pObj)] = p->nTravIds - 1; }
-static inline int Gia_ObjIsTravIdCurrentArray( Gia_Man_t * p, Gia_Obj_t * pObj ) { assert( Gia_ObjId(p, pObj) < p->nTravIdsAlloc ); return (p->pTravIds[Gia_ObjId(p, pObj)] == p->nTravIds); }
-static inline int Gia_ObjIsTravIdPreviousArray( Gia_Man_t * p, Gia_Obj_t * pObj ) { assert( Gia_ObjId(p, pObj) < p->nTravIdsAlloc ); return (p->pTravIds[Gia_ObjId(p, pObj)] == p->nTravIds - 1); }
-static inline void Gia_ObjSetTravIdCurrentArrayId( Gia_Man_t * p, int Id ) { assert( Id < p->nTravIdsAlloc ); p->pTravIds[Id] = p->nTravIds; }
-static inline int Gia_ObjIsTravIdCurrentArrayId( Gia_Man_t * p, int Id ) { assert( Id < p->nTravIdsAlloc ); return (p->pTravIds[Id] == p->nTravIds); }
+static inline int Gia_ObjNodeRefs( Gia_Man_t * p, Gia_Obj_t * pObj ) { assert( p->pNodeRefs); return p->pNodeRefs[Gia_ObjId(p, pObj)]; }
+static inline int Gia_ObjNodeRefsId( Gia_Man_t * p, int Id ) { assert( p->pNodeRefs); return p->pNodeRefs[Id]; }
+static inline int Gia_ObjNodeRefIncId( Gia_Man_t * p, int Id ) { assert( p->pNodeRefs); return p->pNodeRefs[Id]++; }
+static inline int Gia_ObjNodeRefDecId( Gia_Man_t * p, int Id ) { assert( p->pNodeRefs); return --p->pNodeRefs[Id]; }
+static inline int Gia_ObjNodeRefInc( Gia_Man_t * p, Gia_Obj_t * pObj ) { assert( p->pNodeRefs); return p->pNodeRefs[Gia_ObjId(p, pObj)]++; }
+static inline int Gia_ObjNodeRefDec( Gia_Man_t * p, Gia_Obj_t * pObj ) { assert( p->pNodeRefs); return --p->pNodeRefs[Gia_ObjId(p, pObj)]; }
+
+static inline void Gia_ObjSetTravIdCurrent( Gia_Man_t * p, Gia_Obj_t * pObj ) { assert( Gia_ObjId(p, pObj) < p->nTravIdsAlloc ); p->pTravIds[Gia_ObjId(p, pObj)] = p->nTravIds; }
+static inline void Gia_ObjSetTravIdPrevious( Gia_Man_t * p, Gia_Obj_t * pObj ) { assert( Gia_ObjId(p, pObj) < p->nTravIdsAlloc ); p->pTravIds[Gia_ObjId(p, pObj)] = p->nTravIds - 1; }
+static inline int Gia_ObjIsTravIdCurrent( Gia_Man_t * p, Gia_Obj_t * pObj ) { assert( Gia_ObjId(p, pObj) < p->nTravIdsAlloc ); return (p->pTravIds[Gia_ObjId(p, pObj)] == p->nTravIds); }
+static inline int Gia_ObjIsTravIdPrevious( Gia_Man_t * p, Gia_Obj_t * pObj ) { assert( Gia_ObjId(p, pObj) < p->nTravIdsAlloc ); return (p->pTravIds[Gia_ObjId(p, pObj)] == p->nTravIds - 1); }
+static inline void Gia_ObjSetTravIdCurrentId( Gia_Man_t * p, int Id ) { assert( Id < p->nTravIdsAlloc ); p->pTravIds[Id] = p->nTravIds; }
+static inline int Gia_ObjIsTravIdCurrentId( Gia_Man_t * p, int Id ) { assert( Id < p->nTravIdsAlloc ); return (p->pTravIds[Id] == p->nTravIds); }
+
+static inline void Gia_ManTimeClean( Gia_Man_t * p ) { int i; assert( p->vTiming != NULL ); Vec_FltFill(p->vTiming, 3*Gia_ManObjNum(p), 0); for ( i = 0; i < Gia_ManObjNum(p); i++ ) Vec_FltWriteEntry( p->vTiming, 3*i+1, (float)(ABC_INFINITY) ); }
+static inline void Gia_ManTimeStart( Gia_Man_t * p ) { assert( p->vTiming == NULL ); p->vTiming = Vec_FltAlloc(0); Gia_ManTimeClean( p ); }
+static inline void Gia_ManTimeStop( Gia_Man_t * p ) { assert( p->vTiming != NULL ); Vec_FltFreeP(&p->vTiming); }
+static inline float Gia_ObjTimeArrival( Gia_Man_t * p, int Id ) { return Vec_FltEntry(p->vTiming, 3*Id+0); }
+static inline float Gia_ObjTimeRequired( Gia_Man_t * p, int Id ) { return Vec_FltEntry(p->vTiming, 3*Id+1); }
+static inline float Gia_ObjTimeSlack( Gia_Man_t * p, int Id ) { return Vec_FltEntry(p->vTiming, 3*Id+2); }
+static inline float Gia_ObjTimeArrivalObj( Gia_Man_t * p, Gia_Obj_t * pObj ) { return Gia_ObjTimeArrival( p, Gia_ObjId(p, pObj) ); }
+static inline float Gia_ObjTimeRequiredObj( Gia_Man_t * p, Gia_Obj_t * pObj ) { return Gia_ObjTimeRequired( p, Gia_ObjId(p, pObj) ); }
+static inline float Gia_ObjTimeSlackObj( Gia_Man_t * p, Gia_Obj_t * pObj ) { return Gia_ObjTimeSlack( p, Gia_ObjId(p, pObj) ); }
+static inline void Gia_ObjSetTimeArrival( Gia_Man_t * p, int Id, float t ) { Vec_FltWriteEntry( p->vTiming, 3*Id+0, t ); }
+static inline void Gia_ObjSetTimeRequired( Gia_Man_t * p, int Id, float t ) { Vec_FltWriteEntry( p->vTiming, 3*Id+1, t ); }
+static inline void Gia_ObjSetTimeSlack( Gia_Man_t * p, int Id, float t ) { Vec_FltWriteEntry( p->vTiming, 3*Id+2, t ); }
+static inline void Gia_ObjSetTimeArrivalObj( Gia_Man_t * p, Gia_Obj_t * pObj, float t ) { Gia_ObjSetTimeArrival( p, Gia_ObjId(p, pObj), t ); }
+static inline void Gia_ObjSetTimeRequiredObj( Gia_Man_t * p, Gia_Obj_t * pObj, float t ) { Gia_ObjSetTimeRequired( p, Gia_ObjId(p, pObj), t ); }
+static inline void Gia_ObjSetTimeSlackObj( Gia_Man_t * p, Gia_Obj_t * pObj, float t ) { Gia_ObjSetTimeSlack( p, Gia_ObjId(p, pObj), t ); }
// AIG construction
extern void Gia_ObjAddFanout( Gia_Man_t * p, Gia_Obj_t * pObj, Gia_Obj_t * pFanout );
@@ -405,6 +459,12 @@ static inline int Gia_ManAppendCo( Gia_Man_t * p, int iLit0 )
Gia_ObjAddFanout( p, Gia_ObjFanin0(pObj), pObj );
return Gia_ObjId( p, pObj ) << 1;
}
+static inline int Gia_ManAppendMux( Gia_Man_t * p, int iCtrl, int iData1, int iData0 )
+{
+ int iTemp0 = Gia_ManAppendAnd( p, Gia_LitNot(iCtrl), iData0 );
+ int iTemp1 = Gia_ManAppendAnd( p, iCtrl, iData1 );
+ return Gia_LitNotCond( Gia_ManAppendAnd( p, Gia_LitNot(iTemp0), Gia_LitNot(iTemp1) ), 1 );
+}
#define GIA_ZER 1
#define GIA_ONE 2
@@ -428,9 +488,10 @@ static inline int Gia_XsimAndCond( int Value0, int fCompl0, int Value1, int fCom
}
static inline Gia_Obj_t * Gia_ObjReprObj( Gia_Man_t * p, int Id ) { return p->pReprs[Id].iRepr == GIA_VOID ? NULL : Gia_ManObj( p, p->pReprs[Id].iRepr ); }
-static inline int Gia_ObjRepr( Gia_Man_t * p, int Id ) { return p->pReprs[Id].iRepr; }
-static inline void Gia_ObjSetRepr( Gia_Man_t * p, int Id, int Num ) { p->pReprs[Id].iRepr = Num; }
-static inline void Gia_ObjUnsetRepr( Gia_Man_t * p, int Id ) { p->pReprs[Id].iRepr = GIA_VOID; }
+static inline int Gia_ObjRepr( Gia_Man_t * p, int Id ) { return p->pReprs[Id].iRepr; }
+static inline void Gia_ObjSetRepr( Gia_Man_t * p, int Id, int Num ) { assert( Num == GIA_VOID || Num < Id ); p->pReprs[Id].iRepr = Num; }
+static inline void Gia_ObjUnsetRepr( Gia_Man_t * p, int Id ) { p->pReprs[Id].iRepr = GIA_VOID; }
+static inline int Gia_ObjHasRepr( Gia_Man_t * p, int Id ) { return p->pReprs[Id].iRepr != GIA_VOID; }
static inline int Gia_ObjProved( Gia_Man_t * p, int Id ) { return p->pReprs[Id].fProved; }
static inline void Gia_ObjSetProved( Gia_Man_t * p, int Id ) { p->pReprs[Id].fProved = 1; }
@@ -474,14 +535,17 @@ static inline void Gia_ClassUndoPair( Gia_Man_t * p, int i ) { a
for ( assert(Gia_ObjIsHead(p, i)), iObj = Gia_ObjNext(p, i); iObj; iObj = Gia_ObjNext(p, iObj) )
-static inline int Gia_ObjIsGate( Gia_Man_t * p, int Id ) { return p->pMapping[Id] != 0; }
-static inline int Gia_ObjGateSize( Gia_Man_t * p, int Id ) { return p->pMapping[p->pMapping[Id]]; }
-static inline int * Gia_ObjGateFanins( Gia_Man_t * p, int Id ) { return p->pMapping + p->pMapping[Id] + 1; }
+static inline int Gia_ObjIsLut( Gia_Man_t * p, int Id ) { return p->pMapping[Id] != 0; }
+static inline int Gia_ObjLutSize( Gia_Man_t * p, int Id ) { return p->pMapping[p->pMapping[Id]]; }
+static inline int * Gia_ObjLutFanins( Gia_Man_t * p, int Id ) { return p->pMapping + p->pMapping[Id] + 1; }
+static inline int Gia_ObjLutFanin( Gia_Man_t * p, int Id, int i ) { return Gia_ObjLutFanins(p, Id)[i]; }
-#define Gia_ManForEachGate( p, i ) \
- for ( i = 1; i < Gia_ManObjNum(p); i++ ) if ( !Gia_ObjIsGate(p, i) ) {} else
-#define Gia_GateForEachFanin( p, i, iFan, k ) \
- for ( k = 0; k < Gia_ObjGateSize(p,i) && ((iFan = Gia_ObjGateFanins(p,i)[k]),1); k++ )
+#define Gia_ManForEachLut( p, i ) \
+ for ( i = 1; i < Gia_ManObjNum(p); i++ ) if ( !Gia_ObjIsLut(p, i) ) {} else
+#define Gia_LutForEachFanin( p, i, iFan, k ) \
+ for ( k = 0; k < Gia_ObjLutSize(p,i) && ((iFan = Gia_ObjLutFanins(p,i)[k]),1); k++ )
+#define Gia_LutForEachFaninObj( p, i, pFanin, k ) \
+ for ( k = 0; k < Gia_ObjLutSize(p,i) && ((pFanin = Gia_ManObj(p, Gia_ObjLutFanins(p,i)[k])),1); k++ )
////////////////////////////////////////////////////////////////////////
/// MACRO DEFINITIONS ///
@@ -525,9 +589,13 @@ static inline int * Gia_ObjGateFanins( Gia_Man_t * p, int Id ) { re
////////////////////////////////////////////////////////////////////////
/*=== giaAiger.c ===========================================================*/
+extern int Gia_FileSize( char * pFileName );
extern Gia_Man_t * Gia_ReadAiger( char * pFileName, int fCheck );
extern void Gia_WriteAiger( Gia_Man_t * p, char * pFileName, int fWriteSymbols, int fCompact );
extern void Gia_DumpAiger( Gia_Man_t * p, char * pFilePrefix, int iFileNum, int nFileNumDigits );
+/*=== giaBidec.c ===========================================================*/
+extern unsigned * Gia_ManConvertAigToTruth( Gia_Man_t * p, Gia_Obj_t * pRoot, Vec_Int_t * vLeaves, Vec_Int_t * vTruth, Vec_Int_t * vVisited );
+extern Gia_Man_t * Gia_ManPerformBidec( Gia_Man_t * p, int fVerbose );
/*=== giaCsatOld.c ============================================================*/
extern Vec_Int_t * Cbs_ManSolveMiter( Gia_Man_t * pGia, int nConfs, Vec_Str_t ** pvStatus, int fVerbose );
/*=== giaCsat.c ============================================================*/
@@ -542,14 +610,17 @@ extern Gia_Man_t * Gia_ManDupCofAll( Gia_Man_t * p, int nFanLim, int fVe
/*=== giaDfs.c ============================================================*/
extern void Gia_ManCollectCis( Gia_Man_t * p, int * pNodes, int nNodes, Vec_Int_t * vSupp );
extern void Gia_ManCollectAnds( Gia_Man_t * p, int * pNodes, int nNodes, Vec_Int_t * vNodes );
+extern Vec_Int_t * Gia_ManCollectNodesCis( Gia_Man_t * p, int * pNodes, int nNodes );
extern int Gia_ManSuppSize( Gia_Man_t * p, int * pNodes, int nNodes );
extern int Gia_ManConeSize( Gia_Man_t * p, int * pNodes, int nNodes );
extern Vec_Vec_t * Gia_ManLevelize( Gia_Man_t * p );
+extern Vec_Int_t * Gia_ManOrderReverse( Gia_Man_t * p );
/*=== giaDup.c ============================================================*/
extern Gia_Man_t * Gia_ManDupOrderDfs( Gia_Man_t * p );
+extern Gia_Man_t * Gia_ManDupOrderDfsChoices( Gia_Man_t * p );
extern Gia_Man_t * Gia_ManDupOrderDfsReverse( Gia_Man_t * p );
+extern Gia_Man_t * Gia_ManDupOutputGroup( Gia_Man_t * p, int iOutStart, int iOutStop );
extern Gia_Man_t * Gia_ManDupOrderAiger( Gia_Man_t * p );
-
extern Gia_Man_t * Gia_ManDupFlip( Gia_Man_t * p, int * pInitState );
extern Gia_Man_t * Gia_ManDup( Gia_Man_t * p );
extern Gia_Man_t * Gia_ManDupSelf( Gia_Man_t * p );
@@ -562,32 +633,38 @@ extern Gia_Man_t * Gia_ManDupDfsCone( Gia_Man_t * p, Gia_Obj_t * pObj );
extern Gia_Man_t * Gia_ManDupDfsLitArray( Gia_Man_t * p, Vec_Int_t * vLits );
extern Gia_Man_t * Gia_ManDupNormalized( Gia_Man_t * p );
extern Gia_Man_t * Gia_ManDupTrimmed( Gia_Man_t * p, int fTrimCis, int fTrimCos );
+extern Gia_Man_t * Gia_ManDupOntop( Gia_Man_t * p, Gia_Man_t * p2 );
extern Gia_Man_t * Gia_ManDupDfsCiMap( Gia_Man_t * p, int * pCi2Lit, Vec_Int_t * vLits );
extern Gia_Man_t * Gia_ManDupDfsClasses( Gia_Man_t * p );
extern Gia_Man_t * Gia_ManDupTopAnd( Gia_Man_t * p, int fVerbose );
extern Gia_Man_t * Gia_ManMiter( Gia_Man_t * pAig0, Gia_Man_t * pAig1, int fDualOut, int fSeq, int fVerbose );
extern Gia_Man_t * Gia_ManTransformMiter( Gia_Man_t * p );
+extern Gia_Man_t * Gia_ManChoiceMiter( Vec_Ptr_t * vGias );
/*=== giaEnable.c ==========================================================*/
extern void Gia_ManDetectSeqSignals( Gia_Man_t * p, int fSetReset, int fVerbose );
extern Gia_Man_t * Gia_ManUnrollAndCofactor( Gia_Man_t * p, int nFrames, int nFanMax, int fVerbose );
extern Gia_Man_t * Gia_ManRemoveEnables( Gia_Man_t * p );
/*=== giaEquiv.c ==========================================================*/
+extern void Gia_ManEquivFixOutputPairs( Gia_Man_t * p );
extern int Gia_ManCheckTopoOrder( Gia_Man_t * p );
extern int * Gia_ManDeriveNexts( Gia_Man_t * p );
extern void Gia_ManDeriveReprs( Gia_Man_t * p );
extern int Gia_ManEquivCountLits( Gia_Man_t * p );
+extern int Gia_ManEquivCountLitsAll( Gia_Man_t * p );
extern int Gia_ManEquivCountClasses( Gia_Man_t * p );
extern void Gia_ManEquivPrintOne( Gia_Man_t * p, int i, int Counter );
extern void Gia_ManEquivPrintClasses( Gia_Man_t * p, int fVerbose, float Mem );
extern Gia_Man_t * Gia_ManEquivReduce( Gia_Man_t * p, int fUseAll, int fDualOut, int fVerbose );
extern Gia_Man_t * Gia_ManEquivReduceAndRemap( Gia_Man_t * p, int fSeq, int fMiterPairs );
extern int Gia_ManEquivSetColors( Gia_Man_t * p, int fVerbose );
-extern Gia_Man_t * Gia_ManSpecReduce( Gia_Man_t * p, int fDualOut, int fVerbose );
-extern Gia_Man_t * Gia_ManSpecReduceInit( Gia_Man_t * p, Gia_Cex_t * pInit, int nFrames, int fDualOut );
-extern Gia_Man_t * Gia_ManSpecReduceInitFrames( Gia_Man_t * p, Gia_Cex_t * pInit, int nFramesMax, int * pnFrames, int fDualOut, int nMinOutputs );
+extern Gia_Man_t * Gia_ManSpecReduce( Gia_Man_t * p, int fDualOut, int fSynthesis, int fVerbose );
+extern Gia_Man_t * Gia_ManSpecReduceInit( Gia_Man_t * p, Abc_Cex_t * pInit, int nFrames, int fDualOut );
+extern Gia_Man_t * Gia_ManSpecReduceInitFrames( Gia_Man_t * p, Abc_Cex_t * pInit, int nFramesMax, int * pnFrames, int fDualOut, int nMinOutputs );
extern void Gia_ManEquivTransform( Gia_Man_t * p, int fVerbose );
extern void Gia_ManEquivImprove( Gia_Man_t * p );
extern Gia_Man_t * Gia_ManEquivToChoices( Gia_Man_t * p, int nSnapshots );
+extern int Gia_ManCountChoiceNodes( Gia_Man_t * p );
+extern int Gia_ManCountChoices( Gia_Man_t * p );
/*=== giaFanout.c =========================================================*/
extern void Gia_ObjAddFanout( Gia_Man_t * p, Gia_Obj_t * pObj, Gia_Obj_t * pFanout );
extern void Gia_ObjRemoveFanout( Gia_Man_t * p, Gia_Obj_t * pObj, Gia_Obj_t * pFanout );
@@ -611,12 +688,16 @@ extern int Gia_ManHashMux( Gia_Man_t * p, int iCtrl, int iData1,
extern int Gia_ManHashAndTry( Gia_Man_t * p, int iLit0, int iLit1 );
extern Gia_Man_t * Gia_ManRehash( Gia_Man_t * p, int fAddStrash );
extern void Gia_ManHashProfile( Gia_Man_t * p );
+extern int Gia_ManHashLookup( Gia_Man_t * p, Gia_Obj_t * p0, Gia_Obj_t * p1 );
+/*=== giaIf.c ===========================================================*/
+extern void Gia_ManPrintNpnClasses( Gia_Man_t * p );
/*=== giaLogic.c ===========================================================*/
extern void Gia_ManTestDistance( Gia_Man_t * p );
extern void Gia_ManSolveProblem( Gia_Man_t * pGia, Emb_Par_t * pPars );
/*=== giaMan.c ===========================================================*/
extern Gia_Man_t * Gia_ManStart( int nObjsMax );
extern void Gia_ManStop( Gia_Man_t * p );
+extern void Gia_ManStopP( Gia_Man_t ** p );
extern void Gia_ManPrintStats( Gia_Man_t * p, int fSwitch );
extern void Gia_ManPrintStatsShort( Gia_Man_t * p );
extern void Gia_ManPrintMiterStatus( Gia_Man_t * p );
@@ -624,8 +705,32 @@ extern void Gia_ManSetRegNum( Gia_Man_t * p, int nRegs );
extern void Gia_ManReportImprovement( Gia_Man_t * p, Gia_Man_t * pNew );
/*=== giaMap.c ===========================================================*/
extern void Gia_ManPrintMappingStats( Gia_Man_t * p );
+extern int Gia_ManLutFaninCount( Gia_Man_t * p );
+extern int Gia_ManLutSizeMax( Gia_Man_t * p );
+extern int Gia_ManLutNum( Gia_Man_t * p );
+extern int Gia_ManLutLevel( Gia_Man_t * p );
+/*=== giaMem.c ===========================================================*/
+extern Gia_MmFixed_t * Gia_MmFixedStart( int nEntrySize, int nEntriesMax );
+extern void Gia_MmFixedStop( Gia_MmFixed_t * p, int fVerbose );
+extern char * Gia_MmFixedEntryFetch( Gia_MmFixed_t * p );
+extern void Gia_MmFixedEntryRecycle( Gia_MmFixed_t * p, char * pEntry );
+extern void Gia_MmFixedRestart( Gia_MmFixed_t * p );
+extern int Gia_MmFixedReadMemUsage( Gia_MmFixed_t * p );
+extern int Gia_MmFixedReadMaxEntriesUsed( Gia_MmFixed_t * p );
+extern Gia_MmFlex_t * Gia_MmFlexStart();
+extern void Gia_MmFlexStop( Gia_MmFlex_t * p, int fVerbose );
+extern char * Gia_MmFlexEntryFetch( Gia_MmFlex_t * p, int nBytes );
+extern void Gia_MmFlexRestart( Gia_MmFlex_t * p );
+extern int Gia_MmFlexReadMemUsage( Gia_MmFlex_t * p );
+extern Gia_MmStep_t * Gia_MmStepStart( int nSteps );
+extern void Gia_MmStepStop( Gia_MmStep_t * p, int fVerbose );
+extern char * Gia_MmStepEntryFetch( Gia_MmStep_t * p, int nBytes );
+extern void Gia_MmStepEntryRecycle( Gia_MmStep_t * p, char * pEntry, int nBytes );
+extern int Gia_MmStepReadMemUsage( Gia_MmStep_t * p );
/*=== giaPat.c ===========================================================*/
extern void Gia_SatVerifyPattern( Gia_Man_t * p, Gia_Obj_t * pRoot, Vec_Int_t * vCex, Vec_Int_t * vVisit );
+/*=== giaReparam.c ===========================================================*/
+extern Gia_Man_t * Gia_ManReparm( Gia_Man_t * p, int fVerbose );
/*=== giaRetime.c ===========================================================*/
extern Gia_Man_t * Gia_ManRetimeForward( Gia_Man_t * p, int nMaxIters, int fVerbose );
/*=== giaSat.c ============================================================*/
@@ -636,10 +741,16 @@ extern int Gia_ManCombMarkUsed( Gia_Man_t * p );
extern Gia_Man_t * Gia_ManCleanup( Gia_Man_t * p );
extern Gia_Man_t * Gia_ManSeqCleanup( Gia_Man_t * p );
extern Gia_Man_t * Gia_ManSeqStructSweep( Gia_Man_t * p, int fConst, int fEquiv, int fVerbose );
+/*=== giaShrink.c ===========================================================*/
+extern Gia_Man_t * Gia_ManPerformMapShrink( Gia_Man_t * p, int fKeepLevel, int fVerbose );
/*=== giaSort.c ============================================================*/
extern int * Gia_SortFloats( float * pArray, int * pPerm, int nSize );
/*=== giaSim.c ============================================================*/
extern int Gia_ManSimSimulate( Gia_Man_t * pAig, Gia_ParSim_t * pPars );
+/*=== giaSpeedup.c ============================================================*/
+extern float Gia_ManDelayTraceLut( Gia_Man_t * p );
+extern float Gia_ManDelayTraceLutPrint( Gia_Man_t * p, int fVerbose );
+extern Gia_Man_t * Gia_ManSpeedup( Gia_Man_t * p, int Percentage, int Degree, int fVerbose, int fVeryVerbose );
/*=== giaSwitch.c ============================================================*/
extern float Gia_ManEvaluateSwitching( Gia_Man_t * p );
extern float Gia_ManComputeSwitching( Gia_Man_t * p, int nFrames, int nPref, int fProbOne );
@@ -649,7 +760,9 @@ extern Gia_Man_t * Gia_ManReduceConst( Gia_Man_t * pAig, int fVerbose );
extern unsigned Gia_ManRandom( int fReset );
extern void Gia_ManRandomInfo( Vec_Ptr_t * vInfo, int iInputStart, int iWordStart, int iWordStop );
extern unsigned int Gia_PrimeCudd( unsigned int p );
+extern char * Gia_TimeStamp();
extern char * Gia_FileNameGenericAppend( char * pBase, char * pSuffix );
+extern void Gia_ManIncrementTravId( Gia_Man_t * p );
extern void Gia_ManSetMark0( Gia_Man_t * p );
extern void Gia_ManCleanMark0( Gia_Man_t * p );
extern void Gia_ManCheckMark0( Gia_Man_t * p );
@@ -657,8 +770,12 @@ extern void Gia_ManSetMark1( Gia_Man_t * p );
extern void Gia_ManCleanMark1( Gia_Man_t * p );
extern void Gia_ManCheckMark1( Gia_Man_t * p );
extern void Gia_ManCleanValue( Gia_Man_t * p );
+extern void Gia_ManCleanLevels( Gia_Man_t * p, int Size );
+extern void Gia_ManCleanTruth( Gia_Man_t * p );
extern void Gia_ManFillValue( Gia_Man_t * p );
+extern void Gia_ObjSetPhase( Gia_Obj_t * pObj );
extern void Gia_ManSetPhase( Gia_Man_t * p );
+extern void Gia_ManSetPhase1( Gia_Man_t * p );
extern void Gia_ManCleanPhase( Gia_Man_t * p );
extern int Gia_ManLevelNum( Gia_Man_t * p );
extern void Gia_ManSetRefs( Gia_Man_t * p );
@@ -670,13 +787,18 @@ extern Vec_Int_t * Gia_ManCollectPoIds( Gia_Man_t * p );
extern int Gia_ObjIsMuxType( Gia_Obj_t * pNode );
extern int Gia_ObjRecognizeExor( Gia_Obj_t * pObj, Gia_Obj_t ** ppFan0, Gia_Obj_t ** ppFan1 );
extern Gia_Obj_t * Gia_ObjRecognizeMux( Gia_Obj_t * pNode, Gia_Obj_t ** ppNodeT, Gia_Obj_t ** ppNodeE );
-extern Gia_Cex_t * Gia_ManAllocCounterExample( int nRegs, int nRealPis, int nFrames );
-extern int Gia_ManVerifyCounterExample( Gia_Man_t * pAig, Gia_Cex_t * p, int fDualOut );
-extern void Gia_ManPrintCounterExample( Gia_Cex_t * p );
+extern Abc_Cex_t * Gia_ManAllocCounterExample( int nRegs, int nRealPis, int nFrames );
+extern Abc_Cex_t * Gia_ManDeriveCexFromArray( Gia_Man_t * pAig, Vec_Int_t * vValues, int nSkip, int iFrame );
+extern Abc_Cex_t * Gia_ManCreateFromComb( int nRegs, int nRealPis, int iPo, int * pModel );
+extern Abc_Cex_t * Gia_ManDupCounterExample( Abc_Cex_t * p, int nRegsNew );
+extern int Gia_ManVerifyCounterExample( Gia_Man_t * pAig, Abc_Cex_t * p, int fDualOut );
+extern void Gia_ManPrintCounterExample( Abc_Cex_t * p );
extern int Gia_NodeMffcSize( Gia_Man_t * p, Gia_Obj_t * pNode );
extern int Gia_ManHasChoices( Gia_Man_t * p );
-extern int Gia_ManHasDandling( Gia_Man_t * p );
-/*=== giaUtil.c ===========================================================*/
+extern int Gia_ManHasDangling( Gia_Man_t * p );
+extern Vec_Int_t * Gia_ManGetDangling( Gia_Man_t * p );
+extern void Gia_ObjPrint( Gia_Man_t * p, Gia_Obj_t * pObj );
+/*=== giaCTas.c ===========================================================*/
typedef struct Tas_Man_t_ Tas_Man_t;
extern Tas_Man_t * Tas_ManAlloc( Gia_Man_t * pAig, int nBTLimit );
extern void Tas_ManStop( Tas_Man_t * p );
@@ -686,9 +808,11 @@ extern int Tas_ManSolve( Tas_Man_t * p, Gia_Obj_t * pObj, Gia_Ob
extern int Tas_ManSolveArray( Tas_Man_t * p, Vec_Ptr_t * vObjs );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/aig/gia/giaAbs.c b/src/aig/gia/giaAbs.c
new file mode 100644
index 00000000..38e010f1
--- /dev/null
+++ b/src/aig/gia/giaAbs.c
@@ -0,0 +1,553 @@
+/**CFile****************************************************************
+
+ FileName [giaAbs.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Scalable AIG package.]
+
+ Synopsis [Counter-example-guided abstraction refinement.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: giaAbs.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+#include "giaAig.h"
+#include "giaAbs.h"
+#include "saig.h"
+
+#ifndef _WIN32
+#include <unistd.h>
+#endif
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+extern Vec_Int_t * Saig_ManProofAbstractionFlops( Aig_Man_t * p, Gia_ParAbs_t * pPars );
+extern Vec_Int_t * Saig_ManCexAbstractionFlops( Aig_Man_t * p, Gia_ParAbs_t * pPars );
+extern int Saig_ManCexRefineStep( Aig_Man_t * p, Vec_Int_t * vFlops, Abc_Cex_t * pCex, int fVerbose );
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [This procedure sets default parameters.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManAbsSetDefaultParams( Gia_ParAbs_t * p )
+{
+ memset( p, 0, sizeof(Gia_ParAbs_t) );
+ p->Algo = 0; // algorithm: CBA
+ p->nFramesMax = 10; // timeframes for PBA
+ p->nConfMax = 10000; // conflicts for PBA
+ p->fDynamic = 1; // dynamic unfolding for PBA
+ p->fConstr = 0; // use constraints
+ p->nFramesBmc = 250; // timeframes for BMC
+ p->nConfMaxBmc = 5000; // conflicts for BMC
+ p->nStableMax = 1000000; // the number of stable frames to quit
+ p->nRatio = 10; // ratio of flops to quit
+ p->nBobPar = 1000000; // the number of frames before trying to quit
+ p->fUseBdds = 0; // use BDDs to refine abstraction
+ p->fUseDprove = 0; // use 'dprove' to refine abstraction
+ p->fUseStart = 1; // use starting frame
+ p->fVerbose = 0; // verbose output
+ p->fVeryVerbose= 0; // printing additional information
+ p->Status = -1; // the problem status
+ p->nFramesDone = -1; // the number of rames covered
+}
+
+/**Function*************************************************************
+
+ Synopsis [Transform flop list into flop map.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Gia_ManFlops2Classes( Gia_Man_t * pGia, Vec_Int_t * vFlops )
+{
+ Vec_Int_t * vFlopClasses;
+ int i, Entry;
+ vFlopClasses = Vec_IntStart( Gia_ManRegNum(pGia) );
+ Vec_IntForEachEntry( vFlops, Entry, i )
+ Vec_IntWriteEntry( vFlopClasses, Entry, 1 );
+ return vFlopClasses;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Transform flop map into flop list.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Gia_ManClasses2Flops( Vec_Int_t * vFlopClasses )
+{
+ Vec_Int_t * vFlops;
+ int i, Entry;
+ vFlops = Vec_IntAlloc( 100 );
+ Vec_IntForEachEntry( vFlopClasses, Entry, i )
+ if ( Entry )
+ Vec_IntPush( vFlops, i );
+ return vFlops;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Performs abstraction on the AIG manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManCexAbstraction( Gia_Man_t * p, Vec_Int_t * vFlops )
+{
+ Gia_Man_t * pGia;
+ Aig_Man_t * pNew, * pTemp;
+ pNew = Gia_ManToAig( p, 0 );
+ pNew = Saig_ManDeriveAbstraction( pTemp = pNew, vFlops );
+ Aig_ManStop( pTemp );
+ pGia = Gia_ManFromAig( pNew );
+ pGia->vCiNumsOrig = pNew->vCiNumsOrig;
+ pNew->vCiNumsOrig = NULL;
+ Aig_ManStop( pNew );
+ return pGia;
+
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes abstracted flops for the manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Gia_ManCexAbstractionFlops( Gia_Man_t * p, Gia_ParAbs_t * pPars )
+{
+ Vec_Int_t * vFlops;
+ Aig_Man_t * pNew;
+ pNew = Gia_ManToAig( p, 0 );
+ vFlops = Saig_ManCexAbstractionFlops( pNew, pPars );
+ p->pCexSeq = pNew->pSeqModel; pNew->pSeqModel = NULL;
+ Aig_ManStop( pNew );
+ return vFlops;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes abstracted flops for the manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Gia_ManProofAbstractionFlops( Gia_Man_t * p, Gia_ParAbs_t * pPars )
+{
+ Vec_Int_t * vFlops;
+ Aig_Man_t * pNew;
+ pNew = Gia_ManToAig( p, 0 );
+ vFlops = Saig_ManProofAbstractionFlops( pNew, pPars );
+ p->pCexSeq = pNew->pSeqModel; pNew->pSeqModel = NULL;
+ Aig_ManStop( pNew );
+ return vFlops;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Starts abstraction by computing latch map.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManCexAbstractionStart( Gia_Man_t * p, Gia_ParAbs_t * pPars )
+{
+ Vec_Int_t * vFlops;
+ if ( p->vFlopClasses != NULL )
+ {
+ printf( "Gia_ManCexAbstractionStart(): Abstraction latch map is present but will be rederived.\n" );
+ Vec_IntFreeP( &p->vFlopClasses );
+ }
+ vFlops = Gia_ManCexAbstractionFlops( p, pPars );
+ if ( vFlops )
+ {
+ p->vFlopClasses = Gia_ManFlops2Classes( p, vFlops );
+ Vec_IntFree( vFlops );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Derives abstraction using the latch map.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManCexAbstractionDerive( Gia_Man_t * pGia )
+{
+ Vec_Int_t * vFlops;
+ Gia_Man_t * pAbs = NULL;
+ if ( pGia->vFlopClasses == NULL )
+ {
+ printf( "Gia_ManCexAbstractionDerive(): Abstraction latch map is missing.\n" );
+ return NULL;
+ }
+ vFlops = Gia_ManClasses2Flops( pGia->vFlopClasses );
+ pAbs = Gia_ManCexAbstraction( pGia, vFlops );
+ Vec_IntFree( vFlops );
+ return pAbs;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Refines abstraction using the latch map.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManCexAbstractionRefine( Gia_Man_t * pGia, Abc_Cex_t * pCex, int fVerbose )
+{
+ Aig_Man_t * pNew;
+ Vec_Int_t * vFlops;
+ if ( pGia->vFlopClasses == NULL )
+ {
+ printf( "Gia_ManCexAbstractionRefine(): Abstraction latch map is missing.\n" );
+ return -1;
+ }
+ pNew = Gia_ManToAig( pGia, 0 );
+ vFlops = Gia_ManClasses2Flops( pGia->vFlopClasses );
+ if ( !Saig_ManCexRefineStep( pNew, vFlops, pCex, fVerbose ) )
+ {
+ pGia->pCexSeq = pNew->pSeqModel; pNew->pSeqModel = NULL;
+ Vec_IntFree( vFlops );
+ Aig_ManStop( pNew );
+ return 0;
+ }
+ Vec_IntFree( pGia->vFlopClasses );
+ pGia->vFlopClasses = Gia_ManFlops2Classes( pGia, vFlops );
+ Vec_IntFree( vFlops );
+ Aig_ManStop( pNew );
+ return -1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Starts abstraction by computing latch map.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManProofAbstractionStart( Gia_Man_t * pGia, Gia_ParAbs_t * pPars )
+{
+ Vec_Int_t * vFlops;
+ if ( pGia->vFlopClasses != NULL )
+ {
+ printf( "Gia_ManProofAbstractionStart(): Abstraction latch map is present but will be rederived.\n" );
+ Vec_IntFreeP( &pGia->vFlopClasses );
+ }
+ vFlops = Gia_ManProofAbstractionFlops( pGia, pPars );
+ if ( vFlops )
+ {
+ pGia->vFlopClasses = Gia_ManFlops2Classes( pGia, vFlops );
+ Vec_IntFree( vFlops );
+ }
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Read flop map.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Str_t * Gia_ManReadFile( char * pFileName )
+{
+ FILE * pFile;
+ Vec_Str_t * vStr;
+ int c;
+ pFile = fopen( pFileName, "r" );
+ if ( pFile == NULL )
+ {
+ printf( "Cannot open file \"%s\".\n", pFileName );
+ return NULL;
+ }
+ vStr = Vec_StrAlloc( 100 );
+ while ( (c = fgetc(pFile)) != EOF )
+ Vec_StrPush( vStr, (char)c );
+ Vec_StrPush( vStr, '\0' );
+ fclose( pFile );
+ return vStr;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Read flop map.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Gia_ManReadBinary( char * pFileName, char * pToken )
+{
+ Vec_Int_t * vMap = NULL;
+ Vec_Str_t * vStr;
+ char * pStr;
+ int i, Length;
+ vStr = Gia_ManReadFile( pFileName );
+ if ( vStr == NULL )
+ return NULL;
+ pStr = Vec_StrArray( vStr );
+ pStr = strstr( pStr, pToken );
+ if ( pStr != NULL )
+ {
+ pStr += strlen( pToken );
+ vMap = Vec_IntAlloc( 100 );
+ Length = strlen( pStr );
+ for ( i = 0; i < Length; i++ )
+ {
+ if ( pStr[i] == '0' )
+ Vec_IntPush( vMap, 0 );
+ else if ( pStr[i] == '1' )
+ Vec_IntPush( vMap, 1 );
+ if ( ('a' <= pStr[i] && pStr[i] <= 'z') ||
+ ('A' <= pStr[i] && pStr[i] <= 'Z') )
+ break;
+ }
+ }
+ Vec_StrFree( vStr );
+ return vMap;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Read flop map.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManReadInteger( char * pFileName, char * pToken )
+{
+ int Result = -1;
+ Vec_Str_t * vStr;
+ char * pStr;
+ vStr = Gia_ManReadFile( pFileName );
+ if ( vStr == NULL )
+ return -1;
+ pStr = Vec_StrArray( vStr );
+ pStr = strstr( pStr, pToken );
+ if ( pStr != NULL )
+ Result = atoi( pStr + strlen(pToken) );
+ Vec_StrFree( vStr );
+ return Result;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Starts abstraction by computing latch map.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManCexAbstractionStartNew( Gia_Man_t * pGia, Gia_ParAbs_t * pPars )
+{
+ char BufTimeOut[100];
+ char BufTimeOutVT[100];
+ char Command[1000];
+ char * pFileNameIn = "cex_abstr_in_.aig";
+ char * pFileNameOut = "cex_abstr_out_.txt";
+ FILE * pFile;
+ Vec_Int_t * vCex;
+ int RetValue, clk;
+ if ( pGia->vFlopClasses != NULL )
+ {
+ printf( "Gia_ManCexAbstractionStartNew(): Abstraction latch map is present but will be rederived.\n" );
+ Vec_IntFreeP( &pGia->vFlopClasses );
+ }
+ Gia_WriteAiger( pGia, pFileNameIn, 0, 0 );
+ sprintf( BufTimeOut, "-timeout=%d", pPars->TimeOut );
+ sprintf( BufTimeOutVT, "-vt=%d", pPars->TimeOutVT );
+//ABC switch => cex_abstr switch
+//-cba => <input> <output>
+//-pba => ,bmc -pba-soft <input> <output>
+//-cba-then-pba => -pba-soft <input> <output>
+//-cba-with-pba => -pba <input> <output>
+ if ( pPars->Algo == 0 )
+ {
+ sprintf( Command, "cex_abstr %s %s -depth=%d -stable=%d -confl=%d -bob=%d %s %s %s %s",
+ pPars->fVerbose? "":"-quiet",
+ pPars->fVeryVerbose? "-sat-verbosity=1":"",
+ pPars->nFramesBmc, pPars->nStableMax, pPars->nConfMaxBmc, pPars->nBobPar,
+ pPars->TimeOut? BufTimeOut : "",
+ pPars->TimeOutVT? BufTimeOutVT : "",
+ pFileNameIn, pFileNameOut );
+ }
+ else if ( pPars->Algo == 1 )
+ {
+ sprintf( Command, "cex_abstr %s %s -depth=%d -confl=%d -bob=%d ,bmc -pba-soft %s %s %s %s",
+ pPars->fVerbose? "":"-quiet",
+ pPars->fVeryVerbose? "-sat-verbosity=1":"",
+ pPars->nFramesBmc, pPars->nConfMaxBmc, pPars->nBobPar,
+ pPars->TimeOut? BufTimeOut : "",
+ pPars->TimeOutVT? BufTimeOutVT : "",
+ pFileNameIn, pFileNameOut );
+ }
+ else if ( pPars->Algo == 2 )
+ {
+ sprintf( Command, "cex_abstr %s %s -depth=%d -stable=%d -confl=%d -bob=%d -pba-soft %s %s %s %s",
+ pPars->fVerbose? "":"-quiet",
+ pPars->fVeryVerbose? "-sat-verbosity=1":"",
+ pPars->nFramesBmc, pPars->nStableMax, pPars->nConfMaxBmc, pPars->nBobPar,
+ pPars->TimeOut? BufTimeOut : "",
+ pPars->TimeOutVT? BufTimeOutVT : "",
+ pFileNameIn, pFileNameOut );
+ }
+ else if ( pPars->Algo == 3 )
+ {
+ sprintf( Command, "cex_abstr %s %s -depth=%d -stable=%d -confl=%d -bob=%d -pba %s %s %s %s",
+ pPars->fVerbose? "":"-quiet",
+ pPars->fVeryVerbose? "-sat-verbosity=1":"",
+ pPars->nFramesBmc, pPars->nStableMax, pPars->nConfMaxBmc, pPars->nBobPar,
+ pPars->TimeOut? BufTimeOut : "",
+ pPars->TimeOutVT? BufTimeOutVT : "",
+ pFileNameIn, pFileNameOut );
+ }
+ else
+ {
+ printf( "Unnknown option (algo=%d). CBA (algo=0) is assumed.\n", pPars->Algo );
+ sprintf( Command, "cex_abstr %s %s -depth=%d -stable=%d -confl=%d -bob=%d %s %s %s %s",
+ pPars->fVerbose? "":"-quiet",
+ pPars->fVeryVerbose? "-sat-verbosity=1":"",
+ pPars->nFramesBmc, pPars->nStableMax, pPars->nConfMaxBmc, pPars->nBobPar,
+ pPars->TimeOut? BufTimeOut : "",
+ pPars->TimeOutVT? BufTimeOutVT : "",
+ pFileNameIn, pFileNameOut );
+ }
+ // run the command
+ printf( "Executing command line \"%s\"\n", Command );
+ clk = clock();
+ RetValue = system( Command );
+ clk = clock() - clk;
+#ifdef WIN32
+ _unlink( pFileNameIn );
+#else
+ unlink( pFileNameIn );
+#endif
+ if ( RetValue == -1 )
+ {
+ fprintf( stdout, "Command \"%s\" did not succeed.\n", Command );
+ return;
+ }
+ // check that the input PostScript file is okay
+ if ( (pFile = fopen( pFileNameOut, "r" )) == NULL )
+ {
+ fprintf( stdout, "Cannot open intermediate file \"%s\".\n", pFileNameOut );
+ return;
+ }
+ fclose( pFile );
+ pPars->nFramesDone = Gia_ManReadInteger( pFileNameOut, "depth:" );
+ if ( pPars->nFramesDone == -1 )
+ printf( "Gia_ManCexAbstractionStartNew(): Cannot read the number of frames covered by BMC.\n" );
+ pGia->vFlopClasses = Gia_ManReadBinary( pFileNameOut, "abstraction:" );
+ vCex = Gia_ManReadBinary( pFileNameOut, "counter-example:" );
+ if ( vCex )
+ {
+ int nFrames = (Vec_IntSize(vCex) - Gia_ManRegNum(pGia)) / Gia_ManPiNum(pGia);
+ int nRemain = (Vec_IntSize(vCex) - Gia_ManRegNum(pGia)) % Gia_ManPiNum(pGia);
+ if ( nRemain != 0 )
+ {
+ printf( "Counter example has a wrong length.\n" );
+ }
+ else
+ {
+ printf( "Problem is satisfiable. Found counter-example in frame %d. ", nFrames-1 );
+ Abc_PrintTime( 1, "Time", clk );
+ pGia->pCexSeq = Gia_ManDeriveCexFromArray( pGia, vCex, 0, nFrames-1 );
+ if ( !Gia_ManVerifyCounterExample( pGia, pGia->pCexSeq, 0 ) )
+ Abc_Print( 1, "Generated counter-example is INVALID.\n" );
+ pPars->Status = 0;
+ }
+ Vec_IntFreeP( &vCex );
+ }
+#ifdef WIN32
+ _unlink( pFileNameOut );
+#else
+ unlink( pFileNameOut );
+#endif
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaAbs.h b/src/aig/gia/giaAbs.h
new file mode 100644
index 00000000..090d5dca
--- /dev/null
+++ b/src/aig/gia/giaAbs.h
@@ -0,0 +1,89 @@
+/**CFile****************************************************************
+
+ FileName [giaAbs.h]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Scalable AIG package.]
+
+ Synopsis [External declarations.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: giaAbs.h,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#ifndef __GIA_ABS_H__
+#define __GIA_ABS_H__
+
+
+////////////////////////////////////////////////////////////////////////
+/// INCLUDES ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// PARAMETERS ///
+////////////////////////////////////////////////////////////////////////
+
+
+
+ABC_NAMESPACE_HEADER_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// BASIC TYPES ///
+////////////////////////////////////////////////////////////////////////
+
+// abstraction parameters
+typedef struct Gia_ParAbs_t_ Gia_ParAbs_t;
+struct Gia_ParAbs_t_
+{
+ int Algo; // the algorithm to be used
+ int nFramesMax; // timeframes for PBA
+ int nConfMax; // conflicts for PBA
+ int fDynamic; // dynamic unfolding for PBA
+ int fConstr; // use constraints
+ int nFramesBmc; // timeframes for BMC
+ int nConfMaxBmc; // conflicts for BMC
+ int nStableMax; // the number of stable frames to quit
+ int nRatio; // ratio of flops to quit
+ int TimeOut; // approximate timeout in seconds
+ int TimeOutVT; // approximate timeout in seconds
+ int nBobPar; // Bob's parameter
+ int fUseBdds; // use BDDs to refine abstraction
+ int fUseDprove; // use 'dprove' to refine abstraction
+ int fUseStart; // use starting frame
+ int fVerbose; // verbose output
+ int fVeryVerbose; // printing additional information
+ int Status; // the problem status
+ int nFramesDone; // the number of frames covered
+};
+
+extern void Gia_ManAbsSetDefaultParams( Gia_ParAbs_t * p );
+
+////////////////////////////////////////////////////////////////////////
+/// MACRO DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+
+
+
+ABC_NAMESPACE_HEADER_END
+
+
+
+#endif
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
diff --git a/src/aig/gia/giaAig.c b/src/aig/gia/giaAig.c
index fa9030c5..0e004f87 100644
--- a/src/aig/gia/giaAig.c
+++ b/src/aig/gia/giaAig.c
@@ -19,6 +19,12 @@
***********************************************************************/
#include "giaAig.h"
+#include "fra.h"
+#include "dch.h"
+#include "dar.h"
+
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -84,6 +90,7 @@ Gia_Man_t * Gia_ManFromAig( Aig_Man_t * p )
// create the new manager
pNew = Gia_ManStart( Aig_ManObjNum(p) );
pNew->pName = Gia_UtilStrsav( p->pName );
+ pNew->nConstrs = p->nConstrs;
// create room to store equivalences
if ( p->pEquivs )
pNew->pNexts = ABC_CALLOC( int, Aig_ManObjNum(p) );
@@ -122,6 +129,7 @@ Gia_Man_t * Gia_ManFromAigSimple( Aig_Man_t * p )
// create the new manager
pNew = Gia_ManStart( Aig_ManObjNum(p) );
pNew->pName = Gia_UtilStrsav( p->pName );
+ pNew->nConstrs = p->nConstrs;
// create the PIs
Aig_ManCleanData( p );
Aig_ManForEachObj( p, pObj, i )
@@ -138,8 +146,6 @@ Gia_Man_t * Gia_ManFromAigSimple( Aig_Man_t * p )
assert( 0 );
}
Gia_ManSetRegNum( pNew, Aig_ManRegNum(p) );
- if ( pNew->pNexts )
- Gia_ManDeriveReprs( pNew );
return pNew;
}
@@ -162,6 +168,7 @@ Gia_Man_t * Gia_ManFromAigSwitch( Aig_Man_t * p )
// create the new manager
pNew = Gia_ManStart( Aig_ManObjNum(p) );
pNew->pName = Gia_UtilStrsav( p->pName );
+ pNew->nConstrs = p->nConstrs;
// create the PIs
Aig_ManCleanData( p );
Aig_ManConst1(p)->iData = 1;
@@ -178,7 +185,7 @@ Gia_Man_t * Gia_ManFromAigSwitch( Aig_Man_t * p )
Aig_ManForEachPo( p, pObj, i )
Gia_ManFromAig_rec( pNew, p, Aig_ObjFanin0(pObj) );
Aig_ManForEachPo( p, pObj, i )
- Gia_ManAppendCo( pNew, Gia_ObjChild0Copy(pObj) );
+ pObj->iData = Gia_ManAppendCo( pNew, Gia_ObjChild0Copy(pObj) );
Gia_ManSetRegNum( pNew, Aig_ManRegNum(p) );
return pNew;
}
@@ -240,6 +247,7 @@ Aig_Man_t * Gia_ManToAig( Gia_Man_t * p, int fChoices )
// create the new manager
pNew = Aig_ManStart( Gia_ManAndNum(p) );
pNew->pName = Gia_UtilStrsav( p->pName );
+ pNew->nConstrs = p->nConstrs;
// pNew->pSpec = Gia_UtilStrsav( p->pName );
// duplicate representation of choice nodes
if ( fChoices )
@@ -249,6 +257,10 @@ Aig_Man_t * Gia_ManToAig( Gia_Man_t * p, int fChoices )
ppNodes[0] = Aig_ManConst0(pNew);
Gia_ManForEachCi( p, pObj, i )
ppNodes[Gia_ObjId(p, pObj)] = Aig_ObjCreatePi( pNew );
+ // transfer level
+ if ( p->vLevels )
+ Gia_ManForEachCi( p, pObj, i )
+ Aig_ObjSetLevel( ppNodes[Gia_ObjId(p, pObj)], Gia_ObjLevel(p, pObj) );
// add logic for the POs
Gia_ManForEachCo( p, pObj, i )
{
@@ -282,6 +294,7 @@ Aig_Man_t * Gia_ManToAigSkip( Gia_Man_t * p, int nOutDelta )
// create the new manager
pNew = Aig_ManStart( Gia_ManAndNum(p) );
pNew->pName = Gia_UtilStrsav( p->pName );
+ pNew->nConstrs = p->nConstrs;
// pNew->pSpec = Gia_UtilStrsav( p->pName );
// create the PIs
ppNodes = ABC_CALLOC( Aig_Obj_t *, Gia_ManObjNum(p) );
@@ -312,6 +325,48 @@ Aig_Man_t * Gia_ManToAigSkip( Gia_Man_t * p, int nOutDelta )
SeeAlso []
***********************************************************************/
+Aig_Man_t * Gia_ManToAigSimple( Gia_Man_t * p )
+{
+ Aig_Man_t * pNew;
+ Aig_Obj_t ** ppNodes;
+ Gia_Obj_t * pObj;
+ int i;
+ ppNodes = ABC_ALLOC( Aig_Obj_t *, Gia_ManObjNum(p) );
+ // create the new manager
+ pNew = Aig_ManStart( Gia_ManObjNum(p) );
+ pNew->pName = Gia_UtilStrsav( p->pName );
+ pNew->nConstrs = p->nConstrs;
+ // create the PIs
+ Gia_ManForEachObj( p, pObj, i )
+ {
+ if ( Gia_ObjIsAnd(pObj) )
+ ppNodes[i] = Aig_And( pNew, Gia_ObjChild0Copy2(ppNodes, pObj, Gia_ObjId(p, pObj)), Gia_ObjChild1Copy2(ppNodes, pObj, Gia_ObjId(p, pObj)) );
+ else if ( Gia_ObjIsCi(pObj) )
+ ppNodes[i] = Aig_ObjCreatePi( pNew );
+ else if ( Gia_ObjIsCo(pObj) )
+ ppNodes[i] = Aig_ObjCreatePo( pNew, Gia_ObjChild0Copy2(ppNodes, pObj, Gia_ObjId(p, pObj)) );
+ else if ( Gia_ObjIsConst0(pObj) )
+ ppNodes[i] = Aig_ManConst0(pNew);
+ else
+ assert( 0 );
+ pObj->Value = Gia_Var2Lit( Aig_ObjId(Aig_Regular(ppNodes[i])), Aig_IsComplement(ppNodes[i]) );
+ }
+ Aig_ManSetRegNum( pNew, Gia_ManRegNum(p) );
+ ABC_FREE( ppNodes );
+ return pNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Duplicates AIG in the DFS order.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
Aig_Man_t * Gia_ManCofactorAig( Aig_Man_t * p, int nFrames, int nCofFanLit )
{
Aig_Man_t * pMan;
@@ -329,41 +384,69 @@ Aig_Man_t * Gia_ManCofactorAig( Aig_Man_t * p, int nFrames, int nCofFanLit )
Synopsis [Transfers representatives from pGia to pAig.]
- Description []
+ Description [Assumes that pGia was created from pAig.]
SideEffects []
SeeAlso []
***********************************************************************/
-void Gia_ManReprToAigRepr( Aig_Man_t * p, Gia_Man_t * pGia )
+void Gia_ManReprToAigRepr( Aig_Man_t * pAig, Gia_Man_t * pGia )
{
Aig_Obj_t * pObj;
Gia_Obj_t * pGiaObj, * pGiaRepr;
int i;
- assert( p->pReprs == NULL );
+ assert( pAig->pReprs == NULL );
assert( pGia->pReprs != NULL );
// move pointers from AIG to GIA
- Aig_ManForEachObj( p, pObj, i )
+ Aig_ManForEachObj( pAig, pObj, i )
{
assert( i == 0 || !Gia_LitIsCompl(pObj->iData) );
pGiaObj = Gia_ManObj( pGia, Gia_Lit2Var(pObj->iData) );
pGiaObj->Value = i;
}
// set the pointers to the nodes in AIG
- Aig_ManReprStart( p, Aig_ManObjNumMax(p) );
+ Aig_ManReprStart( pAig, Aig_ManObjNumMax(pAig) );
+ Gia_ManForEachObj( pGia, pGiaObj, i )
+ {
+ pGiaRepr = Gia_ObjReprObj( pGia, i );
+ if ( pGiaRepr == NULL )
+ continue;
+ Aig_ObjCreateRepr( pAig, Aig_ManObj(pAig, pGiaRepr->Value), Aig_ManObj(pAig, pGiaObj->Value) );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Transfers representatives from pGia to pAig.]
+
+ Description [Assumes that pAig was created from pGia.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManReprToAigRepr2( Aig_Man_t * pAig, Gia_Man_t * pGia )
+{
+ Gia_Obj_t * pGiaObj, * pGiaRepr;
+ int i;
+ assert( pAig->pReprs == NULL );
+ assert( pGia->pReprs != NULL );
+ // set the pointers to the nodes in AIG
+ Aig_ManReprStart( pAig, Aig_ManObjNumMax(pAig) );
Gia_ManForEachObj( pGia, pGiaObj, i )
{
pGiaRepr = Gia_ObjReprObj( pGia, i );
if ( pGiaRepr == NULL )
continue;
- Aig_ObjCreateRepr( p, Aig_ManObj(p, pGiaRepr->Value), Aig_ManObj(p, pGiaObj->Value) );
+ Aig_ObjCreateRepr( pAig, Aig_ManObj(pAig, Gia_Lit2Var(pGiaRepr->Value)), Aig_ManObj(pAig, Gia_Lit2Var(pGiaObj->Value)) );
}
}
/**Function*************************************************************
- Synopsis [Applied DC2 to the GIA manager.]
+ Synopsis [Transfers representatives from pAig to pGia.]
Description []
@@ -372,21 +455,159 @@ void Gia_ManReprToAigRepr( Aig_Man_t * p, Gia_Man_t * pGia )
SeeAlso []
***********************************************************************/
-Gia_Man_t * Gia_ManCompress2( Gia_Man_t * p )
+void Gia_ManReprFromAigRepr( Aig_Man_t * pAig, Gia_Man_t * pGia )
{
- extern Aig_Man_t * Dar_ManCompress2( Aig_Man_t * pAig, int fBalance, int fUpdateLevel, int fFanout, int fPower, int fVerbose );
+ Gia_Obj_t * pObjGia;
+ Aig_Obj_t * pObjAig, * pReprAig;
+ int i;
+ assert( pAig->pReprs != NULL );
+ assert( pGia->pReprs == NULL );
+ assert( Gia_ManObjNum(pGia) - Gia_ManCoNum(pGia) == Aig_ManObjNum(pAig) - Aig_ManPoNum(pAig) );
+ pGia->pReprs = ABC_CALLOC( Gia_Rpr_t, Gia_ManObjNum(pGia) );
+ for ( i = 0; i < Gia_ManObjNum(pGia); i++ )
+ Gia_ObjSetRepr( pGia, i, GIA_VOID );
+ Gia_ManForEachObj( pGia, pObjGia, i )
+ {
+// Abc_Print( 1, "%d -> %d %d\n", i, Gia_ObjValue(pObjGia), Gia_ObjValue(pObjGia)/2 );
+ if ( Gia_ObjIsCo(pObjGia) )
+ continue;
+ assert( i == 0 || !Gia_LitIsCompl(Gia_ObjValue(pObjGia)) );
+ pObjAig = Aig_ManObj( pAig, Gia_Lit2Var(Gia_ObjValue(pObjGia)) );
+ pObjAig->iData = i;
+ }
+ Aig_ManForEachObj( pAig, pObjAig, i )
+ {
+ if ( Aig_ObjIsPo(pObjAig) )
+ continue;
+ if ( pAig->pReprs[i] == NULL )
+ continue;
+ pReprAig = pAig->pReprs[i];
+ Gia_ObjSetRepr( pGia, pObjAig->iData, pReprAig->iData );
+ }
+ pGia->pNexts = Gia_ManDeriveNexts( pGia );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Applies DC2 to the GIA manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManCompress2( Gia_Man_t * p, int fUpdateLevel, int fVerbose )
+{
+// extern Aig_Man_t * Dar_ManCompress2( Aig_Man_t * pAig, int fBalance, int fUpdateLevel, int fFanout, int fPower, int fVerbose );
Gia_Man_t * pGia;
Aig_Man_t * pNew, * pTemp;
pNew = Gia_ManToAig( p, 0 );
- pNew = Dar_ManCompress2( pTemp = pNew, 1, 0, 1, 0, 0 );
+ pNew = Dar_ManCompress2( pTemp = pNew, 1, fUpdateLevel, 1, 0, fVerbose );
Aig_ManStop( pTemp );
pGia = Gia_ManFromAig( pNew );
Aig_ManStop( pNew );
return pGia;
}
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManPerformDch( Gia_Man_t * p, void * pPars )
+{
+ Gia_Man_t * pGia;
+ Aig_Man_t * pNew;
+ pNew = Gia_ManToAig( p, 0 );
+ pNew = Dar_ManChoiceNew( pNew, (Dch_Pars_t *)pPars );
+ pGia = Gia_ManFromAig( pNew );
+ Aig_ManStop( pNew );
+ return pGia;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes equivalences after structural sequential cleanup.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManSeqCleanupClasses( Gia_Man_t * p, int fConst, int fEquiv, int fVerbose )
+{
+ Aig_Man_t * pNew, * pTemp;
+ pNew = Gia_ManToAigSimple( p );
+ pTemp = Aig_ManScl( pNew, fConst, fEquiv, fVerbose );
+ Gia_ManReprFromAigRepr( pNew, p );
+ Aig_ManStop( pTemp );
+ Aig_ManStop( pNew );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Solves SAT problem.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManSolveSat( Gia_Man_t * p )
+{
+// extern int Fra_FraigSat( Aig_Man_t * pMan, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, int fFlipBits, int fAndOuts, int fVerbose );
+ Aig_Man_t * pNew;
+ int RetValue, clk = clock();
+ pNew = Gia_ManToAig( p, 0 );
+ RetValue = Fra_FraigSat( pNew, 10000000, 0, 1, 1, 0 );
+ if ( RetValue == 0 )
+ {
+ Gia_Obj_t * pObj;
+ int i, * pInit = (int *)pNew->pData;
+ Gia_ManConst0(p)->fMark0 = 0;
+ Gia_ManForEachPi( p, pObj, i )
+ pObj->fMark0 = pInit[i];
+ Gia_ManForEachAnd( p, pObj, i )
+ pObj->fMark0 = (Gia_ObjFanin0(pObj)->fMark0 ^ Gia_ObjFaninC0(pObj)) &
+ (Gia_ObjFanin1(pObj)->fMark0 ^ Gia_ObjFaninC1(pObj));
+ Gia_ManForEachPo( p, pObj, i )
+ pObj->fMark0 = (Gia_ObjFanin0(pObj)->fMark0 ^ Gia_ObjFaninC0(pObj));
+ Gia_ManForEachPo( p, pObj, i )
+ if ( pObj->fMark0 != 1 )
+ break;
+ if ( i != Gia_ManPoNum(p) )
+ Abc_Print( 1, "Counter-example verification has failed. " );
+// else
+// Abc_Print( 1, "Counter-example verification succeeded. " );
+ }
+/*
+ else if ( RetValue == 1 )
+ Abc_Print( 1, "The SAT problem is unsatisfiable. " );
+ else if ( RetValue == -1 )
+ Abc_Print( 1, "The SAT problem is undecided. " );
+ Abc_PrintTime( 1, "Time", clock() - clk );
+*/
+ Aig_ManStop( pNew );
+ return RetValue;
+}
+
+
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaAig.h b/src/aig/gia/giaAig.h
index 8cef5c7e..1c0a24d5 100644
--- a/src/aig/gia/giaAig.h
+++ b/src/aig/gia/giaAig.h
@@ -21,6 +21,7 @@
#ifndef __GIA_AIG_H__
#define __GIA_AIG_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -28,6 +29,9 @@
#include "aig.h"
#include "gia.h"
+ABC_NAMESPACE_HEADER_START
+
+
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
@@ -51,12 +55,18 @@ extern Gia_Man_t * Gia_ManFromAigSimple( Aig_Man_t * p );
extern Gia_Man_t * Gia_ManFromAigSwitch( Aig_Man_t * p );
extern Aig_Man_t * Gia_ManToAig( Gia_Man_t * p, int fChoices );
extern Aig_Man_t * Gia_ManToAigSkip( Gia_Man_t * p, int nOutDelta );
-extern void Gia_ManReprToAigRepr( Aig_Man_t * p, Gia_Man_t * pGia );
-extern Gia_Man_t * Gia_ManCompress2( Gia_Man_t * p );
-
-#ifdef __cplusplus
-}
-#endif
+extern Aig_Man_t * Gia_ManToAigSimple( Gia_Man_t * p );
+extern void Gia_ManReprToAigRepr( Aig_Man_t * pAig, Gia_Man_t * pGia );
+extern void Gia_ManReprToAigRepr2( Aig_Man_t * pAig, Gia_Man_t * pGia );
+extern void Gia_ManReprFromAigRepr( Aig_Man_t * pAig, Gia_Man_t * pGia );
+extern Gia_Man_t * Gia_ManCompress2( Gia_Man_t * p, int fUpdateLevel, int fVerbose );
+extern Gia_Man_t * Gia_ManPerformDch( Gia_Man_t * p, void * pPars );
+extern Gia_Man_t * Gia_ManAbstraction( Gia_Man_t * p, Vec_Int_t * vFlops );
+extern void Gia_ManSeqCleanupClasses( Gia_Man_t * p, int fConst, int fEquiv, int fVerbose );
+extern int Gia_ManSolveSat( Gia_Man_t * p );
+
+
+ABC_NAMESPACE_HEADER_END
#endif
diff --git a/src/aig/gia/giaAiger.c b/src/aig/gia/giaAiger.c
index 6c8ace8a..e201cbb9 100644
--- a/src/aig/gia/giaAiger.c
+++ b/src/aig/gia/giaAiger.c
@@ -21,6 +21,9 @@
#include "gia.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -41,7 +44,7 @@
SeeAlso []
***********************************************************************/
-unsigned Gia_ReadAigerDecode( char ** ppPos )
+unsigned Gia_ReadAigerDecode( unsigned char ** ppPos )
{
unsigned x = 0, i = 0;
unsigned char ch;
@@ -61,7 +64,7 @@ unsigned Gia_ReadAigerDecode( char ** ppPos )
SeeAlso []
***********************************************************************/
-Vec_Int_t * Gia_WriteDecodeLiterals( char ** ppPos, int nEntries )
+Vec_Int_t * Gia_WriteDecodeLiterals( unsigned char ** ppPos, int nEntries )
{
Vec_Int_t * vLits;
int Lit, LitPrev, Diff, i;
@@ -151,30 +154,6 @@ char * Gia_FileNameGeneric( char * FileName )
/**Function*************************************************************
- Synopsis [Returns the time stamp.]
-
- Description [The file should be closed.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-char * Gia_TimeStamp()
-{
- static char Buffer[100];
- char * TimeStamp;
- time_t ltime;
- // get the current time
- time( &ltime );
- TimeStamp = asctime( localtime( &ltime ) );
- TimeStamp[ strlen(TimeStamp) - 1 ] = 0;
- strcpy( Buffer, TimeStamp );
- return Buffer;
-}
-
-/**Function*************************************************************
-
Synopsis [Read integer from the string.]
Description []
@@ -203,7 +182,7 @@ int Gia_ReadInt( unsigned char * pPos )
SeeAlso []
***********************************************************************/
-unsigned Gia_ReadDiffValue( char ** ppPos, int iPrev )
+unsigned Gia_ReadDiffValue( unsigned char ** ppPos, int iPrev )
{
int Item = Gia_ReadAigerDecode( ppPos );
if ( Item & 1 )
@@ -371,7 +350,8 @@ Gia_Man_t * Gia_ReadAiger( char * pFileName, int fCheck )
Vec_Int_t * vNodes, * vDrivers;//, * vTerms;
int iObj, iNode0, iNode1;
int nTotal, nInputs, nOutputs, nLatches, nAnds, nFileSize, i;//, iTerm, nDigits;
- char * pContents, * pDrivers, * pSymbols, * pCur, * pName;//, * pType;
+ unsigned char * pDrivers, * pSymbols, * pCur;//, * pType;
+ char * pContents, * pName;
unsigned uLit0, uLit1, uLit;
// read the file into the buffer
@@ -391,17 +371,17 @@ Gia_Man_t * Gia_ReadAiger( char * pFileName, int fCheck )
}
// read the file type
- pCur = pContents; while ( *pCur++ != ' ' );
+ pCur = (unsigned char *)pContents; while ( *pCur++ != ' ' );
// read the number of objects
- nTotal = atoi( pCur ); while ( *pCur++ != ' ' );
+ nTotal = atoi( (char *)pCur ); while ( *pCur++ != ' ' );
// read the number of inputs
- nInputs = atoi( pCur ); while ( *pCur++ != ' ' );
+ nInputs = atoi( (char *)pCur ); while ( *pCur++ != ' ' );
// read the number of latches
- nLatches = atoi( pCur ); while ( *pCur++ != ' ' );
+ nLatches = atoi( (char *)pCur ); while ( *pCur++ != ' ' );
// read the number of outputs
- nOutputs = atoi( pCur ); while ( *pCur++ != ' ' );
+ nOutputs = atoi( (char *)pCur ); while ( *pCur++ != ' ' );
// read the number of nodes
- nAnds = atoi( pCur ); while ( *pCur++ != '\n' );
+ nAnds = atoi( (char *)pCur ); while ( *pCur++ != '\n' );
// check the parameters
if ( nTotal != nInputs + nLatches + nAnds )
{
@@ -465,14 +445,14 @@ Gia_Man_t * Gia_ReadAiger( char * pFileName, int fCheck )
pCur = pDrivers;
for ( i = 0; i < nLatches; i++ )
{
- uLit0 = atoi( pCur ); while ( *pCur++ != '\n' );
+ uLit0 = atoi( (char *)pCur ); while ( *pCur++ != '\n' );
iNode0 = Gia_LitNotCond( Vec_IntEntry(vNodes, uLit0 >> 1), (uLit0 & 1) );
Vec_IntPush( vDrivers, iNode0 );
}
// read the PO driver literals
for ( i = 0; i < nOutputs; i++ )
{
- uLit0 = atoi( pCur ); while ( *pCur++ != '\n' );
+ uLit0 = atoi( (char *)pCur ); while ( *pCur++ != '\n' );
iNode0 = Gia_LitNotCond( Vec_IntEntry(vNodes, uLit0 >> 1), (uLit0 & 1) );
Vec_IntPush( vDrivers, iNode0 );
}
@@ -509,7 +489,7 @@ Gia_Man_t * Gia_ReadAiger( char * pFileName, int fCheck )
// check if there are other types of information to read
pCur = pSymbols;
- if ( pCur + 1 < pContents + nFileSize && *pCur == 'c' )
+ if ( (char *)pCur + 1 < pContents + nFileSize && *pCur == 'c' )
{
pCur++;
if ( *pCur == 'e' )
@@ -539,17 +519,23 @@ Gia_Man_t * Gia_ReadAiger( char * pFileName, int fCheck )
pNew->pPlacement = Gia_ReadPlacement( &pCur, Gia_ManObjNum(pNew) );
}
if ( *pCur == 's' )
- {
+ {
pCur++;
// read switching activity
pNew->pSwitching = Gia_ReadSwitching( &pCur, Gia_ManObjNum(pNew) );
}
+ if ( *pCur == 'c' )
+ {
+ pCur++;
+ // read number of constraints
+ pNew->nConstrs = Gia_ReadInt( pCur ); pCur += 4;
+ }
if ( *pCur == 'n' )
{
pCur++;
// read model name
ABC_FREE( pNew->pName );
- pNew->pName = Gia_UtilStrsav( pCur );
+ pNew->pName = Gia_UtilStrsav( (char *)pCur );
}
}
@@ -710,7 +696,7 @@ unsigned char * Gia_WriteEquivClasses( Gia_Man_t * p, int * pEquivSize )
Gia_ClassForEachObj( p, iRepr, iNode )
nItems++;
}
- pBuffer = ABC_ALLOC( char, sizeof(int) * (nItems + 1) );
+ pBuffer = ABC_ALLOC( unsigned char, sizeof(int) * (nItems + 1) );
// write constant class
iPos = Gia_WriteAigerEncode( pBuffer, 4, Gia_Var2Lit(0, 1) );
//printf( "\nRepr = %d ", 0 );
@@ -754,7 +740,7 @@ unsigned char * Gia_WriteEquivClasses( Gia_Man_t * p, int * pEquivSize )
SeeAlso []
***********************************************************************/
-int Gia_WriteDiffValue( char * pPos, int iPos, int iPrev, int iThis )
+int Gia_WriteDiffValue( unsigned char * pPos, int iPos, int iPrev, int iThis )
{
if ( iPrev < iThis )
return Gia_WriteAigerEncode( pPos, iPos, Gia_Var2Lit(iThis - iPrev, 1) );
@@ -779,16 +765,16 @@ unsigned char * Gia_WriteMapping( Gia_Man_t * p, int * pMapSize )
assert( p->pMapping );
// count the number of entries to be written
nItems = 0;
- Gia_ManForEachGate( p, i )
- nItems += 2 + Gia_ObjGateSize( p, i );
- pBuffer = ABC_ALLOC( char, sizeof(int) * (nItems + 1) );
+ Gia_ManForEachLut( p, i )
+ nItems += 2 + Gia_ObjLutSize( p, i );
+ pBuffer = ABC_ALLOC( unsigned char, sizeof(int) * (nItems + 1) );
// write non-constant classes
iPrev = 0;
- Gia_ManForEachGate( p, i )
+ Gia_ManForEachLut( p, i )
{
-//printf( "\nSize = %d ", Gia_ObjGateSize(p, i) );
- iPos = Gia_WriteAigerEncode( pBuffer, iPos, Gia_ObjGateSize(p, i) );
- Gia_GateForEachFanin( p, i, iFan, k )
+//printf( "\nSize = %d ", Gia_ObjLutSize(p, i) );
+ iPos = Gia_WriteAigerEncode( pBuffer, iPos, Gia_ObjLutSize(p, i) );
+ Gia_LutForEachFanin( p, i, iFan, k )
{
//printf( "Fan = %d ", iFan );
iPos = Gia_WriteDiffValue( pBuffer, iPos, iPrev, iFan );
@@ -915,8 +901,9 @@ void Gia_WriteAiger( Gia_Man_t * pInit, char * pFileName, int fWriteSymbols, int
// write flop classes
if ( p->vFlopClasses )
{
- char Buffer[10];
+ unsigned char Buffer[10];
int nSize = 4*Gia_ManRegNum(p);
+ Gia_WriteInt( Buffer, nSize );
fprintf( pFile, "f" );
fwrite( Buffer, 1, 4, pFile );
fwrite( Vec_IntArray(p->vFlopClasses), 1, nSize, pFile );
@@ -933,7 +920,7 @@ void Gia_WriteAiger( Gia_Man_t * pInit, char * pFileName, int fWriteSymbols, int
// write placement
if ( p->pPlacement )
{
- char Buffer[10];
+ unsigned char Buffer[10];
int nSize = 4*Gia_ManObjNum(p);
Gia_WriteInt( Buffer, nSize );
fprintf( pFile, "p" );
@@ -943,13 +930,21 @@ void Gia_WriteAiger( Gia_Man_t * pInit, char * pFileName, int fWriteSymbols, int
// write flop classes
if ( p->pSwitching )
{
- char Buffer[10];
+ unsigned char Buffer[10];
int nSize = Gia_ManObjNum(p);
Gia_WriteInt( Buffer, nSize );
fprintf( pFile, "s" );
fwrite( Buffer, 1, 4, pFile );
fwrite( p->pSwitching, 1, nSize, pFile );
}
+ // write constraints
+ if ( p->nConstrs )
+ {
+ unsigned char Buffer[10];
+ Gia_WriteInt( Buffer, p->nConstrs );
+ fprintf( pFile, "c" );
+ fwrite( Buffer, 1, 4, pFile );
+ }
// write name
if ( p->pName )
fprintf( pFile, "n%s%c", p->pName, '\0' );
@@ -983,3 +978,5 @@ void Gia_DumpAiger( Gia_Man_t * p, char * pFilePrefix, int iFileNum, int nFileNu
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaAiger_new.c b/src/aig/gia/giaAiger_new.c
new file mode 100644
index 00000000..67981b26
--- /dev/null
+++ b/src/aig/gia/giaAiger_new.c
@@ -0,0 +1,1251 @@
+/**CFile****************************************************************
+
+ FileName [giaAiger.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Scalable AIG package.]
+
+ Synopsis [Procedures to read/write binary AIGER format developed by
+ Armin Biere, Johannes Kepler University (http://fmv.jku.at/)]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: giaAiger.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+typedef ABC_UINT64_T word;
+
+static inline int Gia_ObjObjPhaseDiff( Gia_Man_t * p, int i, int j ) { return Gia_ManObj(p, i)->fPhase ^ Gia_ManObj(p, j)->fPhase; }
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Extracts one unsigned AIG edge from the input buffer.]
+
+ Description [This procedure is a slightly modified version of Armin Biere's
+ procedure "unsigned decode (FILE * file)". ]
+
+ SideEffects [Updates the current reading position.]
+
+ SeeAlso []
+
+***********************************************************************/
+unsigned Gia_ReadAigerDecode( char ** ppPos )
+{
+ unsigned x = 0, i = 0;
+ unsigned char ch;
+ while ((ch = *(*ppPos)++) & 0x80)
+ x |= (ch & 0x7f) << (7 * i++);
+ return x | (ch << (7 * i));
+}
+
+/**Function*************************************************************
+
+ Synopsis [Extracts one signed AIG edge from the input buffer.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ReadAigerDecodeInt( char ** ppPos )
+{
+ unsigned Res;
+ Res = Gia_ReadAigerDecode( ppPos );
+ if ( Res & 1 )
+ return -((int)(Res >> 1));
+ return Res >> 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Decodes the encoded array of literals.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Gia_WriteDecodeLiterals( char ** ppPos, int nEntries )
+{
+ Vec_Int_t * vLits;
+ int Lit, LitPrev, Diff, i;
+ vLits = Vec_IntAlloc( nEntries );
+ LitPrev = Gia_ReadAigerDecode( ppPos );
+ Vec_IntPush( vLits, LitPrev );
+ for ( i = 1; i < nEntries; i++ )
+ {
+// Diff = Lit - LitPrev;
+// Diff = (Lit < LitPrev)? -Diff : Diff;
+// Diff = ((2 * Diff) << 1) | (int)(Lit < LitPrev);
+ Diff = Gia_ReadAigerDecode( ppPos );
+ Diff = (Diff & 1)? -(Diff >> 1) : Diff >> 1;
+ Lit = Diff + LitPrev;
+ Vec_IntPush( vLits, Lit );
+ LitPrev = Lit;
+ }
+ return vLits;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Returns the file size.]
+
+ Description [The file should be closed.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_FixFileName( char * pFileName )
+{
+ char * pName;
+ for ( pName = pFileName; *pName; pName++ )
+ if ( *pName == '>' )
+ *pName = '\\';
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the file size.]
+
+ Description [The file should be closed.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_FileSize( char * pFileName )
+{
+ FILE * pFile;
+ int nFileSize;
+ pFile = fopen( pFileName, "r" );
+ if ( pFile == NULL )
+ {
+ printf( "Gia_FileSize(): The file is unavailable (absent or open).\n" );
+ return 0;
+ }
+ fseek( pFile, 0, SEEK_END );
+ nFileSize = ftell( pFile );
+ fclose( pFile );
+ return nFileSize;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+char * Gia_FileNameGeneric( char * FileName )
+{
+ char * pDot, * pRes;
+ pRes = Gia_UtilStrsav( FileName );
+ if ( (pDot = strrchr( pRes, '.' )) )
+ *pDot = 0;
+ return pRes;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Write integer into the string.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ReadInt( unsigned char * pPos )
+{
+ int i, Value = 0;
+ for ( i = 0; i < 4; i++ )
+ Value |= ((unsigned)(*pPos++)) << (i << 3);
+ return Value;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Reads decoded value.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+unsigned Gia_ReadDiffValue( char ** ppPos, int iPrev )
+{
+ int Item = Gia_ReadAigerDecode( ppPos );
+ if ( Item & 1 )
+ return iPrev + (Item >> 1);
+ return iPrev - (Item >> 1);
+}
+
+/**Function*************************************************************
+
+ Synopsis [Read equivalence classes from the string.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Rpr_t * Gia_ReadEquivClasses_old( unsigned char ** ppPos, int nSize )
+{
+ Gia_Rpr_t * pReprs;
+ unsigned char * pStop;
+ int i, Item, fProved, iRepr, iNode;
+ pStop = *ppPos;
+ pStop += Gia_ReadInt( *ppPos ); *ppPos += 4;
+ pReprs = ABC_CALLOC( Gia_Rpr_t, nSize );
+ for ( i = 0; i < nSize; i++ )
+ pReprs[i].iRepr = GIA_VOID;
+ iRepr = iNode = 0;
+ while ( *ppPos < pStop )
+ {
+ Item = Gia_ReadAigerDecode( ppPos );
+ if ( Item & 1 )
+ {
+ iRepr += (Item >> 1);
+ iNode = iRepr;
+//printf( "\nRepr = %d ", iRepr );
+ continue;
+ }
+ Item >>= 1;
+ fProved = (Item & 1);
+ Item >>= 1;
+ iNode += Item;
+ pReprs[iNode].fProved = fProved;
+ pReprs[iNode].iRepr = iRepr;
+ assert( iRepr < iNode );
+//printf( "Node = %d ", iNode );
+ }
+ return pReprs;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Read equivalence classes from the string.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Rpr_t * Gia_ReadEquivClasses( unsigned char ** ppPos, int nSize, int nAlloc )
+{
+ Gia_Rpr_t * pReprs;
+ unsigned char * pStop;
+ int i, k, iRepr, iNode, nMembers;
+ // find place to stop
+ pStop = *ppPos + nSize;
+ // prepare equivalence classes
+ pReprs = ABC_CALLOC( Gia_Rpr_t, nAlloc );
+ for ( i = 0; i < nAlloc; i++ )
+ pReprs[i].iRepr = GIA_VOID;
+ // skip the number of classes
+ Gia_ReadAigerDecode( ppPos );
+ // read classes
+ iRepr = 0;
+ while ( *ppPos < pStop )
+ {
+ nMembers = Gia_ReadAigerDecode( ppPos );
+ iRepr += Gia_ReadAigerDecode( ppPos );
+ iNode = iRepr;
+ for ( k = 1; k < nMembers; k++ )
+ {
+ iNode += Gia_ReadAigerDecode( ppPos );
+ pReprs[ Gia_Lit2Var(iNode) ].iRepr = Gia_Lit2Var(iRepr);
+ assert( Gia_Lit2Var(iRepr) < Gia_Lit2Var(iNode) );
+//if ( !iRepr )
+//printf( "%4d: Reading equiv %d -> %d\n", k, iNode, iRepr );
+ }
+ }
+ return pReprs;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Read flop classes from the string.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ReadFlopClasses( unsigned char ** ppPos, Vec_Int_t * vClasses, int nSize )
+{
+ int nAlloc = Gia_ReadInt( *ppPos ); *ppPos += 4;
+ assert( nAlloc/4 == nSize );
+ assert( Vec_IntSize(vClasses) == nSize );
+ memcpy( Vec_IntArray(vClasses), *ppPos, 4*nSize );
+ *ppPos += 4 * nSize;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Read equivalence classes from the string.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int * Gia_ReadMapping( unsigned char ** ppPos, int nSize )
+{
+ int * pMapping;
+ unsigned char * pStop;
+ int k, j, nFanins, nAlloc, iNode = 0, iOffset = nSize;
+ pStop = *ppPos;
+ pStop += Gia_ReadInt( *ppPos ); *ppPos += 4;
+ nAlloc = nSize + pStop - *ppPos;
+ pMapping = ABC_CALLOC( int, nAlloc );
+ while ( *ppPos < pStop )
+ {
+ k = iOffset;
+ pMapping[k++] = nFanins = Gia_ReadAigerDecode( ppPos );
+ for ( j = 0; j <= nFanins; j++ )
+ pMapping[k++] = iNode = Gia_ReadDiffValue( ppPos, iNode );
+ pMapping[iNode] = iOffset;
+ iOffset = k;
+ }
+ assert( iOffset <= nAlloc );
+ return pMapping;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Read switching from the string.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+unsigned char * Gia_ReadSwitching( unsigned char ** ppPos, int nSize )
+{
+ unsigned char * pSwitching;
+ int nAlloc = Gia_ReadInt( *ppPos ); *ppPos += 4;
+ assert( nAlloc == nSize );
+ pSwitching = ABC_ALLOC( unsigned char, nSize );
+ memcpy( pSwitching, *ppPos, nSize );
+ *ppPos += nSize;
+ return pSwitching;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Read placement from the string.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Plc_t * Gia_ReadPlacement( unsigned char ** ppPos, int nSize )
+{
+ Gia_Plc_t * pPlacement;
+ int nAlloc = Gia_ReadInt( *ppPos ); *ppPos += 4;
+ assert( nAlloc/4 == nSize );
+ pPlacement = ABC_ALLOC( Gia_Plc_t, nSize );
+ memcpy( pPlacement, *ppPos, 4*nSize );
+ *ppPos += 4 * nSize;
+ return pPlacement;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Reads char and 64-bit int using little-endian style.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+char Gia_ReadBlockHeader( char ** ppCur, word * pWord )
+{
+ int i;
+ char Char = *(*ppCur)++;
+ *pWord = 0;
+ for ( i = 0; i < 8; i++ )
+ {
+// printf( "%d\n", (unsigned char)(*(*ppCur)) );
+ *pWord |= ((word)(unsigned char)(*(*ppCur)++)) << (i<<3);
+ }
+ return Char;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Reads the AIG in the binary AIGER format.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ReadAiger( char * pFileName, int fCheck )
+{
+ FILE * pFile;
+ Gia_Man_t * pNew;
+ Vec_Int_t * vLits = NULL;
+ Vec_Int_t * vNodes, * vDrivers;//, * vTerms;
+ int iObj, iNode0, iNode1;
+ int nTotal, nInputs, nOutputs, nLatches, nAnds, nFileSize, i;//, iTerm, nDigits;
+ char * pContents, * pDrivers, * pSymbols, * pCur, * pName;//, * pType;
+ unsigned uLit0, uLit1, uLit;
+
+ // read the file into the buffer
+ Gia_FixFileName( pFileName );
+ nFileSize = Gia_FileSize( pFileName );
+ pFile = fopen( pFileName, "rb" );
+ pContents = ABC_ALLOC( char, nFileSize );
+ fread( pContents, nFileSize, 1, pFile );
+ fclose( pFile );
+
+ // check if the input file format is correct
+ if ( strncmp(pContents, "aig", 3) != 0 || (pContents[3] != ' ' && pContents[3] != '2') )
+ {
+ fprintf( stdout, "Wrong input file format.\n" );
+ free( pContents );
+ return NULL;
+ }
+
+ // read the file type
+ pCur = pContents; while ( *pCur++ != ' ' );
+ // read the number of objects
+ nTotal = atoi( pCur ); while ( *pCur++ != ' ' );
+ // read the number of inputs
+ nInputs = atoi( pCur ); while ( *pCur++ != ' ' );
+ // read the number of latches
+ nLatches = atoi( pCur ); while ( *pCur++ != ' ' );
+ // read the number of outputs
+ nOutputs = atoi( pCur ); while ( *pCur++ != ' ' );
+ // read the number of nodes
+ nAnds = atoi( pCur ); while ( *pCur++ != '\n' );
+ // check the parameters
+ if ( nTotal != nInputs + nLatches + nAnds )
+ {
+ fprintf( stdout, "The paramters are wrong.\n" );
+ return NULL;
+ }
+
+ // allocate the empty AIG
+ pNew = Gia_ManStart( nTotal + nLatches + nOutputs + 1 );
+ pName = Gia_FileNameGeneric( pFileName );
+ pNew->pName = Gia_UtilStrsav( pName );
+// pNew->pSpec = Gia_UtilStrsav( pFileName );
+ ABC_FREE( pName );
+
+ // prepare the array of nodes
+ vNodes = Vec_IntAlloc( 1 + nTotal );
+ Vec_IntPush( vNodes, 0 );
+
+ // create the PIs
+ for ( i = 0; i < nInputs + nLatches; i++ )
+ {
+ iObj = Gia_ManAppendCi(pNew);
+ Vec_IntPush( vNodes, iObj );
+ }
+
+ // remember the beginning of latch/PO literals
+ pDrivers = pCur;
+ if ( pContents[3] == ' ' ) // standard AIGER
+ {
+ // scroll to the beginning of the binary data
+ for ( i = 0; i < nLatches + nOutputs; )
+ if ( *pCur++ == '\n' )
+ i++;
+ }
+ else // modified AIGER
+ {
+ vLits = Gia_WriteDecodeLiterals( &pCur, nLatches + nOutputs );
+ }
+
+ // create the AND gates
+ for ( i = 0; i < nAnds; i++ )
+ {
+ uLit = ((i + 1 + nInputs + nLatches) << 1);
+ uLit1 = uLit - Gia_ReadAigerDecode( &pCur );
+ uLit0 = uLit1 - Gia_ReadAigerDecode( &pCur );
+// assert( uLit1 > uLit0 );
+ iNode0 = Gia_LitNotCond( Vec_IntEntry(vNodes, uLit0 >> 1), uLit0 & 1 );
+ iNode1 = Gia_LitNotCond( Vec_IntEntry(vNodes, uLit1 >> 1), uLit1 & 1 );
+ assert( Vec_IntSize(vNodes) == i + 1 + nInputs + nLatches );
+// Vec_IntPush( vNodes, Gia_And(pNew, iNode0, iNode1) );
+ Vec_IntPush( vNodes, Gia_ManAppendAnd(pNew, iNode0, iNode1) );
+ }
+
+ // remember the place where symbols begin
+ pSymbols = pCur;
+
+ // read the latch driver literals
+ vDrivers = Vec_IntAlloc( nLatches + nOutputs );
+ if ( pContents[3] == ' ' ) // standard AIGER
+ {
+ pCur = pDrivers;
+ for ( i = 0; i < nLatches; i++ )
+ {
+ uLit0 = atoi( pCur ); while ( *pCur++ != '\n' );
+ iNode0 = Gia_LitNotCond( Vec_IntEntry(vNodes, uLit0 >> 1), (uLit0 & 1) );
+ Vec_IntPush( vDrivers, iNode0 );
+ }
+ // read the PO driver literals
+ for ( i = 0; i < nOutputs; i++ )
+ {
+ uLit0 = atoi( pCur ); while ( *pCur++ != '\n' );
+ iNode0 = Gia_LitNotCond( Vec_IntEntry(vNodes, uLit0 >> 1), (uLit0 & 1) );
+ Vec_IntPush( vDrivers, iNode0 );
+ }
+
+ }
+ else
+ {
+ // read the latch driver literals
+ for ( i = 0; i < nLatches; i++ )
+ {
+ uLit0 = Vec_IntEntry( vLits, i );
+ iNode0 = Gia_LitNotCond( Vec_IntEntry(vNodes, uLit0 >> 1), (uLit0 & 1) );
+ Vec_IntPush( vDrivers, iNode0 );
+ }
+ // read the PO driver literals
+ for ( i = 0; i < nOutputs; i++ )
+ {
+ uLit0 = Vec_IntEntry( vLits, i+nLatches );
+ iNode0 = Gia_LitNotCond( Vec_IntEntry(vNodes, uLit0 >> 1), (uLit0 & 1) );
+ Vec_IntPush( vDrivers, iNode0 );
+ }
+ Vec_IntFree( vLits );
+ }
+
+ // create the POs
+ for ( i = 0; i < nOutputs; i++ )
+ Gia_ManAppendCo( pNew, Vec_IntEntry(vDrivers, nLatches + i) );
+ for ( i = 0; i < nLatches; i++ )
+ Gia_ManAppendCo( pNew, Vec_IntEntry(vDrivers, i) );
+ Vec_IntFree( vDrivers );
+
+ // create the latches
+ Gia_ManSetRegNum( pNew, nLatches );
+
+ // check if there are other types of information to read
+ pCur = pSymbols;
+ if ( pCur + 1 < pContents + nFileSize && *pCur == 'c' )
+ {
+ char Char;
+ word Size;
+ pCur++;
+
+ // read model name (old style)
+ if ( *pCur == 'n' )
+ {
+ pCur++;
+ ABC_FREE( pNew->pName );
+ pNew->pName = Gia_UtilStrsav( pCur );
+ pCur += (int)(strlen(pNew->pName) + 1);
+ }
+
+ Char = Gia_ReadBlockHeader( &pCur, &Size );
+ if ( Char == '\n' && Size == 0xAC1D0FF1CEC0FFEE )
+ {
+ while ( (Char = Gia_ReadBlockHeader(&pCur, &Size)) )
+ {
+ switch (Char)
+ {
+ case 'N':
+ // read model name
+ ABC_FREE( pNew->pName );
+ pNew->pName = ABC_ALLOC( char, (int)Size + 1 );
+ strncpy( pNew->pName, pCur, (int)Size );
+ pNew->pName[(int)Size] = '\0';
+ pCur += (int)Size;
+ break;
+ case '=':
+ // read equivalence classes
+ pNew->pReprs = Gia_ReadEquivClasses( &pCur, (int)Size, Gia_ManObjNum(pNew) );
+ pNew->pNexts = Gia_ManDeriveNexts( pNew );
+ break;
+ case 'c':
+ // read number of constraints
+ pNew->nConstrs = Gia_ReadInt( pCur ); pCur += 4;
+ break;
+ default:
+ printf( "Unrecognized data.\n" );
+ break;
+ }
+ }
+ }
+ else
+ {
+ printf( "Extended AIGER reader: Internal signature does not match.\n" );
+ }
+
+/*
+ if ( *pCur == 'e' )
+ {
+ pCur++;
+ // read equivalence classes
+ pNew->pReprs = Gia_ReadEquivClasses( &pCur, Gia_ManObjNum(pNew) );
+ pNew->pNexts = Gia_ManDeriveNexts( pNew );
+ }
+ if ( *pCur == 'f' )
+ {
+ pCur++;
+ // read flop classes
+ pNew->vFlopClasses = Vec_IntStart( Gia_ManRegNum(pNew) );
+ Gia_ReadFlopClasses( &pCur, pNew->vFlopClasses, Gia_ManRegNum(pNew) );
+ }
+ if ( *pCur == 'm' )
+ {
+ pCur++;
+ // read mapping
+ pNew->pMapping = Gia_ReadMapping( &pCur, Gia_ManObjNum(pNew) );
+ }
+ if ( *pCur == 'p' )
+ {
+ pCur++;
+ // read placement
+ pNew->pPlacement = Gia_ReadPlacement( &pCur, Gia_ManObjNum(pNew) );
+ }
+ if ( *pCur == 's' )
+ {
+ pCur++;
+ // read switching activity
+ pNew->pSwitching = Gia_ReadSwitching( &pCur, Gia_ManObjNum(pNew) );
+ }
+ if ( *pCur == 'c' )
+ {
+ pCur++;
+ // read number of constraints
+ pNew->nConstrs = Gia_ReadInt( pCur ); pCur += 4;
+ }
+ if ( *pCur == 'n' )
+ {
+ pCur++;
+ // read model name
+ ABC_FREE( pNew->pName );
+ pNew->pName = Gia_UtilStrsav( pCur );
+ }
+*/
+ }
+
+ // skipping the comments
+ ABC_FREE( pContents );
+ Vec_IntFree( vNodes );
+/*
+ // check the result
+ if ( fCheck && !Gia_ManCheck( pNew ) )
+ {
+ printf( "Gia_ReadAiger: The network check has failed.\n" );
+ Gia_ManStop( pNew );
+ return NULL;
+ }
+*/
+ return pNew;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Adds one unsigned AIG edge to the output buffer.]
+
+ Description [This procedure is a slightly modified version of Armin Biere's
+ procedure "void encode (FILE * file, unsigned x)" ]
+
+ SideEffects [Returns the current writing position.]
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_WriteAigerEncode( unsigned char * pBuffer, int Pos, unsigned x )
+{
+ unsigned char ch;
+ while (x & ~0x7f)
+ {
+ ch = (x & 0x7f) | 0x80;
+ pBuffer[Pos++] = ch;
+ x >>= 7;
+ }
+ ch = x;
+ pBuffer[Pos++] = ch;
+ return Pos;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Adds one signed int to the output buffer.]
+
+ Description []
+
+ SideEffects [Returns the current writing position.]
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_WriteAigerEncodeInt( unsigned char * pBuffer, int Pos, int x )
+{
+ if ( x >= 0 )
+ return Gia_WriteAigerEncode( pBuffer, Pos, ((unsigned)(x) << 1) );
+ return Gia_WriteAigerEncode( pBuffer, Pos, ((unsigned)(-x) << 1) | 1 );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Create the array of literals to be written.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Gia_WriteAigerLiterals( Gia_Man_t * p )
+{
+ Vec_Int_t * vLits;
+ Gia_Obj_t * pObj;
+ int i;
+ vLits = Vec_IntAlloc( Gia_ManPoNum(p) );
+ Gia_ManForEachRi( p, pObj, i )
+ Vec_IntPush( vLits, Gia_ObjFaninLit0p(p, pObj) );
+ Gia_ManForEachPo( p, pObj, i )
+ Vec_IntPush( vLits, Gia_ObjFaninLit0p(p, pObj) );
+ return vLits;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates the binary encoded array of literals.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Str_t * Gia_WriteEncodeLiterals( Vec_Int_t * vLits )
+{
+ Vec_Str_t * vBinary;
+ int Pos = 0, Lit, LitPrev, Diff, i;
+ vBinary = Vec_StrAlloc( 2 * Vec_IntSize(vLits) );
+ LitPrev = Vec_IntEntry( vLits, 0 );
+ Pos = Gia_WriteAigerEncode( (unsigned char *)Vec_StrArray(vBinary), Pos, LitPrev );
+ Vec_IntForEachEntryStart( vLits, Lit, i, 1 )
+ {
+ Diff = Lit - LitPrev;
+ Diff = (Lit < LitPrev)? -Diff : Diff;
+ Diff = (Diff << 1) | (int)(Lit < LitPrev);
+ Pos = Gia_WriteAigerEncode( (unsigned char *)Vec_StrArray(vBinary), Pos, Diff );
+ LitPrev = Lit;
+ if ( Pos + 10 > vBinary->nCap )
+ Vec_StrGrow( vBinary, vBinary->nCap+1 );
+ }
+ vBinary->nSize = Pos;
+/*
+ // verify
+ {
+ extern Vec_Int_t * Gia_WriteDecodeLiterals( char ** ppPos, int nEntries );
+ char * pPos = Vec_StrArray( vBinary );
+ Vec_Int_t * vTemp = Gia_WriteDecodeLiterals( &pPos, Vec_IntSize(vLits) );
+ for ( i = 0; i < Vec_IntSize(vLits); i++ )
+ {
+ int Entry1 = Vec_IntEntry(vLits,i);
+ int Entry2 = Vec_IntEntry(vTemp,i);
+ assert( Entry1 == Entry2 );
+ }
+ Vec_IntFree( vTemp );
+ }
+*/
+ return vBinary;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Write integer into the string.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_WriteInt( char * pBuffer, int Value )
+{
+ int i;
+ for ( i = 0; i < 4; i++ )
+ pBuffer[i] = (char)(0xff & (Value >> (i<<3)));
+}
+
+/**Function*************************************************************
+
+ Synopsis [Read equivalence classes from the string.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+unsigned char * Gia_WriteEquivClasses_old( Gia_Man_t * p, int * pEquivSize )
+{
+ unsigned char * pBuffer;
+ int iRepr, iNode, iPrevRepr, iPrevNode, iLit, nItems, iPos;
+ assert( p->pReprs && p->pNexts );
+ // count the number of entries to be written
+ nItems = 0;
+ for ( iRepr = 1; iRepr < Gia_ManObjNum(p); iRepr++ )
+ {
+ nItems += Gia_ObjIsConst( p, iRepr );
+ if ( !Gia_ObjIsHead(p, iRepr) )
+ continue;
+ Gia_ClassForEachObj( p, iRepr, iNode )
+ nItems++;
+ }
+ pBuffer = ABC_ALLOC( char, sizeof(int) * (nItems + 1) );
+ // write constant class
+ iPos = Gia_WriteAigerEncode( pBuffer, 4, Gia_Var2Lit(0, 1) );
+ iPrevNode = 0;
+ for ( iNode = 1; iNode < Gia_ManObjNum(p); iNode++ )
+ if ( Gia_ObjIsConst(p, iNode) )
+ {
+ iLit = Gia_Var2Lit( iNode - iPrevNode, Gia_ObjProved(p, iNode) );
+ iPrevNode = iNode;
+ iPos = Gia_WriteAigerEncode( pBuffer, iPos, Gia_Var2Lit(iLit, 0) );
+ }
+ // write non-constant classes
+ iPrevRepr = 0;
+ Gia_ManForEachClass( p, iRepr )
+ {
+ iPos = Gia_WriteAigerEncode( pBuffer, iPos, Gia_Var2Lit(iRepr - iPrevRepr, 1) );
+ iPrevRepr = iPrevNode = iRepr;
+ Gia_ClassForEachObj1( p, iRepr, iNode )
+ {
+ iLit = Gia_Var2Lit( iNode - iPrevNode, Gia_ObjProved(p, iNode) );
+ iPrevNode = iNode;
+ iPos = Gia_WriteAigerEncode( pBuffer, iPos, Gia_Var2Lit(iLit, 0) );
+ }
+ }
+ Gia_WriteInt( pBuffer, iPos );
+ *pEquivSize = iPos;
+ return pBuffer;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Read equivalence classes from the string.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+unsigned char * Gia_WriteEquivClasses( Gia_Man_t * p, int * pEquivSize )
+{
+ unsigned char * pBuffer;
+ int k, iNode, iRepr, iPrevLit, iNodeLit, iPrevReprLit, iReprLit;
+ int nItems, iPos, nClasses, nMembers;
+ assert( p->pReprs && p->pNexts );
+ Gia_ManSetPhase(p);
+ // count the number of entries to be written
+ nItems = 0;
+ nMembers = 0;
+ nClasses = 0;
+ for ( iRepr = 1; iRepr < Gia_ManObjNum(p); iRepr++ )
+ {
+ nItems += Gia_ObjIsConst( p, iRepr );
+ nMembers += Gia_ObjIsConst( p, iRepr );
+ if ( !Gia_ObjIsHead(p, iRepr) )
+ continue;
+ nClasses++;
+ Gia_ClassForEachObj( p, iRepr, iNode )
+ nItems++;
+ }
+ nClasses += (nMembers > 0);
+ // allocate place for data
+ pBuffer = (unsigned char *)ABC_ALLOC( int, nItems+1 );
+ // write the number of classes
+ iPos = Gia_WriteAigerEncode( pBuffer, 0, nClasses );
+ // write constant class
+ if ( nMembers )
+ {
+ iPos = Gia_WriteAigerEncode( pBuffer, iPos, nMembers+1 );
+ iPos = Gia_WriteAigerEncode( pBuffer, iPos, Gia_Var2Lit(0,0) );
+ iPrevLit = Gia_Var2Lit(0,0);
+ k = 1;
+ for ( iNode = 1; iNode < Gia_ManObjNum(p); iNode++ )
+ if ( Gia_ObjIsConst(p, iNode) )
+ {
+ iNodeLit = Gia_Var2Lit( iNode, Gia_ObjPhase(Gia_ManObj(p, iNode)) );
+ iPos = Gia_WriteAigerEncode( pBuffer, iPos, iNodeLit - iPrevLit );
+ iPrevLit = iNodeLit;
+//printf( "%4d : Writing equiv %d -> %d\n", k++, iNode, 0 );
+ }
+ }
+ // write non-constant classes
+ iPrevReprLit = 0;
+ Gia_ManForEachClass( p, iRepr )
+ {
+ // write number of members
+ nMembers = 0;
+ Gia_ClassForEachObj( p, iRepr, iNode )
+ nMembers++;
+ iPos = Gia_WriteAigerEncode( pBuffer, iPos, nMembers );
+ // write representative
+ iReprLit = Gia_Var2Lit( iRepr, Gia_ObjPhase(Gia_ManObj(p, iRepr)) );
+ iPos = Gia_WriteAigerEncode( pBuffer, iPos, iReprLit - iPrevReprLit );
+ iPrevReprLit = iReprLit;
+ // write members
+ iPrevLit = iReprLit;
+ Gia_ClassForEachObj1( p, iRepr, iNode )
+ {
+ iNodeLit = Gia_Var2Lit( iNode, Gia_ObjPhase(Gia_ManObj(p, iNode)) );
+ iPos = Gia_WriteAigerEncode( pBuffer, iPos, iNodeLit - iPrevLit );
+ iPrevLit = iNodeLit;
+//printf( "Writing equiv %d -> %d\n", iNode, iRepr );
+ }
+ }
+ *pEquivSize = iPos;
+ return pBuffer;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Reads decoded value.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_WriteDiffValue( char * pPos, int iPos, int iPrev, int iThis )
+{
+ if ( iPrev < iThis )
+ return Gia_WriteAigerEncode( pPos, iPos, Gia_Var2Lit(iThis - iPrev, 1) );
+ return Gia_WriteAigerEncode( pPos, iPos, Gia_Var2Lit(iPrev - iThis, 0) );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Read equivalence classes from the string.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+unsigned char * Gia_WriteMapping( Gia_Man_t * p, int * pMapSize )
+{
+ unsigned char * pBuffer;
+ int i, k, iPrev, iFan, nItems, iPos = 4;
+ assert( p->pMapping );
+ // count the number of entries to be written
+ nItems = 0;
+ Gia_ManForEachLut( p, i )
+ nItems += 2 + Gia_ObjLutSize( p, i );
+ pBuffer = ABC_ALLOC( char, sizeof(int) * (nItems + 1) );
+ // write non-constant classes
+ iPrev = 0;
+ Gia_ManForEachLut( p, i )
+ {
+//printf( "\nSize = %d ", Gia_ObjLutSize(p, i) );
+ iPos = Gia_WriteAigerEncode( pBuffer, iPos, Gia_ObjLutSize(p, i) );
+ Gia_LutForEachFanin( p, i, iFan, k )
+ {
+//printf( "Fan = %d ", iFan );
+ iPos = Gia_WriteDiffValue( pBuffer, iPos, iPrev, iFan );
+ iPrev = iFan;
+ }
+ iPos = Gia_WriteDiffValue( pBuffer, iPos, iPrev, i );
+ iPrev = i;
+//printf( "Node = %d ", i );
+ }
+//printf( "\n" );
+ Gia_WriteInt( pBuffer, iPos );
+ *pMapSize = iPos;
+ return pBuffer;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Writes char and 64-bit int using little-endian style.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_WriteBlockHeader( FILE * pFile, char Char, word Word )
+{
+ int i;
+ fprintf( pFile, "%c", Char );
+ for ( i = 0; i < 8; i++ )
+ fprintf( pFile, "%c", (unsigned char)(0xff & (Word >> (i<<3))) );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Write integer into the string.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_WriteIntF( FILE * pFile, int Value )
+{
+ int i;
+ for ( i = 0; i < 4; i++ )
+ fprintf( pFile, "%c", (char)(0xff & (Value >> (i<<3))) );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Writes the AIG in the binary AIGER format.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_WriteAiger( Gia_Man_t * pInit, char * pFileName, int fWriteSymbols, int fCompact )
+{
+ FILE * pFile;
+ Gia_Man_t * p;
+ Gia_Obj_t * pObj;
+ int i, nBufferSize, Pos;
+ unsigned char * pBuffer;
+ unsigned uLit0, uLit1, uLit;
+
+ if ( Gia_ManCoNum(pInit) == 0 )
+ {
+ printf( "AIG cannot be written because it has no POs.\n" );
+ return;
+ }
+
+ // start the output stream
+ pFile = fopen( pFileName, "wb" );
+ if ( pFile == NULL )
+ {
+ fprintf( stdout, "Gia_WriteAiger(): Cannot open the output file \"%s\".\n", pFileName );
+ return;
+ }
+
+ // create normalized AIG
+ if ( !Gia_ManIsNormalized(pInit) )
+ {
+// printf( "Gia_WriteAiger(): Normalizing AIG for writing.\n" );
+ p = Gia_ManDupNormalized( pInit );
+ }
+ else
+ p = pInit;
+
+ // write the header "M I L O A" where M = I + L + A
+ fprintf( pFile, "aig%s %u %u %u %u %u\n",
+ fCompact? "2" : "",
+ Gia_ManCiNum(p) + Gia_ManAndNum(p),
+ Gia_ManPiNum(p),
+ Gia_ManRegNum(p),
+ Gia_ManPoNum(p),
+ Gia_ManAndNum(p) );
+
+ if ( !fCompact )
+ {
+ // write latch drivers
+ Gia_ManForEachRi( p, pObj, i )
+ fprintf( pFile, "%u\n", Gia_ObjFaninLit0p(p, pObj) );
+ // write PO drivers
+ Gia_ManForEachPo( p, pObj, i )
+ fprintf( pFile, "%u\n", Gia_ObjFaninLit0p(p, pObj) );
+ }
+ else
+ {
+ Vec_Int_t * vLits = Gia_WriteAigerLiterals( p );
+ Vec_Str_t * vBinary = Gia_WriteEncodeLiterals( vLits );
+ fwrite( Vec_StrArray(vBinary), 1, Vec_StrSize(vBinary), pFile );
+ Vec_StrFree( vBinary );
+ Vec_IntFree( vLits );
+ }
+
+ // write the nodes into the buffer
+ Pos = 0;
+ nBufferSize = 6 * Gia_ManAndNum(p) + 100; // skeptically assuming 3 chars per one AIG edge
+ pBuffer = ABC_ALLOC( unsigned char, nBufferSize );
+ Gia_ManForEachAnd( p, pObj, i )
+ {
+ uLit = Gia_Var2Lit( i, 0 );
+ uLit0 = Gia_ObjFaninLit0( pObj, i );
+ uLit1 = Gia_ObjFaninLit1( pObj, i );
+ assert( uLit0 < uLit1 );
+ Pos = Gia_WriteAigerEncode( pBuffer, Pos, uLit - uLit1 );
+ Pos = Gia_WriteAigerEncode( pBuffer, Pos, uLit1 - uLit0 );
+ if ( Pos > nBufferSize - 10 )
+ {
+ printf( "Gia_WriteAiger(): AIGER generation has failed because the allocated buffer is too small.\n" );
+ fclose( pFile );
+ if ( p != pInit )
+ Gia_ManStop( p );
+ return;
+ }
+ }
+ assert( Pos < nBufferSize );
+
+ // write the buffer
+ fwrite( pBuffer, 1, Pos, pFile );
+ ABC_FREE( pBuffer );
+
+ // write the comment
+ fprintf( pFile, "c" );
+ // write signature
+ Gia_WriteBlockHeader( pFile, '\n', 0xAC1D0FF1CEC0FFEE );
+ // write name
+ if ( p->pName )
+ {
+ Gia_WriteBlockHeader( pFile, 'N', (word)strlen(pInit->pName) );
+ fwrite( pInit->pName, 1, strlen(pInit->pName), pFile );
+ }
+ // write equivalences
+ if ( p->pReprs && p->pNexts )
+ {
+ int nEquivSize;
+ unsigned char * pEquivs = Gia_WriteEquivClasses( p, &nEquivSize );
+ Gia_WriteBlockHeader( pFile, '=', (word)nEquivSize );
+ fwrite( pEquivs, 1, nEquivSize, pFile );
+ ABC_FREE( pEquivs );
+ }
+/*
+ // write flop classes
+ if ( p->vFlopClasses )
+ {
+ Gia_WriteBlockHeader( pFile, 'f', 4*Gia_ManRegNum(p) );
+ fwrite( Vec_IntArray(p->vFlopClasses), 1, 4*Gia_ManRegNum(p), pFile );
+ }
+ // write mapping
+ if ( p->pMapping )
+ {
+ int nMapSize;
+ unsigned char * pMaps = Gia_WriteMapping( p, &nMapSize );
+ Gia_WriteBlockHeader( pFile, 'm', (word)nMapSize );
+ fwrite( pMaps, 1, nMapSize, pFile );
+ ABC_FREE( pMaps );
+ }
+ // write placement
+ if ( p->pPlacement )
+ {
+ Gia_WriteBlockHeader( pFile, 'p', (word)4*Gia_ManObjNum(p) );
+ fwrite( p->pPlacement, 1, 4*Gia_ManObjNum(p), pFile );
+ }
+ // write switching activity
+ if ( p->pSwitching )
+ {
+ Gia_WriteBlockHeader( pFile, 's', (word)Gia_ManObjNum(p) );
+ fwrite( p->pSwitching, 1, Gia_ManObjNum(p), pFile );
+ }
+ // write name
+ if ( p->pName )
+ fprintf( pFile, "n%s%c", p->pName, '\0' );
+*/
+ // write constraints
+ if ( p->nConstrs )
+ {
+ Gia_WriteBlockHeader( pFile, 'c', (word)p->nConstrs );
+ Gia_WriteIntF( pFile, p->nConstrs );
+ }
+ // write the closing statement
+ Gia_WriteBlockHeader( pFile, '\0', (word)0 );
+ // write comment
+ fprintf( pFile, "\nThis file was produced by the GIA package in ABC on %s\n", Gia_TimeStamp() );
+ fprintf( pFile, "For information about AIGER format, refer to %s\n", "http://fmv.jku.at/aiger" );
+ fclose( pFile );
+ if ( p != pInit )
+ Gia_ManStop( p );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Writes the AIG in the binary AIGER format.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_DumpAiger( Gia_Man_t * p, char * pFilePrefix, int iFileNum, int nFileNumDigits )
+{
+ char Buffer[100];
+ sprintf( Buffer, "%s%0*d.aig", pFilePrefix, nFileNumDigits, iFileNum );
+ Gia_WriteAiger( p, Buffer, 0, 0 );
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaAiger_old.c b/src/aig/gia/giaAiger_old.c
new file mode 100644
index 00000000..9a5ba5cd
--- /dev/null
+++ b/src/aig/gia/giaAiger_old.c
@@ -0,0 +1,1255 @@
+/**CFile****************************************************************
+
+ FileName [giaAiger.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Scalable AIG package.]
+
+ Synopsis [Procedures to read/write binary AIGER format developed by
+ Armin Biere, Johannes Kepler University (http://fmv.jku.at/)]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: giaAiger.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+typedef ABC_UINT64_T word;
+
+static inline int Gia_ObjObjPhaseDiff( Gia_Man_t * p, int i, int j ) { return Gia_ManObj(p, i)->fPhase ^ Gia_ManObj(p, j)->fPhase; }
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Extracts one unsigned AIG edge from the input buffer.]
+
+ Description [This procedure is a slightly modified version of Armin Biere's
+ procedure "unsigned decode (FILE * file)". ]
+
+ SideEffects [Updates the current reading position.]
+
+ SeeAlso []
+
+***********************************************************************/
+unsigned Gia_ReadAigerDecode( char ** ppPos )
+{
+ unsigned x = 0, i = 0;
+ unsigned char ch;
+ while ((ch = *(*ppPos)++) & 0x80)
+ x |= (ch & 0x7f) << (7 * i++);
+ return x | (ch << (7 * i));
+}
+
+/**Function*************************************************************
+
+ Synopsis [Extracts one signed AIG edge from the input buffer.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ReadAigerDecodeInt( char ** ppPos )
+{
+ unsigned Res;
+ Res = Gia_ReadAigerDecode( ppPos );
+ if ( Res & 1 )
+ return -((int)(Res >> 1));
+ return Res >> 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Decodes the encoded array of literals.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Gia_WriteDecodeLiterals( char ** ppPos, int nEntries )
+{
+ Vec_Int_t * vLits;
+ int Lit, LitPrev, Diff, i;
+ vLits = Vec_IntAlloc( nEntries );
+ LitPrev = Gia_ReadAigerDecode( ppPos );
+ Vec_IntPush( vLits, LitPrev );
+ for ( i = 1; i < nEntries; i++ )
+ {
+// Diff = Lit - LitPrev;
+// Diff = (Lit < LitPrev)? -Diff : Diff;
+// Diff = ((2 * Diff) << 1) | (int)(Lit < LitPrev);
+ Diff = Gia_ReadAigerDecode( ppPos );
+ Diff = (Diff & 1)? -(Diff >> 1) : Diff >> 1;
+ Lit = Diff + LitPrev;
+ Vec_IntPush( vLits, Lit );
+ LitPrev = Lit;
+ }
+ return vLits;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Returns the file size.]
+
+ Description [The file should be closed.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_FixFileName( char * pFileName )
+{
+ char * pName;
+ for ( pName = pFileName; *pName; pName++ )
+ if ( *pName == '>' )
+ *pName = '\\';
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the file size.]
+
+ Description [The file should be closed.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_FileSize( char * pFileName )
+{
+ FILE * pFile;
+ int nFileSize;
+ pFile = fopen( pFileName, "r" );
+ if ( pFile == NULL )
+ {
+ printf( "Gia_FileSize(): The file is unavailable (absent or open).\n" );
+ return 0;
+ }
+ fseek( pFile, 0, SEEK_END );
+ nFileSize = ftell( pFile );
+ fclose( pFile );
+ return nFileSize;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+char * Gia_FileNameGeneric( char * FileName )
+{
+ char * pDot, * pRes;
+ pRes = Gia_UtilStrsav( FileName );
+ if ( (pDot = strrchr( pRes, '.' )) )
+ *pDot = 0;
+ return pRes;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Write integer into the string.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ReadInt( unsigned char * pPos )
+{
+ int i, Value = 0;
+ for ( i = 0; i < 4; i++ )
+ Value |= ((unsigned)(*pPos++)) << (i << 3);
+ return Value;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Reads decoded value.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+unsigned Gia_ReadDiffValue( char ** ppPos, int iPrev )
+{
+ int Item = Gia_ReadAigerDecode( ppPos );
+ if ( Item & 1 )
+ return iPrev + (Item >> 1);
+ return iPrev - (Item >> 1);
+}
+
+/**Function*************************************************************
+
+ Synopsis [Read equivalence classes from the string.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Rpr_t * Gia_ReadEquivClasses_old( unsigned char ** ppPos, int nSize )
+{
+ Gia_Rpr_t * pReprs;
+ unsigned char * pStop;
+ int i, Item, fProved, iRepr, iNode;
+ pStop = *ppPos;
+ pStop += Gia_ReadInt( *ppPos ); *ppPos += 4;
+ pReprs = ABC_CALLOC( Gia_Rpr_t, nSize );
+ for ( i = 0; i < nSize; i++ )
+ pReprs[i].iRepr = GIA_VOID;
+ iRepr = iNode = 0;
+ while ( *ppPos < pStop )
+ {
+ Item = Gia_ReadAigerDecode( ppPos );
+ if ( Item & 1 )
+ {
+ iRepr += (Item >> 1);
+ iNode = iRepr;
+//printf( "\nRepr = %d ", iRepr );
+ continue;
+ }
+ Item >>= 1;
+ fProved = (Item & 1);
+ Item >>= 1;
+ iNode += Item;
+ pReprs[iNode].fProved = fProved;
+ pReprs[iNode].iRepr = iRepr;
+ assert( iRepr < iNode );
+//printf( "Node = %d ", iNode );
+ }
+ return pReprs;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Read equivalence classes from the string.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Rpr_t * Gia_ReadEquivClasses( unsigned char ** ppPos, int nSize, int nAlloc )
+{
+ Gia_Rpr_t * pReprs;
+ unsigned char * pStop;
+ int i, k, iRepr, iNode, nMembers;
+ // find place to stop
+ pStop = *ppPos + nSize;
+ // prepare equivalence classes
+ pReprs = ABC_CALLOC( Gia_Rpr_t, nAlloc );
+ for ( i = 0; i < nAlloc; i++ )
+ pReprs[i].iRepr = GIA_VOID;
+ // skip the number of classes
+ Gia_ReadAigerDecode( ppPos );
+ // read classes
+ iRepr = iNode = 0;
+ while ( *ppPos < pStop )
+ {
+ nMembers = Gia_ReadAigerDecode( ppPos );
+ iRepr += Gia_ReadAigerDecode( ppPos ) >> 1;
+ iNode = iRepr;
+ for ( k = 1; k < nMembers; k++ )
+ {
+ iNode += Gia_ReadAigerDecode( ppPos ) >> 1;
+ pReprs[ iNode ].iRepr = iRepr;
+ assert( iRepr < iNode );
+//if ( !iRepr )
+//printf( "%4d: Reading equiv %d -> %d\n", k, iNode, iRepr );
+ }
+ }
+ return pReprs;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Read flop classes from the string.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ReadFlopClasses( unsigned char ** ppPos, Vec_Int_t * vClasses, int nSize )
+{
+ int nAlloc = Gia_ReadInt( *ppPos ); *ppPos += 4;
+ assert( nAlloc/4 == nSize );
+ assert( Vec_IntSize(vClasses) == nSize );
+ memcpy( Vec_IntArray(vClasses), *ppPos, 4*nSize );
+ *ppPos += 4 * nSize;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Read equivalence classes from the string.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int * Gia_ReadMapping( unsigned char ** ppPos, int nSize )
+{
+ int * pMapping;
+ unsigned char * pStop;
+ int k, j, nFanins, nAlloc, iNode = 0, iOffset = nSize;
+ pStop = *ppPos;
+ pStop += Gia_ReadInt( *ppPos ); *ppPos += 4;
+ nAlloc = nSize + pStop - *ppPos;
+ pMapping = ABC_CALLOC( int, nAlloc );
+ while ( *ppPos < pStop )
+ {
+ k = iOffset;
+ pMapping[k++] = nFanins = Gia_ReadAigerDecode( ppPos );
+ for ( j = 0; j <= nFanins; j++ )
+ pMapping[k++] = iNode = Gia_ReadDiffValue( ppPos, iNode );
+ pMapping[iNode] = iOffset;
+ iOffset = k;
+ }
+ assert( iOffset <= nAlloc );
+ return pMapping;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Read switching from the string.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+unsigned char * Gia_ReadSwitching( unsigned char ** ppPos, int nSize )
+{
+ unsigned char * pSwitching;
+ int nAlloc = Gia_ReadInt( *ppPos ); *ppPos += 4;
+ assert( nAlloc == nSize );
+ pSwitching = ABC_ALLOC( unsigned char, nSize );
+ memcpy( pSwitching, *ppPos, nSize );
+ *ppPos += nSize;
+ return pSwitching;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Read placement from the string.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Plc_t * Gia_ReadPlacement( unsigned char ** ppPos, int nSize )
+{
+ Gia_Plc_t * pPlacement;
+ int nAlloc = Gia_ReadInt( *ppPos ); *ppPos += 4;
+ assert( nAlloc/4 == nSize );
+ pPlacement = ABC_ALLOC( Gia_Plc_t, nSize );
+ memcpy( pPlacement, *ppPos, 4*nSize );
+ *ppPos += 4 * nSize;
+ return pPlacement;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Reads char and 64-bit int using little-endian style.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+char Gia_ReadBlockHeader( char ** ppCur, word * pWord )
+{
+ int i;
+ char Char = *(*ppCur)++;
+ *pWord = 0;
+ for ( i = 0; i < 8; i++ )
+ {
+// printf( "%d\n", (unsigned char)(*(*ppCur)) );
+ *pWord |= ((word)(unsigned char)(*(*ppCur)++)) << (i<<3);
+ }
+ return Char;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Reads the AIG in the binary AIGER format.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ReadAiger( char * pFileName, int fCheck )
+{
+ FILE * pFile;
+ Gia_Man_t * pNew;
+ Vec_Int_t * vLits = NULL;
+ Vec_Int_t * vNodes, * vDrivers;//, * vTerms;
+ int iObj, iNode0, iNode1;
+ int nTotal, nInputs, nOutputs, nLatches, nAnds, nFileSize, i;//, iTerm, nDigits;
+ char * pContents, * pDrivers, * pSymbols, * pCur, * pName;//, * pType;
+ unsigned uLit0, uLit1, uLit;
+
+ // read the file into the buffer
+ Gia_FixFileName( pFileName );
+ nFileSize = Gia_FileSize( pFileName );
+ pFile = fopen( pFileName, "rb" );
+ pContents = ABC_ALLOC( char, nFileSize );
+ fread( pContents, nFileSize, 1, pFile );
+ fclose( pFile );
+
+ // check if the input file format is correct
+ if ( strncmp(pContents, "aig", 3) != 0 || (pContents[3] != ' ' && pContents[3] != '2') )
+ {
+ fprintf( stdout, "Wrong input file format.\n" );
+ free( pContents );
+ return NULL;
+ }
+
+ // read the file type
+ pCur = pContents; while ( *pCur++ != ' ' );
+ // read the number of objects
+ nTotal = atoi( pCur ); while ( *pCur++ != ' ' );
+ // read the number of inputs
+ nInputs = atoi( pCur ); while ( *pCur++ != ' ' );
+ // read the number of latches
+ nLatches = atoi( pCur ); while ( *pCur++ != ' ' );
+ // read the number of outputs
+ nOutputs = atoi( pCur ); while ( *pCur++ != ' ' );
+ // read the number of nodes
+ nAnds = atoi( pCur ); while ( *pCur++ != '\n' );
+ // check the parameters
+ if ( nTotal != nInputs + nLatches + nAnds )
+ {
+ fprintf( stdout, "The paramters are wrong.\n" );
+ return NULL;
+ }
+
+ // allocate the empty AIG
+ pNew = Gia_ManStart( nTotal + nLatches + nOutputs + 1 );
+ pName = Gia_FileNameGeneric( pFileName );
+ pNew->pName = Gia_UtilStrsav( pName );
+// pNew->pSpec = Gia_UtilStrsav( pFileName );
+ ABC_FREE( pName );
+
+ // prepare the array of nodes
+ vNodes = Vec_IntAlloc( 1 + nTotal );
+ Vec_IntPush( vNodes, 0 );
+
+ // create the PIs
+ for ( i = 0; i < nInputs + nLatches; i++ )
+ {
+ iObj = Gia_ManAppendCi(pNew);
+ Vec_IntPush( vNodes, iObj );
+ }
+
+ // remember the beginning of latch/PO literals
+ pDrivers = pCur;
+ if ( pContents[3] == ' ' ) // standard AIGER
+ {
+ // scroll to the beginning of the binary data
+ for ( i = 0; i < nLatches + nOutputs; )
+ if ( *pCur++ == '\n' )
+ i++;
+ }
+ else // modified AIGER
+ {
+ vLits = Gia_WriteDecodeLiterals( &pCur, nLatches + nOutputs );
+ }
+
+ // create the AND gates
+ for ( i = 0; i < nAnds; i++ )
+ {
+ uLit = ((i + 1 + nInputs + nLatches) << 1);
+ uLit1 = uLit - Gia_ReadAigerDecode( &pCur );
+ uLit0 = uLit1 - Gia_ReadAigerDecode( &pCur );
+// assert( uLit1 > uLit0 );
+ iNode0 = Gia_LitNotCond( Vec_IntEntry(vNodes, uLit0 >> 1), uLit0 & 1 );
+ iNode1 = Gia_LitNotCond( Vec_IntEntry(vNodes, uLit1 >> 1), uLit1 & 1 );
+ assert( Vec_IntSize(vNodes) == i + 1 + nInputs + nLatches );
+// Vec_IntPush( vNodes, Gia_And(pNew, iNode0, iNode1) );
+ Vec_IntPush( vNodes, Gia_ManAppendAnd(pNew, iNode0, iNode1) );
+ }
+
+ // remember the place where symbols begin
+ pSymbols = pCur;
+
+ // read the latch driver literals
+ vDrivers = Vec_IntAlloc( nLatches + nOutputs );
+ if ( pContents[3] == ' ' ) // standard AIGER
+ {
+ pCur = pDrivers;
+ for ( i = 0; i < nLatches; i++ )
+ {
+ uLit0 = atoi( pCur ); while ( *pCur++ != '\n' );
+ iNode0 = Gia_LitNotCond( Vec_IntEntry(vNodes, uLit0 >> 1), (uLit0 & 1) );
+ Vec_IntPush( vDrivers, iNode0 );
+ }
+ // read the PO driver literals
+ for ( i = 0; i < nOutputs; i++ )
+ {
+ uLit0 = atoi( pCur ); while ( *pCur++ != '\n' );
+ iNode0 = Gia_LitNotCond( Vec_IntEntry(vNodes, uLit0 >> 1), (uLit0 & 1) );
+ Vec_IntPush( vDrivers, iNode0 );
+ }
+
+ }
+ else
+ {
+ // read the latch driver literals
+ for ( i = 0; i < nLatches; i++ )
+ {
+ uLit0 = Vec_IntEntry( vLits, i );
+ iNode0 = Gia_LitNotCond( Vec_IntEntry(vNodes, uLit0 >> 1), (uLit0 & 1) );
+ Vec_IntPush( vDrivers, iNode0 );
+ }
+ // read the PO driver literals
+ for ( i = 0; i < nOutputs; i++ )
+ {
+ uLit0 = Vec_IntEntry( vLits, i+nLatches );
+ iNode0 = Gia_LitNotCond( Vec_IntEntry(vNodes, uLit0 >> 1), (uLit0 & 1) );
+ Vec_IntPush( vDrivers, iNode0 );
+ }
+ Vec_IntFree( vLits );
+ }
+
+ // create the POs
+ for ( i = 0; i < nOutputs; i++ )
+ Gia_ManAppendCo( pNew, Vec_IntEntry(vDrivers, nLatches + i) );
+ for ( i = 0; i < nLatches; i++ )
+ Gia_ManAppendCo( pNew, Vec_IntEntry(vDrivers, i) );
+ Vec_IntFree( vDrivers );
+
+ // create the latches
+ Gia_ManSetRegNum( pNew, nLatches );
+
+ // check if there are other types of information to read
+ pCur = pSymbols;
+ if ( pCur + 1 < pContents + nFileSize && *pCur == 'c' )
+ {
+ char Char;
+ word Size;
+ pCur++;
+
+ // read model name (old style)
+ if ( *pCur == 'n' )
+ {
+ pCur++;
+ ABC_FREE( pNew->pName );
+ pNew->pName = Gia_UtilStrsav( pCur );
+ pCur += (int)(strlen(pNew->pName) + 1);
+ }
+
+ Char = Gia_ReadBlockHeader( &pCur, &Size );
+ if ( Char == '\n' && Size == 0xAC1D0FF1CEC0FFEE )
+ {
+ while ( (Char = Gia_ReadBlockHeader(&pCur, &Size)) )
+ {
+ switch (Char)
+ {
+ case 'N':
+ // read model name
+ ABC_FREE( pNew->pName );
+ pNew->pName = ABC_ALLOC( char, (int)Size + 1 );
+ strncpy( pNew->pName, pCur, (int)Size );
+ pNew->pName[(int)Size] = '\0';
+ pCur += (int)Size;
+ break;
+ case 'n':
+ // read model name
+ ABC_FREE( pNew->pName );
+ pNew->pName = Gia_UtilStrsav( pCur );
+ pCur += (int)(strlen(pNew->pName) + 1);
+ break;
+ case '=':
+ // read equivalence classes
+ pNew->pReprs = Gia_ReadEquivClasses( &pCur, (int)Size, Gia_ManObjNum(pNew) );
+ pNew->pNexts = Gia_ManDeriveNexts( pNew );
+ break;
+ case 'c':
+ // read number of constraints
+ pNew->nConstrs = Gia_ReadInt( pCur ); pCur += 4;
+ break;
+ default:
+ printf( "Unrecognized data.\n" );
+ break;
+ }
+ }
+ }
+ else
+ {
+ printf( "Extended AIGER reader: Internal signature does not match.\n" );
+ }
+
+/*
+ if ( *pCur == 'e' )
+ {
+ pCur++;
+ // read equivalence classes
+ pNew->pReprs = Gia_ReadEquivClasses( &pCur, Gia_ManObjNum(pNew) );
+ pNew->pNexts = Gia_ManDeriveNexts( pNew );
+ }
+ if ( *pCur == 'f' )
+ {
+ pCur++;
+ // read flop classes
+ pNew->vFlopClasses = Vec_IntStart( Gia_ManRegNum(pNew) );
+ Gia_ReadFlopClasses( &pCur, pNew->vFlopClasses, Gia_ManRegNum(pNew) );
+ }
+ if ( *pCur == 'm' )
+ {
+ pCur++;
+ // read mapping
+ pNew->pMapping = Gia_ReadMapping( &pCur, Gia_ManObjNum(pNew) );
+ }
+ if ( *pCur == 'p' )
+ {
+ pCur++;
+ // read placement
+ pNew->pPlacement = Gia_ReadPlacement( &pCur, Gia_ManObjNum(pNew) );
+ }
+ if ( *pCur == 's' )
+ {
+ pCur++;
+ // read switching activity
+ pNew->pSwitching = Gia_ReadSwitching( &pCur, Gia_ManObjNum(pNew) );
+ }
+ if ( *pCur == 'c' )
+ {
+ pCur++;
+ // read number of constraints
+ pNew->nConstrs = Gia_ReadInt( pCur ); pCur += 4;
+ }
+ if ( *pCur == 'n' )
+ {
+ pCur++;
+ // read model name
+ ABC_FREE( pNew->pName );
+ pNew->pName = Gia_UtilStrsav( pCur );
+ }
+*/
+ }
+
+ // skipping the comments
+ ABC_FREE( pContents );
+ Vec_IntFree( vNodes );
+/*
+ // check the result
+ if ( fCheck && !Gia_ManCheck( pNew ) )
+ {
+ printf( "Gia_ReadAiger: The network check has failed.\n" );
+ Gia_ManStop( pNew );
+ return NULL;
+ }
+*/
+ return pNew;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Adds one unsigned AIG edge to the output buffer.]
+
+ Description [This procedure is a slightly modified version of Armin Biere's
+ procedure "void encode (FILE * file, unsigned x)" ]
+
+ SideEffects [Returns the current writing position.]
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_WriteAigerEncode( unsigned char * pBuffer, int Pos, unsigned x )
+{
+ unsigned char ch;
+ while (x & ~0x7f)
+ {
+ ch = (x & 0x7f) | 0x80;
+ pBuffer[Pos++] = ch;
+ x >>= 7;
+ }
+ ch = x;
+ pBuffer[Pos++] = ch;
+ return Pos;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Adds one signed int to the output buffer.]
+
+ Description []
+
+ SideEffects [Returns the current writing position.]
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_WriteAigerEncodeInt( unsigned char * pBuffer, int Pos, int x )
+{
+ if ( x >= 0 )
+ return Gia_WriteAigerEncode( pBuffer, Pos, ((unsigned)(x) << 1) );
+ return Gia_WriteAigerEncode( pBuffer, Pos, ((unsigned)(-x) << 1) | 1 );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Create the array of literals to be written.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Gia_WriteAigerLiterals( Gia_Man_t * p )
+{
+ Vec_Int_t * vLits;
+ Gia_Obj_t * pObj;
+ int i;
+ vLits = Vec_IntAlloc( Gia_ManPoNum(p) );
+ Gia_ManForEachRi( p, pObj, i )
+ Vec_IntPush( vLits, Gia_ObjFaninLit0p(p, pObj) );
+ Gia_ManForEachPo( p, pObj, i )
+ Vec_IntPush( vLits, Gia_ObjFaninLit0p(p, pObj) );
+ return vLits;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates the binary encoded array of literals.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Str_t * Gia_WriteEncodeLiterals( Vec_Int_t * vLits )
+{
+ Vec_Str_t * vBinary;
+ int Pos = 0, Lit, LitPrev, Diff, i;
+ vBinary = Vec_StrAlloc( 2 * Vec_IntSize(vLits) );
+ LitPrev = Vec_IntEntry( vLits, 0 );
+ Pos = Gia_WriteAigerEncode( (unsigned char *)Vec_StrArray(vBinary), Pos, LitPrev );
+ Vec_IntForEachEntryStart( vLits, Lit, i, 1 )
+ {
+ Diff = Lit - LitPrev;
+ Diff = (Lit < LitPrev)? -Diff : Diff;
+ Diff = (Diff << 1) | (int)(Lit < LitPrev);
+ Pos = Gia_WriteAigerEncode( (unsigned char *)Vec_StrArray(vBinary), Pos, Diff );
+ LitPrev = Lit;
+ if ( Pos + 10 > vBinary->nCap )
+ Vec_StrGrow( vBinary, vBinary->nCap+1 );
+ }
+ vBinary->nSize = Pos;
+/*
+ // verify
+ {
+ extern Vec_Int_t * Gia_WriteDecodeLiterals( char ** ppPos, int nEntries );
+ char * pPos = Vec_StrArray( vBinary );
+ Vec_Int_t * vTemp = Gia_WriteDecodeLiterals( &pPos, Vec_IntSize(vLits) );
+ for ( i = 0; i < Vec_IntSize(vLits); i++ )
+ {
+ int Entry1 = Vec_IntEntry(vLits,i);
+ int Entry2 = Vec_IntEntry(vTemp,i);
+ assert( Entry1 == Entry2 );
+ }
+ Vec_IntFree( vTemp );
+ }
+*/
+ return vBinary;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Write integer into the string.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_WriteInt( char * pBuffer, int Value )
+{
+ int i;
+ for ( i = 0; i < 4; i++ )
+ pBuffer[i] = (char)(0xff & (Value >> (i<<3)));
+}
+
+/**Function*************************************************************
+
+ Synopsis [Read equivalence classes from the string.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+unsigned char * Gia_WriteEquivClasses_old( Gia_Man_t * p, int * pEquivSize )
+{
+ unsigned char * pBuffer;
+ int iRepr, iNode, iPrevRepr, iPrevNode, iLit, nItems, iPos;
+ assert( p->pReprs && p->pNexts );
+ // count the number of entries to be written
+ nItems = 0;
+ for ( iRepr = 1; iRepr < Gia_ManObjNum(p); iRepr++ )
+ {
+ nItems += Gia_ObjIsConst( p, iRepr );
+ if ( !Gia_ObjIsHead(p, iRepr) )
+ continue;
+ Gia_ClassForEachObj( p, iRepr, iNode )
+ nItems++;
+ }
+ pBuffer = ABC_ALLOC( char, sizeof(int) * (nItems + 1) );
+ // write constant class
+ iPos = Gia_WriteAigerEncode( pBuffer, 4, Gia_Var2Lit(0, 1) );
+ iPrevNode = 0;
+ for ( iNode = 1; iNode < Gia_ManObjNum(p); iNode++ )
+ if ( Gia_ObjIsConst(p, iNode) )
+ {
+ iLit = Gia_Var2Lit( iNode - iPrevNode, Gia_ObjProved(p, iNode) );
+ iPrevNode = iNode;
+ iPos = Gia_WriteAigerEncode( pBuffer, iPos, Gia_Var2Lit(iLit, 0) );
+ }
+ // write non-constant classes
+ iPrevRepr = 0;
+ Gia_ManForEachClass( p, iRepr )
+ {
+ iPos = Gia_WriteAigerEncode( pBuffer, iPos, Gia_Var2Lit(iRepr - iPrevRepr, 1) );
+ iPrevRepr = iPrevNode = iRepr;
+ Gia_ClassForEachObj1( p, iRepr, iNode )
+ {
+ iLit = Gia_Var2Lit( iNode - iPrevNode, Gia_ObjProved(p, iNode) );
+ iPrevNode = iNode;
+ iPos = Gia_WriteAigerEncode( pBuffer, iPos, Gia_Var2Lit(iLit, 0) );
+ }
+ }
+ Gia_WriteInt( pBuffer, iPos );
+ *pEquivSize = iPos;
+ return pBuffer;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Read equivalence classes from the string.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+unsigned char * Gia_WriteEquivClasses( Gia_Man_t * p, int * pEquivSize )
+{
+ unsigned char * pBuffer;
+ int k, iRepr, iNode, iPrevRepr, iPrevNode, iLit;
+ int nItems, iPos, nClasses, nMembers;
+ assert( p->pReprs && p->pNexts );
+ Gia_ManSetPhase(p);
+ // count the number of entries to be written
+ nItems = 0;
+ nMembers = 0;
+ nClasses = 0;
+ for ( iRepr = 1; iRepr < Gia_ManObjNum(p); iRepr++ )
+ {
+ nItems += Gia_ObjIsConst( p, iRepr );
+ nMembers += Gia_ObjIsConst( p, iRepr );
+ if ( !Gia_ObjIsHead(p, iRepr) )
+ continue;
+ nClasses++;
+ Gia_ClassForEachObj( p, iRepr, iNode )
+ nItems++;
+ }
+ nClasses += (nMembers > 0);
+ // allocate place for data
+ pBuffer = (unsigned char *)ABC_ALLOC( int, nItems+1 );
+ // write the number of classes
+ iPos = Gia_WriteAigerEncode( pBuffer, 0, nClasses );
+ // write constant class
+ if ( nMembers )
+ {
+ iPos = Gia_WriteAigerEncode( pBuffer, iPos, nMembers+1 );
+ iPos = Gia_WriteAigerEncode( pBuffer, iPos, Gia_Var2Lit(0,0) );
+ iPrevNode = 0;
+ k = 1;
+ for ( iNode = 1; iNode < Gia_ManObjNum(p); iNode++ )
+ if ( Gia_ObjIsConst(p, iNode) )
+ {
+ iLit = Gia_Var2Lit( iNode - iPrevNode, Gia_ObjObjPhaseDiff(p, iNode, 0) );
+ iPos = Gia_WriteAigerEncode( pBuffer, iPos, iLit );
+ iPrevNode = iNode;
+//printf( "%4d : Writing equiv %d -> %d\n", k++, iNode, 0 );
+ }
+ }
+ // write non-constant classes
+ iPrevRepr = 0;
+ Gia_ManForEachClass( p, iRepr )
+ {
+ // write number of members
+ nMembers = 0;
+ Gia_ClassForEachObj( p, iRepr, iNode )
+ nMembers++;
+ iPos = Gia_WriteAigerEncode( pBuffer, iPos, nMembers );
+ // write representatives
+ iPos = Gia_WriteAigerEncode( pBuffer, iPos, Gia_Var2Lit(iRepr - iPrevRepr, 0) );
+ // write members
+ iPrevRepr = iPrevNode = iRepr;
+ Gia_ClassForEachObj1( p, iRepr, iNode )
+ {
+ iLit = Gia_Var2Lit( iNode - iPrevNode, Gia_ObjObjPhaseDiff(p, iNode, iRepr) );
+ iPos = Gia_WriteAigerEncode( pBuffer, iPos, iLit );
+ iPrevNode = iNode;
+//printf( "Writing equiv %d -> %d\n", iNode, iRepr );
+ }
+ }
+ *pEquivSize = iPos;
+ return pBuffer;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Reads decoded value.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_WriteDiffValue( char * pPos, int iPos, int iPrev, int iThis )
+{
+ if ( iPrev < iThis )
+ return Gia_WriteAigerEncode( pPos, iPos, Gia_Var2Lit(iThis - iPrev, 1) );
+ return Gia_WriteAigerEncode( pPos, iPos, Gia_Var2Lit(iPrev - iThis, 0) );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Read equivalence classes from the string.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+unsigned char * Gia_WriteMapping( Gia_Man_t * p, int * pMapSize )
+{
+ unsigned char * pBuffer;
+ int i, k, iPrev, iFan, nItems, iPos = 4;
+ assert( p->pMapping );
+ // count the number of entries to be written
+ nItems = 0;
+ Gia_ManForEachLut( p, i )
+ nItems += 2 + Gia_ObjLutSize( p, i );
+ pBuffer = ABC_ALLOC( char, sizeof(int) * (nItems + 1) );
+ // write non-constant classes
+ iPrev = 0;
+ Gia_ManForEachLut( p, i )
+ {
+//printf( "\nSize = %d ", Gia_ObjLutSize(p, i) );
+ iPos = Gia_WriteAigerEncode( pBuffer, iPos, Gia_ObjLutSize(p, i) );
+ Gia_LutForEachFanin( p, i, iFan, k )
+ {
+//printf( "Fan = %d ", iFan );
+ iPos = Gia_WriteDiffValue( pBuffer, iPos, iPrev, iFan );
+ iPrev = iFan;
+ }
+ iPos = Gia_WriteDiffValue( pBuffer, iPos, iPrev, i );
+ iPrev = i;
+//printf( "Node = %d ", i );
+ }
+//printf( "\n" );
+ Gia_WriteInt( pBuffer, iPos );
+ *pMapSize = iPos;
+ return pBuffer;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Writes char and 64-bit int using little-endian style.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_WriteBlockHeader( FILE * pFile, char Char, word Word )
+{
+ int i;
+ fprintf( pFile, "%c", Char );
+ for ( i = 0; i < 8; i++ )
+ fprintf( pFile, "%c", (unsigned char)(0xff & (Word >> (i<<3))) );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Write integer into the string.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_WriteIntF( FILE * pFile, int Value )
+{
+ int i;
+ for ( i = 0; i < 4; i++ )
+ fprintf( pFile, "%c", (char)(0xff & (Value >> (i<<3))) );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Writes the AIG in the binary AIGER format.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_WriteAiger( Gia_Man_t * pInit, char * pFileName, int fWriteSymbols, int fCompact )
+{
+ FILE * pFile;
+ Gia_Man_t * p;
+ Gia_Obj_t * pObj;
+ int i, nBufferSize, Pos;
+ unsigned char * pBuffer;
+ unsigned uLit0, uLit1, uLit;
+
+ if ( Gia_ManCoNum(pInit) == 0 )
+ {
+ printf( "AIG cannot be written because it has no POs.\n" );
+ return;
+ }
+
+ // start the output stream
+ pFile = fopen( pFileName, "wb" );
+ if ( pFile == NULL )
+ {
+ fprintf( stdout, "Gia_WriteAiger(): Cannot open the output file \"%s\".\n", pFileName );
+ return;
+ }
+
+ // create normalized AIG
+ if ( !Gia_ManIsNormalized(pInit) )
+ {
+// printf( "Gia_WriteAiger(): Normalizing AIG for writing.\n" );
+ p = Gia_ManDupNormalized( pInit );
+ }
+ else
+ p = pInit;
+
+ // write the header "M I L O A" where M = I + L + A
+ fprintf( pFile, "aig%s %u %u %u %u %u\n",
+ fCompact? "2" : "",
+ Gia_ManCiNum(p) + Gia_ManAndNum(p),
+ Gia_ManPiNum(p),
+ Gia_ManRegNum(p),
+ Gia_ManPoNum(p),
+ Gia_ManAndNum(p) );
+
+ if ( !fCompact )
+ {
+ // write latch drivers
+ Gia_ManForEachRi( p, pObj, i )
+ fprintf( pFile, "%u\n", Gia_ObjFaninLit0p(p, pObj) );
+ // write PO drivers
+ Gia_ManForEachPo( p, pObj, i )
+ fprintf( pFile, "%u\n", Gia_ObjFaninLit0p(p, pObj) );
+ }
+ else
+ {
+ Vec_Int_t * vLits = Gia_WriteAigerLiterals( p );
+ Vec_Str_t * vBinary = Gia_WriteEncodeLiterals( vLits );
+ fwrite( Vec_StrArray(vBinary), 1, Vec_StrSize(vBinary), pFile );
+ Vec_StrFree( vBinary );
+ Vec_IntFree( vLits );
+ }
+
+ // write the nodes into the buffer
+ Pos = 0;
+ nBufferSize = 6 * Gia_ManAndNum(p) + 100; // skeptically assuming 3 chars per one AIG edge
+ pBuffer = ABC_ALLOC( unsigned char, nBufferSize );
+ Gia_ManForEachAnd( p, pObj, i )
+ {
+ uLit = Gia_Var2Lit( i, 0 );
+ uLit0 = Gia_ObjFaninLit0( pObj, i );
+ uLit1 = Gia_ObjFaninLit1( pObj, i );
+ assert( uLit0 < uLit1 );
+ Pos = Gia_WriteAigerEncode( pBuffer, Pos, uLit - uLit1 );
+ Pos = Gia_WriteAigerEncode( pBuffer, Pos, uLit1 - uLit0 );
+ if ( Pos > nBufferSize - 10 )
+ {
+ printf( "Gia_WriteAiger(): AIGER generation has failed because the allocated buffer is too small.\n" );
+ fclose( pFile );
+ if ( p != pInit )
+ Gia_ManStop( p );
+ return;
+ }
+ }
+ assert( Pos < nBufferSize );
+
+ // write the buffer
+ fwrite( pBuffer, 1, Pos, pFile );
+ ABC_FREE( pBuffer );
+
+ // write the comment
+ fprintf( pFile, "c" );
+ // write signature
+ Gia_WriteBlockHeader( pFile, '\n', 0xAC1D0FF1CEC0FFEE );
+ // write name
+ if ( p->pName )
+ {
+ Gia_WriteBlockHeader( pFile, 'N', (word)strlen(pInit->pName) );
+ fwrite( pInit->pName, 1, strlen(pInit->pName), pFile );
+ }
+ // write equivalences
+ if ( p->pReprs && p->pNexts )
+ {
+ int nEquivSize;
+ unsigned char * pEquivs = Gia_WriteEquivClasses( p, &nEquivSize );
+ Gia_WriteBlockHeader( pFile, '=', (word)nEquivSize );
+ fwrite( pEquivs, 1, nEquivSize, pFile );
+ ABC_FREE( pEquivs );
+ }
+ // write flop classes
+ if ( p->vFlopClasses )
+ {
+ Gia_WriteBlockHeader( pFile, 'f', 4*Gia_ManRegNum(p) );
+ fwrite( Vec_IntArray(p->vFlopClasses), 1, 4*Gia_ManRegNum(p), pFile );
+ }
+/*
+ // write mapping
+ if ( p->pMapping )
+ {
+ int nMapSize;
+ unsigned char * pMaps = Gia_WriteMapping( p, &nMapSize );
+ Gia_WriteBlockHeader( pFile, 'm', (word)nMapSize );
+ fwrite( pMaps, 1, nMapSize, pFile );
+ ABC_FREE( pMaps );
+ }
+ // write placement
+ if ( p->pPlacement )
+ {
+ Gia_WriteBlockHeader( pFile, 'p', (word)4*Gia_ManObjNum(p) );
+ fwrite( p->pPlacement, 1, 4*Gia_ManObjNum(p), pFile );
+ }
+ // write switching activity
+ if ( p->pSwitching )
+ {
+ Gia_WriteBlockHeader( pFile, 's', (word)Gia_ManObjNum(p) );
+ fwrite( p->pSwitching, 1, Gia_ManObjNum(p), pFile );
+ }
+ // write name
+ if ( p->pName )
+ fprintf( pFile, "n%s%c", p->pName, '\0' );
+*/
+ // write constraints
+ if ( p->nConstrs )
+ {
+ Gia_WriteBlockHeader( pFile, 'c', (word)p->nConstrs );
+ Gia_WriteIntF( pFile, p->nConstrs );
+ }
+ // write the closing statement
+ Gia_WriteBlockHeader( pFile, '\0', (word)0 );
+ // write comment
+ fprintf( pFile, "\nThis file was produced by the GIA package in ABC on %s\n", Gia_TimeStamp() );
+ fprintf( pFile, "For information about AIGER format, refer to %s\n", "http://fmv.jku.at/aiger" );
+ fclose( pFile );
+ if ( p != pInit )
+ Gia_ManStop( p );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Writes the AIG in the binary AIGER format.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_DumpAiger( Gia_Man_t * p, char * pFilePrefix, int iFileNum, int nFileNumDigits )
+{
+ char Buffer[100];
+ sprintf( Buffer, "%s%0*d.aig", pFilePrefix, nFileNumDigits, iFileNum );
+ Gia_WriteAiger( p, Buffer, 0, 0 );
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaBidec.c b/src/aig/gia/giaBidec.c
new file mode 100644
index 00000000..fc17b582
--- /dev/null
+++ b/src/aig/gia/giaBidec.c
@@ -0,0 +1,308 @@
+/**CFile****************************************************************
+
+ FileName [giaBidec.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Scalable AIG package.]
+
+ Synopsis [Application of bi-decomposition to AIG minimization.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: giaBidec.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+#include "bdc.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+static inline int Bdc_FunObjCopy( Bdc_Fun_t * pObj ) { return Gia_LitNotCond( Bdc_FuncCopyInt(Bdc_Regular(pObj)), Bdc_IsComplement(pObj) ); }
+static inline int Bdc_FunFanin0Copy( Bdc_Fun_t * pObj ) { return Bdc_FunObjCopy( Bdc_FuncFanin0(pObj) ); }
+static inline int Bdc_FunFanin1Copy( Bdc_Fun_t * pObj ) { return Bdc_FunObjCopy( Bdc_FuncFanin1(pObj) ); }
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Computes truth table of the cut.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+unsigned * Gia_ManConvertAigToTruth_rec( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vTruth, int nWords, Vec_Int_t * vVisited )
+{
+ unsigned * pTruth, * pTruth0, * pTruth1;
+ int i;
+ assert( !Gia_IsComplement(pObj) );
+ if ( Vec_IntGetEntry(p->vTruths, Gia_ObjId(p, pObj)) != -1 )
+ return (unsigned *)Vec_IntEntryP( vTruth, nWords * Vec_IntGetEntry(p->vTruths, Gia_ObjId(p, pObj)) );
+ // compute the truth tables of the fanins
+ pTruth0 = Gia_ManConvertAigToTruth_rec( p, Gia_ObjFanin0(pObj), vTruth, nWords, vVisited );
+ pTruth1 = Gia_ManConvertAigToTruth_rec( p, Gia_ObjFanin1(pObj), vTruth, nWords, vVisited );
+ // get room for the truth table
+ pTruth = Vec_IntFetch( vTruth, nWords );
+ // create the truth table of the node
+ if ( !Gia_ObjFaninC0(pObj) && !Gia_ObjFaninC1(pObj) )
+ for ( i = 0; i < nWords; i++ )
+ pTruth[i] = pTruth0[i] & pTruth1[i];
+ else if ( !Gia_ObjFaninC0(pObj) && Gia_ObjFaninC1(pObj) )
+ for ( i = 0; i < nWords; i++ )
+ pTruth[i] = pTruth0[i] & ~pTruth1[i];
+ else if ( Gia_ObjFaninC0(pObj) && !Gia_ObjFaninC1(pObj) )
+ for ( i = 0; i < nWords; i++ )
+ pTruth[i] = ~pTruth0[i] & pTruth1[i];
+ else // if ( Gia_ObjFaninC0(pObj) && Gia_ObjFaninC1(pObj) )
+ for ( i = 0; i < nWords; i++ )
+ pTruth[i] = ~pTruth0[i] & ~pTruth1[i];
+ // save the visited node
+ Vec_IntSetEntry( p->vTruths, Gia_ObjId(p, pObj), Vec_IntSize(vVisited) );
+ Vec_IntPush( vVisited, Gia_ObjId(p, pObj) );
+ return pTruth;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes truth table of the node.]
+
+ Description [Assumes that the structural support is no more than 8 inputs.
+ Uses array vTruth to store temporary truth tables. The returned pointer should
+ be used immediately.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+unsigned * Gia_ManConvertAigToTruth( Gia_Man_t * p, Gia_Obj_t * pRoot, Vec_Int_t * vLeaves, Vec_Int_t * vTruth, Vec_Int_t * vVisited )
+{
+ static unsigned uTruths[8][8] = { // elementary truth tables
+ { 0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA },
+ { 0xCCCCCCCC,0xCCCCCCCC,0xCCCCCCCC,0xCCCCCCCC,0xCCCCCCCC,0xCCCCCCCC,0xCCCCCCCC,0xCCCCCCCC },
+ { 0xF0F0F0F0,0xF0F0F0F0,0xF0F0F0F0,0xF0F0F0F0,0xF0F0F0F0,0xF0F0F0F0,0xF0F0F0F0,0xF0F0F0F0 },
+ { 0xFF00FF00,0xFF00FF00,0xFF00FF00,0xFF00FF00,0xFF00FF00,0xFF00FF00,0xFF00FF00,0xFF00FF00 },
+ { 0xFFFF0000,0xFFFF0000,0xFFFF0000,0xFFFF0000,0xFFFF0000,0xFFFF0000,0xFFFF0000,0xFFFF0000 },
+ { 0x00000000,0xFFFFFFFF,0x00000000,0xFFFFFFFF,0x00000000,0xFFFFFFFF,0x00000000,0xFFFFFFFF },
+ { 0x00000000,0x00000000,0xFFFFFFFF,0xFFFFFFFF,0x00000000,0x00000000,0xFFFFFFFF,0xFFFFFFFF },
+ { 0x00000000,0x00000000,0x00000000,0x00000000,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF }
+ };
+ Gia_Obj_t * pObj;
+ Vec_Ptr_t * vTtElems = NULL;
+ unsigned * pTruth;//, * pTruth2;
+ int i, nWords, nVars;
+ // get the number of variables and words
+ nVars = Vec_IntSize( vLeaves );
+ nWords = Gia_TruthWordNum( nVars );
+ // check the case of a constant
+ if ( Gia_ObjIsConst0( Gia_Regular(pRoot) ) )
+ {
+ Vec_IntClear( vTruth );
+ // get room for the truth table
+ pTruth = Vec_IntFetch( vTruth, nWords );
+ if ( !Gia_IsComplement(pRoot) )
+ Gia_ManTruthClear( pTruth, nVars );
+ else
+ Gia_ManTruthFill( pTruth, nVars );
+ return pTruth;
+ }
+ // if the number of variables is more than 8, allocate truth tables
+ if ( nVars > 8 )
+ vTtElems = Vec_PtrAllocTruthTables( nVars );
+ // assign elementary truth tables
+ Vec_IntClear( vTruth );
+ Vec_IntClear( vVisited );
+ Gia_ManForEachObjVec( vLeaves, p, pObj, i )
+ {
+ // get room for the truth table
+ pTruth = Vec_IntFetch( vTruth, nWords );
+ // assign elementary variable
+ if ( vTtElems )
+ Gia_ManTruthCopy( pTruth, (unsigned *)Vec_PtrEntry(vTtElems, i), nVars );
+ else
+ Gia_ManTruthCopy( pTruth, uTruths[i], nVars );
+ // save the visited node
+ Vec_IntSetEntry( p->vTruths, Gia_ObjId(p, pObj), Vec_IntSize(vVisited) );
+ Vec_IntPush( vVisited, Gia_ObjId(p, pObj) );
+ }
+ if ( vTtElems )
+ Vec_PtrFree( vTtElems );
+ // clear the marks and compute the truth table
+// pTruth2 = Gia_ManConvertAigToTruth_rec( p, Gia_Regular(pRoot), vTruth, nWords, vVisited );
+ pTruth = Gia_ManConvertAigToTruth_rec( p, Gia_Regular(pRoot), vTruth, nWords, vVisited );
+ // copy the result
+// Gia_ManTruthCopy( pTruth, pTruth2, nVars );
+ if ( Gia_IsComplement(pRoot) )
+ Gia_ManTruthNot( pTruth, pTruth, nVars );
+ // clean truth tables
+ Gia_ManForEachObjVec( vVisited, p, pObj, i )
+ Vec_IntSetEntry( p->vTruths, Gia_ObjId(p, pObj), -1 );
+ return pTruth;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Resynthesizes nodes using bi-decomposition.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ObjPerformBidec( Bdc_Man_t * pManDec,
+ Gia_Man_t * pNew, Gia_Man_t * p, Gia_Obj_t * pRoot,
+ Vec_Int_t * vLeaves, Vec_Int_t * vTruth, Vec_Int_t * vVisited )
+{
+ unsigned * pTruth;
+ Bdc_Fun_t * pFunc;
+ Gia_Obj_t * pFanin;
+ int i, iFan, nVars, nNodes;
+ // collect leaves of this gate
+ Vec_IntClear( vLeaves );
+ Gia_LutForEachFanin( p, Gia_ObjId(p, pRoot), iFan, i )
+ Vec_IntPush( vLeaves, iFan );
+ nVars = Vec_IntSize( vLeaves );
+ assert( nVars < 16 );
+ // derive truth table
+ pTruth = Gia_ManConvertAigToTruth( p, pRoot, vLeaves, vTruth, vVisited );
+//Extra_PrintBinary( stdout, pTruth, (1<<nVars) ); printf( "\n" );
+ if ( Gia_ManTruthIsConst0(pTruth, nVars) )
+ {
+//printf( "Node %d is const0\n", Gia_ObjId(p, pRoot) );
+ return 0;
+ }
+ if ( Gia_ManTruthIsConst1(pTruth, nVars) )
+ {
+//printf( "Node %d is const1\n", Gia_ObjId(p, pRoot) );
+ return 1;
+ }
+ // decompose truth table
+ Bdc_ManDecompose( pManDec, pTruth, NULL, nVars, NULL, 1000 );
+/*
+if ( Bdc_ManNodeNum(pManDec) == 0 )
+ printf( "Node %d has 0 bidec nodes\n", Gia_ObjId(p, pRoot) );
+if ( Kit_TruthSupportSize(pTruth, nVars) != nVars )
+{
+ printf( "Node %d has %d fanins and %d supp size\n", Gia_ObjId(p, pRoot), nVars, Kit_TruthSupportSize(pTruth, nVars) );
+ Gia_LutForEachFanin( p, Gia_ObjId(p, pRoot), iFan, i )
+ {
+ printf( "%d ", Kit_TruthVarInSupport(pTruth, nVars, i) );
+ Gia_ObjPrint( p, Gia_ManObj(p, iFan) );
+ }
+// Gia_ManPrintStats( p, 0 );
+}
+*/
+ // convert back into HOP
+ Bdc_FuncSetCopy( Bdc_ManFunc( pManDec, 0 ), Gia_ManConst1(pNew) );
+ Gia_ManForEachObjVec( vLeaves, p, pFanin, i )
+ Bdc_FuncSetCopyInt( Bdc_ManFunc( pManDec, i+1 ), Gia_ObjValue(pFanin) );
+ nNodes = Bdc_ManNodeNum( pManDec );
+ for ( i = nVars + 1; i < nNodes; i++ )
+ {
+ pFunc = Bdc_ManFunc( pManDec, i );
+ Bdc_FuncSetCopyInt( pFunc, Gia_ManHashAnd( pNew, Bdc_FunFanin0Copy(pFunc), Bdc_FunFanin1Copy(pFunc) ) );
+ }
+ return Bdc_FunObjCopy( Bdc_ManRoot(pManDec) );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManPerformBidec( Gia_Man_t * p, int fVerbose )
+{
+ Bdc_Man_t * pManDec;
+ Bdc_Par_t Pars = {0}, * pPars = &Pars;
+ Vec_Int_t * vLeaves, * vTruth, * vVisited;
+ Gia_Man_t * pNew, * pTemp;
+ Gia_Obj_t * pObj;
+ int i, clk = clock();
+ pPars->nVarsMax = Gia_ManLutSizeMax( p );
+ pPars->fVerbose = fVerbose;
+ if ( pPars->nVarsMax < 2 )
+ {
+ printf( "Resynthesis is not performed when nodes have less than 2 inputs.\n" );
+ return NULL;
+ }
+ if ( pPars->nVarsMax > 15 )
+ {
+ printf( "Resynthesis is not performed when nodes have more than 15 inputs.\n" );
+ return NULL;
+ }
+ vLeaves = Vec_IntAlloc( 0 );
+ vTruth = Vec_IntAlloc( (1<<16) );
+ vVisited = Vec_IntAlloc( 0 );
+ // clean the old manager
+ Gia_ManCleanTruth( p );
+ Gia_ManFillValue( p );
+ Gia_ManConst0(p)->Value = 0;
+ // start the new manager
+ pNew = Gia_ManStart( Gia_ManObjNum(p) );
+ pNew->pName = Gia_UtilStrsav( p->pName );
+ Gia_ManHashAlloc( pNew );
+// Gia_ManCleanLevels( pNew, Gia_ManObjNum(p) );
+ pManDec = Bdc_ManAlloc( pPars );
+ Gia_ManForEachObj1( p, pObj, i )
+ {
+ if ( Gia_ObjIsCi(pObj) ) // transfer the CI level (is it needed?)
+ pObj->Value = Gia_ManAppendCi( pNew );
+ else if ( Gia_ObjIsCo(pObj) )
+ pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
+ else if ( Gia_ObjIsLut(p, i) )
+ pObj->Value = Gia_ObjPerformBidec( pManDec, pNew, p, pObj, vLeaves, vTruth, vVisited );
+ }
+ Bdc_ManFree( pManDec );
+ // cleanup the AIG
+ Gia_ManHashStop( pNew );
+ // check the presence of dangling nodes
+ if ( Gia_ManHasDangling(pNew) )
+ {
+ pNew = Gia_ManCleanup( pTemp = pNew );
+ if ( Gia_ManAndNum(pNew) != Gia_ManAndNum(pTemp) )
+ printf( "Gia_ManPerformBidec() node count before and after: %6d and %6d.\n", Gia_ManAndNum(pNew), Gia_ManAndNum(pTemp) );
+ Gia_ManStop( pTemp );
+ }
+ Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
+ Vec_IntFree( vLeaves );
+ Vec_IntFree( vTruth );
+ Vec_IntFree( vVisited );
+ if ( fVerbose )
+ {
+// printf( "Total gain in AIG nodes = %d. ", Gia_ManObjNum(p)-Gia_ManObjNum(pNew) );
+// ABC_PRT( "Total runtime", clock() - clk );
+ }
+ return pNew;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaCSat.c b/src/aig/gia/giaCSat.c
index e3aca7df..1c5b05fe 100644
--- a/src/aig/gia/giaCSat.c
+++ b/src/aig/gia/giaCSat.c
@@ -20,6 +20,9 @@
#include "gia.h"
+ABC_NAMESPACE_IMPL_START
+
+
//#define gia_assert(exp) ((void)0)
//#define gia_assert(exp) (assert(exp))
@@ -627,7 +630,7 @@ static inline void Cbs_ManDeriveReason( Cbs_Man_t * p, int Level )
assert( pQue->pData[pQue->iHead] != NULL );
pQue->iTail = k;
// clear the marks
- Vec_PtrForEachEntry( p->vTemp, pObj, i )
+ Vec_PtrForEachEntry( Gia_Obj_t *, p->vTemp, pObj, i )
pObj->fMark0 = 1;
}
@@ -1094,3 +1097,5 @@ Vec_Int_t * Cbs_ManSolveMiterNc( Gia_Man_t * pAig, int nConfs, Vec_Str_t ** pvSt
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaCSatOld.c b/src/aig/gia/giaCSatOld.c
index bd8f061b..983081f0 100644
--- a/src/aig/gia/giaCSatOld.c
+++ b/src/aig/gia/giaCSatOld.c
@@ -20,6 +20,9 @@
#include "gia.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -796,3 +799,5 @@ Vec_Int_t * Cbs_ManSolveMiter( Gia_Man_t * pAig, int nConfs, Vec_Str_t ** pvStat
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaCTas.c b/src/aig/gia/giaCTas.c
new file mode 100644
index 00000000..c6aa3fec
--- /dev/null
+++ b/src/aig/gia/giaCTas.c
@@ -0,0 +1,1788 @@
+/**CFile****************************************************************
+
+ FileName [giaCSat.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Scalable AIG package.]
+
+ Synopsis [A simple circuit-based solver.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: giaCSat.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+//#define gia_assert(exp) ((void)0)
+//#define gia_assert(exp) (assert(exp))
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+typedef struct Tas_Par_t_ Tas_Par_t;
+struct Tas_Par_t_
+{
+ // conflict limits
+ int nBTLimit; // limit on the number of conflicts
+ int nJustLimit; // limit on the size of justification queue
+ // current parameters
+ int nBTThis; // number of conflicts
+ int nBTThisNc; // number of conflicts
+ int nJustThis; // max size of the frontier
+ int nBTTotal; // total number of conflicts
+ int nJustTotal; // total size of the frontier
+ // activity
+ float VarDecay; // variable activity decay
+ int VarInc; // variable increment
+ // decision heuristics
+ int fUseActive; // use most active
+ int fUseHighest; // use node with the highest ID
+ int fUseLowest; // use node with the highest ID
+ int fUseMaxFF; // use node with the largest fanin fanout
+ // other
+ int fVerbose;
+};
+
+typedef struct Tas_Cls_t_ Tas_Cls_t;
+struct Tas_Cls_t_
+{
+ int iNext[2]; // beginning of the queue
+ int nLits; // the number of literals
+ int pLits[0]; // clause literals
+};
+
+typedef struct Tas_Sto_t_ Tas_Sto_t;
+struct Tas_Sto_t_
+{
+ int iCur; // current position
+ int nSize; // allocated size
+ int * pData; // clause information
+};
+
+typedef struct Tas_Que_t_ Tas_Que_t;
+struct Tas_Que_t_
+{
+ int iHead; // beginning of the queue
+ int iTail; // end of the queue
+ int nSize; // allocated size
+ Gia_Obj_t ** pData; // nodes stored in the queue
+};
+
+struct Tas_Man_t_
+{
+ Tas_Par_t Pars; // parameters
+ Gia_Man_t * pAig; // AIG manager
+ Tas_Que_t pProp; // propagation queue
+ Tas_Que_t pJust; // justification queue
+ Tas_Que_t pClauses; // clause queue
+ Gia_Obj_t ** pIter; // iterator through clause vars
+ Vec_Int_t * vLevReas; // levels and decisions
+ Vec_Int_t * vModel; // satisfying assignment
+ Vec_Ptr_t * vTemp; // temporary storage
+ // watched clauses
+ Tas_Sto_t pStore; // storage for watched clauses
+ int * pWatches; // watched lists for each literal
+ Vec_Int_t * vWatchLits; // lits whose watched are assigned
+ int nClauses; // the counter of clauses
+ // activity
+ float * pActivity; // variable activity
+ Vec_Int_t * vActiveVars; // variables with activity
+ // SAT calls statistics
+ int nSatUnsat; // the number of proofs
+ int nSatSat; // the number of failure
+ int nSatUndec; // the number of timeouts
+ int nSatTotal; // the number of calls
+ // conflicts
+ int nConfUnsat; // conflicts in unsat problems
+ int nConfSat; // conflicts in sat problems
+ int nConfUndec; // conflicts in undec problems
+ // runtime stats
+ int timeSatUnsat; // unsat
+ int timeSatSat; // sat
+ int timeSatUndec; // undecided
+ int timeTotal; // total runtime
+};
+
+static inline int Tas_VarIsAssigned( Gia_Obj_t * pVar ) { return pVar->fMark0; }
+static inline void Tas_VarAssign( Gia_Obj_t * pVar ) { assert(!pVar->fMark0); pVar->fMark0 = 1; }
+static inline void Tas_VarUnassign( Gia_Obj_t * pVar ) { assert(pVar->fMark0); pVar->fMark0 = 0; pVar->fMark1 = 0; pVar->Value = ~0; }
+static inline int Tas_VarValue( Gia_Obj_t * pVar ) { assert(pVar->fMark0); return pVar->fMark1; }
+static inline void Tas_VarSetValue( Gia_Obj_t * pVar, int v ) { assert(pVar->fMark0); pVar->fMark1 = v; }
+static inline int Tas_VarIsJust( Gia_Obj_t * pVar ) { return Gia_ObjIsAnd(pVar) && !Tas_VarIsAssigned(Gia_ObjFanin0(pVar)) && !Tas_VarIsAssigned(Gia_ObjFanin1(pVar)); }
+static inline int Tas_VarFanin0Value( Gia_Obj_t * pVar ) { return !Tas_VarIsAssigned(Gia_ObjFanin0(pVar)) ? 2 : (Tas_VarValue(Gia_ObjFanin0(pVar)) ^ Gia_ObjFaninC0(pVar)); }
+static inline int Tas_VarFanin1Value( Gia_Obj_t * pVar ) { return !Tas_VarIsAssigned(Gia_ObjFanin1(pVar)) ? 2 : (Tas_VarValue(Gia_ObjFanin1(pVar)) ^ Gia_ObjFaninC1(pVar)); }
+static inline int Tas_VarToLit( Tas_Man_t * p, Gia_Obj_t * pObj ) { assert( Tas_VarIsAssigned(pObj) ); return Gia_Var2Lit( Gia_ObjId(p->pAig, pObj), !Tas_VarValue(pObj) ); }
+static inline int Tas_LitIsTrue( Gia_Obj_t * pObj, int Lit ) { assert( Tas_VarIsAssigned(pObj) ); return Tas_VarValue(pObj) != Gia_LitIsCompl(Lit); }
+
+static inline int Tas_ClsHandle( Tas_Man_t * p, Tas_Cls_t * pClause ) { return ((int *)pClause) - p->pStore.pData; }
+static inline Tas_Cls_t * Tas_ClsFromHandle( Tas_Man_t * p, int h ) { return (Tas_Cls_t *)(p->pStore.pData + h); }
+
+static inline int Tas_VarDecLevel( Tas_Man_t * p, Gia_Obj_t * pVar ) { assert( pVar->Value != ~0 ); return Vec_IntEntry(p->vLevReas, 3*pVar->Value); }
+static inline Gia_Obj_t * Tas_VarReason0( Tas_Man_t * p, Gia_Obj_t * pVar ) { assert( pVar->Value != ~0 ); return pVar + Vec_IntEntry(p->vLevReas, 3*pVar->Value+1); }
+static inline Gia_Obj_t * Tas_VarReason1( Tas_Man_t * p, Gia_Obj_t * pVar ) { assert( pVar->Value != ~0 ); return pVar + Vec_IntEntry(p->vLevReas, 3*pVar->Value+2); }
+static inline int Tas_ClauseDecLevel( Tas_Man_t * p, int hClause ) { return Tas_VarDecLevel( p, p->pClauses.pData[hClause] ); }
+
+static inline int Tas_VarHasReasonCls( Tas_Man_t * p, Gia_Obj_t * pVar ) { assert( pVar->Value != ~0 ); return Vec_IntEntry(p->vLevReas, 3*pVar->Value+1) == 0 && Vec_IntEntry(p->vLevReas, 3*pVar->Value+2) != 0; }
+static inline Tas_Cls_t * Tas_VarReasonCls( Tas_Man_t * p, Gia_Obj_t * pVar ) { assert( pVar->Value != ~0 ); return Tas_ClsFromHandle( p, Vec_IntEntry(p->vLevReas, 3*pVar->Value+2) ); }
+
+#define Tas_QueForEachEntry( Que, pObj, i ) \
+ for ( i = (Que).iHead; (i < (Que).iTail) && ((pObj) = (Que).pData[i]); i++ )
+
+#define Tas_ClauseForEachVar( p, hClause, pObj ) \
+ for ( (p)->pIter = (p)->pClauses.pData + hClause; (pObj = *pIter); (p)->pIter++ )
+#define Tas_ClauseForEachVar1( p, hClause, pObj ) \
+ for ( (p)->pIter = (p)->pClauses.pData+hClause+1; (pObj = *pIter); (p)->pIter++ )
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Sets default values of the parameters.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Tas_SetDefaultParams( Tas_Par_t * pPars )
+{
+ memset( pPars, 0, sizeof(Tas_Par_t) );
+ pPars->nBTLimit = 2000; // limit on the number of conflicts
+ pPars->nJustLimit = 2000; // limit on the size of justification queue
+ pPars->fUseActive = 0; // use node with the highest activity
+ pPars->fUseHighest = 1; // use node with the highest ID
+ pPars->fUseLowest = 0; // use node with the lowest ID
+ pPars->fUseMaxFF = 0; // use node with the largest fanin fanout
+ pPars->fVerbose = 1; // print detailed statistics
+ pPars->VarDecay = (float)0.95; // variable decay
+ pPars->VarInc = 1.0; // variable increment
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Tas_Man_t * Tas_ManAlloc( Gia_Man_t * pAig, int nBTLimit )
+{
+ Tas_Man_t * p;
+ p = ABC_CALLOC( Tas_Man_t, 1 );
+ Tas_SetDefaultParams( &p->Pars );
+ p->pAig = pAig;
+ p->Pars.nBTLimit = nBTLimit;
+ p->pProp.nSize = p->pJust.nSize = p->pClauses.nSize = 10000;
+ p->pProp.pData = ABC_ALLOC( Gia_Obj_t *, p->pProp.nSize );
+ p->pJust.pData = ABC_ALLOC( Gia_Obj_t *, p->pJust.nSize );
+ p->pClauses.pData = ABC_ALLOC( Gia_Obj_t *, p->pClauses.nSize );
+ p->pClauses.iHead = p->pClauses.iTail = 1;
+ p->vModel = Vec_IntAlloc( 1000 );
+ p->vLevReas = Vec_IntAlloc( 1000 );
+ p->vTemp = Vec_PtrAlloc( 1000 );
+ p->pStore.iCur = 16;
+ p->pStore.nSize = 10000;
+ p->pStore.pData = ABC_ALLOC( int, p->pStore.nSize );
+ p->pWatches = ABC_CALLOC( int, 2 * Gia_ManObjNum(pAig) );
+ p->vWatchLits = Vec_IntAlloc( 100 );
+ p->pActivity = ABC_CALLOC( float, Gia_ManObjNum(pAig) );
+ p->vActiveVars = Vec_IntAlloc( 100 );
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Tas_ManStop( Tas_Man_t * p )
+{
+ Vec_IntFree( p->vActiveVars );
+ Vec_IntFree( p->vWatchLits );
+ Vec_IntFree( p->vLevReas );
+ Vec_IntFree( p->vModel );
+ Vec_PtrFree( p->vTemp );
+ ABC_FREE( p->pActivity );
+ ABC_FREE( p->pWatches );
+ ABC_FREE( p->pStore.pData );
+ ABC_FREE( p->pClauses.pData );
+ ABC_FREE( p->pProp.pData );
+ ABC_FREE( p->pJust.pData );
+ ABC_FREE( p );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns satisfying assignment.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Tas_ReadModel( Tas_Man_t * p )
+{
+ return p->vModel;
+}
+
+
+
+
+/**Function*************************************************************
+
+ Synopsis [Returns 1 if the solver is out of limits.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Tas_ManCheckLimits( Tas_Man_t * p )
+{
+ return p->Pars.nJustThis > p->Pars.nJustLimit || p->Pars.nBTThis > p->Pars.nBTLimit;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Saves the satisfying assignment as an array of literals.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Tas_ManSaveModel( Tas_Man_t * p, Vec_Int_t * vCex )
+{
+ Gia_Obj_t * pVar;
+ int i;
+ Vec_IntClear( vCex );
+ p->pProp.iHead = 0;
+// printf( "\n" );
+ Tas_QueForEachEntry( p->pProp, pVar, i )
+ {
+ if ( Gia_ObjIsCi(pVar) )
+// Vec_IntPush( vCex, Gia_Var2Lit(Gia_ObjId(p->pAig,pVar), !Tas_VarValue(pVar)) );
+ Vec_IntPush( vCex, Gia_Var2Lit(Gia_ObjCioId(pVar), !Tas_VarValue(pVar)) );
+/*
+ printf( "%5d(%d) = ", Gia_ObjId(p->pAig, pVar), Tas_VarValue(pVar) );
+ if ( Gia_ObjIsCi(pVar) )
+ printf( "pi %d\n", Gia_ObjCioId(pVar) );
+ else
+ {
+ printf( "%5d %d & ", Gia_ObjFaninId0p(p->pAig, pVar), Gia_ObjFaninC0(pVar) );
+ printf( "%5d %d ", Gia_ObjFaninId1p(p->pAig, pVar), Gia_ObjFaninC1(pVar) );
+ printf( "\n" );
+ }
+*/
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Tas_QueIsEmpty( Tas_Que_t * p )
+{
+ return p->iHead == p->iTail;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Tas_QuePush( Tas_Que_t * p, Gia_Obj_t * pObj )
+{
+ if ( p->iTail == p->nSize )
+ {
+ p->nSize *= 2;
+ p->pData = ABC_REALLOC( Gia_Obj_t *, p->pData, p->nSize );
+ }
+ p->pData[p->iTail++] = pObj;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns 1 if the object in the queue.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Tas_QueHasNode( Tas_Que_t * p, Gia_Obj_t * pObj )
+{
+ Gia_Obj_t * pTemp;
+ int i;
+ Tas_QueForEachEntry( *p, pTemp, i )
+ if ( pTemp == pObj )
+ return 1;
+ return 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Tas_QueStore( Tas_Que_t * p, int * piHeadOld, int * piTailOld )
+{
+ int i;
+ *piHeadOld = p->iHead;
+ *piTailOld = p->iTail;
+ for ( i = *piHeadOld; i < *piTailOld; i++ )
+ Tas_QuePush( p, p->pData[i] );
+ p->iHead = *piTailOld;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Tas_QueRestore( Tas_Que_t * p, int iHeadOld, int iTailOld )
+{
+ p->iHead = iHeadOld;
+ p->iTail = iTailOld;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Finalized the clause.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Tas_QueFinish( Tas_Que_t * p )
+{
+ int iHeadOld = p->iHead;
+ assert( p->iHead < p->iTail );
+ Tas_QuePush( p, NULL );
+ p->iHead = p->iTail;
+ return iHeadOld;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Max number of fanins fanouts.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Tas_VarFaninFanoutMax( Tas_Man_t * p, Gia_Obj_t * pObj )
+{
+ int Count0, Count1;
+ assert( !Gia_IsComplement(pObj) );
+ assert( Gia_ObjIsAnd(pObj) );
+ Count0 = Gia_ObjRefs( p->pAig, Gia_ObjFanin0(pObj) );
+ Count1 = Gia_ObjRefs( p->pAig, Gia_ObjFanin1(pObj) );
+ return ABC_MAX( Count0, Count1 );
+}
+
+
+
+/**Function*************************************************************
+
+ Synopsis [Find variable with the highest activity.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline Gia_Obj_t * Tas_ManFindActive( Tas_Man_t * p )
+{
+ Gia_Obj_t * pObj, * pObjMax = NULL;
+ float BestCost = 0.0;
+ int i, ObjId;
+ Tas_QueForEachEntry( p->pJust, pObj, i )
+ {
+ assert( Gia_ObjIsAnd(pObj) );
+ ObjId = Gia_ObjId( p->pAig, pObj );
+ if ( pObjMax == NULL ||
+ p->pActivity[Gia_ObjFaninId0(pObj,ObjId)] > BestCost ||
+ (p->pActivity[Gia_ObjFaninId0(pObj,ObjId)] == BestCost && pObjMax < Gia_ObjFanin0(pObj)) )
+ {
+ pObjMax = Gia_ObjFanin0(pObj);
+ BestCost = p->pActivity[Gia_ObjFaninId0(pObj,ObjId)];
+ }
+ if ( p->pActivity[Gia_ObjFaninId1(pObj,ObjId)] > BestCost ||
+ (p->pActivity[Gia_ObjFaninId1(pObj,ObjId)] == BestCost && pObjMax < Gia_ObjFanin1(pObj)) )
+ {
+ pObjMax = Gia_ObjFanin1(pObj);
+ BestCost = p->pActivity[Gia_ObjFaninId1(pObj,ObjId)];
+ }
+ }
+ return pObjMax;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Find variable with the highest activity.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline Gia_Obj_t * Tas_ManDecideHighestFanin( Tas_Man_t * p )
+{
+ Gia_Obj_t * pObj, * pObjMax = NULL;
+ int i, ObjId;
+ Tas_QueForEachEntry( p->pJust, pObj, i )
+ {
+ assert( Gia_ObjIsAnd(pObj) );
+ ObjId = Gia_ObjId( p->pAig, pObj );
+ if ( pObjMax == NULL || pObjMax < Gia_ObjFanin0(pObj) )
+ pObjMax = Gia_ObjFanin0(pObj);
+ if ( pObjMax < Gia_ObjFanin1(pObj) )
+ pObjMax = Gia_ObjFanin1(pObj);
+ }
+ return pObjMax;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Find variable with the highest ID.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline Gia_Obj_t * Tas_ManDecideHighest( Tas_Man_t * p )
+{
+ Gia_Obj_t * pObj, * pObjMax = NULL;
+ int i;
+ Tas_QueForEachEntry( p->pJust, pObj, i )
+ {
+//printf( "%d %6.2f ", Gia_ObjId(p->pAig, pObj), p->pActivity[Gia_ObjId(p->pAig, pObj)] );
+ if ( pObjMax == NULL || pObjMax < pObj )
+ pObjMax = pObj;
+ }
+//printf( "\n" );
+ return pObjMax;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Find variable with the highest ID.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline Gia_Obj_t * Tas_ManDecideHighestA( Tas_Man_t * p )
+{
+ Gia_Obj_t * pObj, * pObjMax = NULL;
+ int i;
+ Tas_QueForEachEntry( p->pJust, pObj, i )
+ {
+ if ( pObjMax == NULL ||
+ p->pActivity[Gia_ObjId(p->pAig, pObjMax)] < p->pActivity[Gia_ObjId(p->pAig, pObj)] )
+ pObjMax = pObj;
+ }
+ return pObjMax;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Find variable with the lowest ID.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline Gia_Obj_t * Tas_ManDecideLowest( Tas_Man_t * p )
+{
+ Gia_Obj_t * pObj, * pObjMin = NULL;
+ int i;
+ Tas_QueForEachEntry( p->pJust, pObj, i )
+ if ( pObjMin == NULL || pObjMin > pObj )
+ pObjMin = pObj;
+ return pObjMin;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Find variable with the maximum number of fanin fanouts.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline Gia_Obj_t * Tas_ManDecideMaxFF( Tas_Man_t * p )
+{
+ Gia_Obj_t * pObj, * pObjMax = NULL;
+ int i, iMaxFF = 0, iCurFF;
+ assert( p->pAig->pRefs != NULL );
+ Tas_QueForEachEntry( p->pJust, pObj, i )
+ {
+ iCurFF = Tas_VarFaninFanoutMax( p, pObj );
+ assert( iCurFF > 0 );
+ if ( iMaxFF < iCurFF )
+ {
+ iMaxFF = iCurFF;
+ pObjMax = pObj;
+ }
+ }
+ return pObjMax;
+}
+
+
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Tas_ManCancelUntil( Tas_Man_t * p, int iBound )
+{
+ Gia_Obj_t * pVar;
+ int i;
+ assert( iBound <= p->pProp.iTail );
+ p->pProp.iHead = iBound;
+ Tas_QueForEachEntry( p->pProp, pVar, i )
+ Tas_VarUnassign( pVar );
+ p->pProp.iTail = iBound;
+ Vec_IntShrink( p->vLevReas, 3*iBound );
+}
+
+int s_Counter2 = 0;
+int s_Counter3 = 0;
+int s_Counter4 = 0;
+
+/**Function*************************************************************
+
+ Synopsis [Assigns the variables a value.]
+
+ Description [Returns 1 if conflict; 0 if no conflict.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Tas_ManAssign( Tas_Man_t * p, Gia_Obj_t * pObj, int Level, Gia_Obj_t * pRes0, Gia_Obj_t * pRes1 )
+{
+ Gia_Obj_t * pObjR = Gia_Regular(pObj);
+ assert( Gia_ObjIsCand(pObjR) );
+ assert( !Tas_VarIsAssigned(pObjR) );
+ Tas_VarAssign( pObjR );
+ Tas_VarSetValue( pObjR, !Gia_IsComplement(pObj) );
+ assert( pObjR->Value == ~0 );
+ pObjR->Value = p->pProp.iTail;
+ Tas_QuePush( &p->pProp, pObjR );
+ Vec_IntPush( p->vLevReas, Level );
+ if ( pRes0 == NULL && pRes1 != 0 ) // clause
+ {
+ Vec_IntPush( p->vLevReas, 0 );
+ Vec_IntPush( p->vLevReas, Tas_ClsHandle( p, (Tas_Cls_t *)pRes1 ) );
+ }
+ else
+ {
+ Vec_IntPush( p->vLevReas, pRes0 ? pRes0-pObjR : 0 );
+ Vec_IntPush( p->vLevReas, pRes1 ? pRes1-pObjR : 0 );
+ }
+ assert( Vec_IntSize(p->vLevReas) == 3 * p->pProp.iTail );
+ s_Counter2++;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Returns clause size.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Tas_ManClauseSize( Tas_Man_t * p, int hClause )
+{
+ Tas_Que_t * pQue = &(p->pClauses);
+ Gia_Obj_t ** pIter;
+ for ( pIter = pQue->pData + hClause; *pIter; pIter++ );
+ return pIter - pQue->pData - hClause ;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Prints conflict clause.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Tas_ManPrintClause( Tas_Man_t * p, int Level, int hClause )
+{
+ Tas_Que_t * pQue = &(p->pClauses);
+ Gia_Obj_t * pObj;
+ int i;
+ assert( Tas_QueIsEmpty( pQue ) );
+ printf( "Level %2d : ", Level );
+ for ( i = hClause; (pObj = pQue->pData[i]); i++ )
+ printf( "%d=%d(%d) ", Gia_ObjId(p->pAig, pObj), Tas_VarValue(pObj), Tas_VarDecLevel(p, pObj) );
+ printf( "\n" );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Prints conflict clause.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Tas_ManPrintClauseNew( Tas_Man_t * p, int Level, int hClause )
+{
+ Tas_Que_t * pQue = &(p->pClauses);
+ Gia_Obj_t * pObj;
+ int i;
+ assert( Tas_QueIsEmpty( pQue ) );
+ printf( "Level %2d : ", Level );
+ for ( i = hClause; (pObj = pQue->pData[i]); i++ )
+ printf( "%c%d ", Tas_VarValue(pObj)? '+':'-', Gia_ObjId(p->pAig, pObj) );
+ printf( "\n" );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns conflict clause.]
+
+ Description [Performs conflict analysis.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Tas_ManDeriveReason( Tas_Man_t * p, int Level )
+{
+ Tas_Que_t * pQue = &(p->pClauses);
+ Gia_Obj_t * pObj, * pReason;
+ int i, k, j, iLitLevel, iLitLevel2;//, Id;
+ assert( pQue->pData[pQue->iHead] == NULL );
+ assert( pQue->iHead + 1 < pQue->iTail );
+/*
+ for ( i = pQue->iHead + 1; i < pQue->iTail; i++ )
+ {
+ pObj = pQue->pData[i];
+ assert( pObj->fPhase == 0 );
+ }
+*/
+ // compact literals
+ Vec_PtrClear( p->vTemp );
+ for ( i = k = pQue->iHead + 1; i < pQue->iTail; i++ )
+ {
+ pObj = pQue->pData[i];
+ if ( pObj->fPhase ) // unassigned - seen again
+ continue;
+ // assigned - seen first time
+ pObj->fPhase = 1;
+ Vec_PtrPush( p->vTemp, pObj );
+ // bump activity
+// Id = Gia_ObjId( p->pAig, pObj );
+// if ( p->pActivity[Id] == 0.0 )
+// Vec_IntPush( p->vActiveVars, Id );
+// p->pActivity[Id] += p->Pars.VarInc;
+ // check decision level
+ iLitLevel = Tas_VarDecLevel( p, pObj );
+ if ( iLitLevel < Level )
+ {
+ pQue->pData[k++] = pObj;
+ continue;
+ }
+ assert( iLitLevel == Level );
+ if ( Tas_VarHasReasonCls( p, pObj ) )
+ {
+ Tas_Cls_t * pCls = Tas_VarReasonCls( p, pObj );
+ pReason = Gia_ManObj( p->pAig, Gia_Lit2Var(pCls->pLits[0]) );
+ assert( pReason == pObj );
+ for ( j = 1; j < pCls->nLits; j++ )
+ {
+ pReason = Gia_ManObj( p->pAig, Gia_Lit2Var(pCls->pLits[j]) );
+ iLitLevel2 = Tas_VarDecLevel( p, pReason );
+ assert( Tas_VarIsAssigned( pReason ) );
+ assert( !Tas_LitIsTrue( pReason, pCls->pLits[j] ) );
+ Tas_QuePush( pQue, pReason );
+ }
+ }
+ else
+ {
+ pReason = Tas_VarReason0( p, pObj );
+ if ( pReason == pObj ) // no reason
+ {
+ assert( pQue->pData[pQue->iHead] == NULL || Level == 0 );
+ if ( pQue->pData[pQue->iHead] == NULL )
+ pQue->pData[pQue->iHead] = pObj;
+ else
+ Tas_QuePush( pQue, pObj );
+ continue;
+ }
+ Tas_QuePush( pQue, pReason );
+ pReason = Tas_VarReason1( p, pObj );
+ if ( pReason != pObj ) // second reason
+ Tas_QuePush( pQue, pReason );
+ }
+ }
+ assert( pQue->pData[pQue->iHead] != NULL );
+ if ( pQue->pData[pQue->iHead] == NULL )
+ printf( "Tas_ManDeriveReason(): Failed to derive the clause!!!\n" );
+ pQue->iTail = k;
+ // clear the marks
+ Vec_PtrForEachEntry( Gia_Obj_t *, p->vTemp, pObj, i )
+ pObj->fPhase = 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns conflict clause.]
+
+ Description [Performs conflict analysis.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Tas_ManAnalyze( Tas_Man_t * p, int Level, Gia_Obj_t * pVar, Gia_Obj_t * pFan0, Gia_Obj_t * pFan1 )
+{
+ Tas_Que_t * pQue = &(p->pClauses);
+ assert( Tas_VarIsAssigned(pVar) );
+ assert( Tas_VarIsAssigned(pFan0) );
+ assert( pFan1 == NULL || Tas_VarIsAssigned(pFan1) );
+ assert( Tas_QueIsEmpty( pQue ) );
+ Tas_QuePush( pQue, NULL );
+ Tas_QuePush( pQue, pVar );
+ Tas_QuePush( pQue, pFan0 );
+ if ( pFan1 )
+ Tas_QuePush( pQue, pFan1 );
+ Tas_ManDeriveReason( p, Level );
+ return Tas_QueFinish( pQue );
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Performs resolution of two clauses.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Tas_ManResolve( Tas_Man_t * p, int Level, int hClause0, int hClause1 )
+{
+ Tas_Que_t * pQue = &(p->pClauses);
+ Gia_Obj_t * pObj;
+ int i, LevelMax = -1, LevelCur;
+ assert( pQue->pData[hClause0] != NULL );
+ assert( pQue->pData[hClause0] == pQue->pData[hClause1] );
+/*
+ for ( i = hClause0 + 1; (pObj = pQue->pData[i]); i++ )
+ assert( pObj->fPhase == 0 );
+ for ( i = hClause1 + 1; (pObj = pQue->pData[i]); i++ )
+ assert( pObj->fPhase == 0 );
+*/
+ assert( Tas_QueIsEmpty( pQue ) );
+ Tas_QuePush( pQue, NULL );
+ for ( i = hClause0 + 1; (pObj = pQue->pData[i]); i++ )
+ {
+ if ( pObj->fPhase ) // unassigned - seen again
+ continue;
+ // assigned - seen first time
+ pObj->fPhase = 1;
+ Tas_QuePush( pQue, pObj );
+ LevelCur = Tas_VarDecLevel( p, pObj );
+ if ( LevelMax < LevelCur )
+ LevelMax = LevelCur;
+ }
+ for ( i = hClause1 + 1; (pObj = pQue->pData[i]); i++ )
+ {
+ if ( pObj->fPhase ) // unassigned - seen again
+ continue;
+ // assigned - seen first time
+ pObj->fPhase = 1;
+ Tas_QuePush( pQue, pObj );
+ LevelCur = Tas_VarDecLevel( p, pObj );
+ if ( LevelMax < LevelCur )
+ LevelMax = LevelCur;
+ }
+ for ( i = pQue->iHead + 1; i < pQue->iTail; i++ )
+ pQue->pData[i]->fPhase = 0;
+ Tas_ManDeriveReason( p, LevelMax );
+ return Tas_QueFinish( pQue );
+}
+
+
+
+/**Function*************************************************************
+
+ Synopsis [Allocates clause of the given size.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline Tas_Cls_t * Tas_ManAllocCls( Tas_Man_t * p, int nSize )
+{
+ Tas_Cls_t * pCls;
+ if ( p->pStore.iCur + nSize > p->pStore.nSize )
+ {
+ p->pStore.nSize *= 2;
+ p->pStore.pData = ABC_REALLOC( int, p->pStore.pData, p->pStore.nSize );
+ }
+ pCls = Tas_ClsFromHandle( p, p->pStore.iCur ); p->pStore.iCur += nSize;
+ memset( pCls, 0, sizeof(int) * nSize );
+ p->nClauses++;
+ return pCls;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Adds one clause to the watcher list.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Tas_ManWatchClause( Tas_Man_t * p, Tas_Cls_t * pClause, int Lit )
+{
+ assert( Gia_Lit2Var(Lit) < Gia_ManObjNum(p->pAig) );
+ assert( pClause->nLits >= 2 );
+ assert( pClause->pLits[0] == Lit || pClause->pLits[1] == Lit );
+ if ( pClause->pLits[0] == Lit )
+ pClause->iNext[0] = p->pWatches[Gia_LitNot(Lit)];
+ else
+ pClause->iNext[1] = p->pWatches[Gia_LitNot(Lit)];
+ if ( p->pWatches[Gia_LitNot(Lit)] == 0 )
+ Vec_IntPush( p->vWatchLits, Gia_LitNot(Lit) );
+ p->pWatches[Gia_LitNot(Lit)] = Tas_ClsHandle( p, pClause );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates clause of the given size.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline Tas_Cls_t * Tas_ManCreateCls( Tas_Man_t * p, int hClause )
+{
+ Tas_Cls_t * pClause;
+ Tas_Que_t * pQue = &(p->pClauses);
+ Gia_Obj_t * pObj;
+ int i, nLits = 0;
+ assert( Tas_QueIsEmpty( pQue ) );
+ assert( pQue->pData[hClause] != NULL );
+ for ( i = hClause; (pObj = pQue->pData[i]); i++ )
+ nLits++;
+ if ( nLits == 1 )
+ return NULL;
+ // create this clause
+ pClause = Tas_ManAllocCls( p, nLits + 3 );
+ pClause->nLits = nLits;
+ for ( i = hClause; (pObj = pQue->pData[i]); i++ )
+ {
+ assert( Tas_VarIsAssigned( pObj ) );
+ pClause->pLits[i-hClause] = Gia_LitNot( Tas_VarToLit(p, pObj) );
+ }
+ // add the clause as watched one
+ if ( nLits >= 2 )
+ {
+ Tas_ManWatchClause( p, pClause, pClause->pLits[0] );
+ Tas_ManWatchClause( p, pClause, pClause->pLits[1] );
+ }
+ // increment activity
+// p->Pars.VarInc /= p->Pars.VarDecay;
+ return pClause;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates clause of the given size.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Tas_ManCreateFromCls( Tas_Man_t * p, Tas_Cls_t * pCls, int Level )
+{
+ Tas_Que_t * pQue = &(p->pClauses);
+ Gia_Obj_t * pObj;
+ int i;
+ assert( Tas_QueIsEmpty( pQue ) );
+ Tas_QuePush( pQue, NULL );
+ for ( i = 0; i < pCls->nLits; i++ )
+ {
+ pObj = Gia_ManObj( p->pAig, Gia_Lit2Var(pCls->pLits[i]) );
+ assert( Tas_VarIsAssigned(pObj) );
+ assert( !Tas_LitIsTrue( pObj, pCls->pLits[i] ) );
+ Tas_QuePush( pQue, pObj );
+ }
+ Tas_ManDeriveReason( p, Level );
+ return Tas_QueFinish( pQue );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Propagate one assignment.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Tas_ManPropagateWatch( Tas_Man_t * p, int Level, int Lit )
+{
+ Gia_Obj_t * pObj;
+ Tas_Cls_t * pCur;
+ int * piPrev, iCur, iTemp;
+ int i, LitF = Gia_LitNot(Lit);
+ // iterate through the clauses
+ piPrev = p->pWatches + Lit;
+ for ( iCur = p->pWatches[Lit]; iCur; iCur = *piPrev )
+ {
+ pCur = Tas_ClsFromHandle( p, iCur );
+ // make sure the false literal is in the second literal of the clause
+ if ( pCur->pLits[0] == LitF )
+ {
+ pCur->pLits[0] = pCur->pLits[1];
+ pCur->pLits[1] = LitF;
+ iTemp = pCur->iNext[0];
+ pCur->iNext[0] = pCur->iNext[1];
+ pCur->iNext[1] = iTemp;
+ }
+ assert( pCur->pLits[1] == LitF );
+
+ // if the first literal is true, the clause is satisfied
+// if ( pCur->pLits[0] == p->pAssigns[Gia_Lit2Var(pCur->pLits[0])] )
+ pObj = Gia_ManObj( p->pAig, Gia_Lit2Var(pCur->pLits[0]) );
+ if ( Tas_VarIsAssigned(pObj) && Tas_LitIsTrue( pObj, pCur->pLits[0] ) )
+ {
+ piPrev = &pCur->iNext[1];
+ continue;
+ }
+
+ // look for a new literal to watch
+ for ( i = 2; i < (int)pCur->nLits; i++ )
+ {
+ // skip the case when the literal is false
+// if ( Gia_LitNot(pCur->pLits[i]) == p->pAssigns[Gia_Lit2Var(pCur->pLits[i])] )
+ pObj = Gia_ManObj( p->pAig, Gia_Lit2Var(pCur->pLits[i]) );
+ if ( Tas_VarIsAssigned(pObj) && !Tas_LitIsTrue( pObj, pCur->pLits[i] ) )
+ continue;
+ // the literal is either true or unassigned - watch it
+ pCur->pLits[1] = pCur->pLits[i];
+ pCur->pLits[i] = LitF;
+ // remove this clause from the watch list of Lit
+ *piPrev = pCur->iNext[1];
+ // add this clause to the watch list of pCur->pLits[i] (now it is pCur->pLits[1])
+ Tas_ManWatchClause( p, pCur, pCur->pLits[1] );
+ break;
+ }
+ if ( i < (int)pCur->nLits ) // found new watch
+ continue;
+
+ // clause is unit - enqueue new implication
+ pObj = Gia_ManObj( p->pAig, Gia_Lit2Var(pCur->pLits[0]) );
+ if ( !Tas_VarIsAssigned(pObj) )
+ {
+/*
+ {
+ int iLitLevel, iPlace;
+ for ( i = 1; i < (int)pCur->nLits; i++ )
+ {
+ pObj = Gia_ManObj( p->pAig, Gia_Lit2Var(pCur->pLits[i]) );
+ iLitLevel = Tas_VarDecLevel( p, pObj );
+ iPlace = pObj->Value;
+ printf( "Lit = %d. Level = %d. Place = %d.\n", pCur->pLits[i], iLitLevel, iPlace );
+ i = i;
+ }
+ }
+*/
+ Tas_ManAssign( p, Gia_ObjFromLit(p->pAig, pCur->pLits[0]), Level, NULL, (Gia_Obj_t *)pCur );
+ piPrev = &pCur->iNext[1];
+ continue;
+ }
+ // conflict detected - return the conflict clause
+ assert( !Tas_LitIsTrue( pObj, pCur->pLits[0] ) );
+ return Tas_ManCreateFromCls( p, pCur, Level );
+ }
+ return 0;
+}
+
+
+
+/**Function*************************************************************
+
+ Synopsis [Propagates a variable.]
+
+ Description [Returns clause handle if conflict; 0 if no conflict.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Tas_ManPropagateOne( Tas_Man_t * p, Gia_Obj_t * pVar, int Level )
+{
+ int Value0, Value1, hClause;
+ assert( !Gia_IsComplement(pVar) );
+ assert( Tas_VarIsAssigned(pVar) );
+ s_Counter3++;
+ if ( (hClause = Tas_ManPropagateWatch( p, Level, Tas_VarToLit(p, pVar) )) )
+ return hClause;
+ if ( Gia_ObjIsCi(pVar) )
+ return 0;
+/*
+ if ( pVar->iDiff0 == 570869 && pVar->iDiff1 == 546821 && Level == 3 )
+ {
+ Gia_Obj_t * pFan0 = Gia_ObjFanin0(pVar);
+ Gia_Obj_t * pFan1 = Gia_ObjFanin1(pVar);
+ int s = 0;
+ }
+*/
+ assert( Gia_ObjIsAnd(pVar) );
+ Value0 = Tas_VarFanin0Value(pVar);
+ Value1 = Tas_VarFanin1Value(pVar);
+ if ( Tas_VarValue(pVar) )
+ { // value is 1
+ if ( Value0 == 0 || Value1 == 0 ) // one is 0
+ {
+ if ( Value0 == 0 && Value1 != 0 )
+ return Tas_ManAnalyze( p, Level, pVar, Gia_ObjFanin0(pVar), NULL );
+ if ( Value0 != 0 && Value1 == 0 )
+ return Tas_ManAnalyze( p, Level, pVar, Gia_ObjFanin1(pVar), NULL );
+ assert( Value0 == 0 && Value1 == 0 );
+ return Tas_ManAnalyze( p, Level, pVar, Gia_ObjFanin0(pVar), Gia_ObjFanin1(pVar) );
+ }
+ if ( Value0 == 2 ) // first is unassigned
+ Tas_ManAssign( p, Gia_ObjChild0(pVar), Level, pVar, NULL );
+ if ( Value1 == 2 ) // first is unassigned
+ Tas_ManAssign( p, Gia_ObjChild1(pVar), Level, pVar, NULL );
+ return 0;
+ }
+ // value is 0
+ if ( Value0 == 0 || Value1 == 0 ) // one is 0
+ return 0;
+ if ( Value0 == 1 && Value1 == 1 ) // both are 1
+ return Tas_ManAnalyze( p, Level, pVar, Gia_ObjFanin0(pVar), Gia_ObjFanin1(pVar) );
+ if ( Value0 == 1 || Value1 == 1 ) // one is 1
+ {
+ if ( Value0 == 2 ) // first is unassigned
+ Tas_ManAssign( p, Gia_Not(Gia_ObjChild0(pVar)), Level, pVar, Gia_ObjFanin1(pVar) );
+ if ( Value1 == 2 ) // second is unassigned
+ Tas_ManAssign( p, Gia_Not(Gia_ObjChild1(pVar)), Level, pVar, Gia_ObjFanin0(pVar) );
+ return 0;
+ }
+ assert( Tas_VarIsJust(pVar) );
+ assert( !Tas_QueHasNode( &p->pJust, pVar ) );
+ Tas_QuePush( &p->pJust, pVar );
+ return 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Propagates a variable.]
+
+ Description [Returns 1 if conflict; 0 if no conflict.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Tas_ManPropagateTwo( Tas_Man_t * p, Gia_Obj_t * pVar, int Level )
+{
+ int Value0, Value1;
+ s_Counter4++;
+ assert( !Gia_IsComplement(pVar) );
+ assert( Gia_ObjIsAnd(pVar) );
+ assert( Tas_VarIsAssigned(pVar) );
+ assert( !Tas_VarValue(pVar) );
+ Value0 = Tas_VarFanin0Value(pVar);
+ Value1 = Tas_VarFanin1Value(pVar);
+ // value is 0
+ if ( Value0 == 0 || Value1 == 0 ) // one is 0
+ return 0;
+ if ( Value0 == 1 && Value1 == 1 ) // both are 1
+ return Tas_ManAnalyze( p, Level, pVar, Gia_ObjFanin0(pVar), Gia_ObjFanin1(pVar) );
+ assert( Value0 == 1 || Value1 == 1 );
+ if ( Value0 == 2 ) // first is unassigned
+ Tas_ManAssign( p, Gia_Not(Gia_ObjChild0(pVar)), Level, pVar, Gia_ObjFanin1(pVar) );
+ if ( Value1 == 2 ) // first is unassigned
+ Tas_ManAssign( p, Gia_Not(Gia_ObjChild1(pVar)), Level, pVar, Gia_ObjFanin0(pVar) );
+ return 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Propagates all variables.]
+
+ Description [Returns 1 if conflict; 0 if no conflict.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Tas_ManPropagate( Tas_Man_t * p, int Level )
+{
+ int hClause;
+ Gia_Obj_t * pVar;
+ int i, k, nIter = 0;
+ while ( 1 )
+ {
+// nIter++;
+ Tas_QueForEachEntry( p->pProp, pVar, i )
+ {
+ if ( (hClause = Tas_ManPropagateOne( p, pVar, Level )) )
+ return hClause;
+ }
+ p->pProp.iHead = p->pProp.iTail;
+ k = p->pJust.iHead;
+ Tas_QueForEachEntry( p->pJust, pVar, i )
+ {
+ if ( Tas_VarIsJust( pVar ) )
+ p->pJust.pData[k++] = pVar;
+ else if ( (hClause = Tas_ManPropagateTwo( p, pVar, Level )) )
+ return hClause;
+ }
+ if ( k == p->pJust.iTail )
+ break;
+ p->pJust.iTail = k;
+ }
+// printf( "%d ", nIter );
+ return 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Solve the problem recursively.]
+
+ Description [Returns learnt clause if unsat, NULL if sat or undecided.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Tas_ManSolve_rec( Tas_Man_t * p, int Level )
+{
+ Tas_Que_t * pQue = &(p->pClauses);
+ Gia_Obj_t * pVar, * pDecVar;
+ int hClause, hLearn0, hLearn1;
+ int iPropHead, iJustHead, iJustTail;
+ // propagate assignments
+ assert( !Tas_QueIsEmpty(&p->pProp) );
+ if ( (hClause = Tas_ManPropagate( p, Level )) )
+ {
+ Tas_ManCreateCls( p, hClause );
+ return hClause;
+ }
+ // check for satisfying assignment
+ assert( Tas_QueIsEmpty(&p->pProp) );
+ if ( Tas_QueIsEmpty(&p->pJust) )
+ return 0;
+ // quit using resource limits
+ p->Pars.nJustThis = ABC_MAX( p->Pars.nJustThis, p->pJust.iTail - p->pJust.iHead );
+ if ( Tas_ManCheckLimits( p ) )
+ return 0;
+ // remember the state before branching
+ iPropHead = p->pProp.iHead;
+ Tas_QueStore( &p->pJust, &iJustHead, &iJustTail );
+ // find the decision variable
+ if ( p->Pars.fUseActive )
+ pVar = NULL, pDecVar = Tas_ManFindActive( p );
+ else if ( p->Pars.fUseHighest )
+// pVar = NULL, pDecVar = Tas_ManDecideHighestFanin( p );
+ pVar = Tas_ManDecideHighest( p );
+ else if ( p->Pars.fUseLowest )
+ pVar = Tas_ManDecideLowest( p );
+ else if ( p->Pars.fUseMaxFF )
+ pVar = Tas_ManDecideMaxFF( p );
+ else assert( 0 );
+ // chose decision variable using fanout count
+ if ( pVar != NULL )
+ {
+ assert( Tas_VarIsJust( pVar ) );
+ if ( Gia_ObjRefs(p->pAig, Gia_ObjFanin0(pVar)) > Gia_ObjRefs(p->pAig, Gia_ObjFanin1(pVar)) )
+ pDecVar = Gia_Not(Gia_ObjChild0(pVar));
+ else
+ pDecVar = Gia_Not(Gia_ObjChild1(pVar));
+// pDecVar = Gia_NotCond( pDecVar, Gia_Regular(pDecVar)->fMark1 ^ !Gia_IsComplement(pDecVar) );
+ }
+ // decide on first fanin
+ Tas_ManAssign( p, pDecVar, Level+1, NULL, NULL );
+ if ( !(hLearn0 = Tas_ManSolve_rec( p, Level+1 )) )
+ return 0;
+ if ( pQue->pData[hLearn0] != Gia_Regular(pDecVar) )
+ return hLearn0;
+ Tas_ManCancelUntil( p, iPropHead );
+ Tas_QueRestore( &p->pJust, iJustHead, iJustTail );
+ // decide on second fanin
+ Tas_ManAssign( p, Gia_Not(pDecVar), Level+1, NULL, NULL );
+ if ( !(hLearn1 = Tas_ManSolve_rec( p, Level+1 )) )
+ return 0;
+ if ( pQue->pData[hLearn1] != Gia_Regular(pDecVar) )
+ return hLearn1;
+ hClause = Tas_ManResolve( p, Level, hLearn0, hLearn1 );
+ Tas_ManCreateCls( p, hClause );
+// Tas_ManPrintClauseNew( p, Level, hClause );
+// if ( Level > Tas_ClauseDecLevel(p, hClause) )
+// p->Pars.nBTThisNc++;
+ p->Pars.nBTThis++;
+ return hClause;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Looking for a satisfying assignment of the node.]
+
+ Description [Assumes that each node has flag pObj->fMark0 set to 0.
+ Returns 1 if unsatisfiable, 0 if satisfiable, and -1 if undecided.
+ The node may be complemented. ]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Tas_ManSolve( Tas_Man_t * p, Gia_Obj_t * pObj, Gia_Obj_t * pObj2 )
+{
+ int i, Entry, RetValue = 0;
+ s_Counter2 = 0;
+ Vec_IntClear( p->vModel );
+ if ( pObj == Gia_ManConst0(p->pAig) || pObj2 == Gia_ManConst0(p->pAig) || pObj == Gia_Not(pObj2) )
+ return 1;
+ if ( pObj == Gia_ManConst1(p->pAig) && (pObj2 == NULL || pObj2 == Gia_ManConst1(p->pAig)) )
+ return 0;
+ assert( !p->pProp.iHead && !p->pProp.iTail );
+ assert( !p->pJust.iHead && !p->pJust.iTail );
+ assert( p->pClauses.iHead == 1 && p->pClauses.iTail == 1 );
+ p->Pars.nBTThis = p->Pars.nJustThis = p->Pars.nBTThisNc = 0;
+ Tas_ManAssign( p, pObj, 0, NULL, NULL );
+ if ( pObj2 && !Tas_VarIsAssigned(Gia_Regular(pObj2)) )
+ Tas_ManAssign( p, pObj2, 0, NULL, NULL );
+ if ( !Tas_ManSolve_rec(p, 0) && !Tas_ManCheckLimits(p) )
+ Tas_ManSaveModel( p, p->vModel );
+ else
+ RetValue = 1;
+ Tas_ManCancelUntil( p, 0 );
+ p->pJust.iHead = p->pJust.iTail = 0;
+ p->pClauses.iHead = p->pClauses.iTail = 1;
+ // clauses
+ if ( p->nClauses > 0 )
+ {
+ p->pStore.iCur = 16;
+ Vec_IntForEachEntry( p->vWatchLits, Entry, i )
+ p->pWatches[Entry] = 0;
+ Vec_IntClear( p->vWatchLits );
+ p->nClauses = 0;
+ }
+ // activity
+ Vec_IntForEachEntry( p->vActiveVars, Entry, i )
+ p->pActivity[Entry] = 0.0;
+ Vec_IntClear( p->vActiveVars );
+ // statistics
+ p->Pars.nBTTotal += p->Pars.nBTThis;
+ p->Pars.nJustTotal = ABC_MAX( p->Pars.nJustTotal, p->Pars.nJustThis );
+ if ( Tas_ManCheckLimits( p ) )
+ RetValue = -1;
+ return RetValue;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Looking for a satisfying assignment of the node.]
+
+ Description [Assumes that each node has flag pObj->fMark0 set to 0.
+ Returns 1 if unsatisfiable, 0 if satisfiable, and -1 if undecided.
+ The node may be complemented. ]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Tas_ManSolveArray( Tas_Man_t * p, Vec_Ptr_t * vObjs )
+{
+ Gia_Obj_t * pObj;
+ int i, Entry, RetValue = 0;
+ s_Counter2 = 0;
+ s_Counter3 = 0;
+ s_Counter4 = 0;
+ Vec_IntClear( p->vModel );
+ Vec_PtrForEachEntry( Gia_Obj_t *, vObjs, pObj, i )
+ if ( pObj == Gia_ManConst0(p->pAig) )
+ return 1;
+ assert( !p->pProp.iHead && !p->pProp.iTail );
+ assert( !p->pJust.iHead && !p->pJust.iTail );
+ assert( p->pClauses.iHead == 1 && p->pClauses.iTail == 1 );
+ p->Pars.nBTThis = p->Pars.nJustThis = p->Pars.nBTThisNc = 0;
+ Vec_PtrForEachEntry( Gia_Obj_t *, vObjs, pObj, i )
+ if ( pObj != Gia_ManConst1(p->pAig) && !Tas_VarIsAssigned(Gia_Regular(pObj)) )
+ Tas_ManAssign( p, pObj, 0, NULL, NULL );
+ if ( !Tas_ManSolve_rec(p, 0) && !Tas_ManCheckLimits(p) )
+ Tas_ManSaveModel( p, p->vModel );
+ else
+ RetValue = 1;
+ Tas_ManCancelUntil( p, 0 );
+ p->pJust.iHead = p->pJust.iTail = 0;
+ p->pClauses.iHead = p->pClauses.iTail = 1;
+ // clauses
+ if ( p->nClauses > 0 )
+ {
+ p->pStore.iCur = 16;
+ Vec_IntForEachEntry( p->vWatchLits, Entry, i )
+ p->pWatches[Entry] = 0;
+ Vec_IntClear( p->vWatchLits );
+ p->nClauses = 0;
+ }
+ // activity
+ Vec_IntForEachEntry( p->vActiveVars, Entry, i )
+ p->pActivity[Entry] = 0.0;
+ Vec_IntClear( p->vActiveVars );
+ // statistics
+ p->Pars.nBTTotal += p->Pars.nBTThis;
+ p->Pars.nJustTotal = ABC_MAX( p->Pars.nJustTotal, p->Pars.nJustThis );
+ if ( Tas_ManCheckLimits( p ) )
+ RetValue = -1;
+
+// printf( "%d ", Gia_ManObjNum(p->pAig) );
+// printf( "%d ", p->Pars.nBTThis );
+// printf( "%d ", p->Pars.nJustThis );
+// printf( "%d ", s_Counter2 );
+// printf( "%d ", s_Counter3 );
+// printf( "%d ", s_Counter4 );
+ return RetValue;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Prints statistics of the manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Tas_ManSatPrintStats( Tas_Man_t * p )
+{
+ printf( "CO = %8d ", Gia_ManCoNum(p->pAig) );
+ printf( "AND = %8d ", Gia_ManAndNum(p->pAig) );
+ printf( "Conf = %6d ", p->Pars.nBTLimit );
+ printf( "JustMax = %5d ", p->Pars.nJustLimit );
+ printf( "\n" );
+ printf( "Unsat calls %6d (%6.2f %%) Ave conf = %8.1f ",
+ p->nSatUnsat, p->nSatTotal? 100.0*p->nSatUnsat/p->nSatTotal :0.0, p->nSatUnsat? 1.0*p->nConfUnsat/p->nSatUnsat :0.0 );
+ ABC_PRTP( "Time", p->timeSatUnsat, p->timeTotal );
+ printf( "Sat calls %6d (%6.2f %%) Ave conf = %8.1f ",
+ p->nSatSat, p->nSatTotal? 100.0*p->nSatSat/p->nSatTotal :0.0, p->nSatSat? 1.0*p->nConfSat/p->nSatSat : 0.0 );
+ ABC_PRTP( "Time", p->timeSatSat, p->timeTotal );
+ printf( "Undef calls %6d (%6.2f %%) Ave conf = %8.1f ",
+ p->nSatUndec, p->nSatTotal? 100.0*p->nSatUndec/p->nSatTotal :0.0, p->nSatUndec? 1.0*p->nConfUndec/p->nSatUndec : 0.0 );
+ ABC_PRTP( "Time", p->timeSatUndec, p->timeTotal );
+ ABC_PRT( "Total time", p->timeTotal );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Procedure to test the new SAT solver.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Tas_ManSolveMiterNc( Gia_Man_t * pAig, int nConfs, Vec_Str_t ** pvStatus, int fVerbose )
+{
+ extern void Gia_ManCollectTest( Gia_Man_t * pAig );
+ extern void Cec_ManSatAddToStore( Vec_Int_t * vCexStore, Vec_Int_t * vCex, int Out );
+ Tas_Man_t * p;
+ Vec_Int_t * vCex, * vVisit, * vCexStore;
+ Vec_Str_t * vStatus;
+ Gia_Obj_t * pRoot;//, * pRootCopy;
+// Gia_Man_t * pAigCopy = Gia_ManDup( pAig ), * pAigTemp;
+
+ int i, status, clk, clkTotal = clock();
+ assert( Gia_ManRegNum(pAig) == 0 );
+// Gia_ManCollectTest( pAig );
+ // prepare AIG
+ Gia_ManCreateRefs( pAig );
+ Gia_ManCleanMark0( pAig );
+ Gia_ManCleanMark1( pAig );
+ Gia_ManFillValue( pAig ); // maps nodes into trail ids
+ Gia_ManCleanPhase( pAig ); // maps nodes into trail ids
+ // create logic network
+ p = Tas_ManAlloc( pAig, nConfs );
+ p->pAig = pAig;
+ // create resulting data-structures
+ vStatus = Vec_StrAlloc( Gia_ManPoNum(pAig) );
+ vCexStore = Vec_IntAlloc( 10000 );
+ vVisit = Vec_IntAlloc( 100 );
+ vCex = Tas_ReadModel( p );
+ // solve for each output
+ Gia_ManForEachCo( pAig, pRoot, i )
+ {
+// printf( "%d=", i );
+
+ Vec_IntClear( vCex );
+ if ( Gia_ObjIsConst0(Gia_ObjFanin0(pRoot)) )
+ {
+ if ( Gia_ObjFaninC0(pRoot) )
+ {
+// printf( "Constant 1 output of SRM!!!\n" );
+ Cec_ManSatAddToStore( vCexStore, vCex, i ); // trivial counter-example
+ Vec_StrPush( vStatus, 0 );
+ }
+ else
+ {
+// printf( "Constant 0 output of SRM!!!\n" );
+ Vec_StrPush( vStatus, 1 );
+ }
+ continue;
+ }
+ clk = clock();
+// p->Pars.fUseActive = 1;
+ p->Pars.fUseHighest = 1;
+ p->Pars.fUseLowest = 0;
+ status = Tas_ManSolve( p, Gia_ObjChild0(pRoot), NULL );
+// printf( "\n" );
+/*
+ if ( status == -1 )
+ {
+ p->Pars.fUseHighest = 0;
+ p->Pars.fUseLowest = 1;
+ status = Tas_ManSolve( p, Gia_ObjChild0(pRoot) );
+ }
+*/
+ Vec_StrPush( vStatus, (char)status );
+ if ( status == -1 )
+ {
+// printf( "Unsolved %d.\n", i );
+
+ p->nSatUndec++;
+ p->nConfUndec += p->Pars.nBTThis;
+ Cec_ManSatAddToStore( vCexStore, NULL, i ); // timeout
+ p->timeSatUndec += clock() - clk;
+ continue;
+ }
+
+// pRootCopy = Gia_ManCo( pAigCopy, i );
+// pRootCopy->iDiff0 = Gia_ObjId( pAigCopy, pRootCopy );
+// pRootCopy->fCompl0 = 0;
+
+ if ( status == 1 )
+ {
+ p->nSatUnsat++;
+ p->nConfUnsat += p->Pars.nBTThis;
+ p->timeSatUnsat += clock() - clk;
+ continue;
+ }
+ p->nSatSat++;
+ p->nConfSat += p->Pars.nBTThis;
+// Gia_SatVerifyPattern( pAig, pRoot, vCex, vVisit );
+ Cec_ManSatAddToStore( vCexStore, vCex, i );
+ p->timeSatSat += clock() - clk;
+
+// printf( "%d ", Vec_IntSize(vCex) );
+ }
+// pAigCopy = Gia_ManCleanup( pAigTemp = pAigCopy );
+// Gia_ManStop( pAigTemp );
+// Gia_DumpAiger( pAigCopy, "test", 0, 2 );
+// Gia_ManStop( pAigCopy );
+
+ Vec_IntFree( vVisit );
+ p->nSatTotal = Gia_ManPoNum(pAig);
+ p->timeTotal = clock() - clkTotal;
+ if ( fVerbose )
+ Tas_ManSatPrintStats( p );
+// printf( "RecCalls = %8d. RecClause = %8d. RecNonChro = %8d.\n", p->nRecCall, p->nRecClause, p->nRecNonChro );
+ Tas_ManStop( p );
+ *pvStatus = vStatus;
+
+// printf( "Total number of cex literals = %d. (Ave = %d)\n",
+// Vec_IntSize(vCexStore)-2*p->nSatUndec-2*p->nSatSat,
+// (Vec_IntSize(vCexStore)-2*p->nSatUndec-2*p->nSatSat)/p->nSatSat );
+ return vCexStore;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Packs patterns into array of simulation info.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+*************************************`**********************************/
+int Tas_StorePatternTry( Vec_Ptr_t * vInfo, Vec_Ptr_t * vPres, int iBit, int * pLits, int nLits )
+{
+ unsigned * pInfo, * pPres;
+ int i;
+ for ( i = 0; i < nLits; i++ )
+ {
+ pInfo = (unsigned *)Vec_PtrEntry(vInfo, Gia_Lit2Var(pLits[i]));
+ pPres = (unsigned *)Vec_PtrEntry(vPres, Gia_Lit2Var(pLits[i]));
+ if ( Gia_InfoHasBit( pPres, iBit ) &&
+ Gia_InfoHasBit( pInfo, iBit ) == Gia_LitIsCompl(pLits[i]) )
+ return 0;
+ }
+ for ( i = 0; i < nLits; i++ )
+ {
+ pInfo = (unsigned *)Vec_PtrEntry(vInfo, Gia_Lit2Var(pLits[i]));
+ pPres = (unsigned *)Vec_PtrEntry(vPres, Gia_Lit2Var(pLits[i]));
+ Gia_InfoSetBit( pPres, iBit );
+ if ( Gia_InfoHasBit( pInfo, iBit ) == Gia_LitIsCompl(pLits[i]) )
+ Gia_InfoXorBit( pInfo, iBit );
+ }
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Procedure to test the new SAT solver.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Tas_StorePattern( Vec_Ptr_t * vSimInfo, Vec_Ptr_t * vPres, Vec_Int_t * vCex )
+{
+ int k;
+ for ( k = 1; k < 32; k++ )
+ if ( Tas_StorePatternTry( vSimInfo, vPres, k, (int *)Vec_IntArray(vCex), Vec_IntSize(vCex) ) )
+ break;
+ return (int)(k < 32);
+}
+
+/**Function*************************************************************
+
+ Synopsis [Procedure to test the new SAT solver.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Tas_ManSolveMiterNc2( Gia_Man_t * pAig, int nConfs, Gia_Man_t * pAigOld, Vec_Ptr_t * vOldRoots, Vec_Ptr_t * vSimInfo )
+{
+ int nPatMax = 1000;
+ int fVerbose = 1;
+ extern void Gia_ManCollectTest( Gia_Man_t * pAig );
+ extern void Cec_ManSatAddToStore( Vec_Int_t * vCexStore, Vec_Int_t * vCex, int Out );
+ Tas_Man_t * p;
+ Vec_Ptr_t * vPres;
+ Vec_Int_t * vCex, * vVisit, * vCexStore;
+ Vec_Str_t * vStatus;
+ Gia_Obj_t * pRoot, * pOldRoot;
+ int i, status, clk, clkTotal = clock();
+ int Tried = 0, Stored = 0, Step = Gia_ManCoNum(pAig) / nPatMax;
+ assert( Gia_ManRegNum(pAig) == 0 );
+// Gia_ManCollectTest( pAig );
+ // prepare AIG
+ Gia_ManCreateRefs( pAig );
+ Gia_ManCleanMark0( pAig );
+ Gia_ManCleanMark1( pAig );
+ Gia_ManFillValue( pAig ); // maps nodes into trail ids
+ Gia_ManCleanPhase( pAig ); // maps nodes into trail ids
+ // create logic network
+ p = Tas_ManAlloc( pAig, nConfs );
+ p->pAig = pAig;
+ // create resulting data-structures
+ vStatus = Vec_StrAlloc( Gia_ManPoNum(pAig) );
+ vCexStore = Vec_IntAlloc( 10000 );
+ vVisit = Vec_IntAlloc( 100 );
+ vCex = Tas_ReadModel( p );
+ // solve for each output
+ vPres = Vec_PtrAllocSimInfo( Gia_ManCiNum(pAig), 1 );
+ Vec_PtrCleanSimInfo( vPres, 0, 1 );
+
+ Gia_ManForEachCo( pAig, pRoot, i )
+ {
+ assert( !Gia_ObjIsConst0(Gia_ObjFanin0(pRoot)) );
+ Vec_IntClear( vCex );
+ clk = clock();
+ p->Pars.fUseHighest = 1;
+ p->Pars.fUseLowest = 0;
+ status = Tas_ManSolve( p, Gia_ObjChild0(pRoot), NULL );
+ Vec_StrPush( vStatus, (char)status );
+ if ( status == -1 )
+ {
+ p->nSatUndec++;
+ p->nConfUndec += p->Pars.nBTThis;
+// Cec_ManSatAddToStore( vCexStore, NULL, i ); // timeout
+ p->timeSatUndec += clock() - clk;
+
+ i += Step;
+ continue;
+ }
+ if ( status == 1 )
+ {
+ p->nSatUnsat++;
+ p->nConfUnsat += p->Pars.nBTThis;
+ p->timeSatUnsat += clock() - clk;
+ // record proved
+ pOldRoot = (Gia_Obj_t *)Vec_PtrEntry( vOldRoots, i );
+ assert( !Gia_ObjProved( pAigOld, Gia_ObjId(pAigOld, pOldRoot) ) );
+ Gia_ObjSetProved( pAigOld, Gia_ObjId(pAigOld, pOldRoot) );
+
+ i += Step;
+ continue;
+ }
+ p->nSatSat++;
+ p->nConfSat += p->Pars.nBTThis;
+// Gia_SatVerifyPattern( pAig, pRoot, vCex, vVisit );
+// Cec_ManSatAddToStore( vCexStore, vCex, i );
+
+ // save pattern
+ Tried++;
+ Stored += Tas_StorePattern( vSimInfo, vPres, vCex );
+ p->timeSatSat += clock() - clk;
+ i += Step;
+ }
+ printf( "Tried = %d Stored = %d\n", Tried, Stored );
+ Vec_IntFree( vVisit );
+ p->nSatTotal = Gia_ManPoNum(pAig);
+ p->timeTotal = clock() - clkTotal;
+ if ( fVerbose )
+ Tas_ManSatPrintStats( p );
+ Tas_ManStop( p );
+ Vec_PtrFree( vPres );
+}
+
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaCTas2.c b/src/aig/gia/giaCTas2.c
new file mode 100644
index 00000000..855dcdd3
--- /dev/null
+++ b/src/aig/gia/giaCTas2.c
@@ -0,0 +1,208 @@
+/**CFile****************************************************************
+
+ FileName [giaCSat2.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Scalable AIG package.]
+
+ Synopsis [Circuit-based SAT solver.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: giaCSat2.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+typedef struct Tas_Par_t_ Tas_Par_t;
+struct Tas_Par_t_
+{
+ // conflict limits
+ int nBTLimit; // limit on the number of conflicts
+ // current parameters
+ int nBTThis; // number of conflicts
+ int nBTTotal; // total number of conflicts
+ // decision heuristics
+ int fUseHighest; // use node with the highest ID
+ // other parameters
+ int fVerbose;
+};
+
+typedef struct Tas_Sto_t_ Tas_Sto_t;
+struct Tas_Sto_t_
+{
+ int iCur; // currently used
+ int nSize; // allocated size
+ char * pBuffer; // handles of objects stored in the queue
+};
+
+typedef struct Tas_Que_t_ Tas_Que_t;
+struct Tas_Que_t_
+{
+ int iHead; // beginning of the queue
+ int iTail; // end of the queue
+ int nSize; // allocated size
+ int * pData; // handles of objects stored in the queue
+};
+
+typedef struct Tas_Var_t_ Tas_Var_t;
+struct Tas_Var_t_
+{
+ unsigned fTerm : 1; // terminal node
+ unsigned fVal : 1; // current value
+ unsigned fValOld : 1; // previous value
+ unsigned fAssign : 1; // assigned status
+ unsigned fJQueue : 1; // part of J-frontier
+ unsigned fCompl0 : 1; // complemented attribute
+ unsigned fCompl1 : 1; // complemented attribute
+ unsigned fMark0 : 1; // multi-purpose mark
+ unsigned fMark1 : 1; // multi-purpose mark
+ unsigned fPhase : 1; // polarity
+ unsigned Level : 22; // decision level
+ int Id; // unique ID of this variable
+ int IdAig; // original ID of this variable
+ int Reason0; // reason of this variable
+ int Reason1; // reason of this variable
+ int Diff0; // difference for the first fanin
+ int Diff1; // difference for the second fanin
+ int Watch0; // handle of first watch
+ int Watch1; // handle of second watch
+};
+
+typedef struct Tas_Cls_t_ Tas_Cls_t;
+struct Tas_Cls_t_
+{
+ int Watch0; // next clause to watch
+ int Watch1; // next clause to watch
+ int pVars[0]; // variable handles
+};
+
+typedef struct Tas_Man_t_ Tas_Man_t;
+struct Tas_Man_t_
+{
+ // user data
+ Gia_Man_t * pAig; // AIG manager
+ Tas_Par_t Pars; // parameters
+ // solver data
+ Tas_Sto_t * pVars; // variables
+ Tas_Sto_t * pClauses; // clauses
+ // state representation
+ Tas_Que_t pProp; // propagation queue
+ Tas_Que_t pJust; // justification queue
+ Vec_Int_t * vModel; // satisfying assignment
+ Vec_Ptr_t * vTemp; // temporary storage
+ // SAT calls statistics
+ int nSatUnsat; // the number of proofs
+ int nSatSat; // the number of failure
+ int nSatUndec; // the number of timeouts
+ int nSatTotal; // the number of calls
+ // conflicts
+ int nConfUnsat; // conflicts in unsat problems
+ int nConfSat; // conflicts in sat problems
+ int nConfUndec; // conflicts in undec problems
+ int nConfTotal; // total conflicts
+ // runtime stats
+ int timeSatUnsat; // unsat
+ int timeSatSat; // sat
+ int timeSatUndec; // undecided
+ int timeTotal; // total runtime
+};
+
+static inline int Tas_VarIsAssigned( Tas_Var_t * pVar ) { return pVar->fAssign; }
+static inline void Tas_VarAssign( Tas_Var_t * pVar ) { assert(!pVar->fAssign); pVar->fAssign = 1; }
+static inline void Tas_VarUnassign( Tas_Var_t * pVar ) { assert(pVar->fAssign); pVar->fAssign = 0; pVar->fVal = 0; }
+static inline int Tas_VarValue( Tas_Var_t * pVar ) { assert(pVar->fAssign); return pVar->fVal; }
+static inline void Tas_VarSetValue( Tas_Var_t * pVar, int v ) { assert(pVar->fAssign); pVar->fVal = v; }
+static inline int Tas_VarIsJust( Tas_Var_t * pVar ) { return Gia_ObjIsAnd(pVar) && !Tas_VarIsAssigned(Gia_ObjFanin0(pVar)) && !Tas_VarIsAssigned(Gia_ObjFanin1(pVar)); }
+static inline int Tas_VarFanin0Value( Tas_Var_t * pVar ) { return !Tas_VarIsAssigned(Gia_ObjFanin0(pVar)) ? 2 : (Tas_VarValue(Gia_ObjFanin0(pVar)) ^ Gia_ObjFaninC0(pVar)); }
+static inline int Tas_VarFanin1Value( Tas_Var_t * pVar ) { return !Tas_VarIsAssigned(Gia_ObjFanin1(pVar)) ? 2 : (Tas_VarValue(Gia_ObjFanin1(pVar)) ^ Gia_ObjFaninC1(pVar)); }
+
+static inline int Tas_VarDecLevel( Tas_Man_t * p, Tas_Var_t * pVar ) { assert( pVar->Value != ~0 ); return Vec_IntEntry(p->vLevReas, 3*pVar->Value); }
+static inline Tas_Var_t * Tas_VarReason0( Tas_Man_t * p, Tas_Var_t * pVar ) { assert( pVar->Value != ~0 ); return pVar + Vec_IntEntry(p->vLevReas, 3*pVar->Value+1); }
+static inline Tas_Var_t * Tas_VarReason1( Tas_Man_t * p, Tas_Var_t * pVar ) { assert( pVar->Value != ~0 ); return pVar + Vec_IntEntry(p->vLevReas, 3*pVar->Value+2); }
+static inline int Tas_ClauseDecLevel( Tas_Man_t * p, int hClause ) { return Tas_VarDecLevel( p, p->pClauses.pData[hClause] ); }
+
+static inline Tas_Var_t * Tas_ManVar( Tas_Man_t * p, int h ) { return (Tas_Var_t *)(p->pVars->pBuffer + h); }
+static inline Tas_Cls_t * Tas_ManClause( Tas_Man_t * p, int h ) { return (Tas_Cls_t *)(p->pClauses->pBuffer + h); }
+
+#define Tas_ClaForEachVar( p, pClause, pVar, i ) \
+ for ( pVar = Tas_ManVar(p, pClause->pVars[(i=0)]); pClause->pVars[i]; pVar = (Tas_Var_t *)(((char *)pVar + pClause->pVars[++i])) )
+
+#define Tas_QueForEachVar( p, pQue, pVar, i ) \
+ for ( pVar = Tas_ManVar(p, pQue->pVars[(i=pQue->iHead)]); i < pQue->iTail; pVar = Tas_ManVar(p, pQue->pVars[i++]) )
+
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Tas_Var_t * Tas_ManCreateVar( Tas_Man_t * p )
+{
+ Tas_Var_t * pVar;
+ if ( p->pVars->iCur + sizeof(Tas_Var_t) > p->pVars->nSize )
+ {
+ p->pVars->nSize *= 2;
+ p->pVars->pData = ABC_REALLOC( char, p->pVars->pData, p->pVars->nSize );
+ }
+ pVar = p->pVars->pData + p->pVars->iCur;
+ p->pVars->iCur += sizeof(Tas_Var_t);
+ memset( pVar, 0, sizeof(Tas_Var_t) );
+ pVar->Id = pVar - ((Tas_Var_t *)p->pVars->pData);
+ return pVar;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Tas_Var_t * Tas_ManObj2Var( Tas_Man_t * p, Gia_Obj_t * pObj )
+{
+ Tas_Var_t * pVar;
+ assert( !Gia_ObjIsComplement(pObj) );
+ if ( pObj->Value == 0 )
+ {
+ pVar = Tas_ManCreateVar( p );
+ pVar->
+
+ }
+ return Tas_ManVar( p, pObj->Value );
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaCof.c b/src/aig/gia/giaCof.c
index da48c1b0..5a04d9d3 100644
--- a/src/aig/gia/giaCof.c
+++ b/src/aig/gia/giaCof.c
@@ -21,6 +21,9 @@
#include <math.h>
#include "gia.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -390,7 +393,7 @@ void Cof_ManInsertEntry_rec( Vec_Ptr_t * vNodes, Cof_Obj_t * pNode, int nNodeMax
Vec_PtrPush(vNodes, pNode);
return;
}
- pLast = Vec_PtrPop(vNodes);
+ pLast = (Cof_Obj_t *)Vec_PtrPop(vNodes);
if ( Cof_ObjFanoutNum(pLast) < Cof_ObjFanoutNum(pNode) )
{
Cof_ManInsertEntry_rec( vNodes, pNode, nNodeMax );
@@ -541,7 +544,7 @@ void Cof_ManPrintHighFanout( Cof_Man_t * p, int nNodes )
Cof_Obj_t * pObj;
int i;
vNodes = Cof_ManCollectHighFanout( p, nNodes );
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Cof_Obj_t *, vNodes, pObj, i )
Cof_ManPrintHighFanoutOne( p, pObj );
Vec_PtrFree( vNodes );
}
@@ -633,7 +636,7 @@ void Cof_ManPrintFanio( Cof_Man_t * p )
printf( "%15d : ", k );
else
{
- sprintf( Buffer, "%d - %d", (int)pow(10, k/10) * (k%10), (int)pow(10, k/10) * (k%10+1) - 1 );
+ sprintf( Buffer, "%d - %d", (int)pow((double)10, k/10) * (k%10), (int)pow((double)10, k/10) * (k%10+1) - 1 );
printf( "%15s : ", Buffer );
}
if ( vFanins->pArray[k] == 0 )
@@ -916,3 +919,5 @@ Gia_Man_t * Gia_ManDupCofAll( Gia_Man_t * p, int nFanLim, int fVerbose )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaConstr.c b/src/aig/gia/giaConstr.c
index 14768cc2..60432072 100644
--- a/src/aig/gia/giaConstr.c
+++ b/src/aig/gia/giaConstr.c
@@ -20,6 +20,9 @@
#include "gia.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -45,3 +48,5 @@
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaDfs.c b/src/aig/gia/giaDfs.c
index bcc1748f..3b591aee 100644
--- a/src/aig/gia/giaDfs.c
+++ b/src/aig/gia/giaDfs.c
@@ -20,6 +20,9 @@
#include "gia.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -136,6 +139,63 @@ void Gia_ManCollectAnds( Gia_Man_t * p, int * pNodes, int nNodes, Vec_Int_t * vN
/**Function*************************************************************
+ Synopsis [Counts the support size of the node.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManCollectNodesCis_rec( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vNodes )
+{
+ if ( Gia_ObjIsTravIdCurrent(p, pObj) )
+ return;
+ Gia_ObjSetTravIdCurrent(p, pObj);
+ if ( Gia_ObjIsCi(pObj) )
+ {
+ Vec_IntPush( vNodes, Gia_ObjId(p, pObj) );
+ return;
+ }
+ assert( Gia_ObjIsAnd(pObj) );
+ Gia_ManCollectNodesCis_rec( p, Gia_ObjFanin0(pObj), vNodes );
+ Gia_ManCollectNodesCis_rec( p, Gia_ObjFanin1(pObj), vNodes );
+ Vec_IntPush( vNodes, Gia_ObjId(p, pObj) );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Collects support nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Gia_ManCollectNodesCis( Gia_Man_t * p, int * pNodes, int nNodes )
+{
+ Vec_Int_t * vNodes;
+ Gia_Obj_t * pObj;
+ int i;
+ vNodes = Vec_IntAlloc( 10000 );
+ Gia_ManIncrementTravId( p );
+ Gia_ObjSetTravIdCurrent( p, Gia_ManConst0(p) );
+ for ( i = 0; i < nNodes; i++ )
+ {
+ pObj = Gia_ManObj( p, pNodes[i] );
+ if ( Gia_ObjIsCo(pObj) )
+ Gia_ManCollectNodesCis_rec( p, Gia_ObjFanin0(pObj), vNodes );
+ else
+ Gia_ManCollectNodesCis_rec( p, pObj, vNodes );
+ }
+ return vNodes;
+}
+
+/**Function*************************************************************
+
Synopsis [Collects support nodes.]
Description []
@@ -151,7 +211,6 @@ void Gia_ManCollectTest( Gia_Man_t * p )
Gia_Obj_t * pObj;
int i, iNode, clk = clock();
vNodes = Vec_IntAlloc( 100 );
- Gia_ManResetTravId( p );
Gia_ManIncrementTravId( p );
Gia_ManForEachCo( p, pObj, i )
{
@@ -276,7 +335,7 @@ int Gia_ManConeSize( Gia_Man_t * p, int * pNodes, int nNodes )
***********************************************************************/
Vec_Vec_t * Gia_ManLevelize( Gia_Man_t * p )
-{
+{
Gia_Obj_t * pObj;
Vec_Vec_t * vLevels;
int nLevels, Level, i;
@@ -291,8 +350,49 @@ Vec_Vec_t * Gia_ManLevelize( Gia_Man_t * p )
return vLevels;
}
+/**Function*************************************************************
+
+ Synopsis [Computes reverse topological order.]
+
+ Description [Assumes that levels are already assigned.
+ The levels of CO nodes may not be assigned.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Gia_ManOrderReverse( Gia_Man_t * p )
+{
+ Gia_Obj_t * pObj;
+ Vec_Vec_t * vLevels;
+ Vec_Ptr_t * vLevel;
+ Vec_Int_t * vResult;
+ int i, k;
+ vLevels = Vec_VecStart( 100 );
+ // make sure levels are assigned
+ Gia_ManForEachAnd( p, pObj, i )
+ assert( Gia_ObjLevel(p, pObj) > 0 );
+ // add CO nodes based on the level of their fanin
+ Gia_ManForEachCo( p, pObj, i )
+ Vec_VecPush( vLevels, Gia_ObjLevel(p, Gia_ObjFanin0(pObj)), pObj );
+ // add other nodes based on their level
+ Gia_ManForEachObj( p, pObj, i )
+ if ( !Gia_ObjIsCo(pObj) )
+ Vec_VecPush( vLevels, Gia_ObjLevel(p, pObj), pObj );
+ // put the nodes in the reverse topological order
+ vResult = Vec_IntAlloc( Gia_ManObjNum(p) );
+ Vec_VecForEachLevelReverse( vLevels, vLevel, i )
+ Vec_PtrForEachEntry( Gia_Obj_t *, vLevel, pObj, k )
+ Vec_IntPush( vResult, Gia_ObjId(p, pObj) );
+ Vec_VecFree( vLevels );
+ return vResult;
+}
+
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaDup.c b/src/aig/gia/giaDup.c
index cde19a22..4ded9a78 100644
--- a/src/aig/gia/giaDup.c
+++ b/src/aig/gia/giaDup.c
@@ -20,6 +20,9 @@
#include "gia.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -143,6 +146,8 @@ int Gia_ManDupOrderDfs_rec( Gia_Man_t * pNew, Gia_Man_t * p, Gia_Obj_t * pObj )
return pObj->Value;
if ( Gia_ObjIsCi(pObj) )
return pObj->Value = Gia_ManAppendCi(pNew);
+// if ( p->pNexts && Gia_ObjNext(p, Gia_ObjId(p, pObj)) )
+// Gia_ManDupOrderDfs_rec( pNew, p, Gia_ObjNextObj(p, Gia_ObjId(p, pObj)) );
Gia_ManDupOrderDfs_rec( pNew, p, Gia_ObjFanin0(pObj) );
if ( Gia_ObjIsCo(pObj) )
return pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
@@ -193,6 +198,98 @@ Gia_Man_t * Gia_ManDupOrderDfs( Gia_Man_t * p )
SeeAlso []
***********************************************************************/
+Gia_Man_t * Gia_ManDupOutputGroup( Gia_Man_t * p, int iOutStart, int iOutStop )
+{
+ Gia_Man_t * pNew;
+ Gia_Obj_t * pObj;
+ int i;
+ Gia_ManFillValue( p );
+ pNew = Gia_ManStart( Gia_ManObjNum(p) );
+ pNew->pName = Gia_UtilStrsav( p->pName );
+ Gia_ManConst0(p)->Value = 0;
+ for ( i = iOutStart; i < iOutStop; i++ )
+ {
+ pObj = Gia_ManCo( p, i );
+ Gia_ManDupOrderDfs_rec( pNew, p, pObj );
+ }
+ return pNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Duplicates the AIG in the DFS order.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManDupOrderDfsChoices_rec( Gia_Man_t * pNew, Gia_Man_t * p, Gia_Obj_t * pObj )
+{
+ Gia_Obj_t * pNext;
+ if ( ~pObj->Value )
+ return;
+ assert( Gia_ObjIsAnd(pObj) );
+ pNext = Gia_ObjNextObj( p, Gia_ObjId(p, pObj) );
+ if ( pNext )
+ Gia_ManDupOrderDfsChoices_rec( pNew, p, pNext );
+ Gia_ManDupOrderDfsChoices_rec( pNew, p, Gia_ObjFanin0(pObj) );
+ Gia_ManDupOrderDfsChoices_rec( pNew, p, Gia_ObjFanin1(pObj) );
+ pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+ if ( pNext )
+ {
+ pNew->pNexts[Gia_Lit2Var(pObj->Value)] = Gia_Lit2Var( Gia_Lit2Var(pNext->Value) );
+ assert( Gia_Lit2Var(pObj->Value) > Gia_Lit2Var(pNext->Value) );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Duplicates AIG while putting objects in the DFS order.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManDupOrderDfsChoices( Gia_Man_t * p )
+{
+ Gia_Man_t * pNew;
+ Gia_Obj_t * pObj;
+ int i;
+ assert( p->pReprs && p->pNexts );
+ Gia_ManFillValue( p );
+ pNew = Gia_ManStart( Gia_ManObjNum(p) );
+ pNew->pName = Gia_UtilStrsav( p->pName );
+ pNew->pNexts = ABC_CALLOC( int, Gia_ManObjNum(p) );
+ Gia_ManConst0(p)->Value = 0;
+ Gia_ManForEachCi( p, pObj, i )
+ pObj->Value = Gia_ManAppendCi(pNew);
+ Gia_ManForEachCo( p, pObj, i )
+ {
+ Gia_ManDupOrderDfsChoices_rec( pNew, p, Gia_ObjFanin0(pObj) );
+ pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
+ }
+ Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
+// Gia_ManDeriveReprs( pNew );
+ return pNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Duplicates AIG while putting objects in the DFS order.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
Gia_Man_t * Gia_ManDupOrderDfsReverse( Gia_Man_t * p )
{
Gia_Man_t * pNew;
@@ -274,13 +371,13 @@ Gia_Man_t * Gia_ManDupFlip( Gia_Man_t * p, int * pInitState )
{
pObj->Value = Gia_ManAppendCi( pNew );
if ( Gia_ObjCioId(pObj) >= Gia_ManPiNum(p) )
- pObj->Value = Gia_LitNotCond( pObj->Value, Gia_InfoHasBit(pInitState, Gia_ObjCioId(pObj) - Gia_ManPiNum(p)) );
+ pObj->Value = Gia_LitNotCond( pObj->Value, Gia_InfoHasBit((unsigned *)pInitState, Gia_ObjCioId(pObj) - Gia_ManPiNum(p)) );
}
else if ( Gia_ObjIsCo(pObj) )
{
pObj->Value = Gia_ObjFanin0Copy(pObj);
if ( Gia_ObjCioId(pObj) >= Gia_ManPoNum(p) )
- pObj->Value = Gia_LitNotCond( pObj->Value, Gia_InfoHasBit(pInitState, Gia_ObjCioId(pObj) - Gia_ManPoNum(p)) );
+ pObj->Value = Gia_LitNotCond( pObj->Value, Gia_InfoHasBit((unsigned *)pInitState, Gia_ObjCioId(pObj) - Gia_ManPoNum(p)) );
pObj->Value = Gia_ManAppendCo( pNew, pObj->Value );
}
}
@@ -318,6 +415,8 @@ Gia_Man_t * Gia_ManDup( Gia_Man_t * p )
pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
}
Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
+ if ( p->pCexSeq )
+ pNew->pCexSeq = Gia_ManDupCounterExample( p->pCexSeq, Gia_ManRegNum(p) );
return pNew;
}
@@ -664,6 +763,8 @@ Gia_Man_t * Gia_ManDupDfs( Gia_Man_t * p )
Gia_ManForEachCo( p, pObj, i )
Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
+ if ( p->pCexSeq )
+ pNew->pCexSeq = Gia_ManDupCounterExample( p->pCexSeq, Gia_ManRegNum(p) );
return pNew;
}
@@ -719,7 +820,8 @@ Gia_Man_t * Gia_ManDupDfsCone( Gia_Man_t * p, Gia_Obj_t * pRoot )
Gia_ManConst0(p)->Value = 0;
Gia_ManForEachCi( p, pObj, i )
pObj->Value = Gia_ManAppendCi(pNew);
- Gia_ManDupDfs_rec( pNew, p, pRoot );
+ Gia_ManDupDfs_rec( pNew, p, Gia_ObjFanin0(pRoot) );
+ Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pRoot) );
Gia_ManSetRegNum( pNew, 0 );
return pNew;
}
@@ -820,6 +922,49 @@ Gia_Man_t * Gia_ManDupTrimmed( Gia_Man_t * p, int fTrimCis, int fTrimCos )
/**Function*************************************************************
+ Synopsis [Duplicates AIG in the DFS order while putting CIs first.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManDupOntop( Gia_Man_t * p, Gia_Man_t * p2 )
+{
+ Gia_Man_t * pTemp, * pNew;
+ Gia_Obj_t * pObj;
+ int i;
+ assert( Gia_ManPoNum(p) == Gia_ManPiNum(p2) );
+ assert( Gia_ManRegNum(p) == 0 );
+ assert( Gia_ManRegNum(p2) == 0 );
+ pNew = Gia_ManStart( Gia_ManObjNum(p)+Gia_ManObjNum(p2) );
+ pNew->pName = Gia_UtilStrsav( p->pName );
+ Gia_ManHashAlloc( pNew );
+ // dup first AIG
+ Gia_ManConst0(p)->Value = 0;
+ Gia_ManForEachCi( p, pObj, i )
+ pObj->Value = Gia_ManAppendCi(pNew);
+ Gia_ManForEachAnd( p, pObj, i )
+ pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+ // dup second AIG
+ Gia_ManConst0(p2)->Value = 0;
+ Gia_ManForEachCo( p, pObj, i )
+ Gia_ManPi(p2, i)->Value = Gia_ObjFanin0Copy(pObj);
+ Gia_ManForEachAnd( p2, pObj, i )
+ pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+ Gia_ManForEachCo( p2, pObj, i )
+ pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
+ Gia_ManHashStop( pNew );
+// Gia_ManPrintStats( pGiaNew, 0 );
+ pNew = Gia_ManCleanup( pTemp = pNew );
+ Gia_ManStop( pTemp );
+ return pNew;
+}
+
+/**Function*************************************************************
+
Synopsis [Print representatives.]
Description []
@@ -1243,8 +1388,84 @@ Gia_Man_t * Gia_ManTransformMiter( Gia_Man_t * p )
return pNew;
}
+/**Function*************************************************************
+
+ Synopsis [Duplicates the AIG in the DFS order.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManChoiceMiter_rec( Gia_Man_t * pNew, Gia_Man_t * p, Gia_Obj_t * pObj )
+{
+ if ( ~pObj->Value )
+ return pObj->Value;
+ Gia_ManChoiceMiter_rec( pNew, p, Gia_ObjFanin0(pObj) );
+ if ( Gia_ObjIsCo(pObj) )
+ return pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
+ Gia_ManChoiceMiter_rec( pNew, p, Gia_ObjFanin1(pObj) );
+ return pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Derives the miter of several AIGs for choice computation.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManChoiceMiter( Vec_Ptr_t * vGias )
+{
+ Gia_Man_t * pNew, * pGia, * pGia0;
+ int i, k, iNode, nNodes;
+ // make sure they have equal parameters
+ assert( Vec_PtrSize(vGias) > 0 );
+ pGia0 = (Gia_Man_t *)Vec_PtrEntry( vGias, 0 );
+ Vec_PtrForEachEntry( Gia_Man_t *, vGias, pGia, i )
+ {
+ assert( Gia_ManCiNum(pGia) == Gia_ManCiNum(pGia0) );
+ assert( Gia_ManCoNum(pGia) == Gia_ManCoNum(pGia0) );
+ assert( Gia_ManRegNum(pGia) == Gia_ManRegNum(pGia0) );
+ Gia_ManFillValue( pGia );
+ Gia_ManConst0(pGia)->Value = 0;
+ }
+ // start the new manager
+ pNew = Gia_ManStart( Vec_PtrSize(vGias) * Gia_ManObjNum(pGia0) );
+ pNew->pName = Gia_UtilStrsav( pGia0->pName );
+ // create new CIs and assign them to the old manager CIs
+ for ( k = 0; k < Gia_ManCiNum(pGia0); k++ )
+ {
+ iNode = Gia_ManAppendCi(pNew);
+ Vec_PtrForEachEntry( Gia_Man_t *, vGias, pGia, i )
+ Gia_ManCi( pGia, k )->Value = iNode;
+ }
+ // create internal nodes
+ Gia_ManHashAlloc( pNew );
+ for ( k = 0; k < Gia_ManCoNum(pGia0); k++ )
+ {
+ Vec_PtrForEachEntry( Gia_Man_t *, vGias, pGia, i )
+ Gia_ManChoiceMiter_rec( pNew, pGia, Gia_ManCo( pGia, k ) );
+ }
+ Gia_ManHashStop( pNew );
+ // check the presence of dangling nodes
+ nNodes = Gia_ManHasDangling( pNew );
+ assert( nNodes == 0 );
+ // finalize
+ Gia_ManSetRegNum( pNew, Gia_ManRegNum(pGia0) );
+ return pNew;
+}
+
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaEmbed.c b/src/aig/gia/giaEmbed.c
index bd14eea9..5c7092a3 100644
--- a/src/aig/gia/giaEmbed.c
+++ b/src/aig/gia/giaEmbed.c
@@ -20,6 +20,10 @@
#include <math.h>
#include "gia.h"
+#include "ioa.h"
+
+ABC_NAMESPACE_IMPL_START
+
/*
The code is based on the paper by D. Harel and Y. Koren,
@@ -743,7 +747,7 @@ void Emb_ManPrintFanio( Emb_Man_t * p )
printf( "%15d : ", k );
else
{
- sprintf( Buffer, "%d - %d", (int)pow(10, k/10) * (k%10), (int)pow(10, k/10) * (k%10+1) - 1 );
+ sprintf( Buffer, "%d - %d", (int)pow((double)10, k/10) * (k%10), (int)pow((double)10, k/10) * (k%10+1) - 1 );
printf( "%15s : ", Buffer );
}
if ( vFanins->pArray[k] == 0 )
@@ -1692,7 +1696,7 @@ void Emb_ManDumpGnuplot( Emb_Man_t * p, char * pName, int fDumpLarge, int fShowI
extern void Gia_ManGnuplotShow( char * pPlotFileName );
// char * pDirectory = "place\\";
char * pDirectory = "";
- extern char * Ioa_TimeStamp();
+// extern char * Ioa_TimeStamp();
FILE * pFile;
char Buffer[1000];
Emb_Obj_t * pThis, * pNext;
@@ -1865,3 +1869,5 @@ ABC_PRT( "Image dump", clock() - clk );
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaEnable.c b/src/aig/gia/giaEnable.c
index c768bb43..37f0c94f 100644
--- a/src/aig/gia/giaEnable.c
+++ b/src/aig/gia/giaEnable.c
@@ -20,6 +20,9 @@
#include "gia.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -620,7 +623,7 @@ Gia_Man_t * Gia_ManRemoveEnables( Gia_Man_t * p )
}
Gia_ManForEachRi( p, pObj, i )
{
- pData = Vec_PtrEntry(vDatas, i);
+ pData = (Gia_Obj_t *)Vec_PtrEntry(vDatas, i);
if ( pData == NULL )
pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
else
@@ -641,3 +644,5 @@ Gia_Man_t * Gia_ManRemoveEnables( Gia_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaEquiv.c b/src/aig/gia/giaEquiv.c
index 0f680e31..668bc4a2 100644
--- a/src/aig/gia/giaEquiv.c
+++ b/src/aig/gia/giaEquiv.c
@@ -19,6 +19,9 @@
***********************************************************************/
#include "gia.h"
+#include "cec.h"
+
+ABC_NAMESPACE_IMPL_START
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -221,6 +224,8 @@ int Gia_ManEquivCountLitsAll( Gia_Man_t * p )
int Gia_ManEquivCountClasses( Gia_Man_t * p )
{
int i, Counter = 0;
+ if ( p->pReprs == NULL )
+ return 0;
for ( i = 1; i < Gia_ManObjNum(p); i++ )
Counter += Gia_ObjIsHead(p, i);
return Counter;
@@ -448,14 +453,14 @@ Gia_Man_t * Gia_ManEquivReduce( Gia_Man_t * p, int fUseAll, int fDualOut, int fV
{
printf( "Gia_ManEquivReduce(): Dual-output miter should have even number of POs.\n" );
return NULL;
- }
+ }
// check if there are any equivalences defined
Gia_ManForEachObj( p, pObj, i )
if ( Gia_ObjReprObj(p, i) != NULL )
break;
if ( i == Gia_ManObjNum(p) )
{
- printf( "Gia_ManEquivReduce(): There are no equivalences to reduce.\n" );
+// printf( "Gia_ManEquivReduce(): There are no equivalences to reduce.\n" );
return NULL;
}
/*
@@ -815,7 +820,7 @@ void Gia_ManSpecReduce_rec( Gia_Man_t * pNew, Gia_Man_t * p, Gia_Obj_t * pObj, V
SeeAlso []
***********************************************************************/
-Gia_Man_t * Gia_ManSpecReduce( Gia_Man_t * p, int fDualOut, int fVerbose )
+Gia_Man_t * Gia_ManSpecReduce( Gia_Man_t * p, int fDualOut, int fSynthesis, int fVerbose )
{
Gia_Man_t * pNew, * pTemp;
Gia_Obj_t * pObj;
@@ -858,6 +863,11 @@ Gia_Man_t * Gia_ManSpecReduce( Gia_Man_t * p, int fDualOut, int fVerbose )
Gia_ManSpecBuild( pNew, p, pObj, vXorLits, fDualOut );
Gia_ManForEachCo( p, pObj, i )
Gia_ManSpecReduce_rec( pNew, p, Gia_ObjFanin0(pObj), vXorLits, fDualOut );
+ if ( !fSynthesis )
+ {
+ Gia_ManForEachPo( p, pObj, i )
+ Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
+ }
Vec_IntForEachEntry( vXorLits, iLitNew, i )
Gia_ManAppendCo( pNew, iLitNew );
if ( Vec_IntSize(vXorLits) == 0 )
@@ -935,7 +945,7 @@ void Gia_ManSpecReduceInit_rec( Gia_Man_t * pNew, Gia_Man_t * p, Gia_Obj_t * pOb
SeeAlso []
***********************************************************************/
-Gia_Man_t * Gia_ManSpecReduceInit( Gia_Man_t * p, Gia_Cex_t * pInit, int nFrames, int fDualOut )
+Gia_Man_t * Gia_ManSpecReduceInit( Gia_Man_t * p, Abc_Cex_t * pInit, int nFrames, int fDualOut )
{
Gia_Man_t * pNew, * pTemp;
Gia_Obj_t * pObj, * pObjRi, * pObjRo;
@@ -1024,7 +1034,7 @@ Gia_Man_t * Gia_ManSpecReduceInit( Gia_Man_t * p, Gia_Cex_t * pInit, int nFrames
SeeAlso []
***********************************************************************/
-Gia_Man_t * Gia_ManSpecReduceInitFrames( Gia_Man_t * p, Gia_Cex_t * pInit, int nFramesMax, int * pnFrames, int fDualOut, int nMinOutputs )
+Gia_Man_t * Gia_ManSpecReduceInitFrames( Gia_Man_t * p, Abc_Cex_t * pInit, int nFramesMax, int * pnFrames, int fDualOut, int nMinOutputs )
{
Gia_Man_t * pFrames;
int f, nLits;
@@ -1225,7 +1235,7 @@ int Gia_ObjCheckTfi( Gia_Man_t * p, Gia_Obj_t * pOld, Gia_Obj_t * pNode )
assert( !Gia_IsComplement(pNode) );
vVisited = Vec_PtrAlloc( 100 );
RetValue = Gia_ObjCheckTfi_rec( p, pOld, pNode, vVisited );
- Vec_PtrForEachEntry( vVisited, pObj, i )
+ Vec_PtrForEachEntry( Gia_Obj_t *, vVisited, pObj, i )
pObj->fMark0 = 0;
Vec_PtrFree( vVisited );
return RetValue;
@@ -1293,7 +1303,9 @@ void Gia_ManEquivToChoices_rec( Gia_Man_t * pNew, Gia_Man_t * p, Gia_Obj_t * pOb
pObjNew = Gia_ManObj( pNew, Gia_Lit2Var(pObj->Value) );
if ( Gia_ObjReprObj( pNew, Gia_ObjId(pNew, pObjNew) ) )
{
- assert( Gia_ObjReprObj( pNew, Gia_ObjId(pNew, pObjNew) ) == pReprNew );
+// assert( Gia_ObjReprObj( pNew, Gia_ObjId(pNew, pObjNew) ) == pReprNew );
+ if ( Gia_ObjReprObj( pNew, Gia_ObjId(pNew, pObjNew) ) != pReprNew )
+ return;
pObj->Value = Gia_LitNotCond( pRepr->Value, Gia_ObjPhaseReal(pRepr) ^ Gia_ObjPhaseReal(pObj) );
return;
}
@@ -1373,9 +1385,11 @@ void Gia_ManRemoveBadChoices( Gia_Man_t * p )
***********************************************************************/
Gia_Man_t * Gia_ManEquivToChoices( Gia_Man_t * p, int nSnapshots )
{
+ Vec_Int_t * vNodes;
Gia_Man_t * pNew, * pTemp;
Gia_Obj_t * pObj, * pRepr;
int i;
+//Gia_ManEquivPrintClasses( p, 0, 0 );
assert( (Gia_ManCoNum(p) % nSnapshots) == 0 );
Gia_ManSetPhase( p );
pNew = Gia_ManStart( Gia_ManObjNum(p) );
@@ -1397,24 +1411,77 @@ Gia_Man_t * Gia_ManEquivToChoices( Gia_Man_t * p, int nSnapshots )
Gia_ManHashAlloc( pNew );
Gia_ManForEachCo( p, pObj, i )
Gia_ManEquivToChoices_rec( pNew, p, Gia_ObjFanin0(pObj) );
+ vNodes = Gia_ManGetDangling( p );
+ Gia_ManForEachObjVec( vNodes, p, pObj, i )
+ Gia_ManEquivToChoices_rec( pNew, p, pObj );
+ Vec_IntFree( vNodes );
Gia_ManForEachCo( p, pObj, i )
if ( i % nSnapshots == 0 )
Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
Gia_ManHashStop( pNew );
Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
Gia_ManRemoveBadChoices( pNew );
-// Gia_ManEquivPrintClasses( pNew, 0, 0 );
+//Gia_ManEquivPrintClasses( pNew, 0, 0 );
pNew = Gia_ManCleanup( pTemp = pNew );
Gia_ManStop( pTemp );
-// Gia_ManEquivPrintClasses( pNew, 0, 0 );
+//Gia_ManEquivPrintClasses( pNew, 0, 0 );
return pNew;
}
+/**Function*************************************************************
+
+ Synopsis [Counts the number of choice nodes]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManCountChoiceNodes( Gia_Man_t * p )
+{
+ Gia_Obj_t * pObj;
+ int i, Counter = 0;
+ if ( p->pReprs == NULL || p->pNexts == NULL )
+ return 0;
+ Gia_ManForEachObj( p, pObj, i )
+ Counter += Gia_ObjIsHead( p, i );
+ return Counter;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Counts the number of choices]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManCountChoices( Gia_Man_t * p )
+{
+ Gia_Obj_t * pObj;
+ int i, Counter = 0;
+ if ( p->pReprs == NULL || p->pNexts == NULL )
+ return 0;
+ Gia_ManForEachObj( p, pObj, i )
+ Counter += (int)(Gia_ObjNext( p, i ) > 0);
+ return Counter;
+}
+
+ABC_NAMESPACE_IMPL_END
+
#include "aig.h"
#include "saig.h"
#include "cec.h"
#include "giaAig.h"
+ABC_NAMESPACE_IMPL_START
+
+
/**Function*************************************************************
Synopsis [Implements iteration during speculation.]
@@ -1428,7 +1495,7 @@ Gia_Man_t * Gia_ManEquivToChoices( Gia_Man_t * p, int nSnapshots )
***********************************************************************/
int Gia_CommandSpecI( Gia_Man_t * pGia, int nFramesInit, int nBTLimitInit, int fStart, int fCheckMiter, int fVerbose )
{
- extern int Cec_ManCheckNonTrivialCands( Gia_Man_t * pAig );
+// extern int Cec_ManCheckNonTrivialCands( Gia_Man_t * pAig );
Aig_Man_t * pTemp;
Gia_Man_t * pSrm, * pReduce, * pAux;
int nIter, nStart = 0;
@@ -1460,10 +1527,10 @@ int Gia_CommandSpecI( Gia_Man_t * pGia, int nFramesInit, int nBTLimitInit, int f
printf( "Gia_CommandSpecI: There are only trivial equiv candidates left (PO drivers). Quitting.\n" );
break;
}
- pSrm = Gia_ManSpecReduce( pGia, 0, 0 );
+ pSrm = Gia_ManSpecReduce( pGia, 0, 0, 0 );
// bmc2 -F 100 -C 25000
{
- Gia_Cex_t * pCex;
+ Abc_Cex_t * pCex;
int nFrames = nFramesInit; // different from default
int nNodeDelta = 2000;
int nBTLimit = nBTLimitInit; // different from default
@@ -1471,7 +1538,7 @@ int Gia_CommandSpecI( Gia_Man_t * pGia, int nFramesInit, int nBTLimitInit, int f
pTemp = Gia_ManToAig( pSrm, 0 );
// Aig_ManPrintStats( pTemp );
Gia_ManStop( pSrm );
- Saig_BmcPerform( pTemp, nStart, nFrames, nNodeDelta, 20, nBTLimit, nBTLimitAll, fVerbose, 0 );
+ Saig_BmcPerform( pTemp, nStart, nFrames, nNodeDelta, 0, nBTLimit, nBTLimitAll, fVerbose, 0, NULL );
pCex = pTemp->pSeqModel; pTemp->pSeqModel = NULL;
Aig_ManStop( pTemp );
if ( pCex == NULL )
@@ -1497,7 +1564,7 @@ int Gia_CommandSpecI( Gia_Man_t * pGia, int nFramesInit, int nBTLimitInit, int f
// write equivalence classes
Gia_WriteAiger( pGia, "gore.aig", 0, 0 );
// reduce the model
- pReduce = Gia_ManSpecReduce( pGia, 0, 0 );
+ pReduce = Gia_ManSpecReduce( pGia, 0, 0, 0 );
if ( pReduce )
{
pReduce = Gia_ManSeqStructSweep( pAux = pReduce, 1, 1, 0 );
@@ -1516,3 +1583,5 @@ int Gia_CommandSpecI( Gia_Man_t * pGia, int nFramesInit, int nBTLimitInit, int f
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaEra.c b/src/aig/gia/giaEra.c
new file mode 100644
index 00000000..ec3e1b1b
--- /dev/null
+++ b/src/aig/gia/giaEra.c
@@ -0,0 +1,561 @@
+/**CFile****************************************************************
+
+ FileName [giaEra.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Scalable AIG package.]
+
+ Synopsis [Explicit reachability analysis.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: giaEra.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+#include "mem.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+// explicit state representation
+typedef struct Gia_ObjEra_t_ Gia_ObjEra_t;
+struct Gia_ObjEra_t_
+{
+ int Num; // ID of this state
+ int Cond; // input condition
+ int iPrev; // previous state
+ int iNext; // next state in the hash table
+ unsigned pData[0]; // state bits
+};
+
+// explicit state reachability
+typedef struct Gia_ManEra_t_ Gia_ManEra_t;
+struct Gia_ManEra_t_
+{
+ Gia_Man_t * pAig; // user's AIG manager
+ int nWordsSim; // 2^(PInum)
+ int nWordsDat; // Gia_BitWordNum
+ unsigned * pDataSim; // simulation data
+ Mem_Fixed_t * pMemory; // memory manager
+ Vec_Ptr_t * vStates; // reached states
+ Gia_ObjEra_t * pStateNew; // temporary state
+ int iCurState; // the current state
+ Vec_Int_t * vBugTrace; // the sequence of transitions
+ // hash table for states
+ int nBins;
+ unsigned * pBins;
+};
+
+static inline unsigned * Gia_ManEraData( Gia_ManEra_t * p, int i ) { return p->pDataSim + i * p->nWordsSim; }
+static inline Gia_ObjEra_t * Gia_ManEraState( Gia_ManEra_t * p, int i ) { return (Gia_ObjEra_t *)Vec_PtrEntry(p->vStates, i); }
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Creates reachability manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_ManEra_t * Gia_ManEraCreate( Gia_Man_t * pAig )
+{
+ Vec_Ptr_t * vTruths;
+ Gia_ManEra_t * p;
+ unsigned * pTruth, * pSimInfo;
+ int i;
+ p = ABC_CALLOC( Gia_ManEra_t, 1 );
+ p->pAig = pAig;
+ p->nWordsSim = Gia_TruthWordNum( Gia_ManPiNum(pAig) );
+ p->nWordsDat = Gia_BitWordNum( Gia_ManRegNum(pAig) );
+ p->pDataSim = ABC_ALLOC( unsigned, p->nWordsSim*Gia_ManObjNum(pAig) );
+ p->pMemory = Mem_FixedStart( sizeof(Gia_ObjEra_t) + sizeof(unsigned) * p->nWordsDat );
+ p->vStates = Vec_PtrAlloc( 100000 );
+ p->nBins = Gia_PrimeCudd( 100000 );
+ p->pBins = ABC_CALLOC( unsigned, p->nBins );
+ Vec_PtrPush( p->vStates, NULL );
+ // assign primary input values
+ vTruths = Vec_PtrAllocTruthTables( Gia_ManPiNum(pAig) );
+ Vec_PtrForEachEntry( unsigned *, vTruths, pTruth, i )
+ {
+ pSimInfo = Gia_ManEraData( p, Gia_ObjId(pAig, Gia_ManPi(pAig, i)) );
+ memcpy( pSimInfo, pTruth, sizeof(unsigned) * p->nWordsSim );
+ }
+ Vec_PtrFree( vTruths );
+ // assign constant zero node
+ pSimInfo = Gia_ManEraData( p, 0 );
+ memset( pSimInfo, 0, sizeof(unsigned) * p->nWordsSim );
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Deletes reachability manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManEraFree( Gia_ManEra_t * p )
+{
+ Mem_FixedStop( p->pMemory, 0 );
+ Vec_PtrFree( p->vStates );
+ if ( p->vBugTrace ) Vec_IntFree( p->vBugTrace );
+ ABC_FREE( p->pDataSim );
+ ABC_FREE( p->pBins );
+ ABC_FREE( p );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates new state.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_ObjEra_t * Gia_ManEraCreateState( Gia_ManEra_t * p )
+{
+ Gia_ObjEra_t * pNew;
+ pNew = (Gia_ObjEra_t *)Mem_FixedEntryFetch( p->pMemory );
+ pNew->Num = Vec_PtrSize( p->vStates );
+ pNew->iPrev = 0;
+ Vec_PtrPush( p->vStates, pNew );
+ return pNew;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Computes hash value of the node using its simulation info.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManEraStateHash( unsigned * pState, int nWordsSim, int nTableSize )
+{
+ static int s_FPrimes[128] = {
+ 1009, 1049, 1093, 1151, 1201, 1249, 1297, 1361, 1427, 1459,
+ 1499, 1559, 1607, 1657, 1709, 1759, 1823, 1877, 1933, 1997,
+ 2039, 2089, 2141, 2213, 2269, 2311, 2371, 2411, 2467, 2543,
+ 2609, 2663, 2699, 2741, 2797, 2851, 2909, 2969, 3037, 3089,
+ 3169, 3221, 3299, 3331, 3389, 3461, 3517, 3557, 3613, 3671,
+ 3719, 3779, 3847, 3907, 3943, 4013, 4073, 4129, 4201, 4243,
+ 4289, 4363, 4441, 4493, 4549, 4621, 4663, 4729, 4793, 4871,
+ 4933, 4973, 5021, 5087, 5153, 5227, 5281, 5351, 5417, 5471,
+ 5519, 5573, 5651, 5693, 5749, 5821, 5861, 5923, 6011, 6073,
+ 6131, 6199, 6257, 6301, 6353, 6397, 6481, 6563, 6619, 6689,
+ 6737, 6803, 6863, 6917, 6977, 7027, 7109, 7187, 7237, 7309,
+ 7393, 7477, 7523, 7561, 7607, 7681, 7727, 7817, 7877, 7933,
+ 8011, 8039, 8059, 8081, 8093, 8111, 8123, 8147
+ };
+ unsigned uHash;
+ int i;
+ uHash = 0;
+ for ( i = 0; i < nWordsSim; i++ )
+ uHash ^= pState[i] * s_FPrimes[i & 0x7F];
+ return uHash % nTableSize;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the place of this state in the table or NULL if it exists.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline unsigned * Gia_ManEraHashFind( Gia_ManEra_t * p, Gia_ObjEra_t * pState )
+{
+ Gia_ObjEra_t * pThis;
+ unsigned * pPlace = p->pBins + Gia_ManEraStateHash( pState->pData, p->nWordsDat, p->nBins );
+ for ( pThis = (*pPlace)? Gia_ManEraState(p, *pPlace) : NULL; pThis;
+ pPlace = (unsigned *)&pThis->iNext, pThis = (*pPlace)? Gia_ManEraState(p, *pPlace) : NULL )
+ if ( !memcmp( pState->pData, pThis->pData, sizeof(unsigned) * p->nWordsDat ) )
+ return NULL;
+ return pPlace;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Resizes the hash table.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManEraHashResize( Gia_ManEra_t * p )
+{
+ Gia_ObjEra_t * pThis;
+ unsigned * pBinsOld, * piPlace;
+ int nBinsOld, iNext, Counter, i;
+ assert( p->pBins != NULL );
+ // replace the table
+ pBinsOld = p->pBins;
+ nBinsOld = p->nBins;
+ p->nBins = Gia_PrimeCudd( 3 * p->nBins );
+ p->pBins = ABC_CALLOC( unsigned, p->nBins );
+ // rehash the entries from the old table
+ Counter = 0;
+ for ( i = 0; i < nBinsOld; i++ )
+ for ( pThis = (pBinsOld[i]? Gia_ManEraState(p, pBinsOld[i]) : NULL),
+ iNext = (pThis? pThis->iNext : 0);
+ pThis; pThis = (iNext? Gia_ManEraState(p, iNext) : NULL),
+ iNext = (pThis? pThis->iNext : 0) )
+ {
+ assert( pThis->Num );
+ pThis->iNext = 0;
+ piPlace = Gia_ManEraHashFind( p, pThis );
+ assert( *piPlace == 0 ); // should not be there
+ *piPlace = pThis->Num;
+ Counter++;
+ }
+ assert( Counter == Vec_PtrSize( p->vStates ) - 1 );
+ ABC_FREE( pBinsOld );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Initialize register output to the given state.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManInsertState( Gia_ManEra_t * p, Gia_ObjEra_t * pState )
+{
+ Gia_Obj_t * pObj;
+ unsigned * pSimInfo;
+ int i;
+ Gia_ManForEachRo( p->pAig, pObj, i )
+ {
+ pSimInfo = Gia_ManEraData( p, Gia_ObjId(p->pAig, pObj) );
+ if ( Gia_InfoHasBit(pState->pData, i) )
+ memset( pSimInfo, 0xff, sizeof(unsigned) * p->nWordsSim );
+ else
+ memset( pSimInfo, 0, sizeof(unsigned) * p->nWordsSim );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns -1 if outputs are not asserted.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Gia_ManOutputAsserted( Gia_ManEra_t * p, Gia_Obj_t * pObj )
+{
+ unsigned * pInfo = Gia_ManEraData( p, Gia_ObjId(p->pAig, pObj) );
+ int w;
+ for ( w = 0; w < p->nWordsSim; w++ )
+ if ( pInfo[w] )
+ return 32*w + Gia_WordFindFirstBit( pInfo[w] );
+ return -1;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Gia_ManSimulateCo( Gia_ManEra_t * p, Gia_Obj_t * pObj )
+{
+ int Id = Gia_ObjId(p->pAig, pObj);
+ unsigned * pInfo = Gia_ManEraData( p, Id );
+ unsigned * pInfo0 = Gia_ManEraData( p, Gia_ObjFaninId0(pObj, Id) );
+ int w;
+ if ( Gia_ObjFaninC0(pObj) )
+ for ( w = p->nWordsSim-1; w >= 0; w-- )
+ pInfo[w] = ~pInfo0[w];
+ else
+ for ( w = p->nWordsSim-1; w >= 0; w-- )
+ pInfo[w] = pInfo0[w];
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Gia_ManSimulateNode( Gia_ManEra_t * p, Gia_Obj_t * pObj )
+{
+ int Id = Gia_ObjId(p->pAig, pObj);
+ unsigned * pInfo = Gia_ManEraData( p, Id );
+ unsigned * pInfo0 = Gia_ManEraData( p, Gia_ObjFaninId0(pObj, Id) );
+ unsigned * pInfo1 = Gia_ManEraData( p, Gia_ObjFaninId1(pObj, Id) );
+ int w;
+ if ( Gia_ObjFaninC0(pObj) )
+ {
+ if ( Gia_ObjFaninC1(pObj) )
+ for ( w = p->nWordsSim-1; w >= 0; w-- )
+ pInfo[w] = ~(pInfo0[w] | pInfo1[w]);
+ else
+ for ( w = p->nWordsSim-1; w >= 0; w-- )
+ pInfo[w] = ~pInfo0[w] & pInfo1[w];
+ }
+ else
+ {
+ if ( Gia_ObjFaninC1(pObj) )
+ for ( w = p->nWordsSim-1; w >= 0; w-- )
+ pInfo[w] = pInfo0[w] & ~pInfo1[w];
+ else
+ for ( w = p->nWordsSim-1; w >= 0; w-- )
+ pInfo[w] = pInfo0[w] & pInfo1[w];
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs one iteration of reachability analysis.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManPerformOneIter( Gia_ManEra_t * p )
+{
+ Gia_Obj_t * pObj;
+ int i;
+ Gia_ManForEachObj1( p->pAig, pObj, i )
+ {
+ if ( Gia_ObjIsAnd(pObj) )
+ Gia_ManSimulateNode( p, pObj );
+ else if ( Gia_ObjIsCo(pObj) )
+ Gia_ManSimulateCo( p, pObj );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs one iteration of reachability analysis.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Gia_ManCollectBugTrace( Gia_ManEra_t * p, Gia_ObjEra_t * pState, int iCond )
+{
+ Vec_Int_t * vTrace;
+ vTrace = Vec_IntAlloc( 10 );
+ Vec_IntPush( vTrace, iCond );
+ for ( ; pState; pState = pState->iPrev ? Gia_ManEraState(p, pState->iPrev) : NULL )
+ Vec_IntPush( vTrace, pState->Cond );
+ Vec_IntReverseOrder( vTrace );
+ return vTrace;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Counts the depth of state transitions leading ot this state.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManCountDepth( Gia_ManEra_t * p )
+{
+ Gia_ObjEra_t * pState;
+ int Counter = 0;
+ pState = (Gia_ObjEra_t *)Vec_PtrEntryLast( p->vStates );
+ if ( pState->iPrev == 0 && Vec_PtrSize(p->vStates) > 3 )
+ pState = (Gia_ObjEra_t *)Vec_PtrEntry( p->vStates, Vec_PtrSize(p->vStates) - 2 );
+ for ( ; pState; pState = pState->iPrev ? Gia_ManEraState(p, pState->iPrev) : NULL )
+ Counter++;
+ return Counter;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Analized reached states.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManAnalyzeResult( Gia_ManEra_t * p, Gia_ObjEra_t * pState, int fMiter )
+{
+ Gia_Obj_t * pObj;
+ unsigned * pSimInfo, * piPlace;
+ int i, k, iCond, nMints;
+ // check if the miter is asserted
+ if ( fMiter )
+ {
+ Gia_ManForEachPo( p->pAig, pObj, i )
+ {
+ iCond = Gia_ManOutputAsserted( p, pObj );
+ if ( iCond >= 0 )
+ {
+ p->vBugTrace = Gia_ManCollectBugTrace( p, pState, iCond );
+ return 1;
+ }
+ }
+ }
+ // collect reached states
+ nMints = (1 << Gia_ManPiNum(p->pAig));
+ for ( k = 0; k < nMints; k++ )
+ {
+ if ( p->pStateNew == NULL )
+ p->pStateNew = Gia_ManEraCreateState( p );
+ p->pStateNew->pData[p->nWordsDat-1] = 0;
+ Gia_ManForEachRi( p->pAig, pObj, i )
+ {
+ pSimInfo = Gia_ManEraData( p, Gia_ObjId(p->pAig, pObj) );
+ if ( Gia_InfoHasBit(p->pStateNew->pData, i) != Gia_InfoHasBit(pSimInfo, k) )
+ Gia_InfoXorBit( p->pStateNew->pData, i );
+ }
+ piPlace = Gia_ManEraHashFind( p, p->pStateNew );
+ if ( piPlace == NULL )
+ continue;
+//printf( "Inserting %d ", Vec_PtrSize(p->vStates) );
+//Extra_PrintBinary( stdout, p->pStateNew->pData, Gia_ManRegNum(p->pAig) ); printf( "\n" );
+ assert( *piPlace == 0 );
+ *piPlace = p->pStateNew->Num;
+ p->pStateNew->Cond = k;
+ p->pStateNew->iPrev = pState->Num;
+ p->pStateNew->iNext = 0;
+ p->pStateNew = NULL;
+ // expand hash table if needed
+ if ( Vec_PtrSize(p->vStates) > 2 * p->nBins )
+ Gia_ManEraHashResize( p );
+ }
+ return 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Resizes the hash table.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManCollectReachable( Gia_Man_t * pAig, int nStatesMax, int fMiter, int fVerbose )
+{
+ Gia_ManEra_t * p;
+ Gia_ObjEra_t * pState;
+ int Hash, clk = clock();
+ int RetValue = 1;
+ assert( Gia_ManPiNum(pAig) <= 12 );
+ assert( Gia_ManRegNum(pAig) > 0 );
+ p = Gia_ManEraCreate( pAig );
+ // create init state
+ pState = Gia_ManEraCreateState( p );
+ pState->Cond = 0;
+ pState->iPrev = 0;
+ pState->iNext = 0;
+ memset( pState->pData, 0, sizeof(unsigned) * p->nWordsDat );
+ Hash = Gia_ManEraStateHash(pState->pData, p->nWordsDat, p->nBins);
+ p->pBins[ Hash ] = pState->Num;
+ // process reachable states
+ while ( p->iCurState < Vec_PtrSize( p->vStates ) - 1 )
+ {
+ if ( Vec_PtrSize(p->vStates) >= nStatesMax )
+ {
+ printf( "Reached the limit on states traversed (%d). ", nStatesMax );
+ RetValue = -1;
+ break;
+ }
+ pState = Gia_ManEraState( p, ++p->iCurState );
+ if ( p->iCurState > 1 && pState->iPrev == 0 )
+ continue;
+//printf( "Extracting %d ", p->iCurState );
+//Extra_PrintBinary( stdout, p->pStateNew->pData, Gia_ManRegNum(p->pAig) ); printf( "\n" );
+ Gia_ManInsertState( p, pState );
+ Gia_ManPerformOneIter( p );
+ if ( Gia_ManAnalyzeResult( p, pState, fMiter ) && fMiter )
+ {
+ RetValue = 0;
+ printf( "Miter failed in state %d after %d transitions. ",
+ p->iCurState, Vec_IntSize(p->vBugTrace)-1 );
+ break;
+ }
+ if ( fVerbose && p->iCurState % 5000 == 0 )
+ {
+ printf( "States =%10d. Reached =%10d. R = %5.3f. Depth =%6d. Mem =%9.2f Mb. ",
+ p->iCurState, Vec_PtrSize(p->vStates), 1.0*p->iCurState/Vec_PtrSize(p->vStates), Gia_ManCountDepth(p),
+ (1.0/(1<<20))*(1.0*Vec_PtrSize(p->vStates)*(sizeof(Gia_ObjEra_t) + sizeof(unsigned) * p->nWordsDat) +
+ 1.0*p->nBins*sizeof(unsigned) + 1.0*p->vStates->nCap * sizeof(void*)) );
+ ABC_PRT( "Time", clock() - clk );
+ }
+ }
+ printf( "Reachability analysis traversed %d states with depth %d. ", p->iCurState-1, Gia_ManCountDepth(p) );
+ ABC_PRT( "Time", clock() - clk );
+ Gia_ManEraFree( p );
+ return RetValue;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaEra2.c b/src/aig/gia/giaEra2.c
new file mode 100644
index 00000000..64464832
--- /dev/null
+++ b/src/aig/gia/giaEra2.c
@@ -0,0 +1,1954 @@
+/**CFile****************************************************************
+
+ FileName [gia.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Scalable AIG package.]
+
+ Synopsis []
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: gia.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+#include "giaAig.h"
+
+ABC_NAMESPACE_IMPL_START
+
+/*
+ Limitations of this package:
+ - no more than (1<<31)-1 state cubes and internal nodes
+ - no more than MAX_VARS_NUM state variables
+ - no more than MAX_CALL_NUM transitions from a state
+ - cube list rebalancing happens when cube count reaches MAX_CUBE_NUM
+*/
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+#define MAX_CALL_NUM (1000000) // the max number of recursive calls
+#define MAX_ITEM_NUM (1<<20) // the number of items on a page
+#define MAX_PAGE_NUM (1<<11) // the max number of memory pages
+#define MAX_VARS_NUM (1<<14) // the max number of state vars allowed
+#define MAX_CUBE_NUM 63 // the max number of cubes before rebalancing
+
+// pointer to the tree node or state cube
+typedef struct Gia_PtrAre_t_ Gia_PtrAre_t;
+struct Gia_PtrAre_t_
+{
+ unsigned nItem : 20; // item number (related to MAX_ITEM_NUM)
+ unsigned nPage : 11; // page number (related to MAX_PAGE_NUM)
+ unsigned fMark : 1; // user mark
+};
+
+// tree nodes
+typedef struct Gia_ObjAre_t_ Gia_ObjAre_t;
+struct Gia_ObjAre_t_
+{
+ unsigned iVar : 14; // variable (related to MAX_VARS_NUM)
+ unsigned nStas0 : 6; // cube counter (related to MAX_CUBE_NUM)
+ unsigned nStas1 : 6; // cube counter (related to MAX_CUBE_NUM)
+ unsigned nStas2 : 6; // cube counter (related to MAX_CUBE_NUM)
+ Gia_PtrAre_t F[3]; // branches
+};
+
+// state cube
+typedef struct Gia_StaAre_t_ Gia_StaAre_t;
+struct Gia_StaAre_t_
+{
+ Gia_PtrAre_t iPrev; // previous state
+ Gia_PtrAre_t iNext; // next cube in the list
+ unsigned pData[0]; // state bits
+};
+
+// explicit state reachability manager
+typedef struct Gia_ManAre_t_ Gia_ManAre_t;
+struct Gia_ManAre_t_
+{
+ Gia_Man_t * pAig; // user's AIG manager
+ Gia_Man_t * pNew; // temporary AIG manager
+ unsigned ** ppObjs; // storage for objects (MAX_PAGE_NUM pages)
+ unsigned ** ppStas; // storage for states (MAX_PAGE_NUM pages)
+// unsigned * pfUseless; // to label useless cubes
+// int nUselessAlloc; // the number of useless alloced
+ // internal flags
+ int fMiter; // stops when a bug is discovered
+ int fStopped; // set high when reachability is stopped
+ int fTree; // working in the tree mode
+ // internal parametesr
+ int nWords; // the size of bit info in words
+ int nSize; // the size of state structure in words
+ int nObjPages; // the number of pages used for objects
+ int nStaPages; // the number of pages used for states
+ int nObjs; // the number of objects
+ int nStas; // the number of states
+ int iStaCur; // the next state to be explored
+ Gia_PtrAre_t Root; // root of the tree
+ Vec_Vec_t * vCiTfos; // storage for nodes in the CI TFOs
+ Vec_Vec_t * vCiLits; // storage for literals of these nodes
+ Vec_Int_t * vCubesA; // checked cubes
+ Vec_Int_t * vCubesB; // unchecked cubes
+ // deriving counter-example
+ void * pSat; // SAT solver
+ Vec_Int_t * vSatNumCis; // SAT variables for CIs
+ Vec_Int_t * vSatNumCos; // SAT variables for COs
+ Vec_Int_t * vCofVars; // variables used to cofactor
+ Vec_Int_t * vAssumps; // temporary storage for assumptions
+ Gia_StaAre_t * pTarget; // state that needs to be reached
+ int iOutFail; // the number of the failed output
+ // statistics
+ int nChecks; // the number of timea cube was checked
+ int nEquals; // total number of equal
+ int nCompares; // the number of compares
+ int nRecCalls; // the number of rec calls
+ int nDisjs; // the number of disjoint cube pairs
+ int nDisjs2; // the number of disjoint cube pairs
+ int nDisjs3; // the number of disjoint cube pairs
+ // time
+ int timeAig; // AIG cofactoring time
+ int timeCube; // cube checking time
+};
+
+static inline Gia_PtrAre_t Gia_Int2Ptr( unsigned n ) { return *(Gia_PtrAre_t *)(&n); }
+static inline unsigned Gia_Ptr2Int( Gia_PtrAre_t n ) { return (*(int *)(&n)) & 0x7fffffff; }
+
+static inline int Gia_ObjHasBranch0( Gia_ObjAre_t * q ) { return !q->nStas0 && (q->F[0].nPage || q->F[0].nItem); }
+static inline int Gia_ObjHasBranch1( Gia_ObjAre_t * q ) { return !q->nStas1 && (q->F[1].nPage || q->F[1].nItem); }
+static inline int Gia_ObjHasBranch2( Gia_ObjAre_t * q ) { return !q->nStas2 && (q->F[2].nPage || q->F[2].nItem); }
+
+static inline Gia_ObjAre_t * Gia_ManAreObj( Gia_ManAre_t * p, Gia_PtrAre_t n ) { return (Gia_ObjAre_t *)(p->ppObjs[n.nPage] + (n.nItem << 2)); }
+static inline Gia_StaAre_t * Gia_ManAreSta( Gia_ManAre_t * p, Gia_PtrAre_t n ) { return (Gia_StaAre_t *)(p->ppStas[n.nPage] + n.nItem * p->nSize); }
+static inline Gia_ObjAre_t * Gia_ManAreObjInt( Gia_ManAre_t * p, int n ) { return Gia_ManAreObj( p, Gia_Int2Ptr(n) ); }
+static inline Gia_StaAre_t * Gia_ManAreStaInt( Gia_ManAre_t * p, int n ) { return Gia_ManAreSta( p, Gia_Int2Ptr(n) ); }
+static inline Gia_ObjAre_t * Gia_ManAreObjLast( Gia_ManAre_t * p ) { return Gia_ManAreObjInt( p, p->nObjs-1 ); }
+static inline Gia_StaAre_t * Gia_ManAreStaLast( Gia_ManAre_t * p ) { return Gia_ManAreStaInt( p, p->nStas-1 ); }
+
+static inline Gia_ObjAre_t * Gia_ObjNextObj0( Gia_ManAre_t * p, Gia_ObjAre_t * q ) { return Gia_ManAreObj( p, q->F[0] ); }
+static inline Gia_ObjAre_t * Gia_ObjNextObj1( Gia_ManAre_t * p, Gia_ObjAre_t * q ) { return Gia_ManAreObj( p, q->F[1] ); }
+static inline Gia_ObjAre_t * Gia_ObjNextObj2( Gia_ManAre_t * p, Gia_ObjAre_t * q ) { return Gia_ManAreObj( p, q->F[2] ); }
+
+static inline int Gia_StaHasValue0( Gia_StaAre_t * p, int iReg ) { return Gia_InfoHasBit( p->pData, iReg << 1 ); }
+static inline int Gia_StaHasValue1( Gia_StaAre_t * p, int iReg ) { return Gia_InfoHasBit( p->pData, (iReg << 1) + 1 ); }
+
+static inline void Gia_StaSetValue0( Gia_StaAre_t * p, int iReg ) { Gia_InfoSetBit( p->pData, iReg << 1 ); }
+static inline void Gia_StaSetValue1( Gia_StaAre_t * p, int iReg ) { Gia_InfoSetBit( p->pData, (iReg << 1) + 1 ); }
+
+static inline Gia_StaAre_t * Gia_StaPrev( Gia_ManAre_t * p, Gia_StaAre_t * pS ) { return Gia_ManAreSta(p, pS->iPrev); }
+static inline Gia_StaAre_t * Gia_StaNext( Gia_ManAre_t * p, Gia_StaAre_t * pS ) { return Gia_ManAreSta(p, pS->iNext); }
+static inline int Gia_StaIsGood( Gia_ManAre_t * p, Gia_StaAre_t * pS ) { return ((unsigned *)pS) != p->ppStas[0]; }
+
+static inline void Gia_StaSetUnused( Gia_StaAre_t * pS ) { pS->iPrev.fMark = 1; }
+static inline int Gia_StaIsUnused( Gia_StaAre_t * pS ) { return pS->iPrev.fMark; }
+static inline int Gia_StaIsUsed( Gia_StaAre_t * pS ) { return !pS->iPrev.fMark; }
+
+#define Gia_ManAreForEachCubeList( p, pList, pCube ) \
+ for ( pCube = pList; Gia_StaIsGood(p, pCube); pCube = Gia_StaNext(p, pCube) )
+#define Gia_ManAreForEachCubeList2( p, iList, pCube, iCube ) \
+ for ( iCube = Gia_Ptr2Int(iList), pCube = Gia_ManAreSta(p, iList); \
+ Gia_StaIsGood(p, pCube); \
+ iCube = Gia_Ptr2Int(pCube->iNext), pCube = Gia_StaNext(p, pCube) )
+#define Gia_ManAreForEachCubeStore( p, pCube, i ) \
+ for ( i = 1; i < p->nStas && (pCube = Gia_ManAreStaInt(p, i)); i++ )
+#define Gia_ManAreForEachCubeVec( vVec, p, pCube, i ) \
+ for ( i = 0; i < Vec_IntSize(vVec) && (pCube = Gia_ManAreStaInt(p, Vec_IntEntry(vVec,i))); i++ )
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Count state minterms contained in a cube.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManCountMintermsInCube( Gia_StaAre_t * pCube, int nVars, unsigned * pStore )
+{
+ unsigned Mint, Mask = 0;
+ int i, m, nMints, nDashes = 0, Dashes[32];
+ // count the number of dashes
+ for ( i = 0; i < nVars; i++ )
+ {
+ if ( Gia_StaHasValue0( pCube, i ) )
+ continue;
+ if ( Gia_StaHasValue1( pCube, i ) )
+ Mask |= (1 << i);
+ else
+ Dashes[nDashes++] = i;
+ }
+ // fill in the miterms
+ nMints = (1 << nDashes);
+ for ( m = 0; m < nMints; m++ )
+ {
+ Mint = Mask;
+ for ( i = 0; i < nVars; i++ )
+ if ( m & (1 << i) )
+ Mint |= (1 << Dashes[i]);
+ Gia_InfoSetBit( pStore, Mint );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Count state minterms contains in the used cubes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManCountMinterms( Gia_ManAre_t * p )
+{
+ Gia_StaAre_t * pCube;
+ unsigned * pMemory;
+ int i, nMemSize, Counter = 0;
+ if ( Gia_ManRegNum(p->pAig) > 30 )
+ return -1;
+ nMemSize = Gia_BitWordNum( 1 << Gia_ManRegNum(p->pAig) );
+ pMemory = ABC_CALLOC( unsigned, nMemSize );
+ Gia_ManAreForEachCubeStore( p, pCube, i )
+ if ( Gia_StaIsUsed(pCube) )
+ Gia_ManCountMintermsInCube( pCube, Gia_ManRegNum(p->pAig), pMemory );
+ for ( i = 0; i < nMemSize; i++ )
+ Counter += Gia_WordCountOnes( pMemory[i] );
+ ABC_FREE( pMemory );
+ return Counter;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Derives the TFO of one CI.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManDeriveCiTfo_rec( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vRes )
+{
+ if ( Gia_ObjIsCi(pObj) )
+ return pObj->fMark0;
+ if ( Gia_ObjIsTravIdCurrent(p, pObj) )
+ return pObj->fMark0;
+ Gia_ObjSetTravIdCurrent(p, pObj);
+ assert( Gia_ObjIsAnd(pObj) );
+ Gia_ManDeriveCiTfo_rec( p, Gia_ObjFanin0(pObj), vRes );
+ Gia_ManDeriveCiTfo_rec( p, Gia_ObjFanin1(pObj), vRes );
+ pObj->fMark0 = Gia_ObjFanin0(pObj)->fMark0 | Gia_ObjFanin1(pObj)->fMark0;
+ if ( pObj->fMark0 )
+ Vec_IntPush( vRes, Gia_ObjId(p, pObj) );
+ return pObj->fMark0;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Derives the TFO of one CI.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Gia_ManDeriveCiTfoOne( Gia_Man_t * p, Gia_Obj_t * pPivot )
+{
+ Vec_Int_t * vRes;
+ Gia_Obj_t * pObj;
+ int i;
+ assert( pPivot->fMark0 == 0 );
+ pPivot->fMark0 = 1;
+ vRes = Vec_IntAlloc( 100 );
+ Vec_IntPush( vRes, Gia_ObjId(p, pPivot) );
+ Gia_ManIncrementTravId( p );
+ Gia_ObjSetTravIdCurrent( p, Gia_ManConst0(p) );
+ Gia_ManForEachCo( p, pObj, i )
+ {
+ Gia_ManDeriveCiTfo_rec( p, Gia_ObjFanin0(pObj), vRes );
+ if ( Gia_ObjFanin0(pObj)->fMark0 )
+ Vec_IntPush( vRes, Gia_ObjId(p, pObj) );
+ }
+ pPivot->fMark0 = 0;
+ return vRes;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Derives the TFO of each CI.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Vec_t * Gia_ManDeriveCiTfo( Gia_Man_t * p )
+{
+ Vec_Ptr_t * vRes;
+ Gia_Obj_t * pPivot;
+ int i;
+ Gia_ManCleanMark0( p );
+ Gia_ManIncrementTravId( p );
+ vRes = Vec_PtrAlloc( Gia_ManCiNum(p) );
+ Gia_ManForEachCi( p, pPivot, i )
+ Vec_PtrPush( vRes, Gia_ManDeriveCiTfoOne(p, pPivot) );
+ Gia_ManCleanMark0( p );
+ return (Vec_Vec_t *)vRes;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns 1 if states are equal.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Gia_StaAreEqual( Gia_StaAre_t * p1, Gia_StaAre_t * p2, int nWords )
+{
+ int w;
+ for ( w = 0; w < nWords; w++ )
+ if ( p1->pData[w] != p2->pData[w] )
+ return 0;
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns 1 if states are disjoint.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Gia_StaAreDisjoint( Gia_StaAre_t * p1, Gia_StaAre_t * p2, int nWords )
+{
+ int w;
+ for ( w = 0; w < nWords; w++ )
+ if ( ((p1->pData[w] ^ p2->pData[w]) >> 1) & (p1->pData[w] ^ p2->pData[w]) & 0x55555555 )
+ return 1;
+ return 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns 1 if cube p1 contains cube p2.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Gia_StaAreContain( Gia_StaAre_t * p1, Gia_StaAre_t * p2, int nWords )
+{
+ int w;
+ for ( w = 0; w < nWords; w++ )
+ if ( (p1->pData[w] | p2->pData[w]) != p2->pData[w] )
+ return 0;
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the number of dashes in p1 that are non-dashes in p2.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Gia_StaAreDashNum( Gia_StaAre_t * p1, Gia_StaAre_t * p2, int nWords )
+{
+ int w, Counter = 0;
+ for ( w = 0; w < nWords; w++ )
+ Counter += Gia_WordCountOnes( (~(p1->pData[w] ^ (p1->pData[w] >> 1))) & (p2->pData[w] ^ (p2->pData[w] >> 1)) & 0x55555555 );
+ return Counter;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the number of a variable for sharping the cube.]
+
+ Description [Counts the number of variables that have dash in p1 and
+ non-dash in p2. If there is exactly one such variable, returns its index.
+ Otherwise returns -1.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Gia_StaAreSharpVar( Gia_StaAre_t * p1, Gia_StaAre_t * p2, int nWords )
+{
+ unsigned Word;
+ int w, iVar = -1;
+ for ( w = 0; w < nWords; w++ )
+ {
+ Word = (~(p1->pData[w] ^ (p1->pData[w] >> 1))) & (p2->pData[w] ^ (p2->pData[w] >> 1)) & 0x55555555;
+ if ( Word == 0 )
+ continue;
+ if ( !Gia_WordHasOneBit(Word) )
+ return -1;
+ // has exactly one bit
+ if ( iVar >= 0 )
+ return -1;
+ // the first variable of this type
+ iVar = 16 * w + Gia_WordFindFirstBit( Word ) / 2;
+ }
+ return iVar;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the number of a variable for merging the cubes.]
+
+ Description [If there is exactly one such variable, returns its index.
+ Otherwise returns -1.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Gia_StaAreDisjointVar( Gia_StaAre_t * p1, Gia_StaAre_t * p2, int nWords )
+{
+ unsigned Word;
+ int w, iVar = -1;
+ for ( w = 0; w < nWords; w++ )
+ {
+ Word = (p1->pData[w] ^ p2->pData[w]) & ((p1->pData[w] ^ p2->pData[w]) >> 1) & 0x55555555;
+ if ( Word == 0 )
+ continue;
+ if ( !Gia_WordHasOneBit(Word) )
+ return -1;
+ // has exactly one bit
+ if ( iVar >= 0 )
+ return -1;
+ // the first variable of this type
+ iVar = 16 * w + Gia_WordFindFirstBit( Word ) / 2;
+ }
+ return iVar;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates reachability manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_ManAre_t * Gia_ManAreCreate( Gia_Man_t * pAig )
+{
+ Gia_ManAre_t * p;
+ assert( sizeof(Gia_ObjAre_t) == 16 );
+ p = ABC_CALLOC( Gia_ManAre_t, 1 );
+ p->pAig = pAig;
+ p->nWords = Gia_BitWordNum( 2 * Gia_ManRegNum(pAig) );
+ p->nSize = sizeof(Gia_StaAre_t)/4 + p->nWords;
+ p->ppObjs = ABC_CALLOC( unsigned *, MAX_PAGE_NUM );
+ p->ppStas = ABC_CALLOC( unsigned *, MAX_PAGE_NUM );
+ p->vCiTfos = Gia_ManDeriveCiTfo( pAig );
+ p->vCiLits = Vec_VecDupInt( p->vCiTfos );
+ p->vCubesA = Vec_IntAlloc( 100 );
+ p->vCubesB = Vec_IntAlloc( 100 );
+ p->iOutFail = -1;
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Deletes reachability manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManAreFree( Gia_ManAre_t * p )
+{
+ int i;
+ Gia_ManStop( p->pAig );
+ if ( p->pNew )
+ Gia_ManStop( p->pNew );
+ Vec_IntFree( p->vCubesA );
+ Vec_IntFree( p->vCubesB );
+ Vec_VecFree( p->vCiTfos );
+ Vec_VecFree( p->vCiLits );
+ for ( i = 0; i < p->nObjPages; i++ )
+ ABC_FREE( p->ppObjs[i] );
+ ABC_FREE( p->ppObjs );
+ for ( i = 0; i < p->nStaPages; i++ )
+ ABC_FREE( p->ppStas[i] );
+ ABC_FREE( p->ppStas );
+// ABC_FREE( p->pfUseless );
+ ABC_FREE( p );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns new object.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline Gia_ObjAre_t * Gia_ManAreCreateObj( Gia_ManAre_t * p )
+{
+ if ( p->nObjs == p->nObjPages * MAX_ITEM_NUM )
+ {
+ if ( p->nObjPages == MAX_PAGE_NUM )
+ {
+ printf( "ERA manager has run out of memory after allocating 2B internal nodes.\n" );
+ return NULL;
+ }
+ p->ppObjs[p->nObjPages++] = ABC_CALLOC( unsigned, MAX_ITEM_NUM * 4 );
+ if ( p->nObjs == 0 )
+ p->nObjs = 1;
+ }
+ return Gia_ManAreObjInt( p, p->nObjs++ );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns new state.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline Gia_StaAre_t * Gia_ManAreCreateSta( Gia_ManAre_t * p )
+{
+ if ( p->nStas == p->nStaPages * MAX_ITEM_NUM )
+ {
+ if ( p->nStaPages == MAX_PAGE_NUM )
+ {
+ printf( "ERA manager has run out of memory after allocating 2B state cubes.\n" );
+ return NULL;
+ }
+ if ( p->ppStas[p->nStaPages] == NULL )
+ p->ppStas[p->nStaPages] = ABC_CALLOC( unsigned, MAX_ITEM_NUM * p->nSize );
+ p->nStaPages++;
+ if ( p->nStas == 0 )
+ {
+ p->nStas = 1;
+// p->nUselessAlloc = (1 << 18);
+// p->pfUseless = ABC_CALLOC( unsigned, p->nUselessAlloc );
+ }
+// if ( p->nStas == p->nUselessAlloc * 32 )
+// {
+// p->nUselessAlloc *= 2;
+// p->pfUseless = ABC_REALLOC( unsigned, p->pfUseless, p->nUselessAlloc );
+// memset( p->pfUseless + p->nUselessAlloc/2, 0, sizeof(unsigned) * p->nUselessAlloc/2 );
+// }
+ }
+ return Gia_ManAreStaInt( p, p->nStas++ );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Recycles new state.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Gia_ManAreRycycleSta( Gia_ManAre_t * p, Gia_StaAre_t * pSta )
+{
+ memset( pSta, 0, p->nSize << 2 );
+ if ( pSta == Gia_ManAreStaLast(p) )
+ {
+ p->nStas--;
+ if ( p->nStas == (p->nStaPages-1) * MAX_ITEM_NUM )
+ p->nStaPages--;
+ }
+ else
+ {
+// Gia_StaSetUnused( pSta );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates new state state from the latch values.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline Gia_StaAre_t * Gia_ManAreCreateStaNew( Gia_ManAre_t * p )
+{
+ Gia_StaAre_t * pSta;
+ Gia_Obj_t * pObj;
+ int i;
+ pSta = Gia_ManAreCreateSta( p );
+ Gia_ManForEachRi( p->pAig, pObj, i )
+ {
+ if ( pObj->Value == 0 )
+ Gia_StaSetValue0( pSta, i );
+ else if ( pObj->Value == 1 )
+ Gia_StaSetValue1( pSta, i );
+ }
+ return pSta;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates new state state with latch init values.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline Gia_StaAre_t * Gia_ManAreCreateStaInit( Gia_ManAre_t * p )
+{
+ Gia_Obj_t * pObj;
+ int i;
+ Gia_ManForEachRi( p->pAig, pObj, i )
+ pObj->Value = 0;
+ return Gia_ManAreCreateStaNew( p );
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Prints the state cube.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManArePrintCube( Gia_ManAre_t * p, Gia_StaAre_t * pSta )
+{
+ Gia_Obj_t * pObj;
+ int i, Count0 = 0, Count1 = 0, Count2 = 0;
+ printf( "%4d %4d : ", p->iStaCur, p->nStas-1 );
+ printf( "Prev %4d ", Gia_Ptr2Int(pSta->iPrev) );
+ printf( "%p ", pSta );
+ Gia_ManForEachRi( p->pAig, pObj, i )
+ {
+ if ( Gia_StaHasValue0(pSta, i) )
+ printf( "0" ), Count0++;
+ else if ( Gia_StaHasValue1(pSta, i) )
+ printf( "1" ), Count1++;
+ else
+ printf( "-" ), Count2++;
+ }
+ printf( " 0 =%3d", Count0 );
+ printf( " 1 =%3d", Count1 );
+ printf( " - =%3d", Count2 );
+ printf( "\n" );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Counts the depth of state transitions leading ot this state.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManAreDepth( Gia_ManAre_t * p, int iState )
+{
+ Gia_StaAre_t * pSta;
+ int Counter = 0;
+ for ( pSta = Gia_ManAreStaInt(p, iState); Gia_StaIsGood(p, pSta); pSta = Gia_StaPrev(p, pSta) )
+ Counter++;
+ return Counter;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Counts the number of cubes in the list.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Gia_ManAreListCountListUsed( Gia_ManAre_t * p, Gia_PtrAre_t Root )
+{
+ Gia_StaAre_t * pCube;
+ int Counter = 0;
+ Gia_ManAreForEachCubeList( p, Gia_ManAreSta(p, Root), pCube )
+ Counter += Gia_StaIsUsed(pCube);
+ return Counter;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Counts the number of used cubes in the tree.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManAreListCountUsed_rec( Gia_ManAre_t * p, Gia_PtrAre_t Root, int fTree )
+{
+ Gia_ObjAre_t * pObj;
+ if ( !fTree )
+ return Gia_ManAreListCountListUsed( p, Root );
+ pObj = Gia_ManAreObj(p, Root);
+ return Gia_ManAreListCountUsed_rec( p, pObj->F[0], Gia_ObjHasBranch0(pObj) ) +
+ Gia_ManAreListCountUsed_rec( p, pObj->F[1], Gia_ObjHasBranch1(pObj) ) +
+ Gia_ManAreListCountUsed_rec( p, pObj->F[2], Gia_ObjHasBranch2(pObj) );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Counts the number of used cubes in the tree.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Gia_ManAreListCountUsed( Gia_ManAre_t * p )
+{
+ return Gia_ManAreListCountUsed_rec( p, p->Root, p->fTree );
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Prints used cubes in the list.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Gia_ManArePrintListUsed( Gia_ManAre_t * p, Gia_PtrAre_t Root )
+{
+ Gia_StaAre_t * pCube;
+ Gia_ManAreForEachCubeList( p, Gia_ManAreSta(p, Root), pCube )
+ if ( Gia_StaIsUsed(pCube) )
+ Gia_ManArePrintCube( p, pCube );
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Prints used cubes in the tree.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManArePrintUsed_rec( Gia_ManAre_t * p, Gia_PtrAre_t Root, int fTree )
+{
+ Gia_ObjAre_t * pObj;
+ if ( !fTree )
+ return Gia_ManArePrintListUsed( p, Root );
+ pObj = Gia_ManAreObj(p, Root);
+ return Gia_ManArePrintUsed_rec( p, pObj->F[0], Gia_ObjHasBranch0(pObj) ) +
+ Gia_ManArePrintUsed_rec( p, pObj->F[1], Gia_ObjHasBranch1(pObj) ) +
+ Gia_ManArePrintUsed_rec( p, pObj->F[2], Gia_ObjHasBranch2(pObj) );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Prints used cubes in the tree.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Gia_ManArePrintUsed( Gia_ManAre_t * p )
+{
+ return Gia_ManArePrintUsed_rec( p, p->Root, p->fTree );
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Best var has max weight.]
+
+ Description [Weight is defined as the number of 0/1-lits minus the
+ absolute value of the diff between the number of 0-lits and 1-lits.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManAreFindBestVar( Gia_ManAre_t * p, Gia_PtrAre_t List )
+{
+ Gia_StaAre_t * pCube;
+ int Count0, Count1, Count2;
+ int iVarThis, iVarBest = -1, WeightThis, WeightBest = -1;
+ for ( iVarThis = 0; iVarThis < Gia_ManRegNum(p->pAig); iVarThis++ )
+ {
+ Count0 = Count1 = Count2 = 0;
+ Gia_ManAreForEachCubeList( p, Gia_ManAreSta(p, List), pCube )
+ {
+ if ( Gia_StaIsUnused(pCube) )
+ continue;
+ if ( Gia_StaHasValue0(pCube, iVarThis) )
+ Count0++;
+ else if ( Gia_StaHasValue1(pCube, iVarThis) )
+ Count1++;
+ else
+ Count2++;
+ }
+// printf( "%4d : %5d %5d %5d Weight = %5d\n", iVarThis, Count0, Count1, Count2,
+// Count0 + Count1 - (Count0 > Count1 ? Count0 - Count1 : Count1 - Count0) );
+ if ( (!Count0 && !Count1) || (!Count0 && !Count2) || (!Count1 && !Count2) )
+ continue;
+ WeightThis = Count0 + Count1 - (Count0 > Count1 ? Count0 - Count1 : Count1 - Count0);
+ if ( WeightBest < WeightThis )
+ {
+ WeightBest = WeightThis;
+ iVarBest = iVarThis;
+ }
+ }
+ if ( iVarBest == -1 )
+ {
+ Gia_ManArePrintListUsed( p, List );
+ printf( "Error: Best variable not found!!!\n" );
+ }
+ assert( iVarBest != -1 );
+ return iVarBest;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Rebalances the tree when cubes exceed the limit.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Gia_ManAreRebalance( Gia_ManAre_t * p, Gia_PtrAre_t * pRoot )
+{
+ Gia_ObjAre_t * pNode;
+ Gia_StaAre_t * pCube;
+ Gia_PtrAre_t iCube, iNext;
+ assert( pRoot->nItem || pRoot->nPage );
+ pNode = Gia_ManAreCreateObj( p );
+ pNode->iVar = Gia_ManAreFindBestVar( p, *pRoot );
+ for ( iCube = *pRoot, pCube = Gia_ManAreSta(p, iCube), iNext = pCube->iNext;
+ Gia_StaIsGood(p, pCube);
+ iCube = iNext, pCube = Gia_ManAreSta(p, iCube), iNext = pCube->iNext )
+ {
+ if ( Gia_StaIsUnused(pCube) )
+ continue;
+ if ( Gia_StaHasValue0(pCube, pNode->iVar) )
+ pCube->iNext = pNode->F[0], pNode->F[0] = iCube, pNode->nStas0++;
+ else if ( Gia_StaHasValue1(pCube, pNode->iVar) )
+ pCube->iNext = pNode->F[1], pNode->F[1] = iCube, pNode->nStas1++;
+ else
+ pCube->iNext = pNode->F[2], pNode->F[2] = iCube, pNode->nStas2++;
+ }
+ *pRoot = Gia_Int2Ptr(p->nObjs - 1);
+ assert( pNode == Gia_ManAreObj(p, *pRoot) );
+ p->fTree = 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Compresses the list by removing unused cubes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Gia_ManAreCompress( Gia_ManAre_t * p, Gia_PtrAre_t * pRoot )
+{
+ Gia_StaAre_t * pCube;
+ Gia_PtrAre_t iList = *pRoot;
+ Gia_PtrAre_t iCube, iNext;
+ assert( pRoot->nItem || pRoot->nPage );
+ pRoot->nItem = 0;
+ pRoot->nPage = 0;
+ for ( iCube = iList, pCube = Gia_ManAreSta(p, iCube), iNext = pCube->iNext;
+ Gia_StaIsGood(p, pCube);
+ iCube = iNext, pCube = Gia_ManAreSta(p, iCube), iNext = pCube->iNext )
+ {
+ if ( Gia_StaIsUnused(pCube) )
+ continue;
+ pCube->iNext = *pRoot;
+ *pRoot = iCube;
+ }
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Checks if the state exists in the list.]
+
+ Description [The state may be sharped.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Gia_ManAreCubeCheckList( Gia_ManAre_t * p, Gia_PtrAre_t * pRoot, Gia_StaAre_t * pSta )
+{
+ int fVerbose = 0;
+ Gia_StaAre_t * pCube;
+ int iVar;
+if ( fVerbose )
+{
+printf( "Trying cube: " );
+Gia_ManArePrintCube( p, pSta );
+}
+ Gia_ManAreForEachCubeList( p, Gia_ManAreSta(p, *pRoot), pCube )
+ {
+ p->nChecks++;
+ if ( Gia_StaIsUnused( pCube ) )
+ continue;
+ if ( Gia_StaAreDisjoint( pSta, pCube, p->nWords ) )
+ continue;
+ if ( Gia_StaAreContain( pCube, pSta, p->nWords ) )
+ {
+if ( fVerbose )
+{
+printf( "Contained in " );
+Gia_ManArePrintCube( p, pCube );
+}
+ Gia_ManAreRycycleSta( p, pSta );
+ return 0;
+ }
+ if ( Gia_StaAreContain( pSta, pCube, p->nWords ) )
+ {
+if ( fVerbose )
+{
+printf( "Contains " );
+Gia_ManArePrintCube( p, pCube );
+}
+ Gia_StaSetUnused( pCube );
+ continue;
+ }
+ iVar = Gia_StaAreSharpVar( pSta, pCube, p->nWords );
+ if ( iVar == -1 )
+ continue;
+if ( fVerbose )
+{
+printf( "Sharped by " );
+Gia_ManArePrintCube( p, pCube );
+Gia_ManArePrintCube( p, pSta );
+}
+// printf( "%d %d\n", Gia_StaAreDashNum( pSta, pCube, p->nWords ), Gia_StaAreSharpVar( pSta, pCube, p->nWords ) );
+ assert( !Gia_StaHasValue0(pSta, iVar) && !Gia_StaHasValue1(pSta, iVar) );
+ assert( Gia_StaHasValue0(pCube, iVar) ^ Gia_StaHasValue1(pCube, iVar) );
+ if ( Gia_StaHasValue0(pCube, iVar) )
+ Gia_StaSetValue1( pSta, iVar );
+ else
+ Gia_StaSetValue0( pSta, iVar );
+// return Gia_ManAreCubeCheckList( p, pRoot, pSta );
+ }
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Adds new state to the list.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Gia_ManAreCubeAddToList( Gia_ManAre_t * p, Gia_PtrAre_t * pRoot, Gia_StaAre_t * pSta )
+{
+ int fVerbose = 0;
+ pSta->iNext = *pRoot;
+ *pRoot = Gia_Int2Ptr( p->nStas - 1 );
+ assert( pSta == Gia_ManAreSta(p, *pRoot) );
+if ( fVerbose )
+{
+printf( "Adding cube: " );
+Gia_ManArePrintCube( p, pSta );
+//printf( "\n" );
+}
+}
+
+/**Function*************************************************************
+
+ Synopsis [Checks if the cube like this exists in the tree.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManAreCubeCheckTree_rec( Gia_ManAre_t * p, Gia_ObjAre_t * pObj, Gia_StaAre_t * pSta )
+{
+ int RetValue;
+ if ( Gia_StaHasValue0(pSta, pObj->iVar) )
+ {
+ if ( Gia_ObjHasBranch0(pObj) )
+ RetValue = Gia_ManAreCubeCheckTree_rec( p, Gia_ObjNextObj0(p, pObj), pSta );
+ else
+ RetValue = Gia_ManAreCubeCheckList( p, pObj->F, pSta );
+ if ( RetValue == 0 )
+ return 0;
+ }
+ else if ( Gia_StaHasValue1(pSta, pObj->iVar) )
+ {
+ if ( Gia_ObjHasBranch1(pObj) )
+ RetValue = Gia_ManAreCubeCheckTree_rec( p, Gia_ObjNextObj1(p, pObj), pSta );
+ else
+ RetValue = Gia_ManAreCubeCheckList( p, pObj->F + 1, pSta );
+ if ( RetValue == 0 )
+ return 0;
+ }
+ if ( Gia_ObjHasBranch2(pObj) )
+ return Gia_ManAreCubeCheckTree_rec( p, Gia_ObjNextObj2(p, pObj), pSta );
+ return Gia_ManAreCubeCheckList( p, pObj->F + 2, pSta );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Adds new cube to the tree.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManAreCubeAddToTree_rec( Gia_ManAre_t * p, Gia_ObjAre_t * pObj, Gia_StaAre_t * pSta )
+{
+ if ( Gia_StaHasValue0(pSta, pObj->iVar) )
+ {
+ if ( Gia_ObjHasBranch0(pObj) )
+ Gia_ManAreCubeAddToTree_rec( p, Gia_ObjNextObj0(p, pObj), pSta );
+ else
+ {
+ Gia_ManAreCubeAddToList( p, pObj->F, pSta );
+ if ( ++pObj->nStas0 == MAX_CUBE_NUM )
+ {
+ pObj->nStas0 = Gia_ManAreListCountListUsed( p, pObj->F[0] );
+ if ( pObj->nStas0 < MAX_CUBE_NUM/2 )
+ Gia_ManAreCompress( p, pObj->F );
+ else
+ {
+ Gia_ManAreRebalance( p, pObj->F );
+ pObj->nStas0 = 0;
+ }
+ }
+ }
+ }
+ else if ( Gia_StaHasValue1(pSta, pObj->iVar) )
+ {
+ if ( Gia_ObjHasBranch1(pObj) )
+ Gia_ManAreCubeAddToTree_rec( p, Gia_ObjNextObj1(p, pObj), pSta );
+ else
+ {
+ Gia_ManAreCubeAddToList( p, pObj->F+1, pSta );
+ if ( ++pObj->nStas1 == MAX_CUBE_NUM )
+ {
+ pObj->nStas1 = Gia_ManAreListCountListUsed( p, pObj->F[1] );
+ if ( pObj->nStas1 < MAX_CUBE_NUM/2 )
+ Gia_ManAreCompress( p, pObj->F+1 );
+ else
+ {
+ Gia_ManAreRebalance( p, pObj->F+1 );
+ pObj->nStas1 = 0;
+ }
+ }
+ }
+ }
+ else
+ {
+ if ( Gia_ObjHasBranch2(pObj) )
+ Gia_ManAreCubeAddToTree_rec( p, Gia_ObjNextObj2(p, pObj), pSta );
+ else
+ {
+ Gia_ManAreCubeAddToList( p, pObj->F+2, pSta );
+ if ( ++pObj->nStas2 == MAX_CUBE_NUM )
+ {
+ pObj->nStas2 = Gia_ManAreListCountListUsed( p, pObj->F[2] );
+ if ( pObj->nStas2 < MAX_CUBE_NUM/2 )
+ Gia_ManAreCompress( p, pObj->F+2 );
+ else
+ {
+ Gia_ManAreRebalance( p, pObj->F+2 );
+ pObj->nStas2 = 0;
+ }
+ }
+ }
+ }
+}
+
+
+
+/**Function*************************************************************
+
+ Synopsis [Collects overlapping cubes in the list.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Gia_ManAreCubeCollectList( Gia_ManAre_t * p, Gia_PtrAre_t * pRoot, Gia_StaAre_t * pSta )
+{
+ Gia_StaAre_t * pCube;
+ int iCube;
+ Gia_ManAreForEachCubeList2( p, *pRoot, pCube, iCube )
+ {
+ if ( Gia_StaIsUnused( pCube ) )
+ continue;
+ if ( Gia_StaAreDisjoint( pSta, pCube, p->nWords ) )
+ {
+/*
+ int iVar;
+ p->nDisjs++;
+ iVar = Gia_StaAreDisjointVar( pSta, pCube, p->nWords );
+ if ( iVar >= 0 )
+ {
+ p->nDisjs2++;
+ if ( iCube > p->iStaCur )
+ p->nDisjs3++;
+ }
+*/
+ continue;
+ }
+// p->nCompares++;
+// p->nEquals += Gia_StaAreEqual( pSta, pCube, p->nWords );
+ if ( iCube <= p->iStaCur )
+ Vec_IntPush( p->vCubesA, iCube );
+ else
+ Vec_IntPush( p->vCubesB, iCube );
+ }
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Collects overlapping cubes in the tree.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManAreCubeCollectTree_rec( Gia_ManAre_t * p, Gia_ObjAre_t * pObj, Gia_StaAre_t * pSta )
+{
+ int RetValue;
+ if ( Gia_StaHasValue0(pSta, pObj->iVar) )
+ {
+ if ( Gia_ObjHasBranch0(pObj) )
+ RetValue = Gia_ManAreCubeCollectTree_rec( p, Gia_ObjNextObj0(p, pObj), pSta );
+ else
+ RetValue = Gia_ManAreCubeCollectList( p, pObj->F, pSta );
+ if ( RetValue == 0 )
+ return 0;
+ }
+ else if ( Gia_StaHasValue1(pSta, pObj->iVar) )
+ {
+ if ( Gia_ObjHasBranch1(pObj) )
+ RetValue = Gia_ManAreCubeCollectTree_rec( p, Gia_ObjNextObj1(p, pObj), pSta );
+ else
+ RetValue = Gia_ManAreCubeCollectList( p, pObj->F + 1, pSta );
+ if ( RetValue == 0 )
+ return 0;
+ }
+ if ( Gia_ObjHasBranch2(pObj) )
+ return Gia_ManAreCubeCollectTree_rec( p, Gia_ObjNextObj2(p, pObj), pSta );
+ return Gia_ManAreCubeCollectList( p, pObj->F + 2, pSta );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Checks if the cube like this exists in the tree.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManAreCubeCheckTree( Gia_ManAre_t * p, Gia_StaAre_t * pSta )
+{
+ Gia_StaAre_t * pCube;
+ int i, iVar;
+ assert( p->fTree );
+ Vec_IntClear( p->vCubesA );
+ Vec_IntClear( p->vCubesB );
+ Gia_ManAreCubeCollectTree_rec( p, Gia_ManAreObj(p, p->Root), pSta );
+// if ( p->nStas > 3000 )
+// printf( "%d %d \n", Vec_IntSize(p->vCubesA), Vec_IntSize(p->vCubesB) );
+// Vec_IntSort( p->vCubesA, 0 );
+// Vec_IntSort( p->vCubesB, 0 );
+ Gia_ManAreForEachCubeVec( p->vCubesA, p, pCube, i )
+ {
+ if ( Gia_StaIsUnused( pCube ) )
+ continue;
+ if ( Gia_StaAreDisjoint( pSta, pCube, p->nWords ) )
+ continue;
+ if ( Gia_StaAreContain( pCube, pSta, p->nWords ) )
+ {
+ Gia_ManAreRycycleSta( p, pSta );
+ return 0;
+ }
+ if ( Gia_StaAreContain( pSta, pCube, p->nWords ) )
+ {
+ Gia_StaSetUnused( pCube );
+ continue;
+ }
+ iVar = Gia_StaAreSharpVar( pSta, pCube, p->nWords );
+ if ( iVar == -1 )
+ continue;
+ assert( !Gia_StaHasValue0(pSta, iVar) && !Gia_StaHasValue1(pSta, iVar) );
+ assert( Gia_StaHasValue0(pCube, iVar) ^ Gia_StaHasValue1(pCube, iVar) );
+ if ( Gia_StaHasValue0(pCube, iVar) )
+ Gia_StaSetValue1( pSta, iVar );
+ else
+ Gia_StaSetValue0( pSta, iVar );
+ return Gia_ManAreCubeCheckTree( p, pSta );
+ }
+ Gia_ManAreForEachCubeVec( p->vCubesB, p, pCube, i )
+ {
+ if ( Gia_StaIsUnused( pCube ) )
+ continue;
+ if ( Gia_StaAreDisjoint( pSta, pCube, p->nWords ) )
+ continue;
+ if ( Gia_StaAreContain( pCube, pSta, p->nWords ) )
+ {
+ Gia_ManAreRycycleSta( p, pSta );
+ return 0;
+ }
+ if ( Gia_StaAreContain( pSta, pCube, p->nWords ) )
+ {
+ Gia_StaSetUnused( pCube );
+ continue;
+ }
+ iVar = Gia_StaAreSharpVar( pSta, pCube, p->nWords );
+ if ( iVar == -1 )
+ continue;
+ assert( !Gia_StaHasValue0(pSta, iVar) && !Gia_StaHasValue1(pSta, iVar) );
+ assert( Gia_StaHasValue0(pCube, iVar) ^ Gia_StaHasValue1(pCube, iVar) );
+ if ( Gia_StaHasValue0(pCube, iVar) )
+ Gia_StaSetValue1( pSta, iVar );
+ else
+ Gia_StaSetValue0( pSta, iVar );
+ return Gia_ManAreCubeCheckTree( p, pSta );
+ }
+/*
+ if ( p->nStas > 3000 )
+ {
+printf( "Trying cube: " );
+Gia_ManArePrintCube( p, pSta );
+ Gia_ManAreForEachCubeVec( p->vCubesA, p, pCube, i )
+ {
+printf( "aaaaaaaaaaaa %5d ", Vec_IntEntry(p->vCubesA,i) );
+Gia_ManArePrintCube( p, pCube );
+ }
+ Gia_ManAreForEachCubeVec( p->vCubesB, p, pCube, i )
+ {
+printf( "bbbbbbbbbbbb %5d ", Vec_IntEntry(p->vCubesB,i) );
+Gia_ManArePrintCube( p, pCube );
+ }
+ }
+*/
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Processes the new cube.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Gia_ManAreCubeProcess( Gia_ManAre_t * p, Gia_StaAre_t * pSta )
+{
+ int RetValue;
+ p->nChecks = 0;
+ if ( !p->fTree && p->nStas == MAX_CUBE_NUM )
+ Gia_ManAreRebalance( p, &p->Root );
+ if ( p->fTree )
+ {
+// RetValue = Gia_ManAreCubeCheckTree_rec( p, Gia_ManAreObj(p, p->Root), pSta );
+ RetValue = Gia_ManAreCubeCheckTree( p, pSta );
+ if ( RetValue )
+ Gia_ManAreCubeAddToTree_rec( p, Gia_ManAreObj(p, p->Root), pSta );
+ }
+ else
+ {
+ RetValue = Gia_ManAreCubeCheckList( p, &p->Root, pSta );
+ if ( RetValue )
+ Gia_ManAreCubeAddToList( p, &p->Root, pSta );
+ }
+// printf( "%d ", p->nChecks );
+ return RetValue;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Returns the most used CI, or NULL if condition is met.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManAreMostUsedPi_rec( Gia_Man_t * p, Gia_Obj_t * pObj )
+{
+ if ( Gia_ObjIsTravIdCurrent(p, pObj) )
+ return;
+ Gia_ObjSetTravIdCurrent(p, pObj);
+ if ( Gia_ObjIsCi(pObj) )
+ {
+ pObj->Value++;
+ return;
+ }
+ assert( Gia_ObjIsAnd(pObj) );
+ Gia_ManAreMostUsedPi_rec( p, Gia_ObjFanin0(pObj) );
+ Gia_ManAreMostUsedPi_rec( p, Gia_ObjFanin1(pObj) );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the most used CI, or NULL if condition is met.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline Gia_Obj_t * Gia_ManAreMostUsedPi( Gia_ManAre_t * p )
+{
+ Gia_Obj_t * pObj, * pObjMax = NULL;
+ int i;
+ // clean CI counters
+ Gia_ManForEachCi( p->pNew, pObj, i )
+ pObj->Value = 0;
+ // traverse from each register output
+ Gia_ManForEachRi( p->pAig, pObj, i )
+ {
+ if ( pObj->Value <= 1 )
+ continue;
+ Gia_ManIncrementTravId( p->pNew );
+ Gia_ManAreMostUsedPi_rec( p->pNew, Gia_ManObj(p->pNew, Gia_Lit2Var(pObj->Value)) );
+ }
+ // check the CI counters
+ Gia_ManForEachCi( p->pNew, pObj, i )
+ if ( pObjMax == NULL || pObjMax->Value < pObj->Value )
+ pObjMax = pObj;
+ // return the result
+ return pObjMax->Value > 1 ? pObjMax : NULL;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Counts maximum support of primary outputs.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManCheckPOs_rec( Gia_Man_t * p, Gia_Obj_t * pObj )
+{
+ if ( Gia_ObjIsTravIdCurrent(p, pObj) )
+ return 0;
+ Gia_ObjSetTravIdCurrent(p, pObj);
+ if ( Gia_ObjIsCi(pObj) )
+ return 1;
+ assert( Gia_ObjIsAnd(pObj) );
+ return Gia_ManCheckPOs_rec( p, Gia_ObjFanin0(pObj) ) +
+ Gia_ManCheckPOs_rec( p, Gia_ObjFanin1(pObj) );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Counts maximum support of primary outputs.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Gia_ManCheckPOs( Gia_ManAre_t * p )
+{
+ Gia_Obj_t * pObj, * pObjNew;
+ int i, CountCur, CountMax = 0;
+ Gia_ManForEachPo( p->pAig, pObj, i )
+ {
+ pObjNew = Gia_ManObj( p->pNew, Gia_Lit2Var(pObj->Value) );
+ if ( Gia_ObjIsConst0(pObjNew) )
+ CountCur = 0;
+ else
+ {
+ Gia_ManIncrementTravId( p->pNew );
+ CountCur = Gia_ManCheckPOs_rec( p->pNew, pObjNew );
+ }
+ CountMax = ABC_MAX( CountMax, CountCur );
+ }
+ return CountMax;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the status of the primary outputs.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Gia_ManCheckPOstatus( Gia_ManAre_t * p )
+{
+ Gia_Obj_t * pObj, * pObjNew;
+ int i;
+ Gia_ManForEachPo( p->pAig, pObj, i )
+ {
+ pObjNew = Gia_ManObj( p->pNew, Gia_Lit2Var(pObj->Value) );
+ if ( Gia_ObjIsConst0(pObjNew) )
+ {
+ if ( Gia_LitIsCompl(pObj->Value) )
+ {
+ p->iOutFail = i;
+ return 1;
+ }
+ }
+ else
+ {
+ p->iOutFail = i;
+// printf( "To fix later: PO may be assertable.\n" );
+ return 1;
+ }
+ }
+ return 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Derives next state cubes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManAreDeriveNexts_rec( Gia_ManAre_t * p, Gia_PtrAre_t Sta )
+{
+ Gia_Obj_t * pPivot;
+ Vec_Int_t * vLits, * vTfos;
+ Gia_Obj_t * pObj;
+ int i, clk;
+ if ( ++p->nRecCalls == MAX_CALL_NUM )
+ return 0;
+ if ( (pPivot = Gia_ManAreMostUsedPi(p)) == NULL )
+ {
+ Gia_StaAre_t * pNew;
+ clk = clock();
+ pNew = Gia_ManAreCreateStaNew( p );
+ pNew->iPrev = Sta;
+ p->fStopped = (p->fMiter && (Gia_ManCheckPOstatus(p) & 1));
+ if ( p->fStopped )
+ {
+ assert( p->pTarget == NULL );
+ p->pTarget = pNew;
+ return 1;
+ }
+ Gia_ManAreCubeProcess( p, pNew );
+ p->timeCube += clock() - clk;
+ return p->fStopped;
+ }
+ // remember values in the cone and perform update
+ vTfos = (Vec_Int_t *)Vec_VecEntry( p->vCiTfos, Gia_ObjCioId(pPivot) );
+ vLits = (Vec_Int_t *)Vec_VecEntry( p->vCiLits, Gia_ObjCioId(pPivot) );
+ assert( Vec_IntSize(vTfos) == Vec_IntSize(vLits) );
+ Gia_ManForEachObjVec( vTfos, p->pAig, pObj, i )
+ {
+ Vec_IntWriteEntry( vLits, i, pObj->Value );
+ if ( Gia_ObjIsAnd(pObj) )
+ pObj->Value = Gia_ManHashAnd( p->pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+ else if ( Gia_ObjIsCo(pObj) )
+ pObj->Value = Gia_ObjFanin0Copy(pObj);
+ else
+ {
+ assert( Gia_ObjIsCi(pObj) );
+ pObj->Value = 0;
+ }
+ }
+ if ( Gia_ManAreDeriveNexts_rec( p, Sta ) )
+ return 1;
+ // compute different values
+ Gia_ManForEachObjVec( vTfos, p->pAig, pObj, i )
+ {
+ if ( Gia_ObjIsAnd(pObj) )
+ pObj->Value = Gia_ManHashAnd( p->pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+ else if ( Gia_ObjIsCo(pObj) )
+ pObj->Value = Gia_ObjFanin0Copy(pObj);
+ else
+ {
+ assert( Gia_ObjIsCi(pObj) );
+ pObj->Value = 1;
+ }
+ }
+ if ( Gia_ManAreDeriveNexts_rec( p, Sta ) )
+ return 1;
+ // reset the original values
+ Gia_ManForEachObjVec( vTfos, p->pAig, pObj, i )
+ pObj->Value = Vec_IntEntry( vLits, i );
+ return 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Derives next state cubes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManAreDeriveNexts( Gia_ManAre_t * p, Gia_PtrAre_t Sta )
+{
+ Gia_StaAre_t * pSta;
+ Gia_Obj_t * pObj;
+ int i, RetValue, clk = clock();
+ pSta = Gia_ManAreSta( p, Sta );
+ if ( Gia_StaIsUnused(pSta) )
+ return 0;
+ // recycle the manager
+ if ( p->pNew && Gia_ManObjNum(p->pNew) > 1000000 )
+ {
+ Gia_ManStop( p->pNew );
+ p->pNew = NULL;
+ }
+ // allocate the manager
+ if ( p->pNew == NULL )
+ {
+ p->pNew = Gia_ManStart( 10 * Gia_ManObjNum(p->pAig) );
+ Gia_ManIncrementTravId( p->pNew );
+ Gia_ManHashAlloc( p->pNew );
+ Gia_ManConst0(p->pAig)->Value = 0;
+ Gia_ManForEachCi( p->pAig, pObj, i )
+ pObj->Value = Gia_ManAppendCi(p->pNew);
+ }
+ Gia_ManForEachRo( p->pAig, pObj, i )
+ {
+ if ( Gia_StaHasValue0( pSta, i ) )
+ pObj->Value = 0;
+ else if ( Gia_StaHasValue1( pSta, i ) )
+ pObj->Value = 1;
+ else // don't-care literal
+ pObj->Value = Gia_Var2Lit( Gia_ObjId( p->pNew, Gia_ManCi(p->pNew, Gia_ObjCioId(pObj)) ), 0 );
+ }
+ Gia_ManForEachAnd( p->pAig, pObj, i )
+ pObj->Value = Gia_ManHashAnd( p->pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+ Gia_ManForEachCo( p->pAig, pObj, i )
+ pObj->Value = Gia_ObjFanin0Copy(pObj);
+
+ // perform case-splitting
+ p->nRecCalls = 0;
+ RetValue = Gia_ManAreDeriveNexts_rec( p, Sta );
+ if ( p->nRecCalls >= MAX_CALL_NUM )
+ {
+ printf( "Exceeded the limit on the number of transitions from a state cube (%d).\n", MAX_CALL_NUM );
+ p->fStopped = 1;
+ }
+// printf( "%d ", p->nRecCalls );
+//printf( "%d ", Gia_ManObjNum(p->pNew) );
+ p->timeAig += clock() - clk;
+ return RetValue;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Prints the report]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManArePrintReport( Gia_ManAre_t * p, int Time, int fFinal )
+{
+ printf( "States =%10d. Reached =%10d. R = %5.3f. Depth =%6d. Mem =%9.2f Mb. ",
+ p->iStaCur, p->nStas, 1.0*p->iStaCur/p->nStas, Gia_ManAreDepth(p, p->iStaCur),
+ (sizeof(Gia_ManAre_t) + 4.0*Gia_ManRegNum(p->pAig) + 8.0*MAX_PAGE_NUM +
+ 4.0*p->nStaPages*p->nSize*MAX_ITEM_NUM + 16.0*p->nObjPages*MAX_ITEM_NUM)/(1<<20) );
+ if ( fFinal )
+ {
+ ABC_PRT( "Time", clock() - Time );
+ }
+ else
+ {
+ ABC_PRTr( "Time", clock() - Time );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs explicit reachability.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManArePerform( Gia_Man_t * pAig, int nStatesMax, int fMiter, int fVerbose )
+{
+// extern Gia_Man_t * Gia_ManCompress2( Gia_Man_t * p, int fUpdateLevel, int fVerbose );
+ extern Abc_Cex_t * Gia_ManAreDeriveCex( Gia_ManAre_t * p, Gia_StaAre_t * pLast );
+ Gia_ManAre_t * p;
+ int clk = clock();
+ int RetValue = 1;
+ if ( Gia_ManRegNum(pAig) > MAX_VARS_NUM )
+ {
+ printf( "Currently can only handle circuit with up to %d registers.\n", MAX_VARS_NUM );
+ return -1;
+ }
+ ABC_FREE( pAig->pCexSeq );
+ p = Gia_ManAreCreate( Gia_ManCompress2(pAig, 0, 0) );
+ p->fMiter = fMiter;
+ Gia_ManAreCubeProcess( p, Gia_ManAreCreateStaInit(p) );
+ for ( p->iStaCur = 1; p->iStaCur < p->nStas; p->iStaCur++ )
+ {
+// printf( "Explored state %d. Total cubes %d.\n", p->iStaCur, p->nStas-1 );
+ if ( Gia_ManAreDeriveNexts( p, Gia_Int2Ptr(p->iStaCur) ) || p->nStas > nStatesMax )
+ pAig->pCexSeq = Gia_ManAreDeriveCex( p, p->pTarget );
+ if ( p->fStopped )
+ {
+ RetValue = -1;
+ break;
+ }
+ if ( fVerbose && p->iStaCur % 5000 == 0 )
+ Gia_ManArePrintReport( p, clk, 0 );
+ }
+ Gia_ManArePrintReport( p, clk, 1 );
+ printf( "%s after finding %d state cubes (%d not contained) with depth %d. ",
+ p->fStopped ? "Stopped" : "Completed",
+ p->nStas, Gia_ManAreListCountUsed(p),
+ Gia_ManAreDepth(p, p->iStaCur-1) );
+ ABC_PRT( "Time", clock() - clk );
+ if ( pAig->pCexSeq != NULL )
+// printf( "Miter FAILED in state %d at frame %d (use \"&write_counter\" to dump a witness)\n",
+ printf( "Miter FAILED in state %d at frame %d (the cex is available for refinement)\n",
+ p->iStaCur, Gia_ManAreDepth(p, p->iStaCur)-1 );
+ if ( fVerbose )
+ {
+ ABC_PRTP( "Cofactoring", p->timeAig - p->timeCube, clock() - clk );
+ ABC_PRTP( "Containment", p->timeCube, clock() - clk );
+ ABC_PRTP( "Other ", clock() - clk - p->timeAig, clock() - clk );
+ ABC_PRTP( "TOTAL ", clock() - clk, clock() - clk );
+ }
+ if ( Gia_ManRegNum(pAig) <= 30 )
+ {
+ clk = clock();
+ printf( "The number of unique state minterms in computed state cubes is %d. ", Gia_ManCountMinterms(p) );
+ ABC_PRT( "Time", clock() - clk );
+ }
+// printf( "Compares = %d. Equals = %d. Disj = %d. Disj2 = %d. Disj3 = %d.\n",
+// p->nCompares, p->nEquals, p->nDisjs, p->nDisjs2, p->nDisjs3 );
+// Gia_ManAreFindBestVar( p, Gia_ManAreSta(p, p->Root) );
+// Gia_ManArePrintUsed( p );
+ Gia_ManAreFree( p );
+ // verify
+ if ( pAig->pCexSeq )
+ {
+ if ( !Gia_ManVerifyCounterExample( pAig, pAig->pCexSeq, 0 ) )
+ printf( "Generated counter-example is INVALID. \n" );
+ else
+ printf( "Generated counter-example verified correctly. \n" );
+ return 0;
+ }
+ return RetValue;
+}
+
+ABC_NAMESPACE_IMPL_END
+
+#include "giaAig.h"
+#include "cnf.h"
+#include "satSolver.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManAreDeriveCexSatStart( Gia_ManAre_t * p )
+{
+ Aig_Man_t * pAig2;
+ Cnf_Dat_t * pCnf;
+ assert( p->pSat == NULL );
+ pAig2 = Gia_ManToAig( p->pAig, 0 );
+ Aig_ManSetRegNum( pAig2, 0 );
+ pCnf = Cnf_Derive( pAig2, Gia_ManCoNum(p->pAig) );
+ p->pSat = Cnf_DataWriteIntoSolver( pCnf, 1, 0 );
+ p->vSatNumCis = Cnf_DataCollectCiSatNums( pCnf, pAig2 );
+ p->vSatNumCos = Cnf_DataCollectCoSatNums( pCnf, pAig2 );
+ Cnf_DataFree( pCnf );
+ Aig_ManStop( pAig2 );
+ p->vAssumps = Vec_IntAlloc( 100 );
+ p->vCofVars = Vec_IntAlloc( 100 );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManAreDeriveCexSatStop( Gia_ManAre_t * p )
+{
+ assert( p->pSat != NULL );
+ assert( p->pTarget != NULL );
+ sat_solver_delete( (sat_solver *)p->pSat );
+ Vec_IntFree( p->vSatNumCis );
+ Vec_IntFree( p->vSatNumCos );
+ Vec_IntFree( p->vAssumps );
+ Vec_IntFree( p->vCofVars );
+ p->pTarget = NULL;
+ p->pSat = NULL;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes satisfying assignment in one timeframe.]
+
+ Description [Returns the vector of integers represeting PIO ids
+ of the primary inputs that should be 1 in the counter-example.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManAreDeriveCexSat( Gia_ManAre_t * p, Gia_StaAre_t * pCur, Gia_StaAre_t * pNext, int iOutFailed )
+{
+ int i, status;
+ // make assuptions
+ Vec_IntClear( p->vAssumps );
+ for ( i = 0; i < Gia_ManRegNum(p->pAig); i++ )
+ {
+ if ( Gia_StaHasValue0(pCur, i) )
+ Vec_IntPush( p->vAssumps, Gia_Var2Lit( Vec_IntEntry(p->vSatNumCis, Gia_ManPiNum(p->pAig)+i), 1 ) );
+ else if ( Gia_StaHasValue1(pCur, i) )
+ Vec_IntPush( p->vAssumps, Gia_Var2Lit( Vec_IntEntry(p->vSatNumCis, Gia_ManPiNum(p->pAig)+i), 0 ) );
+ }
+ if ( pNext )
+ for ( i = 0; i < Gia_ManRegNum(p->pAig); i++ )
+ {
+ if ( Gia_StaHasValue0(pNext, i) )
+ Vec_IntPush( p->vAssumps, Gia_Var2Lit( Vec_IntEntry(p->vSatNumCos, Gia_ManPoNum(p->pAig)+i), 1 ) );
+ else if ( Gia_StaHasValue1(pNext, i) )
+ Vec_IntPush( p->vAssumps, Gia_Var2Lit( Vec_IntEntry(p->vSatNumCos, Gia_ManPoNum(p->pAig)+i), 0 ) );
+ }
+ if ( iOutFailed >= 0 )
+ {
+ assert( iOutFailed < Gia_ManPoNum(p->pAig) );
+ Vec_IntPush( p->vAssumps, Gia_Var2Lit( Vec_IntEntry(p->vSatNumCos, iOutFailed), 0 ) );
+ }
+ // solve SAT
+ status = sat_solver_solve( (sat_solver *)p->pSat, (int *)Vec_IntArray(p->vAssumps), (int *)Vec_IntArray(p->vAssumps) + Vec_IntSize(p->vAssumps),
+ (ABC_INT64_T)1000000, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
+ if ( status != l_True )
+ {
+ printf( "SAT problem is not satisfiable. Failure...\n" );
+ return;
+ }
+ assert( status == l_True );
+ // check the model
+ Vec_IntClear( p->vCofVars );
+ for ( i = 0; i < Gia_ManPiNum(p->pAig); i++ )
+ {
+ if ( sat_solver_var_value( (sat_solver *)p->pSat, Vec_IntEntry(p->vSatNumCis, i) ) )
+ Vec_IntPush( p->vCofVars, i );
+ }
+ // write the current state
+ for ( i = 0; i < Gia_ManRegNum(p->pAig); i++ )
+ {
+ if ( Gia_StaHasValue0(pCur, i) )
+ assert( sat_solver_var_value( (sat_solver *)p->pSat, Vec_IntEntry(p->vSatNumCis, Gia_ManPiNum(p->pAig)+i) ) == 0 );
+ else if ( Gia_StaHasValue1(pCur, i) )
+ assert( sat_solver_var_value( (sat_solver *)p->pSat, Vec_IntEntry(p->vSatNumCis, Gia_ManPiNum(p->pAig)+i) ) == 1 );
+ // set don't-care value
+ if ( sat_solver_var_value( (sat_solver *)p->pSat, Vec_IntEntry(p->vSatNumCis, Gia_ManPiNum(p->pAig)+i) ) == 0 )
+ Gia_StaSetValue0( pCur, i );
+ else
+ Gia_StaSetValue1( pCur, i );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the status of the cone.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Abc_Cex_t * Gia_ManAreDeriveCex( Gia_ManAre_t * p, Gia_StaAre_t * pLast )
+{
+ Abc_Cex_t * pCex;
+ Vec_Ptr_t * vStates;
+ Gia_StaAre_t * pSta, * pPrev;
+ int Var, i, v;
+ assert( p->iOutFail >= 0 );
+ Gia_ManAreDeriveCexSatStart( p );
+ // compute the trace
+ vStates = Vec_PtrAlloc( 1000 );
+ for ( pSta = pLast; Gia_StaIsGood(p, pSta); pSta = Gia_StaPrev(p, pSta) )
+ if ( pSta != pLast )
+ Vec_PtrPush( vStates, pSta );
+ assert( Vec_PtrSize(vStates) >= 1 );
+ // start the counter-example
+ pCex = Gia_ManAllocCounterExample( Gia_ManRegNum(p->pAig), Gia_ManPiNum(p->pAig), Vec_PtrSize(vStates) );
+ pCex->iFrame = Vec_PtrSize(vStates)-1;
+ pCex->iPo = p->iOutFail;
+ // compute states
+ pPrev = NULL;
+ Vec_PtrForEachEntry( Gia_StaAre_t *, vStates, pSta, i )
+ {
+ Gia_ManAreDeriveCexSat( p, pSta, pPrev, (i == 0) ? p->iOutFail : -1 );
+ pPrev = pSta;
+ // create the counter-example
+ Vec_IntForEachEntry( p->vCofVars, Var, v )
+ {
+ assert( Var < Gia_ManPiNum(p->pAig) );
+ Gia_InfoSetBit( pCex->pData, Gia_ManRegNum(p->pAig) + (Vec_PtrSize(vStates)-1-i) * Gia_ManPiNum(p->pAig) + Var );
+ }
+ }
+ // free temporary things
+ Vec_PtrFree( vStates );
+ Gia_ManAreDeriveCexSatStop( p );
+ return pCex;
+}
+
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaFanout.c b/src/aig/gia/giaFanout.c
index b32484af..c3e39405 100644
--- a/src/aig/gia/giaFanout.c
+++ b/src/aig/gia/giaFanout.c
@@ -20,6 +20,9 @@
#include "gia.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -195,3 +198,5 @@ void Gia_ObjRemoveFanout( Gia_Man_t * p, Gia_Obj_t * pObj, Gia_Obj_t * pFanout )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaForce.c b/src/aig/gia/giaForce.c
index 04c8f2e7..b9135404 100644
--- a/src/aig/gia/giaForce.c
+++ b/src/aig/gia/giaForce.c
@@ -20,9 +20,12 @@
#include "gia.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*
The code is based on the paper by F. A. Aloul, I. L. Markov, and K. A. Sakallah.
- "FORCE: A Fast and Easy-To-Implement Variable-Ordering Heuristic", Proc. GLSVLSI’03.
+ "FORCE: A Fast and Easy-To-Implement Variable-Ordering Heuristic", Proc. GLSVLSI�03.
http://www.eecs.umich.edu/~imarkov/pubs/conf/glsvlsi03-force.pdf
*/
@@ -1096,4 +1099,7 @@ Write = 1.81 sec
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
-//////////////////////////////////////////////////////////////////////// \ No newline at end of file
+////////////////////////////////////////////////////////////////////////
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaFrames.c b/src/aig/gia/giaFrames.c
index c0ea6680..75b17361 100644
--- a/src/aig/gia/giaFrames.c
+++ b/src/aig/gia/giaFrames.c
@@ -20,6 +20,9 @@
#include "gia.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -116,7 +119,7 @@ void Gia_ManFraSupports( Gia_ManFra_t * p )
p->vIns = Vec_PtrStart( p->pPars->nFrames );
p->vAnds = Vec_PtrStart( p->pPars->nFrames );
p->vOuts = Vec_PtrStart( p->pPars->nFrames );
- Gia_ManResetTravId( p->pAig );
+ Gia_ManIncrementTravId( p->pAig );
for ( f = p->pPars->nFrames - 1; f >= 0; f-- )
{
vOuts = Gia_ManCollectPoIds( p->pAig );
@@ -185,9 +188,9 @@ Gia_Man_t * Gia_ManFramesInit( Gia_Man_t * pAig, Gia_ParFra_t * pPars )
Gia_ManConst0(pAig)->Value = 0;
for ( f = 0; f < pPars->nFrames; f++ )
{
- vIns = Vec_PtrEntry( p->vIns, f );
- vAnds = Vec_PtrEntry( p->vAnds, f );
- vOuts = Vec_PtrEntry( p->vOuts, f );
+ vIns = (Vec_Int_t *)Vec_PtrEntry( p->vIns, f );
+ vAnds = (Vec_Int_t *)Vec_PtrEntry( p->vAnds, f );
+ vOuts = (Vec_Int_t *)Vec_PtrEntry( p->vOuts, f );
if ( pPars->fVerbose )
printf( "Frame %3d : CI = %6d. AND = %6d. CO = %6d.\n",
f, Vec_IntSize(vIns), Vec_IntSize(vAnds), Vec_IntSize(vOuts) );
@@ -344,3 +347,5 @@ Gia_Man_t * Gia_ManFrames( Gia_Man_t * pAig, Gia_ParFra_t * pPars )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaFront.c b/src/aig/gia/giaFront.c
index b3a3c2d0..6f1ce5a7 100644
--- a/src/aig/gia/giaFront.c
+++ b/src/aig/gia/giaFront.c
@@ -20,6 +20,9 @@
#include "gia.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -193,7 +196,7 @@ Gia_Man_t * Gia_ManFront( Gia_Man_t * p )
pFront[iFront] = 0;
}
assert( pNew->nObjs == p->nObjs );
- assert( nCrossCut == 0 && nCrossCutMax == nCrossCutMaxInit );
+ assert( nCrossCut == 0 || nCrossCutMax == nCrossCutMaxInit );
for ( i = 0; i < pNew->nFront; i++ )
assert( pFront[i] == 0 );
ABC_FREE( pFront );
@@ -246,3 +249,5 @@ void Gia_ManFrontTest( Gia_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaGiarf.c b/src/aig/gia/giaGiarf.c
new file mode 100644
index 00000000..501f9bb3
--- /dev/null
+++ b/src/aig/gia/giaGiarf.c
@@ -0,0 +1,1077 @@
+/**CFile****************************************************************
+
+ FileName [gia.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Scalable AIG package.]
+
+ Synopsis []
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: gia.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+
+ABC_NAMESPACE_IMPL_START
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+// combinational simulation manager
+typedef struct Hcd_Man_t_ Hcd_Man_t;
+struct Hcd_Man_t_
+{
+ // parameters
+ Gia_Man_t * pGia; // the AIG to be used for simulation
+ int nBTLimit; // internal backtrack limit
+ int fVerbose; // internal verbose flag
+ // internal variables
+ unsigned * pSimInfo; // simulation info for each object
+ Vec_Ptr_t * vSimInfo; // pointers to the CI simulation info
+ Vec_Ptr_t * vSimPres; // pointers to the presense of simulation info
+ // temporaries
+ Vec_Int_t * vClassOld; // old class numbers
+ Vec_Int_t * vClassNew; // new class numbers
+ Vec_Int_t * vClassTemp; // temporary storage
+ Vec_Int_t * vRefinedC; // refined const reprs
+};
+
+static inline unsigned Hcd_ObjSim( Hcd_Man_t * p, int Id ) { return p->pSimInfo[Id]; }
+static inline unsigned * Hcd_ObjSimP( Hcd_Man_t * p, int Id ) { return p->pSimInfo + Id; }
+static inline unsigned Hcd_ObjSetSim( Hcd_Man_t * p, int Id, unsigned n ) { return p->pSimInfo[Id] = n; }
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Starts the fraiging manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Hcd_Man_t * Gia_ManEquivStart( Gia_Man_t * pGia, int nBTLimit, int fVerbose )
+{
+ Hcd_Man_t * p;
+ Gia_Obj_t * pObj;
+ int i;
+ p = ABC_CALLOC( Hcd_Man_t, 1 );
+ p->pGia = pGia;
+ p->nBTLimit = nBTLimit;
+ p->fVerbose = fVerbose;
+ p->pSimInfo = ABC_ALLOC( unsigned, Gia_ManObjNum(pGia) );
+ p->vClassOld = Vec_IntAlloc( 100 );
+ p->vClassNew = Vec_IntAlloc( 100 );
+ p->vClassTemp = Vec_IntAlloc( 100 );
+ p->vRefinedC = Vec_IntAlloc( 100 );
+ // collect simulation info
+ p->vSimInfo = Vec_PtrAlloc( 1000 );
+ Gia_ManForEachCi( pGia, pObj, i )
+ Vec_PtrPush( p->vSimInfo, Hcd_ObjSimP(p, Gia_ObjId(pGia,pObj)) );
+ p->vSimPres = Vec_PtrAllocSimInfo( Gia_ManCiNum(pGia), 1 );
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Starts the fraiging manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManEquivStop( Hcd_Man_t * p )
+{
+ Vec_PtrFree( p->vSimInfo );
+ Vec_PtrFree( p->vSimPres );
+ Vec_IntFree( p->vClassOld );
+ Vec_IntFree( p->vClassNew );
+ Vec_IntFree( p->vClassTemp );
+ Vec_IntFree( p->vRefinedC );
+ ABC_FREE( p->pSimInfo );
+ ABC_FREE( p );
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Compared two simulation infos.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Hcd_ManCompareEqual( unsigned s0, unsigned s1 )
+{
+ if ( (s0 & 1) == (s1 & 1) )
+ return s0 == s1;
+ else
+ return s0 ==~s1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Compares one simulation info.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Hcd_ManCompareConst( unsigned s )
+{
+ if ( s & 1 )
+ return s ==~0;
+ else
+ return s == 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates one equivalence class.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Hcd_ManClassCreate( Gia_Man_t * pGia, Vec_Int_t * vClass )
+{
+ int Repr = -1, EntPrev = -1, Ent, i;
+ assert( Vec_IntSize(vClass) > 0 );
+ Vec_IntForEachEntry( vClass, Ent, i )
+ {
+ if ( i == 0 )
+ {
+ Repr = Ent;
+ Gia_ObjSetRepr( pGia, Ent, -1 );
+ EntPrev = Ent;
+ }
+ else
+ {
+ Gia_ObjSetRepr( pGia, Ent, Repr );
+ Gia_ObjSetNext( pGia, EntPrev, Ent );
+ EntPrev = Ent;
+ }
+ }
+ Gia_ObjSetNext( pGia, EntPrev, 0 );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Refines one equivalence class.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Hcd_ManClassClassRemoveOne( Hcd_Man_t * p, int i )
+{
+ int iRepr, Ent;
+ if ( Gia_ObjIsConst(p->pGia, i) )
+ {
+ Gia_ObjSetRepr( p->pGia, i, GIA_VOID );
+ return 1;
+ }
+ if ( !Gia_ObjIsClass(p->pGia, i) )
+ return 0;
+ assert( Gia_ObjIsClass(p->pGia, i) );
+ iRepr = Gia_ObjRepr( p->pGia, i );
+ if ( iRepr == GIA_VOID )
+ iRepr = i;
+ // collect nodes
+ Vec_IntClear( p->vClassOld );
+ Vec_IntClear( p->vClassNew );
+ Gia_ClassForEachObj( p->pGia, iRepr, Ent )
+ {
+ if ( Ent == i )
+ Vec_IntPush( p->vClassNew, Ent );
+ else
+ Vec_IntPush( p->vClassOld, Ent );
+ }
+ assert( Vec_IntSize( p->vClassNew ) == 1 );
+ Hcd_ManClassCreate( p->pGia, p->vClassOld );
+ Hcd_ManClassCreate( p->pGia, p->vClassNew );
+ assert( !Gia_ObjIsClass(p->pGia, i) );
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Refines one equivalence class.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Hcd_ManClassRefineOne( Hcd_Man_t * p, int i )
+{
+ unsigned Sim0, Sim1;
+ int Ent;
+ Vec_IntClear( p->vClassOld );
+ Vec_IntClear( p->vClassNew );
+ Vec_IntPush( p->vClassOld, i );
+ Sim0 = Hcd_ObjSim(p, i);
+ Gia_ClassForEachObj1( p->pGia, i, Ent )
+ {
+ Sim1 = Hcd_ObjSim(p, Ent);
+ if ( Hcd_ManCompareEqual( Sim0, Sim1 ) )
+ Vec_IntPush( p->vClassOld, Ent );
+ else
+ Vec_IntPush( p->vClassNew, Ent );
+ }
+ if ( Vec_IntSize( p->vClassNew ) == 0 )
+ return 0;
+ Hcd_ManClassCreate( p->pGia, p->vClassOld );
+ Hcd_ManClassCreate( p->pGia, p->vClassNew );
+ if ( Vec_IntSize(p->vClassNew) > 1 )
+ return 1 + Hcd_ManClassRefineOne( p, Vec_IntEntry(p->vClassNew,0) );
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes hash key of the simulation info.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Hcd_ManHashKey( unsigned * pSim, int nWords, int nTableSize )
+{
+ static int s_Primes[16] = {
+ 1291, 1699, 1999, 2357, 2953, 3313, 3907, 4177,
+ 4831, 5147, 5647, 6343, 6899, 7103, 7873, 8147 };
+ unsigned uHash = 0;
+ int i;
+ if ( pSim[0] & 1 )
+ for ( i = 0; i < nWords; i++ )
+ uHash ^= ~pSim[i] * s_Primes[i & 0xf];
+ else
+ for ( i = 0; i < nWords; i++ )
+ uHash ^= pSim[i] * s_Primes[i & 0xf];
+ return (int)(uHash % nTableSize);
+
+}
+
+/**Function*************************************************************
+
+ Synopsis [Rehashes the refined classes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Hcd_ManClassesRehash( Hcd_Man_t * p, Vec_Int_t * vRefined )
+{
+ int * pTable, nTableSize, Key, i, k;
+ nTableSize = Gia_PrimeCudd( 100 + Vec_IntSize(vRefined) / 5 );
+ pTable = ABC_CALLOC( int, nTableSize );
+ Vec_IntForEachEntry( vRefined, i, k )
+ {
+ assert( !Hcd_ManCompareConst( Hcd_ObjSim(p, i) ) );
+ Key = Hcd_ManHashKey( Hcd_ObjSimP(p, i), 1, nTableSize );
+ if ( pTable[Key] == 0 )
+ Gia_ObjSetRepr( p->pGia, i, GIA_VOID );
+ else
+ {
+ Gia_ObjSetNext( p->pGia, pTable[Key], i );
+ Gia_ObjSetRepr( p->pGia, i, Gia_ObjRepr(p->pGia, pTable[Key]) );
+ if ( Gia_ObjRepr(p->pGia, i) == GIA_VOID )
+ Gia_ObjSetRepr( p->pGia, i, pTable[Key] );
+ }
+ pTable[Key] = i;
+ }
+ ABC_FREE( pTable );
+// Gia_ManEquivPrintClasses( p->pGia, 0, 0.0 );
+ // refine classes in the table
+ Vec_IntForEachEntry( vRefined, i, k )
+ {
+ if ( Gia_ObjIsHead( p->pGia, i ) )
+ Hcd_ManClassRefineOne( p, i );
+ }
+ Gia_ManEquivPrintClasses( p->pGia, 0, 0.0 );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Refines equivalence classes after simulation.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Hcd_ManClassesRefine( Hcd_Man_t * p )
+{
+ Gia_Obj_t * pObj;
+ int i;
+ Vec_IntClear( p->vRefinedC );
+ Gia_ManForEachAnd( p->pGia, pObj, i )
+ {
+ if ( Gia_ObjIsTail(p->pGia, i) ) // add check for the class level
+ {
+ Hcd_ManClassRefineOne( p, Gia_ObjRepr(p->pGia, i) );
+ }
+ else if ( Gia_ObjIsConst(p->pGia, i) )
+ {
+ if ( !Hcd_ManCompareConst( Hcd_ObjSim(p, i) ) )
+ Vec_IntPush( p->vRefinedC, i );
+ }
+ }
+ Hcd_ManClassesRehash( p, p->vRefinedC );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates equivalence classes for the first time.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Hcd_ManClassesCreate( Hcd_Man_t * p )
+{
+ Gia_Obj_t * pObj;
+ int i;
+ assert( p->pGia->pReprs == NULL );
+ p->pGia->pReprs = ABC_CALLOC( Gia_Rpr_t, Gia_ManObjNum(p->pGia) );
+ p->pGia->pNexts = ABC_CALLOC( int, Gia_ManObjNum(p->pGia) );
+ Gia_ManForEachObj( p->pGia, pObj, i )
+ Gia_ObjSetRepr( p->pGia, i, Gia_ObjIsAnd(pObj) ? 0 : GIA_VOID );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Initializes simulation info.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Hcd_ManSimulationInit( Hcd_Man_t * p )
+{
+ Gia_Obj_t * pObj;
+ int i;
+ Gia_ManForEachCi( p->pGia, pObj, i )
+ Hcd_ObjSetSim( p, i, (Gia_ManRandom(0) << 1) );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs one round of simple combinational simulation.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Hcd_ManSimulateSimple( Hcd_Man_t * p )
+{
+ Gia_Obj_t * pObj;
+ unsigned Res0, Res1;
+ int i;
+ Gia_ManForEachAnd( p->pGia, pObj, i )
+ {
+ Res0 = Hcd_ObjSim( p, Gia_ObjFaninId0(pObj, i) );
+ Res1 = Hcd_ObjSim( p, Gia_ObjFaninId1(pObj, i) );
+ Hcd_ObjSetSim( p, i, (Gia_ObjFaninC0(pObj)? ~Res0: Res0) &
+ (Gia_ObjFaninC1(pObj)? ~Res1: Res1) );
+ }
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Resimulate and refine one equivalence class.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+unsigned Gia_Resimulate_rec( Hcd_Man_t * p, int iObj )
+{
+ Gia_Obj_t * pObj;
+ unsigned Res0, Res1;
+ if ( Gia_ObjIsTravIdCurrentId( p->pGia, iObj ) )
+ return Hcd_ObjSim( p, iObj );
+ Gia_ObjSetTravIdCurrentId( p->pGia, iObj );
+ pObj = Gia_ManObj(p->pGia, iObj);
+ if ( Gia_ObjIsCi(pObj) )
+ return Hcd_ObjSim( p, iObj );
+ assert( Gia_ObjIsAnd(pObj) );
+ Res0 = Gia_Resimulate_rec( p, Gia_ObjFaninId0(pObj, iObj) );
+ Res1 = Gia_Resimulate_rec( p, Gia_ObjFaninId1(pObj, iObj) );
+ return Hcd_ObjSetSim( p, iObj, (Gia_ObjFaninC0(pObj)? ~Res0: Res0) &
+ (Gia_ObjFaninC1(pObj)? ~Res1: Res1) );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Resimulate and refine one equivalence class.]
+
+ Description [Assumes that the counter-example is assigned at the PIs.
+ The counter-example should have the first bit set to 0 at each PI.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ResimulateAndRefine( Hcd_Man_t * p, int i )
+{
+ int RetValue, iObj;
+ Gia_ManIncrementTravId( p->pGia );
+ Gia_ClassForEachObj( p->pGia, i, iObj )
+ Gia_Resimulate_rec( p, iObj );
+ RetValue = Hcd_ManClassRefineOne( p, i );
+ if ( RetValue == 0 )
+ printf( "!!! no refinement !!!\n" );
+// assert( RetValue );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns temporary representative of the node.]
+
+ Description [The temp repr is the first node among the nodes in the class that
+ (a) precedes the given node, and (b) whose level is lower than the given node.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline Gia_Obj_t * Gia_ObjTempRepr( Gia_Man_t * p, int i, int Level )
+{
+ int iRepr, iMember;
+ iRepr = Gia_ObjRepr( p, i );
+ if ( !Gia_ObjProved(p, i) )
+ return NULL;
+ if ( Gia_ObjFailed(p, i) )
+ return NULL;
+ if ( iRepr == GIA_VOID )
+ return NULL;
+ if ( iRepr == 0 )
+ return Gia_ManConst0( p );
+// if ( p->pLevels[iRepr] < Level )
+// return Gia_ManObj( p, iRepr );
+ Gia_ClassForEachObj( p, iRepr, iMember )
+ {
+ if ( Gia_ObjFailed(p, iMember) )
+ continue;
+ if ( iMember >= i )
+ return NULL;
+ if ( Gia_ObjLevelId(p, iMember) < Level )
+ return Gia_ManObj( p, iMember );
+ }
+ assert( 0 );
+ return NULL;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Generates reduced AIG for the given level.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_GenerateReducedLevel( Gia_Man_t * p, int Level, Vec_Ptr_t ** pvRoots )
+{
+ Gia_Man_t * pNew;
+ Gia_Obj_t * pObj, * pRepr;
+ Vec_Ptr_t * vRoots;
+ int i;
+ vRoots = Vec_PtrAlloc( 100 );
+ // copy unmarked nodes
+ pNew = Gia_ManStart( Gia_ManObjNum(p) );
+ pNew->pName = Gia_UtilStrsav( p->pName );
+ Gia_ManConst0(p)->Value = 0;
+ Gia_ManForEachCi( p, pObj, i )
+ pObj->Value = Gia_ManAppendCi(pNew);
+ Gia_ManHashAlloc( pNew );
+ Gia_ManForEachAnd( p, pObj, i )
+ {
+ if ( Gia_ObjLevelId(p, i) > Level )
+ continue;
+ if ( Gia_ObjLevelId(p, i) == Level )
+ Vec_PtrPush( vRoots, pObj );
+ if ( Gia_ObjLevelId(p, i) < Level && (pRepr = Gia_ObjTempRepr(p, i, Level)) )
+ {
+// printf( "Substituting %d <--- %d\n", Gia_ObjId(p, pRepr), Gia_ObjId(p, pObj) );
+ assert( pRepr < pObj );
+ pObj->Value = Gia_LitNotCond( pRepr->Value, Gia_ObjPhase(pRepr) ^ Gia_ObjPhase(pObj) );
+ continue;
+ }
+ pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+ }
+ *pvRoots = vRoots;
+ // required by SAT solving
+ Gia_ManCreateRefs( pNew );
+ Gia_ManFillValue( pNew );
+ Gia_ManIncrementTravId( pNew ); // needed for MiniSat to record cexes
+// Gia_ManSetPhase( pNew ); // needed if MiniSat is using polarity -- should not be enabled for TAS because fPhase is used to label
+ return pNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Collects relevant classes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Ptr_t * Gia_CollectRelatedClasses( Gia_Man_t * pGia, Vec_Ptr_t * vRoots )
+{
+ Vec_Ptr_t * vClasses;
+ Gia_Obj_t * pRoot, * pRepr;
+ int i;
+ vClasses = Vec_PtrAlloc( 100 );
+ Gia_ManConst0( pGia )->fMark0 = 1;
+ Vec_PtrForEachEntry( Gia_Obj_t *, vRoots, pRoot, i )
+ {
+ pRepr = Gia_ObjReprObj( pGia, Gia_ObjId(pGia, pRoot) );
+ if ( pRepr == NULL || pRepr->fMark0 )
+ continue;
+ pRepr->fMark0 = 1;
+ Vec_PtrPush( vClasses, pRepr );
+ }
+ Gia_ManConst0( pGia )->fMark0 = 0;
+ Vec_PtrForEachEntry( Gia_Obj_t *, vClasses, pRepr, i )
+ pRepr->fMark0 = 0;
+ return vClasses;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Collects class members.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Obj_t * Gia_CollectClassMembers( Gia_Man_t * p, Gia_Obj_t * pRepr, Vec_Ptr_t * vMembers, int Level )
+{
+ Gia_Obj_t * pTempRepr = NULL;
+ int iRepr, iMember;
+ iRepr = Gia_ObjId( p, pRepr );
+ Vec_PtrClear( vMembers );
+ Gia_ClassForEachObj( p, iRepr, iMember )
+ {
+ if ( Gia_ObjLevelId(p, iMember) == Level )
+ Vec_PtrPush( vMembers, Gia_ManObj( p, iMember ) );
+ if ( pTempRepr == NULL && Gia_ObjLevelId(p, iMember) < Level )
+ pTempRepr = Gia_ManObj( p, iMember );
+ }
+ return pTempRepr;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Packs patterns into array of simulation info.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+*************************************`**********************************/
+int Gia_GiarfStorePatternTry( Vec_Ptr_t * vInfo, Vec_Ptr_t * vPres, int iBit, int * pLits, int nLits )
+{
+ unsigned * pInfo, * pPres;
+ int i;
+ for ( i = 0; i < nLits; i++ )
+ {
+ pInfo = (unsigned *)Vec_PtrEntry(vInfo, Gia_Lit2Var(pLits[i]));
+ pPres = (unsigned *)Vec_PtrEntry(vPres, Gia_Lit2Var(pLits[i]));
+ if ( Gia_InfoHasBit( pPres, iBit ) &&
+ Gia_InfoHasBit( pInfo, iBit ) == Gia_LitIsCompl(pLits[i]) )
+ return 0;
+ }
+ for ( i = 0; i < nLits; i++ )
+ {
+ pInfo = (unsigned *)Vec_PtrEntry(vInfo, Gia_Lit2Var(pLits[i]));
+ pPres = (unsigned *)Vec_PtrEntry(vPres, Gia_Lit2Var(pLits[i]));
+ Gia_InfoSetBit( pPres, iBit );
+ if ( Gia_InfoHasBit( pInfo, iBit ) == Gia_LitIsCompl(pLits[i]) )
+ Gia_InfoXorBit( pInfo, iBit );
+ }
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Procedure to test the new SAT solver.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_GiarfStorePattern( Vec_Ptr_t * vSimInfo, Vec_Ptr_t * vPres, Vec_Int_t * vCex )
+{
+ int k;
+ for ( k = 1; k < 32; k++ )
+ if ( Gia_GiarfStorePatternTry( vSimInfo, vPres, k, (int *)Vec_IntArray(vCex), Vec_IntSize(vCex) ) )
+ break;
+ return (int)(k < 32);
+}
+
+/**Function*************************************************************
+
+ Synopsis [Inserts pattern into simulation info for the PIs.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_GiarfInsertPattern( Hcd_Man_t * p, Vec_Int_t * vCex, int k )
+{
+ Gia_Obj_t * pObj;
+ unsigned * pInfo;
+ int Lit, i;
+ Vec_IntForEachEntry( vCex, Lit, i )
+ {
+ pObj = Gia_ManCi( p->pGia, Gia_Lit2Var(Lit) );
+ pInfo = Hcd_ObjSimP( p, Gia_ObjId( p->pGia, pObj ) );
+ if ( Gia_InfoHasBit( pInfo, k ) == Gia_LitIsCompl(Lit) )
+ Gia_InfoXorBit( pInfo, k );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Inserts pattern into simulation info for the PIs.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_GiarfPrintClasses( Gia_Man_t * pGia )
+{
+ int nFails = 0;
+ int nProves = 0;
+ int nTotal = 0;
+ int nBoth = 0;
+ int i;
+ for ( i = 0; i < Gia_ManObjNum(pGia); i++ )
+ {
+ nFails += Gia_ObjFailed(pGia, i);
+ nProves += Gia_ObjProved(pGia, i);
+ nTotal += Gia_ObjReprObj(pGia, i) != NULL;
+ nBoth += Gia_ObjFailed(pGia, i) && Gia_ObjProved(pGia, i);
+ }
+ printf( "nFails = %7d. nProves = %7d. nBoth = %7d. nTotal = %7d.\n",
+ nFails, nProves, nBoth, nTotal );
+}
+
+ABC_NAMESPACE_IMPL_END
+
+#include "cecInt.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+/**Function*************************************************************
+
+ Synopsis [Performs computation of AIGs with choices.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ComputeEquivalencesLevel( Hcd_Man_t * p, Gia_Man_t * pGiaLev, Vec_Ptr_t * vOldRoots, int Level, int fUseMiniSat )
+{
+ int fUse2Solver = 0;
+ Cec_ManSat_t * pSat;
+ Cec_ParSat_t Pars;
+ Tas_Man_t * pTas;
+ Vec_Int_t * vCex;
+ Vec_Ptr_t * vClasses, * vMembers, * vOldRootsNew;
+ Gia_Obj_t * pRoot, * pMember, * pMemberPrev, * pRepr, * pTempRepr;
+ int i, k, nIter, iRoot, iRootNew, iMember, iMemberPrev, status, fOneFailed;//, iRepr;//, fTwoMember;
+ int nSaved = 0, nRecords = 0, nUndec = 0, nClassRefs = 0, nTsat = 0, nMiniSat = 0;
+ int clk, timeTsat = 0, timeMiniSat = 0, timeSim = 0, timeTotal = clock();
+ if ( Vec_PtrSize(vOldRoots) == 0 )
+ return 0;
+ // start SAT solvers
+ Cec_ManSatSetDefaultParams( &Pars );
+ Pars.fPolarFlip = 0;
+ Pars.nBTLimit = p->nBTLimit;
+ pSat = Cec_ManSatCreate( pGiaLev, &Pars );
+ pTas = Tas_ManAlloc( pGiaLev, p->nBTLimit );
+ if ( fUseMiniSat )
+ vCex = Cec_ManSatReadCex( pSat );
+ else
+ vCex = Tas_ReadModel( pTas );
+ vMembers = Vec_PtrAlloc( 100 );
+ Vec_PtrCleanSimInfo( p->vSimPres, 0, 1 );
+ // resolve constants
+ Vec_PtrForEachEntry( Gia_Obj_t *, vOldRoots, pRoot, i )
+ {
+ iRoot = Gia_ObjId( p->pGia, pRoot );
+ if ( !Gia_ObjIsConst( p->pGia, iRoot ) )
+ continue;
+ iRootNew = Gia_LitNotCond( pRoot->Value, pRoot->fPhase );
+ assert( iRootNew != 1 );
+ if ( fUse2Solver )
+ {
+ nTsat++;
+ clk = clock();
+ status = Tas_ManSolve( pTas, Gia_ObjFromLit(pGiaLev, iRootNew), NULL );
+ timeTsat += clock() - clk;
+ if ( status == -1 )
+ {
+ nMiniSat++;
+ clk = clock();
+ status = Cec_ManSatCheckNode( pSat, Gia_ObjFromLit(pGiaLev, iRootNew) );
+ timeMiniSat += clock() - clk;
+ if ( status == 0 )
+ {
+ Cec_ManSavePattern( pSat, Gia_ObjFromLit(pGiaLev, iRootNew), NULL );
+ vCex = Cec_ManSatReadCex( pSat );
+ }
+ }
+ else if ( status == 0 )
+ vCex = Tas_ReadModel( pTas );
+ }
+ else if ( fUseMiniSat )
+ {
+ nMiniSat++;
+ clk = clock();
+ status = Cec_ManSatCheckNode( pSat, Gia_ObjFromLit(pGiaLev, iRootNew) );
+ timeMiniSat += clock() - clk;
+ if ( status == 0 )
+ Cec_ManSavePattern( pSat, Gia_ObjFromLit(pGiaLev, iRootNew), NULL );
+ }
+ else
+ {
+ nTsat++;
+ clk = clock();
+ status = Tas_ManSolve( pTas, Gia_ObjFromLit(pGiaLev, iRootNew), NULL );
+ timeTsat += clock() - clk;
+ }
+ if ( status == -1 ) // undec
+ {
+// Gia_ObjSetFailed( p->pGia, iRoot );
+ nUndec++;
+// Hcd_ManClassClassRemoveOne( p, iRoot );
+ Gia_ObjSetFailed( p->pGia, iRoot );
+ }
+ else if ( status == 1 ) // unsat
+ {
+ Gia_ObjSetProved( p->pGia, iRoot );
+// printf( "proved constant %d\n", iRoot );
+ }
+ else // sat
+ {
+// printf( "Disproved constant %d\n", iRoot );
+ Gia_ObjUnsetRepr( p->pGia, iRoot ); // do we need this?
+ nRecords++;
+ nSaved += Gia_GiarfStorePattern( p->vSimInfo, p->vSimPres, vCex );
+ }
+ }
+
+ vClasses = Vec_PtrAlloc( 100 );
+ vOldRootsNew = Vec_PtrAlloc( 100 );
+ for ( nIter = 0; Vec_PtrSize(vOldRoots) > 0; nIter++ )
+ {
+// printf( "Iter = %d (Size = %d)\n", nIter, Vec_PtrSize(vOldRoots) );
+ // resolve equivalences
+ Vec_PtrClear( vClasses );
+ Vec_PtrClear( vOldRootsNew );
+ Gia_ManConst0( p->pGia )->fMark0 = 1;
+ Vec_PtrForEachEntry( Gia_Obj_t *, vOldRoots, pRoot, i )
+ {
+ iRoot = Gia_ObjId( p->pGia, pRoot );
+ if ( Gia_ObjIsHead( p->pGia, iRoot ) )
+ pRepr = pRoot;
+ else if ( Gia_ObjIsClass( p->pGia, iRoot ) )
+ pRepr = Gia_ObjReprObj( p->pGia, iRoot );
+ else
+ continue;
+ if ( pRepr->fMark0 )
+ continue;
+ pRepr->fMark0 = 1;
+ Vec_PtrPush( vClasses, pRepr );
+// iRepr = Gia_ObjId( p->pGia, pRepr );
+// fTwoMember = Gia_ClassIsPair(p->pGia, iRepr)
+ // derive temp repr and members on this level
+ pTempRepr = Gia_CollectClassMembers( p->pGia, pRepr, vMembers, Level );
+ if ( pTempRepr )
+ Vec_PtrPush( vMembers, pTempRepr );
+ if ( Vec_PtrSize(vMembers) < 2 )
+ continue;
+ // try proving the members
+ fOneFailed = 0;
+ pMemberPrev = (Gia_Obj_t *)Vec_PtrEntryLast( vMembers );
+ Vec_PtrForEachEntry( Gia_Obj_t *, vMembers, pMember, k )
+ {
+ iMemberPrev = Gia_LitNotCond( pMemberPrev->Value, pMemberPrev->fPhase );
+ iMember = Gia_LitNotCond( pMember->Value, !pMember->fPhase );
+ assert( iMemberPrev != iMember );
+ if ( fUse2Solver )
+ {
+ nTsat++;
+ clk = clock();
+ status = Tas_ManSolve( pTas, Gia_ObjFromLit(pGiaLev, iMemberPrev), Gia_ObjFromLit(pGiaLev, iMember) );
+ timeTsat += clock() - clk;
+ if ( status == -1 )
+ {
+ nMiniSat++;
+ clk = clock();
+ status = Cec_ManSatCheckNodeTwo( pSat, Gia_ObjFromLit(pGiaLev, iMemberPrev), Gia_ObjFromLit(pGiaLev, iMember) );
+ timeMiniSat += clock() - clk;
+ if ( status == 0 )
+ {
+ Cec_ManSavePattern( pSat, Gia_ObjFromLit(pGiaLev, iMemberPrev), Gia_ObjFromLit(pGiaLev, iMember) );
+ vCex = Cec_ManSatReadCex( pSat );
+ }
+ }
+ else if ( status == 0 )
+ vCex = Tas_ReadModel( pTas );
+ }
+ else if ( fUseMiniSat )
+ {
+ nMiniSat++;
+ clk = clock();
+ status = Cec_ManSatCheckNodeTwo( pSat, Gia_ObjFromLit(pGiaLev, iMemberPrev), Gia_ObjFromLit(pGiaLev, iMember) );
+ timeMiniSat += clock() - clk;
+ if ( status == 0 )
+ Cec_ManSavePattern( pSat, Gia_ObjFromLit(pGiaLev, iMemberPrev), Gia_ObjFromLit(pGiaLev, iMember) );
+ }
+ else
+ {
+ nTsat++;
+ clk = clock();
+ status = Tas_ManSolve( pTas, Gia_ObjFromLit(pGiaLev, iMemberPrev), Gia_ObjFromLit(pGiaLev, iMember) );
+ timeTsat += clock() - clk;
+ }
+ if ( status == -1 ) // undec
+ {
+// Gia_ObjSetFailed( p->pGia, iRoot );
+ nUndec++;
+ if ( Gia_ObjLevel(p->pGia, pMemberPrev) > Gia_ObjLevel(p->pGia, pMember) )
+ {
+// Hcd_ManClassClassRemoveOne( p, Gia_ObjId(p->pGia, pMemberPrev) );
+ Gia_ObjSetFailed( p->pGia, Gia_ObjId(p->pGia, pMemberPrev) );
+ Gia_ObjSetFailed( p->pGia, Gia_ObjId(p->pGia, pMember) );
+ }
+ else
+ {
+// Hcd_ManClassClassRemoveOne( p, Gia_ObjId(p->pGia, pMember) );
+ Gia_ObjSetFailed( p->pGia, Gia_ObjId(p->pGia, pMemberPrev) );
+ Gia_ObjSetFailed( p->pGia, Gia_ObjId(p->pGia, pMember) );
+ }
+ }
+ else if ( status == 1 ) // unsat
+ {
+// Gia_ObjSetProved( p->pGia, iRoot );
+ }
+ else // sat
+ {
+// iRepr = Gia_ObjId( p->pGia, pRepr );
+// if ( Gia_ClassIsPair(p->pGia, iRepr) )
+// Gia_ClassUndoPair(p->pGia, iRepr);
+// else
+ {
+ fOneFailed = 1;
+ nRecords++;
+ nSaved += Gia_GiarfStorePattern( p->vSimInfo, p->vSimPres, vCex );
+ Gia_GiarfInsertPattern( p, vCex, (k % 31) + 1 );
+ }
+ }
+ pMemberPrev = pMember;
+// if ( fOneFailed )
+// k += Vec_PtrSize(vMembers) / 4;
+ }
+ // if fail, quit this class
+ if ( fOneFailed )
+ {
+ nClassRefs++;
+ Vec_PtrForEachEntry( Gia_Obj_t *, vMembers, pMember, k )
+ if ( pMember != pTempRepr && !Gia_ObjFailed(p->pGia, Gia_ObjId(p->pGia, pMember)) )
+ Vec_PtrPush( vOldRootsNew, pMember );
+ clk = clock();
+ Gia_ResimulateAndRefine( p, Gia_ObjId(p->pGia, pRepr) );
+ timeSim += clock() - clk;
+ }
+ else
+ {
+ Vec_PtrForEachEntry( Gia_Obj_t *, vMembers, pMember, k )
+ Gia_ObjSetProved( p->pGia, Gia_ObjId(p->pGia, pMember) );
+/*
+// }
+// else
+// {
+ printf( "Proved equivalent: " );
+ Vec_PtrForEachEntry( Gia_Obj_t *, vMembers, pMember, k )
+ printf( "%d(L=%d) ", Gia_ObjId(p->pGia, pMember), p->pGia->pLevels[Gia_ObjId(p->pGia, pMember)] );
+ printf( "\n" );
+*/
+ }
+
+ }
+ Vec_PtrClear( vOldRoots );
+ Vec_PtrForEachEntry( Gia_Obj_t *, vOldRootsNew, pMember, i )
+ Vec_PtrPush( vOldRoots, pMember );
+ // clean up
+ Gia_ManConst0( p->pGia )->fMark0 = 0;
+ Vec_PtrForEachEntry( Gia_Obj_t *, vClasses, pRepr, i )
+ pRepr->fMark0 = 0;
+ }
+ Vec_PtrFree( vClasses );
+ Vec_PtrFree( vOldRootsNew );
+ printf( "nSaved = %d nRecords = %d nUndec = %d nClassRefs = %d nMiniSat = %d nTas = %d\n",
+ nSaved, nRecords, nUndec, nClassRefs, nMiniSat, nTsat );
+ ABC_PRT( "Tas ", timeTsat );
+ ABC_PRT( "MiniSat", timeMiniSat );
+ ABC_PRT( "Sim ", timeSim );
+ ABC_PRT( "Total ", clock() - timeTotal );
+
+ // resimulate
+// clk = clock();
+ Hcd_ManSimulateSimple( p );
+ Hcd_ManClassesRefine( p );
+// ABC_PRT( "Simulate/refine", clock() - clk );
+
+ // verify the results
+ Vec_PtrFree( vMembers );
+ Tas_ManStop( pTas );
+ Cec_ManSatStop( pSat );
+ return nIter;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs computation of AIGs with choices.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ComputeEquivalences( Gia_Man_t * pGia, int nBTLimit, int fUseMiniSat, int fVerbose )
+{
+ Hcd_Man_t * p;
+ Vec_Ptr_t * vRoots;
+ Gia_Man_t * pGiaLev;
+ int i, Lev, nLevels, nIters, clk;
+ Gia_ManRandom( 1 );
+ Gia_ManSetPhase( pGia );
+ nLevels = Gia_ManLevelNum( pGia );
+ Gia_ManIncrementTravId( pGia );
+ // start the manager
+ p = Gia_ManEquivStart( pGia, nBTLimit, fVerbose );
+ // create trivial classes
+ Hcd_ManClassesCreate( p );
+ // refine
+ for ( i = 0; i < 3; i++ )
+ {
+ clk = clock();
+ Hcd_ManSimulationInit( p );
+ Hcd_ManSimulateSimple( p );
+ ABC_PRT( "Sim", clock() - clk );
+ clk = clock();
+ Hcd_ManClassesRefine( p );
+ ABC_PRT( "Ref", clock() - clk );
+ }
+ // process in the levelized order
+ for ( Lev = 1; Lev < nLevels; Lev++ )
+ {
+ clk = clock();
+ printf( "LEVEL %3d (out of %3d) ", Lev, nLevels );
+ pGiaLev = Gia_GenerateReducedLevel( pGia, Lev, &vRoots );
+ nIters = Gia_ComputeEquivalencesLevel( p, pGiaLev, vRoots, Lev, fUseMiniSat );
+ Gia_ManStop( pGiaLev );
+ Vec_PtrFree( vRoots );
+ printf( "Iters = %3d " );
+ ABC_PRT( "Time", clock() - clk );
+ }
+ Gia_GiarfPrintClasses( pGia );
+ // clean up
+ Gia_ManEquivStop( p );
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaGlitch.c b/src/aig/gia/giaGlitch.c
index ed636540..a6e5315a 100644
--- a/src/aig/gia/giaGlitch.c
+++ b/src/aig/gia/giaGlitch.c
@@ -20,6 +20,9 @@
#include "gia.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -779,3 +782,5 @@ void Gli_ManSwitchesAndGlitches( Gli_Man_t * p, int nPatterns, float PiTransProb
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaHash.c b/src/aig/gia/giaHash.c
index 97326c92..6561ca13 100644
--- a/src/aig/gia/giaHash.c
+++ b/src/aig/gia/giaHash.c
@@ -20,6 +20,9 @@
#include "gia.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -66,7 +69,7 @@ static inline int * Gia_ManHashFind( Gia_Man_t * p, int iLit0, int iLit1 )
Gia_Obj_t * pThis;
int * pPlace = p->pHTable + Gia_ManHashOne( iLit0, iLit1, p->nHTable );
for ( pThis = (*pPlace)? Gia_ManObj(p, Gia_Lit2Var(*pPlace)) : NULL; pThis;
- pPlace = &pThis->Value, pThis = (*pPlace)? Gia_ManObj(p, Gia_Lit2Var(*pPlace)) : NULL )
+ pPlace = (int *)&pThis->Value, pThis = (*pPlace)? Gia_ManObj(p, Gia_Lit2Var(*pPlace)) : NULL )
if ( Gia_ObjFaninLit0p(p, pThis) == iLit0 && Gia_ObjFaninLit1p(p, pThis) == iLit1 )
break;
return pPlace;
@@ -74,6 +77,26 @@ static inline int * Gia_ManHashFind( Gia_Man_t * p, int iLit0, int iLit1 )
/**Function*************************************************************
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManHashLookup( Gia_Man_t * p, Gia_Obj_t * p0, Gia_Obj_t * p1 )
+{
+ int iLit0 = Gia_ObjToLit( p, p0 );
+ int iLit1 = Gia_ObjToLit( p, p1 );
+ if ( iLit0 > iLit1 )
+ iLit0 ^= iLit1, iLit1 ^= iLit0, iLit0 ^= iLit1;
+ return *Gia_ManHashFind( p, iLit0, iLit1 );
+}
+
+/**Function*************************************************************
+
Synopsis [Starts the hash table.]
Description []
@@ -594,3 +617,5 @@ Gia_Man_t * Gia_ManRehash( Gia_Man_t * p, int fAddStrash )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaHcd.c b/src/aig/gia/giaHcd.c
new file mode 100644
index 00000000..454785b9
--- /dev/null
+++ b/src/aig/gia/giaHcd.c
@@ -0,0 +1,686 @@
+/**CFile****************************************************************
+
+ FileName [giaHcd.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Scalable AIG package.]
+
+ Synopsis [New choice computation package.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: giaHcd.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+#include "giaAig.h"
+#include "aig.h"
+#include "dar.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+// choicing parameters
+typedef struct Hcd_Pars_t_ Hcd_Pars_t;
+struct Hcd_Pars_t_
+{
+ int nWords; // the number of simulation words
+ int nBTLimit; // conflict limit at a node
+ int nSatVarMax; // the max number of SAT variables
+ int fSynthesis; // set to 1 to perform synthesis
+ int fPolarFlip; // uses polarity adjustment
+ int fSimulateTfo; // uses simulation of TFO classes
+ int fPower; // uses power-aware rewriting
+ int fUseGia; // uses GIA package
+ int fUseCSat; // uses circuit-based solver
+ int fVerbose; // verbose stats
+ int timeSynth; // synthesis runtime
+ int nNodesAhead; // the lookahead in terms of nodes
+ int nCallsRecycle; // calls to perform before recycling SAT solver
+};
+
+extern void Gia_ComputeEquivalences( Gia_Man_t * pMiter, int nBTLimit, int fUseMiniSat, int fVerbose );
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [This procedure sets default parameters.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Hcd_ManSetDefaultParams( Hcd_Pars_t * p )
+{
+ memset( p, 0, sizeof(Hcd_Pars_t) );
+ p->nWords = 8; // the number of simulation words
+ p->nBTLimit = 1000; // conflict limit at a node
+ p->nSatVarMax = 5000; // the max number of SAT variables
+ p->fSynthesis = 1; // derives three snapshots
+ p->fPolarFlip = 1; // uses polarity adjustment
+ p->fSimulateTfo = 1; // simulate TFO
+ p->fPower = 0; // power-aware rewriting
+ p->fVerbose = 0; // verbose stats
+ p->nNodesAhead = 1000; // the lookahead in terms of nodes
+ p->nCallsRecycle = 100; // calls to perform before recycling SAT solver
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Reproduces script "compress".]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Man_t * Hcd_Compress( Aig_Man_t * pAig, int fBalance, int fUpdateLevel, int fPower, int fVerbose )
+//alias compress2 "b -l; rw -l; rwz -l; b -l; rwz -l; b -l"
+{
+ Aig_Man_t * pTemp;
+
+ Dar_RwrPar_t ParsRwr, * pParsRwr = &ParsRwr;
+ Dar_RefPar_t ParsRef, * pParsRef = &ParsRef;
+
+ Dar_ManDefaultRwrParams( pParsRwr );
+ Dar_ManDefaultRefParams( pParsRef );
+
+ pParsRwr->fUpdateLevel = fUpdateLevel;
+ pParsRef->fUpdateLevel = fUpdateLevel;
+
+ pParsRwr->fPower = fPower;
+
+ pParsRwr->fVerbose = 0;//fVerbose;
+ pParsRef->fVerbose = 0;//fVerbose;
+
+// pAig = Aig_ManDupDfs( pAig );
+ if ( fVerbose ) Aig_ManPrintStats( pAig );
+
+ // rewrite
+ Dar_ManRewrite( pAig, pParsRwr );
+ pAig = Aig_ManDupDfs( pTemp = pAig );
+ Aig_ManStop( pTemp );
+ if ( fVerbose ) Aig_ManPrintStats( pAig );
+
+ // refactor
+ Dar_ManRefactor( pAig, pParsRef );
+ pAig = Aig_ManDupDfs( pTemp = pAig );
+ Aig_ManStop( pTemp );
+ if ( fVerbose ) Aig_ManPrintStats( pAig );
+
+ // balance
+ if ( fBalance )
+ {
+ pAig = Dar_ManBalance( pTemp = pAig, fUpdateLevel );
+ Aig_ManStop( pTemp );
+ if ( fVerbose ) Aig_ManPrintStats( pAig );
+ }
+
+ pParsRwr->fUseZeros = 1;
+ pParsRef->fUseZeros = 1;
+
+ // rewrite
+ Dar_ManRewrite( pAig, pParsRwr );
+ pAig = Aig_ManDupDfs( pTemp = pAig );
+ Aig_ManStop( pTemp );
+ if ( fVerbose ) Aig_ManPrintStats( pAig );
+
+ return pAig;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Reproduces script "compress2".]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Man_t * Hcd_Compress2( Aig_Man_t * pAig, int fBalance, int fUpdateLevel, int fFanout, int fPower, int fVerbose )
+//alias compress2 "b -l; rw -l; rf -l; b -l; rw -l; rwz -l; b -l; rfz -l; rwz -l; b -l"
+{
+ Aig_Man_t * pTemp;
+
+ Dar_RwrPar_t ParsRwr, * pParsRwr = &ParsRwr;
+ Dar_RefPar_t ParsRef, * pParsRef = &ParsRef;
+
+ Dar_ManDefaultRwrParams( pParsRwr );
+ Dar_ManDefaultRefParams( pParsRef );
+
+ pParsRwr->fUpdateLevel = fUpdateLevel;
+ pParsRef->fUpdateLevel = fUpdateLevel;
+ pParsRwr->fFanout = fFanout;
+ pParsRwr->fPower = fPower;
+
+ pParsRwr->fVerbose = 0;//fVerbose;
+ pParsRef->fVerbose = 0;//fVerbose;
+
+// pAig = Aig_ManDupDfs( pAig );
+ if ( fVerbose ) Aig_ManPrintStats( pAig );
+
+ // rewrite
+ Dar_ManRewrite( pAig, pParsRwr );
+ pAig = Aig_ManDupDfs( pTemp = pAig );
+ Aig_ManStop( pTemp );
+ if ( fVerbose ) Aig_ManPrintStats( pAig );
+
+ // refactor
+ Dar_ManRefactor( pAig, pParsRef );
+ pAig = Aig_ManDupDfs( pTemp = pAig );
+ Aig_ManStop( pTemp );
+ if ( fVerbose ) Aig_ManPrintStats( pAig );
+
+ // balance
+// if ( fBalance )
+ {
+ pAig = Dar_ManBalance( pTemp = pAig, fUpdateLevel );
+ Aig_ManStop( pTemp );
+ if ( fVerbose ) Aig_ManPrintStats( pAig );
+ }
+
+ // rewrite
+ Dar_ManRewrite( pAig, pParsRwr );
+ pAig = Aig_ManDupDfs( pTemp = pAig );
+ Aig_ManStop( pTemp );
+ if ( fVerbose ) Aig_ManPrintStats( pAig );
+
+ pParsRwr->fUseZeros = 1;
+ pParsRef->fUseZeros = 1;
+
+ // rewrite
+ Dar_ManRewrite( pAig, pParsRwr );
+ pAig = Aig_ManDupDfs( pTemp = pAig );
+ Aig_ManStop( pTemp );
+ if ( fVerbose ) Aig_ManPrintStats( pAig );
+
+ // balance
+ if ( fBalance )
+ {
+ pAig = Dar_ManBalance( pTemp = pAig, fUpdateLevel );
+ Aig_ManStop( pTemp );
+ if ( fVerbose ) Aig_ManPrintStats( pAig );
+ }
+
+ // refactor
+ Dar_ManRefactor( pAig, pParsRef );
+ pAig = Aig_ManDupDfs( pTemp = pAig );
+ Aig_ManStop( pTemp );
+ if ( fVerbose ) Aig_ManPrintStats( pAig );
+
+ // rewrite
+ Dar_ManRewrite( pAig, pParsRwr );
+ pAig = Aig_ManDupDfs( pTemp = pAig );
+ Aig_ManStop( pTemp );
+ if ( fVerbose ) Aig_ManPrintStats( pAig );
+
+ // balance
+ if ( fBalance )
+ {
+ pAig = Dar_ManBalance( pTemp = pAig, fUpdateLevel );
+ Aig_ManStop( pTemp );
+ if ( fVerbose ) Aig_ManPrintStats( pAig );
+ }
+ return pAig;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Reproduces script "compress2".]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Ptr_t * Hcd_ChoiceSynthesis( Aig_Man_t * pAig, int fBalance, int fUpdateLevel, int fPower, int fVerbose )
+//alias resyn "b; rw; rwz; b; rwz; b"
+//alias resyn2 "b; rw; rf; b; rw; rwz; b; rfz; rwz; b"
+{
+ Vec_Ptr_t * vGias;
+ Gia_Man_t * pGia;
+
+ vGias = Vec_PtrAlloc( 3 );
+ pGia = Gia_ManFromAig(pAig);
+ Vec_PtrPush( vGias, pGia );
+
+ pAig = Hcd_Compress( pAig, fBalance, fUpdateLevel, fPower, fVerbose );
+ pGia = Gia_ManFromAig(pAig);
+ Vec_PtrPush( vGias, pGia );
+//Aig_ManPrintStats( pAig );
+
+ pAig = Hcd_Compress2( pAig, fBalance, fUpdateLevel, 1, fPower, fVerbose );
+ pGia = Gia_ManFromAig(pAig);
+ Vec_PtrPush( vGias, pGia );
+//Aig_ManPrintStats( pAig );
+
+ Aig_ManStop( pAig );
+ return vGias;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Duplicates the AIG in the DFS order.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Hcd_ManChoiceMiter_rec( Gia_Man_t * pNew, Gia_Man_t * p, Gia_Obj_t * pObj )
+{
+ if ( ~pObj->Value )
+ return pObj->Value;
+ Hcd_ManChoiceMiter_rec( pNew, p, Gia_ObjFanin0(pObj) );
+ if ( Gia_ObjIsCo(pObj) )
+ return pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
+ Hcd_ManChoiceMiter_rec( pNew, p, Gia_ObjFanin1(pObj) );
+ return pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Derives the miter of several AIGs for choice computation.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Hcd_ManChoiceMiter( Vec_Ptr_t * vGias )
+{
+ Gia_Man_t * pNew, * pGia, * pGia0;
+ int i, k, iNode, nNodes;
+ // make sure they have equal parameters
+ assert( Vec_PtrSize(vGias) > 0 );
+ pGia0 = (Gia_Man_t *)Vec_PtrEntry( vGias, 0 );
+ Vec_PtrForEachEntry( Gia_Man_t *, vGias, pGia, i )
+ {
+ assert( Gia_ManCiNum(pGia) == Gia_ManCiNum(pGia0) );
+ assert( Gia_ManCoNum(pGia) == Gia_ManCoNum(pGia0) );
+ assert( Gia_ManRegNum(pGia) == Gia_ManRegNum(pGia0) );
+ Gia_ManFillValue( pGia );
+ Gia_ManConst0(pGia)->Value = 0;
+ }
+ // start the new manager
+ pNew = Gia_ManStart( Vec_PtrSize(vGias) * Gia_ManObjNum(pGia0) );
+ pNew->pName = Gia_UtilStrsav( pGia0->pName );
+ // create new CIs and assign them to the old manager CIs
+ for ( k = 0; k < Gia_ManCiNum(pGia0); k++ )
+ {
+ iNode = Gia_ManAppendCi(pNew);
+ Vec_PtrForEachEntry( Gia_Man_t *, vGias, pGia, i )
+ Gia_ManCi( pGia, k )->Value = iNode;
+ }
+ // create internal nodes
+ Gia_ManHashAlloc( pNew );
+ for ( k = 0; k < Gia_ManCoNum(pGia0); k++ )
+ {
+ Vec_PtrForEachEntry( Gia_Man_t *, vGias, pGia, i )
+ Hcd_ManChoiceMiter_rec( pNew, pGia, Gia_ManCo( pGia, k ) );
+ }
+ Gia_ManHashStop( pNew );
+ // check the presence of dangling nodes
+ nNodes = Gia_ManHasDangling( pNew );
+ assert( nNodes == 0 );
+ return pNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns 1 if pOld is in the TFI of pNode.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Hcd_ObjCheckTfi_rec( Gia_Man_t * p, Gia_Obj_t * pOld, Gia_Obj_t * pNode, Vec_Ptr_t * vVisited )
+{
+ // check the trivial cases
+ if ( pNode == NULL )
+ return 0;
+ if ( Gia_ObjIsCi(pNode) )
+ return 0;
+// if ( pNode->Id < pOld->Id ) // cannot use because of choices of pNode
+// return 0;
+ if ( pNode == pOld )
+ return 1;
+ // skip the visited node
+ if ( pNode->fMark0 )
+ return 0;
+ pNode->fMark0 = 1;
+ Vec_PtrPush( vVisited, pNode );
+ // check the children
+ if ( Hcd_ObjCheckTfi_rec( p, pOld, Gia_ObjFanin0(pNode), vVisited ) )
+ return 1;
+ if ( Hcd_ObjCheckTfi_rec( p, pOld, Gia_ObjFanin1(pNode), vVisited ) )
+ return 1;
+ // check equivalent nodes
+ return Hcd_ObjCheckTfi_rec( p, pOld, Gia_ObjNextObj(p, Gia_ObjId(p, pNode)), vVisited );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns 1 if pOld is in the TFI of pNode.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Hcd_ObjCheckTfi( Gia_Man_t * p, Gia_Obj_t * pOld, Gia_Obj_t * pNode )
+{
+ Vec_Ptr_t * vVisited;
+ Gia_Obj_t * pObj;
+ int RetValue, i;
+ assert( !Gia_IsComplement(pOld) );
+ assert( !Gia_IsComplement(pNode) );
+ vVisited = Vec_PtrAlloc( 100 );
+ RetValue = Hcd_ObjCheckTfi_rec( p, pOld, pNode, vVisited );
+ Vec_PtrForEachEntry( Gia_Obj_t *, vVisited, pObj, i )
+ pObj->fMark0 = 0;
+ Vec_PtrFree( vVisited );
+ return RetValue;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Adds the next entry while making choices.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Hcd_ManAddNextEntry_rec( Gia_Man_t * p, Gia_Obj_t * pOld, Gia_Obj_t * pNode )
+{
+ if ( Gia_ObjNext(p, Gia_ObjId(p, pOld)) == 0 )
+ {
+ Gia_ObjSetNext( p, Gia_ObjId(p, pOld), Gia_ObjId(p, pNode) );
+ return;
+ }
+ Hcd_ManAddNextEntry_rec( p, Gia_ObjNextObj(p, Gia_ObjId(p, pOld)), pNode );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Duplicates the AIG in the DFS order.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Hcd_ManEquivToChoices_rec( Gia_Man_t * pNew, Gia_Man_t * p, Gia_Obj_t * pObj )
+{
+ Gia_Obj_t * pRepr, * pReprNew, * pObjNew;
+ if ( ~pObj->Value )
+ return;
+ if ( (pRepr = Gia_ObjReprObj(p, Gia_ObjId(p, pObj))) )
+ {
+ if ( Gia_ObjIsConst0(pRepr) )
+ {
+ pObj->Value = Gia_LitNotCond( pRepr->Value, Gia_ObjPhaseReal(pRepr) ^ Gia_ObjPhaseReal(pObj) );
+ return;
+ }
+ Hcd_ManEquivToChoices_rec( pNew, p, pRepr );
+ assert( Gia_ObjIsAnd(pObj) );
+ Hcd_ManEquivToChoices_rec( pNew, p, Gia_ObjFanin0(pObj) );
+ Hcd_ManEquivToChoices_rec( pNew, p, Gia_ObjFanin1(pObj) );
+ pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+ if ( Gia_LitRegular(pObj->Value) == Gia_LitRegular(pRepr->Value) )
+ {
+ assert( (int)pObj->Value == Gia_LitNotCond( pRepr->Value, Gia_ObjPhaseReal(pRepr) ^ Gia_ObjPhaseReal(pObj) ) );
+ return;
+ }
+ if ( pRepr->Value > pObj->Value ) // should never happen with high resource limit
+ return;
+ assert( pRepr->Value < pObj->Value );
+ pReprNew = Gia_ManObj( pNew, Gia_Lit2Var(pRepr->Value) );
+ pObjNew = Gia_ManObj( pNew, Gia_Lit2Var(pObj->Value) );
+ if ( Gia_ObjReprObj( pNew, Gia_ObjId(pNew, pObjNew) ) )
+ {
+ assert( Gia_ObjReprObj( pNew, Gia_ObjId(pNew, pObjNew) ) == pReprNew );
+ pObj->Value = Gia_LitNotCond( pRepr->Value, Gia_ObjPhaseReal(pRepr) ^ Gia_ObjPhaseReal(pObj) );
+ return;
+ }
+ if ( !Hcd_ObjCheckTfi( pNew, pReprNew, pObjNew ) )
+ {
+ assert( Gia_ObjNext(pNew, Gia_ObjId(pNew, pObjNew)) == 0 );
+ Gia_ObjSetRepr( pNew, Gia_ObjId(pNew, pObjNew), Gia_ObjId(pNew, pReprNew) );
+ Hcd_ManAddNextEntry_rec( pNew, pReprNew, pObjNew );
+ }
+ pObj->Value = Gia_LitNotCond( pRepr->Value, Gia_ObjPhaseReal(pRepr) ^ Gia_ObjPhaseReal(pObj) );
+ return;
+ }
+ assert( Gia_ObjIsAnd(pObj) );
+ Hcd_ManEquivToChoices_rec( pNew, p, Gia_ObjFanin0(pObj) );
+ Hcd_ManEquivToChoices_rec( pNew, p, Gia_ObjFanin1(pObj) );
+ pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Removes choices, which contain fanouts.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Hcd_ManRemoveBadChoices( Gia_Man_t * p )
+{
+ Gia_Obj_t * pObj;
+ int i, iObj, iPrev, Counter = 0;
+ // mark nodes with fanout
+ Gia_ManForEachObj( p, pObj, i )
+ {
+ pObj->fMark0 = 0;
+ if ( Gia_ObjIsAnd(pObj) )
+ {
+ Gia_ObjFanin0(pObj)->fMark0 = 1;
+ Gia_ObjFanin1(pObj)->fMark0 = 1;
+ }
+ else if ( Gia_ObjIsCo(pObj) )
+ Gia_ObjFanin0(pObj)->fMark0 = 1;
+ }
+ // go through the classes and remove
+ Gia_ManForEachClass( p, i )
+ {
+ for ( iPrev = i, iObj = Gia_ObjNext(p, i); iObj; iObj = Gia_ObjNext(p, iPrev) )
+ {
+ if ( !Gia_ManObj(p, iObj)->fMark0 )
+ {
+ iPrev = iObj;
+ continue;
+ }
+ Gia_ObjSetRepr( p, iObj, GIA_VOID );
+ Gia_ObjSetNext( p, iPrev, Gia_ObjNext(p, iObj) );
+ Gia_ObjSetNext( p, iObj, 0 );
+ Counter++;
+ }
+ }
+ // remove the marks
+ Gia_ManCleanMark0( p );
+// printf( "Removed %d bad choices.\n", Counter );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Reduces AIG using equivalence classes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Hcd_ManEquivToChoices( Gia_Man_t * p, int nSnapshots )
+{
+ Gia_Man_t * pNew, * pTemp;
+ Gia_Obj_t * pObj, * pRepr;
+ int i;
+ assert( (Gia_ManCoNum(p) % nSnapshots) == 0 );
+ Gia_ManSetPhase( p );
+ pNew = Gia_ManStart( Gia_ManObjNum(p) );
+ pNew->pName = Gia_UtilStrsav( p->pName );
+ pNew->pReprs = ABC_CALLOC( Gia_Rpr_t, Gia_ManObjNum(p) );
+ pNew->pNexts = ABC_CALLOC( int, Gia_ManObjNum(p) );
+ for ( i = 0; i < Gia_ManObjNum(p); i++ )
+ Gia_ObjSetRepr( pNew, i, GIA_VOID );
+ Gia_ManFillValue( p );
+ Gia_ManConst0(p)->Value = 0;
+ Gia_ManForEachCi( p, pObj, i )
+ pObj->Value = Gia_ManAppendCi(pNew);
+ Gia_ManForEachRo( p, pObj, i )
+ if ( (pRepr = Gia_ObjReprObj(p, Gia_ObjId(p, pObj))) )
+ {
+ assert( Gia_ObjIsConst0(pRepr) || Gia_ObjIsRo(p, pRepr) );
+ pObj->Value = pRepr->Value;
+ }
+ Gia_ManHashAlloc( pNew );
+ Gia_ManForEachCo( p, pObj, i )
+ Hcd_ManEquivToChoices_rec( pNew, p, Gia_ObjFanin0(pObj) );
+ Gia_ManForEachCo( p, pObj, i )
+ if ( i % nSnapshots == 0 )
+ Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
+ Gia_ManHashStop( pNew );
+ Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
+ Hcd_ManRemoveBadChoices( pNew );
+// Gia_ManEquivPrintClasses( pNew, 0, 0 );
+ pNew = Gia_ManCleanup( pTemp = pNew );
+ Gia_ManStop( pTemp );
+// Gia_ManEquivPrintClasses( pNew, 0, 0 );
+ return pNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs computation of AIGs with choices.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Man_t * Hcd_ComputeChoices( Aig_Man_t * pAig, int nBTLimit, int fSynthesis, int fUseMiniSat, int fVerbose )
+{
+ Vec_Ptr_t * vGias;
+ Gia_Man_t * pGia, * pMiter;
+ Aig_Man_t * pAigNew;
+ int i, clk = clock();
+ // perform synthesis
+ if ( fSynthesis )
+ {
+ vGias = Hcd_ChoiceSynthesis( Aig_ManDupDfs(pAig), 1, 1, 0, 0 );
+ if ( fVerbose )
+ ABC_PRT( "Synthesis time", clock() - clk );
+ // create choices
+ clk = clock();
+ pMiter = Hcd_ManChoiceMiter( vGias );
+ Vec_PtrForEachEntry( Gia_Man_t *, vGias, pGia, i )
+ Gia_ManStop( pGia );
+
+ Gia_WriteAiger( pMiter, "m3.aig", 0, 0 );
+ }
+ else
+ {
+ vGias = Vec_PtrStart( 3 );
+ pMiter = Gia_ManFromAig(pAig);
+ }
+ // perform choicing
+ Gia_ComputeEquivalences( pMiter, nBTLimit, fUseMiniSat, fVerbose );
+ // derive AIG with choices
+ pGia = Hcd_ManEquivToChoices( pMiter, Vec_PtrSize(vGias) );
+ Gia_ManSetRegNum( pGia, Aig_ManRegNum(pAig) );
+ Gia_ManStop( pMiter );
+ Vec_PtrFree( vGias );
+ if ( fVerbose )
+ ABC_PRT( "Choicing time", clock() - clk );
+ Gia_ManHasChoices( pGia );
+ // transform back
+ pAigNew = Gia_ManToAig( pGia, 1 );
+ Gia_ManStop( pGia );
+
+ if ( fVerbose )
+ {
+ extern int Dch_DeriveChoiceCountReprs( Aig_Man_t * pAig );
+ extern int Dch_DeriveChoiceCountEquivs( Aig_Man_t * pAig );
+ printf( "Choices : Reprs = %5d. Equivs = %5d. Choices = %5d.\n",
+ Dch_DeriveChoiceCountReprs( pAigNew ),
+ Dch_DeriveChoiceCountEquivs( pAigNew ),
+ Aig_ManChoiceNum( pAigNew ) );
+ }
+
+ return pAigNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs computation of AIGs with choices.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Hcd_ComputeChoicesTest( Gia_Man_t * pGia, int nBTLimit, int fSynthesis, int fUseMiniSat, int fVerbose )
+{
+ Aig_Man_t * pAig, * pAigNew;
+ pAig = Gia_ManToAig( pGia, 0 );
+ pAigNew = Hcd_ComputeChoices( pAig, nBTLimit, fSynthesis, fUseMiniSat, fVerbose );
+ Aig_ManStop( pAigNew );
+ Aig_ManStop( pAig );
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaMap.c b/src/aig/gia/giaIf.c
index 72bdb001..a06a6024 100644
--- a/src/aig/gia/giaMap.c
+++ b/src/aig/gia/giaIf.c
@@ -19,7 +19,12 @@
***********************************************************************/
#include "gia.h"
+#include "aig.h"
#include "if.h"
+#include "dar.h"
+
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -95,6 +100,7 @@ If_Man_t * Gia_ManToIf( Gia_Man_t * p, If_Par_t * pPars, Vec_Ptr_t * vAigToIf )
Gia_Obj_t * pNode;
int i, clk = clock();
Gia_ManLevelNum( p );
+// assert( p->pReprs == NULL );
/*
// set the number of registers (switch activity will be combinational)
Gia_ManSetRegNum( p, 0 );
@@ -114,24 +120,25 @@ If_Man_t * Gia_ManToIf( Gia_Man_t * p, If_Par_t * pPars, Vec_Ptr_t * vAigToIf )
pIfMan = If_ManStart( pPars );
// pIfMan->vSwitching = vSwitching2;
// load the AIG into the mapper
+ Gia_ManCreateRefs( p );
Gia_ManForEachObj( p, pNode, i )
{
if ( Gia_ObjIsAnd(pNode) )
pIfObj = If_ManCreateAnd( pIfMan,
- If_NotCond( Vec_PtrEntry(vAigToIf, Gia_ObjFaninId0(pNode, i)), Gia_ObjFaninC0(pNode) ),
- If_NotCond( Vec_PtrEntry(vAigToIf, Gia_ObjFaninId1(pNode, i)), Gia_ObjFaninC1(pNode) ) );
+ If_NotCond( (If_Obj_t *)Vec_PtrEntry(vAigToIf, Gia_ObjFaninId0(pNode, i)), Gia_ObjFaninC0(pNode) ),
+ If_NotCond( (If_Obj_t *)Vec_PtrEntry(vAigToIf, Gia_ObjFaninId1(pNode, i)), Gia_ObjFaninC1(pNode) ) );
else if ( Gia_ObjIsCi(pNode) )
{
pIfObj = If_ManCreateCi( pIfMan );
If_ObjSetLevel( pIfObj, Gia_ObjLevel(p,pNode) );
-// printf( "pi=%d ", pIfObj->Level );
+// Abc_Print( 1, "pi=%d ", pIfObj->Level );
if ( pIfMan->nLevelMax < (int)pIfObj->Level )
pIfMan->nLevelMax = (int)pIfObj->Level;
}
else if ( Gia_ObjIsCo(pNode) )
{
- pIfObj = If_ManCreateCo( pIfMan, If_NotCond( Vec_PtrEntry(vAigToIf, Gia_ObjFaninId0(pNode, i)), Gia_ObjFaninC0(pNode) ) );
-// printf( "po=%d ", pIfObj->Level );
+ pIfObj = If_ManCreateCo( pIfMan, If_NotCond( (If_Obj_t *)Vec_PtrEntry(vAigToIf, Gia_ObjFaninId0(pNode, i)), Gia_ObjFaninC0(pNode) ) );
+// Abc_Print( 1, "po=%d ", pIfObj->Level );
}
else if ( Gia_ObjIsConst0(pNode) )
pIfObj = If_Not(If_ManConst1( pIfMan ));
@@ -142,6 +149,18 @@ If_Man_t * Gia_ManToIf( Gia_Man_t * p, If_Par_t * pPars, Vec_Ptr_t * vAigToIf )
Vec_PtrWriteEntry( vAigToIf, i, pIfObj );
// if ( vSwitching2 )
// pSwitching2[pIfObj->Id] = pSwitching[pNode->Id];
+ // set up the choice node
+/*
+// if ( p->pReprs && p->pNexts && Gia_ObjIsHead( p, i ) )
+ if ( p->pNexts && Gia_ObjNext(p, i) && Gia_ObjRefsId(p, i) )
+ {
+ int iPrev, iFanin;
+ pIfMan->nChoices++;
+ for ( iPrev = i, iFanin = Gia_ObjNext(p, i); iFanin; iPrev = iFanin, iFanin = Gia_ObjNext(p, iFanin) )
+ If_ObjSetChoice( Vec_PtrEntry(vAigToIf,iPrev), Vec_PtrEntry(vAigToIf,iFanin) );
+ If_ManCreateChoice( pIfMan, Vec_PtrEntry(vAigToIf,i) );
+ }
+*/
/* // set up the choice node
if ( Gia_ObjIsChoice( p, pNode ) )
{
@@ -186,7 +205,7 @@ int * Gia_ManFromIf( If_Man_t * pIfMan, Gia_Man_t * p, Vec_Ptr_t * vAigToIf )
vIfToAig = Vec_PtrStart( If_ManObjNum(pIfMan) );
Gia_ManForEachObj( p, pObj, i )
{
- pIfObj = Vec_PtrEntry( vAigToIf, i );
+ pIfObj = (If_Obj_t *)Vec_PtrEntry( vAigToIf, i );
Vec_PtrWriteEntry( vIfToAig, pIfObj->Id, pObj );
if ( !Gia_ObjIsAnd(pObj) || pIfObj->nRefs == 0 )
continue;
@@ -197,7 +216,7 @@ int * Gia_ManFromIf( If_Man_t * pIfMan, Gia_Man_t * p, Vec_Ptr_t * vAigToIf )
iOffset = Gia_ManObjNum(p);
Gia_ManForEachObj( p, pObj, i )
{
- pIfObj = Vec_PtrEntry( vAigToIf, i );
+ pIfObj = (If_Obj_t *)Vec_PtrEntry( vAigToIf, i );
if ( !Gia_ObjIsAnd(pObj) || pIfObj->nRefs == 0 )
continue;
pCutBest = If_ObjCutBest( pIfObj );
@@ -208,7 +227,7 @@ int * Gia_ManFromIf( If_Man_t * pIfMan, Gia_Man_t * p, Vec_Ptr_t * vAigToIf )
pMapping[k++] = nLeaves;
for ( j = 0; j < nLeaves; j++ )
{
- pObjRepr = Vec_PtrEntry( vIfToAig, ppLeaves[j] );
+ pObjRepr = (Gia_Obj_t *)Vec_PtrEntry( vIfToAig, ppLeaves[j] );
pMapping[k++] = Gia_ObjId( p, pObjRepr );
}
pMapping[k++] = i;
@@ -279,23 +298,226 @@ void Gia_ManPrintMappingStats( Gia_Man_t * p )
if ( !p->pMapping )
return;
pLevels = ABC_CALLOC( int, Gia_ManObjNum(p) );
- Gia_ManForEachGate( p, i )
+ Gia_ManForEachLut( p, i )
{
nLuts++;
- nFanins += Gia_ObjGateSize(p, i);
- nLutSize = ABC_MAX( nLutSize, Gia_ObjGateSize(p, i) );
- Gia_GateForEachFanin( p, i, iFan, k )
+ nFanins += Gia_ObjLutSize(p, i);
+ nLutSize = ABC_MAX( nLutSize, Gia_ObjLutSize(p, i) );
+ Gia_LutForEachFanin( p, i, iFan, k )
pLevels[i] = ABC_MAX( pLevels[i], pLevels[iFan] );
pLevels[i]++;
LevelMax = ABC_MAX( LevelMax, pLevels[i] );
}
ABC_FREE( pLevels );
- printf( "mapping : " );
- printf( "%d=lut =%7d ", nLutSize, nLuts );
- printf( "edge =%8d ", nFanins );
- printf( "lev =%5d ", LevelMax );
- printf( "mem =%5.2f Mb", 4.0*(Gia_ManObjNum(p) + 2*nLuts + nFanins)/(1<<20) );
- printf( "\n" );
+ Abc_Print( 1, "mapping (K=%d) : ", nLutSize );
+ Abc_Print( 1, "lut =%7d ", nLuts );
+ Abc_Print( 1, "edge =%8d ", nFanins );
+ Abc_Print( 1, "lev =%5d ", LevelMax );
+ Abc_Print( 1, "mem =%5.2f Mb", 4.0*(Gia_ManObjNum(p) + 2*nLuts + nFanins)/(1<<20) );
+ Abc_Print( 1, "\n" );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Prints mapping statistics.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManLutFaninCount( Gia_Man_t * p )
+{
+ int i, Counter = 0;
+ Gia_ManForEachLut( p, i )
+ Counter += Gia_ObjLutSize(p, i);
+ return Counter;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Prints mapping statistics.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManLutSizeMax( Gia_Man_t * p )
+{
+ int i, nSizeMax = -1;
+ Gia_ManForEachLut( p, i )
+ nSizeMax = ABC_MAX( nSizeMax, Gia_ObjLutSize(p, i) );
+ return nSizeMax;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Prints mapping statistics.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManLutNum( Gia_Man_t * p )
+{
+ int i, Counter = 0;
+ Gia_ManForEachLut( p, i )
+ Counter ++;
+ return Counter;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Prints mapping statistics.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManLutLevel( Gia_Man_t * p )
+{
+ Gia_Obj_t * pObj;
+ int i, k, iFan, Level;
+ int * pLevels = ABC_CALLOC( int, Gia_ManObjNum(p) );
+ Gia_ManForEachLut( p, i )
+ {
+ Level = 0;
+ Gia_LutForEachFanin( p, i, iFan, k )
+ if ( Level < pLevels[iFan] )
+ Level = pLevels[iFan];
+ pLevels[i] = Level + 1;
+ }
+ Level = 0;
+ Gia_ManForEachCo( p, pObj, k )
+ if ( Level < pLevels[Gia_ObjFaninId0p(p, pObj)] )
+ Level = pLevels[Gia_ObjFaninId0p(p, pObj)];
+ ABC_FREE( pLevels );
+ return Level;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Assigns levels.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManSetRefsMapped( Gia_Man_t * p )
+{
+ Gia_Obj_t * pObj;
+ int i, k, iFan;
+ ABC_FREE( p->pRefs );
+ p->pRefs = ABC_CALLOC( int, Gia_ManObjNum(p) );
+ Gia_ManForEachCo( p, pObj, i )
+ Gia_ObjRefInc( p, Gia_ObjFanin0(pObj) );
+ Gia_ManForEachLut( p, i )
+ Gia_LutForEachFanin( p, i, iFan, k )
+ Gia_ObjRefInc( p, Gia_ManObj(p, iFan) );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Prints NPN class statistics.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManPrintNpnClasses( Gia_Man_t * p )
+{
+ extern char ** Kit_DsdNpn4ClassNames();
+ char ** pNames = Kit_DsdNpn4ClassNames();
+ Vec_Int_t * vLeaves, * vTruth, * vVisited;
+ int * pLutClass, ClassCounts[222] = {0};
+ int i, k, iFan, Class, OtherClasses, OtherClasses2, nTotal, Counter, Counter2;
+ unsigned * pTruth;
+ assert( p->pMapping != NULL );
+ assert( Gia_ManLutSizeMax( p ) <= 4 );
+ vLeaves = Vec_IntAlloc( 100 );
+ vVisited = Vec_IntAlloc( 100 );
+ vTruth = Vec_IntAlloc( (1<<16) );
+ pLutClass = ABC_CALLOC( int, Gia_ManObjNum(p) );
+ Gia_ManCleanTruth( p );
+ Gia_ManForEachLut( p, i )
+ {
+ if ( Gia_ObjLutSize(p,i) > 4 )
+ continue;
+ Vec_IntClear( vLeaves );
+ Gia_LutForEachFanin( p, i, iFan, k )
+ Vec_IntPush( vLeaves, iFan );
+ for ( ; k < 4; k++ )
+ Vec_IntPush( vLeaves, 0 );
+ pTruth = Gia_ManConvertAigToTruth( p, Gia_ManObj(p, i), vLeaves, vTruth, vVisited );
+ Class = Dar_LibReturnClass( *pTruth );
+ ClassCounts[ Class ]++;
+ pLutClass[i] = Class;
+ }
+ Vec_IntFree( vLeaves );
+ Vec_IntFree( vTruth );
+ Vec_IntFree( vVisited );
+ Vec_IntFreeP( &p->vTruths );
+ nTotal = 0;
+ for ( i = 0; i < 222; i++ )
+ nTotal += ClassCounts[i];
+ Abc_Print( 1, "NPN CLASS STATISTICS (for %d LUT4 present in the current mapping):\n", nTotal );
+ OtherClasses = 0;
+ for ( i = 0; i < 222; i++ )
+ {
+ if ( ClassCounts[i] == 0 )
+ continue;
+ if ( 100.0 * ClassCounts[i] / (nTotal+1) < 0.1 ) // do not show anything below 0.1 percent
+ continue;
+ OtherClasses += ClassCounts[i];
+ Abc_Print( 1, "Class %3d : Count = %6d (%7.2f %%) %s\n",
+ i, ClassCounts[i], 100.0 * ClassCounts[i] / (nTotal+1), pNames[i] );
+ }
+ OtherClasses = nTotal - OtherClasses;
+ Abc_Print( 1, "Other : Count = %6d (%7.2f %%)\n",
+ OtherClasses, 100.0 * OtherClasses / (nTotal+1) );
+ // count the number of LUTs that have MUX function and two fanins with MUX functions
+ OtherClasses = OtherClasses2 = 0;
+ ABC_FREE( p->pRefs );
+ Gia_ManSetRefsMapped( p );
+ Gia_ManForEachLut( p, i )
+ {
+ if ( pLutClass[i] != 109 )
+ continue;
+ Counter = Counter2 = 0;
+ Gia_LutForEachFanin( p, i, iFan, k )
+ {
+ Counter += (pLutClass[iFan] == 109);
+ Counter2 += (pLutClass[iFan] == 109) && (Gia_ObjRefsId(p, iFan) == 1);
+ }
+ OtherClasses += (Counter > 1);
+ OtherClasses2 += (Counter2 > 1);
+// Abc_Print( 1, "%d -- ", pLutClass[i] );
+// Gia_LutForEachFanin( p, i, iFan, k )
+// Abc_Print( 1, "%d ", pLutClass[iFan] );
+// Abc_Print( 1, "\n" );
+ }
+ ABC_FREE( p->pRefs );
+ Abc_Print( 1, "Approximate number of 4:1 MUX structures: All = %6d (%7.2f %%) MFFC = %6d (%7.2f %%)\n",
+ OtherClasses, 100.0 * OtherClasses / (nTotal+1),
+ OtherClasses2, 100.0 * OtherClasses2 / (nTotal+1) );
+ ABC_FREE( pLutClass );
}
////////////////////////////////////////////////////////////////////////
@@ -303,3 +525,5 @@ void Gia_ManPrintMappingStats( Gia_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaMan.c b/src/aig/gia/giaMan.c
index 4547e61c..ed6a5c95 100644
--- a/src/aig/gia/giaMan.c
+++ b/src/aig/gia/giaMan.c
@@ -19,6 +19,10 @@
***********************************************************************/
#include "gia.h"
+#include "tim.h"
+
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -66,10 +70,18 @@ Gia_Man_t * Gia_ManStart( int nObjsMax )
***********************************************************************/
void Gia_ManStop( Gia_Man_t * p )
{
+ Tim_ManStopP( (Tim_Man_t **)&p->pManTime );
+ assert( p->pManTime == NULL );
Vec_PtrFreeFree( p->vNamesIn );
Vec_PtrFreeFree( p->vNamesOut );
- if ( p->vFlopClasses )
- Vec_IntFree( p->vFlopClasses );
+ Vec_FltFreeP( &p->vTiming );
+ Vec_VecFreeP( &p->vClockDoms );
+ Vec_IntFreeP( &p->vLutConfigs );
+ Vec_IntFreeP( &p->vCiNumsOrig );
+ Vec_IntFreeP( &p->vCoNumsOrig );
+ Vec_IntFreeP( &p->vFlopClasses );
+ Vec_IntFreeP( &p->vLevels );
+ Vec_IntFreeP( &p->vTruths );
Vec_IntFree( p->vCis );
Vec_IntFree( p->vCos );
ABC_FREE( p->pTravIds );
@@ -85,7 +97,7 @@ void Gia_ManStop( Gia_Man_t * p )
ABC_FREE( p->pNexts );
ABC_FREE( p->pName );
ABC_FREE( p->pRefs );
- ABC_FREE( p->pLevels );
+ ABC_FREE( p->pNodeRefs );
ABC_FREE( p->pHTable );
ABC_FREE( p->pObjs );
ABC_FREE( p );
@@ -93,6 +105,25 @@ void Gia_ManStop( Gia_Man_t * p )
/**Function*************************************************************
+ Synopsis [Stops the AIG manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManStopP( Gia_Man_t ** p )
+{
+ if ( *p == NULL )
+ return;
+ Gia_ManStop( *p );
+ *p = NULL;
+}
+
+/**Function*************************************************************
+
Synopsis [Prints stats for the AIG.]
Description []
@@ -102,7 +133,7 @@ void Gia_ManStop( Gia_Man_t * p )
SeeAlso []
***********************************************************************/
-void Gia_ManPrintClasses( Gia_Man_t * p )
+void Gia_ManPrintClasses_old( Gia_Man_t * p )
{
Gia_Obj_t * pObj;
int i;
@@ -134,6 +165,44 @@ void Gia_ManPrintClasses( Gia_Man_t * p )
SeeAlso []
***********************************************************************/
+void Gia_ManPrintClasses( Gia_Man_t * p )
+{
+ int i, Class, Counter0, Counter1;
+ if ( p->vFlopClasses == NULL )
+ return;
+ if ( Vec_IntSize(p->vFlopClasses) != Gia_ManRegNum(p) )
+ {
+ printf( "Gia_ManPrintClasses(): The number of flop map entries differs from the number of flops.\n" );
+ return;
+ }
+ printf( "Register classes: " );
+ // count zero entries
+ Counter0 = 0;
+ Vec_IntForEachEntry( p->vFlopClasses, Class, i )
+ Counter0 += (Class == 0);
+ printf( "0=%d ", Counter0 );
+ // count one entries
+ Counter1 = 0;
+ Vec_IntForEachEntry( p->vFlopClasses, Class, i )
+ Counter1 += (Class == 1);
+ printf( "1=%d ", Counter1 );
+ // add comment
+ if ( Counter0 + Counter1 < Gia_ManRegNum(p) )
+ printf( "there are other classes..." );
+ printf( "\n" );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Prints stats for the AIG.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
void Gia_ManPrintPlacement( Gia_Man_t * p )
{
int i, nFixed = 0, nUndef = 0;
@@ -163,13 +232,15 @@ void Gia_ManPrintStats( Gia_Man_t * p, int fSwitch )
if ( p->pName )
printf( "%-8s : ", p->pName );
printf( "i/o =%7d/%7d", Gia_ManPiNum(p), Gia_ManPoNum(p) );
+ if ( Gia_ManConstrNum(p) )
+ printf( "(c=%d)", Gia_ManConstrNum(p) );
if ( Gia_ManRegNum(p) )
printf( " ff =%7d", Gia_ManRegNum(p) );
printf( " and =%8d", Gia_ManAndNum(p) );
printf( " lev =%5d", Gia_ManLevelNum(p) );
printf( " cut =%5d", Gia_ManCrossCut(p) );
printf( " mem =%5.2f Mb", 12.0*Gia_ManObjNum(p)/(1<<20) );
- if ( Gia_ManHasDandling(p) )
+ if ( Gia_ManHasDangling(p) )
printf( " ch =%5d", Gia_ManEquivCountClasses(p) );
if ( fSwitch )
{
@@ -189,7 +260,7 @@ void Gia_ManPrintStats( Gia_Man_t * p, int fSwitch )
if ( p->pPlacement )
Gia_ManPrintPlacement( p );
// print register classes
-// Gia_ManPrintClasses( p );
+ Gia_ManPrintClasses( p );
}
/**Function*************************************************************
@@ -309,3 +380,5 @@ void Gia_ManReportImprovement( Gia_Man_t * p, Gia_Man_t * pNew )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaMem.c b/src/aig/gia/giaMem.c
new file mode 100644
index 00000000..d77ddfd5
--- /dev/null
+++ b/src/aig/gia/giaMem.c
@@ -0,0 +1,598 @@
+/**CFile****************************************************************
+
+ FileName [giaMem.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [AIG package.]
+
+ Synopsis [Memory managers.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - April 28, 2007.]
+
+ Revision [$Id: giaMem.c,v 1.00 2007/04/28 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+struct Gia_MmFixed_t_
+{
+ // information about individual entries
+ int nEntrySize; // the size of one entry
+ int nEntriesAlloc; // the total number of entries allocated
+ int nEntriesUsed; // the number of entries in use
+ int nEntriesMax; // the max number of entries in use
+ char * pEntriesFree; // the linked list of free entries
+
+ // this is where the memory is stored
+ int nChunkSize; // the size of one chunk
+ int nChunksAlloc; // the maximum number of memory chunks
+ int nChunks; // the current number of memory chunks
+ char ** pChunks; // the allocated memory
+
+ // statistics
+ int nMemoryUsed; // memory used in the allocated entries
+ int nMemoryAlloc; // memory allocated
+};
+
+struct Gia_MmFlex_t_
+{
+ // information about individual entries
+ int nEntriesUsed; // the number of entries allocated
+ char * pCurrent; // the current pointer to free memory
+ char * pEnd; // the first entry outside the free memory
+
+ // this is where the memory is stored
+ int nChunkSize; // the size of one chunk
+ int nChunksAlloc; // the maximum number of memory chunks
+ int nChunks; // the current number of memory chunks
+ char ** pChunks; // the allocated memory
+
+ // statistics
+ int nMemoryUsed; // memory used in the allocated entries
+ int nMemoryAlloc; // memory allocated
+};
+
+struct Gia_MmStep_t_
+{
+ int nMems; // the number of fixed memory managers employed
+ Gia_MmFixed_t ** pMems; // memory managers: 2^1 words, 2^2 words, etc
+ int nMapSize; // the size of the memory array
+ Gia_MmFixed_t ** pMap; // maps the number of bytes into its memory manager
+ // additional memory chunks
+ int nChunksAlloc; // the maximum number of memory chunks
+ int nChunks; // the current number of memory chunks
+ char ** pChunks; // the allocated memory
+};
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Allocates memory pieces of fixed size.]
+
+ Description [The size of the chunk is computed as the minimum of
+ 1024 entries and 64K. Can only work with entry size at least 4 byte long.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_MmFixed_t * Gia_MmFixedStart( int nEntrySize, int nEntriesMax )
+{
+ Gia_MmFixed_t * p;
+
+ p = ABC_ALLOC( Gia_MmFixed_t, 1 );
+ memset( p, 0, sizeof(Gia_MmFixed_t) );
+
+ p->nEntrySize = nEntrySize;
+ p->nEntriesAlloc = 0;
+ p->nEntriesUsed = 0;
+ p->pEntriesFree = NULL;
+
+ p->nChunkSize = nEntriesMax / 8;
+ if ( p->nChunkSize < 8 )
+ p->nChunkSize = 8;
+
+ p->nChunksAlloc = 64;
+ p->nChunks = 0;
+ p->pChunks = ABC_ALLOC( char *, p->nChunksAlloc );
+
+ p->nMemoryUsed = 0;
+ p->nMemoryAlloc = 0;
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_MmFixedStop( Gia_MmFixed_t * p, int fVerbose )
+{
+ int i;
+ if ( p == NULL )
+ return;
+ if ( fVerbose )
+ {
+ printf( "Fixed memory manager: Entry = %5d. Chunk = %5d. Chunks used = %5d.\n",
+ p->nEntrySize, p->nChunkSize, p->nChunks );
+ printf( " Entries used = %8d. Entries peak = %8d. Memory used = %8d. Memory alloc = %8d.\n",
+ p->nEntriesUsed, p->nEntriesMax, p->nEntrySize * p->nEntriesUsed, p->nMemoryAlloc );
+ }
+ for ( i = 0; i < p->nChunks; i++ )
+ ABC_FREE( p->pChunks[i] );
+ ABC_FREE( p->pChunks );
+ ABC_FREE( p );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+char * Gia_MmFixedEntryFetch( Gia_MmFixed_t * p )
+{
+ char * pTemp;
+ int i;
+
+ // check if there are still free entries
+ if ( p->nEntriesUsed == p->nEntriesAlloc )
+ { // need to allocate more entries
+ assert( p->pEntriesFree == NULL );
+ if ( p->nChunks == p->nChunksAlloc )
+ {
+ p->nChunksAlloc *= 2;
+ p->pChunks = ABC_REALLOC( char *, p->pChunks, p->nChunksAlloc );
+ }
+ p->pEntriesFree = ABC_ALLOC( char, p->nEntrySize * p->nChunkSize );
+ p->nMemoryAlloc += p->nEntrySize * p->nChunkSize;
+ // transform these entries into a linked list
+ pTemp = p->pEntriesFree;
+ for ( i = 1; i < p->nChunkSize; i++ )
+ {
+ *((char **)pTemp) = pTemp + p->nEntrySize;
+ pTemp += p->nEntrySize;
+ }
+ // set the last link
+ *((char **)pTemp) = NULL;
+ // add the chunk to the chunk storage
+ p->pChunks[ p->nChunks++ ] = p->pEntriesFree;
+ // add to the number of entries allocated
+ p->nEntriesAlloc += p->nChunkSize;
+ }
+ // incrememt the counter of used entries
+ p->nEntriesUsed++;
+ if ( p->nEntriesMax < p->nEntriesUsed )
+ p->nEntriesMax = p->nEntriesUsed;
+ // return the first entry in the free entry list
+ pTemp = p->pEntriesFree;
+ p->pEntriesFree = *((char **)pTemp);
+ return pTemp;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_MmFixedEntryRecycle( Gia_MmFixed_t * p, char * pEntry )
+{
+ // decrement the counter of used entries
+ p->nEntriesUsed--;
+ // add the entry to the linked list of free entries
+ *((char **)pEntry) = p->pEntriesFree;
+ p->pEntriesFree = pEntry;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description [Relocates all the memory except the first chunk.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_MmFixedRestart( Gia_MmFixed_t * p )
+{
+ int i;
+ char * pTemp;
+ if ( p->nChunks == 0 )
+ return;
+ // deallocate all chunks except the first one
+ for ( i = 1; i < p->nChunks; i++ )
+ ABC_FREE( p->pChunks[i] );
+ p->nChunks = 1;
+ // transform these entries into a linked list
+ pTemp = p->pChunks[0];
+ for ( i = 1; i < p->nChunkSize; i++ )
+ {
+ *((char **)pTemp) = pTemp + p->nEntrySize;
+ pTemp += p->nEntrySize;
+ }
+ // set the last link
+ *((char **)pTemp) = NULL;
+ // set the free entry list
+ p->pEntriesFree = p->pChunks[0];
+ // set the correct statistics
+ p->nMemoryAlloc = p->nEntrySize * p->nChunkSize;
+ p->nMemoryUsed = 0;
+ p->nEntriesAlloc = p->nChunkSize;
+ p->nEntriesUsed = 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_MmFixedReadMemUsage( Gia_MmFixed_t * p )
+{
+ return p->nMemoryAlloc;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_MmFixedReadMaxEntriesUsed( Gia_MmFixed_t * p )
+{
+ return p->nEntriesMax;
+}
+
+
+
+/**Function*************************************************************
+
+ Synopsis [Allocates entries of flexible size.]
+
+ Description [Can only work with entry size at least 4 byte long.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_MmFlex_t * Gia_MmFlexStart()
+{
+ Gia_MmFlex_t * p;
+
+ p = ABC_ALLOC( Gia_MmFlex_t, 1 );
+ memset( p, 0, sizeof(Gia_MmFlex_t) );
+
+ p->nEntriesUsed = 0;
+ p->pCurrent = NULL;
+ p->pEnd = NULL;
+
+ p->nChunkSize = (1 << 18);
+ p->nChunksAlloc = 64;
+ p->nChunks = 0;
+ p->pChunks = ABC_ALLOC( char *, p->nChunksAlloc );
+
+ p->nMemoryUsed = 0;
+ p->nMemoryAlloc = 0;
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_MmFlexStop( Gia_MmFlex_t * p, int fVerbose )
+{
+ int i;
+ if ( p == NULL )
+ return;
+ if ( fVerbose )
+ {
+ printf( "Flexible memory manager: Chunk size = %d. Chunks used = %d.\n",
+ p->nChunkSize, p->nChunks );
+ printf( " Entries used = %d. Memory used = %d. Memory alloc = %d.\n",
+ p->nEntriesUsed, p->nMemoryUsed, p->nMemoryAlloc );
+ }
+ for ( i = 0; i < p->nChunks; i++ )
+ ABC_FREE( p->pChunks[i] );
+ ABC_FREE( p->pChunks );
+ ABC_FREE( p );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+char * Gia_MmFlexEntryFetch( Gia_MmFlex_t * p, int nBytes )
+{
+ char * pTemp;
+ // check if there are still free entries
+ if ( p->pCurrent == NULL || p->pCurrent + nBytes > p->pEnd )
+ { // need to allocate more entries
+ if ( p->nChunks == p->nChunksAlloc )
+ {
+ p->nChunksAlloc *= 2;
+ p->pChunks = ABC_REALLOC( char *, p->pChunks, p->nChunksAlloc );
+ }
+ if ( nBytes > p->nChunkSize )
+ {
+ // resize the chunk size if more memory is requested than it can give
+ // (ideally, this should never happen)
+ p->nChunkSize = 2 * nBytes;
+ }
+ p->pCurrent = ABC_ALLOC( char, p->nChunkSize );
+ p->pEnd = p->pCurrent + p->nChunkSize;
+ p->nMemoryAlloc += p->nChunkSize;
+ // add the chunk to the chunk storage
+ p->pChunks[ p->nChunks++ ] = p->pCurrent;
+ }
+ assert( p->pCurrent + nBytes <= p->pEnd );
+ // increment the counter of used entries
+ p->nEntriesUsed++;
+ // keep track of the memory used
+ p->nMemoryUsed += nBytes;
+ // return the next entry
+ pTemp = p->pCurrent;
+ p->pCurrent += nBytes;
+ return pTemp;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description [Relocates all the memory except the first chunk.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_MmFlexRestart( Gia_MmFlex_t * p )
+{
+ int i;
+ if ( p->nChunks == 0 )
+ return;
+ // deallocate all chunks except the first one
+ for ( i = 1; i < p->nChunks; i++ )
+ ABC_FREE( p->pChunks[i] );
+ p->nChunks = 1;
+ p->nMemoryAlloc = p->nChunkSize;
+ // transform these entries into a linked list
+ p->pCurrent = p->pChunks[0];
+ p->pEnd = p->pCurrent + p->nChunkSize;
+ p->nEntriesUsed = 0;
+ p->nMemoryUsed = 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_MmFlexReadMemUsage( Gia_MmFlex_t * p )
+{
+ return p->nMemoryUsed;
+}
+
+
+
+
+
+/**Function*************************************************************
+
+ Synopsis [Starts the hierarchical memory manager.]
+
+ Description [This manager can allocate entries of any size.
+ Iternally they are mapped into the entries with the number of bytes
+ equal to the power of 2. The smallest entry size is 8 bytes. The
+ next one is 16 bytes etc. So, if the user requests 6 bytes, he gets
+ 8 byte entry. If we asks for 25 bytes, he gets 32 byte entry etc.
+ The input parameters "nSteps" says how many fixed memory managers
+ are employed internally. Calling this procedure with nSteps equal
+ to 10 results in 10 hierarchically arranged internal memory managers,
+ which can allocate up to 4096 (1Kb) entries. Requests for larger
+ entries are handed over to malloc() and then ABC_FREE()ed.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_MmStep_t * Gia_MmStepStart( int nSteps )
+{
+ Gia_MmStep_t * p;
+ int i, k;
+ p = ABC_ALLOC( Gia_MmStep_t, 1 );
+ memset( p, 0, sizeof(Gia_MmStep_t) );
+ p->nMems = nSteps;
+ // start the fixed memory managers
+ p->pMems = ABC_ALLOC( Gia_MmFixed_t *, p->nMems );
+ for ( i = 0; i < p->nMems; i++ )
+ p->pMems[i] = Gia_MmFixedStart( (8<<i), (1<<13) );
+ // set up the mapping of the required memory size into the corresponding manager
+ p->nMapSize = (4<<p->nMems);
+ p->pMap = ABC_ALLOC( Gia_MmFixed_t *, p->nMapSize+1 );
+ p->pMap[0] = NULL;
+ for ( k = 1; k <= 4; k++ )
+ p->pMap[k] = p->pMems[0];
+ for ( i = 0; i < p->nMems; i++ )
+ for ( k = (4<<i)+1; k <= (8<<i); k++ )
+ p->pMap[k] = p->pMems[i];
+//for ( i = 1; i < 100; i ++ )
+//printf( "%10d: size = %10d\n", i, p->pMap[i]->nEntrySize );
+ p->nChunksAlloc = 64;
+ p->nChunks = 0;
+ p->pChunks = ABC_ALLOC( char *, p->nChunksAlloc );
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Stops the memory manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_MmStepStop( Gia_MmStep_t * p, int fVerbose )
+{
+ int i;
+ for ( i = 0; i < p->nMems; i++ )
+ Gia_MmFixedStop( p->pMems[i], fVerbose );
+ if ( p->nChunksAlloc )
+ {
+ for ( i = 0; i < p->nChunks; i++ )
+ ABC_FREE( p->pChunks[i] );
+ ABC_FREE( p->pChunks );
+ }
+ ABC_FREE( p->pMems );
+ ABC_FREE( p->pMap );
+ ABC_FREE( p );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates the entry.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+char * Gia_MmStepEntryFetch( Gia_MmStep_t * p, int nBytes )
+{
+ if ( nBytes == 0 )
+ return NULL;
+ if ( nBytes > p->nMapSize )
+ {
+ if ( p->nChunks == p->nChunksAlloc )
+ {
+ p->nChunksAlloc *= 2;
+ p->pChunks = ABC_REALLOC( char *, p->pChunks, p->nChunksAlloc );
+ }
+ p->pChunks[ p->nChunks++ ] = ABC_ALLOC( char, nBytes );
+ return p->pChunks[p->nChunks-1];
+ }
+ return Gia_MmFixedEntryFetch( p->pMap[nBytes] );
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Recycles the entry.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_MmStepEntryRecycle( Gia_MmStep_t * p, char * pEntry, int nBytes )
+{
+ if ( nBytes == 0 )
+ return;
+ if ( nBytes > p->nMapSize )
+ {
+// ABC_FREE( pEntry );
+ return;
+ }
+ Gia_MmFixedEntryRecycle( p->pMap[nBytes], pEntry );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_MmStepReadMemUsage( Gia_MmStep_t * p )
+{
+ int i, nMemTotal = 0;
+ for ( i = 0; i < p->nMems; i++ )
+ nMemTotal += p->pMems[i]->nMemoryAlloc;
+ return nMemTotal;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaPat.c b/src/aig/gia/giaPat.c
index 7968932c..bd43380f 100644
--- a/src/aig/gia/giaPat.c
+++ b/src/aig/gia/giaPat.c
@@ -20,6 +20,9 @@
#include "gia.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -127,3 +130,5 @@ void Gia_SatVerifyPattern( Gia_Man_t * p, Gia_Obj_t * pRoot, Vec_Int_t * vCex, V
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaProp.c b/src/aig/gia/giaProp.c
index 1d9ed8cf..fee9aa40 100644
--- a/src/aig/gia/giaProp.c
+++ b/src/aig/gia/giaProp.c
@@ -20,6 +20,9 @@
#include "gia.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -169,3 +172,5 @@ int Gia_SatPathStart( Gia_Obj_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaReparam.c b/src/aig/gia/giaReparam.c
new file mode 100644
index 00000000..e33c1b7e
--- /dev/null
+++ b/src/aig/gia/giaReparam.c
@@ -0,0 +1,201 @@
+/**CFile****************************************************************
+
+ FileName [gia.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Scalable AIG package.]
+
+ Synopsis []
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: gia.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+#include "giaAig.h"
+#include "saig.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Specialized duplication.]
+
+ Description [Replaces registers by PIs/POs and PIs by registers.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManDupIn2Ff( Gia_Man_t * p )
+{
+ Vec_Int_t * vPiOuts;
+ Gia_Man_t * pNew;
+ Gia_Obj_t * pObj;
+ int i;
+ vPiOuts = Vec_IntAlloc( Gia_ManPiNum(p) );
+ pNew = Gia_ManStart( Gia_ManObjNum(p) + 2 * Gia_ManPiNum(p) );
+ pNew->pName = Gia_UtilStrsav( p->pName );
+ Gia_ManFillValue( p );
+ Gia_ManConst0(p)->Value = 0;
+ Gia_ManForEachPi( p, pObj, i )
+ Vec_IntPush( vPiOuts, Gia_ManAppendCi(pNew) );
+ Gia_ManForEachRo( p, pObj, i )
+ pObj->Value = Gia_ManAppendCi( pNew );
+ Gia_ManForEachPi( p, pObj, i )
+ pObj->Value = Gia_ManAppendCi( pNew );
+ Gia_ManForEachAnd( p, pObj, i )
+ pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+ Gia_ManForEachPo( p, pObj, i )
+ pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
+ Gia_ManForEachRi( p, pObj, i )
+ pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
+ Gia_ManForEachPi( p, pObj, i )
+ Gia_ManAppendCo( pNew, Vec_IntEntry(vPiOuts, i) );
+ Gia_ManSetRegNum( pNew, Gia_ManPiNum(p) );
+ Vec_IntFree( vPiOuts );
+ return pNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Reverses the above step.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManDupFf2In_rec( Gia_Man_t * pNew, Gia_Obj_t * pObj )
+{
+ if ( pObj->Value != ~0 )
+ return pObj->Value;
+ assert( Gia_ObjIsAnd(pObj) );
+ Gia_ManDupFf2In_rec( pNew, Gia_ObjFanin0(pObj) );
+ Gia_ManDupFf2In_rec( pNew, Gia_ObjFanin1(pObj) );
+ return pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Reverses the above step.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManDupFf2In( Gia_Man_t * p, int nFlopsOld )
+{
+ Gia_Man_t * pNew;
+ Gia_Obj_t * pObj;
+ int i;
+ pNew = Gia_ManStart( Gia_ManObjNum(p) );
+ pNew->pName = Gia_UtilStrsav( p->pName );
+ Gia_ManFillValue( p );
+ Gia_ManConst0(p)->Value = 0;
+ Gia_ManForEachRo( p, pObj, i )
+ pObj->Value = Gia_ManAppendCi( pNew );
+ for ( i = Gia_ManPiNum(p) - nFlopsOld; i < Gia_ManPiNum(p); i++ )
+ Gia_ManPi(p, i)->Value = Gia_ManAppendCi( pNew );
+ Gia_ManForEachPo( p, pObj, i )
+ Gia_ManDupFf2In_rec( pNew, Gia_ObjFanin0(pObj) );
+ Gia_ManForEachPo( p, pObj, i )
+ Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
+ Gia_ManSetRegNum( pNew, nFlopsOld );
+ return pNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Reparameterized to get rid of useless primary inputs.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManReparm( Gia_Man_t * p, int fVerbose )
+{
+// extern Aig_Man_t * Saig_ManRetimeMinArea( Aig_Man_t * p, int nMaxIters, int fForwardOnly, int fBackwardOnly, int fInitial, int fVerbose );
+ Aig_Man_t * pMan, * pTemp;
+ Gia_Man_t * pNew, * pTmp;
+ int nFlopsOld = Gia_ManRegNum(p);
+ if ( fVerbose )
+ {
+ printf( "Original AIG:\n" );
+ Gia_ManPrintStats( p, 0 );
+ }
+
+ // perform input trimming
+ pNew = Gia_ManDupTrimmed( p, 1, 0 );
+ if ( fVerbose )
+ {
+ printf( "After PI trimming:\n" );
+ Gia_ManPrintStats( pNew, 0 );
+ }
+ // transform GIA
+ pNew = Gia_ManDupIn2Ff( pTmp = pNew );
+ Gia_ManStop( pTmp );
+ if ( fVerbose )
+ {
+ printf( "After PI-2-FF transformation:\n" );
+ Gia_ManPrintStats( pNew, 0 );
+ }
+
+ // derive AIG
+ pMan = Gia_ManToAigSimple( pNew );
+ Gia_ManStop( pNew );
+ // perform min-reg retiming
+ pMan = Saig_ManRetimeMinArea( pTemp = pMan, 10, 0, 0, 1, 0 );
+ Aig_ManStop( pTemp );
+ // derive GIA
+ pNew = Gia_ManFromAigSimple( pMan );
+ Aig_ManStop( pMan );
+ if ( fVerbose )
+ {
+ printf( "After min-area retiming:\n" );
+ Gia_ManPrintStats( pNew, 0 );
+ }
+
+ // transform back
+ pNew = Gia_ManDupFf2In( pTmp = pNew, nFlopsOld );
+ Gia_ManStop( pTmp );
+ if ( fVerbose )
+ {
+ printf( "After FF-2-PI tranformation:\n" );
+ Gia_ManPrintStats( pNew, 0 );
+ }
+ return pNew;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaRetime.c b/src/aig/gia/giaRetime.c
index 967b6d01..58029b66 100644
--- a/src/aig/gia/giaRetime.c
+++ b/src/aig/gia/giaRetime.c
@@ -20,6 +20,9 @@
#include "gia.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -131,7 +134,7 @@ Gia_Man_t * Gia_ManRetimeDupForward( Gia_Man_t * p, Vec_Ptr_t * vCut )
Gia_ManForEachPi( p, pObj, i )
pObj->Value = Gia_ManAppendCi( pNew );
// create the registers
- Vec_PtrForEachEntry( vCut, pObj, i )
+ Vec_PtrForEachEntry( Gia_Obj_t *, vCut, pObj, i )
pObj->Value = Gia_LitNotCond( Gia_ManAppendCi(pNew), pObj->fPhase );
// duplicate logic above the cut
Gia_ManForEachCo( p, pObj, i )
@@ -146,11 +149,11 @@ Gia_Man_t * Gia_ManRetimeDupForward( Gia_Man_t * p, Vec_Ptr_t * vCut )
Gia_ManForEachRiRo( p, pObjRi, pObjRo, i )
pObjRo->Value = pObjRi->Value;
// erase the data values on the internal nodes of the cut
- Vec_PtrForEachEntry( vCut, pObj, i )
+ Vec_PtrForEachEntry( Gia_Obj_t *, vCut, pObj, i )
if ( Gia_ObjIsAnd(pObj) )
pObj->Value = ~0;
// duplicate logic below the cut
- Vec_PtrForEachEntry( vCut, pObj, i )
+ Vec_PtrForEachEntry( Gia_Obj_t *, vCut, pObj, i )
{
Gia_ManRetimeDup_rec( pNew, pObj );
Gia_ManAppendCo( pNew, Gia_LitNotCond( pObj->Value, pObj->fPhase ) );
@@ -192,7 +195,7 @@ Gia_Man_t * Gia_ManRetimeForwardOne( Gia_Man_t * p, int * pnRegFixed, int * pnRe
vFlopClasses = Vec_IntAlloc( Gia_ManRegNum(p) );
}
// mark the retimable nodes
- Gia_ManResetTravId( p );
+ Gia_ManIncrementTravId( p );
Gia_ManMarkAutonomous( p );
// mark the retimable registers with the fresh trav ID
Gia_ManIncrementTravId( p );
@@ -295,3 +298,5 @@ Gia_Man_t * Gia_ManRetimeForward( Gia_Man_t * p, int nMaxIters, int fVerbose )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaSat.c b/src/aig/gia/giaSat.c
index 29ade5c6..c2d70795 100644
--- a/src/aig/gia/giaSat.c
+++ b/src/aig/gia/giaSat.c
@@ -20,6 +20,9 @@
#include "gia.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -419,3 +422,5 @@ void Gia_ManSatExperiment( Gia_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaScl.c b/src/aig/gia/giaScl.c
index 5ac8e04a..a482d024 100644
--- a/src/aig/gia/giaScl.c
+++ b/src/aig/gia/giaScl.c
@@ -20,6 +20,9 @@
#include "gia.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -187,7 +190,7 @@ Gia_Man_t * Gia_ManReduceEquiv( Gia_Man_t * p, int fVerbose )
if ( Gia_ObjFanin0(pObjRi)->Value == 0 )
Gia_ObjFanin0(pObjRi)->Value = 2*nFanins++;
pCi2Lit = ABC_FALLOC( unsigned, Gia_ManCiNum(p) );
- pMaps = ABC_FALLOC( unsigned, 2 * nFanins );
+ pMaps = ABC_FALLOC( unsigned, 2 * nFanins );
Gia_ManForEachRiRo( p, pObjRi, pObjRo, i )
{
iLit = Gia_ObjFanin0Copy( pObjRi );
@@ -215,7 +218,7 @@ Gia_Man_t * Gia_ManReduceEquiv( Gia_Man_t * p, int fVerbose )
// printf( "ReduceEquiv detected %d constant regs and %d equivalent regs.\n", Counter0, Counter );
ABC_FREE( pMaps );
if ( Counter0 || Counter )
- pNew = Gia_ManDupDfsCiMap( p, pCi2Lit, NULL );
+ pNew = Gia_ManDupDfsCiMap( p, (int *)pCi2Lit, NULL );
else
pNew = p;
ABC_FREE( pCi2Lit );
@@ -274,3 +277,5 @@ Gia_Man_t * Gia_ManSeqStructSweep( Gia_Man_t * p, int fConst, int fEquiv, int fV
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaShrink.c b/src/aig/gia/giaShrink.c
new file mode 100644
index 00000000..fc9e80d6
--- /dev/null
+++ b/src/aig/gia/giaShrink.c
@@ -0,0 +1,151 @@
+/**CFile****************************************************************
+
+ FileName [giaShrink.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Scalable AIG package.]
+
+ Synopsis [Implementation of mapShrink based on ideas of Niklas Een.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: giaShrink.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+#include "aig.h"
+#include "dar.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+extern int Dar_LibEvalBuild( Gia_Man_t * p, Vec_Int_t * vCut, unsigned uTruth, int fKeepLevel, Vec_Int_t * vLeavesBest );
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Performs AIG shrinking using the current mapping.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManPerformMapShrink( Gia_Man_t * p, int fKeepLevel, int fVerbose )
+{
+ Vec_Int_t * vLeaves, * vTruth, * vVisited, * vLeavesBest;
+ Gia_Man_t * pNew, * pTemp;
+ Gia_Obj_t * pObj, * pFanin;
+ unsigned * pTruth;
+ int i, k, iFan, clk = clock();
+ int ClassCounts[222] = {0};
+ int * pLutClass, Counter = 0;
+ assert( p->pMapping != NULL );
+ if ( Gia_ManLutSizeMax( p ) > 4 )
+ {
+ printf( "Resynthesis is not performed when nodes have more than 4 inputs.\n" );
+ return NULL;
+ }
+ pLutClass = ABC_CALLOC( int, Gia_ManObjNum(p) );
+ vLeaves = Vec_IntAlloc( 0 );
+ vTruth = Vec_IntAlloc( (1<<16) );
+ vVisited = Vec_IntAlloc( 0 );
+ vLeavesBest = Vec_IntAlloc( 4 );
+ // prepare the library
+ Dar_LibPrepare( 5 );
+ // clean the old manager
+ Gia_ManCleanTruth( p );
+ Gia_ManSetPhase( p );
+ Gia_ManFillValue( p );
+ Gia_ManConst0(p)->Value = 0;
+ // start the new manager
+ pNew = Gia_ManStart( Gia_ManObjNum(p) );
+ pNew->pName = Gia_UtilStrsav( p->pName );
+ Gia_ManHashAlloc( pNew );
+ Gia_ManCleanLevels( pNew, Gia_ManObjNum(p) );
+ Gia_ManForEachObj1( p, pObj, i )
+ {
+ if ( Gia_ObjIsCi(pObj) )
+ {
+ pObj->Value = Gia_ManAppendCi( pNew );
+ Gia_ObjSetLevel( pNew, Gia_ObjFromLit(pNew, Gia_ObjValue(pObj)), Gia_ObjLevel(p, pObj) );
+ }
+ else if ( Gia_ObjIsCo(pObj) )
+ {
+ pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
+ }
+ else if ( Gia_ObjIsLut(p, i) )
+ {
+ Counter++;
+ // collect leaves of this gate
+ Vec_IntClear( vLeaves );
+ Gia_LutForEachFanin( p, i, iFan, k )
+ Vec_IntPush( vLeaves, iFan );
+ for ( ; k < 4; k++ )
+ Vec_IntPush( vLeaves, 0 );
+ //.compute the truth table
+ pTruth = Gia_ManConvertAigToTruth( p, pObj, vLeaves, vTruth, vVisited );
+ // change from node IDs to their literals
+ Gia_ManForEachObjVec( vLeaves, p, pFanin, k )
+ {
+ assert( Gia_ObjValue(pFanin) != ~0 );
+ Vec_IntWriteEntry( vLeaves, k, Gia_ObjValue(pFanin) );
+ }
+ // derive new structre
+ if ( Gia_ManTruthIsConst0(pTruth, Vec_IntSize(vLeaves)) )
+ pObj->Value = 0;
+ else if ( Gia_ManTruthIsConst1(pTruth, Vec_IntSize(vLeaves)) )
+ pObj->Value = 1;
+ else
+ {
+ pObj->Value = Dar_LibEvalBuild( pNew, vLeaves, 0xffff & *pTruth, fKeepLevel, vLeavesBest );
+ pObj->Value = Gia_LitNotCond( pObj->Value, Gia_ObjPhaseRealLit(pNew, pObj->Value) ^ pObj->fPhase );
+ }
+ }
+ }
+ // cleanup the AIG
+ Gia_ManHashStop( pNew );
+ // check the presence of dangling nodes
+ if ( Gia_ManHasDangling(pNew) )
+ {
+ pNew = Gia_ManCleanup( pTemp = pNew );
+ if ( Gia_ManAndNum(pNew) != Gia_ManAndNum(pTemp) )
+ printf( "Gia_ManPerformMapShrink() node reduction after sweep %6d -> %6d.\n", Gia_ManAndNum(pTemp), Gia_ManAndNum(pNew) );
+ Gia_ManStop( pTemp );
+ }
+ Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
+ Vec_IntFree( vLeaves );
+ Vec_IntFree( vTruth );
+ Vec_IntFree( vVisited );
+ Vec_IntFree( vLeavesBest );
+ if ( fVerbose )
+ {
+ printf( "Total gain in AIG nodes = %d. ", Gia_ManObjNum(p)-Gia_ManObjNum(pNew) );
+ ABC_PRT( "Total runtime", clock() - clk );
+ }
+ ABC_FREE( pLutClass );
+ return pNew;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaSim.c b/src/aig/gia/giaSim.c
index ae9e304c..68b50fb6 100644
--- a/src/aig/gia/giaSim.c
+++ b/src/aig/gia/giaSim.c
@@ -20,6 +20,9 @@
#include "gia.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -65,6 +68,28 @@ void Gia_ManSimSetDefaultParams( Gia_ParSim_t * p )
p->TimeLimit = 60; // time limit in seconds
p->fCheckMiter = 0; // check if miter outputs are non-zero
p->fVerbose = 0; // enables verbose output
+ p->iOutFail = -1; // index of the failed output
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManSimDelete( Gia_ManSim_t * p )
+{
+ Vec_IntFreeP( &p->vCis2Ids );
+ Gia_ManStopP( &p->pAig );
+ ABC_FREE( p->pDataSim );
+ ABC_FREE( p->pDataSimCis );
+ ABC_FREE( p->pDataSimCos );
+ ABC_FREE( p );
}
/**Function*************************************************************
@@ -90,10 +115,18 @@ Gia_ManSim_t * Gia_ManSimCreate( Gia_Man_t * pAig, Gia_ParSim_t * pPars )
p->pDataSim = ABC_ALLOC( unsigned, p->nWords * p->pAig->nFront );
p->pDataSimCis = ABC_ALLOC( unsigned, p->nWords * Gia_ManCiNum(p->pAig) );
p->pDataSimCos = ABC_ALLOC( unsigned, p->nWords * Gia_ManCoNum(p->pAig) );
+ if ( !p->pDataSim || !p->pDataSimCis || !p->pDataSimCos )
+ {
+ Abc_Print( 1, "Simulator could not allocate %.2f Gb for simulation info.\n",
+ 4.0 * p->nWords * (p->pAig->nFront + Gia_ManCiNum(p->pAig) + Gia_ManCoNum(p->pAig)) / (1<<30) );
+ Gia_ManSimDelete( p );
+ return NULL;
+ }
p->vCis2Ids = Vec_IntAlloc( Gia_ManCiNum(p->pAig) );
Vec_IntForEachEntry( pAig->vCis, Entry, i )
Vec_IntPush( p->vCis2Ids, i ); // do we need p->vCis2Ids?
- printf( "AIG = %7.2f Mb. Front mem = %7.2f Mb. Other mem = %7.2f Mb.\n",
+ if ( pPars->fVerbose )
+ Abc_Print( 1, "AIG = %7.2f Mb. Front mem = %7.2f Mb. Other mem = %7.2f Mb.\n",
12.0*Gia_ManObjNum(p->pAig)/(1<<20),
4.0*p->nWords*p->pAig->nFront/(1<<20),
4.0*p->nWords*(Gia_ManCiNum(p->pAig) + Gia_ManCoNum(p->pAig))/(1<<20) );
@@ -111,27 +144,6 @@ Gia_ManSim_t * Gia_ManSimCreate( Gia_Man_t * pAig, Gia_ParSim_t * pPars )
SeeAlso []
***********************************************************************/
-void Gia_ManSimDelete( Gia_ManSim_t * p )
-{
- Vec_IntFree( p->vCis2Ids );
- Gia_ManStop( p->pAig );
- ABC_FREE( p->pDataSim );
- ABC_FREE( p->pDataSimCis );
- ABC_FREE( p->pDataSimCos );
- ABC_FREE( p );
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
static inline void Gia_ManSimInfoRandom( Gia_ManSim_t * p, unsigned * pInfo )
{
int w;
@@ -171,9 +183,9 @@ static inline void Gia_ManSimInfoZero( Gia_ManSim_t * p, unsigned * pInfo )
static inline int Gia_ManSimInfoIsZero( Gia_ManSim_t * p, unsigned * pInfo )
{
int w;
- for ( w = p->nWords-1; w >= 0; w-- )
+ for ( w = 0; w < p->nWords; w++ )
if ( pInfo[w] )
- return 32*(w-1) + Gia_WordFindFirstBit( pInfo[w] );
+ return 32*w + Gia_WordFindFirstBit( pInfo[w] );
return -1;
}
@@ -418,9 +430,9 @@ static inline int Gia_ManCheckPos( Gia_ManSim_t * p, int * piPo, int * piPat )
SeeAlso []
***********************************************************************/
-Gia_Cex_t * Gia_ManGenerateCounter( Gia_Man_t * pAig, int iFrame, int iOut, int nWords, int iPat, Vec_Int_t * vCis2Ids )
+Abc_Cex_t * Gia_ManGenerateCounter( Gia_Man_t * pAig, int iFrame, int iOut, int nWords, int iPat, Vec_Int_t * vCis2Ids )
{
- Gia_Cex_t * p;
+ Abc_Cex_t * p;
unsigned * pData;
int f, i, w, iPioId, Counter;
p = Gia_ManAllocCounterExample( Gia_ManRegNum(pAig), Gia_ManPiNum(pAig), iFrame+1 );
@@ -468,43 +480,44 @@ int Gia_ManSimSimulate( Gia_Man_t * pAig, Gia_ParSim_t * pPars )
for ( i = 0; i < pPars->nIters; i++ )
{
Gia_ManSimulateRound( p );
-
if ( pPars->fVerbose )
{
- printf( "Frame %4d out of %4d and timeout %3d sec. ", i+1, pPars->nIters, pPars->TimeLimit );
- printf( "Time = %7.2f sec\r", (1.0*clock()-clkTotal)/CLOCKS_PER_SEC );
+ Abc_Print( 1, "Frame %4d out of %4d and timeout %3d sec. ", i+1, pPars->nIters, pPars->TimeLimit );
+ Abc_Print( 1, "Time = %7.2f sec\r", (1.0*clock()-clkTotal)/CLOCKS_PER_SEC );
}
if ( pPars->fCheckMiter && Gia_ManCheckPos( p, &iOut, &iPat ) )
{
+ pPars->iOutFail = iOut;
pAig->pCexSeq = Gia_ManGenerateCounter( pAig, i, iOut, p->nWords, iPat, p->vCis2Ids );
- printf( "Output %d was asserted in frame %d (use \"write_counter\" to dump a witness).\n", iOut, i );
+ Abc_Print( 1, "Networks are NOT EQUIVALENT. Output %d was asserted in frame %d. ", iOut, i );
if ( !Gia_ManVerifyCounterExample( pAig, pAig->pCexSeq, 0 ) )
{
- printf( "\n" );
- printf( "Generated counter-example is INVALID \n" );
- printf( "\n" );
+// Abc_Print( 1, "\n" );
+ Abc_Print( 1, "\nGenerated counter-example is INVALID. " );
+// Abc_Print( 1, "\n" );
}
else
{
- printf( "\n" );
- printf( "Generated counter-example is fine \n" );
- printf( "\n" );
+// Abc_Print( 1, "\n" );
+// if ( pPars->fVerbose )
+// Abc_Print( 1, "\nGenerated counter-example is verified correctly. " );
+// Abc_Print( 1, "\n" );
}
RetValue = 1;
break;
}
if ( (clock() - clkTotal)/CLOCKS_PER_SEC >= pPars->TimeLimit )
{
- printf( "No bug detected after %d frames with time limit %d seconds. \n", i+1, pPars->TimeLimit );
+ i++;
break;
}
-
if ( i < pPars->nIters - 1 )
Gia_ManSimInfoTransfer( p );
}
Gia_ManSimDelete( p );
- printf( "Simulated %d frames with %d words. ", i, pPars->nWords );
- ABC_PRT( "Time", clock() - clkTotal );
+ if ( pAig->pCexSeq == NULL )
+ Abc_Print( 1, "No bug detected after simulating %d frames with %d words. ", i, pPars->nWords );
+ Abc_PrintTime( 1, "Time", clock() - clkTotal );
return RetValue;
}
@@ -513,3 +526,5 @@ int Gia_ManSimSimulate( Gia_Man_t * pAig, Gia_ParSim_t * pPars )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaSort.c b/src/aig/gia/giaSort.c
index 8574297d..f73e92bb 100644
--- a/src/aig/gia/giaSort.c
+++ b/src/aig/gia/giaSort.c
@@ -20,6 +20,9 @@
#include "gia.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -266,3 +269,5 @@ int * Gia_SortFloats( float * pArray, int * pPerm, int nSize )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaSpeedup.c b/src/aig/gia/giaSpeedup.c
new file mode 100644
index 00000000..cce0b68d
--- /dev/null
+++ b/src/aig/gia/giaSpeedup.c
@@ -0,0 +1,810 @@
+/**CFile****************************************************************
+
+ FileName [gia.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Scalable AIG package.]
+
+ Synopsis []
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: gia.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+#include "if.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Sorts the pins in the decreasing order of delays.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_LutDelayTraceSortPins( Gia_Man_t * p, int iObj, int * pPinPerm, float * pPinDelays )
+{
+ int iFanin, i, j, best_i, temp;
+ assert( Gia_ObjIsLut(p, iObj) );
+ // start the trivial permutation and collect pin delays
+ Gia_LutForEachFanin( p, iObj, iFanin, i )
+ {
+ pPinPerm[i] = i;
+ pPinDelays[i] = Gia_ObjTimeArrival(p, iFanin);
+ }
+ // selection sort the pins in the decreasible order of delays
+ // this order will match the increasing order of LUT input pins
+ for ( i = 0; i < Gia_ObjLutSize(p, iObj)-1; i++ )
+ {
+ best_i = i;
+ for ( j = i+1; j < Gia_ObjLutSize(p, iObj); j++ )
+ if ( pPinDelays[pPinPerm[j]] > pPinDelays[pPinPerm[best_i]] )
+ best_i = j;
+ if ( best_i == i )
+ continue;
+ temp = pPinPerm[i];
+ pPinPerm[i] = pPinPerm[best_i];
+ pPinPerm[best_i] = temp;
+ }
+ // verify
+ assert( Gia_ObjLutSize(p, iObj) == 0 || pPinPerm[0] < Gia_ObjLutSize(p, iObj) );
+ for ( i = 1; i < Gia_ObjLutSize(p, iObj); i++ )
+ {
+ assert( pPinPerm[i] < Gia_ObjLutSize(p, iObj) );
+ assert( pPinDelays[pPinPerm[i-1]] >= pPinDelays[pPinPerm[i]] );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Sorts the pins in the decreasing order of delays.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_LutWhereIsPin( Gia_Man_t * p, int iFanout, int iFanin, int * pPinPerm )
+{
+ int i;
+ for ( i = 0; i < Gia_ObjLutSize(p, iFanout); i++ )
+ if ( Gia_ObjLutFanin(p, iFanout, pPinPerm[i]) == iFanin )
+ return i;
+ return -1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes the arrival times for the given object.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+float Gia_ObjComputeArrival( Gia_Man_t * p, int iObj, int fUseSorting )
+{
+ If_Lib_t * pLutLib = (If_Lib_t *)p->pLutLib;
+ Gia_Obj_t * pObj = Gia_ManObj( p, iObj );
+ int k, iFanin, pPinPerm[32];
+ float pPinDelays[32];
+ float tArrival, * pDelays;
+ if ( Gia_ObjIsCi(pObj) )
+ return Gia_ObjTimeArrival(p, iObj);
+ if ( Gia_ObjIsCo(pObj) )
+ return Gia_ObjTimeArrival(p, Gia_ObjFaninId0p(p, pObj) );
+ assert( Gia_ObjIsLut(p, iObj) );
+ tArrival = -TIM_ETERNITY;
+ if ( pLutLib == NULL )
+ {
+ Gia_LutForEachFanin( p, iObj, iFanin, k )
+ if ( tArrival < Gia_ObjTimeArrival(p, iFanin) + 1.0 )
+ tArrival = Gia_ObjTimeArrival(p, iFanin) + 1.0;
+ }
+ else if ( !pLutLib->fVarPinDelays )
+ {
+ pDelays = pLutLib->pLutDelays[Gia_ObjLutSize(p, iObj)];
+ Gia_LutForEachFanin( p, iObj, iFanin, k )
+ if ( tArrival < Gia_ObjTimeArrival(p, iFanin) + pDelays[0] )
+ tArrival = Gia_ObjTimeArrival(p, iFanin) + pDelays[0];
+ }
+ else
+ {
+ pDelays = pLutLib->pLutDelays[Gia_ObjLutSize(p, iObj)];
+ if ( fUseSorting )
+ {
+ Gia_LutDelayTraceSortPins( p, iObj, pPinPerm, pPinDelays );
+ Gia_LutForEachFanin( p, iObj, iFanin, k )
+ if ( tArrival < Gia_ObjTimeArrival( p, Gia_ObjLutFanin(p,iObj,pPinPerm[k])) + pDelays[k] )
+ tArrival = Gia_ObjTimeArrival( p, Gia_ObjLutFanin(p,iObj,pPinPerm[k])) + pDelays[k];
+ }
+ else
+ {
+ Gia_LutForEachFanin( p, iObj, iFanin, k )
+ if ( tArrival < Gia_ObjTimeArrival(p, iFanin) + pDelays[k] )
+ tArrival = Gia_ObjTimeArrival(p, iFanin) + pDelays[k];
+ }
+ }
+ if ( Gia_ObjLutSize(p, iObj) == 0 )
+ tArrival = 0.0;
+ return tArrival;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Propagates the required times through the given node.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+float Gia_ObjPropagateRequired( Gia_Man_t * p, int iObj, int fUseSorting )
+{
+ If_Lib_t * pLutLib = (If_Lib_t *)p->pLutLib;
+ int k, iFanin, pPinPerm[32];
+ float pPinDelays[32];
+ float tRequired = 0.0; // Suppress "might be used uninitialized"
+ float * pDelays;
+ assert( Gia_ObjIsLut(p, iObj) );
+ if ( pLutLib == NULL )
+ {
+ tRequired = Gia_ObjTimeRequired( p, iObj) - (float)1.0;
+ Gia_LutForEachFanin( p, iObj, iFanin, k )
+ if ( Gia_ObjTimeRequired(p, iFanin) > tRequired )
+ Gia_ObjSetTimeRequired( p, iFanin, tRequired );
+ }
+ else if ( !pLutLib->fVarPinDelays )
+ {
+ pDelays = pLutLib->pLutDelays[Gia_ObjLutSize(p, iObj)];
+ tRequired = Gia_ObjTimeRequired(p, iObj) - pDelays[0];
+ Gia_LutForEachFanin( p, iObj, iFanin, k )
+ if ( Gia_ObjTimeRequired(p, iFanin) > tRequired )
+ Gia_ObjSetTimeRequired( p, iFanin, tRequired );
+ }
+ else
+ {
+ pDelays = pLutLib->pLutDelays[Gia_ObjLutSize(p, iObj)];
+ if ( fUseSorting )
+ {
+ Gia_LutDelayTraceSortPins( p, iObj, pPinPerm, pPinDelays );
+ Gia_LutForEachFanin( p, iObj, iFanin, k )
+ {
+ tRequired = Gia_ObjTimeRequired( p, iObj) - pDelays[k];
+ if ( Gia_ObjTimeRequired( p, Gia_ObjLutFanin(p, iObj,pPinPerm[k])) > tRequired )
+ Gia_ObjSetTimeRequired( p, Gia_ObjLutFanin(p, iObj,pPinPerm[k]), tRequired );
+ }
+ }
+ else
+ {
+ Gia_LutForEachFanin( p, iObj, iFanin, k )
+ {
+ tRequired = Gia_ObjTimeRequired(p, iObj) - pDelays[k];
+ if ( Gia_ObjTimeRequired(p, iFanin) > tRequired )
+ Gia_ObjSetTimeRequired( p, iFanin, tRequired );
+ }
+ }
+ }
+ return tRequired;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes the delay trace of the given network.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+float Gia_ManDelayTraceLut( Gia_Man_t * p )
+{
+ int fUseSorting = 1;
+ If_Lib_t * pLutLib = (If_Lib_t *)p->pLutLib;
+ Vec_Int_t * vObjs;
+ Gia_Obj_t * pObj;
+ float tArrival, tArrivalCur, tRequired, tSlack;
+ int i, iObj;
+
+ // get the library
+ if ( pLutLib && pLutLib->LutMax < Gia_ManLutSizeMax(p) )
+ {
+ printf( "The max LUT size (%d) is less than the max fanin count (%d).\n",
+ pLutLib->LutMax, Gia_ManLutSizeMax(p) );
+ return -TIM_ETERNITY;
+ }
+
+ // initialize the arrival times
+ Gia_ManTimeStart( p );
+
+ // propagate arrival times
+ if ( p->pManTime )
+ Tim_ManIncrementTravId( (Tim_Man_t *)p->pManTime );
+ Gia_ManForEachObj( p, pObj, i )
+ {
+ if ( !Gia_ObjIsCi(pObj) && !Gia_ObjIsCo(pObj) && !Gia_ObjIsLut(p, i) )
+ continue;
+ tArrival = Gia_ObjComputeArrival( p, i, fUseSorting );
+ if ( Gia_ObjIsCi(pObj) && p->pManTime )
+ {
+ tArrival = Tim_ManGetCiArrival( (Tim_Man_t *)p->pManTime, Gia_ObjCioId(pObj) );
+//printf( "%.3f ", tArrival );
+ }
+ if ( Gia_ObjIsCo(pObj) && p->pManTime )
+ Tim_ManSetCoArrival( (Tim_Man_t *)p->pManTime, Gia_ObjCioId(pObj), tArrival );
+ Gia_ObjSetTimeArrival( p, i, tArrival );
+ }
+
+ // get the latest arrival times
+ tArrival = -TIM_ETERNITY;
+ Gia_ManForEachCo( p, pObj, i )
+ {
+ tArrivalCur = Gia_ObjTimeArrivalObj( p, Gia_ObjFanin0(pObj) );
+ Gia_ObjSetTimeArrival( p, Gia_ObjId(p,pObj), tArrivalCur );
+ if ( tArrival < tArrivalCur )
+ tArrival = tArrivalCur;
+ }
+
+ // initialize the required times
+ if ( p->pManTime )
+ {
+ Tim_ManIncrementTravId( (Tim_Man_t *)p->pManTime );
+ Tim_ManSetCoRequiredAll( (Tim_Man_t *)p->pManTime, tArrival );
+ }
+ else
+ {
+ Gia_ManForEachCo( p, pObj, i )
+ Gia_ObjSetTimeRequiredObj( p, pObj, tArrival );
+ }
+
+ // propagate the required times
+ vObjs = Gia_ManOrderReverse( p );
+ Vec_IntForEachEntry( vObjs, iObj, i )
+ {
+ if ( i == 1137 )
+ {
+ int s = 0;
+ }
+ pObj = Gia_ManObj(p, iObj);
+//printf( "%d ", Gia_ObjLevel(p, pObj) );
+ if ( Gia_ObjIsLut(p, iObj) )
+ {
+ Gia_ObjPropagateRequired( p, iObj, fUseSorting );
+ }
+ else if ( Gia_ObjIsCi(pObj) )
+ {
+ if ( p->pManTime )
+ Tim_ManSetCiRequired( (Tim_Man_t *)p->pManTime, Gia_ObjCioId(pObj), Gia_ObjTimeRequired(p, iObj) );
+ }
+ else if ( Gia_ObjIsCo(pObj) )
+ {
+ if ( p->pManTime )
+ {
+ tRequired = Tim_ManGetCoRequired( (Tim_Man_t *)p->pManTime, Gia_ObjCioId(pObj) );
+ Gia_ObjSetTimeRequired( p, iObj, tRequired );
+ }
+ if ( Gia_ObjTimeRequired(p, Gia_ObjFaninId0p(p, pObj)) > Gia_ObjTimeRequired(p, iObj) )
+ Gia_ObjSetTimeRequired(p, Gia_ObjFaninId0p(p, pObj), Gia_ObjTimeRequired(p, iObj) );
+ }
+
+ // set slack for this object
+ tSlack = Gia_ObjTimeRequired(p, iObj) - Gia_ObjTimeArrival(p, iObj);
+ assert( tSlack + 0.01 > 0.0 );
+ Gia_ObjSetTimeSlack( p, iObj, tSlack < 0.0 ? 0.0 : tSlack );
+ }
+ Vec_IntFree( vObjs );
+ return tArrival;
+}
+
+#if 0
+
+/**Function*************************************************************
+
+ Synopsis [Computes the required times for the given node.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+float Gia_ObjComputeRequired( Gia_Man_t * p, int iObj, int fUseSorting )
+{
+ If_Lib_t * pLutLib = p->pLutLib;
+ int pPinPerm[32];
+ float pPinDelays[32];
+ Gia_Obj_t * pFanout;
+ float tRequired, tDelay, * pDelays;
+ int k, iFanin;
+ if ( Gia_ObjIsCo(iObj) )
+ return Gia_ObjTimeRequired( p, iObj);
+ tRequired = TIM_ETERNITY;
+ if ( pLutLib == NULL )
+ {
+ Gia_ObjForEachFanout( iObj, pFanout, k )
+ {
+ tDelay = Gia_ObjIsCo(pFanout)? 0.0 : 1.0;
+ if ( tRequired > Gia_ObjTimeRequired( p, pFanout) - tDelay )
+ tRequired = Gia_ObjTimeRequired( p, pFanout) - tDelay;
+ }
+ }
+ else if ( !pLutLib->fVarPinDelays )
+ {
+ Gia_ObjForEachFanout( iObj, pFanout, k )
+ {
+ pDelays = pLutLib->pLutDelays[Gia_ObjLutSize(p, pFanout)];
+ tDelay = Gia_ObjIsCo(pFanout)? 0.0 : pDelays[0];
+ if ( tRequired > Gia_ObjTimeRequired( p, pFanout) - tDelay )
+ tRequired = Gia_ObjTimeRequired( p, pFanout) - tDelay;
+ }
+ }
+ else
+ {
+ if ( fUseSorting )
+ {
+ Gia_ObjForEachFanout( iObj, pFanout, k )
+ {
+ pDelays = pLutLib->pLutDelays[Gia_ObjLutSize(p, pFanout)];
+ Gia_LutDelayTraceSortPins( p, pFanout, pPinPerm, pPinDelays );
+ iFanin = Gia_LutWhereIsPin( p, pFanout, iObj, pPinPerm );
+ assert( Gia_ObjLutFanin( p, pFanout, pPinPerm[iFanin]) == iObj );
+ tDelay = Gia_ObjIsCo(pFanout)? 0.0 : pDelays[iFanin];
+ if ( tRequired > Gia_ObjTimeRequired( p, pFanout) - tDelay )
+ tRequired = Gia_ObjTimeRequired( p, pFanout) - tDelay;
+ }
+ }
+ else
+ {
+ Gia_ObjForEachFanout( iObj, pFanout, k )
+ {
+ pDelays = pLutLib->pLutDelays[Gia_ObjLutSize(p, pFanout)];
+ iFanin = Gia_ObjFindFanin( p, pFanout, iObj );
+ assert( Gia_ObjLutFanin(p, pFanout, iFanin) == iObj );
+ tDelay = Gia_ObjIsCo(pFanout)? 0.0 : pDelays[iFanin];
+ if ( tRequired > Gia_ObjTimeRequired( p, pFanout) - tDelay )
+ tRequired = Gia_ObjTimeRequired( p, pFanout) - tDelay;
+ }
+ }
+ }
+ return tRequired;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes the arrival times for the given node.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_LutVerifyTiming( Gia_Man_t * p )
+{
+ int iObj;
+ float tArrival, tRequired;
+ int i;
+ Gia_LutForEachObj( p, iObj, i )
+ {
+ if ( Gia_ObjIsCi(iObj) && Gia_ObjFanoutNum(iObj) == 0 )
+ continue;
+ tArrival = Gia_ObjComputeArrival( p, iObj, 1 );
+ tRequired = Gia_ObjComputeRequired( p, iObj, 1 );
+ if ( !Gia_LutTimeEqual( tArrival, Gia_ObjTimeArrival( p, iObj), (float)0.01 ) )
+ printf( "Gia_LutVerifyTiming(): Object %d has different arrival time (%.2f) from computed (%.2f).\n",
+ iObj->Id, Gia_ObjTimeArrival( p, iObj), tArrival );
+ if ( !Gia_LutTimeEqual( tRequired, Gia_ObjTimeRequired( p, iObj), (float)0.01 ) )
+ printf( "Gia_LutVerifyTiming(): Object %d has different required time (%.2f) from computed (%.2f).\n",
+ iObj->Id, Gia_ObjTimeRequired( p, iObj), tRequired );
+ }
+ return 1;
+}
+
+#endif
+
+/**Function*************************************************************
+
+ Synopsis [Prints the delay trace for the given network.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+float Gia_ManDelayTraceLutPrint( Gia_Man_t * p, int fVerbose )
+{
+ If_Lib_t * pLutLib = (If_Lib_t *)p->pLutLib;
+ int i, Nodes, * pCounters;
+ float tArrival, tDelta, nSteps, Num;
+ // get the library
+ if ( pLutLib && pLutLib->LutMax < Gia_ManLutSizeMax(p) )
+ {
+ printf( "The max LUT size (%d) is less than the max fanin count (%d).\n",
+ pLutLib->LutMax, Gia_ManLutSizeMax(p) );
+ return -ABC_INFINITY;
+ }
+ // decide how many steps
+ nSteps = pLutLib ? 20 : Gia_ManLutLevel(p);
+ pCounters = ABC_ALLOC( int, nSteps + 1 );
+ memset( pCounters, 0, sizeof(int)*(nSteps + 1) );
+ // perform delay trace
+ tArrival = Gia_ManDelayTraceLut( p );
+ tDelta = tArrival / nSteps;
+ // count how many nodes have slack in the corresponding intervals
+ Gia_ManForEachLut( p, i )
+ {
+ if ( Gia_ObjLutSize(p, i) == 0 )
+ continue;
+ Num = Gia_ObjTimeSlack(p, i) / tDelta;
+ if ( Num > nSteps )
+ continue;
+ assert( Num >=0 && Num <= nSteps );
+ pCounters[(int)Num]++;
+ }
+ // print the results
+ if ( fVerbose )
+ {
+ printf( "Max delay = %6.2f. Delay trace using %s model:\n", tArrival, pLutLib? "LUT library" : "unit-delay" );
+ Nodes = 0;
+ for ( i = 0; i < nSteps; i++ )
+ {
+ Nodes += pCounters[i];
+ printf( "%3d %s : %5d (%6.2f %%)\n", pLutLib? 5*(i+1) : i+1,
+ pLutLib? "%":"lev", Nodes, 100.0*Nodes/Gia_ManLutNum(p) );
+ }
+ }
+ ABC_FREE( pCounters );
+ Gia_ManTimeStop( p );
+ return tArrival;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Determines timing-critical edges of the node.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+unsigned Gia_LutDelayTraceTCEdges( Gia_Man_t * p, int iObj, float tDelta )
+{
+ If_Lib_t * pLutLib = (If_Lib_t *)p->pLutLib;
+ int pPinPerm[32];
+ float pPinDelays[32];
+ float tRequired, * pDelays;
+ unsigned uResult = 0;
+ int k, iFanin;
+ tRequired = Gia_ObjTimeRequired( p, iObj );
+ if ( pLutLib == NULL )
+ {
+ Gia_LutForEachFanin( p, iObj, iFanin, k )
+ if ( tRequired < Gia_ObjTimeArrival(p, iFanin) + 1.0 + tDelta )
+ uResult |= (1 << k);
+ }
+ else if ( !pLutLib->fVarPinDelays )
+ {
+ pDelays = pLutLib->pLutDelays[Gia_ObjLutSize(p, iObj)];
+ Gia_LutForEachFanin( p, iObj, iFanin, k )
+ if ( tRequired < Gia_ObjTimeArrival(p, iFanin) + pDelays[0] + tDelta )
+ uResult |= (1 << k);
+ }
+ else
+ {
+ pDelays = pLutLib->pLutDelays[Gia_ObjLutSize(p, iObj)];
+ Gia_LutDelayTraceSortPins( p, iObj, pPinPerm, pPinDelays );
+ Gia_LutForEachFanin( p, iObj, iFanin, k )
+ if ( tRequired < Gia_ObjTimeArrival( p, Gia_ObjLutFanin(p, iObj,pPinPerm[k])) + pDelays[k] + tDelta )
+ uResult |= (1 << pPinPerm[k]);
+ }
+ return uResult;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Adds strashed nodes for one node.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManSpeedupObj_rec( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vNodes )
+{
+ if ( Gia_ObjIsTravIdCurrent(p, pObj) )
+ return 1;
+ Gia_ObjSetTravIdCurrent( p, pObj );
+ if ( Gia_ObjIsCi(pObj) )
+ return 0;
+ assert( Gia_ObjIsAnd(pObj) );
+ if ( !Gia_ManSpeedupObj_rec( p, Gia_ObjFanin0(pObj), vNodes ) )
+ return 0;
+ if ( !Gia_ManSpeedupObj_rec( p, Gia_ObjFanin1(pObj), vNodes ) )
+ return 0;
+ Vec_IntPush( vNodes, Gia_ObjId(p, pObj) );
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Adds strashed nodes for one node.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManSpeedupObj( Gia_Man_t * pNew, Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vLeaves, Vec_Int_t * vTimes )
+{
+ Vec_Int_t * vNodes;
+ Gia_Obj_t * pTemp = NULL;
+ int pCofs[32], nCofs, nSkip, i, k, iResult, iObj;
+ // mark the leaves
+ Gia_ManIncrementTravId( p );
+ Gia_ObjSetTravIdCurrent( p, Gia_ManConst0(p) );
+ Gia_ManForEachObjVec( vLeaves, p, pTemp, i )
+ Gia_ObjSetTravIdCurrent( p, pTemp );
+ // collect the AIG nodes
+ vNodes = Vec_IntAlloc( 100 );
+ if ( !Gia_ManSpeedupObj_rec( p, pObj, vNodes ) )
+ {
+ printf( "Bad node!!!\n" );
+ Vec_IntFree( vNodes );
+ return;
+ }
+ // derive cofactors
+ nCofs = (1 << Vec_IntSize(vTimes));
+ for ( i = 0; i < nCofs; i++ )
+ {
+ Gia_ManForEachObjVec( vLeaves, p, pTemp, k )
+ pTemp->Value = Gia_Var2Lit( Gia_ObjId(p, pTemp), 0 );
+ Gia_ManForEachObjVec( vTimes, p, pTemp, k )
+ pTemp->Value = ((i & (1<<k)) != 0);
+ Gia_ManForEachObjVec( vNodes, p, pTemp, k )
+ pTemp->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pTemp), Gia_ObjFanin1Copy(pTemp) );
+ pCofs[i] = pTemp->Value;
+ }
+ Vec_IntFree( vNodes );
+ // collect the resulting tree
+ Gia_ManForEachObjVec( vTimes, p, pTemp, k )
+ for ( nSkip = (1<<k), i = 0; i < nCofs; i += 2*nSkip )
+ pCofs[i] = Gia_ManHashMux( pNew, Gia_ObjToLit(p,pTemp), pCofs[i+nSkip], pCofs[i] );
+ // create choice node (pObj is repr and ppCofs[0] is new)
+ iObj = Gia_ObjId( p, pObj );
+ iResult = Gia_Lit2Var( pCofs[0] );
+ if ( iResult <= iObj )
+ return;
+ Gia_ObjSetRepr( pNew, iResult, iObj );
+ Gia_ObjSetNext( pNew, iResult, Gia_ObjNext(pNew, iObj) );
+ Gia_ObjSetNext( pNew, iObj, iResult );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Adds choices to speed up the network by the given percentage.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManSpeedup( Gia_Man_t * p, int Percentage, int Degree, int fVerbose, int fVeryVerbose )
+{
+ Gia_Man_t * pNew, * pTemp;
+ Vec_Int_t * vTimeCries, * vTimeFanins;
+ int iObj, iFanin, iFanin2, nNodesNew;
+ float tDelta, tArrival;
+ int i, k, k2, Counter, CounterRes, nTimeCris;
+ int fUseLutLib = (p->pLutLib != NULL);
+ void * pTempTim = NULL;
+ unsigned * puTCEdges;
+ assert( p->pMapping != NULL );
+ if ( !fUseLutLib && p->pManTime )
+ {
+ pTempTim = p->pManTime;
+ p->pManTime = Tim_ManDup( (Tim_Man_t *)pTempTim, 1 );
+ }
+ // perform delay trace
+ tArrival = Gia_ManDelayTraceLut( p );
+ tDelta = fUseLutLib ? tArrival*Percentage/100.0 : 1.0;
+ if ( fVerbose )
+ {
+ printf( "Max delay = %.2f. Delta = %.2f. ", tArrival, tDelta );
+ printf( "Using %s model. ", fUseLutLib ? "LUT library" : "unit-delay" );
+ if ( fUseLutLib )
+ printf( "Percentage = %d. ", Percentage );
+ printf( "\n" );
+ }
+ // mark the timing critical nodes and edges
+ puTCEdges = ABC_CALLOC( unsigned, Gia_ManObjNum(p) );
+ Gia_ManForEachLut( p, iObj )
+ {
+ if ( Gia_ObjTimeSlack(p, iObj) >= tDelta )
+ continue;
+ puTCEdges[iObj] = Gia_LutDelayTraceTCEdges( p, iObj, tDelta );
+ }
+ if ( fVerbose )
+ {
+ Counter = CounterRes = 0;
+ Gia_ManForEachLut( p, iObj )
+ {
+ Gia_LutForEachFanin( p, iObj, iFanin, k )
+ if ( !Gia_ObjIsCi(Gia_ManObj(p, iFanin)) && Gia_ObjTimeSlack(p, iFanin) < tDelta )
+ Counter++;
+ CounterRes += Gia_WordCountOnes( puTCEdges[iObj] );
+ }
+ printf( "Edges: Total = %7d. 0-slack = %7d. Critical = %7d. Ratio = %4.2f\n",
+ Gia_ManLutFaninCount(p), Counter, CounterRes, Counter? 1.0*CounterRes/Counter : 0.0 );
+ }
+
+ // start the resulting network
+ pNew = Gia_ManDup( p );
+ Gia_ManHashStart( pNew );
+ nNodesNew = 1000 + 3 * Gia_ManObjNum(pNew);
+ pNew->pNexts = ABC_CALLOC( int, nNodesNew );
+ pNew->pReprs = ABC_CALLOC( Gia_Rpr_t, nNodesNew );
+ for ( i = 0; i < nNodesNew; i++ )
+ Gia_ObjSetRepr( pNew, i, GIA_VOID );
+
+ // collect nodes to be used for resynthesis
+ Counter = CounterRes = 0;
+ vTimeCries = Vec_IntAlloc( 16 );
+ vTimeFanins = Vec_IntAlloc( 16 );
+ Gia_ManForEachLut( p, iObj )
+ {
+ if ( Gia_ObjTimeSlack(p, iObj) >= tDelta )
+ continue;
+ // count the number of non-PI timing-critical nodes
+ nTimeCris = 0;
+ Gia_LutForEachFanin( p, iObj, iFanin, k )
+ if ( !Gia_ObjIsCi(Gia_ManObj(p, iFanin)) && (puTCEdges[iObj] & (1<<k)) )
+ nTimeCris++;
+ if ( !fVeryVerbose && nTimeCris == 0 )
+ continue;
+ Counter++;
+ // count the total number of timing critical second-generation nodes
+ Vec_IntClear( vTimeCries );
+ if ( nTimeCris )
+ {
+ Gia_LutForEachFanin( p, iObj, iFanin, k )
+ if ( !Gia_ObjIsCi(Gia_ManObj(p, iFanin)) && (puTCEdges[iObj] & (1<<k)) )
+ Gia_LutForEachFanin( p, iFanin, iFanin2, k2 )
+ if ( puTCEdges[iFanin] & (1<<k2) )
+ Vec_IntPushUnique( vTimeCries, iFanin2 );
+ }
+// if ( !fVeryVerbose && (Vec_IntSize(vTimeCries) == 0 || Vec_IntSize(vTimeCries) > Degree) )
+ if ( (Vec_IntSize(vTimeCries) == 0 || Vec_IntSize(vTimeCries) > Degree) )
+ continue;
+ CounterRes++;
+ // collect second generation nodes
+ Vec_IntClear( vTimeFanins );
+ Gia_LutForEachFanin( p, iObj, iFanin, k )
+ {
+ if ( Gia_ObjIsCi(Gia_ManObj(p, iFanin)) )
+ Vec_IntPushUnique( vTimeFanins, iFanin );
+ else
+ Gia_LutForEachFanin( p, iFanin, iFanin2, k2 )
+ Vec_IntPushUnique( vTimeFanins, iFanin2 );
+ }
+ // print the results
+ if ( fVeryVerbose )
+ {
+ printf( "%5d Node %5d : %d %2d %2d ", Counter, iObj,
+ nTimeCris, Vec_IntSize(vTimeCries), Vec_IntSize(vTimeFanins) );
+ Gia_LutForEachFanin( p, iObj, iFanin, k )
+ printf( "%d(%.2f)%s ", iFanin, Gia_ObjTimeSlack(p, iFanin), (puTCEdges[iObj] & (1<<k))? "*":"" );
+ printf( "\n" );
+ }
+ // add the node to choices
+ if ( Vec_IntSize(vTimeCries) == 0 || Vec_IntSize(vTimeCries) > Degree )
+ continue;
+ // order the fanins in the increasing order of criticalily
+ if ( Vec_IntSize(vTimeCries) > 1 )
+ {
+ iFanin = Vec_IntEntry( vTimeCries, 0 );
+ iFanin2 = Vec_IntEntry( vTimeCries, 1 );
+ if ( Gia_ObjTimeSlack(p, iFanin) < Gia_ObjTimeSlack(p, iFanin2) )
+ {
+ Vec_IntWriteEntry( vTimeCries, 0, iFanin2 );
+ Vec_IntWriteEntry( vTimeCries, 1, iFanin );
+ }
+ }
+ if ( Vec_IntSize(vTimeCries) > 2 )
+ {
+ iFanin = Vec_IntEntry( vTimeCries, 1 );
+ iFanin2 = Vec_IntEntry( vTimeCries, 2 );
+ if ( Gia_ObjTimeSlack(p, iFanin) < Gia_ObjTimeSlack(p, iFanin2) )
+ {
+ Vec_IntWriteEntry( vTimeCries, 1, iFanin2 );
+ Vec_IntWriteEntry( vTimeCries, 2, iFanin );
+ }
+ iFanin = Vec_IntEntry( vTimeCries, 0 );
+ iFanin2 = Vec_IntEntry( vTimeCries, 1 );
+ if ( Gia_ObjTimeSlack(p, iFanin) < Gia_ObjTimeSlack(p, iFanin2) )
+ {
+ Vec_IntWriteEntry( vTimeCries, 0, iFanin2 );
+ Vec_IntWriteEntry( vTimeCries, 1, iFanin );
+ }
+ }
+ // add choice
+ Gia_ManSpeedupObj( pNew, p, Gia_ManObj(p,iObj), vTimeFanins, vTimeCries );
+ // quit if the number of nodes is large
+ if ( Gia_ManObjNum(pNew) > nNodesNew - 100 )
+ {
+ printf( "Speedup stopped adding choices because there was too many to add.\n" );
+ break;
+ }
+ }
+ Gia_ManTimeStop( p );
+ Vec_IntFree( vTimeCries );
+ Vec_IntFree( vTimeFanins );
+ ABC_FREE( puTCEdges );
+ if ( fVerbose )
+ printf( "Nodes: Total = %7d. 0-slack = %7d. Workable = %7d. Ratio = %4.2f\n",
+ Gia_ManLutNum(p), Counter, CounterRes, Counter? 1.0*CounterRes/Counter : 0.0 );
+ if ( pTempTim )
+ {
+ Tim_ManStop( (Tim_Man_t *)p->pManTime );
+ p->pManTime = pTempTim;
+ }
+ // derive AIG with choices
+//Gia_ManPrintStats( pNew, 0 );
+ pTemp = Gia_ManEquivToChoices( pNew, 1 );
+ Gia_ManStop( pNew );
+//Gia_ManPrintStats( pTemp, 0 );
+// pNew = Gia_ManDupOrderDfsChoices( pTemp );
+// Gia_ManStop( pTemp );
+//Gia_ManPrintStats( pNew, 0 );
+// return pNew;
+ return pTemp;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaSupMin.c b/src/aig/gia/giaSupMin.c
new file mode 100644
index 00000000..4abaab0f
--- /dev/null
+++ b/src/aig/gia/giaSupMin.c
@@ -0,0 +1,165 @@
+/**CFile****************************************************************
+
+ FileName [giaSupMin.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Scalable AIG package.]
+
+ Synopsis [Support minimization for AIGs with don't-cares.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: giaSupMin.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "gia.h"
+#include "kit.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+// decomposition manager
+typedef struct Gia_ManSup_t_ Gia_ManSup_t;
+struct Gia_ManSup_t_
+{
+ int nVarsMax; // the max number of variables
+ int nWordsMax; // the max number of words
+ Vec_Ptr_t * vTruthVars; // elementary truth tables
+ Vec_Ptr_t * vTruthNodes; // internal truth tables
+ // current problem
+ Gia_Man_t * pGia;
+ int iData;
+ int iCare;
+ Vec_Int_t * vConeCare;
+ Vec_Int_t * vConeData;
+ unsigned * pTruthIn;
+ unsigned * pTruthOut;
+};
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Starts Decmetry manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_ManSup_t * Gia_ManSupStart( int nVarsMax )
+{
+ Gia_ManSup_t * p;
+ assert( nVarsMax <= 20 );
+ p = ABC_CALLOC( Gia_ManSup_t, 1 );
+ p->nVarsMax = nVarsMax;
+ p->nWordsMax = Kit_TruthWordNum( p->nVarsMax );
+ p->vTruthVars = Vec_PtrAllocTruthTables( p->nVarsMax );
+ p->vTruthNodes = Vec_PtrAllocSimInfo( 512, p->nWordsMax );
+ p->vConeCare = Vec_IntAlloc( 512 );
+ p->vConeData = Vec_IntAlloc( 512 );
+ p->pTruthIn = ABC_ALLOC( unsigned, p->nWordsMax );
+ p->pTruthOut = ABC_ALLOC( unsigned, p->nWordsMax );
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Stops Decmetry manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManSupStop( Gia_ManSup_t * p )
+{
+ ABC_FREE( p->pTruthIn );
+ ABC_FREE( p->pTruthOut );
+ Vec_IntFreeP( &p->vConeCare );
+ Vec_IntFreeP( &p->vConeData );
+ Vec_PtrFreeP( &p->vTruthVars );
+ Vec_PtrFreeP( &p->vTruthNodes );
+ ABC_FREE( p );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManSupExperimentOne( Gia_ManSup_t * p, Gia_Obj_t * pData, Gia_Obj_t * pCare )
+{
+ int iData = Gia_ObjId( p->pGia, Gia_Regular(pData) );
+ int iCare = Gia_ObjId( p->pGia, Gia_Regular(pCare) );
+ if ( !Gia_ObjIsAnd(Gia_Regular(pCare)) )
+ {
+ Abc_Print( 1, "Enable is not an AND.\n" );
+ return;
+ }
+ Abc_Print( 1, "DataSupp = %6d. DataCone = %6d. CareSupp = %6d. CareCone = %6d.",
+ Gia_ManSuppSize( p->pGia, &iData, 1 ),
+ Gia_ManConeSize( p->pGia, &iData, 1 ),
+ Gia_ManSuppSize( p->pGia, &iCare, 1 ),
+ Gia_ManConeSize( p->pGia, &iCare, 1 ) );
+ Abc_Print( 1, "\n" );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManSupExperiment( Gia_Man_t * pGia, Vec_Int_t * vPairs )
+{
+ Gia_ManSup_t * p;
+ Gia_Obj_t * pData, * pCare;
+ int i;
+ p = Gia_ManSupStart( 16 );
+ p->pGia = pGia;
+ assert( Vec_IntSize(vPairs) % 2 == 0 );
+ for ( i = 0; i < Vec_IntSize(vPairs)/2; i++ )
+ {
+ Abc_Print( 1, "%6d : ", i );
+ pData = Gia_ManPo( pGia, Vec_IntEntry(vPairs, 2*i+0) );
+ pCare = Gia_ManPo( pGia, Vec_IntEntry(vPairs, 2*i+1) );
+ Gia_ManSupExperimentOne( p, Gia_ObjChild0(pData), Gia_ObjChild0(pCare) );
+ }
+ Gia_ManSupStop( p );
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaSwitch.c b/src/aig/gia/giaSwitch.c
index 5dac1fbc..bc2f0f67 100644
--- a/src/aig/gia/giaSwitch.c
+++ b/src/aig/gia/giaSwitch.c
@@ -19,6 +19,10 @@
***********************************************************************/
#include "giaAig.h"
+#include "main.h"
+
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -597,6 +601,13 @@ Vec_Int_t * Gia_ManSwiSimulate( Gia_Man_t * pAig, Gia_ParSwi_t * pPars )
{
Gia_ManForEachObj( pAig, pObj, i )
pSwitching[i] = Gia_ManSwiComputeProbOne( p->pData1[i], pPars->nWords*(pPars->nIters-pPars->nPref) );
+ Gia_ManForEachCo( pAig, pObj, i )
+ {
+ if ( Gia_ObjFaninC0(pObj) )
+ pSwitching[Gia_ObjId(pAig,pObj)] = (float)1.0-pSwitching[Gia_ObjId(pAig,Gia_ObjFanin0(pObj))];
+ else
+ pSwitching[Gia_ObjId(pAig,pObj)] = pSwitching[Gia_ObjId(pAig,Gia_ObjFanin0(pObj))];
+ }
}
else if ( pPars->fProbTrans )
{
@@ -608,6 +619,27 @@ Vec_Int_t * Gia_ManSwiSimulate( Gia_Man_t * pAig, Gia_ParSwi_t * pPars )
Gia_ManForEachObj( pAig, pObj, i )
pSwitching[i] = Gia_ManSwiComputeSwitching( p->pData1[i], pPars->nWords*(pPars->nIters-pPars->nPref) );
}
+/*
+ printf( "PI: " );
+ Gia_ManForEachPi( pAig, pObj, i )
+ printf( "%d=%d (%f) ", i, p->pData1[Gia_ObjId(pAig,pObj)], pSwitching[Gia_ObjId(pAig,pObj)] );
+ printf( "\n" );
+
+ printf( "LO: " );
+ Gia_ManForEachRo( pAig, pObj, i )
+ printf( "%d=%d (%f) ", i, p->pData1[Gia_ObjId(pAig,pObj)], pSwitching[Gia_ObjId(pAig,pObj)] );
+ printf( "\n" );
+
+ printf( "PO: " );
+ Gia_ManForEachPo( pAig, pObj, i )
+ printf( "%d=%d (%f) ", i, p->pData1[Gia_ObjId(pAig,pObj)], pSwitching[Gia_ObjId(pAig,pObj)] );
+ printf( "\n" );
+
+ printf( "LI: " );
+ Gia_ManForEachRi( pAig, pObj, i )
+ printf( "%d=%d (%f) ", i, p->pData1[Gia_ObjId(pAig,pObj)], pSwitching[Gia_ObjId(pAig,pObj)] );
+ printf( "\n" );
+*/
Gia_ManSwiDelete( p );
return vSwitching;
@@ -625,7 +657,6 @@ Vec_Int_t * Gia_ManSwiSimulate( Gia_Man_t * pAig, Gia_ParSwi_t * pPars )
***********************************************************************/
Vec_Int_t * Saig_ManComputeSwitchProbs( Aig_Man_t * pAig, int nFrames, int nPref, int fProbOne )
{
- extern char * Abc_FrameReadFlag( char * pFlag );
Gia_ParSwi_t Pars, * pPars = &Pars;
Vec_Int_t * vSwitching, * vResult;
Gia_Man_t * p;
@@ -658,7 +689,11 @@ Vec_Int_t * Saig_ManComputeSwitchProbs( Aig_Man_t * pAig, int nFrames, int nPref
// transfer the computed result to the original AIG
vResult = Vec_IntStart( Aig_ManObjNumMax(pAig) );
Aig_ManForEachObj( pAig, pObj, i )
+ {
+// if ( Aig_ObjIsPo(pObj) )
+// printf( "%d=%f\n", i, Aig_Int2Float( Vec_IntEntry(vSwitching, Gia_Lit2Var(pObj->iData)) ) );
Vec_IntWriteEntry( vResult, i, Vec_IntEntry(vSwitching, Gia_Lit2Var(pObj->iData)) );
+ }
// delete intermediate results
Vec_IntFree( vSwitching );
Gia_ManStop( p );
@@ -757,3 +792,5 @@ float Gia_ManComputeSwitching( Gia_Man_t * p, int nFrames, int nPref, int fProbO
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaTsim.c b/src/aig/gia/giaTsim.c
index a4cdf88a..e829ff5b 100644
--- a/src/aig/gia/giaTsim.c
+++ b/src/aig/gia/giaTsim.c
@@ -20,6 +20,9 @@
#include "gia.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -111,7 +114,7 @@ void Gia_ManTerStatesFree( Vec_Ptr_t * vStates )
{
unsigned * pTemp;
int i;
- Vec_PtrForEachEntry( vStates, pTemp, i )
+ Vec_PtrForEachEntry( unsigned *, vStates, pTemp, i )
ABC_FREE( pTemp );
Vec_PtrFree( vStates );
}
@@ -505,12 +508,12 @@ void Gia_ManTerStatePrint( unsigned * pState, int nRegs, int iNum )
***********************************************************************/
void Gia_ManTerAnalyze2( Vec_Ptr_t * vStates, int nRegs )
{
- unsigned * pTemp, * pStates = Vec_PtrPop( vStates );
+ unsigned * pTemp, * pStates = (unsigned *)Vec_PtrPop( vStates );
int i, w, nZeros, nConsts, nStateWords;
// detect constant zero registers
nStateWords = Gia_BitWordNum( 2*nRegs );
memset( pStates, 0, sizeof(int) * nStateWords );
- Vec_PtrForEachEntry( vStates, pTemp, i )
+ Vec_PtrForEachEntry( unsigned *, vStates, pTemp, i )
for ( w = 0; w < nStateWords; w++ )
pStates[w] |= pTemp[w];
// count the number of zeros
@@ -521,7 +524,7 @@ void Gia_ManTerAnalyze2( Vec_Ptr_t * vStates, int nRegs )
printf( "Found %d constant registers.\n", nZeros );
// detect non-ternary registers
memset( pStates, 0, sizeof(int) * nStateWords );
- Vec_PtrForEachEntry( vStates, pTemp, i )
+ Vec_PtrForEachEntry( unsigned *, vStates, pTemp, i )
for ( w = 0; w < nStateWords; w++ )
pStates[w] |= (~(pTemp[w] ^ (pTemp[w] >> 1)) & 0x55555555);
// count the nonternary registers
@@ -585,7 +588,7 @@ Vec_Ptr_t * Gia_ManTerTranspose( Gia_ManTer_t * p )
continue;
pFlop = Gia_ManTerStateAlloc( nFlopWords );
Vec_PtrPush( vFlops, pFlop );
- Vec_PtrForEachEntry( p->vStates, pState, k )
+ Vec_PtrForEachEntry( unsigned *, p->vStates, pState, k )
Gia_ManTerSimInfoSet( pFlop, k, Gia_ManTerSimInfoGet(pState, i) );
//Gia_ManTerStatePrint( pFlop, Vec_PtrSize(p->vStates), i );
}
@@ -607,8 +610,8 @@ int Gia_ManFindEqualFlop( Vec_Ptr_t * vFlops, int iFlop, int nFlopWords )
{
unsigned * pFlop, * pTemp;
int i;
- pFlop = Vec_PtrEntry( vFlops, iFlop );
- Vec_PtrForEachEntryStop( vFlops, pTemp, i, iFlop )
+ pFlop = (unsigned *)Vec_PtrEntry( vFlops, iFlop );
+ Vec_PtrForEachEntryStop( unsigned *, vFlops, pTemp, i, iFlop )
if ( !memcmp( pTemp, pFlop, sizeof(unsigned) * nFlopWords ) )
return i;
return -1;
@@ -633,7 +636,7 @@ int * Gia_ManTerCreateMap( Gia_ManTer_t * p, int fVerbose )
int i, iRepr, nFlopWords, Counter0 = 0, CounterE = 0;
nFlopWords = Gia_BitWordNum( 2*Vec_PtrSize(p->vStates) );
p->vFlops = Gia_ManTerTranspose( p );
- pCi2Lit = ABC_FALLOC( unsigned, Gia_ManCiNum(p->pAig) );
+ pCi2Lit = ABC_FALLOC( int, Gia_ManCiNum(p->pAig) );
vMapKtoI = Vec_IntAlloc( 100 );
for ( i = 0; i < Gia_ManRegNum(p->pAig); i++ )
if ( p->pCount0[i] == Vec_PtrSize(p->vStates) )
@@ -678,8 +681,7 @@ Gia_ManTer_t * Gia_ManTerSimulate( Gia_Man_t * pAig, int fVerbose )
if ( 0 )
{
printf( "Obj = %8d (%8d). F = %6d. ",
- pAig->nObjs, Gia_ManCiNum(pAig) + Gia_ManAndNum(pAig), p->pAig->nFront,
- 4.0*Gia_BitWordNum(2 * p->pAig->nFront)/(1<<20) );
+ pAig->nObjs, Gia_ManCiNum(pAig) + Gia_ManAndNum(pAig), p->pAig->nFront );
printf( "AIG = %7.2f Mb. F-mem = %7.2f Mb. Other = %7.2f Mb. ",
12.0*Gia_ManObjNum(p->pAig)/(1<<20),
4.0*Gia_BitWordNum(2 * p->pAig->nFront)/(1<<20),
@@ -754,3 +756,5 @@ Gia_Man_t * Gia_ManReduceConst( Gia_Man_t * pAig, int fVerbose )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/giaUtil.c b/src/aig/gia/giaUtil.c
index 938c6363..002e766d 100644
--- a/src/aig/gia/giaUtil.c
+++ b/src/aig/gia/giaUtil.c
@@ -20,6 +20,9 @@
#include "gia.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -72,7 +75,7 @@ void Gia_ManRandomInfo( Vec_Ptr_t * vInfo, int iInputStart, int iWordStart, int
{
unsigned * pInfo;
int i, w;
- Vec_PtrForEachEntryStart( vInfo, pInfo, i, iInputStart )
+ Vec_PtrForEachEntryStart( unsigned *, vInfo, pInfo, i, iInputStart )
for ( w = iWordStart; w < iWordStop; w++ )
pInfo[w] = Gia_ManRandom(0);
}
@@ -116,6 +119,30 @@ unsigned int Gia_PrimeCudd( unsigned int p )
/**Function*************************************************************
+ Synopsis [Returns the time stamp.]
+
+ Description [The file should be closed.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+char * Gia_TimeStamp()
+{
+ static char Buffer[100];
+ char * TimeStamp;
+ time_t ltime;
+ // get the current time
+ time( &ltime );
+ TimeStamp = asctime( localtime( &ltime ) );
+ TimeStamp[ strlen(TimeStamp) - 1 ] = 0;
+ strcpy( Buffer, TimeStamp );
+ return Buffer;
+}
+
+/**Function*************************************************************
+
Synopsis [Returns the composite name of the file.]
Description []
@@ -140,6 +167,34 @@ char * Gia_FileNameGenericAppend( char * pBase, char * pSuffix )
/**Function*************************************************************
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManIncrementTravId( Gia_Man_t * p )
+{
+ if ( p->pTravIds == NULL )
+ {
+ p->nTravIdsAlloc = Gia_ManObjNum(p) + 100;
+ p->pTravIds = ABC_CALLOC( int, p->nTravIdsAlloc );
+ p->nTravIds = 0;
+ }
+ while ( p->nTravIdsAlloc < Gia_ManObjNum(p) )
+ {
+ p->nTravIdsAlloc *= 2;
+ p->pTravIds = ABC_REALLOC( int, p->pTravIds, p->nTravIdsAlloc );
+ memset( p->pTravIds + p->nTravIdsAlloc/2, 0, sizeof(int) * p->nTravIdsAlloc/2 );
+ }
+ p->nTravIds++;
+}
+
+/**Function*************************************************************
+
Synopsis [Sets phases of the internal nodes.]
Description []
@@ -290,6 +345,28 @@ void Gia_ManFillValue( Gia_Man_t * p )
/**Function*************************************************************
+ Synopsis [Sets the phase of one object.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ObjSetPhase( Gia_Obj_t * pObj )
+{
+ if ( Gia_ObjIsAnd(pObj) )
+ pObj->fPhase = (Gia_ObjPhase(Gia_ObjFanin0(pObj)) ^ Gia_ObjFaninC0(pObj)) &
+ (Gia_ObjPhase(Gia_ObjFanin1(pObj)) ^ Gia_ObjFaninC1(pObj));
+ else if ( Gia_ObjIsCo(pObj) )
+ pObj->fPhase = (Gia_ObjPhase(Gia_ObjFanin0(pObj)) ^ Gia_ObjFaninC0(pObj));
+ else
+ pObj->fPhase = 0;
+}
+
+/**Function*************************************************************
+
Synopsis [Sets phases of the internal nodes.]
Description []
@@ -304,15 +381,29 @@ void Gia_ManSetPhase( Gia_Man_t * p )
Gia_Obj_t * pObj;
int i;
Gia_ManForEachObj( p, pObj, i )
- {
- if ( Gia_ObjIsAnd(pObj) )
- pObj->fPhase = (Gia_ObjPhase(Gia_ObjFanin0(pObj)) ^ Gia_ObjFaninC0(pObj)) &
- (Gia_ObjPhase(Gia_ObjFanin1(pObj)) ^ Gia_ObjFaninC1(pObj));
- else if ( Gia_ObjIsCo(pObj) )
- pObj->fPhase = (Gia_ObjPhase(Gia_ObjFanin0(pObj)) ^ Gia_ObjFaninC0(pObj));
- else
- pObj->fPhase = 0;
- }
+ Gia_ObjSetPhase( pObj );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Sets phases of the internal nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManSetPhase1( Gia_Man_t * p )
+{
+ Gia_Obj_t * pObj;
+ int i;
+ Gia_ManForEachCi( p, pObj, i )
+ pObj->fPhase = 1;
+ Gia_ManForEachObj( p, pObj, i )
+ if ( !Gia_ObjIsCi(pObj) )
+ Gia_ObjSetPhase( pObj );
}
/**Function*************************************************************
@@ -336,6 +427,41 @@ void Gia_ManCleanPhase( Gia_Man_t * p )
/**Function*************************************************************
+ Synopsis [Prepares copies for the model.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManCleanLevels( Gia_Man_t * p, int Size )
+{
+ if ( p->vLevels == NULL )
+ p->vLevels = Vec_IntAlloc( Size );
+ Vec_IntFill( p->vLevels, Size, 0 );
+}
+/**Function*************************************************************
+
+ Synopsis [Prepares copies for the model.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManCleanTruth( Gia_Man_t * p )
+{
+ if ( p->vTruths == NULL )
+ p->vTruths = Vec_IntAlloc( Gia_ManObjNum(p) );
+ Vec_IntFill( p->vTruths, Gia_ManObjNum(p), -1 );
+}
+
+/**Function*************************************************************
+
Synopsis [Assigns levels.]
Description []
@@ -349,24 +475,18 @@ int Gia_ManLevelNum( Gia_Man_t * p )
{
Gia_Obj_t * pObj;
int i;
- if ( p->pLevels )
- return p->nLevels;
+ Gia_ManCleanLevels( p, Gia_ManObjNum(p) );
p->nLevels = 0;
- p->pLevels = ABC_ALLOC( int, p->nObjsAlloc );
Gia_ManForEachObj( p, pObj, i )
if ( Gia_ObjIsAnd(pObj) )
+ Gia_ObjSetAndLevel( p, pObj );
+ else if ( Gia_ObjIsCo(pObj) )
{
- if ( p->pLevels[Gia_ObjFaninId0(pObj, i)] > p->pLevels[Gia_ObjFaninId1(pObj, i)] )
- p->pLevels[i] = 1 + p->pLevels[Gia_ObjFaninId0(pObj, i)];
- else
- p->pLevels[i] = 1 + p->pLevels[Gia_ObjFaninId1(pObj, i)];
- if ( p->nLevels < p->pLevels[i] )
- p->nLevels = p->pLevels[i];
+ Gia_ObjSetCoLevel( p, pObj );
+ p->nLevels = ABC_MAX( p->nLevels, Gia_ObjLevel(p, pObj) );
}
- else if ( Gia_ObjIsCo(pObj) )
- p->pLevels[i] = p->pLevels[Gia_ObjFaninId0(pObj, i)];
else
- p->pLevels[i] = 0;
+ Gia_ObjSetLevel( p, pObj, 0 );
return p->nLevels;
}
@@ -718,18 +838,93 @@ Gia_Obj_t * Gia_ObjRecognizeMux( Gia_Obj_t * pNode, Gia_Obj_t ** ppNodeT, Gia_Ob
SeeAlso []
***********************************************************************/
-Gia_Cex_t * Gia_ManAllocCounterExample( int nRegs, int nRealPis, int nFrames )
+Abc_Cex_t * Gia_ManAllocCounterExample( int nRegs, int nRealPis, int nFrames )
{
- Gia_Cex_t * pCex;
+ Abc_Cex_t * pCex;
int nWords = Gia_BitWordNum( nRegs + nRealPis * nFrames );
- pCex = (Gia_Cex_t *)ABC_ALLOC( char, sizeof(Gia_Cex_t) + sizeof(unsigned) * nWords );
- memset( pCex, 0, sizeof(Gia_Cex_t) + sizeof(unsigned) * nWords );
+ pCex = (Abc_Cex_t *)ABC_ALLOC( char, sizeof(Abc_Cex_t) + sizeof(unsigned) * nWords );
+ memset( pCex, 0, sizeof(Abc_Cex_t) + sizeof(unsigned) * nWords );
pCex->nRegs = nRegs;
pCex->nPis = nRealPis;
pCex->nBits = nRegs + nRealPis * nFrames;
return pCex;
}
+
+/**Function*************************************************************
+
+ Synopsis [Prints the counter-example.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ManPrintCex( Abc_Cex_t * p )
+{
+ int i, f, k;
+ for ( k = 0; k < p->nRegs; k++ )
+ printf( "%d", Gia_InfoHasBit(p->pData, k) );
+ printf( "\n" );
+ for ( f = 0; f <= p->iFrame; f++ )
+ {
+ for ( i = 0; i < p->nPis; i++ )
+ printf( "%d", Gia_InfoHasBit(p->pData, k++) );
+ printf( "\n" );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Derives the counter-example.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Abc_Cex_t * Gia_ManDeriveCexFromArray( Gia_Man_t * pAig, Vec_Int_t * vValues, int nSkip, int iFrame )
+{
+ Abc_Cex_t * pCex;
+ int i;
+ pCex = Gia_ManAllocCounterExample( Gia_ManRegNum(pAig), Gia_ManPiNum(pAig), iFrame+1 );
+ assert( Vec_IntSize(vValues) == nSkip + pCex->nBits );
+ pCex->iPo = 0;
+ pCex->iFrame = iFrame;
+ for ( i = 0; i < pCex->nBits; i++ )
+ if ( Vec_IntEntry(vValues, nSkip + i) )
+ Gia_InfoSetBit( pCex->pData, i );
+ return pCex;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Allocates a counter-example.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Abc_Cex_t * Gia_ManCreateFromComb( int nRegs, int nRealPis, int iPo, int * pModel )
+{
+ Abc_Cex_t * pCex;
+ int i;
+ pCex = Gia_ManAllocCounterExample( nRegs, nRealPis, 1 );
+ pCex->iPo = iPo;
+ pCex->iFrame = 0;
+ for ( i = pCex->nRegs; i < pCex->nBits; i++ )
+ if ( pModel[i-pCex->nRegs] )
+ Gia_InfoSetBit( pCex->pData, i );
+ return pCex;
+}
+
/**Function*************************************************************
Synopsis [Resimulates the counter-example.]
@@ -741,10 +936,11 @@ Gia_Cex_t * Gia_ManAllocCounterExample( int nRegs, int nRealPis, int nFrames )
SeeAlso []
***********************************************************************/
-int Gia_ManVerifyCounterExample( Gia_Man_t * pAig, Gia_Cex_t * p, int fDualOut )
+int Gia_ManVerifyCounterExample( Gia_Man_t * pAig, Abc_Cex_t * p, int fDualOut )
{
Gia_Obj_t * pObj, * pObjRi, * pObjRo;
int RetValue, i, k, iBit = 0;
+ Gia_ManCleanMark0(pAig);
Gia_ManForEachRo( pAig, pObj, i )
pObj->fMark0 = Gia_InfoHasBit(p->pData, iBit++);
for ( i = 0; i <= p->iFrame; i++ )
@@ -770,6 +966,73 @@ int Gia_ManVerifyCounterExample( Gia_Man_t * pAig, Gia_Cex_t * p, int fDualOut )
/**Function*************************************************************
+ Synopsis [Resimulates the counter-example.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Gia_ManVerifyCounterExampleAllOuts( Gia_Man_t * pAig, Abc_Cex_t * p )
+{
+ Gia_Obj_t * pObj, * pObjRi, * pObjRo;
+ int RetValue, i, k, iBit = 0;
+ Gia_ManCleanMark0(pAig);
+ Gia_ManForEachRo( pAig, pObj, i )
+ pObj->fMark0 = Gia_InfoHasBit(p->pData, iBit++);
+ for ( i = 0; i <= p->iFrame; i++ )
+ {
+ Gia_ManForEachPi( pAig, pObj, k )
+ pObj->fMark0 = Gia_InfoHasBit(p->pData, iBit++);
+ Gia_ManForEachAnd( pAig, pObj, k )
+ pObj->fMark0 = (Gia_ObjFanin0(pObj)->fMark0 ^ Gia_ObjFaninC0(pObj)) &
+ (Gia_ObjFanin1(pObj)->fMark0 ^ Gia_ObjFaninC1(pObj));
+ Gia_ManForEachCo( pAig, pObj, k )
+ pObj->fMark0 = Gia_ObjFanin0(pObj)->fMark0 ^ Gia_ObjFaninC0(pObj);
+ Gia_ManForEachRiRo( pAig, pObjRi, pObjRo, k )
+ pObjRo->fMark0 = pObjRi->fMark0;
+ }
+ assert( iBit == p->nBits );
+ // remember the number of failed output
+ RetValue = -1;
+ Gia_ManForEachPo( pAig, pObj, i )
+ if ( Gia_ManPo(pAig, i)->fMark0 )
+ {
+ RetValue = i;
+ break;
+ }
+ Gia_ManCleanMark0(pAig);
+ return RetValue;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Make the trivial counter-example for the trivially asserted output.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Abc_Cex_t * Gia_ManDupCounterExample( Abc_Cex_t * p, int nRegsNew )
+{
+ Abc_Cex_t * pCex;
+ int i;
+ pCex = Gia_ManAllocCounterExample( nRegsNew, p->nPis, p->iFrame+1 );
+ pCex->iPo = p->iPo;
+ pCex->iFrame = p->iFrame;
+ for ( i = p->nRegs; i < p->nBits; i++ )
+ if ( Gia_InfoHasBit(p->pData, i) )
+ Gia_InfoSetBit( pCex->pData, pCex->nRegs + i - p->nRegs );
+ return pCex;
+}
+
+/**Function*************************************************************
+
Synopsis [Prints out the counter-example.]
Description []
@@ -779,7 +1042,7 @@ int Gia_ManVerifyCounterExample( Gia_Man_t * pAig, Gia_Cex_t * p, int fDualOut )
SeeAlso []
***********************************************************************/
-void Gia_ManPrintCounterExample( Gia_Cex_t * p )
+void Gia_ManPrintCounterExample( Abc_Cex_t * p )
{
int i, f, k;
printf( "Counter-example: iPo = %d iFrame = %d nRegs = %d nPis = %d nBits = %d\n",
@@ -979,7 +1242,7 @@ int Gia_ManHasChoices( Gia_Man_t * p )
SeeAlso []
***********************************************************************/
-int Gia_ManHasDandling( Gia_Man_t * p )
+int Gia_ManHasDangling( Gia_Man_t * p )
{
Gia_Obj_t * pObj;
int i, Counter = 0;
@@ -1000,8 +1263,115 @@ int Gia_ManHasDandling( Gia_Man_t * p )
return Counter;
}
+/**Function*************************************************************
+
+ Synopsis [Returns 1 if AIG has dangling nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Gia_ManGetDangling( Gia_Man_t * p )
+{
+ Vec_Int_t * vDangles;
+ Gia_Obj_t * pObj;
+ int i;
+ Gia_ManForEachObj( p, pObj, i )
+ {
+ pObj->fMark0 = 0;
+ if ( Gia_ObjIsAnd(pObj) )
+ {
+ Gia_ObjFanin0(pObj)->fMark0 = 1;
+ Gia_ObjFanin1(pObj)->fMark0 = 1;
+ }
+ else if ( Gia_ObjIsCo(pObj) )
+ Gia_ObjFanin0(pObj)->fMark0 = 1;
+ }
+ vDangles = Vec_IntAlloc( 100 );
+ Gia_ManForEachAnd( p, pObj, i )
+ if ( !pObj->fMark0 )
+ Vec_IntPush( vDangles, i );
+ Gia_ManCleanMark0( p );
+ return vDangles;
+}
+/**Function*************************************************************
+
+ Synopsis [Verbose printing of the AIG node.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Gia_ObjPrint( Gia_Man_t * p, Gia_Obj_t * pObj )
+{
+ if ( pObj == NULL )
+ {
+ printf( "Object is NULL." );
+ return;
+ }
+ if ( Gia_IsComplement(pObj) )
+ {
+ printf( "Compl " );
+ pObj = Gia_Not(pObj);
+ }
+ assert( !Gia_IsComplement(pObj) );
+ printf( "Node %4d : ", Gia_ObjId(p, pObj) );
+ if ( Gia_ObjIsConst0(pObj) )
+ printf( "constant 0" );
+ else if ( Gia_ObjIsPi(p, pObj) )
+ printf( "PI" );
+ else if ( Gia_ObjIsPo(p, pObj) )
+ printf( "PO( %4d%s )", Gia_ObjFaninId0p(p, pObj), (Gia_ObjFaninC0(pObj)? "\'" : " ") );
+ else if ( Gia_ObjIsCi(pObj) )
+ printf( "RI" );
+ else if ( Gia_ObjIsCo(pObj) )
+ printf( "RO( %4d%s )", Gia_ObjFaninId0p(p, pObj), (Gia_ObjFaninC0(pObj)? "\'" : " ") );
+// else if ( Gia_ObjIsBuf(pObj) )
+// printf( "BUF( %d%s )", Gia_ObjFaninId0p(p, pObj), (Gia_ObjFaninC0(pObj)? "\'" : " ") );
+ else
+ printf( "AND( %4d%s, %4d%s )",
+ Gia_ObjFaninId0p(p, pObj), (Gia_ObjFaninC0(pObj)? "\'" : " "),
+ Gia_ObjFaninId1p(p, pObj), (Gia_ObjFaninC1(pObj)? "\'" : " ") );
+ if ( p->pRefs )
+ printf( " (refs = %3d)", Gia_ObjRefs(p, pObj) );
+ printf( "\n" );
+/*
+ if ( p->pRefs )
+ {
+ Gia_Obj_t * pFanout;
+ int i;
+ int iFan = -1; // Suppress "might be used uninitialized"
+ printf( "\nFanouts:\n" );
+ Gia_ObjForEachFanout( p, pObj, pFanout, iFan, i )
+ {
+ printf( " " );
+ printf( "Node %4d : ", Gia_ObjId(pFanout) );
+ if ( Gia_ObjIsPo(pFanout) )
+ printf( "PO( %4d%s )", Gia_ObjFanin0(pFanout)->Id, (Gia_ObjFaninC0(pFanout)? "\'" : " ") );
+ else if ( Gia_ObjIsBuf(pFanout) )
+ printf( "BUF( %d%s )", Gia_ObjFanin0(pFanout)->Id, (Gia_ObjFaninC0(pFanout)? "\'" : " ") );
+ else
+ printf( "AND( %4d%s, %4d%s )",
+ Gia_ObjFanin0(pFanout)->Id, (Gia_ObjFaninC0(pFanout)? "\'" : " "),
+ Gia_ObjFanin1(pFanout)->Id, (Gia_ObjFaninC1(pFanout)? "\'" : " ") );
+ printf( "\n" );
+ }
+ return;
+ }
+*/
+}
+
+
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/gia/module.make b/src/aig/gia/module.make
index 0245b0f1..fc1c5c73 100644
--- a/src/aig/gia/module.make
+++ b/src/aig/gia/module.make
@@ -2,6 +2,7 @@ SRC += src/aig/gia/gia.c \
src/aig/gia/giaAbs.c \
src/aig/gia/giaAig.c \
src/aig/gia/giaAiger.c \
+ src/aig/gia/giaBidec.c \
src/aig/gia/giaCof.c \
src/aig/gia/giaCSatOld.c \
src/aig/gia/giaCSat.c \
@@ -19,13 +20,18 @@ SRC += src/aig/gia/gia.c \
src/aig/gia/giaFront.c \
src/aig/gia/giaGlitch.c \
src/aig/gia/giaHash.c \
+ src/aig/gia/giaIf.c \
src/aig/gia/giaMan.c \
- src/aig/gia/giaMap.c \
+ src/aig/gia/giaMem.c \
src/aig/gia/giaPat.c \
+ src/aig/gia/giaReparam.c \
src/aig/gia/giaRetime.c \
src/aig/gia/giaScl.c \
+ src/aig/gia/giaShrink.c \
src/aig/gia/giaSim.c \
src/aig/gia/giaSort.c \
+ src/aig/gia/giaSpeedup.c \
+ src/aig/gia/giaSupMin.c \
src/aig/gia/giaSwitch.c \
src/aig/gia/giaTsim.c \
src/aig/gia/giaUtil.c
diff --git a/src/aig/hop/cudd2.c b/src/aig/hop/cudd2.c
index 11842c39..3ad44e4c 100644
--- a/src/aig/hop/cudd2.c
+++ b/src/aig/hop/cudd2.c
@@ -21,6 +21,9 @@
#include "hop.h"
#include "st.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -353,3 +356,5 @@ void Cudd2_bddEqual( void * pCudd, void * pArg0, void * pArg1, int Result )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/hop/cudd2.h b/src/aig/hop/cudd2.h
index 27359b3f..2382b22f 100644
--- a/src/aig/hop/cudd2.h
+++ b/src/aig/hop/cudd2.h
@@ -21,6 +21,7 @@
#ifndef __CUDD2_H__
#define __CUDD2_H__
+
// HA: Added for printing messages
#ifndef MSG
#define MSG(msg) (printf("%s = \n",(msg)));
@@ -34,9 +35,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -70,9 +72,11 @@ extern void Cudd2_bddCompose( void * pCudd, void * pArg0, void * pArg1, int v, v
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
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/aig/hop/hop.h b/src/aig/hop/hop.h
index 15641250..a634f136 100644
--- a/src/aig/hop/hop.h
+++ b/src/aig/hop/hop.h
@@ -21,6 +21,7 @@
#ifndef __HOP_H__
#define __HOP_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -37,9 +38,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -102,7 +104,7 @@ struct Hop_Man_t_
// 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 ABC_FREE nodes
+ Hop_Obj_t * pListFree; // the list of free nodes
// timing statistics
int time1;
int time2;
@@ -111,14 +113,15 @@ struct Hop_Man_t_
////////////////////////////////////////////////////////////////////////
/// MACRO DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
+extern void Hop_ManAddMemory( Hop_Man_t * p );
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 int Hop_Base2Log( unsigned n ) { int r; assert( n >= 0 ); if ( n < 2 ) return n; for ( r = 0, n--; n; n >>= 1, r++ ); return r; }
-static inline int Hop_Base10Log( unsigned n ) { int r; assert( n >= 0 ); if ( n < 2 ) return n; for ( r = 0, n--; n; n /= 10, r++ ); return r; }
+static inline int Hop_Base2Log( unsigned n ) { int r; if ( n < 2 ) return n; for ( r = 0, n--; n; n >>= 1, r++ ); return r; }
+static inline int Hop_Base10Log( unsigned n ) { int r; if ( n < 2 ) return n; for ( r = 0, n--; n; n /= 10, r++ ); return r; }
static inline Hop_Obj_t * Hop_Regular( Hop_Obj_t * p ) { return (Hop_Obj_t *)((ABC_PTRUINT_T)(p) & ~01); }
static inline Hop_Obj_t * Hop_Not( Hop_Obj_t * p ) { return (Hop_Obj_t *)((ABC_PTRUINT_T)(p) ^ 01); }
@@ -224,7 +227,6 @@ static inline Hop_Obj_t * Hop_ObjCreateGhost( Hop_Man_t * p, Hop_Obj_t * p0, Ho
// 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 );
@@ -253,10 +255,10 @@ static inline void Hop_ManRecycleMemory( Hop_Man_t * p, Hop_Obj_t * pEntry )
// iterator over the primary inputs
#define Hop_ManForEachPi( p, pObj, i ) \
- Vec_PtrForEachEntry( p->vPis, pObj, i )
+ Vec_PtrForEachEntry( Hop_Obj_t *, p->vPis, pObj, i )
// iterator over the primary outputs
#define Hop_ManForEachPo( p, pObj, i ) \
- Vec_PtrForEachEntry( p->vPos, pObj, i )
+ Vec_PtrForEachEntry( Hop_Obj_t *, 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++ ) \
@@ -334,9 +336,11 @@ 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
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/aig/hop/hopBalance.c b/src/aig/hop/hopBalance.c
index 4bc15bb7..9240ffa9 100644
--- a/src/aig/hop/hopBalance.c
+++ b/src/aig/hop/hopBalance.c
@@ -20,6 +20,9 @@
#include "hop.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -96,27 +99,27 @@ Hop_Obj_t * Hop_NodeBalance_rec( Hop_Man_t * pNew, Hop_Obj_t * pObjOld, Vec_Vec_
assert( !Hop_IsComplement(pObjOld) );
// return if the result is known
if ( pObjOld->pData )
- return pObjOld->pData;
+ return (Hop_Obj_t *)pObjOld->pData;
assert( Hop_ObjIsNode(pObjOld) );
// get the implication supergate
vSuper = Hop_NodeBalanceCone( pObjOld, vStore, Level );
// check if supergate contains two nodes in the opposite polarity
if ( vSuper->nSize == 0 )
- return pObjOld->pData = Hop_ManConst0(pNew);
+ return (Hop_Obj_t *)(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 = Hop_NodeBalance_rec( pNew, Hop_Regular(vSuper->pArray[i]), vStore, Level + 1, fUpdateLevel );
- vSuper->pArray[i] = Hop_NotCond( pObjNew, Hop_IsComplement(vSuper->pArray[i]) );
+ pObjNew = Hop_NodeBalance_rec( pNew, Hop_Regular((Hop_Obj_t *)vSuper->pArray[i]), vStore, Level + 1, fUpdateLevel );
+ vSuper->pArray[i] = Hop_NotCond( pObjNew, Hop_IsComplement((Hop_Obj_t *)vSuper->pArray[i]) );
}
// build the supergate
pObjNew = Hop_NodeBalanceBuildSuper( pNew, vSuper, Hop_ObjType(pObjOld), fUpdateLevel );
// make sure the balanced node is not assigned
// assert( pObjOld->Level >= Hop_Regular(pObjNew)->Level );
assert( pObjOld->pData == NULL );
- return pObjOld->pData = pObjNew;
+ return (Hop_Obj_t *)(pObjOld->pData = pObjNew);
}
/**Function*************************************************************
@@ -185,13 +188,13 @@ Vec_Ptr_t * Hop_NodeBalanceCone( Hop_Obj_t * pObj, Vec_Vec_t * vStore, int Level
if ( Vec_VecSize( vStore ) <= Level )
Vec_VecPush( vStore, Level, 0 );
// get the temporary array of nodes
- vNodes = Vec_VecEntry( vStore, Level );
+ vNodes = (Vec_Ptr_t *)Vec_VecEntry( vStore, Level );
Vec_PtrClear( vNodes );
// collect the nodes in the implication supergate
RetValue = Hop_NodeBalanceCone_rec( pObj, pObj, vNodes );
assert( vNodes->nSize > 1 );
// unmark the visited nodes
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Hop_Obj_t *, vNodes, pObj, i )
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)
@@ -238,7 +241,7 @@ Hop_Obj_t * Hop_NodeBalanceBuildSuper( Hop_Man_t * p, Vec_Ptr_t * vSuper, Hop_Ty
int LeftBound;
assert( vSuper->nSize > 1 );
// sort the new nodes by level in the decreasing order
- Vec_PtrSort( vSuper, Hop_NodeCompareLevelsDecrease );
+ Vec_PtrSort( vSuper, (int (*)(void))Hop_NodeCompareLevelsDecrease );
// balance the nodes
while ( vSuper->nSize > 1 )
{
@@ -247,11 +250,11 @@ Hop_Obj_t * Hop_NodeBalanceBuildSuper( Hop_Man_t * p, Vec_Ptr_t * vSuper, Hop_Ty
// find the node that can be shared (if no such node, randomize choice)
Hop_NodeBalancePermute( p, vSuper, LeftBound, Type == AIG_EXOR );
// pull out the last two nodes
- pObj1 = Vec_PtrPop(vSuper);
- pObj2 = Vec_PtrPop(vSuper);
+ pObj1 = (Hop_Obj_t *)Vec_PtrPop(vSuper);
+ pObj2 = (Hop_Obj_t *)Vec_PtrPop(vSuper);
Hop_NodeBalancePushUniqueOrderByLevel( vSuper, Hop_Oper(p, pObj1, pObj2, Type) );
}
- return Vec_PtrEntry(vSuper, 0);
+ return (Hop_Obj_t *)Vec_PtrEntry(vSuper, 0);
}
/**Function*************************************************************
@@ -278,19 +281,19 @@ int Hop_NodeBalanceFindLeft( Vec_Ptr_t * vSuper )
return 0;
// set the pointer to the one before the last
Current = Vec_PtrSize(vSuper) - 2;
- pObjRight = Vec_PtrEntry( vSuper, Current );
+ pObjRight = (Hop_Obj_t *)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 );
+ pObjLeft = (Hop_Obj_t *)Vec_PtrEntry( vSuper, Current );
// if the level of this node is different, quit the loop
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 );
+ pObjLeft = (Hop_Obj_t *)Vec_PtrEntry( vSuper, Current );
assert( Hop_ObjLevel(Hop_Regular(pObjLeft)) == Hop_ObjLevel(Hop_Regular(pObjRight)) );
return Current;
}
@@ -317,14 +320,14 @@ void Hop_NodeBalancePermute( Hop_Man_t * p, Vec_Ptr_t * vSuper, int LeftBound, i
if ( LeftBound == RightBound )
return;
// get the two last nodes
- pObj1 = Vec_PtrEntry( vSuper, RightBound + 1 );
- pObj2 = Vec_PtrEntry( vSuper, RightBound );
+ pObj1 = (Hop_Obj_t *)Vec_PtrEntry( vSuper, RightBound + 1 );
+ pObj2 = (Hop_Obj_t *)Vec_PtrEntry( vSuper, RightBound );
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 );
+ pObj3 = (Hop_Obj_t *)Vec_PtrEntry( vSuper, i );
if ( Hop_Regular(pObj3) == p->pConst1 )
{
Vec_PtrWriteEntry( vSuper, i, pObj2 );
@@ -374,8 +377,8 @@ void Hop_NodeBalancePushUniqueOrderByLevel( Vec_Ptr_t * vStore, Hop_Obj_t * pObj
// find the p of the node
for ( i = vStore->nSize-1; i > 0; i-- )
{
- pObj1 = vStore->pArray[i ];
- pObj2 = vStore->pArray[i-1];
+ pObj1 = (Hop_Obj_t *)vStore->pArray[i ];
+ pObj2 = (Hop_Obj_t *)vStore->pArray[i-1];
if ( Hop_ObjLevel(Hop_Regular(pObj1)) <= Hop_ObjLevel(Hop_Regular(pObj2)) )
break;
vStore->pArray[i ] = pObj2;
@@ -389,3 +392,5 @@ void Hop_NodeBalancePushUniqueOrderByLevel( Vec_Ptr_t * vStore, Hop_Obj_t * pObj
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/hop/hopCheck.c b/src/aig/hop/hopCheck.c
index 9120906f..174c5523 100644
--- a/src/aig/hop/hopCheck.c
+++ b/src/aig/hop/hopCheck.c
@@ -20,6 +20,9 @@
#include "hop.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -108,3 +111,5 @@ int Hop_ManCheck( Hop_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/hop/hopDfs.c b/src/aig/hop/hopDfs.c
index 27fb1aa6..be1e6c0b 100644
--- a/src/aig/hop/hopDfs.c
+++ b/src/aig/hop/hopDfs.c
@@ -20,6 +20,9 @@
#include "hop.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -94,7 +97,7 @@ Vec_Ptr_t * Hop_ManDfsNode( Hop_Man_t * p, Hop_Obj_t * pNode )
assert( !Hop_IsComplement(pNode) );
vNodes = Vec_PtrAlloc( 16 );
Hop_ManDfs_rec( pNode, vNodes );
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Hop_Obj_t *, vNodes, pObj, i )
Hop_ObjClearMarkA(pObj);
return vNodes;
}
@@ -121,7 +124,7 @@ int Hop_ManCountLevels( Hop_Man_t * p )
pObj->pData = NULL;
// compute levels in a DFS order
vNodes = Hop_ManDfs( p );
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Hop_Obj_t *, vNodes, pObj, i )
{
Level0 = (int)(ABC_PTRUINT_T)Hop_ObjFanin0(pObj)->pData;
Level1 = (int)(ABC_PTRUINT_T)Hop_ObjFanin1(pObj)->pData;
@@ -335,7 +338,7 @@ Hop_Obj_t * Hop_Transfer( Hop_Man_t * pSour, Hop_Man_t * pDest, Hop_Obj_t * pRoo
Hop_Transfer_rec( pDest, Hop_Regular(pRoot) );
// clear the markings
Hop_ConeUnmark_rec( Hop_Regular(pRoot) );
- return Hop_NotCond( Hop_Regular(pRoot)->pData, Hop_IsComplement(pRoot) );
+ return Hop_NotCond( (Hop_Obj_t *)Hop_Regular(pRoot)->pData, Hop_IsComplement(pRoot) );
}
/**Function*************************************************************
@@ -389,7 +392,7 @@ Hop_Obj_t * Hop_Compose( Hop_Man_t * p, Hop_Obj_t * pRoot, Hop_Obj_t * pFunc, in
Hop_Compose_rec( p, Hop_Regular(pRoot), pFunc, Hop_ManPi(p, iVar) );
// clear the markings
Hop_ConeUnmark_rec( Hop_Regular(pRoot) );
- return Hop_NotCond( Hop_Regular(pRoot)->pData, Hop_IsComplement(pRoot) );
+ return Hop_NotCond( (Hop_Obj_t *)Hop_Regular(pRoot)->pData, Hop_IsComplement(pRoot) );
}
/**Function*************************************************************
@@ -457,7 +460,7 @@ Hop_Obj_t * Hop_Remap( Hop_Man_t * p, Hop_Obj_t * pRoot, unsigned uSupp, int nVa
Hop_Remap_rec( p, Hop_Regular(pRoot) );
// clear the markings
Hop_ConeUnmark_rec( Hop_Regular(pRoot) );
- return Hop_NotCond( Hop_Regular(pRoot)->pData, Hop_IsComplement(pRoot) );
+ return Hop_NotCond( (Hop_Obj_t *)Hop_Regular(pRoot)->pData, Hop_IsComplement(pRoot) );
}
////////////////////////////////////////////////////////////////////////
@@ -465,3 +468,5 @@ Hop_Obj_t * Hop_Remap( Hop_Man_t * p, Hop_Obj_t * pRoot, unsigned uSupp, int nVa
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/hop/hopMan.c b/src/aig/hop/hopMan.c
index bf38a780..84d987bb 100644
--- a/src/aig/hop/hopMan.c
+++ b/src/aig/hop/hopMan.c
@@ -20,6 +20,9 @@
#include "hop.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -127,7 +130,7 @@ int Hop_ManCleanup( Hop_Man_t * p )
if ( Hop_ObjRefs(pNode) == 0 )
Vec_PtrPush( vObjs, pNode );
// recursively remove dangling nodes
- Vec_PtrForEachEntry( vObjs, pNode, i )
+ Vec_PtrForEachEntry( Hop_Obj_t *, vObjs, pNode, i )
Hop_ObjDelete_rec( p, pNode );
Vec_PtrFree( vObjs );
return nNodesOld - Hop_ManNodeNum(p);
@@ -162,3 +165,5 @@ void Hop_ManPrintStats( Hop_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/hop/hopMem.c b/src/aig/hop/hopMem.c
index c6d05865..79de3804 100644
--- a/src/aig/hop/hopMem.c
+++ b/src/aig/hop/hopMem.c
@@ -20,6 +20,9 @@
#include "hop.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -64,7 +67,7 @@ void Hop_ManStopMemory( Hop_Man_t * p )
{
void * pMemory;
int i;
- Vec_PtrForEachEntry( p->vChunks, pMemory, i )
+ Vec_PtrForEachEntry( void *, p->vChunks, pMemory, i )
ABC_FREE( pMemory );
Vec_PtrFree( p->vChunks );
Vec_PtrFree( p->vPages );
@@ -113,3 +116,5 @@ void Hop_ManAddMemory( Hop_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/hop/hopObj.c b/src/aig/hop/hopObj.c
index f173248f..4451b3fa 100644
--- a/src/aig/hop/hopObj.c
+++ b/src/aig/hop/hopObj.c
@@ -20,6 +20,9 @@
#include "hop.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -240,7 +243,7 @@ Hop_Obj_t * Hop_ObjRepr( Hop_Obj_t * pObj )
assert( !Hop_IsComplement(pObj) );
if ( pObj->pData == NULL || pObj->pData == pObj )
return pObj;
- return Hop_ObjRepr( pObj->pData );
+ return Hop_ObjRepr( (Hop_Obj_t *)pObj->pData );
}
/**Function*************************************************************
@@ -270,3 +273,5 @@ void Hop_ObjCreateChoice( Hop_Obj_t * pOld, Hop_Obj_t * pNew )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/hop/hopOper.c b/src/aig/hop/hopOper.c
index 0ecb8d61..2f5e7650 100644
--- a/src/aig/hop/hopOper.c
+++ b/src/aig/hop/hopOper.c
@@ -20,6 +20,9 @@
#include "hop.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -298,7 +301,7 @@ Hop_Obj_t * Hop_Miter( Hop_Man_t * p, Vec_Ptr_t * vPairs )
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] = Hop_Not( Hop_Exor( p, vPairs->pArray[i], vPairs->pArray[i+1] ) );
+ vPairs->pArray[i/2] = Hop_Not( Hop_Exor( p, (Hop_Obj_t *)vPairs->pArray[i], (Hop_Obj_t *)vPairs->pArray[i+1] ) );
vPairs->nSize = vPairs->nSize/2;
return Hop_Not( Hop_Multi_rec( p, (Hop_Obj_t **)vPairs->pArray, vPairs->nSize, AIG_AND ) );
}
@@ -371,3 +374,5 @@ Hop_Obj_t * Hop_CreateExor( Hop_Man_t * p, int nVars )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/hop/hopTable.c b/src/aig/hop/hopTable.c
index cfc6add0..8148a125 100644
--- a/src/aig/hop/hopTable.c
+++ b/src/aig/hop/hopTable.c
@@ -20,6 +20,9 @@
#include "hop.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -260,3 +263,5 @@ unsigned int Cudd_PrimeAig( unsigned int p)
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/hop/hopTruth.c b/src/aig/hop/hopTruth.c
index 42ded3ed..0b674225 100644
--- a/src/aig/hop/hopTruth.c
+++ b/src/aig/hop/hopTruth.c
@@ -20,6 +20,9 @@
#include "hop.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -97,7 +100,7 @@ unsigned * Hop_ManConvertAigToTruth_rec2( Hop_Obj_t * pObj, Vec_Int_t * vTruth,
int i;
assert( !Hop_IsComplement(pObj) );
if ( !Hop_ObjIsNode(pObj) || !Hop_ObjIsMarkA(pObj) )
- return pObj->pData;
+ return (unsigned *)pObj->pData;
// compute the truth tables of the fanins
pTruth0 = Hop_ManConvertAigToTruth_rec2( Hop_ObjFanin0(pObj), vTruth, nWords );
pTruth1 = Hop_ManConvertAigToTruth_rec2( Hop_ObjFanin1(pObj), vTruth, nWords );
@@ -220,3 +223,5 @@ unsigned * Hop_ManConvertAigToTruth( Hop_Man_t * p, Hop_Obj_t * pRoot, int nVars
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/hop/hopUtil.c b/src/aig/hop/hopUtil.c
index d541ab99..76ed7b17 100644
--- a/src/aig/hop/hopUtil.c
+++ b/src/aig/hop/hopUtil.c
@@ -20,6 +20,9 @@
#include "hop.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -338,10 +341,10 @@ void Hop_ObjPrintEqn( FILE * pFile, Hop_Obj_t * pObj, Vec_Vec_t * vLevels, int L
}
// AND case
Vec_VecExpand( vLevels, Level );
- vSuper = Vec_VecEntry(vLevels, Level);
+ vSuper = (Vec_Ptr_t *)Vec_VecEntry(vLevels, Level);
Hop_ObjCollectMulti( pObj, vSuper );
fprintf( pFile, "%s", (Level==0? "" : "(") );
- Vec_PtrForEachEntry( vSuper, pFanin, i )
+ Vec_PtrForEachEntry( Hop_Obj_t *, vSuper, pFanin, i )
{
Hop_ObjPrintEqn( pFile, Hop_NotCond(pFanin, fCompl), vLevels, Level+1 );
if ( i < Vec_PtrSize(vSuper) - 1 )
@@ -387,10 +390,10 @@ void Hop_ObjPrintVerilog( FILE * pFile, Hop_Obj_t * pObj, Vec_Vec_t * vLevels, i
if ( Hop_ObjIsExor(pObj) )
{
Vec_VecExpand( vLevels, Level );
- vSuper = Vec_VecEntry( vLevels, Level );
+ vSuper = (Vec_Ptr_t *)Vec_VecEntry( vLevels, Level );
Hop_ObjCollectMulti( pObj, vSuper );
fprintf( pFile, "%s", (Level==0? "" : "(") );
- Vec_PtrForEachEntry( vSuper, pFanin, i )
+ Vec_PtrForEachEntry( Hop_Obj_t *, vSuper, pFanin, i )
{
Hop_ObjPrintVerilog( pFile, Hop_NotCond(pFanin, (fCompl && i==0)), vLevels, Level+1 );
if ( i < Vec_PtrSize(vSuper) - 1 )
@@ -425,10 +428,10 @@ void Hop_ObjPrintVerilog( FILE * pFile, Hop_Obj_t * pObj, Vec_Vec_t * vLevels, i
}
// AND case
Vec_VecExpand( vLevels, Level );
- vSuper = Vec_VecEntry(vLevels, Level);
+ vSuper = (Vec_Ptr_t *)Vec_VecEntry(vLevels, Level);
Hop_ObjCollectMulti( pObj, vSuper );
fprintf( pFile, "%s", (Level==0? "" : "(") );
- Vec_PtrForEachEntry( vSuper, pFanin, i )
+ Vec_PtrForEachEntry( Hop_Obj_t *, vSuper, pFanin, i )
{
Hop_ObjPrintVerilog( pFile, Hop_NotCond(pFanin, fCompl), vLevels, Level+1 );
if ( i < Vec_PtrSize(vSuper) - 1 )
@@ -486,7 +489,7 @@ void Hop_ManPrintVerbose( Hop_Man_t * p, int fHaig )
printf( " %p", pObj );
printf( "\n" );
vNodes = Hop_ManDfs( p );
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Hop_Obj_t *, vNodes, pObj, i )
Hop_ObjPrintVerbose( pObj, fHaig ), printf( "\n" );
printf( "\n" );
}
@@ -521,7 +524,7 @@ void Hop_ManDumpBlif( Hop_Man_t * p, char * pFileName )
pObj->pData = (void *)(ABC_PTRUINT_T)Counter++;
Hop_ManForEachPo( p, pObj, i )
pObj->pData = (void *)(ABC_PTRUINT_T)Counter++;
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Hop_Obj_t *, vNodes, pObj, i )
pObj->pData = (void *)(ABC_PTRUINT_T)Counter++;
nDigits = Hop_Base10Log( Counter );
// write the file
@@ -540,7 +543,7 @@ void Hop_ManDumpBlif( Hop_Man_t * p, char * pFileName )
fprintf( pFile, " n%0*d", nDigits, (int)(ABC_PTRUINT_T)pObj->pData );
fprintf( pFile, "\n" );
// write nodes
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Hop_Obj_t *, vNodes, pObj, i )
{
fprintf( pFile, ".names n%0*d n%0*d n%0*d\n",
nDigits, (int)(ABC_PTRUINT_T)Hop_ObjFanin0(pObj)->pData,
@@ -570,3 +573,5 @@ void Hop_ManDumpBlif( Hop_Man_t * p, char * pFileName )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/hop/hop_.c b/src/aig/hop/hop_.c
index 658b8c4e..b2bd8c22 100644
--- a/src/aig/hop/hop_.c
+++ b/src/aig/hop/hop_.c
@@ -20,6 +20,9 @@
#include "hop.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -46,3 +49,5 @@
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/int/int.h b/src/aig/int/int.h
index 1487b9bf..907691ed 100644
--- a/src/aig/int/int.h
+++ b/src/aig/int/int.h
@@ -21,6 +21,7 @@
#ifndef __INT_H__
#define __INT_H__
+
/*
The interpolation algorithm implemented here was introduced in the paper:
K. L. McMillan. Interpolation and SAT-based model checking. CAV’03, pp. 1-13.
@@ -34,9 +35,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -48,6 +50,7 @@ struct Inter_ManParams_t_
{
int nBTLimit; // limit on the number of conflicts
int nFramesMax; // the max number timeframes to unroll
+ int nSecLimit; // time limit in seconds
int nFramesK; // the number of timeframes to use in induction
int fRewrite; // use additional rewriting to simplify timeframes
int fTransLoop; // add transition into the init state under new PI var
@@ -58,7 +61,9 @@ struct Inter_ManParams_t_
int fUseBias; // bias decisions to global variables
int fUseBackward; // perform backward interpolation
int fUseSeparate; // solve each output separately
+ int fDropSatOuts; // replace by 1 the solved outputs
int fVerbose; // print verbose statistics
+ int iFrameMax; // the time frame reached
};
////////////////////////////////////////////////////////////////////////
@@ -74,9 +79,11 @@ extern void Inter_ManSetDefaultParams( Inter_ManParams_t * p );
extern int Inter_ManPerformInterpolation( Aig_Man_t * pAig, Inter_ManParams_t * pPars, int * piFrame );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/aig/int/intContain.c b/src/aig/int/intContain.c
index 3c16629f..4cc8577e 100644
--- a/src/aig/int/intContain.c
+++ b/src/aig/int/intContain.c
@@ -21,6 +21,8 @@
#include "intInt.h"
#include "fra.h"
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -219,7 +221,7 @@ int Inter_ManCheckInductiveContainment( Aig_Man_t * pTrans, Aig_Man_t * pInter,
// convert to CNF
pCnf = Cnf_Derive( pFrames, 0 );
- pSat = Cnf_DataWriteIntoSolver( pCnf, 1, 0 );
+ pSat = (sat_solver *)Cnf_DataWriteIntoSolver( pCnf, 1, 0 );
// Cnf_DataFree( pCnf );
// Aig_ManStop( pFrames );
@@ -241,9 +243,13 @@ int Inter_ManCheckInductiveContainment( Aig_Man_t * pTrans, Aig_Man_t * pInter,
sat_solver_delete( pSat );
return status == l_False;
}
+ABC_NAMESPACE_IMPL_END
#include "fra.h"
+ABC_NAMESPACE_IMPL_START
+
+
/**Function*************************************************************
Synopsis [Check if cex satisfies uniqueness constraints.]
@@ -326,3 +332,5 @@ int Inter_ManCheckUniqueness( Aig_Man_t * p, sat_solver * pSat, Cnf_Dat_t * pCnf
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/int/intCore.c b/src/aig/int/intCore.c
index d1f89c07..c0df48fb 100644
--- a/src/aig/int/intCore.c
+++ b/src/aig/int/intCore.c
@@ -20,6 +20,9 @@
#include "intInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -44,6 +47,7 @@ void Inter_ManSetDefaultParams( Inter_ManParams_t * p )
memset( p, 0, sizeof(Inter_ManParams_t) );
p->nBTLimit = 10000; // limit on the number of conflicts
p->nFramesMax = 40; // the max number timeframes to unroll
+ p->nSecLimit = 0; // time limit in seconds
p->nFramesK = 1; // the number of timeframes to use in induction
p->fRewrite = 0; // use additional rewriting to simplify timeframes
p->fTransLoop = 1; // add transition into the init state under new PI var
@@ -54,7 +58,9 @@ void Inter_ManSetDefaultParams( Inter_ManParams_t * p )
p->fUseBias = 0; // bias decisions to global variables
p->fUseBackward = 0; // perform backward interpolation
p->fUseSeparate = 0; // solve each output separately
+ p->fDropSatOuts = 0; // replace by 1 the solved outputs
p->fVerbose = 0; // print verbose statistics
+ p->iFrameMax =-1;
}
/**Function*************************************************************
@@ -77,7 +83,9 @@ int Inter_ManPerformInterpolation( Aig_Man_t * pAig, Inter_ManParams_t * pPars,
// sanity checks
assert( Saig_ManRegNum(pAig) > 0 );
assert( Saig_ManPiNum(pAig) > 0 );
- assert( Saig_ManPoNum(pAig) == 1 );
+ assert( Saig_ManPoNum(pAig)-Saig_ManConstrNum(pAig) == 1 );
+ if ( pPars->fVerbose && Saig_ManConstrNum(pAig) )
+ printf( "Performing interpolation with %d constraints...\n", Saig_ManConstrNum(pAig) );
/*
if ( Inter_ManCheckInitialState(pAig) )
{
@@ -179,6 +187,8 @@ p->timeCnf += clock() - clk;
i+1, i + 1 + p->nFrames, Aig_ManNodeNum(p->pInter), Aig_ManLevelNum(p->pInter), p->nConfCur );
ABC_PRT( "Time", clock() - clk );
}
+ // remember the number of timeframes completed
+ pPars->iFrameMax = i + 1 + p->nFrames;
if ( RetValue == 0 ) // found a (spurious?) counter-example
{
if ( i == 0 ) // real counterexample
@@ -187,7 +197,7 @@ p->timeCnf += clock() - clk;
printf( "Found a real counterexample in frame %d.\n", p->nFrames );
p->timeTotal = clock() - clkTotal;
*piFrame = p->nFrames;
- pAig->pSeqModel = Inter_ManGetCounterExample( pAig, p->nFrames+1, pPars->fVerbose );
+ pAig->pSeqModel = (Abc_Cex_t *)Inter_ManGetCounterExample( pAig, p->nFrames+1, pPars->fVerbose );
Inter_ManStop( p );
return 0;
}
@@ -211,6 +221,7 @@ clk = clock();
if ( p->pInterNew )
{
p->pInterNew = Dar_ManRwsat( pAigTemp = p->pInterNew, 1, 0 );
+// p->pInterNew = Dar_ManRwsat( pAigTemp = p->pInterNew, 0, 0 );
Aig_ManStop( pAigTemp );
}
p->timeRwr += clock() - clk;
@@ -251,6 +262,13 @@ p->timeEqu += clock() - clk;
Inter_ManStop( p );
return 1;
}
+ if ( pPars->nSecLimit && ((float)pPars->nSecLimit <= (float)(clock()-clkTotal)/(float)(CLOCKS_PER_SEC)) )
+ {
+ printf( "Reached timeout (%d seconds).\n", pPars->nSecLimit );
+ p->timeTotal = clock() - clkTotal;
+ Inter_ManStop( p );
+ return -1;
+ }
// save interpolant and convert it into CNF
if ( pPars->fTransLoop )
{
@@ -286,3 +304,5 @@ p->timeCnf += clock() - clk;
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/int/intCtrex.c b/src/aig/int/intCtrex.c
index ddb0bce6..28b1e293 100644
--- a/src/aig/int/intCtrex.c
+++ b/src/aig/int/intCtrex.c
@@ -21,6 +21,9 @@
#include "intInt.h"
#include "ssw.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -92,7 +95,7 @@ Aig_Man_t * Inter_ManFramesBmc( Aig_Man_t * pAig, int nFrames )
void * Inter_ManGetCounterExample( Aig_Man_t * pAig, int nFrames, int fVerbose )
{
int nConfLimit = 1000000;
- Ssw_Cex_t * pCtrex = NULL;
+ Abc_Cex_t * pCtrex = NULL;
Aig_Man_t * pFrames;
sat_solver * pSat;
Cnf_Dat_t * pCnf;
@@ -107,7 +110,7 @@ void * Inter_ManGetCounterExample( Aig_Man_t * pAig, int nFrames, int fVerbose )
vCiIds = Cnf_DataCollectPiSatNums( pCnf, pFrames );
Aig_ManStop( pFrames );
// convert into SAT solver
- pSat = Cnf_DataWriteIntoSolver( pCnf, 1, 0 );
+ pSat = (sat_solver *)Cnf_DataWriteIntoSolver( pCnf, 1, 0 );
Cnf_DataFree( pCnf );
if ( pSat == NULL )
{
@@ -160,3 +163,5 @@ void * Inter_ManGetCounterExample( Aig_Man_t * pAig, int nFrames, int fVerbose )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/int/intDup.c b/src/aig/int/intDup.c
index 4c5b7ab6..800375a9 100644
--- a/src/aig/int/intDup.c
+++ b/src/aig/int/intDup.c
@@ -20,6 +20,9 @@
#include "intInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -83,12 +86,21 @@ Aig_Man_t * Inter_ManStartDuplicated( Aig_Man_t * p )
Aig_ManForEachPi( p, pObj, i )
pObj->pData = Aig_ObjCreatePi( pNew );
// set registers
- pNew->nRegs = p->nRegs;
pNew->nTruePis = p->nTruePis;
- pNew->nTruePos = 0;
+ pNew->nTruePos = Saig_ManConstrNum(p);
+ pNew->nRegs = p->nRegs;
// duplicate internal nodes
Aig_ManForEachNode( p, pObj, i )
pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
+
+ // create constraint outputs
+ Saig_ManForEachPo( p, pObj, i )
+ {
+ if ( i < Saig_ManPoNum(p)-Saig_ManConstrNum(p) )
+ continue;
+ Aig_ObjCreatePo( pNew, Aig_Not( Aig_ObjChild0Copy(pObj) ) );
+ }
+
// create register inputs with MUXes
Saig_ManForEachLi( p, pObj, i )
Aig_ObjCreatePo( pNew, Aig_ObjChild0Copy(pObj) );
@@ -130,10 +142,19 @@ Aig_Man_t * Inter_ManStartOneOutput( Aig_Man_t * p, int fAddFirstPo )
// set registers
pNew->nRegs = fAddFirstPo? 0 : p->nRegs;
pNew->nTruePis = fAddFirstPo? Aig_ManPiNum(p) + 1 : p->nTruePis + 1;
- pNew->nTruePos = fAddFirstPo;
+ pNew->nTruePos = fAddFirstPo + Saig_ManConstrNum(p);
// duplicate internal nodes
Aig_ManForEachNode( p, pObj, i )
pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
+
+ // create constraint outputs
+ Saig_ManForEachPo( p, pObj, i )
+ {
+ if ( i < Saig_ManPoNum(p)-Saig_ManConstrNum(p) )
+ continue;
+ Aig_ObjCreatePo( pNew, Aig_Not( Aig_ObjChild0Copy(pObj) ) );
+ }
+
// add the PO
if ( fAddFirstPo )
{
@@ -145,7 +166,7 @@ Aig_Man_t * Inter_ManStartOneOutput( Aig_Man_t * p, int fAddFirstPo )
// create register inputs with MUXes
Saig_ManForEachLiLo( p, pObjLi, pObjLo, i )
{
- pObj = Aig_Mux( pNew, pCtrl, pObjLo->pData, Aig_ObjChild0Copy(pObjLi) );
+ pObj = Aig_Mux( pNew, pCtrl, (Aig_Obj_t *)pObjLo->pData, Aig_ObjChild0Copy(pObjLi) );
// pObj = Aig_Mux( pNew, pCtrl, Aig_ManConst0(pNew), Aig_ObjChild0Copy(pObjLi) );
Aig_ObjCreatePo( pNew, pObj );
}
@@ -159,3 +180,5 @@ Aig_Man_t * Inter_ManStartOneOutput( Aig_Man_t * p, int fAddFirstPo )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/int/intFrames.c b/src/aig/int/intFrames.c
index 809cb06b..0fbab6cb 100644
--- a/src/aig/int/intFrames.c
+++ b/src/aig/int/intFrames.c
@@ -20,6 +20,9 @@
#include "intInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -47,7 +50,7 @@ Aig_Man_t * Inter_ManFramesInter( Aig_Man_t * pAig, int nFrames, int fAddRegOuts
Aig_Obj_t * pObj, * pObjLi, * pObjLo;
int i, f;
assert( Saig_ManRegNum(pAig) > 0 );
- assert( Saig_ManPoNum(pAig) == 1 );
+ assert( Saig_ManPoNum(pAig)-Saig_ManConstrNum(pAig) == 1 );
pFrames = Aig_ManStart( Aig_ManNodeNum(pAig) * nFrames );
// map the constant node
Aig_ManConst1(pAig)->pData = Aig_ManConst1( pFrames );
@@ -71,6 +74,13 @@ Aig_Man_t * Inter_ManFramesInter( Aig_Man_t * pAig, int nFrames, int fAddRegOuts
// add internal nodes of this frame
Aig_ManForEachNode( pAig, pObj, i )
pObj->pData = Aig_And( pFrames, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
+ // add outputs for constraints
+ Saig_ManForEachPo( pAig, pObj, i )
+ {
+ if ( i < Saig_ManPoNum(pAig)-Saig_ManConstrNum(pAig) )
+ continue;
+ Aig_ObjCreatePo( pFrames, Aig_Not( Aig_ObjChild0Copy(pObj) ) );
+ }
if ( f == nFrames - 1 )
break;
// save register inputs
@@ -101,3 +111,5 @@ Aig_Man_t * Inter_ManFramesInter( Aig_Man_t * pAig, int nFrames, int fAddRegOuts
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/int/intInt.h b/src/aig/int/intInt.h
index 2d571f09..72079a49 100644
--- a/src/aig/int/intInt.h
+++ b/src/aig/int/intInt.h
@@ -21,6 +21,7 @@
#ifndef __INT_INT_H__
#define __INT_INT_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -35,9 +36,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -118,9 +120,11 @@ extern int Inter_ManPerformOneStepM114p( Inter_Man_t * p, int fUsePudl
extern int Inter_ManCheckInitialState( Aig_Man_t * p );
extern int Inter_ManCheckAllStates( Aig_Man_t * p );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/aig/int/intInter.c b/src/aig/int/intInter.c
index 592eedcf..ef32294b 100644
--- a/src/aig/int/intInter.c
+++ b/src/aig/int/intInter.c
@@ -20,6 +20,9 @@
#include "intInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -138,3 +141,5 @@ void Inter_ManVerifyInterpolant2( Intb_Man_t * pMan, Sto_Man_t * pCnf, Aig_Man_t
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/int/intM114.c b/src/aig/int/intM114.c
index 359d5458..c1718eae 100644
--- a/src/aig/int/intM114.c
+++ b/src/aig/int/intM114.c
@@ -20,6 +20,9 @@
#include "intInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -296,11 +299,11 @@ clk = clock();
*/
pManInterA = Inta_ManAlloc();
- p->pInterNew = Inta_ManInterpolate( pManInterA, pSatCnf, p->vVarsAB, 0 );
+ p->pInterNew = (Aig_Man_t *)Inta_ManInterpolate( pManInterA, (Sto_Man_t *)pSatCnf, p->vVarsAB, 0 );
Inta_ManFree( pManInterA );
p->timeInt += clock() - clk;
- Sto_ManFree( pSatCnf );
+ Sto_ManFree( (Sto_Man_t *)pSatCnf );
return RetValue;
}
@@ -309,3 +312,5 @@ p->timeInt += clock() - clk;
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/int/intM114p.c b/src/aig/int/intM114p.c
index 6818fdce..0ad0552f 100644
--- a/src/aig/int/intM114p.c
+++ b/src/aig/int/intM114p.c
@@ -18,11 +18,13 @@
***********************************************************************/
-#ifdef ABC_USE_LIBRARIES
-
#include "intInt.h"
#include "m114p.h"
+#ifdef ABC_USE_LIBRARIES
+
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -433,6 +435,8 @@ p->timeInt += clock() - clk;
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
#endif
diff --git a/src/aig/int/intMan.c b/src/aig/int/intMan.c
index 14a79f65..2faef198 100644
--- a/src/aig/int/intMan.c
+++ b/src/aig/int/intMan.c
@@ -20,6 +20,9 @@
#include "intInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -126,3 +129,5 @@ void Inter_ManStop( Inter_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/int/intUtil.c b/src/aig/int/intUtil.c
index c0dc9ddb..0d8beda5 100644
--- a/src/aig/int/intUtil.c
+++ b/src/aig/int/intUtil.c
@@ -20,6 +20,9 @@
#include "intInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -47,7 +50,7 @@ int Inter_ManCheckInitialState( Aig_Man_t * p )
int status;
int clk = clock();
pCnf = Cnf_Derive( p, Saig_ManRegNum(p) );
- pSat = Cnf_DataWriteIntoSolver( pCnf, 1, 1 );
+ pSat = (sat_solver *)Cnf_DataWriteIntoSolver( pCnf, 1, 1 );
Cnf_DataFree( pCnf );
if ( pSat == NULL )
return 0;
@@ -75,7 +78,7 @@ int Inter_ManCheckAllStates( Aig_Man_t * p )
int status;
int clk = clock();
pCnf = Cnf_Derive( p, Saig_ManRegNum(p) );
- pSat = Cnf_DataWriteIntoSolver( pCnf, 1, 0 );
+ pSat = (sat_solver *)Cnf_DataWriteIntoSolver( pCnf, 1, 0 );
Cnf_DataFree( pCnf );
if ( pSat == NULL )
return 1;
@@ -90,3 +93,5 @@ int Inter_ManCheckAllStates( Aig_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ioa/ioa.h b/src/aig/ioa/ioa.h
index 55d95f6e..46dbda09 100644
--- a/src/aig/ioa/ioa.h
+++ b/src/aig/ioa/ioa.h
@@ -21,6 +21,7 @@
#ifndef __IOA_H__
#define __IOA_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -39,9 +40,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -60,8 +62,10 @@ extern "C" {
////////////////////////////////////////////////////////////////////////
/*=== ioaReadAig.c ========================================================*/
+extern Aig_Man_t * Ioa_ReadAigerFromMemory( char * pContents, int nFileSize, int fCheck );
extern Aig_Man_t * Ioa_ReadAiger( char * pFileName, int fCheck );
/*=== ioaWriteAig.c =======================================================*/
+extern char * Ioa_WriteAigerIntoMemory( Aig_Man_t * pMan, int * pnSize );
extern void Ioa_WriteAiger( Aig_Man_t * pMan, char * pFileName, int fWriteSymbols, int fCompact );
/*=== ioaUtil.c =======================================================*/
extern int Ioa_FileSize( char * pFileName );
@@ -69,9 +73,11 @@ extern char * Ioa_FileNameGeneric( char * FileName );
extern char * Ioa_FileNameGenericAppend( char * pBase, char * pSuffix );
extern char * Ioa_TimeStamp();
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/aig/ioa/ioaReadAig.c b/src/aig/ioa/ioaReadAig.c
index 6aaa6c64..defaa752 100644
--- a/src/aig/ioa/ioaReadAig.c
+++ b/src/aig/ioa/ioaReadAig.c
@@ -21,6 +21,9 @@
#include "ioa.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -91,7 +94,7 @@ Vec_Int_t * Ioa_WriteDecodeLiterals( char ** ppPos, int nEntries )
Synopsis [Reads the AIG in from the memory buffer.]
Description [The buffer constains the AIG in AIGER format. The size gives
- the number of types in the buffer. The buffer is allocated by the user
+ the number of bytes in the buffer. The buffer is allocated by the user
and not deallocated by this procedure.]
SideEffects []
@@ -198,8 +201,8 @@ Aig_Man_t * Ioa_ReadAigerFromMemory( char * pContents, int nFileSize, int fCheck
uLit1 = uLit - Ioa_ReadAigerDecode( &pCur );
uLit0 = uLit1 - Ioa_ReadAigerDecode( &pCur );
// assert( uLit1 > uLit0 );
- pNode0 = Aig_NotCond( Vec_PtrEntry(vNodes, uLit0 >> 1), uLit0 & 1 );
- pNode1 = Aig_NotCond( Vec_PtrEntry(vNodes, uLit1 >> 1), uLit1 & 1 );
+ pNode0 = Aig_NotCond( (Aig_Obj_t *)Vec_PtrEntry(vNodes, uLit0 >> 1), uLit0 & 1 );
+ pNode1 = Aig_NotCond( (Aig_Obj_t *)Vec_PtrEntry(vNodes, uLit1 >> 1), uLit1 & 1 );
assert( Vec_PtrSize(vNodes) == i + 1 + nInputs + nLatches );
Vec_PtrPush( vNodes, Aig_And(pNew, pNode0, pNode1) );
}
@@ -216,14 +219,14 @@ Aig_Man_t * Ioa_ReadAigerFromMemory( char * pContents, int nFileSize, int fCheck
for ( i = 0; i < nLatches; i++ )
{
uLit0 = atoi( pCur ); while ( *pCur++ != '\n' );
- pNode0 = Aig_NotCond( Vec_PtrEntry(vNodes, uLit0 >> 1), (uLit0 & 1) );//^ (uLit0 < 2) );
+ pNode0 = Aig_NotCond( (Aig_Obj_t *)Vec_PtrEntry(vNodes, uLit0 >> 1), (uLit0 & 1) );//^ (uLit0 < 2) );
Vec_PtrPush( vDrivers, pNode0 );
}
// read the PO driver literals
for ( i = 0; i < nOutputs; i++ )
{
uLit0 = atoi( pCur ); while ( *pCur++ != '\n' );
- pNode0 = Aig_NotCond( Vec_PtrEntry(vNodes, uLit0 >> 1), (uLit0 & 1) );//^ (uLit0 < 2) );
+ pNode0 = Aig_NotCond( (Aig_Obj_t *)Vec_PtrEntry(vNodes, uLit0 >> 1), (uLit0 & 1) );//^ (uLit0 < 2) );
Vec_PtrPush( vDrivers, pNode0 );
}
@@ -234,14 +237,14 @@ Aig_Man_t * Ioa_ReadAigerFromMemory( char * pContents, int nFileSize, int fCheck
for ( i = 0; i < nLatches; i++ )
{
uLit0 = Vec_IntEntry( vLits, i );
- pNode0 = Aig_NotCond( Vec_PtrEntry(vNodes, uLit0 >> 1), (uLit0 & 1) );//^ (uLit0 < 2) );
+ pNode0 = Aig_NotCond( (Aig_Obj_t *)Vec_PtrEntry(vNodes, uLit0 >> 1), (uLit0 & 1) );//^ (uLit0 < 2) );
Vec_PtrPush( vDrivers, pNode0 );
}
// read the PO driver literals
for ( i = 0; i < nOutputs; i++ )
{
uLit0 = Vec_IntEntry( vLits, i+nLatches );
- pNode0 = Aig_NotCond( Vec_PtrEntry(vNodes, uLit0 >> 1), (uLit0 & 1) );//^ (uLit0 < 2) );
+ pNode0 = Aig_NotCond( (Aig_Obj_t *)Vec_PtrEntry(vNodes, uLit0 >> 1), (uLit0 & 1) );//^ (uLit0 < 2) );
Vec_PtrPush( vDrivers, pNode0 );
}
Vec_IntFree( vLits );
@@ -249,9 +252,9 @@ Aig_Man_t * Ioa_ReadAigerFromMemory( char * pContents, int nFileSize, int fCheck
// create the POs
for ( i = 0; i < nOutputs; i++ )
- Aig_ObjCreatePo( pNew, Vec_PtrEntry(vDrivers, nLatches + i) );
+ Aig_ObjCreatePo( pNew, (Aig_Obj_t *)Vec_PtrEntry(vDrivers, nLatches + i) );
for ( i = 0; i < nLatches; i++ )
- Aig_ObjCreatePo( pNew, Vec_PtrEntry(vDrivers, i) );
+ Aig_ObjCreatePo( pNew, (Aig_Obj_t *)Vec_PtrEntry(vDrivers, i) );
Vec_PtrFree( vDrivers );
/*
@@ -403,3 +406,5 @@ Aig_Man_t * Ioa_ReadAiger( char * pFileName, int fCheck )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ioa/ioaUtil.c b/src/aig/ioa/ioaUtil.c
index b0e5618b..06034956 100644
--- a/src/aig/ioa/ioaUtil.c
+++ b/src/aig/ioa/ioaUtil.c
@@ -21,6 +21,9 @@
#include "ioa.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -139,3 +142,5 @@ char * Ioa_TimeStamp()
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ioa/ioaWriteAig.c b/src/aig/ioa/ioaWriteAig.c
index 42aa42db..7aa975f2 100644
--- a/src/aig/ioa/ioaWriteAig.c
+++ b/src/aig/ioa/ioaWriteAig.c
@@ -21,6 +21,9 @@
#include "ioa.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -163,6 +166,35 @@ int Ioa_WriteAigerEncode( unsigned char * pBuffer, int Pos, unsigned x )
/**Function*************************************************************
+ Synopsis [Adds one unsigned AIG edge to the output buffer.]
+
+ Description [This procedure is a slightly modified version of Armin Biere's
+ procedure "void encode (FILE * file, unsigned x)" ]
+
+ SideEffects [Returns the current writing position.]
+
+ SeeAlso []
+
+***********************************************************************/
+void Ioa_WriteAigerEncodeStr( Vec_Str_t * vStr, unsigned x )
+{
+ unsigned char ch;
+ while (x & ~0x7f)
+ {
+ ch = (x & 0x7f) | 0x80;
+// putc (ch, file);
+// pBuffer[Pos++] = ch;
+ Vec_StrPush( vStr, ch );
+ x >>= 7;
+ }
+ ch = x;
+// putc (ch, file);
+// pBuffer[Pos++] = ch;
+ Vec_StrPush( vStr, ch );
+}
+
+/**Function*************************************************************
+
Synopsis [Create the array of literals to be written.]
Description []
@@ -240,6 +272,151 @@ Vec_Str_t * Ioa_WriteEncodeLiterals( Vec_Int_t * vLits )
/**Function*************************************************************
+ Synopsis [Writes the AIG in into the memory buffer.]
+
+ Description [The resulting buffer constains the AIG in AIGER format.
+ The returned size (pnSize) gives the number of bytes in the buffer.
+ The resulting buffer should be deallocated by the user.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+char * Ioa_WriteAigerIntoMemory( Aig_Man_t * pMan, int * pnSize )
+{
+ char * pBuffer;
+ Vec_Str_t * vBuffer;
+ Aig_Obj_t * pObj, * pDriver;
+ int nNodes, i, uLit, uLit0, uLit1;
+ // set the node numbers to be used in the output file
+ nNodes = 0;
+ Ioa_ObjSetAigerNum( Aig_ManConst1(pMan), nNodes++ );
+ Aig_ManForEachPi( pMan, pObj, i )
+ Ioa_ObjSetAigerNum( pObj, nNodes++ );
+ Aig_ManForEachNode( pMan, pObj, i )
+ Ioa_ObjSetAigerNum( pObj, nNodes++ );
+
+ // write the header "M I L O A" where M = I + L + A
+/*
+ fprintf( pFile, "aig%s %u %u %u %u %u\n",
+ fCompact? "2" : "",
+ Aig_ManPiNum(pMan) + Aig_ManNodeNum(pMan),
+ Aig_ManPiNum(pMan) - Aig_ManRegNum(pMan),
+ Aig_ManRegNum(pMan),
+ Aig_ManPoNum(pMan) - Aig_ManRegNum(pMan),
+ Aig_ManNodeNum(pMan) );
+*/
+ vBuffer = Vec_StrAlloc( 3*Aig_ManObjNum(pMan) );
+ Vec_StrPrintStr( vBuffer, "aig " );
+ Vec_StrPrintNum( vBuffer, Aig_ManPiNum(pMan) + Aig_ManNodeNum(pMan) );
+ Vec_StrPrintStr( vBuffer, " " );
+ Vec_StrPrintNum( vBuffer, Aig_ManPiNum(pMan) - Aig_ManRegNum(pMan) );
+ Vec_StrPrintStr( vBuffer, " " );
+ Vec_StrPrintNum( vBuffer, Aig_ManRegNum(pMan) );
+ Vec_StrPrintStr( vBuffer, " " );
+ Vec_StrPrintNum( vBuffer, Aig_ManPoNum(pMan) - Aig_ManRegNum(pMan) );
+ Vec_StrPrintStr( vBuffer, " " );
+ Vec_StrPrintNum( vBuffer, Aig_ManNodeNum(pMan) );
+ Vec_StrPrintStr( vBuffer, "\n" );
+
+ // write latch drivers
+ Aig_ManForEachLiSeq( pMan, pObj, i )
+ {
+ pDriver = Aig_ObjFanin0(pObj);
+ uLit = Ioa_ObjMakeLit( Ioa_ObjAigerNum(pDriver), Aig_ObjFaninC0(pObj) ^ (Ioa_ObjAigerNum(pDriver) == 0) );
+// fprintf( pFile, "%u\n", uLit );
+ Vec_StrPrintNum( vBuffer, uLit );
+ Vec_StrPrintStr( vBuffer, "\n" );
+ }
+
+ // write PO drivers
+ Aig_ManForEachPoSeq( pMan, pObj, i )
+ {
+ pDriver = Aig_ObjFanin0(pObj);
+ uLit = Ioa_ObjMakeLit( Ioa_ObjAigerNum(pDriver), Aig_ObjFaninC0(pObj) ^ (Ioa_ObjAigerNum(pDriver) == 0) );
+// fprintf( pFile, "%u\n", uLit );
+ Vec_StrPrintNum( vBuffer, uLit );
+ Vec_StrPrintStr( vBuffer, "\n" );
+ }
+ // write the nodes into the buffer
+ Aig_ManForEachNode( pMan, pObj, i )
+ {
+ uLit = Ioa_ObjMakeLit( Ioa_ObjAigerNum(pObj), 0 );
+ uLit0 = Ioa_ObjMakeLit( Ioa_ObjAigerNum(Aig_ObjFanin0(pObj)), Aig_ObjFaninC0(pObj) );
+ uLit1 = Ioa_ObjMakeLit( Ioa_ObjAigerNum(Aig_ObjFanin1(pObj)), Aig_ObjFaninC1(pObj) );
+ assert( uLit0 != uLit1 );
+ if ( uLit0 > uLit1 )
+ {
+ int Temp = uLit0;
+ uLit0 = uLit1;
+ uLit1 = Temp;
+ }
+// Pos = Ioa_WriteAigerEncode( pBuffer, Pos, uLit - uLit1 );
+// Pos = Ioa_WriteAigerEncode( pBuffer, Pos, uLit1 - uLit0 );
+ Ioa_WriteAigerEncodeStr( vBuffer, uLit - uLit1 );
+ Ioa_WriteAigerEncodeStr( vBuffer, uLit1 - uLit0 );
+ }
+// fprintf( pFile, "c" );
+// if ( pMan->pName )
+// fprintf( pFile, "n%s%c", pMan->pName, '\0' );
+ Vec_StrPrintStr( vBuffer, "c" );
+ if ( pMan->pName )
+ {
+ Vec_StrPrintStr( vBuffer, "n" );
+ Vec_StrPrintStr( vBuffer, pMan->pName );
+ Vec_StrPush( vBuffer, 0 );
+ }
+ // prepare the return values
+ *pnSize = Vec_StrSize( vBuffer );
+ pBuffer = Vec_StrReleaseArray( vBuffer );
+ Vec_StrFree( vBuffer );
+ return pBuffer;
+}
+
+/**Function*************************************************************
+
+ Synopsis [This procedure is used to test the above procedure.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Ioa_WriteAigerBufferTest( Aig_Man_t * pMan, char * pFileName, int fWriteSymbols, int fCompact )
+{
+ FILE * pFile;
+ char * pBuffer;
+ int nSize;
+ if ( Aig_ManPoNum(pMan) == 0 )
+ {
+ printf( "AIG cannot be written because it has no POs.\n" );
+ return;
+ }
+ // start the output stream
+ pFile = fopen( pFileName, "wb" );
+ if ( pFile == NULL )
+ {
+ fprintf( stdout, "Ioa_WriteAiger(): Cannot open the output file \"%s\".\n", pFileName );
+ return;
+ }
+ // write the buffer
+ pBuffer = Ioa_WriteAigerIntoMemory( pMan, &nSize );
+ fwrite( pBuffer, 1, nSize, pFile );
+ ABC_FREE( pBuffer );
+ // write the comment
+// fprintf( pFile, "c" );
+// if ( pMan->pName )
+// fprintf( pFile, "n%s%c", pMan->pName, '\0' );
+ fprintf( pFile, "\nThis file was produced by the IOA package in ABC on %s\n", Ioa_TimeStamp() );
+ fprintf( pFile, "For information about AIGER format, refer to %s\n", "http://fmv.jku.at/aiger" );
+ fclose( pFile );
+}
+
+/**Function*************************************************************
+
Synopsis [Writes the AIG in the binary AIGER format.]
Description []
@@ -388,3 +565,5 @@ void Ioa_WriteAiger( Aig_Man_t * pMan, char * pFileName, int fWriteSymbols, int
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ivy/attr.h b/src/aig/ivy/attr.h
index ad342ce9..b65906cf 100644
--- a/src/aig/ivy/attr.h
+++ b/src/aig/ivy/attr.h
@@ -21,6 +21,7 @@
#ifndef __ATTR_H__
#define __ATTR_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -31,9 +32,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -402,9 +404,11 @@ static inline void Attr_ManSetAttrPtr( Attr_Man_t * p, int Id, void * pAttr )
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/aig/ivy/ivy.h b/src/aig/ivy/ivy.h
index 2c915e5b..870c0906 100644
--- a/src/aig/ivy/ivy.h
+++ b/src/aig/ivy/ivy.h
@@ -21,6 +21,7 @@
#ifndef __IVY_H__
#define __IVY_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -33,9 +34,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -121,7 +123,7 @@ struct Ivy_Man_t_
// memory management
Vec_Ptr_t * vChunks; // allocated memory pieces
Vec_Ptr_t * vPages; // memory pages used by nodes
- Ivy_Obj_t * pListFree; // the list of ABC_FREE nodes
+ Ivy_Obj_t * pListFree; // the list of free nodes
// timing statistics
int time1;
int time2;
@@ -180,6 +182,8 @@ struct Ivy_Store_t_
#define IVY_MIN(a,b) (((a) < (b))? (a) : (b))
#define IVY_MAX(a,b) (((a) > (b))? (a) : (b))
+extern void Ivy_ManAddMemory( Ivy_Man_t * p );
+
static inline int Ivy_BitWordNum( int nBits ) { return (nBits>>5) + ((nBits&31) > 0); }
static inline int Ivy_TruthWordNum( int nVars ) { return nVars <= 5 ? 1 : (1 << (nVars - 5)); }
static inline int Ivy_InfoHasBit( unsigned * p, int i ) { return (p[(i)>>5] & (1<<((i) & 31))) > 0; }
@@ -224,8 +228,8 @@ static inline int Ivy_ManNodeNum( Ivy_Man_t * p ) { return p->nO
static inline int Ivy_ManHashObjNum( Ivy_Man_t * p ) { return p->nObjs[IVY_AND]+p->nObjs[IVY_EXOR]+p->nObjs[IVY_LATCH]; }
static inline int Ivy_ManGetCost( Ivy_Man_t * p ) { return p->nObjs[IVY_AND]+3*p->nObjs[IVY_EXOR]+8*p->nObjs[IVY_LATCH]; }
-static inline Ivy_Type_t Ivy_ObjType( Ivy_Obj_t * pObj ) { return pObj->Type; }
-static inline Ivy_Init_t Ivy_ObjInit( Ivy_Obj_t * pObj ) { return pObj->Init; }
+static inline Ivy_Type_t Ivy_ObjType( Ivy_Obj_t * pObj ) { return (Ivy_Type_t)pObj->Type; }
+static inline Ivy_Init_t Ivy_ObjInit( Ivy_Obj_t * pObj ) { return (Ivy_Init_t)pObj->Init; }
static inline int Ivy_ObjIsConst1( Ivy_Obj_t * pObj ) { return pObj->Id == 0; }
static inline int Ivy_ObjIsGhost( Ivy_Obj_t * pObj ) { return pObj->Id < 0; }
static inline int Ivy_ObjIsNone( Ivy_Obj_t * pObj ) { return pObj->Type == IVY_NONE; }
@@ -359,7 +363,6 @@ static Ivy_Init_t Ivy_InitExor( Ivy_Init_t InitA, Ivy_Init_t InitB )
// internal memory manager
static inline Ivy_Obj_t * Ivy_ManFetchMemory( Ivy_Man_t * p )
{
- extern void Ivy_ManAddMemory( Ivy_Man_t * p );
Ivy_Obj_t * pTemp;
if ( p->pListFree == NULL )
Ivy_ManAddMemory( p );
@@ -382,13 +385,13 @@ static inline void Ivy_ManRecycleMemory( Ivy_Man_t * p, Ivy_Obj_t * pEntry )
// iterator over the primary inputs
#define Ivy_ManForEachPi( p, pObj, i ) \
- Vec_PtrForEachEntry( p->vPis, pObj, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, p->vPis, pObj, i )
// iterator over the primary outputs
#define Ivy_ManForEachPo( p, pObj, i ) \
- Vec_PtrForEachEntry( p->vPos, pObj, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, p->vPos, pObj, i )
// iterator over all objects, including those currently not used
#define Ivy_ManForEachObj( p, pObj, i ) \
- Vec_PtrForEachEntry( p->vObjs, pObj, i ) if ( (pObj) == NULL ) {} else
+ Vec_PtrForEachEntry( Ivy_Obj_t *, p->vObjs, pObj, i ) if ( (pObj) == NULL ) {} else
// iterator over the combinational inputs
#define Ivy_ManForEachCi( p, pObj, i ) \
Ivy_ManForEachObj( p, pObj, i ) if ( !Ivy_ObjIsCi(pObj) ) {} else
@@ -407,7 +410,7 @@ static inline void Ivy_ManRecycleMemory( Ivy_Man_t * p, Ivy_Obj_t * pEntry )
// iterator over the fanouts of an object
#define Ivy_ObjForEachFanout( p, pObj, vArray, pFanout, i ) \
for ( i = 0, Ivy_ObjCollectFanouts(p, pObj, vArray); \
- i < Vec_PtrSize(vArray) && ((pFanout) = Vec_PtrEntry(vArray,i)); i++ )
+ i < Vec_PtrSize(vArray) && ((pFanout) = (Ivy_Obj_t *)Vec_PtrEntry(vArray,i)); i++ )
////////////////////////////////////////////////////////////////////////
/// FUNCTION DECLARATIONS ///
@@ -545,9 +548,11 @@ extern void Ivy_ObjPrintVerbose( Ivy_Man_t * p, Ivy_Obj_t * pObj, int
extern void Ivy_ManPrintVerbose( Ivy_Man_t * p, int fHaig );
extern int Ivy_CutTruthPrint( Ivy_Man_t * p, Ivy_Cut_t * pCut, unsigned uTruth );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/aig/ivy/ivyBalance.c b/src/aig/ivy/ivyBalance.c
index b5c77e39..4abdf8c3 100644
--- a/src/aig/ivy/ivyBalance.c
+++ b/src/aig/ivy/ivyBalance.c
@@ -20,6 +20,9 @@
#include "ivy.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -139,8 +142,8 @@ int Ivy_NodeBalance_rec( Ivy_Man_t * pNew, Ivy_Obj_t * pObjOld, Vec_Vec_t * vSto
// for each old node, derive the new well-balanced node
for ( i = 0; i < vSuper->nSize; i++ )
{
- NewNodeId = Ivy_NodeBalance_rec( pNew, Ivy_Regular(vSuper->pArray[i]), vStore, Level + 1, fUpdateLevel );
- NewNodeId = Ivy_EdgeNotCond( NewNodeId, Ivy_IsComplement(vSuper->pArray[i]) );
+ NewNodeId = Ivy_NodeBalance_rec( pNew, Ivy_Regular((Ivy_Obj_t *)vSuper->pArray[i]), vStore, Level + 1, fUpdateLevel );
+ NewNodeId = Ivy_EdgeNotCond( NewNodeId, Ivy_IsComplement((Ivy_Obj_t *)vSuper->pArray[i]) );
vSuper->pArray[i] = Ivy_EdgeToNode( pNew, NewNodeId );
}
// build the supergate
@@ -170,7 +173,7 @@ Ivy_Obj_t * Ivy_NodeBalanceBuildSuper( Ivy_Man_t * p, Vec_Ptr_t * vSuper, Ivy_Ty
int LeftBound;
assert( vSuper->nSize > 1 );
// sort the new nodes by level in the decreasing order
- Vec_PtrSort( vSuper, Ivy_NodeCompareLevelsDecrease );
+ Vec_PtrSort( vSuper, (int (*)(void))Ivy_NodeCompareLevelsDecrease );
// balance the nodes
while ( vSuper->nSize > 1 )
{
@@ -179,11 +182,11 @@ Ivy_Obj_t * Ivy_NodeBalanceBuildSuper( Ivy_Man_t * p, Vec_Ptr_t * vSuper, Ivy_Ty
// find the node that can be shared (if no such node, randomize choice)
Ivy_NodeBalancePermute( p, vSuper, LeftBound, Type == IVY_EXOR );
// pull out the last two nodes
- pObj1 = Vec_PtrPop(vSuper);
- pObj2 = Vec_PtrPop(vSuper);
+ pObj1 = (Ivy_Obj_t *)Vec_PtrPop(vSuper);
+ pObj2 = (Ivy_Obj_t *)Vec_PtrPop(vSuper);
Ivy_NodeBalancePushUniqueOrderByLevel( vSuper, Ivy_Oper(p, pObj1, pObj2, Type) );
}
- return Vec_PtrEntry(vSuper, 0);
+ return (Ivy_Obj_t *)Vec_PtrEntry(vSuper, 0);
}
/**Function*************************************************************
@@ -252,13 +255,13 @@ Vec_Ptr_t * Ivy_NodeBalanceCone( Ivy_Obj_t * pObj, Vec_Vec_t * vStore, int Level
if ( Vec_VecSize( vStore ) <= Level )
Vec_VecPush( vStore, Level, 0 );
// get the temporary array of nodes
- vNodes = Vec_VecEntry( vStore, Level );
+ vNodes = (Vec_Ptr_t *)Vec_VecEntry( vStore, Level );
Vec_PtrClear( vNodes );
// collect the nodes in the implication supergate
RetValue = Ivy_NodeBalanceCone_rec( pObj, pObj, vNodes );
assert( vNodes->nSize > 1 );
// unmark the visited nodes
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vNodes, pObj, i )
Ivy_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)
@@ -291,19 +294,19 @@ int Ivy_NodeBalanceFindLeft( Vec_Ptr_t * vSuper )
return 0;
// set the pointer to the one before the last
Current = Vec_PtrSize(vSuper) - 2;
- pObjRight = Vec_PtrEntry( vSuper, Current );
+ pObjRight = (Ivy_Obj_t *)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 );
+ pObjLeft = (Ivy_Obj_t *)Vec_PtrEntry( vSuper, Current );
// if the level of this node is different, quit the loop
if ( Ivy_Regular(pObjLeft)->Level != Ivy_Regular(pObjRight)->Level )
break;
}
Current++;
// get the node, for which the equality holds
- pObjLeft = Vec_PtrEntry( vSuper, Current );
+ pObjLeft = (Ivy_Obj_t *)Vec_PtrEntry( vSuper, Current );
assert( Ivy_Regular(pObjLeft)->Level == Ivy_Regular(pObjRight)->Level );
return Current;
}
@@ -330,14 +333,14 @@ void Ivy_NodeBalancePermute( Ivy_Man_t * p, Vec_Ptr_t * vSuper, int LeftBound, i
if ( LeftBound == RightBound )
return;
// get the two last nodes
- pObj1 = Vec_PtrEntry( vSuper, RightBound + 1 );
- pObj2 = Vec_PtrEntry( vSuper, RightBound );
+ pObj1 = (Ivy_Obj_t *)Vec_PtrEntry( vSuper, RightBound + 1 );
+ pObj2 = (Ivy_Obj_t *)Vec_PtrEntry( vSuper, RightBound );
if ( Ivy_Regular(pObj1) == p->pConst1 || Ivy_Regular(pObj2) == p->pConst1 )
return;
// find the first node that can be shared
for ( i = RightBound; i >= LeftBound; i-- )
{
- pObj3 = Vec_PtrEntry( vSuper, i );
+ pObj3 = (Ivy_Obj_t *)Vec_PtrEntry( vSuper, i );
if ( Ivy_Regular(pObj3) == p->pConst1 )
{
Vec_PtrWriteEntry( vSuper, i, pObj2 );
@@ -387,8 +390,8 @@ void Ivy_NodeBalancePushUniqueOrderByLevel( Vec_Ptr_t * vStore, Ivy_Obj_t * pObj
// find the p of the node
for ( i = vStore->nSize-1; i > 0; i-- )
{
- pObj1 = vStore->pArray[i ];
- pObj2 = vStore->pArray[i-1];
+ pObj1 = (Ivy_Obj_t *)vStore->pArray[i ];
+ pObj2 = (Ivy_Obj_t *)vStore->pArray[i-1];
if ( Ivy_Regular(pObj1)->Level <= Ivy_Regular(pObj2)->Level )
break;
vStore->pArray[i ] = pObj2;
@@ -402,3 +405,5 @@ void Ivy_NodeBalancePushUniqueOrderByLevel( Vec_Ptr_t * vStore, Ivy_Obj_t * pObj
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ivy/ivyCanon.c b/src/aig/ivy/ivyCanon.c
index db5918de..34ed781f 100644
--- a/src/aig/ivy/ivyCanon.c
+++ b/src/aig/ivy/ivyCanon.c
@@ -20,6 +20,9 @@
#include "ivy.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -142,3 +145,5 @@ Ivy_Obj_t * Ivy_CanonLatch( Ivy_Man_t * p, Ivy_Obj_t * pObj, Ivy_Init_t Init )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ivy/ivyCheck.c b/src/aig/ivy/ivyCheck.c
index 55448f19..c924e2d0 100644
--- a/src/aig/ivy/ivyCheck.c
+++ b/src/aig/ivy/ivyCheck.c
@@ -20,6 +20,9 @@
#include "ivy.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -271,3 +274,5 @@ int Ivy_ManCheckChoices( Ivy_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ivy/ivyCut.c b/src/aig/ivy/ivyCut.c
index e3651645..d5a31dee 100644
--- a/src/aig/ivy/ivyCut.c
+++ b/src/aig/ivy/ivyCut.c
@@ -20,6 +20,9 @@
#include "ivy.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -332,7 +335,7 @@ int Ivy_ManFindBoolCut( Ivy_Man_t * p, Ivy_Obj_t * pRoot, Vec_Ptr_t * vFront, Ve
while ( 1 )
{
// find the next node to expand on this level
- Vec_PtrForEachEntry( vFront, pObj, k )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vFront, pObj, k )
if ( (int)pObj->Level == Lev )
break;
if ( k == Vec_PtrSize(vFront) )
@@ -399,11 +402,11 @@ int Ivy_ManFindBoolCut( Ivy_Man_t * p, Ivy_Obj_t * pRoot, Vec_Ptr_t * vFront, Ve
if ( pFaninC && !pFaninC->fMarkA && !pFaninC->fMarkB )
Vec_PtrPush( vFront, pFaninC );
// clean the markings
- Vec_PtrForEachEntry( vVolume, pObj, k )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vVolume, pObj, k )
pObj->fMarkA = pObj->fMarkB = 0;
// mark the nodes on the frontier (including the pivot)
- Vec_PtrForEachEntry( vFront, pObj, k )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vFront, pObj, k )
pObj->fMarkA = 1;
// cut exists, collect all the nodes on the shortest path to the pivot
Vec_PtrClear( vLeaves );
@@ -411,16 +414,16 @@ int Ivy_ManFindBoolCut( Ivy_Man_t * p, Ivy_Obj_t * pRoot, Vec_Ptr_t * vFront, Ve
RetValue = Ivy_ManFindBoolCut_rec( p, pRoot, vLeaves, vVolume, pPivot );
assert( RetValue == 1 );
// unmark the nodes on the frontier (including the pivot)
- Vec_PtrForEachEntry( vFront, pObj, k )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vFront, pObj, k )
pObj->fMarkA = 0;
// mark the nodes in the volume
- Vec_PtrForEachEntry( vVolume, pObj, k )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vVolume, pObj, k )
pObj->fMarkA = 1;
// expand the cut without increasing its size
while ( 1 )
{
- Vec_PtrForEachEntry( vLeaves, pObj, k )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vLeaves, pObj, k )
if ( Ivy_ManFindBoolCutCost(pObj) < 2 )
break;
if ( k == Vec_PtrSize(vLeaves) )
@@ -448,7 +451,7 @@ int Ivy_ManFindBoolCut( Ivy_Man_t * p, Ivy_Obj_t * pRoot, Vec_Ptr_t * vFront, Ve
}
}
// unmark the nodes in the volume
- Vec_PtrForEachEntry( vVolume, pObj, k )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vVolume, pObj, k )
pObj->fMarkA = 0;
return 1;
}
@@ -491,7 +494,7 @@ void Ivy_ManTestCutsBool( Ivy_Man_t * p )
printf( "%d ", Vec_PtrSize(vLeaves) );
/*
printf( "( " );
- Vec_PtrForEachEntry( vFront, pTemp, k )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vFront, pTemp, k )
printf( "%d ", Ivy_ObjRefs(Ivy_Regular(pTemp)) );
printf( ")\n" );
*/
@@ -988,3 +991,5 @@ void Ivy_ManTestCutsAll( Ivy_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ivy/ivyCutTrav.c b/src/aig/ivy/ivyCutTrav.c
index a52bbcf9..3cdca141 100644
--- a/src/aig/ivy/ivyCutTrav.c
+++ b/src/aig/ivy/ivyCutTrav.c
@@ -20,6 +20,9 @@
#include "ivy.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -70,7 +73,7 @@ Ivy_Store_t * Ivy_NodeFindCutsTravAll( Ivy_Man_t * p, Ivy_Obj_t * pObj, int nLea
// set elementary cuts for the leaves
nWords = Extra_BitWordNum( nNodes );
- Vec_PtrForEachEntry( vFront, pLeaf, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vFront, pLeaf, i )
{
assert( Ivy_ObjTravId(pLeaf) < nNodes );
// get the new bitcut
@@ -80,10 +83,10 @@ Ivy_Store_t * Ivy_NodeFindCutsTravAll( Ivy_Man_t * p, Ivy_Obj_t * pObj, int nLea
}
// compute the cuts for each node
- Vec_PtrForEachEntry( vNodes, pLeaf, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vNodes, pLeaf, i )
{
// skip the leaves
- vCuts = Vec_VecEntry( vBitCuts, Ivy_ObjTravId(pLeaf) );
+ vCuts = (Vec_Ptr_t *)Vec_VecEntry( vBitCuts, Ivy_ObjTravId(pLeaf) );
if ( Vec_PtrSize(vCuts) > 0 )
continue;
// add elementary cut
@@ -91,8 +94,8 @@ Ivy_Store_t * Ivy_NodeFindCutsTravAll( Ivy_Man_t * p, Ivy_Obj_t * pObj, int nLea
// set it as the cut of this leaf
Vec_VecPush( vBitCuts, Ivy_ObjTravId(pLeaf), pBitCut );
// get the fanin cuts
- vCuts0 = Vec_VecEntry( vBitCuts, Ivy_ObjTravId( Ivy_ObjFanin0(pLeaf) ) );
- vCuts1 = Vec_VecEntry( vBitCuts, Ivy_ObjTravId( Ivy_ObjFanin1(pLeaf) ) );
+ vCuts0 = (Vec_Ptr_t *)Vec_VecEntry( vBitCuts, Ivy_ObjTravId( Ivy_ObjFanin0(pLeaf) ) );
+ vCuts1 = (Vec_Ptr_t *)Vec_VecEntry( vBitCuts, Ivy_ObjTravId( Ivy_ObjFanin1(pLeaf) ) );
assert( Vec_PtrSize(vCuts0) > 0 );
assert( Vec_PtrSize(vCuts1) > 0 );
// merge the cuts
@@ -103,8 +106,8 @@ Ivy_Store_t * Ivy_NodeFindCutsTravAll( Ivy_Man_t * p, Ivy_Obj_t * pObj, int nLea
pCutStore->nCuts = 0;
pCutStore->nCutsMax = IVY_CUT_LIMIT;
// collect the cuts of the root node
- vCuts = Vec_VecEntry( vBitCuts, Ivy_ObjTravId(pObj) );
- Vec_PtrForEachEntry( vCuts, pBitCut, i )
+ vCuts = (Vec_Ptr_t *)Vec_VecEntry( vBitCuts, Ivy_ObjTravId(pObj) );
+ Vec_PtrForEachEntry( unsigned *, vCuts, pBitCut, i )
{
pCut = pCutStore->pCuts + pCutStore->nCuts++;
pCut->nSize = 0;
@@ -112,14 +115,14 @@ Ivy_Store_t * Ivy_NodeFindCutsTravAll( Ivy_Man_t * p, Ivy_Obj_t * pObj, int nLea
pCut->uHash = 0;
for ( k = 0; k < nNodes; k++ )
if ( Extra_TruthHasBit(pBitCut, k) )
- pCut->pArray[ pCut->nSize++ ] = Ivy_ObjId( Vec_PtrEntry(vNodes, k) );
+ pCut->pArray[ pCut->nSize++ ] = Ivy_ObjId( (Ivy_Obj_t *)Vec_PtrEntry(vNodes, k) );
assert( pCut->nSize <= nLeaves );
if ( pCutStore->nCuts == pCutStore->nCutsMax )
break;
}
// clean the travIds
- Vec_PtrForEachEntry( vNodes, pLeaf, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vNodes, pLeaf, i )
pLeaf->TravId = 0;
return pCutStore;
}
@@ -228,7 +231,7 @@ void Ivy_NodeComputeVolume( Ivy_Obj_t * pObj, int nNodeLimit, Vec_Ptr_t * vNodes
Ivy_NodeComputeVolumeTrav2_rec( pObj, vFront );
// find the fanins that are not marked
Vec_PtrClear( vNodes );
- Vec_PtrForEachEntry( vFront, pTemp, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vFront, pTemp, i )
{
pFanin = Ivy_ObjFanin0(pTemp);
if ( !pFanin->fMarkA )
@@ -246,17 +249,17 @@ void Ivy_NodeComputeVolume( Ivy_Obj_t * pObj, int nNodeLimit, Vec_Ptr_t * vNodes
// remember the number of nodes in the frontier
nNodes = Vec_PtrSize( vNodes );
// add the remaining nodes
- Vec_PtrForEachEntry( vFront, pTemp, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vFront, pTemp, i )
Vec_PtrPush( vNodes, pTemp );
// unmark the nodes
- Vec_PtrForEachEntry( vNodes, pTemp, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vNodes, pTemp, i )
{
pTemp->fMarkA = 0;
pTemp->TravId = i;
}
// collect the frontier nodes
Vec_PtrClear( vFront );
- Vec_PtrForEachEntryStop( vNodes, pTemp, i, nNodes )
+ Vec_PtrForEachEntryStop( Ivy_Obj_t *, vNodes, pTemp, i, nNodes )
Vec_PtrPush( vFront, pTemp );
// printf( "%d ", Vec_PtrSize(vNodes) );
}
@@ -289,7 +292,7 @@ void Ivy_NodeComputeVolume2( Ivy_Obj_t * pObj, int nNodeLimit, Vec_Ptr_t * vNode
do {
// get the node to expand
pPivot = NULL;
- Vec_PtrForEachEntryReverse( vFront, pLeaf, i )
+ Vec_PtrForEachEntryReverse( Ivy_Obj_t *, vFront, pLeaf, i )
{
if ( (int)pLeaf->Level == LevelMax )
{
@@ -326,14 +329,14 @@ void Ivy_NodeComputeVolume2( Ivy_Obj_t * pObj, int nNodeLimit, Vec_Ptr_t * vNode
} while ( Vec_PtrSize(vNodes) < nNodeLimit );
// sort nodes by level
- Vec_PtrSort( vNodes, Ivy_CompareNodesByLevel );
+ Vec_PtrSort( vNodes, (int (*)(void))Ivy_CompareNodesByLevel );
// make sure the nodes are ordered in the increasing number of levels
- pFanin = Vec_PtrEntry( vNodes, 0 );
- pPivot = Vec_PtrEntryLast( vNodes );
+ pFanin = (Ivy_Obj_t *)Vec_PtrEntry( vNodes, 0 );
+ pPivot = (Ivy_Obj_t *)Vec_PtrEntryLast( vNodes );
assert( pFanin->Level <= pPivot->Level );
// clean the marks and remember node numbers in the TravId
- Vec_PtrForEachEntry( vNodes, pFanin, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vNodes, pFanin, i )
{
pFanin->fMarkA = 0;
pFanin->TravId = i;
@@ -383,8 +386,8 @@ void Ivy_NodeFindCutsMerge( Vec_Ptr_t * vCuts0, Vec_Ptr_t * vCuts1, Vec_Ptr_t *
unsigned * pBitCut, * pBitCut0, * pBitCut1, * pBitCutTest;
int i, k, c, w, Counter;
// iterate through the cut pairs
- Vec_PtrForEachEntry( vCuts0, pBitCut0, i )
- Vec_PtrForEachEntry( vCuts1, pBitCut1, k )
+ Vec_PtrForEachEntry( unsigned *, vCuts0, pBitCut0, i )
+ Vec_PtrForEachEntry( unsigned *, vCuts1, pBitCut1, k )
{
// skip infeasible cuts
Counter = 0;
@@ -401,7 +404,7 @@ void Ivy_NodeFindCutsMerge( Vec_Ptr_t * vCuts0, Vec_Ptr_t * vCuts1, Vec_Ptr_t *
Extra_TruthOrWords( pBitCutTest, pBitCut0, pBitCut1, nWords );
// filter contained cuts; try to find containing cut
w = 0;
- Vec_PtrForEachEntry( vCuts, pBitCut, c )
+ Vec_PtrForEachEntry( unsigned *, vCuts, pBitCut, c )
{
if ( Extra_TruthIsImplyWords( pBitCut, pBitCutTest, nWords ) )
break;
@@ -471,3 +474,5 @@ void Ivy_ManTestCutsTravAll( Ivy_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ivy/ivyDfs.c b/src/aig/ivy/ivyDfs.c
index 9594c0d2..611dd854 100644
--- a/src/aig/ivy/ivyDfs.c
+++ b/src/aig/ivy/ivyDfs.c
@@ -20,6 +20,9 @@
#include "ivy.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -196,14 +199,14 @@ void Ivy_ManCollectCone( Ivy_Obj_t * pObj, Vec_Ptr_t * vFront, Vec_Ptr_t * vCone
assert( !Ivy_IsComplement(pObj) );
assert( Ivy_ObjIsNode(pObj) );
// mark the nodes
- Vec_PtrForEachEntry( vFront, pTemp, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vFront, pTemp, i )
Ivy_Regular(pTemp)->fMarkA = 1;
assert( pObj->fMarkA == 0 );
// collect the cone
Vec_PtrClear( vCone );
Ivy_ManCollectCone_rec( pObj, vCone );
// unmark the nodes
- Vec_PtrForEachEntry( vFront, pTemp, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vFront, pTemp, i )
Ivy_Regular(pTemp)->fMarkA = 0;
}
@@ -255,7 +258,7 @@ Vec_Int_t * Ivy_ManRequiredLevels( Ivy_Man_t * p )
vLevelsR = Vec_IntStart( Ivy_ManObjIdMax(p) + 1 );
// iterate through the nodes in the reverse order
vNodes = Ivy_ManLevelize( p );
- Vec_VecForEachEntryReverseReverse( vNodes, pObj, i, k )
+ Vec_VecForEachEntryReverseReverse( Ivy_Obj_t *, vNodes, pObj, i, k )
{
Level = Vec_IntEntry( vLevelsR, pObj->Id ) + 1 + Ivy_ObjIsExor(pObj);
if ( Vec_IntEntry( vLevelsR, Ivy_ObjFaninId0(pObj) ) < Level )
@@ -491,3 +494,5 @@ int Ivy_ManSetLevels( Ivy_Man_t * p, int fHaig )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ivy/ivyDsd.c b/src/aig/ivy/ivyDsd.c
index 3b8a2e68..71c4863a 100644
--- a/src/aig/ivy/ivyDsd.c
+++ b/src/aig/ivy/ivyDsd.c
@@ -20,6 +20,9 @@
#include "ivy.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -50,9 +53,13 @@ struct Ivy_Dec_t_
unsigned Fan5 : 4; // fanin 5
};
-static inline int Ivy_DecToInt( Ivy_Dec_t Node ) { return *((int *)&Node); }
-static inline Ivy_Dec_t Ivy_IntToDec( int Node ) { return *((Ivy_Dec_t *)&Node); }
-static inline void Ivy_DecClear( Ivy_Dec_t * pNode ) { *((int *)pNode) = 0; }
+static inline int Ivy_DecToInt( Ivy_Dec_t m ) { union { Ivy_Dec_t x; int y; } v; v.x = m; return v.y; }
+static inline Ivy_Dec_t Ivy_IntToDec( int m ) { union { Ivy_Dec_t x; int y; } v; v.y = m; return v.x; }
+static inline void Ivy_DecClear( Ivy_Dec_t * pNode ) { *pNode = Ivy_IntToDec(0); }
+
+//static inline int Ivy_DecToInt( Ivy_Dec_t Node ) { return *((int *)&Node); }
+//static inline Ivy_Dec_t Ivy_IntToDec( int Node ) { return *((Ivy_Dec_t *)&Node); }
+//static inline void Ivy_DecClear( Ivy_Dec_t * pNode ) { *((int *)pNode) = 0; }
static unsigned s_Masks[6][2] = {
@@ -817,3 +824,5 @@ void Ivy_TruthTest5()
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ivy/ivyFanout.c b/src/aig/ivy/ivyFanout.c
index 3930186a..9ff4f4bc 100644
--- a/src/aig/ivy/ivyFanout.c
+++ b/src/aig/ivy/ivyFanout.c
@@ -20,6 +20,9 @@
#include "ivy.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -307,3 +310,5 @@ int Ivy_ObjFanoutNum( Ivy_Man_t * p, Ivy_Obj_t * pObj )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ivy/ivyFastMap.c b/src/aig/ivy/ivyFastMap.c
index 0c0102c0..05db377d 100644
--- a/src/aig/ivy/ivyFastMap.c
+++ b/src/aig/ivy/ivyFastMap.c
@@ -20,6 +20,9 @@
#include "ivy.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -168,7 +171,7 @@ clk = clock();
{
Vec_Ptr_t * vNodes;
vNodes = Vec_PtrAlloc( 100 );
- Vec_VecForEachEntry( pMan->vLuts, pObj, i, k )
+ Vec_VecForEachEntry( Ivy_Obj_t *, pMan->vLuts, pObj, i, k )
Vec_PtrPush( vNodes, pObj );
Ivy_ManShow( pAig, 0, vNodes );
Vec_PtrFree( vNodes );
@@ -189,7 +192,7 @@ clk = clock();
***********************************************************************/
void Ivy_FastMapStop( Ivy_Man_t * pAig )
{
- Ivy_SuppMan_t * p = pAig->pData;
+ Ivy_SuppMan_t * p = (Ivy_SuppMan_t *)pAig->pData;
Vec_VecFree( p->vLuts );
ABC_FREE( p->pMem );
ABC_FREE( p );
@@ -886,7 +889,7 @@ void Ivy_FastMapRequired( Ivy_Man_t * pAig, int Delay, int fSetInter )
vLuts = ((Ivy_SuppMan_t *)pAig->pData)->vLuts;
// propagate the required times
Vec_VecForEachLevelReverse( vLuts, vNodes, i )
- Vec_PtrForEachEntry( vNodes, pObj, k )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vNodes, pObj, k )
{
pSupp = Ivy_ObjSupp( pAig, pObj );
assert( pSupp->nRefs > 0 );
@@ -911,7 +914,7 @@ void Ivy_FastMapRequired( Ivy_Man_t * pAig, int Delay, int fSetInter )
{
// set the required times of the intermediate nodes
Vec_VecForEachLevelReverse( vLuts, vNodes, i )
- Vec_PtrForEachEntry( vNodes, pObj, k )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vNodes, pObj, k )
{
pSupp = Ivy_ObjSupp( pAig, pObj );
Ivy_FastMapRequired_rec( pAig, pObj, pObj, pSupp->DelayR );
@@ -1117,7 +1120,7 @@ int Ivy_FastMapCutCost( Ivy_Man_t * pAig, Vec_Ptr_t * vFront )
Ivy_Supp_t * pSuppF;
Ivy_Obj_t * pFanin;
int i, Counter = 0;
- Vec_PtrForEachEntry( vFront, pFanin, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vFront, pFanin, i )
{
pSuppF = Ivy_ObjSupp( pAig, pFanin );
if ( pSuppF->nRefs == 0 )
@@ -1246,7 +1249,7 @@ int Ivy_FastMapNodeFaninCompact0( Ivy_Man_t * pAig, Ivy_Obj_t * pObj, int nLimit
{
Ivy_Obj_t * pFanin;
int i;
- Vec_PtrForEachEntry( vFront, pFanin, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vFront, pFanin, i )
{
if ( Ivy_ObjIsCi(pFanin) )
continue;
@@ -1276,7 +1279,7 @@ int Ivy_FastMapNodeFaninCompact1( Ivy_Man_t * pAig, Ivy_Obj_t * pObj, int nLimit
{
Ivy_Obj_t * pFanin;
int i;
- Vec_PtrForEachEntry( vFront, pFanin, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vFront, pFanin, i )
{
if ( Ivy_ObjIsCi(pFanin) )
continue;
@@ -1304,7 +1307,7 @@ int Ivy_FastMapNodeFaninCompact2( Ivy_Man_t * pAig, Ivy_Obj_t * pObj, int nLimit
{
Ivy_Obj_t * pFanin;
int i;
- Vec_PtrForEachEntry( vFront, pFanin, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vFront, pFanin, i )
{
if ( Ivy_ObjIsCi(pFanin) )
continue;
@@ -1409,7 +1412,7 @@ void Ivy_FastMapNodeUpdate( Ivy_Man_t * pAig, Ivy_Obj_t * pObj, Vec_Ptr_t * vFro
Ivy_FastMapNodeDeref( pAig, pObj );
// update the node's cut
pSupp->nSize = Vec_PtrSize(vFront);
- Vec_PtrForEachEntry( vFront, pFanin, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vFront, pFanin, i )
pSupp->pArray[i] = pFanin->Id;
// ref the new cut
Ivy_FastMapNodeRef( pAig, pObj );
@@ -1587,3 +1590,5 @@ void Ivy_FastMapNodeRecover4( Ivy_Man_t * pAig, Ivy_Obj_t * pObj, int nLimit, Ve
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ivy/ivyFraig.c b/src/aig/ivy/ivyFraig.c
index 68726501..77b64700 100644
--- a/src/aig/ivy/ivyFraig.c
+++ b/src/aig/ivy/ivyFraig.c
@@ -22,6 +22,8 @@
#include "extra.h"
#include "ivy.h"
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -249,7 +251,7 @@ void Ivy_FraigParamsDefault( Ivy_FraigParams_t * pParams )
***********************************************************************/
int Ivy_FraigProve( Ivy_Man_t ** ppManAig, void * pPars )
{
- Prove_Params_t * pParams = pPars;
+ Prove_Params_t * pParams = (Prove_Params_t *)pPars;
Ivy_FraigParams_t Params, * pIvyParams = &Params;
Ivy_Man_t * pManAig, * pManTemp;
int RetValue, nIter, clk;//, Counter;
@@ -1536,7 +1538,7 @@ void Ivy_FraigSavePattern( Ivy_FraigMan_t * p )
int i;
memset( p->pPatWords, 0, sizeof(unsigned) * p->nPatWords );
Ivy_ManForEachPi( p->pManFraig, pObj, i )
-// Vec_PtrForEachEntry( p->vPiVars, pObj, i )
+// Vec_PtrForEachEntry( Ivy_Obj_t *, p->vPiVars, pObj, i )
if ( p->pSat->model.ptr[Ivy_ObjSatNum(pObj)] == l_True )
Ivy_InfoSetBit( p->pPatWords, i );
// Ivy_InfoSetBit( p->pPatWords, pObj->Id - 1 );
@@ -1559,7 +1561,7 @@ void Ivy_FraigSavePattern2( Ivy_FraigMan_t * p )
int i;
memset( p->pPatWords, 0, sizeof(unsigned) * p->nPatWords );
// Ivy_ManForEachPi( p->pManFraig, pObj, i )
- Vec_PtrForEachEntry( p->vPiVars, pObj, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, p->vPiVars, pObj, i )
if ( p->pSat->model.ptr[Ivy_ObjSatNum(pObj)] == l_True )
// Ivy_InfoSetBit( p->pPatWords, i );
Ivy_InfoSetBit( p->pPatWords, pObj->Id - 1 );
@@ -1582,7 +1584,7 @@ void Ivy_FraigSavePattern3( Ivy_FraigMan_t * p )
int i;
for ( i = 0; i < p->nPatWords; i++ )
p->pPatWords[i] = Ivy_ObjRandomSim();
- Vec_PtrForEachEntry( p->vPiVars, pObj, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, p->vPiVars, pObj, i )
if ( Ivy_InfoHasBit( p->pPatWords, pObj->Id - 1 ) ^ (p->pSat->model.ptr[Ivy_ObjSatNum(pObj)] == l_True) )
Ivy_InfoXorBit( p->pPatWords, pObj->Id - 1 );
}
@@ -1820,12 +1822,14 @@ int Ivy_FraigMiterStatus( Ivy_Man_t * pMan )
CountConst0++;
continue;
}
+/*
// check if the output is a primary input
if ( Ivy_ObjIsPi(Ivy_Regular(pObjNew)) )
{
CountNonConst0++;
continue;
}
+*/
// check if the output can be constant 0
if ( Ivy_Regular(pObjNew)->fPhase != (unsigned)Ivy_IsComplement(pObjNew) )
{
@@ -2398,7 +2402,7 @@ void Ivy_FraigAddClausesSuper( Ivy_FraigMan_t * p, Ivy_Obj_t * pNode, Vec_Ptr_t
pLits = ABC_ALLOC( int, nLits );
// suppose AND-gate is A & B = C
// add !A => !C or A + !C
- Vec_PtrForEachEntry( vSuper, pFanin, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vSuper, pFanin, i )
{
pLits[0] = toLitCond(Ivy_ObjSatNum(Ivy_Regular(pFanin)), Ivy_IsComplement(pFanin));
pLits[1] = toLitCond(Ivy_ObjSatNum(pNode), 1);
@@ -2406,7 +2410,7 @@ void Ivy_FraigAddClausesSuper( Ivy_FraigMan_t * p, Ivy_Obj_t * pNode, Vec_Ptr_t
assert( RetValue );
}
// add A & B => C or !A + !B + C
- Vec_PtrForEachEntry( vSuper, pFanin, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vSuper, pFanin, i )
pLits[i] = toLitCond(Ivy_ObjSatNum(Ivy_Regular(pFanin)), !Ivy_IsComplement(pFanin));
pLits[nLits-1] = toLitCond(Ivy_ObjSatNum(pNode), 0);
RetValue = sat_solver_addclause( p->pSat, pLits, pLits + nLits );
@@ -2511,7 +2515,7 @@ void Ivy_FraigNodeAddToSolver( Ivy_FraigMan_t * p, Ivy_Obj_t * pOld, Ivy_Obj_t *
if ( pOld ) Ivy_FraigObjAddToFrontier( p, pOld, vFrontier );
if ( pNew ) Ivy_FraigObjAddToFrontier( p, pNew, vFrontier );
// explore nodes in the frontier
- Vec_PtrForEachEntry( vFrontier, pNode, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vFrontier, pNode, i )
{
// create the supergate
assert( Ivy_ObjSatNum(pNode) );
@@ -2523,14 +2527,14 @@ void Ivy_FraigNodeAddToSolver( Ivy_FraigMan_t * p, Ivy_Obj_t * pOld, Ivy_Obj_t *
Vec_PtrPushUnique( vFanins, Ivy_ObjFanin0( Ivy_ObjFanin1(pNode) ) );
Vec_PtrPushUnique( vFanins, Ivy_ObjFanin1( Ivy_ObjFanin0(pNode) ) );
Vec_PtrPushUnique( vFanins, Ivy_ObjFanin1( Ivy_ObjFanin1(pNode) ) );
- Vec_PtrForEachEntry( vFanins, pFanin, k )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vFanins, pFanin, k )
Ivy_FraigObjAddToFrontier( p, Ivy_Regular(pFanin), vFrontier );
Ivy_FraigAddClausesMux( p, pNode );
}
else
{
vFanins = Ivy_FraigCollectSuper( pNode, fUseMuxes );
- Vec_PtrForEachEntry( vFanins, pFanin, k )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vFanins, pFanin, k )
Ivy_FraigObjAddToFrontier( p, Ivy_Regular(pFanin), vFrontier );
Ivy_FraigAddClausesSuper( p, pNode, vFanins );
}
@@ -2572,7 +2576,7 @@ int Ivy_FraigSetActivityFactors_rec( Ivy_FraigMan_t * p, Ivy_Obj_t * pObj, int L
veci_push(&p->pSat->act_vars, Ivy_ObjSatNum(pObj));
// explore the fanins
vFanins = Ivy_ObjFaninVec( pObj );
- Vec_PtrForEachEntry( vFanins, pFanin, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vFanins, pFanin, i )
Counter += Ivy_FraigSetActivityFactors_rec( p, Ivy_Regular(pFanin), LevelMin, LevelMax );
return 1 + Counter;
}
@@ -2611,10 +2615,13 @@ p->timeTrav += clock() - clk;
return 1;
}
-
+ABC_NAMESPACE_IMPL_END
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/**Function*************************************************************
Synopsis [Checks equivalence using BDDs.]
@@ -2635,7 +2642,7 @@ DdNode * Ivy_FraigNodesAreEquivBdd_int( DdManager * dd, DdNode * bFunc, Vec_Ptr_
int i, NewSize;
// create new frontier
vTemp = Vec_PtrAlloc( 100 );
- Vec_PtrForEachEntry( vFront, pObj, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vFront, pObj, i )
{
if ( (int)pObj->Level != Level )
{
@@ -2664,7 +2671,7 @@ DdNode * Ivy_FraigNodesAreEquivBdd_int( DdManager * dd, DdNode * bFunc, Vec_Ptr_
// collect the permutation
NewSize = IVY_MAX(dd->size, Vec_PtrSize(vTemp));
pFuncs = ABC_ALLOC( DdNode *, NewSize );
- Vec_PtrForEachEntry( vFront, pObj, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vFront, pObj, i )
{
if ( (int)pObj->Level != Level )
pFuncs[i] = Cudd_bddIthVar( dd, pObj->TravId );
@@ -2685,7 +2692,7 @@ DdNode * Ivy_FraigNodesAreEquivBdd_int( DdManager * dd, DdNode * bFunc, Vec_Ptr_
// create new
bFuncNew = Cudd_bddVectorCompose( dd, bFunc, pFuncs ); Cudd_Ref( bFuncNew );
// clean trav Id
- Vec_PtrForEachEntry( vTemp, pObj, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vTemp, pObj, i )
{
pObj->fMarkB = 0;
pObj->TravId = 0;
@@ -2739,7 +2746,7 @@ int Ivy_FraigNodesAreEquivBdd( Ivy_Obj_t * pObj1, Ivy_Obj_t * pObj2 )
{
// find max level
Level = 0;
- Vec_PtrForEachEntry( vFront, pObj, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vFront, pObj, i )
if ( Level < (int)pObj->Level )
Level = (int)pObj->Level;
if ( Level == 0 )
@@ -2771,3 +2778,5 @@ int Ivy_FraigNodesAreEquivBdd( Ivy_Obj_t * pObj1, Ivy_Obj_t * pObj2 )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ivy/ivyHaig.c b/src/aig/ivy/ivyHaig.c
index 87021600..a4fda7d8 100644
--- a/src/aig/ivy/ivyHaig.c
+++ b/src/aig/ivy/ivyHaig.c
@@ -20,6 +20,9 @@
#include "ivy.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -158,7 +161,7 @@ void Ivy_ManHaigStop( Ivy_Man_t * p )
Ivy_Obj_t * pObj;
int i;
assert( p->pHaig != NULL );
- Vec_IntFree( p->pHaig->pData );
+ Vec_IntFree( (Vec_Int_t *)p->pHaig->pData );
Ivy_ManStop( p->pHaig );
p->pHaig = NULL;
// remove dangling pointers to the HAIG objects
@@ -189,7 +192,7 @@ void Ivy_ManHaigCreateObj( Ivy_Man_t * p, Ivy_Obj_t * pObj )
// pObj->pEquiv = Ivy_Latch( p->pHaig, Ivy_ObjChild0Equiv(pObj), pObj->Init );
pEquiv0 = Ivy_ObjChild0Equiv(pObj);
pEquiv0 = Ivy_NotCond( Ivy_HaigObjRepr(Ivy_Regular(pEquiv0)), Ivy_IsComplement(pEquiv0) );
- pObj->pEquiv = Ivy_Latch( p->pHaig, pEquiv0, pObj->Init );
+ pObj->pEquiv = Ivy_Latch( p->pHaig, pEquiv0, (Ivy_Init_t)pObj->Init );
}
else if ( Ivy_ObjType(pObj) == IVY_AND )
{
@@ -469,7 +472,7 @@ printf( "Collected node %d with fanins %d and %d\n", pObj->Id, Ivy_ObjFanin0(pOb
Ivy_ManForEachNodeVec( p, vLatches, pObj, i )
pObj->Init = IVY_INIT_DC;
// set the latches of D to be determinate
- vLatchesD = p->pData;
+ vLatchesD = (Vec_Int_t *)p->pData;
Ivy_ManForEachNodeVec( p, vLatchesD, pObj, i )
pObj->Init = IVY_INIT_0;
@@ -487,21 +490,21 @@ printf( "Collected node %d with fanins %d and %d\n", pObj->Id, Ivy_ObjFanin0(pOb
{
if ( fVerbose )
printf( "Processing node %d with fanins %d and %d\n", pObj->Id, Ivy_ObjFanin0(pObj)->Id, Ivy_ObjFanin1(pObj)->Id );
- In0 = Ivy_InitNotCond( Ivy_ObjFanin0(pObj)->Init, Ivy_ObjFaninC0(pObj) );
- In1 = Ivy_InitNotCond( Ivy_ObjFanin1(pObj)->Init, Ivy_ObjFaninC1(pObj) );
+ In0 = Ivy_InitNotCond( (Ivy_Init_t)Ivy_ObjFanin0(pObj)->Init, Ivy_ObjFaninC0(pObj) );
+ In1 = Ivy_InitNotCond( (Ivy_Init_t)Ivy_ObjFanin1(pObj)->Init, Ivy_ObjFaninC1(pObj) );
pObj->Init = Ivy_ManHaigSimulateAnd( In0, In1 );
// simulate the equivalence class if the node is a representative
if ( pObj->pEquiv && Ivy_ObjRefs(pObj) > 0 )
{
if ( fVerbose )
printf( "Processing choice node %d\n", pObj->Id );
- In0 = pObj->Init;
+ In0 = (Ivy_Init_t)pObj->Init;
assert( !Ivy_IsComplement(pObj->pEquiv) );
for ( pTemp = pObj->pEquiv; pTemp != pObj; pTemp = Ivy_Regular(pTemp->pEquiv) )
{
if ( fVerbose )
printf( "Processing secondary node %d\n", pTemp->Id );
- In1 = Ivy_InitNotCond( pTemp->Init, Ivy_IsComplement(pTemp->pEquiv) );
+ In1 = Ivy_InitNotCond( (Ivy_Init_t)pTemp->Init, Ivy_IsComplement(pTemp->pEquiv) );
In0 = Ivy_ManHaigSimulateChoice( In0, In1 );
}
pObj->Init = In0;
@@ -528,3 +531,5 @@ printf( "Using latch %d with fanin %d\n", pObj->Id, Ivy_ObjFanin0(pObj)->Id );
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ivy/ivyMan.c b/src/aig/ivy/ivyMan.c
index 909548d1..6fa34144 100644
--- a/src/aig/ivy/ivyMan.c
+++ b/src/aig/ivy/ivyMan.c
@@ -20,6 +20,9 @@
#include "ivy.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -333,10 +336,10 @@ int Ivy_ManCleanupSeq( Ivy_Man_t * p )
return 0;
}
// disconnect the marked objects
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vNodes, pObj, i )
Ivy_ObjDisconnect( p, pObj );
// remove the dangling objects
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vNodes, pObj, i )
{
assert( Ivy_ObjIsNode(pObj) || Ivy_ObjIsLatch(pObj) || Ivy_ObjIsBuf(pObj) );
assert( Ivy_ObjRefs(pObj) == 0 );
@@ -416,7 +419,7 @@ int Ivy_ManPropagateBuffers( Ivy_Man_t * p, int fUpdateLevel )
int nSteps;
for ( nSteps = 0; Vec_PtrSize(p->vBufs) > 0; nSteps++ )
{
- pNode = Vec_PtrEntryLast(p->vBufs);
+ pNode = (Ivy_Obj_t *)Vec_PtrEntryLast(p->vBufs);
while ( Ivy_ObjIsBuf(pNode) )
pNode = Ivy_ObjReadFirstFanout( p, pNode );
// check if this buffer should remain
@@ -494,7 +497,7 @@ void Ivy_ManMakeSeq( Ivy_Man_t * p, int nLatches, int * pInits )
for ( i = 0; i < nLatches; i++ )
{
// get the latch value
- Init = pInits? pInits[i] : IVY_INIT_0;
+ Init = pInits? (Ivy_Init_t)pInits[i] : IVY_INIT_0;
// create latch
pObj = Ivy_ManPo( p, Ivy_ManPoNum(p) - nLatches + i );
pLatch = Ivy_Latch( p, Ivy_ObjChild0(pObj), Init );
@@ -545,3 +548,5 @@ void Ivy_ManMakeSeq( Ivy_Man_t * p, int nLatches, int * pInits )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ivy/ivyMem.c b/src/aig/ivy/ivyMem.c
index 4ea6d891..d5e6e545 100644
--- a/src/aig/ivy/ivyMem.c
+++ b/src/aig/ivy/ivyMem.c
@@ -20,6 +20,9 @@
#include "ivy.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -64,7 +67,7 @@ void Ivy_ManStopMemory( Ivy_Man_t * p )
{
void * pMemory;
int i;
- Vec_PtrForEachEntry( p->vChunks, pMemory, i )
+ Vec_PtrForEachEntry( void *, p->vChunks, pMemory, i )
ABC_FREE( pMemory );
Vec_PtrFree( p->vChunks );
Vec_PtrFree( p->vPages );
@@ -114,3 +117,5 @@ void Ivy_ManAddMemory( Ivy_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ivy/ivyMulti.c b/src/aig/ivy/ivyMulti.c
index 882c2c87..c137a659 100644
--- a/src/aig/ivy/ivyMulti.c
+++ b/src/aig/ivy/ivyMulti.c
@@ -20,6 +20,9 @@
#include "ivy.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -74,7 +77,7 @@ int Ivy_MultiPlus( Ivy_Man_t * p, Vec_Ptr_t * vLeaves, Vec_Ptr_t * vCone, Ivy_Ty
// set the leaf entries
uMaskAll = ((1 << nLeaves) - 1);
nEvals = 0;
- Vec_PtrForEachEntry( vLeaves, pObj, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vLeaves, pObj, i )
{
pEval = pEvals + nEvals;
pEval->pArg = pObj;
@@ -86,7 +89,7 @@ int Ivy_MultiPlus( Ivy_Man_t * p, Vec_Ptr_t * vLeaves, Vec_Ptr_t * vCone, Ivy_Ty
}
// propagate masks through the cone
- Vec_PtrForEachEntry( vCone, pObj, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vCone, pObj, i )
{
pObj->TravId = nEvals + i;
if ( Ivy_ObjIsBuf(pObj) )
@@ -96,7 +99,7 @@ int Ivy_MultiPlus( Ivy_Man_t * p, Vec_Ptr_t * vLeaves, Vec_Ptr_t * vCone, Ivy_Ty
}
// set the internal entries
- Vec_PtrForEachEntry( vCone, pObj, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vCone, pObj, i )
{
if ( i == Vec_PtrSize(vCone) - 1 )
break;
@@ -129,7 +132,7 @@ int Ivy_MultiPlus( Ivy_Man_t * p, Vec_Ptr_t * vLeaves, Vec_Ptr_t * vCone, Ivy_Ty
continue;
// skip the leaves
for ( x = 0; x < nLeaves; x++ )
- if ( pTemp == Ivy_Regular(vLeaves->pArray[x]) )
+ if ( pTemp == Ivy_Regular((Ivy_Obj_t *)vLeaves->pArray[x]) )
break;
if ( x < nLeaves )
continue;
@@ -305,3 +308,5 @@ int Ivy_MultiCover( Ivy_Man_t * p, Ivy_Eva_t * pEvals, int nLeaves, int nEvals,
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ivy/ivyMulti8.c b/src/aig/ivy/ivyMulti8.c
index 059d1500..23af0e38 100644
--- a/src/aig/ivy/ivyMulti8.c
+++ b/src/aig/ivy/ivyMulti8.c
@@ -20,6 +20,9 @@
#include "ivy.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -425,3 +428,5 @@ Ivy_Obj_t * Ivy_Multi2( Ivy_Obj_t ** pArgs, int nArgs, Ivy_Type_t Type )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ivy/ivyObj.c b/src/aig/ivy/ivyObj.c
index 59dda19c..becf69d1 100644
--- a/src/aig/ivy/ivyObj.c
+++ b/src/aig/ivy/ivyObj.c
@@ -20,6 +20,9 @@
#include "ivy.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -474,3 +477,5 @@ void Ivy_NodeFixBufferFanins( Ivy_Man_t * p, Ivy_Obj_t * pNode, int fUpdateLevel
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ivy/ivyOper.c b/src/aig/ivy/ivyOper.c
index 8115ce4f..ea61924d 100644
--- a/src/aig/ivy/ivyOper.c
+++ b/src/aig/ivy/ivyOper.c
@@ -20,6 +20,9 @@
#include "ivy.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -265,7 +268,7 @@ Ivy_Obj_t * Ivy_Miter( Ivy_Man_t * p, Vec_Ptr_t * vPairs )
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] = Ivy_Not( Ivy_Exor( p, vPairs->pArray[i], vPairs->pArray[i+1] ) );
+ vPairs->pArray[i/2] = Ivy_Not( Ivy_Exor( p, (Ivy_Obj_t *)vPairs->pArray[i], (Ivy_Obj_t *)vPairs->pArray[i+1] ) );
vPairs->nSize = vPairs->nSize/2;
return Ivy_Not( Ivy_Multi_rec( p, (Ivy_Obj_t **)vPairs->pArray, vPairs->nSize, IVY_AND ) );
}
@@ -291,3 +294,5 @@ Ivy_Obj_t * Ivy_Latch( Ivy_Man_t * p, Ivy_Obj_t * pObj, Ivy_Init_t Init )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ivy/ivyResyn.c b/src/aig/ivy/ivyResyn.c
index 35ecb122..8d571110 100644
--- a/src/aig/ivy/ivyResyn.c
+++ b/src/aig/ivy/ivyResyn.c
@@ -20,6 +20,9 @@
#include "ivy.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -194,3 +197,5 @@ if ( fVerbose ) Ivy_ManPrintStats( pMan );
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ivy/ivyRwr.c b/src/aig/ivy/ivyRwr.c
index af425079..b7cb500c 100644
--- a/src/aig/ivy/ivyRwr.c
+++ b/src/aig/ivy/ivyRwr.c
@@ -22,6 +22,9 @@
#include "deco.h"
#include "rwt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -83,14 +86,14 @@ int Ivy_ManRewritePre( Ivy_Man_t * p, int fUpdateLevel, int fUseZeroCost, int fV
nGain = Ivy_NodeRewrite( p, pManRwt, pNode, fUpdateLevel, fUseZeroCost );
if ( nGain > 0 || (nGain == 0 && fUseZeroCost) )
{
- Dec_Graph_t * pGraph = Rwt_ManReadDecs(pManRwt);
+ Dec_Graph_t * pGraph = (Dec_Graph_t *)Rwt_ManReadDecs(pManRwt);
int fCompl = Rwt_ManReadCompl(pManRwt);
/*
{
Ivy_Obj_t * pObj;
int i;
printf( "USING: (" );
- Vec_PtrForEachEntry( Rwt_ManReadLeaves(pManRwt), pObj, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, Rwt_ManReadLeaves(pManRwt), pObj, i )
printf( "%d ", Ivy_ObjFanoutNum(Ivy_Regular(pObj)) );
printf( ") Gain = %d.\n", nGain );
}
@@ -208,18 +211,18 @@ p->timeTruth += clock() - clk2;
clk2 = clock();
/*
printf( "Considering: (" );
- Vec_PtrForEachEntry( p->vFaninsCur, pFanin, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, p->vFaninsCur, pFanin, i )
printf( "%d ", Ivy_ObjFanoutNum(Ivy_Regular(pFanin)) );
printf( ")\n" );
*/
// mark the fanin boundary
- Vec_PtrForEachEntry( p->vFaninsCur, pFanin, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, p->vFaninsCur, pFanin, i )
Ivy_ObjRefsInc( Ivy_Regular(pFanin) );
// label MFFC with current ID
Ivy_ManIncrementTravId( pMan );
nNodesSaved = Ivy_ObjMffcLabel( pMan, pNode );
// unmark the fanin boundary
- Vec_PtrForEachEntry( p->vFaninsCur, pFanin, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, p->vFaninsCur, pFanin, i )
Ivy_ObjRefsDec( Ivy_Regular(pFanin) );
p->timeMffc += clock() - clk2;
@@ -239,7 +242,7 @@ p->timeEval += clock() - clk2;
uTruthBest = uTruth;
// collect fanins in the
Vec_PtrClear( p->vFanins );
- Vec_PtrForEachEntry( p->vFaninsCur, pFanin, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, p->vFaninsCur, pFanin, i )
Vec_PtrPush( p->vFanins, pFanin );
}
}
@@ -257,7 +260,7 @@ p->timeRes += clock() - clk;
else
{
printf( "Node %d : ", pNode->Id );
- Vec_PtrForEachEntry( p->vFanins, pFanin, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, p->vFanins, pFanin, i )
printf( "%d ", Ivy_Regular(pFanin)->Id );
printf( "a" );
}
@@ -272,8 +275,8 @@ p->timeRes += clock() - clk;
*/
// copy the leaves
- Vec_PtrForEachEntry( p->vFanins, pFanin, i )
- Dec_GraphNode(p->pGraph, i)->pFunc = pFanin;
+ Vec_PtrForEachEntry( Ivy_Obj_t *, p->vFanins, pFanin, i )
+ Dec_GraphNode((Dec_Graph_t *)p->pGraph, i)->pFunc = pFanin;
p->nScores[p->pMap[uTruthBest]]++;
p->nNodesGained += GainBest;
@@ -288,7 +291,7 @@ p->timeRes += clock() - clk;
printf( "Save = %d. ", nNodesSaveCur );
printf( "Add = %d. ", nNodesSaveCur-GainBest );
printf( "GAIN = %d. ", GainBest );
- printf( "Cone = %d. ", p->pGraph? Dec_GraphNodeNum(p->pGraph) : 0 );
+ printf( "Cone = %d. ", p->pGraph? Dec_GraphNodeNum((Dec_Graph_t *)p->pGraph) : 0 );
printf( "Class = %d. ", p->pMap[uTruthBest] );
printf( "\n" );
}
@@ -363,16 +366,16 @@ Dec_Graph_t * Rwt_CutEvaluate( Ivy_Man_t * pMan, Rwt_Man_t * p, Ivy_Obj_t * pRoo
Rwt_Node_t * pNode, * pFanin;
int nNodesAdded, GainBest, i, k;
// find the matching class of subgraphs
- vSubgraphs = Vec_VecEntry( p->vClasses, p->pMap[uTruth] );
+ vSubgraphs = (Vec_Ptr_t *)Vec_VecEntry( p->vClasses, p->pMap[uTruth] );
p->nSubgraphs += vSubgraphs->nSize;
// determine the best subgraph
GainBest = -1;
- Vec_PtrForEachEntry( vSubgraphs, pNode, i )
+ Vec_PtrForEachEntry( Rwt_Node_t *, vSubgraphs, pNode, i )
{
// get the current graph
pGraphCur = (Dec_Graph_t *)pNode->pNext;
// copy the leaves
- Vec_PtrForEachEntry( vFaninsCur, pFanin, k )
+ Vec_PtrForEachEntry( Rwt_Node_t *, vFaninsCur, pFanin, k )
Dec_GraphNode(pGraphCur, k)->pFunc = pFanin;
// detect how many unlabeled nodes will be reused
nNodesAdded = Ivy_GraphToNetworkCount( pMan, pRoot, pGraphCur, nNodesSaved, LevelMax );
@@ -417,7 +420,7 @@ int Ivy_GraphToNetworkCount( Ivy_Man_t * p, Ivy_Obj_t * pRoot, Dec_Graph_t * pGr
return 0;
// set the levels of the leaves
Dec_GraphForEachLeaf( pGraph, pNode, i )
- pNode->Level = Ivy_Regular(pNode->pFunc)->Level;
+ pNode->Level = Ivy_Regular((Ivy_Obj_t *)pNode->pFunc)->Level;
// compute the AIG size after adding the internal nodes
Counter = 0;
Dec_GraphForEachNode( pGraph, pNode, i )
@@ -426,8 +429,8 @@ int Ivy_GraphToNetworkCount( Ivy_Man_t * p, Ivy_Obj_t * pRoot, Dec_Graph_t * pGr
pNode0 = Dec_GraphNode( pGraph, pNode->eEdge0.Node );
pNode1 = Dec_GraphNode( pGraph, pNode->eEdge1.Node );
// get the AIG nodes corresponding to the children
- pAnd0 = pNode0->pFunc;
- pAnd1 = pNode1->pFunc;
+ pAnd0 = (Ivy_Obj_t *)pNode0->pFunc;
+ pAnd1 = (Ivy_Obj_t *)pNode1->pFunc;
if ( pAnd0 && pAnd1 )
{
// if they are both present, find the resulting node
@@ -489,16 +492,16 @@ Ivy_Obj_t * Ivy_GraphToNetwork( Ivy_Man_t * p, Dec_Graph_t * pGraph )
return Ivy_NotCond( Ivy_ManConst1(p), Dec_GraphIsComplement(pGraph) );
// check for a literal
if ( Dec_GraphIsVar(pGraph) )
- return Ivy_NotCond( Dec_GraphVar(pGraph)->pFunc, Dec_GraphIsComplement(pGraph) );
+ return Ivy_NotCond( (Ivy_Obj_t *)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 = Ivy_NotCond( Dec_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl );
- pAnd1 = Ivy_NotCond( Dec_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl );
+ pAnd0 = Ivy_NotCond( (Ivy_Obj_t *)Dec_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl );
+ pAnd1 = Ivy_NotCond( (Ivy_Obj_t *)Dec_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl );
pNode->pFunc = Ivy_And( p, pAnd0, pAnd1 );
}
// complement the result if necessary
- return Ivy_NotCond( pNode->pFunc, Dec_GraphIsComplement(pGraph) );
+ return Ivy_NotCond( (Ivy_Obj_t *)pNode->pFunc, Dec_GraphIsComplement(pGraph) );
}
/**Function*************************************************************
@@ -561,7 +564,7 @@ void Ivy_GraphUpdateNetwork3( Ivy_Man_t * p, Ivy_Obj_t * pRoot, Dec_Graph_t * pG
//printf( "Before = %d. ", Ivy_ManNodeNum(p) );
// mark the cut
- Vec_PtrForEachEntry( ((Rwt_Man_t *)p->pData)->vFanins, pFanin, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, ((Rwt_Man_t *)p->pData)->vFanins, pFanin, i )
Ivy_ObjRefsInc( Ivy_Regular(pFanin) );
// deref the old cone
nRefsOld = pRoot->nRefs;
@@ -569,7 +572,7 @@ void Ivy_GraphUpdateNetwork3( Ivy_Man_t * p, Ivy_Obj_t * pRoot, Dec_Graph_t * pG
Ivy_ObjDelete_rec( p, pRoot, 0 );
pRoot->nRefs = nRefsOld;
// unmark the cut
- Vec_PtrForEachEntry( ((Rwt_Man_t *)p->pData)->vFanins, pFanin, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, ((Rwt_Man_t *)p->pData)->vFanins, pFanin, i )
Ivy_ObjRefsDec( Ivy_Regular(pFanin) );
//printf( "Deref = %d. ", Ivy_ManNodeNum(p) );
@@ -591,7 +594,7 @@ void Ivy_GraphUpdateNetwork3( Ivy_Man_t * p, Ivy_Obj_t * pRoot, Dec_Graph_t * pG
//printf( "Replace = %d. ", Ivy_ManNodeNum(p) );
// delete remaining dangling nodes
- Vec_PtrForEachEntry( ((Rwt_Man_t *)p->pData)->vFanins, pFanin, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, ((Rwt_Man_t *)p->pData)->vFanins, pFanin, i )
{
pFanin = Ivy_Regular(pFanin);
if ( !Ivy_ObjIsNone(pFanin) && Ivy_ObjRefs(pFanin) == 0 )
@@ -611,3 +614,5 @@ void Ivy_GraphUpdateNetwork3( Ivy_Man_t * p, Ivy_Obj_t * pRoot, Dec_Graph_t * pG
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ivy/ivyRwrAlg.c b/src/aig/ivy/ivyRwrAlg.c
index fc48deb0..ce605003 100644
--- a/src/aig/ivy/ivyRwrAlg.c
+++ b/src/aig/ivy/ivyRwrAlg.c
@@ -20,6 +20,9 @@
#include "ivy.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -136,7 +139,7 @@ Ivy_Obj_t * Ivy_NodeRewriteAlg( Ivy_Obj_t * pObj, Vec_Ptr_t * vFront, Vec_Ptr_t
/*
printf( "%d ", Vec_PtrSize(vFront) );
printf( "( " );
- Vec_PtrForEachEntry( vFront, pTemp, k )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vFront, pTemp, k )
printf( "%d ", Ivy_ObjRefs(Ivy_Regular(pTemp)) );
printf( ")\n" );
*/
@@ -147,7 +150,7 @@ Ivy_Obj_t * Ivy_NodeRewriteAlg( Ivy_Obj_t * pObj, Vec_Ptr_t * vFront, Vec_Ptr_t
Ivy_ManCollectCone( pObj, vLeaves, vCone );
// deref nodes in the cone
- Vec_PtrForEachEntry( vCone, pTemp, k )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vCone, pTemp, k )
{
Ivy_ObjRefsDec( Ivy_ObjFanin0(pTemp) );
Ivy_ObjRefsDec( Ivy_ObjFanin1(pTemp) );
@@ -155,27 +158,27 @@ Ivy_Obj_t * Ivy_NodeRewriteAlg( Ivy_Obj_t * pObj, Vec_Ptr_t * vFront, Vec_Ptr_t
}
// count the MFFC size
- Vec_PtrForEachEntry( vFront, pTemp, k )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vFront, pTemp, k )
Ivy_Regular(pTemp)->fMarkA = 1;
nMffc = Ivy_NodeCountMffc( pObj );
- Vec_PtrForEachEntry( vFront, pTemp, k )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vFront, pTemp, k )
Ivy_Regular(pTemp)->fMarkA = 0;
if ( fVerbose )
{
Counter = 0;
- Vec_PtrForEachEntry( vCone, pTemp, k )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vCone, pTemp, k )
Counter += (Ivy_ObjRefs(pTemp) > 0);
printf( "%5d : Leaves = %2d. Cone = %2d. ConeRef = %2d. Mffc = %d. Lev = %d. LevR = %d.\n",
pObj->Id, Vec_PtrSize(vFront), Vec_PtrSize(vCone), Counter-1, nMffc, Ivy_ObjLevel(pObj), LevelR );
}
/*
printf( "Leaves:" );
- Vec_PtrForEachEntry( vLeaves, pTemp, k )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vLeaves, pTemp, k )
printf( " %d%s", Ivy_Regular(pTemp)->Id, Ivy_IsComplement(pTemp)? "\'" : "" );
printf( "\n" );
printf( "Cone:\n" );
- Vec_PtrForEachEntry( vCone, pTemp, k )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vCone, pTemp, k )
printf( " %5d = %d%s %d%s\n", pTemp->Id,
Ivy_ObjFaninId0(pTemp), Ivy_ObjFaninC0(pTemp)? "\'" : "",
Ivy_ObjFaninId1(pTemp), Ivy_ObjFaninC1(pTemp)? "\'" : "" );
@@ -184,7 +187,7 @@ Ivy_Obj_t * Ivy_NodeRewriteAlg( Ivy_Obj_t * pObj, Vec_Ptr_t * vFront, Vec_Ptr_t
RetValue = Ivy_MultiPlus( vLeaves, vCone, Ivy_ObjType(pObj), nMffc + fUseZeroCost, vSols );
// ref nodes in the cone
- Vec_PtrForEachEntry( vCone, pTemp, k )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vCone, pTemp, k )
{
Ivy_ObjRefsInc( Ivy_ObjFanin0(pTemp) );
Ivy_ObjRefsInc( Ivy_ObjFanin1(pTemp) );
@@ -356,7 +359,7 @@ int Ivy_ManFindAlgCut( Ivy_Obj_t * pRoot, Vec_Ptr_t * vFront, Vec_Ptr_t * vLeave
Vec_PtrClear( vLeaves );
RetValue = Ivy_ManFindAlgCut_rec( pRoot, Ivy_ObjType(pRoot), vFront, vCone );
// clean the marks
- Vec_PtrForEachEntry( vCone, pObj, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vCone, pObj, i )
pObj->fMarkA = pObj->fMarkB = 0;
// quit if the same node is found in both polarities
if ( RetValue == -1 )
@@ -368,11 +371,11 @@ int Ivy_ManFindAlgCut( Ivy_Obj_t * pRoot, Vec_Ptr_t * vFront, Vec_Ptr_t * vLeave
if ( Vec_PtrSize(vFront) <= 2 )
return 1;
// sort the entries in increasing order
- Vec_PtrSort( vFront, Ivy_ManFindAlgCutCompare );
+ Vec_PtrSort( vFront, (int (*)(void))Ivy_ManFindAlgCutCompare );
// remove duplicates from vFront and save the nodes in vLeaves
pPrev = Vec_PtrEntry(vFront, 0);
Vec_PtrPush( vLeaves, pPrev );
- Vec_PtrForEachEntryStart( vFront, pObj, i, 1 )
+ Vec_PtrForEachEntryStart( Ivy_Obj_t *, vFront, pObj, i, 1 )
{
// compare current entry and the previous entry
if ( pObj == pPrev )
@@ -406,3 +409,5 @@ int Ivy_ManFindAlgCut( Ivy_Obj_t * pRoot, Vec_Ptr_t * vFront, Vec_Ptr_t * vLeave
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ivy/ivySeq.c b/src/aig/ivy/ivySeq.c
index 0971a548..69d05463 100644
--- a/src/aig/ivy/ivySeq.c
+++ b/src/aig/ivy/ivySeq.c
@@ -22,6 +22,9 @@
#include "deco.h"
#include "rwt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -93,7 +96,7 @@ int Ivy_ManRewriteSeq( Ivy_Man_t * p, int fUseZeroCost, int fVerbose )
nGain = Ivy_NodeRewriteSeq( p, pManRwt, pNode, fUseZeroCost );
if ( nGain > 0 || (nGain == 0 && fUseZeroCost) )
{
- Dec_Graph_t * pGraph = Rwt_ManReadDecs(pManRwt);
+ Dec_Graph_t * pGraph = (Dec_Graph_t *)Rwt_ManReadDecs(pManRwt);
int fCompl = Rwt_ManReadCompl(pManRwt);
// complement the FF if needed
clk = clock();
@@ -199,7 +202,7 @@ p->timeTruth += clock() - clk2;
}
clk2 = clock();
// mark the fanin boundary
- Vec_PtrForEachEntry( p->vFaninsCur, pFanin, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, p->vFaninsCur, pFanin, i )
Ivy_ObjRefsInc( Ivy_Regular(pFanin) );
// label MFFC with current ID
Ivy_ManIncrementTravId( pMan );
@@ -208,7 +211,7 @@ clk2 = clock();
// Ivy_ObjForEachFanout( pMan, pNode, vFanout, pFanout, i )
// Ivy_ObjSetTravIdCurrent( pMan, pFanout );
// unmark the fanin boundary
- Vec_PtrForEachEntry( p->vFaninsCur, pFanin, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, p->vFaninsCur, pFanin, i )
Ivy_ObjRefsDec( Ivy_Regular(pFanin) );
p->timeMffc += clock() - clk2;
@@ -231,7 +234,7 @@ p->timeEval += clock() - clk2;
uTruthBest = uTruth;
// collect fanins in the
Vec_PtrClear( p->vFanins );
- Vec_PtrForEachEntry( p->vFaninsCur, pFanin, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, p->vFaninsCur, pFanin, i )
Vec_PtrPush( p->vFanins, pFanin );
}
}
@@ -260,7 +263,7 @@ p->timeRes += clock() - clk;
// nMovesS++;
// copy the leaves
- Ivy_GraphPrepare( p->pGraph, p->pCut, p->vFanins, p->pPerm );
+ Ivy_GraphPrepare( (Dec_Graph_t *)p->pGraph, (Ivy_Cut_t *)p->pCut, p->vFanins, p->pPerm );
p->nScores[p->pMap[uTruthBest]]++;
p->nNodesGained += GainBest;
@@ -286,7 +289,7 @@ p->timeRes += clock() - clk;
printf( "Save = %d. ", nNodesSaveCur );
printf( "Add = %d. ", nNodesSaveCur-GainBest );
printf( "GAIN = %d. ", GainBest );
- printf( "Cone = %d. ", p->pGraph? Dec_GraphNodeNum(p->pGraph) : 0 );
+ printf( "Cone = %d. ", p->pGraph? Dec_GraphNodeNum((Dec_Graph_t *)p->pGraph) : 0 );
printf( "Class = %d. ", p->pMap[uTruthBest] );
printf( "\n" );
}
@@ -313,11 +316,11 @@ Dec_Graph_t * Rwt_CutEvaluateSeq( Ivy_Man_t * pMan, Rwt_Man_t * p, Ivy_Obj_t * p
Rwt_Node_t * pNode;
int nNodesAdded, GainBest, i;
// find the matching class of subgraphs
- vSubgraphs = Vec_VecEntry( p->vClasses, p->pMap[uTruth] );
+ vSubgraphs = (Vec_Ptr_t *)Vec_VecEntry( p->vClasses, p->pMap[uTruth] );
p->nSubgraphs += vSubgraphs->nSize;
// determine the best subgraph
GainBest = -1;
- Vec_PtrForEachEntry( vSubgraphs, pNode, i )
+ Vec_PtrForEachEntry( Rwt_Node_t *, vSubgraphs, pNode, i )
{
// get the current graph
pGraphCur = (Dec_Graph_t *)pNode->pNext;
@@ -325,7 +328,7 @@ Dec_Graph_t * Rwt_CutEvaluateSeq( Ivy_Man_t * pMan, Rwt_Man_t * p, Ivy_Obj_t * p
// if ( pRoot->Id == 8648 )
// Dec_GraphPrint( stdout, pGraphCur, NULL, NULL );
// copy the leaves
-// Vec_PtrForEachEntry( vFaninsCur, pFanin, k )
+// Vec_PtrForEachEntry( Ivy_Obj_t *, vFaninsCur, pFanin, k )
// Dec_GraphNode(pGraphCur, k)->pFunc = pFanin;
Ivy_GraphPrepare( pGraphCur, pCut, vFaninsCur, pPerm );
@@ -413,8 +416,8 @@ int Ivy_GraphToNetworkSeqCountSeq( Ivy_Man_t * p, Ivy_Obj_t * pRoot, Dec_Graph_t
pNode0 = Dec_GraphNode( pGraph, pNode->eEdge0.Node );
pNode1 = Dec_GraphNode( pGraph, pNode->eEdge1.Node );
// get the AIG nodes corresponding to the children
- pAnd0 = pNode0->pFunc;
- pAnd1 = pNode1->pFunc;
+ pAnd0 = (Ivy_Obj_t *)pNode0->pFunc;
+ pAnd1 = (Ivy_Obj_t *)pNode1->pFunc;
// skip the latches
for ( k = 0; pAnd0 && k < (int)pNode->nLat0; k++ )
{
@@ -486,14 +489,14 @@ Ivy_Obj_t * Ivy_GraphToNetworkSeq( Ivy_Man_t * p, Dec_Graph_t * pGraph )
pNode = Dec_GraphVar(pGraph);
// add the remaining latches
for ( k = 0; k < (int)pNode->nLat2; k++ )
- pNode->pFunc = Ivy_Latch( p, pNode->pFunc, IVY_INIT_DC );
- return Ivy_NotCond( pNode->pFunc, Dec_GraphIsComplement(pGraph) );
+ pNode->pFunc = Ivy_Latch( p, (Ivy_Obj_t *)pNode->pFunc, IVY_INIT_DC );
+ return Ivy_NotCond( (Ivy_Obj_t *)pNode->pFunc, Dec_GraphIsComplement(pGraph) );
}
// build the AIG nodes corresponding to the AND gates of the graph
Dec_GraphForEachNode( pGraph, pNode, i )
{
- pAnd0 = Ivy_NotCond( Dec_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl );
- pAnd1 = Ivy_NotCond( Dec_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl );
+ pAnd0 = Ivy_NotCond( (Ivy_Obj_t *)Dec_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl );
+ pAnd1 = Ivy_NotCond( (Ivy_Obj_t *)Dec_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl );
// add the latches
for ( k = 0; k < (int)pNode->nLat0; k++ )
pAnd0 = Ivy_Latch( p, pAnd0, IVY_INIT_DC );
@@ -504,9 +507,9 @@ Ivy_Obj_t * Ivy_GraphToNetworkSeq( Ivy_Man_t * p, Dec_Graph_t * pGraph )
}
// add the remaining latches
for ( k = 0; k < (int)pNode->nLat2; k++ )
- pNode->pFunc = Ivy_Latch( p, pNode->pFunc, IVY_INIT_DC );
+ pNode->pFunc = Ivy_Latch( p, (Ivy_Obj_t *)pNode->pFunc, IVY_INIT_DC );
// complement the result if necessary
- return Ivy_NotCond( pNode->pFunc, Dec_GraphIsComplement(pGraph) );
+ return Ivy_NotCond( (Ivy_Obj_t *)pNode->pFunc, Dec_GraphIsComplement(pGraph) );
}
/**Function*************************************************************
@@ -1135,3 +1138,5 @@ void Ivy_CutComputeAll( Ivy_Man_t * p, int nInputs )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ivy/ivyShow.c b/src/aig/ivy/ivyShow.c
index 4fac2709..3aa1e041 100644
--- a/src/aig/ivy/ivyShow.c
+++ b/src/aig/ivy/ivyShow.c
@@ -20,6 +20,9 @@
#include "ivy.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -94,7 +97,7 @@ void Ivy_WriteDotAig( Ivy_Man_t * pMan, char * pFileName, int fHaig, Vec_Ptr_t *
// mark the nodes
if ( vBold )
- Vec_PtrForEachEntry( vBold, pNode, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vBold, pNode, i )
pNode->fMarkB = 1;
// compute levels
@@ -326,7 +329,7 @@ void Ivy_WriteDotAig( Ivy_Man_t * pMan, char * pFileName, int fHaig, Vec_Ptr_t *
// unmark nodes
if ( vBold )
- Vec_PtrForEachEntry( vBold, pNode, i )
+ Vec_PtrForEachEntry( Ivy_Obj_t *, vBold, pNode, i )
pNode->fMarkB = 0;
}
@@ -336,3 +339,5 @@ void Ivy_WriteDotAig( Ivy_Man_t * pMan, char * pFileName, int fHaig, Vec_Ptr_t *
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ivy/ivyTable.c b/src/aig/ivy/ivyTable.c
index fdcc4bfb..0fe5c7ba 100644
--- a/src/aig/ivy/ivyTable.c
+++ b/src/aig/ivy/ivyTable.c
@@ -20,6 +20,9 @@
#include "ivy.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -299,3 +302,5 @@ unsigned int Cudd_PrimeAig( unsigned int p)
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ivy/ivyUtil.c b/src/aig/ivy/ivyUtil.c
index ab62a276..4df67517 100644
--- a/src/aig/ivy/ivyUtil.c
+++ b/src/aig/ivy/ivyUtil.c
@@ -20,6 +20,9 @@
#include "ivy.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -816,3 +819,5 @@ int Ivy_CutTruthPrint( Ivy_Man_t * p, Ivy_Cut_t * pCut, unsigned uTruth )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ivy/ivy_.c b/src/aig/ivy/ivy_.c
index 65689689..ccad8a46 100644
--- a/src/aig/ivy/ivy_.c
+++ b/src/aig/ivy/ivy_.c
@@ -20,6 +20,9 @@
#include "ivy.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -46,3 +49,5 @@
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/kit/cloud.c b/src/aig/kit/cloud.c
index dc57e2b7..fd372970 100644
--- a/src/aig/kit/cloud.c
+++ b/src/aig/kit/cloud.c
@@ -18,6 +18,9 @@
#include "cloud.h"
+ABC_NAMESPACE_IMPL_START
+
+
// the number of operators using cache
static int CacheOperNum = 4;
@@ -985,3 +988,5 @@ void Cloud_PrintHashTable( CloudManager * dd )
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/kit/cloud.h b/src/aig/kit/cloud.h
index 6f6a1eae..c48b55de 100644
--- a/src/aig/kit/cloud.h
+++ b/src/aig/kit/cloud.h
@@ -19,15 +19,18 @@
#ifndef __CLOUD_H__
#define __CLOUD_H__
+
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <time.h>
+
#include "abc_global.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
#ifdef _WIN32
#define inline __inline // compatible with MS VS 6.0
@@ -239,9 +242,11 @@ extern CloudNode * Cloud_bddOr( CloudManager * dd, CloudNode * f, CloudNode *
extern void Cloud_PrintInfo( CloudManager * dd );
extern void Cloud_PrintHashTable( CloudManager * dd );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/aig/kit/kit.h b/src/aig/kit/kit.h
index 3b564da5..f1075c2f 100644
--- a/src/aig/kit/kit.h
+++ b/src/aig/kit/kit.h
@@ -21,6 +21,7 @@
#ifndef __KIT_H__
#define __KIT_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -38,9 +39,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -197,8 +199,10 @@ static inline void Kit_SopWriteCube( Kit_Sop_t * cSop, unsigned uCube, i
static inline Kit_Edge_t Kit_EdgeCreate( int Node, int fCompl ) { Kit_Edge_t eEdge = { fCompl, Node }; return eEdge; }
static inline unsigned Kit_EdgeToInt( Kit_Edge_t eEdge ) { return (eEdge.Node << 1) | eEdge.fCompl; }
static inline Kit_Edge_t Kit_IntToEdge( unsigned Edge ) { return Kit_EdgeCreate( Edge >> 1, Edge & 1 ); }
-static inline unsigned Kit_EdgeToInt_( Kit_Edge_t eEdge ) { return *(unsigned *)&eEdge; }
-static inline Kit_Edge_t Kit_IntToEdge_( unsigned Edge ) { return *(Kit_Edge_t *)&Edge; }
+//static inline unsigned Kit_EdgeToInt_( Kit_Edge_t eEdge ) { return *(unsigned *)&eEdge; }
+//static inline Kit_Edge_t Kit_IntToEdge_( unsigned Edge ) { return *(Kit_Edge_t *)&Edge; }
+static inline unsigned Kit_EdgeToInt_( Kit_Edge_t m ) { union { Kit_Edge_t x; unsigned y; } v; v.x = m; return v.y; }
+static inline Kit_Edge_t Kit_IntToEdge_( unsigned m ) { union { Kit_Edge_t x; unsigned y; } v; v.y = m; return v.x; }
static inline int Kit_GraphIsConst( Kit_Graph_t * pGraph ) { return pGraph->fConst; }
static inline int Kit_GraphIsConst0( Kit_Graph_t * pGraph ) { return pGraph->fConst && pGraph->eRoot.fCompl; }
@@ -219,8 +223,12 @@ static inline Kit_Node_t * Kit_GraphNodeFanin0( Kit_Graph_t * pGraph, Kit_Node_t
static inline Kit_Node_t * Kit_GraphNodeFanin1( Kit_Graph_t * pGraph, Kit_Node_t * pNode ){ return Kit_GraphNodeIsVar(pGraph, pNode)? NULL : Kit_GraphNode(pGraph, pNode->eEdge1.Node); }
static inline int Kit_GraphRootLevel( Kit_Graph_t * pGraph ) { return Kit_GraphNode(pGraph, pGraph->eRoot.Node)->Level; }
-static inline int Kit_Float2Int( float Val ) { return *((int *)&Val); }
-static inline float Kit_Int2Float( int Num ) { return *((float *)&Num); }
+static inline int Kit_SuppIsMinBase( int Supp ) { return (Supp & (Supp+1)) == 0; }
+
+//static inline int Kit_Float2Int( float Val ) { return *((int *)&Val); }
+//static inline float Kit_Int2Float( int Num ) { return *((float *)&Num); }
+static inline int Kit_Float2Int( float Val ) { union { int x; float y; } v; v.y = Val; return v.x; }
+static inline float Kit_Int2Float( int Num ) { union { int x; float y; } v; v.x = Num; return v.y; }
static inline int Kit_BitWordNum( int nBits ) { return nBits/(8*sizeof(unsigned)) + ((nBits%(8*sizeof(unsigned))) > 0); }
static inline int Kit_TruthWordNum( int nVars ) { return nVars <= 5 ? 1 : (1 << (nVars - 5)); }
static inline unsigned Kit_BitMask( int nBits ) { assert( nBits <= 32 ); return ~((~(unsigned)0) << nBits); }
@@ -280,6 +288,14 @@ static inline int Kit_TruthIsEqual( unsigned * pIn0, unsigned * pIn1, int nVars
return 0;
return 1;
}
+static inline int Kit_TruthIsEqualWithCare( unsigned * pIn0, unsigned * pIn1, unsigned * pCare, int nVars )
+{
+ int w;
+ for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
+ if ( (pIn0[w] & pCare[w]) != (pIn1[w] & pCare[w]) )
+ return 0;
+ return 1;
+}
static inline int Kit_TruthIsOpposite( unsigned * pIn0, unsigned * pIn1, int nVars )
{
int w;
@@ -423,6 +439,30 @@ static inline void Kit_TruthAndPhase( unsigned * pOut, unsigned * pIn0, unsigned
pOut[w] = pIn0[w] & pIn1[w];
}
}
+static inline void Kit_TruthOrPhase( unsigned * pOut, unsigned * pIn0, unsigned * pIn1, int nVars, int fCompl0, int fCompl1 )
+{
+ int w;
+ if ( fCompl0 && fCompl1 )
+ {
+ for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
+ pOut[w] = ~(pIn0[w] & pIn1[w]);
+ }
+ else if ( fCompl0 && !fCompl1 )
+ {
+ for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
+ pOut[w] = ~pIn0[w] | pIn1[w];
+ }
+ else if ( !fCompl0 && fCompl1 )
+ {
+ for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
+ pOut[w] = pIn0[w] | ~pIn1[w];
+ }
+ else // if ( !fCompl0 && !fCompl1 )
+ {
+ for ( w = Kit_TruthWordNum(nVars)-1; w >= 0; w-- )
+ pOut[w] = pIn0[w] | pIn1[w];
+ }
+}
static inline void Kit_TruthMux( unsigned * pOut, unsigned * pIn0, unsigned * pIn1, unsigned * pCtrl, int nVars )
{
int w;
@@ -547,7 +587,10 @@ extern char * Kit_PlaStart( void * p, int nCubes, int nVars );
extern char * Kit_PlaCreateFromIsop( void * p, int nVars, Vec_Int_t * vCover );
extern void Kit_PlaToIsop( char * pSop, Vec_Int_t * vCover );
extern char * Kit_PlaStoreSop( void * p, char * pSop );
-extern ABC_DLL char * Kit_PlaFromTruth( void * p, unsigned * pTruth, int nVars, Vec_Int_t * vCover );
+extern char * Kit_PlaFromTruth( void * p, unsigned * pTruth, int nVars, Vec_Int_t * vCover );
+extern char * Kit_PlaFromTruthNew( unsigned * pTruth, int nVars, Vec_Int_t * vCover, Vec_Str_t * vStr );
+extern ABC_UINT64_T Kit_PlaToTruth6( char * pSop, int nVars );
+extern void Kit_PlaToTruth( char * pSop, int nVars, Vec_Ptr_t * vVars, unsigned * pTemp, unsigned * pTruth );
/*=== kitSop.c ==========================================================*/
extern void Kit_SopCreate( Kit_Sop_t * cResult, Vec_Int_t * vInput, int nVars, Vec_Int_t * vMemory );
extern void Kit_SopCreateInverse( Kit_Sop_t * cResult, Vec_Int_t * vInput, int nVars, Vec_Int_t * vMemory );
@@ -584,6 +627,8 @@ extern void Kit_TruthUniqueNew( unsigned * pRes, unsigned * pTruth, i
extern void Kit_TruthMuxVar( unsigned * pOut, unsigned * pCof0, unsigned * pCof1, int nVars, int iVar );
extern void Kit_TruthMuxVarPhase( unsigned * pOut, unsigned * pCof0, unsigned * pCof1, int nVars, int iVar, int fCompl0 );
extern void Kit_TruthChangePhase( unsigned * pTruth, int nVars, int iVar );
+extern int Kit_TruthVarsSymm( unsigned * pTruth, int nVars, int iVar0, int iVar1, unsigned * pCof0, unsigned * pCof1 );
+extern int Kit_TruthVarsAntiSymm( unsigned * pTruth, int nVars, int iVar0, int iVar1, unsigned * pCof0, unsigned * pCof1 );
extern int Kit_TruthMinCofSuppOverlap( unsigned * pTruth, int nVars, int * pVarMin );
extern int Kit_TruthBestCofVar( unsigned * pTruth, int nVars, unsigned * pCof0, unsigned * pCof1 );
extern void Kit_TruthCountOnesInCofs( unsigned * pTruth, int nVars, short * pStore );
@@ -592,10 +637,13 @@ extern void Kit_TruthCountOnesInCofsSlow( unsigned * pTruth, int nVar
extern unsigned Kit_TruthHash( unsigned * pIn, int nWords );
extern unsigned Kit_TruthSemiCanonicize( unsigned * pInOut, unsigned * pAux, int nVars, char * pCanonPerm, short * pStore );
extern char * Kit_TruthDumpToFile( unsigned * pTruth, int nVars, int nFile );
+extern void Kit_TruthPrintProfile( unsigned * pTruth, int nVars );
+
+
+
+ABC_NAMESPACE_HEADER_END
+
-#ifdef __cplusplus
-}
-#endif
#endif
diff --git a/src/aig/kit/kitAig.c b/src/aig/kit/kitAig.c
index 83012a8c..88f17fc2 100644
--- a/src/aig/kit/kitAig.c
+++ b/src/aig/kit/kitAig.c
@@ -21,6 +21,9 @@
#include "kit.h"
#include "aig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -50,16 +53,16 @@ Aig_Obj_t * Kit_GraphToAigInternal( Aig_Man_t * pMan, Kit_Graph_t * pGraph )
return Aig_NotCond( Aig_ManConst1(pMan), Kit_GraphIsComplement(pGraph) );
// check for a literal
if ( Kit_GraphIsVar(pGraph) )
- return Aig_NotCond( Kit_GraphVar(pGraph)->pFunc, Kit_GraphIsComplement(pGraph) );
+ return Aig_NotCond( (Aig_Obj_t *)Kit_GraphVar(pGraph)->pFunc, Kit_GraphIsComplement(pGraph) );
// build the AIG nodes corresponding to the AND gates of the graph
Kit_GraphForEachNode( pGraph, pNode, i )
{
- pAnd0 = Aig_NotCond( Kit_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl );
- pAnd1 = Aig_NotCond( Kit_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl );
+ pAnd0 = Aig_NotCond( (Aig_Obj_t *)Kit_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl );
+ pAnd1 = Aig_NotCond( (Aig_Obj_t *)Kit_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl );
pNode->pFunc = Aig_And( pMan, pAnd0, pAnd1 );
}
// complement the result if necessary
- return Aig_NotCond( pNode->pFunc, Kit_GraphIsComplement(pGraph) );
+ return Aig_NotCond( (Aig_Obj_t *)pNode->pFunc, Kit_GraphIsComplement(pGraph) );
}
/**Function*************************************************************
@@ -119,3 +122,5 @@ Aig_Obj_t * Kit_TruthToAig( Aig_Man_t * pMan, Aig_Obj_t ** pFanins, unsigned * p
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/kit/kitBdd.c b/src/aig/kit/kitBdd.c
index 75caf949..1b24ac24 100644
--- a/src/aig/kit/kitBdd.c
+++ b/src/aig/kit/kitBdd.c
@@ -21,6 +21,9 @@
#include "kit.h"
#include "extra.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -111,13 +114,13 @@ DdNode * Kit_GraphToBdd( DdManager * dd, Kit_Graph_t * pGraph )
{
bFunc0 = Cudd_NotCond( Kit_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl );
bFunc1 = Cudd_NotCond( Kit_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl );
- pNode->pFunc = Cudd_bddAnd( dd, bFunc0, bFunc1 ); Cudd_Ref( pNode->pFunc );
+ pNode->pFunc = Cudd_bddAnd( dd, bFunc0, bFunc1 ); Cudd_Ref( (DdNode *)pNode->pFunc );
}
// deref the intermediate results
- bFunc = pNode->pFunc; Cudd_Ref( bFunc );
+ bFunc = (DdNode *)pNode->pFunc; Cudd_Ref( bFunc );
Kit_GraphForEachNode( pGraph, pNode, i )
- Cudd_RecursiveDeref( dd, pNode->pFunc );
+ Cudd_RecursiveDeref( dd, (DdNode *)pNode->pFunc );
Cudd_Deref( bFunc );
// complement the result if necessary
@@ -229,3 +232,5 @@ int Kit_SopFactorVerify( Vec_Int_t * vCover, Kit_Graph_t * pFForm, int nVars )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/kit/kitCloud.c b/src/aig/kit/kitCloud.c
index 525f89f5..dea56749 100644
--- a/src/aig/kit/kitCloud.c
+++ b/src/aig/kit/kitCloud.c
@@ -20,6 +20,9 @@
#include "kit.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -35,6 +38,9 @@ struct Kit_Mux_t_
unsigned i : 1; // complemented attr of top node
};
+static inline int Kit_Mux2Int( Kit_Mux_t m ) { union { Kit_Mux_t x; int y; } v; v.x = m; return v.y; }
+static inline Kit_Mux_t Kit_Int2Mux( int m ) { union { Kit_Mux_t x; int y; } v; v.y = m; return v.x; }
+
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
@@ -180,7 +186,7 @@ int Kit_CreateCloud( CloudManager * dd, CloudNode * pFunc, Vec_Int_t * vNodes )
Mux.c = Cloud_IsComplement(dd->ppNodes[i]->e);
Mux.i = (i == nNodes - 1)? Cloud_IsComplement(pFunc) : 0;
// put the MUX into the array
- Vec_IntPush( vNodes, *((int *)&Mux) );
+ Vec_IntPush( vNodes, Kit_Mux2Int(Mux) );
}
assert( Vec_IntSize(vNodes) == nNodes );
// reset signatures
@@ -226,15 +232,15 @@ unsigned * Kit_CloudToTruth( Vec_Int_t * vNodes, int nVars, Vec_Ptr_t * vStore,
Kit_Mux_t Mux;
int i, Entry;
assert( Vec_IntSize(vNodes) <= Vec_PtrSize(vStore) );
- pThis = Vec_PtrEntry( vStore, 0 );
+ pThis = (unsigned *)Vec_PtrEntry( vStore, 0 );
Kit_TruthFill( pThis, nVars );
Vec_IntForEachEntryStart( vNodes, Entry, i, 1 )
{
- Mux = *((Kit_Mux_t *)&Entry);
+ Mux = Kit_Int2Mux(Entry);
assert( (int)Mux.e < i && (int)Mux.t < i && (int)Mux.v < nVars );
- pFan0 = Vec_PtrEntry( vStore, Mux.e );
- pFan1 = Vec_PtrEntry( vStore, Mux.t );
- pThis = Vec_PtrEntry( vStore, i );
+ pFan0 = (unsigned *)Vec_PtrEntry( vStore, Mux.e );
+ pFan1 = (unsigned *)Vec_PtrEntry( vStore, Mux.t );
+ pThis = (unsigned *)Vec_PtrEntry( vStore, i );
Kit_TruthMuxVarPhase( pThis, pFan0, pFan1, nVars, fInv? Mux.v : nVars-1-Mux.v, Mux.c );
}
// complement the result
@@ -274,14 +280,14 @@ unsigned * Kit_TruthCompose( CloudManager * dd, unsigned * pTruth, int nVars,
// printf( "Failed!\n" );
// compute truth table from the BDD
assert( Vec_IntSize(vNodes) <= Vec_PtrSize(vStore) );
- pThis = Vec_PtrEntry( vStore, 0 );
+ pThis = (unsigned *)Vec_PtrEntry( vStore, 0 );
Kit_TruthFill( pThis, nVarsAll );
Vec_IntForEachEntryStart( vNodes, Entry, i, 1 )
{
- Mux = *((Kit_Mux_t *)&Entry);
- pFan0 = Vec_PtrEntry( vStore, Mux.e );
- pFan1 = Vec_PtrEntry( vStore, Mux.t );
- pThis = Vec_PtrEntry( vStore, i );
+ Mux = Kit_Int2Mux(Entry);
+ pFan0 = (unsigned *)Vec_PtrEntry( vStore, Mux.e );
+ pFan1 = (unsigned *)Vec_PtrEntry( vStore, Mux.t );
+ pThis = (unsigned *)Vec_PtrEntry( vStore, i );
Kit_TruthMuxPhase( pThis, pFan0, pFan1, pInputs[nVars-1-Mux.v], nVarsAll, Mux.c );
}
// complement the result
@@ -319,7 +325,7 @@ void Kit_TruthCofSupports( Vec_Int_t * vBddDir, Vec_Int_t * vBddInv, int nVars,
// compute supports from nodes
Vec_IntForEachEntryStart( vBddDir, Entry, i, 1 )
{
- Mux = *((Kit_Mux_t *)&Entry);
+ Mux = Kit_Int2Mux(Entry);
Var = nVars - 1 - Mux.v;
pFan0 = puSuppAll + nSupps * Mux.e;
pFan1 = puSuppAll + nSupps * Mux.t;
@@ -344,7 +350,7 @@ void Kit_TruthCofSupports( Vec_Int_t * vBddDir, Vec_Int_t * vBddInv, int nVars,
// compute supports from nodes
Vec_IntForEachEntryStart( vBddInv, Entry, i, 1 )
{
- Mux = *((Kit_Mux_t *)&Entry);
+ Mux = Kit_Int2Mux(Entry);
// Var = nVars - 1 - Mux.v;
Var = Mux.v;
pFan0 = puSuppAll + nSupps * Mux.e;
@@ -368,3 +374,5 @@ void Kit_TruthCofSupports( Vec_Int_t * vBddDir, Vec_Int_t * vBddInv, int nVars,
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/kit/kitDec.c b/src/aig/kit/kitDec.c
new file mode 100644
index 00000000..afc7ef6c
--- /dev/null
+++ b/src/aig/kit/kitDec.c
@@ -0,0 +1,343 @@
+/**CFile****************************************************************
+
+ FileName [kitDec.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Computation kit.]
+
+ Synopsis [Decomposition manager.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - November 18, 2009.]
+
+ Revision [$Id: kitDec.c,v 1.00 2006/12/06 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "kit.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+// decomposition manager
+typedef struct Kit_ManDec_t_ Kit_ManDec_t;
+struct Kit_ManDec_t_
+{
+ int nVarsMax; // the max number of variables
+ int nWordsMax; // the max number of words
+ Vec_Ptr_t * vTruthVars; // elementary truth tables
+ Vec_Ptr_t * vTruthNodes; // internal truth tables
+ // current problem
+ int nVarsIn; // the current number of variables
+ Vec_Int_t * vLutsIn; // LUT truth tables
+ Vec_Int_t * vSuppIn; // LUT supports
+ char ATimeIn[64]; // variable arrival times
+ // extracted information
+ unsigned * pTruthIn; // computed truth table
+ unsigned * pTruthOut; // computed truth table
+ int nVarsOut; // the current number of variables
+ int nWordsOut; // the current number of words
+ char Order[32]; // new vars into old vars after supp minimization
+ // computed information
+ Vec_Int_t * vLutsOut; // problem decomposition
+ Vec_Int_t * vSuppOut; // problem decomposition
+ char ATimeOut[64]; // variable arrival times
+};
+
+static inline int Kit_DecOuputArrival( int nVars, Vec_Int_t * vLuts, char ATimes[] ) { return ATimes[nVars + Vec_IntSize(vLuts) - 1]; }
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Starts Decmetry manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Kit_ManDec_t * Kit_ManDecStart( int nVarsMax )
+{
+ Kit_ManDec_t * p;
+ assert( nVarsMax <= 20 );
+ p = ABC_CALLOC( Kit_ManDec_t, 1 );
+ p->nVarsMax = nVarsMax;
+ p->nWordsMax = Kit_TruthWordNum( p->nVarsMax );
+ p->vTruthVars = Vec_PtrAllocTruthTables( p->nVarsMax );
+ p->vTruthNodes = Vec_PtrAllocSimInfo( 64, p->nWordsMax );
+ p->vLutsIn = Vec_IntAlloc( 50 );
+ p->vSuppIn = Vec_IntAlloc( 50 );
+ p->vLutsOut = Vec_IntAlloc( 50 );
+ p->vSuppOut = Vec_IntAlloc( 50 );
+ p->pTruthIn = ABC_ALLOC( unsigned, p->nWordsMax );
+ p->pTruthOut = ABC_ALLOC( unsigned, p->nWordsMax );
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Stops Decmetry manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Kit_ManDecStop( Kit_ManDec_t * p )
+{
+ ABC_FREE( p->pTruthIn );
+ ABC_FREE( p->pTruthOut );
+ Vec_IntFreeP( &p->vLutsIn );
+ Vec_IntFreeP( &p->vSuppIn );
+ Vec_IntFreeP( &p->vLutsOut );
+ Vec_IntFreeP( &p->vSuppOut );
+ Vec_PtrFreeP( &p->vTruthVars );
+ Vec_PtrFreeP( &p->vTruthNodes );
+ ABC_FREE( p );
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Deriving timing information for the decomposed structure.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Kit_DecComputeOuputArrival( int nVars, Vec_Int_t * vSupps, int LutSize, char ATimesIn[], char ATimesOut[] )
+{
+ int i, v, iVar, nLuts, Delay;
+ nLuts = Vec_IntSize(vSupps) / LutSize;
+ assert( nLuts > 0 );
+ assert( Vec_IntSize(vSupps) % LutSize == 0 );
+ for ( v = 0; v < nVars; v++ )
+ ATimesOut[v] = ATimesIn[v];
+ for ( v = 0; v < nLuts; v++ )
+ {
+ Delay = 0;
+ for ( i = 0; i < LutSize; i++ )
+ {
+ iVar = Vec_IntEntry( vSupps, v * LutSize + i );
+ assert( iVar < nVars + v );
+ Delay = ABC_MAX( Delay, ATimesOut[iVar] );
+ }
+ ATimesOut[nVars + v] = Delay + 1;
+ }
+ return ATimesOut[nVars + nLuts - 1];
+}
+
+/**Function*************************************************************
+
+ Synopsis [Derives the truth table]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Kit_DecComputeTruthOne( int LutSize, unsigned * pTruthLut, int nVars, unsigned * pTruths[], unsigned * pTemp, unsigned * pRes )
+{
+ int i, v;
+ Kit_TruthClear( pRes, nVars );
+ for ( i = 0; i < (1<<LutSize); i++ )
+ {
+ if ( !Kit_TruthHasBit( pTruthLut, i ) )
+ continue;
+ Kit_TruthFill( pTemp, nVars );
+ for ( v = 0; v < LutSize; v++ )
+ if ( i & (1<<v) )
+ Kit_TruthAnd( pTemp, pTemp, pTruths[v], nVars );
+ else
+ Kit_TruthSharp( pTemp, pTemp, pTruths[v], nVars );
+ Kit_TruthOr( pRes, pRes, pTemp, nVars );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Derives the truth table]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Kit_DecComputeTruth( Kit_ManDec_t * p, int nVars, Vec_Int_t * vSupps, int LutSize, Vec_Int_t * vLuts, unsigned * pRes )
+{
+ unsigned * pResult, * pTruthLuts, * pTruths[17];
+ int nTruthLutWords, i, v, iVar, nLuts;
+ nLuts = Vec_IntSize(vSupps) / LutSize;
+ pTruthLuts = Vec_IntArray( vLuts );
+ nTruthLutWords = Kit_TruthWordNum( LutSize );
+ assert( nLuts > 0 );
+ assert( Vec_IntSize(vSupps) % LutSize == 0 );
+ assert( nLuts * nTruthLutWords == Vec_IntSize(vLuts) );
+ for ( v = 0; v < nLuts; v++ )
+ {
+ for ( i = 0; i < LutSize; i++ )
+ {
+ iVar = Vec_IntEntry( vSupps, v * LutSize + i );
+ assert( iVar < nVars + v );
+ pTruths[i] = (iVar < nVars)? Vec_PtrEntry(p->vTruthVars, iVar) : Vec_PtrEntry(p->vTruthNodes, iVar-nVars);
+ }
+ pResult = (v == nLuts - 1) ? pRes : Vec_PtrEntry(p->vTruthNodes, v);
+ Kit_DecComputeTruthOne( LutSize, pTruthLuts, nVars, pTruths, Vec_PtrEntry(p->vTruthNodes, v+1), pResult );
+ pTruthLuts += nTruthLutWords;
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Derives the truth table]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Kit_DecComputePattern( int nVars, unsigned * pTruth, int LutSize, int Pattern[] )
+{
+ int nCofs = (1 << LutSize);
+ int i, k, nMyu = 0;
+ assert( LutSize <= 6 );
+ assert( LutSize < nVars );
+ if ( nVars - LutSize <= 5 )
+ {
+ unsigned uCofs[64];
+ int nBits = (1 << (nVars - LutSize));
+ for ( i = 0; i < nCofs; i++ )
+ uCofs[i] = (pTruth[(i*nBits)/32] >> ((i*nBits)%32)) & ((1<<nBits)-1);
+ for ( i = 0; i < nCofs; i++ )
+ {
+ for ( k = 0; k < nMyu; k++ )
+ if ( uCofs[i] == uCofs[k] )
+ {
+ Pattern[i] = k;
+ break;
+ }
+ if ( k == i )
+ Pattern[nMyu++] = i;
+ }
+ }
+ else
+ {
+ unsigned * puCofs[64];
+ int nWords = (1 << (nVars - LutSize - 5));
+ for ( i = 0; i < nCofs; i++ )
+ puCofs[i] = pTruth + nWords;
+ for ( i = 0; i < nCofs; i++ )
+ {
+ for ( k = 0; k < nMyu; k++ )
+ if ( Kit_TruthIsEqual( puCofs[i], puCofs[k], nVars - LutSize - 5 ) )
+ {
+ Pattern[i] = k;
+ break;
+ }
+ if ( k == i )
+ Pattern[nMyu++] = i;
+ }
+ }
+ return nMyu;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the number of shared variables.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Kit_DecComputeShared_rec( int Pattern[], int Vars[], int nVars, int Shared[], int iVarTry )
+{
+ int Pat0[32], Pat1[32], Shared0[5], Shared1[5], VarsNext[5];
+ int v, u, iVarsNext, iPat0, iPat1, m, nMints = (1 << nVars);
+ int nShared0, nShared1, nShared = 0;
+ for ( v = iVarTry; v < nVars; v++ )
+ {
+ iVarsNext = 0;
+ for ( u = 0; u < nVars; u++ )
+ if ( u == v )
+ VarsNext[iVarsNext++] = Vars[u];
+ iPat0 = iPat1 = 0;
+ for ( m = 0; m < nMints; m++ )
+ if ( m & (1 << v) )
+ Pat1[iPat1++] = m;
+ else
+ Pat0[iPat0++] = m;
+ assert( iPat0 == nMints / 2 );
+ assert( iPat1 == nMints / 2 );
+ nShared0 = Kit_DecComputeShared_rec( Pat0, VarsNext, nVars-1, Shared0, v + 1 );
+ if ( nShared0 == 0 )
+ continue;
+ nShared1 = Kit_DecComputeShared_rec( Pat1, VarsNext, nVars-1, Shared1, v + 1 );
+ if ( nShared1 == 0 )
+ continue;
+ Shared[nShared++] = v;
+ for ( u = 0; u < nShared0; u++ )
+ for ( m = 0; m < nShared1; m++ )
+ if ( Shared0[u] >= 0 && Shared1[m] >= 0 && Shared0[u] == Shared1[m] )
+ {
+ Shared[nShared++] = Shared0[u];
+ Shared0[u] = Shared1[m] = -1;
+ }
+ return nShared;
+ }
+ return 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the number of shared variables.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Kit_DecComputeShared( int Pattern[], int LutSize, int Shared[] )
+{
+ int i, Vars[6];
+ assert( LutSize <= 6 );
+ for ( i = 0; i < LutSize; i++ )
+ Vars[i] = i;
+ return Kit_DecComputeShared_rec( Pattern, Vars, LutSize, Shared, 0 );
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/kit/kitDsd.c b/src/aig/kit/kitDsd.c
index a85262a9..fbf92e48 100644
--- a/src/aig/kit/kitDsd.c
+++ b/src/aig/kit/kitDsd.c
@@ -20,6 +20,9 @@
#include "kit.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -268,7 +271,7 @@ void Kit_DsdPrint( FILE * pFile, Kit_DsdNtk_t * pNtk )
if ( Kit_DsdLitIsCompl(pNtk->Root) )
fprintf( pFile, "!" );
Kit_DsdPrint_rec( pFile, pNtk, Kit_DsdLit2Var(pNtk->Root) );
- fprintf( pFile, "\n" );
+// fprintf( pFile, "\n" );
}
/**Function*************************************************************
@@ -333,7 +336,7 @@ unsigned * Kit_DsdTruthComputeNode_rec( Kit_DsdMan_t * p, Kit_DsdNtk_t * pNtk, i
// get the node with this ID
pObj = Kit_DsdNtkObj( pNtk, Id );
- pTruthRes = Vec_PtrEntry( p->vTtNodes, Id );
+ pTruthRes = (unsigned *)Vec_PtrEntry( p->vTtNodes, Id );
// special case: literal of an internal node
if ( pObj == NULL )
@@ -434,7 +437,7 @@ unsigned * Kit_DsdTruthCompute( Kit_DsdMan_t * p, Kit_DsdNtk_t * pNtk )
// assign elementary truth ables
assert( pNtk->nVars <= p->nVars );
for ( i = 0; i < (int)pNtk->nVars; i++ )
- Kit_TruthCopy( Vec_PtrEntry(p->vTtNodes, i), Vec_PtrEntry(p->vTtElems, i), p->nVars );
+ Kit_TruthCopy( (unsigned *)Vec_PtrEntry(p->vTtNodes, i), (unsigned *)Vec_PtrEntry(p->vTtElems, i), p->nVars );
// compute truth table for each node
pTruthRes = Kit_DsdTruthComputeNode_rec( p, pNtk, Kit_DsdLit2Var(pNtk->Root) );
// complement the truth table if needed
@@ -463,7 +466,7 @@ unsigned * Kit_DsdTruthComputeNodeOne_rec( Kit_DsdMan_t * p, Kit_DsdNtk_t * pNtk
// get the node with this ID
pObj = Kit_DsdNtkObj( pNtk, Id );
- pTruthRes = Vec_PtrEntry( p->vTtNodes, Id );
+ pTruthRes = (unsigned *)Vec_PtrEntry( p->vTtNodes, Id );
// special case: literal of an internal node
if ( pObj == NULL )
@@ -597,7 +600,7 @@ unsigned * Kit_DsdTruthComputeOne( Kit_DsdMan_t * p, Kit_DsdNtk_t * pNtk, unsign
// assign elementary truth tables
assert( pNtk->nVars <= p->nVars );
for ( i = 0; i < (int)pNtk->nVars; i++ )
- Kit_TruthCopy( Vec_PtrEntry(p->vTtNodes, i), Vec_PtrEntry(p->vTtElems, i), p->nVars );
+ Kit_TruthCopy( (unsigned *)Vec_PtrEntry(p->vTtNodes, i), (unsigned *)Vec_PtrEntry(p->vTtElems, i), p->nVars );
// compute truth table for each node
pTruthRes = Kit_DsdTruthComputeNodeOne_rec( p, pNtk, Kit_DsdLit2Var(pNtk->Root), uSupp );
// complement the truth table if needed
@@ -628,7 +631,7 @@ unsigned * Kit_DsdTruthComputeNodeTwo_rec( Kit_DsdMan_t * p, Kit_DsdNtk_t * pNtk
// get the node with this ID
pObj = Kit_DsdNtkObj( pNtk, Id );
- pTruthRes = Vec_PtrEntry( p->vTtNodes, Id );
+ pTruthRes = (unsigned *)Vec_PtrEntry( p->vTtNodes, Id );
if ( pObj == NULL )
{
assert( Id < pNtk->nVars );
@@ -812,7 +815,7 @@ unsigned * Kit_DsdTruthComputeTwo( Kit_DsdMan_t * p, Kit_DsdNtk_t * pNtk, unsign
}
// assign elementary truth tables
for ( i = 0; i < (int)pNtk->nVars; i++ )
- Kit_TruthCopy( Vec_PtrEntry(p->vTtNodes, i), Vec_PtrEntry(p->vTtElems, i), p->nVars );
+ Kit_TruthCopy( (unsigned *)Vec_PtrEntry(p->vTtNodes, i), (unsigned *)Vec_PtrEntry(p->vTtElems, i), p->nVars );
// compute truth table for each node
pTruthRes = Kit_DsdTruthComputeNodeTwo_rec( p, pNtk, Kit_DsdLit2Var(pNtk->Root), uSupp, iVar, pTruthDec );
// complement the truth table if needed
@@ -1125,7 +1128,7 @@ int Kit_DsdExpandNode_rec( Kit_DsdNtk_t * pNew, Kit_DsdNtk_t * p, int iLit )
return iLit;
if ( pObj->Type == KIT_DSD_AND )
{
- Kit_DsdExpandCollectAnd_rec( p, Kit_DsdLitRegular(iLit), piLitsNew, &nLitsNew );
+ Kit_DsdExpandCollectAnd_rec( p, Kit_DsdLitRegular(iLit), piLitsNew, (int *)&nLitsNew );
pObjNew = Kit_DsdObjAlloc( pNew, KIT_DSD_AND, nLitsNew );
for ( i = 0; i < pObjNew->nFans; i++ )
pObjNew->pFans[i] = Kit_DsdExpandNode_rec( pNew, p, piLitsNew[i] );
@@ -1134,7 +1137,7 @@ int Kit_DsdExpandNode_rec( Kit_DsdNtk_t * pNew, Kit_DsdNtk_t * p, int iLit )
if ( pObj->Type == KIT_DSD_XOR )
{
int fCompl = Kit_DsdLitIsCompl(iLit);
- Kit_DsdExpandCollectXor_rec( p, Kit_DsdLitRegular(iLit), piLitsNew, &nLitsNew );
+ Kit_DsdExpandCollectXor_rec( p, Kit_DsdLitRegular(iLit), piLitsNew, (int *)&nLitsNew );
pObjNew = Kit_DsdObjAlloc( pNew, KIT_DSD_XOR, nLitsNew );
for ( i = 0; i < pObjNew->nFans; i++ )
{
@@ -2716,8 +2719,252 @@ void Kit_DsdPrintCofactors( unsigned * pTruth, int nVars, int nCofLevel, int fVe
ABC_FREE( ppCofs[0][0] );
}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+char ** Kit_DsdNpn4ClassNames()
+{
+ static const char * pNames[222] = {
+ "F = 0", /* 0 */
+ "F = (!d*(!c*(!b*!a)))", /* 1 */
+ "F = (!d*(!c*!b))", /* 2 */
+ "F = (!d*(!c*(b+a)))", /* 3 */
+ "F = (!d*(!c*!(b*a)))", /* 4 */
+ "F = (!d*!c)", /* 5 */
+ "F = (!d*16(a,b,c))", /* 6 */
+ "F = (!d*17(a,b,c))", /* 7 */
+ "F = (!d*18(a,b,c))", /* 8 */
+ "F = (!d*19(a,b,c))", /* 9 */
+ "F = (!d*CA(!b,!c,a))", /* 10 */
+ "F = (!d*(c+!(!b*!a)))", /* 11 */
+ "F = (!d*!(c*!(!b*!a)))", /* 12 */
+ "F = (!d*(c+b))", /* 13 */
+ "F = (!d*3D(a,b,c))", /* 14 */
+ "F = (!d*!(c*b))", /* 15 */
+ "F = (!d*(c+(b+!a)))", /* 16 */
+ "F = (!d*6B(a,b,c))", /* 17 */
+ "F = (!d*!(c*!(b+a)))", /* 18 */
+ "F = (!d*7E(a,b,c))", /* 19 */
+ "F = (!d*!(c*(b*a)))", /* 20 */
+ "F = (!d)", /* 21 */
+ "F = 0116(a,b,c,d)", /* 22 */
+ "F = 0117(a,b,c,d)", /* 23 */
+ "F = 0118(a,b,c,d)", /* 24 */
+ "F = 0119(a,b,c,d)", /* 25 */
+ "F = 011A(a,b,c,d)", /* 26 */
+ "F = 011B(a,b,c,d)", /* 27 */
+ "F = 29((!b*!a),c,d)", /* 28 */
+ "F = 2B((!b*!a),c,d)", /* 29 */
+ "F = 012C(a,b,c,d)", /* 30 */
+ "F = 012D(a,b,c,d)", /* 31 */
+ "F = 012F(a,b,c,d)", /* 32 */
+ "F = 013C(a,b,c,d)", /* 33 */
+ "F = 013D(a,b,c,d)", /* 34 */
+ "F = 013E(a,b,c,d)", /* 35 */
+ "F = 013F(a,b,c,d)", /* 36 */
+ "F = 0168(a,b,c,d)", /* 37 */
+ "F = 0169(a,b,c,d)", /* 38 */
+ "F = 016A(a,b,c,d)", /* 39 */
+ "F = 016B(a,b,c,d)", /* 40 */
+ "F = 016E(a,b,c,d)", /* 41 */
+ "F = 016F(a,b,c,d)", /* 42 */
+ "F = 017E(a,b,c,d)", /* 43 */
+ "F = 017F(a,b,c,d)", /* 44 */
+ "F = 0180(a,b,c,d)", /* 45 */
+ "F = 0181(a,b,c,d)", /* 46 */
+ "F = 0182(a,b,c,d)", /* 47 */
+ "F = 0183(a,b,c,d)", /* 48 */
+ "F = 0186(a,b,c,d)", /* 49 */
+ "F = 0187(a,b,c,d)", /* 50 */
+ "F = 0189(a,b,c,d)", /* 51 */
+ "F = 018B(a,b,c,d)", /* 52 */
+ "F = 018F(a,b,c,d)", /* 53 */
+ "F = 0196(a,b,c,d)", /* 54 */
+ "F = 0197(a,b,c,d)", /* 55 */
+ "F = 0198(a,b,c,d)", /* 56 */
+ "F = 0199(a,b,c,d)", /* 57 */
+ "F = 019A(a,b,c,d)", /* 58 */
+ "F = 019B(a,b,c,d)", /* 59 */
+ "F = 019E(a,b,c,d)", /* 60 */
+ "F = 019F(a,b,c,d)", /* 61 */
+ "F = 42(a,(!c*!b),d)", /* 62 */
+ "F = 46(a,(!c*!b),d)", /* 63 */
+ "F = 4A(a,(!c*!b),d)", /* 64 */
+ "F = CA((!c*!b),!d,a)", /* 65 */
+ "F = 01AC(a,b,c,d)", /* 66 */
+ "F = 01AD(a,b,c,d)", /* 67 */
+ "F = 01AE(a,b,c,d)", /* 68 */
+ "F = 01AF(a,b,c,d)", /* 69 */
+ "F = 01BC(a,b,c,d)", /* 70 */
+ "F = 01BD(a,b,c,d)", /* 71 */
+ "F = 01BE(a,b,c,d)", /* 72 */
+ "F = 01BF(a,b,c,d)", /* 73 */
+ "F = 01E8(a,b,c,d)", /* 74 */
+ "F = 01E9(a,b,c,d)", /* 75 */
+ "F = 01EA(a,b,c,d)", /* 76 */
+ "F = 01EB(a,b,c,d)", /* 77 */
+ "F = 25((!b*!a),c,d)", /* 78 */
+ "F = !CA(d,c,(!b*!a))", /* 79 */
+ "F = (d+!(!c*(!b*!a)))", /* 80 */
+ "F = 16(b,c,d)", /* 81 */
+ "F = 033D(a,b,c,d)", /* 82 */
+ "F = 17(b,c,d)", /* 83 */
+ "F = ((!d*!a)+(!c*!b))", /* 84 */
+ "F = !(!(!c*!b)*!(!d*!a))", /* 85 */
+ "F = 0358(a,b,c,d)", /* 86 */
+ "F = 0359(a,b,c,d)", /* 87 */
+ "F = 035A(a,b,c,d)", /* 88 */
+ "F = 035B(a,b,c,d)", /* 89 */
+ "F = 035E(a,b,c,d)", /* 90 */
+ "F = 035F(a,b,c,d)", /* 91 */
+ "F = 0368(a,b,c,d)", /* 92 */
+ "F = 0369(a,b,c,d)", /* 93 */
+ "F = 036A(a,b,c,d)", /* 94 */
+ "F = 036B(a,b,c,d)", /* 95 */
+ "F = 036C(a,b,c,d)", /* 96 */
+ "F = 036D(a,b,c,d)", /* 97 */
+ "F = 036E(a,b,c,d)", /* 98 */
+ "F = 036F(a,b,c,d)", /* 99 */
+ "F = 037C(a,b,c,d)", /* 100 */
+ "F = 037D(a,b,c,d)", /* 101 */
+ "F = 037E(a,b,c,d)", /* 102 */
+ "F = 18(b,c,d)", /* 103 */
+ "F = 03C1(a,b,c,d)", /* 104 */
+ "F = 19(b,c,d)", /* 105 */
+ "F = 03C5(a,b,c,d)", /* 106 */
+ "F = 03C6(a,b,c,d)", /* 107 */
+ "F = 03C7(a,b,c,d)", /* 108 */
+ "F = CA(!c,!d,b)", /* 109 */
+ "F = 03D4(a,b,c,d)", /* 110 */
+ "F = 03D5(a,b,c,d)", /* 111 */
+ "F = 03D6(a,b,c,d)", /* 112 */
+ "F = 03D7(a,b,c,d)", /* 113 */
+ "F = 03D8(a,b,c,d)", /* 114 */
+ "F = 03D9(a,b,c,d)", /* 115 */
+ "F = 03DB(a,b,c,d)", /* 116 */
+ "F = 03DC(a,b,c,d)", /* 117 */
+ "F = 03DD(a,b,c,d)", /* 118 */
+ "F = 03DE(a,b,c,d)", /* 119 */
+ "F = (d+!(!c*!b))", /* 120 */
+ "F = ((d+c)*(b+a))", /* 121 */
+ "F = 0661(a,b,c,d)", /* 122 */
+ "F = 0662(a,b,c,d)", /* 123 */
+ "F = 0663(a,b,c,d)", /* 124 */
+ "F = (!(d*c)*(b+a))", /* 125 */
+ "F = 0667(a,b,c,d)", /* 126 */
+ "F = 29((b+a),c,d)", /* 127 */
+ "F = 066B(a,b,c,d)", /* 128 */
+ "F = 2B((b+a),c,d)", /* 129 */
+ "F = 0672(a,b,c,d)", /* 130 */
+ "F = 0673(a,b,c,d)", /* 131 */
+ "F = 0676(a,b,c,d)", /* 132 */
+ "F = 0678(a,b,c,d)", /* 133 */
+ "F = 0679(a,b,c,d)", /* 134 */
+ "F = 067A(a,b,c,d)", /* 135 */
+ "F = 067B(a,b,c,d)", /* 136 */
+ "F = 067E(a,b,c,d)", /* 137 */
+ "F = 24((b+a),c,d)", /* 138 */
+ "F = 0691(a,b,c,d)", /* 139 */
+ "F = 0693(a,b,c,d)", /* 140 */
+ "F = 26((b+a),c,d)", /* 141 */
+ "F = 0697(a,b,c,d)", /* 142 */
+ "F = !CA(d,c,(b+a))", /* 143 */
+ "F = 06B0(a,b,c,d)", /* 144 */
+ "F = 06B1(a,b,c,d)", /* 145 */
+ "F = 06B2(a,b,c,d)", /* 146 */
+ "F = 06B3(a,b,c,d)", /* 147 */
+ "F = 06B4(a,b,c,d)", /* 148 */
+ "F = 06B5(a,b,c,d)", /* 149 */
+ "F = 06B6(a,b,c,d)", /* 150 */
+ "F = 06B7(a,b,c,d)", /* 151 */
+ "F = 06B9(a,b,c,d)", /* 152 */
+ "F = 06BD(a,b,c,d)", /* 153 */
+ "F = 2C((b+a),c,d)", /* 154 */
+ "F = 06F1(a,b,c,d)", /* 155 */
+ "F = 06F2(a,b,c,d)", /* 156 */
+ "F = CA((b+a),!d,c)", /* 157 */
+ "F = (d+!(!c*!(b+!a)))", /* 158 */
+ "F = 0776(a,b,c,d)", /* 159 */
+ "F = 16((b*a),c,d)", /* 160 */
+ "F = 0779(a,b,c,d)", /* 161 */
+ "F = 077A(a,b,c,d)", /* 162 */
+ "F = 077E(a,b,c,d)", /* 163 */
+ "F = 07B0(a,b,c,d)", /* 164 */
+ "F = 07B1(a,b,c,d)", /* 165 */
+ "F = 07B4(a,b,c,d)", /* 166 */
+ "F = 07B5(a,b,c,d)", /* 167 */
+ "F = 07B6(a,b,c,d)", /* 168 */
+ "F = 07BC(a,b,c,d)", /* 169 */
+ "F = 07E0(a,b,c,d)", /* 170 */
+ "F = 07E1(a,b,c,d)", /* 171 */
+ "F = 07E2(a,b,c,d)", /* 172 */
+ "F = 07E3(a,b,c,d)", /* 173 */
+ "F = 07E6(a,b,c,d)", /* 174 */
+ "F = 07E9(a,b,c,d)", /* 175 */
+ "F = 1C((b*a),c,d)", /* 176 */
+ "F = 07F1(a,b,c,d)", /* 177 */
+ "F = 07F2(a,b,c,d)", /* 178 */
+ "F = (d+!(!c*!(b*a)))", /* 179 */
+ "F = (d+c)", /* 180 */
+ "F = 1668(a,b,c,d)", /* 181 */
+ "F = 1669(a,b,c,d)", /* 182 */
+ "F = 166A(a,b,c,d)", /* 183 */
+ "F = 166B(a,b,c,d)", /* 184 */
+ "F = 166E(a,b,c,d)", /* 185 */
+ "F = 167E(a,b,c,d)", /* 186 */
+ "F = 1681(a,b,c,d)", /* 187 */
+ "F = 1683(a,b,c,d)", /* 188 */
+ "F = 1686(a,b,c,d)", /* 189 */
+ "F = 1687(a,b,c,d)", /* 190 */
+ "F = 1689(a,b,c,d)", /* 191 */
+ "F = 168B(a,b,c,d)", /* 192 */
+ "F = 168E(a,b,c,d)", /* 193 */
+ "F = 1696(a,b,c,d)", /* 194 */
+ "F = 1697(a,b,c,d)", /* 195 */
+ "F = 1698(a,b,c,d)", /* 196 */
+ "F = 1699(a,b,c,d)", /* 197 */
+ "F = 169A(a,b,c,d)", /* 198 */
+ "F = 169B(a,b,c,d)", /* 199 */
+ "F = 169E(a,b,c,d)", /* 200 */
+ "F = 16A9(a,b,c,d)", /* 201 */
+ "F = 16AC(a,b,c,d)", /* 202 */
+ "F = 16AD(a,b,c,d)", /* 203 */
+ "F = 16BC(a,b,c,d)", /* 204 */
+ "F = (d+E9(a,b,c))", /* 205 */
+ "F = 177E(a,b,c,d)", /* 206 */
+ "F = 178E(a,b,c,d)", /* 207 */
+ "F = 1796(a,b,c,d)", /* 208 */
+ "F = 1798(a,b,c,d)", /* 209 */
+ "F = 179A(a,b,c,d)", /* 210 */
+ "F = 17AC(a,b,c,d)", /* 211 */
+ "F = (d+E8(a,b,c))", /* 212 */
+ "F = (d+E7(a,b,c))", /* 213 */
+ "F = 19E1(a,b,c,d)", /* 214 */
+ "F = 19E3(a,b,c,d)", /* 215 */
+ "F = (d+E6(a,b,c))", /* 216 */
+ "F = 1BD8(a,b,c,d)", /* 217 */
+ "F = (d+CA(b,c,a))", /* 218 */
+ "F = (d+(c+(!b*!a)))", /* 219 */
+ "F = (d+(c+!b))", /* 220 */
+ "F = (d+(c+(b+a)))" /* 221 */
+ };
+ return (char **)pNames;
+}
+
+
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/kit/kitFactor.c b/src/aig/kit/kitFactor.c
index 273d4821..3982d7a8 100644
--- a/src/aig/kit/kitFactor.c
+++ b/src/aig/kit/kitFactor.c
@@ -20,6 +20,9 @@
#include "kit.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -337,3 +340,5 @@ void Kit_FactorTest( unsigned * pTruth, int nVars )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/kit/kitGraph.c b/src/aig/kit/kitGraph.c
index 565c000b..f407a93a 100644
--- a/src/aig/kit/kitGraph.c
+++ b/src/aig/kit/kitGraph.c
@@ -20,6 +20,9 @@
#include "kit.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -395,3 +398,5 @@ int Kit_GraphLeafDepth_rec( Kit_Graph_t * pGraph, Kit_Node_t * pNode, Kit_Node_t
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/kit/kitHop.c b/src/aig/kit/kitHop.c
index 044633bc..0dad6295 100644
--- a/src/aig/kit/kitHop.c
+++ b/src/aig/kit/kitHop.c
@@ -21,6 +21,9 @@
#include "kit.h"
#include "hop.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -50,16 +53,16 @@ Hop_Obj_t * Kit_GraphToHopInternal( Hop_Man_t * pMan, Kit_Graph_t * pGraph )
return Hop_NotCond( Hop_ManConst1(pMan), Kit_GraphIsComplement(pGraph) );
// check for a literal
if ( Kit_GraphIsVar(pGraph) )
- return Hop_NotCond( Kit_GraphVar(pGraph)->pFunc, Kit_GraphIsComplement(pGraph) );
+ return Hop_NotCond( (Hop_Obj_t *)Kit_GraphVar(pGraph)->pFunc, Kit_GraphIsComplement(pGraph) );
// build the AIG nodes corresponding to the AND gates of the graph
Kit_GraphForEachNode( pGraph, pNode, i )
{
- pAnd0 = Hop_NotCond( Kit_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl );
- pAnd1 = Hop_NotCond( Kit_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl );
+ pAnd0 = Hop_NotCond( (Hop_Obj_t *)Kit_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl );
+ pAnd1 = Hop_NotCond( (Hop_Obj_t *)Kit_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl );
pNode->pFunc = Hop_And( pMan, pAnd0, pAnd1 );
}
// complement the result if necessary
- return Hop_NotCond( pNode->pFunc, Kit_GraphIsComplement(pGraph) );
+ return Hop_NotCond( (Hop_Obj_t *)pNode->pFunc, Kit_GraphIsComplement(pGraph) );
}
/**Function*************************************************************
@@ -143,3 +146,5 @@ Hop_Obj_t * Kit_CoverToHop( Hop_Man_t * pMan, Vec_Int_t * vCover, int nVars, Vec
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/kit/kitIsop.c b/src/aig/kit/kitIsop.c
index 42fae2ea..18039dc5 100644
--- a/src/aig/kit/kitIsop.c
+++ b/src/aig/kit/kitIsop.c
@@ -20,6 +20,9 @@
#include "kit.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -323,3 +326,5 @@ unsigned Kit_TruthIsop5_rec( unsigned uOn, unsigned uOnDc, int nVars, Kit_Sop_t
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/kit/kitPla.c b/src/aig/kit/kitPla.c
index 776762c2..df6d4e11 100644
--- a/src/aig/kit/kitPla.c
+++ b/src/aig/kit/kitPla.c
@@ -21,6 +21,9 @@
#include "kit.h"
#include "aig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -115,7 +118,9 @@ int Kit_PlaIsInv( char * pSop )
int Kit_PlaGetVarNum( char * pSop )
{
char * pCur;
- for ( pCur = pSop; *pCur != '\n'; pCur++ );
+ for ( pCur = pSop; *pCur != '\n'; pCur++ )
+ if ( *pCur == 0 )
+ return -1;
return pCur - pSop - 2;
}
@@ -205,7 +210,7 @@ void Kit_PlaComplement( char * pSop )
***********************************************************************/
char * Kit_PlaStart( void * p, int nCubes, int nVars )
{
- Aig_MmFlex_t * pMan = p;
+ Aig_MmFlex_t * pMan = (Aig_MmFlex_t *)p;
char * pSopCover, * pCube;
int i, Length;
@@ -237,7 +242,7 @@ char * Kit_PlaStart( void * p, int nCubes, int nVars )
***********************************************************************/
char * Kit_PlaCreateFromIsop( void * p, int nVars, Vec_Int_t * vCover )
{
- Aig_MmFlex_t * pMan = p;
+ Aig_MmFlex_t * pMan = (Aig_MmFlex_t *)p;
char * pSop, * pCube;
int i, k, Entry, Literal;
assert( Vec_IntSize(vCover) > 0 );
@@ -311,7 +316,7 @@ void Kit_PlaToIsop( char * pSop, Vec_Int_t * vCover )
***********************************************************************/
char * Kit_PlaStoreSop( void * p, char * pSop )
{
- Aig_MmFlex_t * pMan = p;
+ Aig_MmFlex_t * pMan = (Aig_MmFlex_t *)p;
char * pStore;
pStore = Aig_MmFlexEntryFetch( pMan, strlen(pSop) + 1 );
strcpy( pStore, pSop );
@@ -331,7 +336,7 @@ char * Kit_PlaStoreSop( void * p, char * pSop )
***********************************************************************/
char * Kit_PlaFromTruth( void * p, unsigned * pTruth, int nVars, Vec_Int_t * vCover )
{
- Aig_MmFlex_t * pMan = p;
+ Aig_MmFlex_t * pMan = (Aig_MmFlex_t *)p;
char * pSop;
int RetValue;
if ( Kit_TruthIsConst0(pTruth, nVars) )
@@ -347,8 +352,184 @@ char * Kit_PlaFromTruth( void * p, unsigned * pTruth, int nVars, Vec_Int_t * vCo
}
+/**Function*************************************************************
+
+ Synopsis [Creates the cover from the ISOP computed from TT.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+char * Kit_PlaFromIsop( Vec_Str_t * vStr, int nVars, Vec_Int_t * vCover )
+{
+ int i, k, Entry, Literal;
+ assert( Vec_IntSize(vCover) > 0 );
+ if ( Vec_IntSize(vCover) == 0 )
+ return NULL;
+ Vec_StrClear( vStr );
+ Vec_IntForEachEntry( vCover, Entry, i )
+ {
+ for ( k = 0; k < nVars; k++ )
+ {
+ Literal = 3 & (Entry >> (k << 1));
+ if ( Literal == 1 )
+ Vec_StrPush( vStr, '0' );
+ else if ( Literal == 2 )
+ Vec_StrPush( vStr, '1' );
+ else if ( Literal == 0 )
+ Vec_StrPush( vStr, '-' );
+ else
+ assert( 0 );
+ }
+ Vec_StrPush( vStr, ' ' );
+ Vec_StrPush( vStr, '1' );
+ Vec_StrPush( vStr, '\n' );
+ }
+ Vec_StrPush( vStr, '\0' );
+ return Vec_StrArray( vStr );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates the SOP from TT.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+char * Kit_PlaFromTruthNew( unsigned * pTruth, int nVars, Vec_Int_t * vCover, Vec_Str_t * vStr )
+{
+ char * pResult;
+ // transform truth table into the SOP
+ int RetValue = Kit_TruthIsop( pTruth, nVars, vCover, 1 );
+ assert( RetValue == 0 || RetValue == 1 );
+ // check the case of constant cover
+ if ( Vec_IntSize(vCover) == 0 || (Vec_IntSize(vCover) == 1 && Vec_IntEntry(vCover,0) == 0) )
+ {
+ assert( RetValue == 0 );
+ Vec_StrClear( vStr );
+ Vec_StrAppend( vStr, (Vec_IntSize(vCover) == 0) ? " 0\n" : " 1\n" );
+ Vec_StrPush( vStr, '\0' );
+ return Vec_StrArray( vStr );
+ }
+ pResult = Kit_PlaFromIsop( vStr, nVars, vCover );
+ if ( RetValue )
+ Kit_PlaComplement( pResult );
+ if ( nVars < 6 )
+ assert( pTruth[0] == (unsigned)Kit_PlaToTruth6(pResult, nVars) );
+ else if ( nVars == 6 )
+ assert( *((ABC_UINT64_T*)pTruth) == Kit_PlaToTruth6(pResult, nVars) );
+ return pResult;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Converts SOP into a truth table.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+ABC_UINT64_T Kit_PlaToTruth6( char * pSop, int nVars )
+{
+ static ABC_UINT64_T Truth[8] = {
+ 0xAAAAAAAAAAAAAAAA,
+ 0xCCCCCCCCCCCCCCCC,
+ 0xF0F0F0F0F0F0F0F0,
+ 0xFF00FF00FF00FF00,
+ 0xFFFF0000FFFF0000,
+ 0xFFFFFFFF00000000,
+ 0x0000000000000000,
+ 0xFFFFFFFFFFFFFFFF
+ };
+ ABC_UINT64_T valueAnd, valueOr = Truth[6];
+ int v, lit = 0;
+ assert( nVars < 7 );
+ do {
+ valueAnd = Truth[7];
+ for ( v = 0; v < nVars; v++, lit++ )
+ {
+ if ( pSop[lit] == '1' )
+ valueAnd &= Truth[v];
+ else if ( pSop[lit] == '0' )
+ valueAnd &= ~Truth[v];
+ else if ( pSop[lit] != '-' )
+ assert( 0 );
+ }
+ valueOr |= valueAnd;
+ assert( pSop[lit] == ' ' );
+ lit++;
+ lit++;
+ assert( pSop[lit] == '\n' );
+ lit++;
+ } while ( pSop[lit] );
+ if ( Kit_PlaIsComplement(pSop) )
+ valueOr = ~valueOr;
+ return valueOr;
+}
+
+/**Fnction*************************************************************
+
+ Synopsis [Converting SOP into a truth table.]
+
+ Description [The SOP is represented as a C-string, as documented in
+ file "bblif.h". The truth table is returned as a bit-string composed
+ of 2^nVars bits. For functions of less than 6 variables, the full
+ machine word is returned. (The truth table looks as if the function
+ had 5 variables.) The use of this procedure should be limited to
+ Boolean functions with no more than 16 inputs.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Kit_PlaToTruth( char * pSop, int nVars, Vec_Ptr_t * vVars, unsigned * pTemp, unsigned * pTruth )
+{
+ int v, c, nCubes, fCompl = 0;
+ assert( pSop != NULL );
+ assert( nVars >= 0 );
+ if ( strlen(pSop) % (nVars + 3) != 0 )
+ {
+ printf( "Kit_PlaToTruth(): SOP is represented incorrectly.\n" );
+ return;
+ }
+ // iterate through the cubes
+ Kit_TruthClear( pTruth, nVars );
+ nCubes = strlen(pSop) / (nVars + 3);
+ for ( c = 0; c < nCubes; c++ )
+ {
+ fCompl = (pSop[nVars+1] == '0');
+ Kit_TruthFill( pTemp, nVars );
+ // iterate through the literals of the cube
+ for ( v = 0; v < nVars; v++ )
+ if ( pSop[v] == '1' )
+ Kit_TruthAnd( pTemp, pTemp, (unsigned *)Vec_PtrEntry(vVars, v), nVars );
+ else if ( pSop[v] == '0' )
+ Kit_TruthSharp( pTemp, pTemp, (unsigned *)Vec_PtrEntry(vVars, v), nVars );
+ // add cube to storage
+ Kit_TruthOr( pTruth, pTruth, pTemp, nVars );
+ // go to the next cube
+ pSop += (nVars + 3);
+ }
+ if ( fCompl )
+ Kit_TruthNot( pTruth, pTruth, nVars );
+}
+
+
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/kit/kitSop.c b/src/aig/kit/kitSop.c
index 0d1b9e2c..21ea69b8 100644
--- a/src/aig/kit/kitSop.c
+++ b/src/aig/kit/kitSop.c
@@ -20,6 +20,9 @@
#include "kit.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -510,7 +513,7 @@ void Kit_SopDivisorZeroKernel_rec( Kit_Sop_t * cSop, int nLits )
iLit = Kit_SopWorstLiteral( cSop, nLits );
if ( iLit == -1 )
return;
- // derive the cube-ABC_FREE quotient
+ // derive the cube-free quotient
Kit_SopDivideByLiteralQuo( cSop, iLit ); // the same cover
Kit_SopMakeCubeFree( cSop ); // the same cover
// call recursively
@@ -572,3 +575,5 @@ void Kit_SopBestLiteralCover( Kit_Sop_t * cResult, Kit_Sop_t * cSop, unsigned uC
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/kit/kitTruth.c b/src/aig/kit/kitTruth.c
index 3f9188c7..56f10ac0 100644
--- a/src/aig/kit/kitTruth.c
+++ b/src/aig/kit/kitTruth.c
@@ -20,6 +20,9 @@
#include "kit.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -187,7 +190,7 @@ void Kit_TruthStretch( unsigned * pOut, unsigned * pIn, int nVars, int nVarsAll,
Description [The input and output truth tables are in pIn/pOut. The current number
of variables is nVars. The total number of variables in nVarsAll. The last argument
- (Phase) contains shows what variables should remain.]
+ (Phase) shows what variables should remain.]
SideEffects [The input truth table is modified.]
@@ -229,7 +232,7 @@ void Kit_TruthShrink( unsigned * pOut, unsigned * pIn, int nVars, int nVarsAll,
***********************************************************************/
void Kit_TruthPermute( unsigned * pOut, unsigned * pIn, int nVars, char * pPerm, int fReturnIn )
{
- int * pTemp;
+ unsigned * pTemp;
int i, Temp, fChange, Counter = 0;
do {
fChange = 0;
@@ -404,6 +407,57 @@ void Kit_TruthCofactor0( unsigned * pTruth, int nVars, int iVar )
/**Function*************************************************************
+ Synopsis [Computes negative cofactor of the function.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Kit_TruthCofactor0Count( unsigned * pTruth, int nVars, int iVar )
+{
+ int nWords = Kit_TruthWordNum( nVars );
+ int i, k, Step, Counter = 0;
+
+ assert( iVar < nVars );
+ switch ( iVar )
+ {
+ case 0:
+ for ( i = 0; i < nWords; i++ )
+ Counter += Kit_WordCountOnes(pTruth[i] & 0x55555555);
+ return Counter;
+ case 1:
+ for ( i = 0; i < nWords; i++ )
+ Counter += Kit_WordCountOnes(pTruth[i] & 0x33333333);
+ return Counter;
+ case 2:
+ for ( i = 0; i < nWords; i++ )
+ Counter += Kit_WordCountOnes(pTruth[i] & 0x0F0F0F0F);
+ return Counter;
+ case 3:
+ for ( i = 0; i < nWords; i++ )
+ Counter += Kit_WordCountOnes(pTruth[i] & 0x00FF00FF);
+ return Counter;
+ case 4:
+ for ( i = 0; i < nWords; i++ )
+ Counter += Kit_WordCountOnes(pTruth[i] & 0x0000FFFF);
+ return Counter;
+ default:
+ Step = (1 << (iVar - 5));
+ for ( k = 0; k < nWords; k += 2*Step )
+ {
+ for ( i = 0; i < Step; i++ )
+ Counter += Kit_WordCountOnes(pTruth[i]);
+ pTruth += 2*Step;
+ }
+ return Counter;
+ }
+}
+
+/**Function*************************************************************
+
Synopsis [Computes positive cofactor of the function.]
Description []
@@ -598,7 +652,7 @@ int Kit_TruthVarIsVacuous( unsigned * pOnset, unsigned * pOffset, int nVars, int
return 1;
case 4:
for ( i = 0; i < nWords; i++ )
- if ( ((pOnset[i] & (pOffset[i] >> 16)) || (pOffset[i] & (pOnset[i] >> 16))) & 0x0000FFFF )
+ if ( ((pOnset[i] & (pOffset[i] >> 16)) | (pOffset[i] & (pOnset[i] >> 16))) & 0x0000FFFF )
return 0;
return 1;
default:
@@ -911,6 +965,77 @@ void Kit_TruthUniqueNew( unsigned * pRes, unsigned * pTruth, int nVars, int iVar
/**Function*************************************************************
+ Synopsis [Returns the number of minterms in the Boolean difference.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Kit_TruthBooleanDiffCount( unsigned * pTruth, int nVars, int iVar )
+{
+ int nWords = Kit_TruthWordNum( nVars );
+ int i, k, Step, Counter = 0;
+
+ assert( iVar < nVars );
+ switch ( iVar )
+ {
+ case 0:
+ for ( i = 0; i < nWords; i++ )
+ Counter += Kit_WordCountOnes( (pTruth[i] ^ (pTruth[i] >> 1)) & 0x55555555 );
+ return Counter;
+ case 1:
+ for ( i = 0; i < nWords; i++ )
+ Counter += Kit_WordCountOnes( (pTruth[i] ^ (pTruth[i] >> 2)) & 0x33333333 );
+ return Counter;
+ case 2:
+ for ( i = 0; i < nWords; i++ )
+ Counter += Kit_WordCountOnes( (pTruth[i] ^ (pTruth[i] >> 4)) & 0x0F0F0F0F );
+ return Counter;
+ case 3:
+ for ( i = 0; i < nWords; i++ )
+ Counter += Kit_WordCountOnes( (pTruth[i] ^ (pTruth[i] >> 8)) & 0x00FF00FF );
+ return Counter;
+ case 4:
+ for ( i = 0; i < nWords; i++ )
+ Counter += Kit_WordCountOnes( (pTruth[i] ^ (pTruth[i] >>16)) & 0x0000FFFF );
+ return Counter;
+ default:
+ Step = (1 << (iVar - 5));
+ for ( k = 0; k < nWords; k += 2*Step )
+ {
+ for ( i = 0; i < Step; i++ )
+ Counter += Kit_WordCountOnes( pTruth[i] ^ pTruth[Step+i] );
+ pTruth += 2*Step;
+ }
+ return Counter;
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the number of minterms in the Boolean difference.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Kit_TruthXorCount( unsigned * pTruth0, unsigned * pTruth1, int nVars )
+{
+ int nWords = Kit_TruthWordNum( nVars );
+ int i, Counter = 0;
+ for ( i = 0; i < nWords; i++ )
+ Counter += Kit_WordCountOnes( pTruth0[i] ^ pTruth1[i] );
+ return Counter;
+}
+
+/**Function*************************************************************
+
Synopsis [Universally quantifies the set of variables.]
Description []
@@ -1059,20 +1184,29 @@ void Kit_TruthMuxVarPhase( unsigned * pOut, unsigned * pCof0, unsigned * pCof1,
SeeAlso []
***********************************************************************/
-int Kit_TruthVarsSymm( unsigned * pTruth, int nVars, int iVar0, int iVar1 )
+int Kit_TruthVarsSymm( unsigned * pTruth, int nVars, int iVar0, int iVar1, unsigned * pCof0, unsigned * pCof1 )
{
- static unsigned uTemp0[16], uTemp1[16];
- assert( nVars <= 9 );
+ static unsigned uTemp0[32], uTemp1[32];
+ if ( pCof0 == NULL )
+ {
+ assert( nVars <= 10 );
+ pCof0 = uTemp0;
+ }
+ if ( pCof1 == NULL )
+ {
+ assert( nVars <= 10 );
+ pCof1 = uTemp1;
+ }
// compute Cof01
- Kit_TruthCopy( uTemp0, pTruth, nVars );
- Kit_TruthCofactor0( uTemp0, nVars, iVar0 );
- Kit_TruthCofactor1( uTemp0, nVars, iVar1 );
+ Kit_TruthCopy( pCof0, pTruth, nVars );
+ Kit_TruthCofactor0( pCof0, nVars, iVar0 );
+ Kit_TruthCofactor1( pCof0, nVars, iVar1 );
// compute Cof10
- Kit_TruthCopy( uTemp1, pTruth, nVars );
- Kit_TruthCofactor1( uTemp1, nVars, iVar0 );
- Kit_TruthCofactor0( uTemp1, nVars, iVar1 );
+ Kit_TruthCopy( pCof1, pTruth, nVars );
+ Kit_TruthCofactor1( pCof1, nVars, iVar0 );
+ Kit_TruthCofactor0( pCof1, nVars, iVar1 );
// compare
- return Kit_TruthIsEqual( uTemp0, uTemp1, nVars );
+ return Kit_TruthIsEqual( pCof0, pCof1, nVars );
}
/**Function*************************************************************
@@ -1086,20 +1220,29 @@ int Kit_TruthVarsSymm( unsigned * pTruth, int nVars, int iVar0, int iVar1 )
SeeAlso []
***********************************************************************/
-int Kit_TruthVarsAntiSymm( unsigned * pTruth, int nVars, int iVar0, int iVar1 )
+int Kit_TruthVarsAntiSymm( unsigned * pTruth, int nVars, int iVar0, int iVar1, unsigned * pCof0, unsigned * pCof1 )
{
- static unsigned uTemp0[16], uTemp1[16];
- assert( nVars <= 9 );
+ static unsigned uTemp0[32], uTemp1[32];
+ if ( pCof0 == NULL )
+ {
+ assert( nVars <= 10 );
+ pCof0 = uTemp0;
+ }
+ if ( pCof1 == NULL )
+ {
+ assert( nVars <= 10 );
+ pCof1 = uTemp1;
+ }
// compute Cof00
- Kit_TruthCopy( uTemp0, pTruth, nVars );
- Kit_TruthCofactor0( uTemp0, nVars, iVar0 );
- Kit_TruthCofactor0( uTemp0, nVars, iVar1 );
+ Kit_TruthCopy( pCof0, pTruth, nVars );
+ Kit_TruthCofactor0( pCof0, nVars, iVar0 );
+ Kit_TruthCofactor0( pCof0, nVars, iVar1 );
// compute Cof11
- Kit_TruthCopy( uTemp1, pTruth, nVars );
- Kit_TruthCofactor1( uTemp1, nVars, iVar0 );
- Kit_TruthCofactor1( uTemp1, nVars, iVar1 );
+ Kit_TruthCopy( pCof1, pTruth, nVars );
+ Kit_TruthCofactor1( pCof1, nVars, iVar0 );
+ Kit_TruthCofactor1( pCof1, nVars, iVar1 );
// compare
- return Kit_TruthIsEqual( uTemp0, uTemp1, nVars );
+ return Kit_TruthIsEqual( pCof0, pCof1, nVars );
}
/**Function*************************************************************
@@ -1691,7 +1834,7 @@ unsigned Kit_TruthSemiCanonicize( unsigned * pInOut, unsigned * pAux, int nVars,
SeeAlso []
***********************************************************************/
-int Kit_TruthCountMinterms( unsigned * pTruth, int nVars, int * pRes, int * pBytes )
+int Kit_TruthCountMinterms( unsigned * pTruth, int nVars, int * pRes, int * pBytesInit )
{
// the number of 1s if every byte as well as in the 0-cofactors w.r.t. three variables
static unsigned Table[256] = {
@@ -1730,6 +1873,7 @@ int Kit_TruthCountMinterms( unsigned * pTruth, int nVars, int * pRes, int * pByt
};
unsigned uSum;
unsigned char * pTruthC, * pLimit;
+ int * pBytes = pBytesInit;
int i, iVar, Step, nWords, nBytes, nTotal;
assert( nVars <= 20 );
@@ -1768,11 +1912,14 @@ int Kit_TruthCountMinterms( unsigned * pTruth, int nVars, int * pRes, int * pByt
for ( iVar = 3, Step = 1; Step < nBytes; Step *= 2, iVar++ )
for ( i = 0; i < nBytes; i += Step + Step )
{
- pRes[iVar] += pBytes[i];
- pBytes[i] += pBytes[i+Step];
+ pRes[iVar] += pBytesInit[i];
+ pBytesInit[i] += pBytesInit[i+Step];
}
- assert( pBytes[0] == nTotal );
+ assert( pBytesInit[0] == nTotal );
assert( iVar == nVars );
+
+ for ( i = 0; i < nVars; i++ )
+ assert( pRes[i] == Kit_TruthCofactor0Count(pTruth, nVars, i) );
return nTotal;
}
@@ -1866,8 +2013,210 @@ char * Kit_TruthDumpToFile( unsigned * pTruth, int nVars, int nFile )
}
+/**Function*************************************************************
+
+ Synopsis [Dumps truth table into a file.]
+
+ Description [Generates script file for reading into ABC.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Kit_TruthPrintProfile_int( unsigned * pTruth, int nVars )
+{
+ int Mints[20];
+ int Mints0[20];
+ int Mints1[20];
+ int Unique1[20];
+ int Total2[20][20];
+ int Unique2[20][20];
+ int Common2[20][20];
+ int nWords = Kit_TruthWordNum( nVars );
+ int * pBytes = ABC_ALLOC( int, nWords * 4 );
+ unsigned * pIn = ABC_ALLOC( unsigned, nWords );
+ unsigned * pOut = ABC_ALLOC( unsigned, nWords );
+ unsigned * pCof00 = ABC_ALLOC( unsigned, nWords );
+ unsigned * pCof01 = ABC_ALLOC( unsigned, nWords );
+ unsigned * pCof10 = ABC_ALLOC( unsigned, nWords );
+ unsigned * pCof11 = ABC_ALLOC( unsigned, nWords );
+ unsigned * pTemp;
+ int nTotalMints, nTotalMints0, nTotalMints1;
+ int v, u, i, iVar, nMints1;
+ int Cof00, Cof01, Cof10, Cof11;
+ int Coz00, Coz01, Coz10, Coz11;
+ assert( nVars <= 20 );
+ assert( nVars >= 6 );
+
+ nTotalMints = Kit_TruthCountMinterms( pTruth, nVars, Mints, pBytes );
+ for ( v = 0; v < nVars; v++ )
+ Unique1[v] = Kit_TruthBooleanDiffCount( pTruth, nVars, v );
+
+ for ( v = 0; v < nVars; v++ )
+ for ( u = 0; u < nVars; u++ )
+ Total2[v][u] = Unique2[v][u] = Common2[v][u] = -1;
+
+ nMints1 = (1<<(nVars-2));
+ for ( v = 0; v < nVars; v++ )
+ {
+ // move this var to be the first
+ Kit_TruthCopy( pIn, pTruth, nVars );
+// Extra_PrintBinary( stdout, pIn, (1<<nVars) ); printf( "\n" );
+ for ( i = v; i < nVars - 1; i++ )
+ {
+ Kit_TruthSwapAdjacentVars( pOut, pIn, nVars, i );
+ pTemp = pIn; pIn = pOut; pOut = pTemp;
+ }
+// Extra_PrintBinary( stdout, pIn, (1<<nVars) ); printf( "\n" );
+// printf( "\n" );
+
+
+ // count minterms in both cofactor
+ nTotalMints0 = Kit_TruthCountMinterms( pIn, nVars-1, Mints0, pBytes );
+ nTotalMints1 = Kit_TruthCountMinterms( pIn+nWords/2, nVars-1, Mints1, pBytes );
+ assert( nTotalMints == nTotalMints0 + nTotalMints1 );
+/*
+ for ( u = 0; u < nVars-1; u++ )
+ printf( "%2d ", Mints0[u] );
+ printf( "\n" );
+
+ for ( u = 0; u < nVars-1; u++ )
+ printf( "%2d ", Mints1[u] );
+ printf( "\n" );
+*/
+ for ( u = 0; u < nVars-1; u++ )
+ {
+ if ( u < v )
+ iVar = u;
+ else
+ iVar = u + 1;
+ assert( v != iVar );
+ // get minter counts in the cofactors
+ Cof00 = Mints0[u]; Coz00 = nMints1 - Cof00;
+ Cof01 = nTotalMints0-Mints0[u]; Coz01 = nMints1 - Cof01;
+ Cof10 = Mints1[u]; Coz10 = nMints1 - Cof10;
+ Cof11 = nTotalMints1-Mints1[u]; Coz11 = nMints1 - Cof11;
+
+ assert( Cof00 >= 0 && Cof00 <= nMints1 );
+ assert( Cof01 >= 0 && Cof01 <= nMints1 );
+ assert( Cof10 >= 0 && Cof10 <= nMints1 );
+ assert( Cof11 >= 0 && Cof11 <= nMints1 );
+
+ assert( Coz00 >= 0 && Coz00 <= nMints1 );
+ assert( Coz01 >= 0 && Coz01 <= nMints1 );
+ assert( Coz10 >= 0 && Coz10 <= nMints1 );
+ assert( Coz11 >= 0 && Coz11 <= nMints1 );
+
+ Common2[v][iVar] = Common2[iVar][v] = Cof00 * Coz11 + Coz00 * Cof11 + Cof01 * Coz10 + Coz01 * Cof10;
+
+ Total2[v][iVar] = Total2[iVar][v] =
+ Cof00 * Coz01 + Coz00 * Cof01 +
+ Cof00 * Coz10 + Coz00 * Cof10 +
+ Cof00 * Coz11 + Coz00 * Cof11 +
+ Cof01 * Coz10 + Coz01 * Cof10 +
+ Cof01 * Coz11 + Coz01 * Cof11 +
+ Cof10 * Coz11 + Coz10 * Cof11 ;
+
+
+ Kit_TruthCofactor0New( pCof00, pIn, nVars-1, u );
+ Kit_TruthCofactor1New( pCof01, pIn, nVars-1, u );
+ Kit_TruthCofactor0New( pCof10, pIn+nWords/2, nVars-1, u );
+ Kit_TruthCofactor1New( pCof11, pIn+nWords/2, nVars-1, u );
+
+ Unique2[v][iVar] = Unique2[iVar][v] =
+ Kit_TruthXorCount( pCof00, pCof01, nVars-1 ) +
+ Kit_TruthXorCount( pCof00, pCof10, nVars-1 ) +
+ Kit_TruthXorCount( pCof00, pCof11, nVars-1 ) +
+ Kit_TruthXorCount( pCof01, pCof10, nVars-1 ) +
+ Kit_TruthXorCount( pCof01, pCof11, nVars-1 ) +
+ Kit_TruthXorCount( pCof10, pCof11, nVars-1 );
+ }
+ }
+
+ printf( "\n" );
+ printf( " V: " );
+ for ( v = 0; v < nVars; v++ )
+ printf( "%8c ", v+'a' );
+ printf( "\n" );
+
+ printf( " M: " );
+ for ( v = 0; v < nVars; v++ )
+ printf( "%8d ", Mints[v] );
+ printf( "\n" );
+
+ printf( " U: " );
+ for ( v = 0; v < nVars; v++ )
+ printf( "%8d ", Unique1[v] );
+ printf( "\n" );
+ printf( "\n" );
+
+ printf( "Unique:\n" );
+ for ( i = 0; i < nVars; i++ )
+ {
+ printf( " %2d ", i );
+ for ( v = 0; v < nVars; v++ )
+ printf( "%8d ", Unique2[i][v] );
+ printf( "\n" );
+ }
+
+ printf( "Common:\n" );
+ for ( i = 0; i < nVars; i++ )
+ {
+ printf( " %2d ", i );
+ for ( v = 0; v < nVars; v++ )
+ printf( "%8d ", Common2[i][v] );
+ printf( "\n" );
+ }
+
+ printf( "Total:\n" );
+ for ( i = 0; i < nVars; i++ )
+ {
+ printf( " %2d ", i );
+ for ( v = 0; v < nVars; v++ )
+ printf( "%8d ", Total2[i][v] );
+ printf( "\n" );
+ }
+
+ ABC_FREE( pIn );
+ ABC_FREE( pOut );
+ ABC_FREE( pCof00 );
+ ABC_FREE( pCof01 );
+ ABC_FREE( pCof10 );
+ ABC_FREE( pCof11 );
+ ABC_FREE( pBytes );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Dumps truth table into a file.]
+
+ Description [Generates script file for reading into ABC.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Kit_TruthPrintProfile( unsigned * pTruth, int nVars )
+{
+ unsigned uTruth[2];
+ if ( nVars >= 6 )
+ {
+ Kit_TruthPrintProfile_int( pTruth, nVars );
+ return;
+ }
+ assert( nVars >= 2 );
+ uTruth[0] = pTruth[0];
+ uTruth[1] = pTruth[0];
+ Kit_TruthPrintProfile( uTruth, 6 );
+}
+
+
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/kit/kit_.c b/src/aig/kit/kit_.c
index 5c68ee3c..37be0b49 100644
--- a/src/aig/kit/kit_.c
+++ b/src/aig/kit/kit_.c
@@ -20,6 +20,9 @@
#include "kit.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -46,3 +49,5 @@
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/live/liveness.c b/src/aig/live/liveness.c
new file mode 100644
index 00000000..e0511556
--- /dev/null
+++ b/src/aig/live/liveness.c
@@ -0,0 +1,2575 @@
+/**CFile****************************************************************
+
+ FileName [liveness.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Liveness property checking.]
+
+ Synopsis [Main implementation module.]
+
+ Author [Sayak Ray]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - January 1, 2009.]
+
+ Revision [$Id: liveness.c,v 1.00 2009/01/01 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include <stdio.h>
+#include "main.h"
+#include "aig.h"
+#include "saig.h"
+#include <string.h>
+#include "mainInt.h"
+
+ABC_NAMESPACE_IMPL_START
+
+#define PROPAGATE_NAMES
+#define MULTIPLE_LTL_FORMULA
+#define ALLOW_SAFETY_PROPERTIES
+
+#define FULL_BIERE_MODE 0
+#define IGNORE_LIVENESS_KEEP_SAFETY_MODE 1
+#define IGNORE_SAFETY_KEEP_LIVENESS_MODE 2
+#define IGNORE_SAFETY_KEEP_LIVENESS_ONE_LOOP_MODE 3
+#define FULL_BIERE_ONE_LOOP_MODE 4
+//#define DUPLICATE_CKT_DEBUG
+
+extern Aig_Man_t * Abc_NtkToDar( Abc_Ntk_t * pNtk, int fExors, int fRegisters );
+extern Abc_Ntk_t * Abc_NtkFromAigPhase( Aig_Man_t * pMan );
+//char *strdup(const char *string);
+
+//******************************************
+//external functions defined in ltl_parser.c
+//******************************************
+typedef struct ltlNode_t ltlNode;
+extern ltlNode *readLtlFormula( char *formula );
+extern void traverseAbstractSyntaxTree( ltlNode *node );
+extern ltlNode *parseFormulaCreateAST( char *inputFormula );
+extern int isWellFormed( ltlNode *topNode );
+extern int checkSignalNameExistence( Abc_Ntk_t *pNtk, ltlNode *topASTNode );
+extern void populateBoolWithAigNodePtr( Abc_Ntk_t *pNtk, Aig_Man_t *pAigOld, Aig_Man_t *pAigNew, ltlNode *topASTNode );
+extern int checkAllBoolHaveAIGPointer( ltlNode *topASTNode );
+extern void populateAigPointerUnitGF( Aig_Man_t *pAigNew, ltlNode *topASTNode, Vec_Ptr_t *vSignal, Vec_Vec_t *vAigGFMap );
+extern void setAIGNodePtrOfGloballyNode( ltlNode *astNode, Aig_Obj_t *pObjLo );
+extern Aig_Obj_t *buildLogicFromLTLNode( Aig_Man_t *pAig, ltlNode *pLtlNode );
+extern Aig_Obj_t *retriveAIGPointerFromLTLNode( ltlNode *astNode );
+extern void traverseAbstractSyntaxTree_postFix( ltlNode *node );
+//**********************************
+//external function declaration ends
+//**********************************
+
+
+/*******************************************************************
+LAYOUT OF PI VECTOR:
+
++------------------------------------------------------------------------------------------------------------------------------------+
+| TRUE ORIGINAL PI (n) | SAVE(PI) (1) | ORIGINAL LO (k) | SAVED(LO) (1) | SHADOW_ORIGINAL LO (k) | LIVENESS LO (l) | FAIRNESS LO (f) |
++------------------------------------------------------------------------------------------------------------------------------------+
+<------------True PI----------------->|<----------------------------LO--------------------------------------------------------------->
+
+LAYOUT OF PO VECTOR:
+
++-----------------------------------------------------------------------------------------------------------+
+| SOLE PO (1) | ORIGINAL LI (k) | SAVED LI (1) | SHADOW_ORIGINAL LI (k) | LIVENESS LI (l) | FAIRNESS LI (f) |
++-----------------------------------------------------------------------------------------------------------+
+<--True PO--->|<--------------------------------------LI---------------------------------------------------->
+
+********************************************************************/
+
+
+static int nodeName_starts_with( Abc_Obj_t *pNode, const char *prefix )
+{
+ if( strstr( Abc_ObjName( pNode ), prefix ) == Abc_ObjName( pNode ) )
+ return 1;
+ else
+ return 0;
+}
+
+void printVecPtrOfString( Vec_Ptr_t *vec )
+{
+ int i;
+
+ for( i=0; i< Vec_PtrSize( vec ); i++ )
+ {
+ printf("vec[%d] = %s\n", i, (char *)Vec_PtrEntry(vec, i) );
+ }
+}
+
+int getPoIndex( Aig_Man_t *pAig, Aig_Obj_t *pPivot )
+{
+ int i;
+ Aig_Obj_t *pObj;
+
+ Saig_ManForEachPo( pAig, pObj, i )
+ {
+ if( pObj == pPivot )
+ return i;
+ }
+ return -1;
+}
+
+char * retrieveTruePiName( Abc_Ntk_t *pNtkOld, Aig_Man_t *pAigOld, Aig_Man_t *pAigNew, Aig_Obj_t *pObjPivot )
+{
+ Aig_Obj_t *pObjOld, *pObj;
+ Abc_Obj_t *pNode;
+ int index;
+
+ assert( Saig_ObjIsPi( pAigNew, pObjPivot ) );
+ Aig_ManForEachPi( pAigNew, pObj, index )
+ if( pObj == pObjPivot )
+ break;
+ assert( index < Aig_ManPiNum( pAigNew ) - Aig_ManRegNum( pAigNew ) );
+ if( index == Saig_ManPiNum( pAigNew ) - 1 )
+ return "SAVE_BIERE";
+ else
+ {
+ pObjOld = Aig_ManPi( pAigOld, index );
+ pNode = Abc_NtkPi( pNtkOld, index );
+ assert( pObjOld->pData == pObjPivot );
+ return Abc_ObjName( pNode );
+ }
+}
+
+char * retrieveLOName( Abc_Ntk_t *pNtkOld, Aig_Man_t *pAigOld, Aig_Man_t *pAigNew, Aig_Obj_t *pObjPivot, Vec_Ptr_t *vLive, Vec_Ptr_t * vFair )
+{
+ Aig_Obj_t *pObjOld, *pObj;
+ Abc_Obj_t *pNode;
+ int index, oldIndex, originalLatchNum = Saig_ManRegNum(pAigOld), strMatch, i;
+ char *dummyStr = (char *)malloc( sizeof(char) * 50 );
+
+ assert( Saig_ObjIsLo( pAigNew, pObjPivot ) );
+ Saig_ManForEachLo( pAigNew, pObj, index )
+ if( pObj == pObjPivot )
+ break;
+ if( index < originalLatchNum )
+ {
+ oldIndex = Saig_ManPiNum( pAigOld ) + index;
+ pObjOld = Aig_ManPi( pAigOld, oldIndex );
+ pNode = Abc_NtkCi( pNtkOld, oldIndex );
+ assert( pObjOld->pData == pObjPivot );
+ return Abc_ObjName( pNode );
+ }
+ else if( index == originalLatchNum )
+ return "SAVED_LO";
+ else if( index > originalLatchNum && index < 2 * originalLatchNum + 1 )
+ {
+ oldIndex = Saig_ManPiNum( pAigOld ) + index - originalLatchNum - 1;
+ pObjOld = Aig_ManPi( pAigOld, oldIndex );
+ pNode = Abc_NtkCi( pNtkOld, oldIndex );
+ sprintf( dummyStr, "%s__%s", Abc_ObjName( pNode ), "SHADOW");
+ return dummyStr;
+ }
+ else if( index >= 2 * originalLatchNum + 1 && index < 2 * originalLatchNum + 1 + Vec_PtrSize( vLive ) )
+ {
+ oldIndex = index - 2 * originalLatchNum - 1;
+ strMatch = 0;
+ dummyStr[0] = '\0';
+ Saig_ManForEachPo( pAigOld, pObj, i )
+ {
+ pNode = Abc_NtkPo( pNtkOld, i );
+ //if( strstr( Abc_ObjName( pNode ), "assert_fair" ) != NULL )
+ if( nodeName_starts_with( pNode, "assert_fair" ) )
+ {
+ if( strMatch == oldIndex )
+ {
+ sprintf( dummyStr, "%s__%s", Abc_ObjName( pNode ), "LIVENESS");
+ //return dummyStr;
+ break;
+ }
+ else
+ strMatch++;
+ }
+ }
+ assert( dummyStr[0] != '\0' );
+ return dummyStr;
+ }
+ else if( index >= 2 * originalLatchNum + 1 + Vec_PtrSize( vLive ) && index < 2 * originalLatchNum + 1 + Vec_PtrSize( vLive ) + Vec_PtrSize( vFair ) )
+ {
+ oldIndex = index - 2 * originalLatchNum - 1 - Vec_PtrSize( vLive );
+ strMatch = 0;
+ dummyStr[0] = '\0';
+ Saig_ManForEachPo( pAigOld, pObj, i )
+ {
+ pNode = Abc_NtkPo( pNtkOld, i );
+ //if( strstr( Abc_ObjName( pNode ), "assume_fair" ) != NULL )
+ if( nodeName_starts_with( pNode, "assume_fair" ) )
+ {
+ if( strMatch == oldIndex )
+ {
+ sprintf( dummyStr, "%s__%s", Abc_ObjName( pNode ), "FAIRNESS");
+ //return dummyStr;
+ break;
+ }
+ else
+ strMatch++;
+ }
+ }
+ assert( dummyStr[0] != '\0' );
+ return dummyStr;
+ }
+ else
+ return "UNKNOWN";
+}
+
+Vec_Ptr_t *vecPis, *vecPiNames;
+Vec_Ptr_t *vecLos, *vecLoNames;
+
+
+int Aig_ManPiCleanupBiere( Aig_Man_t * p )
+{
+ int k = 0, nPisOld = Aig_ManPiNum(p);
+
+ p->nObjs[AIG_OBJ_PI] = Vec_PtrSize( p->vPis );
+ if ( Aig_ManRegNum(p) )
+ p->nTruePis = Aig_ManPiNum(p) - Aig_ManRegNum(p);
+
+ return nPisOld - Aig_ManPiNum(p);
+}
+
+
+int Aig_ManPoCleanupBiere( Aig_Man_t * p )
+{
+ int k = 0, nPosOld = Aig_ManPoNum(p);
+
+ p->nObjs[AIG_OBJ_PO] = Vec_PtrSize( p->vPos );
+ if ( Aig_ManRegNum(p) )
+ p->nTruePos = Aig_ManPoNum(p) - Aig_ManRegNum(p);
+ return nPosOld - Aig_ManPoNum(p);
+}
+
+Aig_Man_t * LivenessToSafetyTransformation( int mode, Abc_Ntk_t * pNtk, Aig_Man_t * p,
+ Vec_Ptr_t *vLive, Vec_Ptr_t *vFair, Vec_Ptr_t *vAssertSafety, Vec_Ptr_t *vAssumeSafety )
+{
+ Aig_Man_t * pNew;
+ int i, nRegCount;
+ Aig_Obj_t * pObjSavePi;
+ Aig_Obj_t *pObjSavedLo, *pObjSavedLi;
+ Aig_Obj_t *pObj, *pMatch;
+ Aig_Obj_t *pObjSaveOrSaved, *pObjSaveAndNotSaved, *pObjSavedLoAndEquality;
+ Aig_Obj_t *pObjShadowLo, *pObjShadowLi, *pObjShadowLiDriver;
+ Aig_Obj_t *pObjXor, *pObjXnor, *pObjAndAcc;
+ Aig_Obj_t *pObjLive, *pObjFair, *pObjSafetyGate;
+ Aig_Obj_t *pObjSafetyPropertyOutput;
+ Aig_Obj_t *pObjOriginalSafetyPropertyOutput;
+ Aig_Obj_t *pDriverImage, *pArgument, *collectiveAssertSafety, *collectiveAssumeSafety;
+ char *nodeName;
+ int piCopied = 0, liCopied = 0, loCopied = 0, liCreated = 0, loCreated = 0, piVecIndex = 0, liveLatch = 0, fairLatch = 0;
+
+ vecPis = Vec_PtrAlloc( Saig_ManPiNum( p ) + 1);
+ vecPiNames = Vec_PtrAlloc( Saig_ManPiNum( p ) + 1);
+
+ vecLos = Vec_PtrAlloc( Saig_ManRegNum( p )*2 + 1 + Vec_PtrSize( vLive ) + Vec_PtrSize( vFair ) );
+ vecLoNames = Vec_PtrAlloc( Saig_ManRegNum( p )*2 + 1 + Vec_PtrSize( vLive ) + Vec_PtrSize( vFair ) );
+
+ //****************************************************************
+ // Step1: create the new manager
+ // Note: The new manager is created with "2 * Aig_ManObjNumMax(p)"
+ // nodes, but this selection is arbitrary - need to be justified
+ //****************************************************************
+ pNew = Aig_ManStart( 2 * Aig_ManObjNumMax(p) );
+ pNew->pName = (char *)malloc( strlen( pNtk->pName ) + strlen("_l2s") + 1 );
+ sprintf(pNew->pName, "%s_%s", pNtk->pName, "l2s");
+ pNew->pSpec = NULL;
+
+ //****************************************************************
+ // Step 2: map constant nodes
+ //****************************************************************
+ pObj = Aig_ManConst1( p );
+ pObj->pData = Aig_ManConst1( pNew );
+
+ //****************************************************************
+ // Step 3: create true PIs
+ //****************************************************************
+ Saig_ManForEachPi( p, pObj, i )
+ {
+ piCopied++;
+ pObj->pData = Aig_ObjCreatePi(pNew);
+ Vec_PtrPush( vecPis, pObj->pData );
+ nodeName = Aig_UtilStrsav(Abc_ObjName( Abc_NtkPi( pNtk, i ) ));
+ Vec_PtrPush( vecPiNames, nodeName );
+ }
+
+ //****************************************************************
+ // Step 4: create the special Pi corresponding to SAVE
+ //****************************************************************
+ if( mode == FULL_BIERE_MODE || mode == IGNORE_SAFETY_KEEP_LIVENESS_MODE )
+ {
+ pObjSavePi = Aig_ObjCreatePi( pNew );
+ nodeName = "SAVE_BIERE",
+ Vec_PtrPush( vecPiNames, nodeName );
+ }
+
+ //****************************************************************
+ // Step 5: create register outputs
+ //****************************************************************
+ Saig_ManForEachLo( p, pObj, i )
+ {
+ loCopied++;
+ pObj->pData = Aig_ObjCreatePi(pNew);
+ Vec_PtrPush( vecLos, pObj->pData );
+ nodeName = Aig_UtilStrsav(Abc_ObjName( Abc_NtkCi( pNtk, Abc_NtkPiNum(pNtk) + i ) ));
+ Vec_PtrPush( vecLoNames, nodeName );
+ }
+
+ //****************************************************************
+ // Step 6: create "saved" register output
+ //****************************************************************
+ if( mode == FULL_BIERE_MODE || mode == IGNORE_SAFETY_KEEP_LIVENESS_MODE )
+ {
+ loCreated++;
+ pObjSavedLo = Aig_ObjCreatePi( pNew );
+ Vec_PtrPush( vecLos, pObjSavedLo );
+ nodeName = "SAVED_LO";
+ Vec_PtrPush( vecLoNames, nodeName );
+ }
+
+ //****************************************************************
+ // Step 7: create the OR gate and the AND gate directly fed by "SAVE" Pi
+ //****************************************************************
+ if( mode == FULL_BIERE_MODE || mode == IGNORE_SAFETY_KEEP_LIVENESS_MODE )
+ {
+ pObjSaveOrSaved = Aig_Or( pNew, pObjSavePi, pObjSavedLo );
+ pObjSaveAndNotSaved = Aig_And( pNew, pObjSavePi, Aig_Not(pObjSavedLo) );
+ }
+
+ //********************************************************************
+ // Step 8: create internal nodes
+ //********************************************************************
+ Aig_ManForEachNode( p, pObj, i )
+ {
+ pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
+ }
+
+
+ //********************************************************************
+ // Step 8.x : create PO for each safety assertions
+ // NOTE : Here the output is purposely inverted as it will be thrown to
+ // dprove
+ //********************************************************************
+ if( mode == FULL_BIERE_MODE || mode == IGNORE_LIVENESS_KEEP_SAFETY_MODE )
+ {
+ if( Vec_PtrSize( vAssertSafety ) != 0 && Vec_PtrSize( vAssumeSafety ) == 0 )
+ {
+ pObjAndAcc = Aig_ManConst1( pNew );
+ Vec_PtrForEachEntry( Aig_Obj_t *, vAssertSafety, pObj, i )
+ {
+ pArgument = Aig_NotCond( (Aig_Obj_t *)Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0( pObj ) );
+ pObjAndAcc = Aig_And( pNew, pArgument, pObjAndAcc );
+ }
+ pObjOriginalSafetyPropertyOutput = Aig_ObjCreatePo( pNew, Aig_Not(pObjAndAcc) );
+ }
+ else if( Vec_PtrSize( vAssertSafety ) != 0 && Vec_PtrSize( vAssumeSafety ) != 0 )
+ {
+ pObjAndAcc = Aig_ManConst1( pNew );
+ Vec_PtrForEachEntry( Aig_Obj_t *, vAssertSafety, pObj, i )
+ {
+ pArgument = Aig_NotCond( (Aig_Obj_t *)Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0( pObj ) );
+ pObjAndAcc = Aig_And( pNew, pArgument, pObjAndAcc );
+ }
+ collectiveAssertSafety = pObjAndAcc;
+
+ pObjAndAcc = Aig_ManConst1( pNew );
+ Vec_PtrForEachEntry( Aig_Obj_t *, vAssumeSafety, pObj, i )
+ {
+ pArgument = Aig_NotCond( (Aig_Obj_t *)Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0( pObj ) );
+ pObjAndAcc = Aig_And( pNew, pArgument, pObjAndAcc );
+ }
+ collectiveAssumeSafety = pObjAndAcc;
+ pObjOriginalSafetyPropertyOutput = Aig_ObjCreatePo( pNew, Aig_And( pNew, Aig_Not(collectiveAssertSafety), collectiveAssumeSafety ) );
+ }
+ else
+ {
+ printf("WARNING!! No safety property is found, a new (negated) constant 1 output is created\n");
+ pObjOriginalSafetyPropertyOutput = Aig_ObjCreatePo( pNew, Aig_Not( Aig_ManConst1(pNew) ) );
+ }
+ }
+
+ //********************************************************************
+ // Step 9: create the safety property output gate for the liveness properties
+ // discuss with Sat/Alan for an alternative implementation
+ //********************************************************************
+ if( mode == FULL_BIERE_MODE || mode == IGNORE_SAFETY_KEEP_LIVENESS_MODE )
+ {
+ pObjSafetyPropertyOutput = Aig_ObjCreatePo( pNew, (Aig_Obj_t *)Aig_ObjFanin0(pObj)->pData );
+ }
+
+ // create register inputs for the original registers
+ nRegCount = 0;
+
+ Saig_ManForEachLo( p, pObj, i )
+ {
+ pMatch = Saig_ObjLoToLi( p, pObj );
+ Aig_ObjCreatePo( pNew, Aig_NotCond((Aig_Obj_t *)Aig_ObjFanin0(pMatch)->pData, Aig_ObjFaninC0( pMatch ) ) );
+ nRegCount++;
+ liCopied++;
+ }
+
+ // create register input corresponding to the register "saved"
+ if( mode == FULL_BIERE_MODE || mode == IGNORE_SAFETY_KEEP_LIVENESS_MODE )
+ {
+ #ifndef DUPLICATE_CKT_DEBUG
+ pObjSavedLi = Aig_ObjCreatePo( pNew, pObjSaveOrSaved );
+ nRegCount++;
+ liCreated++;
+
+ //Changed on October 13, 2009
+ //pObjAndAcc = NULL;
+ pObjAndAcc = Aig_ManConst1( pNew );
+
+ // create the family of shadow registers, then create the cascade of Xnor and And gates for the comparator
+ Saig_ManForEachLo( p, pObj, i )
+ {
+ pObjShadowLo = Aig_ObjCreatePi( pNew );
+
+ #ifdef PROPAGATE_NAMES
+ Vec_PtrPush( vecLos, pObjShadowLo );
+ nodeName = (char *)malloc( strlen( Abc_ObjName( Abc_NtkCi( pNtk, Abc_NtkPiNum(pNtk) + i ) ) ) + 10 );
+ sprintf( nodeName, "%s__%s", Abc_ObjName( Abc_NtkCi( pNtk, Abc_NtkPiNum(pNtk) + i ) ), "SHADOW" );
+
+ Vec_PtrPush( vecLoNames, nodeName );
+ #endif
+
+ pObjShadowLiDriver = Aig_Mux( pNew, pObjSaveAndNotSaved, (Aig_Obj_t *)pObj->pData, pObjShadowLo );
+ pObjShadowLi = Aig_ObjCreatePo( pNew, pObjShadowLiDriver );
+ nRegCount++;
+ loCreated++; liCreated++;
+
+ pObjXor = Aig_Exor( pNew, (Aig_Obj_t *)pObj->pData, pObjShadowLo );
+ pObjXnor = Aig_Not( pObjXor );
+
+ pObjAndAcc = Aig_And( pNew, pObjXnor, pObjAndAcc );
+ }
+
+ // create the AND gate whose output will be the signal "looped"
+ pObjSavedLoAndEquality = Aig_And( pNew, pObjSavedLo, pObjAndAcc );
+
+ // create the master AND gate and corresponding AND and OR logic for the liveness properties
+ pObjAndAcc = Aig_ManConst1( pNew );
+ if( vLive == NULL || Vec_PtrSize( vLive ) == 0 )
+ {
+ printf("Circuit without any liveness property\n");
+ }
+ else
+ {
+ Vec_PtrForEachEntry( Aig_Obj_t *, vLive, pObj, i )
+ {
+ liveLatch++;
+ pDriverImage = Aig_NotCond((Aig_Obj_t *)Aig_Regular(Aig_ObjChild0( pObj ))->pData, Aig_ObjFaninC0(pObj));
+ pObjShadowLo = Aig_ObjCreatePi( pNew );
+
+ #ifdef PROPAGATE_NAMES
+ Vec_PtrPush( vecLos, pObjShadowLo );
+ nodeName = (char *)malloc( strlen( Abc_ObjName( Abc_NtkPo( pNtk, getPoIndex( p, pObj ) ) ) ) + 12 );
+ sprintf( nodeName, "%s__%s", Abc_ObjName( Abc_NtkPo( pNtk, getPoIndex( p, pObj ) ) ), "LIVENESS" );
+ Vec_PtrPush( vecLoNames, nodeName );
+ #endif
+
+ pObjShadowLiDriver = Aig_Or( pNew, pObjShadowLo, Aig_And( pNew, pDriverImage, pObjSaveOrSaved ) );
+ pObjShadowLi = Aig_ObjCreatePo( pNew, pObjShadowLiDriver );
+ nRegCount++;
+ loCreated++; liCreated++;
+
+ pObjAndAcc = Aig_And( pNew, pObjShadowLo, pObjAndAcc );
+ }
+ }
+
+ pObjLive = pObjAndAcc;
+
+ pObjAndAcc = Aig_ManConst1( pNew );
+ if( vFair == NULL || Vec_PtrSize( vFair ) == 0 )
+ printf("Circuit without any fairness property\n");
+ else
+ {
+ Vec_PtrForEachEntry( Aig_Obj_t *, vFair, pObj, i )
+ {
+ fairLatch++;
+ pDriverImage = Aig_NotCond((Aig_Obj_t *)Aig_Regular(Aig_ObjChild0( pObj ))->pData, Aig_ObjFaninC0(pObj));
+ pObjShadowLo = Aig_ObjCreatePi( pNew );
+
+ #ifdef PROPAGATE_NAMES
+ Vec_PtrPush( vecLos, pObjShadowLo );
+ nodeName = (char *)malloc( strlen( Abc_ObjName( Abc_NtkPo( pNtk, getPoIndex( p, pObj ) ) ) ) + 12 );
+ sprintf( nodeName, "%s__%s", Abc_ObjName( Abc_NtkPo( pNtk, getPoIndex( p, pObj ) ) ), "FAIRNESS" );
+ Vec_PtrPush( vecLoNames, nodeName );
+ #endif
+
+ pObjShadowLiDriver = Aig_Or( pNew, pObjShadowLo, Aig_And( pNew, pDriverImage, pObjSaveOrSaved ) );
+ pObjShadowLi = Aig_ObjCreatePo( pNew, pObjShadowLiDriver );
+ nRegCount++;
+ loCreated++; liCreated++;
+
+ pObjAndAcc = Aig_And( pNew, pObjShadowLo, pObjAndAcc );
+ }
+ }
+
+ pObjFair = pObjAndAcc;
+
+ //pObjSafetyGate = Aig_Exor( pNew, Aig_Not(Aig_ManConst1( pNew )), Aig_And( pNew, pObjSavedLoAndEquality, Aig_And( pNew, pObjFair, Aig_Not( pObjLive ) ) ) );
+ //Following is the actual Biere translation
+ pObjSafetyGate = Aig_And( pNew, pObjSavedLoAndEquality, Aig_And( pNew, pObjFair, Aig_Not( pObjLive ) ) );
+
+ Aig_ObjPatchFanin0( pNew, pObjSafetyPropertyOutput, pObjSafetyGate );
+ #endif
+ }
+
+ Aig_ManSetRegNum( pNew, nRegCount );
+
+ Aig_ManPiCleanupBiere( pNew );
+ Aig_ManPoCleanupBiere( pNew );
+
+ Aig_ManCleanup( pNew );
+
+ assert( Aig_ManCheck( pNew ) );
+
+ if( mode == FULL_BIERE_MODE || mode == IGNORE_SAFETY_KEEP_LIVENESS_MODE )
+ {
+ assert((Aig_Obj_t *)Vec_PtrEntry(pNew->vPos, Saig_ManPoNum(pNew)+Aig_ObjPioNum(pObjSavedLo)-Saig_ManPiNum(p)-1) == pObjSavedLi);
+ assert( Saig_ManPiNum( p ) + 1 == Saig_ManPiNum( pNew ) );
+ assert( Saig_ManRegNum( pNew ) == Saig_ManRegNum( p ) * 2 + 1 + liveLatch + fairLatch );
+ }
+
+ return pNew;
+}
+
+
+
+
+
+Aig_Man_t * LivenessToSafetyTransformationAbs( int mode, Abc_Ntk_t * pNtk, Aig_Man_t * p, Vec_Int_t *vFlops,
+ Vec_Ptr_t *vLive, Vec_Ptr_t *vFair, Vec_Ptr_t *vAssertSafety, Vec_Ptr_t *vAssumeSafety )
+{
+ Aig_Man_t * pNew;
+ int i, nRegCount, iEntry;
+ Aig_Obj_t * pObjSavePi;
+ Aig_Obj_t *pObjSavedLo, *pObjSavedLi;
+ Aig_Obj_t *pObj, *pMatch;
+ Aig_Obj_t *pObjSaveOrSaved, *pObjSaveAndNotSaved, *pObjSavedLoAndEquality;
+ Aig_Obj_t *pObjShadowLo, *pObjShadowLi, *pObjShadowLiDriver;
+ Aig_Obj_t *pObjXor, *pObjXnor, *pObjAndAcc;
+ Aig_Obj_t *pObjLive, *pObjFair, *pObjSafetyGate;
+ Aig_Obj_t *pObjSafetyPropertyOutput;
+ Aig_Obj_t *pDriverImage, *pArgument, *collectiveAssertSafety, *collectiveAssumeSafety;
+ char *nodeName;
+ int piCopied = 0, liCopied = 0, loCopied = 0, liCreated = 0, loCreated = 0, piVecIndex = 0, liveLatch = 0, fairLatch = 0;
+
+ vecPis = Vec_PtrAlloc( Saig_ManPiNum( p ) + 1);
+ vecPiNames = Vec_PtrAlloc( Saig_ManPiNum( p ) + 1);
+
+ vecLos = Vec_PtrAlloc( Saig_ManRegNum( p ) + Vec_IntSize( vFlops ) + 1 + Vec_PtrSize( vLive ) + Vec_PtrSize( vFair ) );
+ vecLoNames = Vec_PtrAlloc( Saig_ManRegNum( p ) + Vec_IntSize( vFlops ) + 1 + Vec_PtrSize( vLive ) + Vec_PtrSize( vFair ) );
+
+ //****************************************************************
+ // Step1: create the new manager
+ // Note: The new manager is created with "2 * Aig_ManObjNumMax(p)"
+ // nodes, but this selection is arbitrary - need to be justified
+ //****************************************************************
+ pNew = Aig_ManStart( 2 * Aig_ManObjNumMax(p) );
+ pNew->pName = (char *)malloc( strlen( pNtk->pName ) + strlen("_l2s") + 1 );
+ sprintf(pNew->pName, "%s_%s", pNtk->pName, "l2s");
+ pNew->pSpec = NULL;
+
+ //****************************************************************
+ // Step 2: map constant nodes
+ //****************************************************************
+ pObj = Aig_ManConst1( p );
+ pObj->pData = Aig_ManConst1( pNew );
+
+ //****************************************************************
+ // Step 3: create true PIs
+ //****************************************************************
+ Saig_ManForEachPi( p, pObj, i )
+ {
+ piCopied++;
+ pObj->pData = Aig_ObjCreatePi(pNew);
+ Vec_PtrPush( vecPis, pObj->pData );
+ nodeName = Aig_UtilStrsav(Abc_ObjName( Abc_NtkPi( pNtk, i ) ));
+ Vec_PtrPush( vecPiNames, nodeName );
+ }
+
+ //****************************************************************
+ // Step 4: create the special Pi corresponding to SAVE
+ //****************************************************************
+ if( mode == FULL_BIERE_MODE || mode == IGNORE_SAFETY_KEEP_LIVENESS_MODE )
+ {
+ pObjSavePi = Aig_ObjCreatePi( pNew );
+ nodeName = "SAVE_BIERE",
+ Vec_PtrPush( vecPiNames, nodeName );
+ }
+
+ //****************************************************************
+ // Step 5: create register outputs
+ //****************************************************************
+ Saig_ManForEachLo( p, pObj, i )
+ {
+ loCopied++;
+ pObj->pData = Aig_ObjCreatePi(pNew);
+ Vec_PtrPush( vecLos, pObj->pData );
+ nodeName = Aig_UtilStrsav(Abc_ObjName( Abc_NtkCi( pNtk, Abc_NtkPiNum(pNtk) + i ) ));
+ Vec_PtrPush( vecLoNames, nodeName );
+ }
+
+ //****************************************************************
+ // Step 6: create "saved" register output
+ //****************************************************************
+ if( mode == FULL_BIERE_MODE || mode == IGNORE_SAFETY_KEEP_LIVENESS_MODE )
+ {
+ loCreated++;
+ pObjSavedLo = Aig_ObjCreatePi( pNew );
+ Vec_PtrPush( vecLos, pObjSavedLo );
+ nodeName = "SAVED_LO";
+ Vec_PtrPush( vecLoNames, nodeName );
+ }
+
+ //****************************************************************
+ // Step 7: create the OR gate and the AND gate directly fed by "SAVE" Pi
+ //****************************************************************
+ if( mode == FULL_BIERE_MODE || mode == IGNORE_SAFETY_KEEP_LIVENESS_MODE )
+ {
+ pObjSaveOrSaved = Aig_Or( pNew, pObjSavePi, pObjSavedLo );
+ pObjSaveAndNotSaved = Aig_And( pNew, pObjSavePi, Aig_Not(pObjSavedLo) );
+ }
+
+ //********************************************************************
+ // Step 8: create internal nodes
+ //********************************************************************
+ Aig_ManForEachNode( p, pObj, i )
+ {
+ pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
+ }
+
+
+ //********************************************************************
+ // Step 8.x : create PO for each safety assertions
+ // NOTE : Here the output is purposely inverted as it will be thrown to
+ // dprove
+ //********************************************************************
+ if( mode == FULL_BIERE_MODE || mode == IGNORE_LIVENESS_KEEP_SAFETY_MODE )
+ {
+ if( Vec_PtrSize( vAssertSafety ) != 0 && Vec_PtrSize( vAssumeSafety ) == 0 )
+ {
+ pObjAndAcc = Aig_ManConst1( pNew );
+ Vec_PtrForEachEntry( Aig_Obj_t *, vAssertSafety, pObj, i )
+ {
+ pArgument = Aig_NotCond( (Aig_Obj_t *)Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0( pObj ) );
+ pObjAndAcc = Aig_And( pNew, pArgument, pObjAndAcc );
+ }
+ Aig_ObjCreatePo( pNew, Aig_Not(pObjAndAcc) );
+ }
+ else if( Vec_PtrSize( vAssertSafety ) != 0 && Vec_PtrSize( vAssumeSafety ) != 0 )
+ {
+ pObjAndAcc = Aig_ManConst1( pNew );
+ Vec_PtrForEachEntry( Aig_Obj_t *, vAssertSafety, pObj, i )
+ {
+ pArgument = Aig_NotCond( (Aig_Obj_t *)Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0( pObj ) );
+ pObjAndAcc = Aig_And( pNew, pArgument, pObjAndAcc );
+ }
+ collectiveAssertSafety = pObjAndAcc;
+
+ pObjAndAcc = Aig_ManConst1( pNew );
+ Vec_PtrForEachEntry( Aig_Obj_t *, vAssumeSafety, pObj, i )
+ {
+ pArgument = Aig_NotCond( (Aig_Obj_t *)Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0( pObj ) );
+ pObjAndAcc = Aig_And( pNew, pArgument, pObjAndAcc );
+ }
+ collectiveAssumeSafety = pObjAndAcc;
+ Aig_ObjCreatePo( pNew, Aig_And( pNew, Aig_Not(collectiveAssertSafety), collectiveAssumeSafety ) );
+ }
+ else
+ {
+ printf("WARNING!! No safety property is found, a new (negated) constant 1 output is created\n");
+ Aig_ObjCreatePo( pNew, Aig_Not( Aig_ManConst1(pNew) ) );
+ }
+ }
+
+ //********************************************************************
+ // Step 9: create the safety property output gate for the liveness properties
+ // discuss with Sat/Alan for an alternative implementation
+ //********************************************************************
+ if( mode == FULL_BIERE_MODE || mode == IGNORE_SAFETY_KEEP_LIVENESS_MODE )
+ {
+ pObjSafetyPropertyOutput = Aig_ObjCreatePo( pNew, (Aig_Obj_t *)Aig_ObjFanin0(pObj)->pData );
+ }
+
+ // create register inputs for the original registers
+ nRegCount = 0;
+
+ Saig_ManForEachLo( p, pObj, i )
+ {
+ pMatch = Saig_ObjLoToLi( p, pObj );
+ Aig_ObjCreatePo( pNew, Aig_NotCond((Aig_Obj_t *)Aig_ObjFanin0(pMatch)->pData, Aig_ObjFaninC0( pMatch ) ) );
+ nRegCount++;
+ liCopied++;
+ }
+
+ // create register input corresponding to the register "saved"
+ if( mode == FULL_BIERE_MODE || mode == IGNORE_SAFETY_KEEP_LIVENESS_MODE )
+ {
+ #ifndef DUPLICATE_CKT_DEBUG
+ pObjSavedLi = Aig_ObjCreatePo( pNew, pObjSaveOrSaved );
+ nRegCount++;
+ liCreated++;
+
+ //Changed on October 13, 2009
+ //pObjAndAcc = NULL;
+ pObjAndAcc = Aig_ManConst1( pNew );
+
+ // create the family of shadow registers, then create the cascade of Xnor and And gates for the comparator
+ //Saig_ManForEachLo( p, pObj, i )
+ Saig_ManForEachLo( p, pObj, i )
+ {
+ printf("Flop[%d] = %s\n", i, Abc_ObjName( Abc_NtkCi( pNtk, Abc_NtkPiNum(pNtk) + i ) ) );
+ }
+ Vec_IntForEachEntry( vFlops, iEntry, i )
+ {
+ pObjShadowLo = Aig_ObjCreatePi( pNew );
+ pObj = Aig_ManLo( p, iEntry );
+
+ #ifdef PROPAGATE_NAMES
+ Vec_PtrPush( vecLos, pObjShadowLo );
+ nodeName = (char *)malloc( strlen( Abc_ObjName( Abc_NtkCi( pNtk, Abc_NtkPiNum(pNtk) + iEntry ) ) ) + 10 );
+ sprintf( nodeName, "%s__%s", Abc_ObjName( Abc_NtkCi( pNtk, Abc_NtkPiNum(pNtk) + iEntry ) ), "SHADOW" );
+ printf("Flop copied [%d] = %s\n", iEntry, nodeName );
+ Vec_PtrPush( vecLoNames, nodeName );
+ #endif
+
+ pObjShadowLiDriver = Aig_Mux( pNew, pObjSaveAndNotSaved, (Aig_Obj_t *)pObj->pData, pObjShadowLo );
+ pObjShadowLi = Aig_ObjCreatePo( pNew, pObjShadowLiDriver );
+ nRegCount++;
+ loCreated++; liCreated++;
+
+ pObjXor = Aig_Exor( pNew, (Aig_Obj_t *)pObj->pData, pObjShadowLo );
+ pObjXnor = Aig_Not( pObjXor );
+
+ pObjAndAcc = Aig_And( pNew, pObjXnor, pObjAndAcc );
+ }
+
+ // create the AND gate whose output will be the signal "looped"
+ pObjSavedLoAndEquality = Aig_And( pNew, pObjSavedLo, pObjAndAcc );
+
+ // create the master AND gate and corresponding AND and OR logic for the liveness properties
+ pObjAndAcc = Aig_ManConst1( pNew );
+ if( vLive == NULL || Vec_PtrSize( vLive ) == 0 )
+ {
+ printf("Circuit without any liveness property\n");
+ }
+ else
+ {
+ Vec_PtrForEachEntry( Aig_Obj_t *, vLive, pObj, i )
+ {
+ liveLatch++;
+ pDriverImage = Aig_NotCond((Aig_Obj_t *)Aig_Regular(Aig_ObjChild0( pObj ))->pData, Aig_ObjFaninC0(pObj));
+ pObjShadowLo = Aig_ObjCreatePi( pNew );
+
+ #ifdef PROPAGATE_NAMES
+ Vec_PtrPush( vecLos, pObjShadowLo );
+ nodeName = (char *)malloc( strlen( Abc_ObjName( Abc_NtkPo( pNtk, getPoIndex( p, pObj ) ) ) ) + 12 );
+ sprintf( nodeName, "%s__%s", Abc_ObjName( Abc_NtkPo( pNtk, getPoIndex( p, pObj ) ) ), "LIVENESS" );
+ Vec_PtrPush( vecLoNames, nodeName );
+ #endif
+
+ pObjShadowLiDriver = Aig_Or( pNew, pObjShadowLo, Aig_And( pNew, pDriverImage, pObjSaveOrSaved ) );
+ pObjShadowLi = Aig_ObjCreatePo( pNew, pObjShadowLiDriver );
+ nRegCount++;
+ loCreated++; liCreated++;
+
+ pObjAndAcc = Aig_And( pNew, pObjShadowLo, pObjAndAcc );
+ }
+ }
+
+ pObjLive = pObjAndAcc;
+
+ pObjAndAcc = Aig_ManConst1( pNew );
+ if( vFair == NULL || Vec_PtrSize( vFair ) == 0 )
+ printf("Circuit without any fairness property\n");
+ else
+ {
+ Vec_PtrForEachEntry( Aig_Obj_t *, vFair, pObj, i )
+ {
+ fairLatch++;
+ pDriverImage = Aig_NotCond((Aig_Obj_t *)Aig_Regular(Aig_ObjChild0( pObj ))->pData, Aig_ObjFaninC0(pObj));
+ pObjShadowLo = Aig_ObjCreatePi( pNew );
+
+ #ifdef PROPAGATE_NAMES
+ Vec_PtrPush( vecLos, pObjShadowLo );
+ nodeName = (char *)malloc( strlen( Abc_ObjName( Abc_NtkPo( pNtk, getPoIndex( p, pObj ) ) ) ) + 12 );
+ sprintf( nodeName, "%s__%s", Abc_ObjName( Abc_NtkPo( pNtk, getPoIndex( p, pObj ) ) ), "FAIRNESS" );
+ Vec_PtrPush( vecLoNames, nodeName );
+ #endif
+
+ pObjShadowLiDriver = Aig_Or( pNew, pObjShadowLo, Aig_And( pNew, pDriverImage, pObjSaveOrSaved ) );
+ pObjShadowLi = Aig_ObjCreatePo( pNew, pObjShadowLiDriver );
+ nRegCount++;
+ loCreated++; liCreated++;
+
+ pObjAndAcc = Aig_And( pNew, pObjShadowLo, pObjAndAcc );
+ }
+ }
+
+ pObjFair = pObjAndAcc;
+
+ //pObjSafetyGate = Aig_Exor( pNew, Aig_Not(Aig_ManConst1( pNew )), Aig_And( pNew, pObjSavedLoAndEquality, Aig_And( pNew, pObjFair, Aig_Not( pObjLive ) ) ) );
+ //Following is the actual Biere translation
+ pObjSafetyGate = Aig_And( pNew, pObjSavedLoAndEquality, Aig_And( pNew, pObjFair, Aig_Not( pObjLive ) ) );
+
+ Aig_ObjPatchFanin0( pNew, pObjSafetyPropertyOutput, pObjSafetyGate );
+ #endif
+ }
+
+ Aig_ManSetRegNum( pNew, nRegCount );
+
+ Aig_ManPiCleanupBiere( pNew );
+ Aig_ManPoCleanupBiere( pNew );
+
+ Aig_ManCleanup( pNew );
+
+ assert( Aig_ManCheck( pNew ) );
+
+ if( mode == FULL_BIERE_MODE || mode == IGNORE_SAFETY_KEEP_LIVENESS_MODE )
+ {
+ assert((Aig_Obj_t *)Vec_PtrEntry(pNew->vPos, Saig_ManPoNum(pNew)+Aig_ObjPioNum(pObjSavedLo)-Saig_ManPiNum(p)-1) == pObjSavedLi);
+ assert( Saig_ManPiNum( p ) + 1 == Saig_ManPiNum( pNew ) );
+ assert( Saig_ManRegNum( pNew ) == Saig_ManRegNum( p ) + Vec_IntSize( vFlops ) + 1 + liveLatch + fairLatch );
+ }
+
+ return pNew;
+}
+
+
+
+Aig_Man_t * LivenessToSafetyTransformationOneStepLoop( int mode, Abc_Ntk_t * pNtk, Aig_Man_t * p,
+ Vec_Ptr_t *vLive, Vec_Ptr_t *vFair, Vec_Ptr_t *vAssertSafety, Vec_Ptr_t *vAssumeSafety )
+{
+ Aig_Man_t * pNew;
+ int i, nRegCount;
+ Aig_Obj_t * pObjSavePi;
+ Aig_Obj_t *pObj, *pMatch;
+ Aig_Obj_t *pObjSavedLoAndEquality;
+ Aig_Obj_t *pObjXor, *pObjXnor, *pObjAndAcc, *pObjAndAccDummy;
+ Aig_Obj_t *pObjLive, *pObjFair, *pObjSafetyGate;
+ Aig_Obj_t *pObjSafetyPropertyOutput;
+ Aig_Obj_t *pDriverImage;
+ Aig_Obj_t *pObjCorrespondingLi;
+ Aig_Obj_t *pArgument;
+ Aig_Obj_t *collectiveAssertSafety, *collectiveAssumeSafety;
+
+ char *nodeName;
+ int piCopied = 0, liCopied = 0, loCopied = 0, liCreated = 0, loCreated = 0, piVecIndex = 0;
+
+ if( Aig_ManRegNum( p ) == 0 )
+ {
+ printf("The input AIG contains no register, returning the original AIG as it is\n");
+ return p;
+ }
+
+ vecPis = Vec_PtrAlloc( Saig_ManPiNum( p ) + 1);
+ vecPiNames = Vec_PtrAlloc( Saig_ManPiNum( p ) + 1);
+
+ vecLos = Vec_PtrAlloc( Saig_ManRegNum( p )*2 + 1 + Vec_PtrSize( vLive ) + Vec_PtrSize( vFair ) );
+ vecLoNames = Vec_PtrAlloc( Saig_ManRegNum( p )*2 + 1 + Vec_PtrSize( vLive ) + Vec_PtrSize( vFair ) );
+
+ //****************************************************************
+ // Step1: create the new manager
+ // Note: The new manager is created with "2 * Aig_ManObjNumMax(p)"
+ // nodes, but this selection is arbitrary - need to be justified
+ //****************************************************************
+ pNew = Aig_ManStart( 2 * Aig_ManObjNumMax(p) );
+ pNew->pName = Aig_UtilStrsav( "live2safe" );
+ pNew->pSpec = NULL;
+
+ //****************************************************************
+ // Step 2: map constant nodes
+ //****************************************************************
+ pObj = Aig_ManConst1( p );
+ pObj->pData = Aig_ManConst1( pNew );
+
+ //****************************************************************
+ // Step 3: create true PIs
+ //****************************************************************
+ Saig_ManForEachPi( p, pObj, i )
+ {
+ piCopied++;
+ pObj->pData = Aig_ObjCreatePi(pNew);
+ Vec_PtrPush( vecPis, pObj->pData );
+ nodeName = Aig_UtilStrsav(Abc_ObjName( Abc_NtkPi( pNtk, i ) ));
+ Vec_PtrPush( vecPiNames, nodeName );
+ }
+
+ //****************************************************************
+ // Step 4: create the special Pi corresponding to SAVE
+ //****************************************************************
+ if( mode == FULL_BIERE_ONE_LOOP_MODE || mode == IGNORE_SAFETY_KEEP_LIVENESS_ONE_LOOP_MODE )
+ {
+ pObjSavePi = Aig_ObjCreatePi( pNew );
+ nodeName = "SAVE_BIERE",
+ Vec_PtrPush( vecPiNames, nodeName );
+ }
+
+ //****************************************************************
+ // Step 5: create register outputs
+ //****************************************************************
+ Saig_ManForEachLo( p, pObj, i )
+ {
+ loCopied++;
+ pObj->pData = Aig_ObjCreatePi(pNew);
+ Vec_PtrPush( vecLos, pObj->pData );
+ nodeName = Aig_UtilStrsav(Abc_ObjName( Abc_NtkCi( pNtk, Abc_NtkPiNum(pNtk) + i ) ));
+ Vec_PtrPush( vecLoNames, nodeName );
+ }
+
+ //****************************************************************
+ // Step 6: create "saved" register output
+ //****************************************************************
+
+#if 0
+ loCreated++;
+ pObjSavedLo = Aig_ObjCreatePi( pNew );
+ Vec_PtrPush( vecLos, pObjSavedLo );
+ nodeName = "SAVED_LO";
+ Vec_PtrPush( vecLoNames, nodeName );
+#endif
+
+ //****************************************************************
+ // Step 7: create the OR gate and the AND gate directly fed by "SAVE" Pi
+ //****************************************************************
+#if 0
+ pObjSaveOrSaved = Aig_Or( pNew, pObjSavePi, pObjSavedLo );
+ pObjSaveAndNotSaved = Aig_And( pNew, pObjSavePi, Aig_Not(pObjSavedLo) );
+#endif
+
+ //********************************************************************
+ // Step 8: create internal nodes
+ //********************************************************************
+ Aig_ManForEachNode( p, pObj, i )
+ {
+ pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
+ }
+
+#if 0
+ //********************************************************************
+ // Step 8.x : create PO for each safety assertions
+ //********************************************************************
+ Vec_PtrForEachEntry( Aig_Obj_t *, vAssertSafety, pObj, i )
+ {
+ pObj->pData = Aig_ObjCreatePo( pNew, Aig_NotCond(Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0( pObj ) ) );
+ }
+#endif
+
+ if( mode == FULL_BIERE_ONE_LOOP_MODE || mode == IGNORE_LIVENESS_KEEP_SAFETY_MODE )
+ {
+ if( Vec_PtrSize( vAssertSafety ) != 0 && Vec_PtrSize( vAssumeSafety ) == 0 )
+ {
+ pObjAndAcc = NULL;
+ Vec_PtrForEachEntry( Aig_Obj_t *, vAssertSafety, pObj, i )
+ {
+ //pObj->pData = Aig_ObjCreatePo( pNew, Aig_NotCond(Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0( pObj ) ) );
+ pArgument = Aig_NotCond( (Aig_Obj_t *)Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0( pObj ) );
+ if( pObjAndAcc == NULL )
+ pObjAndAcc = pArgument;
+ else
+ {
+ pObjAndAccDummy = pObjAndAcc;
+ pObjAndAcc = Aig_And( pNew, pArgument, pObjAndAccDummy );
+ }
+ }
+ Aig_ObjCreatePo( pNew, Aig_Not(pObjAndAcc) );
+ }
+ else if( Vec_PtrSize( vAssertSafety ) != 0 && Vec_PtrSize( vAssumeSafety ) != 0 )
+ {
+ pObjAndAcc = NULL;
+ Vec_PtrForEachEntry( Aig_Obj_t *, vAssertSafety, pObj, i )
+ {
+ //pObj->pData = Aig_ObjCreatePo( pNew, Aig_NotCond(Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0( pObj ) ) );
+ pArgument = Aig_NotCond( (Aig_Obj_t *)Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0( pObj ) );
+ if( pObjAndAcc == NULL )
+ pObjAndAcc = pArgument;
+ else
+ {
+ pObjAndAccDummy = pObjAndAcc;
+ pObjAndAcc = Aig_And( pNew, pArgument, pObjAndAccDummy );
+ }
+ }
+ collectiveAssertSafety = pObjAndAcc;
+ pObjAndAcc = NULL;
+ Vec_PtrForEachEntry( Aig_Obj_t *, vAssumeSafety, pObj, i )
+ {
+ //pObj->pData = Aig_ObjCreatePo( pNew, Aig_NotCond(Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0( pObj ) ) );
+ pArgument = Aig_NotCond( (Aig_Obj_t *)Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0( pObj ) );
+ if( pObjAndAcc == NULL )
+ pObjAndAcc = pArgument;
+ else
+ {
+ pObjAndAccDummy = pObjAndAcc;
+ pObjAndAcc = Aig_And( pNew, pArgument, pObjAndAccDummy );
+ }
+ }
+ collectiveAssumeSafety = pObjAndAcc;
+ Aig_ObjCreatePo( pNew, Aig_And( pNew, Aig_Not(collectiveAssertSafety), collectiveAssumeSafety ) );
+ }
+ else
+ printf("No safety property is specified, hence no safety gate is created\n");
+ }
+
+ //********************************************************************
+ // Step 9: create the safety property output gate
+ // create the safety property output gate, this will be the sole true PO
+ // of the whole circuit, discuss with Sat/Alan for an alternative implementation
+ //********************************************************************
+
+ if( mode == FULL_BIERE_ONE_LOOP_MODE || mode == IGNORE_SAFETY_KEEP_LIVENESS_ONE_LOOP_MODE )
+ {
+ pObjSafetyPropertyOutput = Aig_ObjCreatePo( pNew, (Aig_Obj_t *)Aig_ObjFanin0(pObj)->pData );
+ }
+
+ // create register inputs for the original registers
+ nRegCount = 0;
+
+ Saig_ManForEachLo( p, pObj, i )
+ {
+ pMatch = Saig_ObjLoToLi( p, pObj );
+ //Aig_ObjCreatePo( pNew, Aig_ObjChild0Copy(pMatch) );
+ Aig_ObjCreatePo( pNew, Aig_NotCond((Aig_Obj_t *)Aig_ObjFanin0(pMatch)->pData, Aig_ObjFaninC0( pMatch ) ) );
+ nRegCount++;
+ liCopied++;
+ }
+
+#if 0
+ // create register input corresponding to the register "saved"
+ pObjSavedLi = Aig_ObjCreatePo( pNew, pObjSaveOrSaved );
+ nRegCount++;
+ liCreated++;7
+#endif
+
+ pObjAndAcc = NULL;
+
+ //****************************************************************************************************
+ //For detection of loop of length 1 we do not need any shadow register, we only need equality detector
+ //between Lo_j and Li_j and then a cascade of AND gates
+ //****************************************************************************************************
+
+ if( mode == FULL_BIERE_ONE_LOOP_MODE || mode == IGNORE_SAFETY_KEEP_LIVENESS_ONE_LOOP_MODE )
+ {
+ Saig_ManForEachLo( p, pObj, i )
+ {
+ pObjCorrespondingLi = Saig_ObjLoToLi( p, pObj );
+
+ pObjXor = Aig_Exor( pNew, (Aig_Obj_t *)pObj->pData, Aig_NotCond( (Aig_Obj_t *)Aig_ObjFanin0( pObjCorrespondingLi )->pData, Aig_ObjFaninC0( pObjCorrespondingLi ) ) );
+ pObjXnor = Aig_Not( pObjXor );
+
+ if( pObjAndAcc == NULL )
+ pObjAndAcc = pObjXnor;
+ else
+ {
+ pObjAndAccDummy = pObjAndAcc;
+ pObjAndAcc = Aig_And( pNew, pObjXnor, pObjAndAccDummy );
+ }
+ }
+
+ // create the AND gate whose output will be the signal "looped"
+ pObjSavedLoAndEquality = Aig_And( pNew, pObjSavePi, pObjAndAcc );
+
+ // create the master AND gate and corresponding AND and OR logic for the liveness properties
+ pObjAndAcc = NULL;
+ if( vLive == NULL || Vec_PtrSize( vLive ) == 0 )
+ printf("Circuit without any liveness property\n");
+ else
+ {
+ Vec_PtrForEachEntry( Aig_Obj_t *, vLive, pObj, i )
+ {
+ pDriverImage = Aig_NotCond((Aig_Obj_t *)Aig_Regular(Aig_ObjChild0( pObj ))->pData, Aig_ObjFaninC0(pObj));
+ if( pObjAndAcc == NULL )
+ pObjAndAcc = pDriverImage;
+ else
+ {
+ pObjAndAccDummy = pObjAndAcc;
+ pObjAndAcc = Aig_And( pNew, pDriverImage, pObjAndAccDummy );
+ }
+ }
+ }
+
+ if( pObjAndAcc != NULL )
+ pObjLive = pObjAndAcc;
+ else
+ pObjLive = Aig_ManConst1( pNew );
+
+ // create the master AND gate and corresponding AND and OR logic for the fairness properties
+ pObjAndAcc = NULL;
+ if( vFair == NULL || Vec_PtrSize( vFair ) == 0 )
+ printf("Circuit without any fairness property\n");
+ else
+ {
+ Vec_PtrForEachEntry( Aig_Obj_t *, vFair, pObj, i )
+ {
+ pDriverImage = Aig_NotCond((Aig_Obj_t *)Aig_Regular(Aig_ObjChild0( pObj ))->pData, Aig_ObjFaninC0(pObj));
+ if( pObjAndAcc == NULL )
+ pObjAndAcc = pDriverImage;
+ else
+ {
+ pObjAndAccDummy = pObjAndAcc;
+ pObjAndAcc = Aig_And( pNew, pDriverImage, pObjAndAccDummy );
+ }
+ }
+ }
+
+ if( pObjAndAcc != NULL )
+ pObjFair = pObjAndAcc;
+ else
+ pObjFair = Aig_ManConst1( pNew );
+
+ pObjSafetyGate = Aig_And( pNew, pObjSavedLoAndEquality, Aig_And( pNew, pObjFair, Aig_Not( pObjLive ) ) );
+
+ Aig_ObjPatchFanin0( pNew, pObjSafetyPropertyOutput, pObjSafetyGate );
+ }
+
+ Aig_ManSetRegNum( pNew, nRegCount );
+
+ //printf("\nSaig_ManPiNum = %d, Reg Num = %d, before everything, before Pi cleanup\n", Vec_PtrSize( pNew->vPis ), pNew->nRegs );
+
+ Aig_ManPiCleanupBiere( pNew );
+ Aig_ManPoCleanupBiere( pNew );
+
+ Aig_ManCleanup( pNew );
+
+ assert( Aig_ManCheck( pNew ) );
+
+ return pNew;
+}
+
+
+
+Vec_Ptr_t * populateLivenessVector( Abc_Ntk_t *pNtk, Aig_Man_t *pAig )
+{
+ Abc_Obj_t * pNode;
+ int i, liveCounter = 0;
+ Vec_Ptr_t * vLive;
+
+ vLive = Vec_PtrAlloc( 100 );
+ Abc_NtkForEachPo( pNtk, pNode, i )
+ //if( strstr( Abc_ObjName( pNode ), "assert_fair") != NULL )
+ if( nodeName_starts_with( pNode, "assert_fair" ) )
+ {
+ Vec_PtrPush( vLive, Aig_ManPo( pAig, i ) );
+ liveCounter++;
+ }
+ printf("Number of liveness property found = %d\n", liveCounter);
+ return vLive;
+}
+
+Vec_Ptr_t * populateFairnessVector( Abc_Ntk_t *pNtk, Aig_Man_t *pAig )
+{
+ Abc_Obj_t * pNode;
+ int i, fairCounter = 0;
+ Vec_Ptr_t * vFair;
+
+ vFair = Vec_PtrAlloc( 100 );
+ Abc_NtkForEachPo( pNtk, pNode, i )
+ //if( strstr( Abc_ObjName( pNode ), "assume_fair") != NULL )
+ if( nodeName_starts_with( pNode, "assume_fair" ) )
+ {
+ Vec_PtrPush( vFair, Aig_ManPo( pAig, i ) );
+ fairCounter++;
+ }
+ printf("Number of fairness property found = %d\n", fairCounter);
+ return vFair;
+}
+
+Vec_Ptr_t * populateSafetyAssertionVector( Abc_Ntk_t *pNtk, Aig_Man_t *pAig )
+{
+ Abc_Obj_t * pNode;
+ int i, assertSafetyCounter = 0;
+ Vec_Ptr_t * vAssertSafety;
+
+ vAssertSafety = Vec_PtrAlloc( 100 );
+ Abc_NtkForEachPo( pNtk, pNode, i )
+ //if( strstr( Abc_ObjName( pNode ), "Assert") != NULL )
+ if( nodeName_starts_with( pNode, "assert_safety" ) || nodeName_starts_with( pNode, "Assert" ))
+ {
+ Vec_PtrPush( vAssertSafety, Aig_ManPo( pAig, i ) );
+ assertSafetyCounter++;
+ }
+ printf("Number of safety property found = %d\n", assertSafetyCounter);
+ return vAssertSafety;
+}
+
+Vec_Ptr_t * populateSafetyAssumptionVector( Abc_Ntk_t *pNtk, Aig_Man_t *pAig )
+{
+ Abc_Obj_t * pNode;
+ int i, assumeSafetyCounter = 0;
+ Vec_Ptr_t * vAssumeSafety;
+
+ vAssumeSafety = Vec_PtrAlloc( 100 );
+ Abc_NtkForEachPo( pNtk, pNode, i )
+ //if( strstr( Abc_ObjName( pNode ), "Assert") != NULL )
+ if( nodeName_starts_with( pNode, "assume_safety" ) || nodeName_starts_with( pNode, "Assume" ))
+ {
+ Vec_PtrPush( vAssumeSafety, Aig_ManPo( pAig, i ) );
+ assumeSafetyCounter++;
+ }
+ printf("Number of assume_safety property found = %d\n", assumeSafetyCounter);
+ return vAssumeSafety;
+}
+
+void updateNewNetworkNameManager( Abc_Ntk_t *pNtk, Aig_Man_t *pAig, Vec_Ptr_t *vPiNames, Vec_Ptr_t *vLoNames )
+{
+ Aig_Obj_t *pObj;
+ Abc_Obj_t *pNode;
+ int i, ntkObjId;
+
+ pNtk->pManName = Nm_ManCreate( Abc_NtkCiNum( pNtk ) );
+
+ if( vPiNames )
+ {
+ Saig_ManForEachPi( pAig, pObj, i )
+ {
+ ntkObjId = Abc_NtkCi( pNtk, i )->Id;
+ //printf("Pi %d, Saved Name = %s, id = %d\n", i, Nm_ManStoreIdName( pNtk->pManName, ntkObjId, Aig_ObjType(pObj), Vec_PtrEntry(vPiNames, i), NULL ), ntkObjId);
+ Nm_ManStoreIdName( pNtk->pManName, ntkObjId, Aig_ObjType(pObj), (char *)Vec_PtrEntry(vPiNames, i), NULL );
+ }
+ }
+ if( vLoNames )
+ {
+ Saig_ManForEachLo( pAig, pObj, i )
+ {
+ ntkObjId = Abc_NtkCi( pNtk, Saig_ManPiNum( pAig ) + i )->Id;
+ //printf("Lo %d, Saved name = %s, id = %d\n", i, Nm_ManStoreIdName( pNtk->pManName, ntkObjId, Aig_ObjType(pObj), Vec_PtrEntry(vLoNames, i), NULL ), ntkObjId);
+ Nm_ManStoreIdName( pNtk->pManName, ntkObjId, Aig_ObjType(pObj), (char *)Vec_PtrEntry(vLoNames, i), NULL );
+ }
+ }
+
+ Abc_NtkForEachPo(pNtk, pNode, i)
+ {
+ Abc_ObjAssignName(pNode, "assert_safety_", Abc_ObjName(pNode) );
+ }
+
+ // assign latch input names
+ Abc_NtkForEachLatch(pNtk, pNode, i)
+ if ( Nm_ManFindNameById(pNtk->pManName, Abc_ObjFanin0(pNode)->Id) == NULL )
+ Abc_ObjAssignName( Abc_ObjFanin0(pNode), Abc_ObjName(Abc_ObjFanin0(pNode)), NULL );
+}
+
+
+int Abc_CommandAbcLivenessToSafety( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ FILE * pOut, * pErr;
+ Abc_Ntk_t * pNtk, * pNtkTemp, *pNtkNew, *pNtkOld;
+ Aig_Man_t * pAig, *pAigNew;
+ int c;
+ Vec_Ptr_t * vLive, * vFair, *vAssertSafety, *vAssumeSafety;
+ int directive = -1;
+
+ pNtk = Abc_FrameReadNtk(pAbc);
+ pOut = Abc_FrameReadOut(pAbc);
+ pErr = Abc_FrameReadErr(pAbc);
+
+ if( argc == 1 )
+ {
+ assert( directive == -1 );
+ directive = FULL_BIERE_MODE;
+ }
+ else
+ {
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "1slh" ) ) != EOF )
+ {
+ switch( c )
+ {
+ case '1':
+ if( directive == -1 )
+ directive = FULL_BIERE_ONE_LOOP_MODE;
+ else
+ {
+ assert( directive == IGNORE_LIVENESS_KEEP_SAFETY_MODE || directive == IGNORE_SAFETY_KEEP_LIVENESS_MODE );
+ if( directive == IGNORE_LIVENESS_KEEP_SAFETY_MODE )
+ directive = IGNORE_LIVENESS_KEEP_SAFETY_MODE;
+ else
+ directive = IGNORE_SAFETY_KEEP_LIVENESS_ONE_LOOP_MODE;
+ }
+ break;
+ case 's':
+ if( directive == -1 )
+ directive = IGNORE_SAFETY_KEEP_LIVENESS_MODE;
+ else
+ {
+ if( directive != FULL_BIERE_ONE_LOOP_MODE )
+ goto usage;
+ assert(directive == FULL_BIERE_ONE_LOOP_MODE);
+ directive = IGNORE_SAFETY_KEEP_LIVENESS_ONE_LOOP_MODE;
+ }
+ break;
+ case 'l':
+ if( directive == -1 )
+ directive = IGNORE_LIVENESS_KEEP_SAFETY_MODE;
+ else
+ {
+ if( directive != FULL_BIERE_ONE_LOOP_MODE )
+ goto usage;
+ assert(directive == FULL_BIERE_ONE_LOOP_MODE);
+ directive = IGNORE_LIVENESS_KEEP_SAFETY_MODE;
+ }
+ break;
+ case 'h':
+ goto usage;
+ default:
+ goto usage;
+ }
+ }
+ }
+
+ if ( pNtk == NULL )
+ {
+ fprintf( pErr, "Empty network.\n" );
+ return 1;
+ }
+ if( !Abc_NtkIsStrash( pNtk ) )
+ {
+ printf("The input network was not strashed, strashing....\n");
+ pNtkTemp = Abc_NtkStrash( pNtk, 0, 0, 0 );
+ pNtkOld = pNtkTemp;
+ pAig = Abc_NtkToDar( pNtkTemp, 0, 1 );
+ vLive = populateLivenessVector( pNtk, pAig );
+ vFair = populateFairnessVector( pNtk, pAig );
+ vAssertSafety = populateSafetyAssertionVector( pNtk, pAig );
+ vAssumeSafety = populateSafetyAssumptionVector( pNtk, pAig );
+ }
+ else
+ {
+ pAig = Abc_NtkToDar( pNtk, 0, 1 );
+ pNtkOld = pNtk;
+ vLive = populateLivenessVector( pNtk, pAig );
+ vFair = populateFairnessVector( pNtk, pAig );
+ vAssertSafety = populateSafetyAssertionVector( pNtk, pAig );
+ vAssumeSafety = populateSafetyAssumptionVector( pNtk, pAig );
+ }
+
+ switch( directive )
+ {
+ case FULL_BIERE_MODE:
+ //if( Vec_PtrSize(vLive) == 0 && Vec_PtrSize(vAssertSafety) == 0 )
+ //{
+ // printf("Input circuit has NO safety and NO liveness property, original network is not disturbed\n");
+ // return 1;
+ //}
+ //else
+ //{
+ pAigNew = LivenessToSafetyTransformation( FULL_BIERE_MODE, pNtk, pAig, vLive, vFair, vAssertSafety, vAssumeSafety );
+ if( Aig_ManRegNum(pAigNew) != 0 )
+ printf("A new circuit is produced with\n\t2 POs - one for safety and one for liveness.\n\tone additional input is added (due to Biere's nondeterminism)\n\tshadow flops are not created if the original circuit is combinational\n\tnon-property POs are suppressed\n");
+ break;
+ //}
+ case FULL_BIERE_ONE_LOOP_MODE:
+ //if( Vec_PtrSize(vLive) == 0 && Vec_PtrSize(vAssertSafety) == 0 )
+ //{
+ // printf("Input circuit has NO safety and NO liveness property, original network is not disturbed\n");
+ // return 1;
+ //}
+ //else
+ //{
+ pAigNew = LivenessToSafetyTransformationOneStepLoop( FULL_BIERE_ONE_LOOP_MODE, pNtk, pAig, vLive, vFair, vAssertSafety, vAssumeSafety );
+ if( Aig_ManRegNum(pAigNew) != 0 )
+ printf("A new circuit is produced with\n\t2 POs - one for safety and one for liveness.\n\tone additional input is added (due to Biere's nondeterminism)\n\tshadow flops are not created\n\tnon-property POs are suppressed\n");
+ break;
+ //}
+ case IGNORE_LIVENESS_KEEP_SAFETY_MODE:
+ //if( Vec_PtrSize(vAssertSafety) == 0 )
+ //{
+ // printf("Input circuit has NO safety property, original network is not disturbed\n");
+ // return 1;
+ //}
+ //else
+ //{
+ pAigNew = LivenessToSafetyTransformation( IGNORE_LIVENESS_KEEP_SAFETY_MODE, pNtk, pAig, vLive, vFair, vAssertSafety, vAssumeSafety );
+ if( Aig_ManRegNum(pAigNew) != 0 )
+ printf("A new circuit is produced with\n\t1 PO - only for safety property; liveness properties are ignored, if any.\n\tno additional input is added (due to Biere's nondeterminism)\n\tshadow flops are not created\n\tnon-property POs are suppressed\n");
+ break;
+ //}
+ case IGNORE_SAFETY_KEEP_LIVENESS_MODE:
+ //if( Vec_PtrSize(vLive) == 0 )
+ //{
+ // printf("Input circuit has NO liveness property, original network is not disturbed\n");
+ // return 1;
+ //}
+ //else
+ //{
+ pAigNew = LivenessToSafetyTransformation( IGNORE_SAFETY_KEEP_LIVENESS_MODE, pNtk, pAig, vLive, vFair, vAssertSafety, vAssumeSafety );
+ if( Aig_ManRegNum(pAigNew) != 0 )
+ printf("A new circuit is produced with\n\t1 PO - only for liveness property; safety properties are ignored, if any.\n\tone additional input is added (due to Biere's nondeterminism)\n\tshadow flops are not created if the original circuit is combinational\n\tnon-property POs are suppressed\n");
+ break;
+ //}
+ case IGNORE_SAFETY_KEEP_LIVENESS_ONE_LOOP_MODE:
+ //if( Vec_PtrSize(vLive) == 0 )
+ //{
+ // printf("Input circuit has NO liveness property, original network is not disturbed\n");
+ // return 1;
+ //}
+ //else
+ //{
+ pAigNew = LivenessToSafetyTransformationOneStepLoop( IGNORE_SAFETY_KEEP_LIVENESS_ONE_LOOP_MODE, pNtk, pAig, vLive, vFair, vAssertSafety, vAssumeSafety );
+ if( Aig_ManRegNum(pAigNew) != 0 )
+ printf("New circuit is produced ignoring safety outputs!\nOnly liveness and fairness outputs are considered.\nShadow registers are not created\n");
+ break;
+ //}
+ }
+
+#if 0
+ if( argc == 1 )
+ {
+ pAigNew = LivenessToSafetyTransformation( FULL_BIERE_MODE, pNtk, pAig, vLive, vFair, vAssertSafety, vAssumeSafety );
+ if( Aig_ManRegNum(pAigNew) != 0 )
+ printf("New circuit is produced considering all safety, liveness and fairness outputs.\nBiere's logic is created\n");
+ }
+ else
+ {
+ Extra_UtilGetoptReset();
+ c = Extra_UtilGetopt( argc, argv, "1lsh" );
+ if( c == '1' )
+ {
+ if ( pNtk == NULL )
+ {
+ fprintf( pErr, "Empty network.\n" );
+ return 1;
+ }
+ if( !Abc_NtkIsStrash( pNtk ) )
+ {
+ printf("The input network was not strashed, strashing....\n");
+ pNtkTemp = Abc_NtkStrash( pNtk, 0, 0, 0 );
+ pNtkOld = pNtkTemp;
+ pAig = Abc_NtkToDar( pNtkTemp, 0, 1 );
+ vLive = populateLivenessVector( pNtk, pAig );
+ vFair = populateFairnessVector( pNtk, pAig );
+ vAssertSafety = populateSafetyAssertionVector( pNtk, pAig );
+ vAssumeSafety = populateSafetyAssumptionVector( pNtk, pAig );
+ }
+ else
+ {
+ pAig = Abc_NtkToDar( pNtk, 0, 1 );
+ pNtkOld = pNtk;
+ vLive = populateLivenessVector( pNtk, pAig );
+ vFair = populateFairnessVector( pNtk, pAig );
+ vAssertSafety = populateSafetyAssertionVector( pNtk, pAig );
+ vAssumeSafety = populateSafetyAssumptionVector( pNtk, pAig );
+ }
+ pAigNew = LivenessToSafetyTransformationOneStepLoop( pNtk, pAig, vLive, vFair, vAssertSafety, vAssumeSafety );
+ }
+ else if( c == 'l' )
+ {
+ if ( pNtk == NULL )
+ {
+ fprintf( pErr, "Empty network.\n" );
+ return 1;
+ }
+ if( !Abc_NtkIsStrash( pNtk ) )
+ {
+ printf("The input network was not strashed, strashing....\n");
+ pNtkTemp = Abc_NtkStrash( pNtk, 0, 0, 0 );
+ pNtkOld = pNtkTemp;
+ pAig = Abc_NtkToDar( pNtkTemp, 0, 1 );
+ vLive = populateLivenessVector( pNtk, pAig );
+ vFair = populateFairnessVector( pNtk, pAig );
+ vAssertSafety = populateSafetyAssertionVector( pNtk, pAig );
+ vAssumeSafety = populateSafetyAssumptionVector( pNtk, pAig );
+ }
+ else
+ {
+ pAig = Abc_NtkToDar( pNtk, 0, 1 );
+ pNtkOld = pNtk;
+ vLive = populateLivenessVector( pNtk, pAig );
+ vFair = populateFairnessVector( pNtk, pAig );
+ vAssertSafety = populateSafetyAssertionVector( pNtk, pAig );
+ vAssumeSafety = populateSafetyAssumptionVector( pNtk, pAig );
+ }
+ pAigNew = LivenessToSafetyTransformation( IGNORE_LIVENESS_KEEP_SAFETY_MODE, pNtk, pAig, vLive, vFair, vAssertSafety, vAssumeSafety );
+ if( Aig_ManRegNum(pAigNew) != 0 )
+ printf("New circuit is produced ignoring liveness outputs!\nOnly safety outputs are kept.\nBiere's logic is not created\n");
+ }
+ else if( c == 's' )
+ {
+ if ( pNtk == NULL )
+ {
+ fprintf( pErr, "Empty network.\n" );
+ return 1;
+ }
+
+ if( !Abc_NtkIsStrash( pNtk ) )
+ {
+ printf("The input network was not strashed, strashing....\n");
+ pNtkTemp = Abc_NtkStrash( pNtk, 0, 0, 0 );
+ pNtkOld = pNtkTemp;
+ pAig = Abc_NtkToDar( pNtkTemp, 0, 1 );
+ vLive = populateLivenessVector( pNtk, pAig );
+ vFair = populateFairnessVector( pNtk, pAig );
+ vAssertSafety = populateSafetyAssertionVector( pNtk, pAig );
+ vAssumeSafety = populateSafetyAssumptionVector( pNtk, pAig );
+ }
+ else
+ {
+ pAig = Abc_NtkToDar( pNtk, 0, 1 );
+ pNtkOld = pNtk;
+ vLive = populateLivenessVector( pNtk, pAig );
+ vFair = populateFairnessVector( pNtk, pAig );
+ vAssertSafety = populateSafetyAssertionVector( pNtk, pAig );
+ vAssumeSafety = populateSafetyAssumptionVector( pNtk, pAig );
+ }
+ pAigNew = LivenessToSafetyTransformation( IGNORE_SAFETY_KEEP_LIVENESS_MODE, pNtk, pAig, vLive, vFair, vAssertSafety, vAssumeSafety );
+ if( Aig_ManRegNum(pAigNew) != 0 )
+ printf("New circuit is produced ignoring safety outputs!\nOnly liveness and fairness outputs are considered.\nBiere's logic is created\n");
+ }
+ else if( c == 'h' )
+ goto usage;
+ else
+ goto usage;
+ }
+#endif
+
+#if 0
+ Aig_ManPrintStats( pAigNew );
+ printf("\nDetail statistics*************************************\n");
+ printf("Number of true primary inputs = %d\n", Saig_ManPiNum( pAigNew ));
+ printf("Number of true primary outputs = %d\n", Saig_ManPoNum( pAigNew ));
+ printf("Number of true latch outputs = %d\n", Saig_ManCiNum( pAigNew ) - Saig_ManPiNum( pAigNew ));
+ printf("Number of true latch inputs = %d\n", Saig_ManCoNum( pAigNew ) - Saig_ManPoNum( pAigNew ));
+ printf("Numer of registers = %d\n", Saig_ManRegNum( pAigNew ) );
+ printf("\n*******************************************************\n");
+#endif
+
+ pNtkNew = Abc_NtkFromAigPhase( pAigNew );
+ pNtkNew->pName = Aig_UtilStrsav( pAigNew->pName );
+
+ if ( !Abc_NtkCheck( pNtkNew ) )
+ fprintf( stdout, "Abc_NtkCreateCone(): Network check has failed.\n" );
+
+ updateNewNetworkNameManager( pNtkNew, pAigNew, vecPiNames, vecLoNames );
+ Abc_FrameSetCurrentNetwork( pAbc, pNtkNew );
+
+#if 0
+#ifndef DUPLICATE_CKT_DEBUG
+ Saig_ManForEachPi( pAigNew, pObj, i )
+ assert( strcmp( (char *)Vec_PtrEntry(vecPiNames, i), retrieveTruePiName( pNtk, pAig, pAigNew, pObj ) ) == 0 );
+ //printf("Name of %d-th Pi = %s, %s\n", i, retrieveTruePiName( pNtk, pAig, pAigNew, pObj ), (char *)Vec_PtrEntry(vecPiNames, i) );
+
+ Saig_ManForEachLo( pAigNew, pObj, i )
+ assert( strcmp( (char *)Vec_PtrEntry(vecLoNames, i), retrieveLOName( pNtk, pAig, pAigNew, pObj, vLive, vFair ) ) == 0 );
+#endif
+#endif
+
+ return 0;
+
+usage:
+ fprintf( stdout, "usage: l2s [-1lsh]\n" );
+ fprintf( stdout, "\t performs Armin Biere's live-to-safe transformation\n" );
+ fprintf( stdout, "\t-1 : no shadow logic, presume all loops are self loops\n");
+ fprintf( stdout, "\t-l : ignore liveness and fairness outputs\n");
+ fprintf( stdout, "\t-s : ignore safety assertions and assumptions\n");
+ fprintf( stdout, "\t-h : print command usage\n");
+ return 1;
+}
+
+Vec_Int_t * prepareFlopVector( Aig_Man_t * pAig, int vectorLength )
+{
+ Vec_Int_t *vFlops;
+ int i;
+
+ vFlops = Vec_IntAlloc( vectorLength );
+
+ for( i=0; i<vectorLength; i++ )
+ Vec_IntPush( vFlops, i );
+
+#if 0
+ Vec_IntPush( vFlops, 19 );
+ Vec_IntPush( vFlops, 20 );
+ Vec_IntPush( vFlops, 23 );
+ Vec_IntPush( vFlops, 24 );
+ //Vec_IntPush( vFlops, 2 );
+ //Vec_IntPush( vFlops, 3 );
+ //Vec_IntPush( vFlops, 4 );
+ //Vec_IntPush( vFlops, 5 );
+ //Vec_IntPush( vFlops, 8 );
+ //Vec_IntPush( vFlops, 9 );
+ //Vec_IntPush( vFlops, 10 );
+ //Vec_IntPush( vFlops, 11 );
+ //Vec_IntPush( vFlops, 0 );
+ //Vec_IntPush( vFlops, 0 );
+#endif
+
+ return vFlops;
+}
+
+int Abc_CommandAbcLivenessToSafetyAbstraction( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ FILE * pOut, * pErr;
+ Abc_Ntk_t * pNtk, * pNtkTemp, *pNtkNew, *pNtkOld;
+ Aig_Man_t * pAig, *pAigNew;
+ int c;
+ Vec_Ptr_t * vLive, * vFair, *vAssertSafety, *vAssumeSafety;
+ int directive = -1;
+ Vec_Int_t * vFlops;
+
+ pNtk = Abc_FrameReadNtk(pAbc);
+ pOut = Abc_FrameReadOut(pAbc);
+ pErr = Abc_FrameReadErr(pAbc);
+
+ if( argc == 1 )
+ {
+ assert( directive == -1 );
+ directive = FULL_BIERE_MODE;
+ }
+ else
+ {
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "1slh" ) ) != EOF )
+ {
+ switch( c )
+ {
+ case '1':
+ if( directive == -1 )
+ directive = FULL_BIERE_ONE_LOOP_MODE;
+ else
+ {
+ assert( directive == IGNORE_LIVENESS_KEEP_SAFETY_MODE || directive == IGNORE_SAFETY_KEEP_LIVENESS_MODE );
+ if( directive == IGNORE_LIVENESS_KEEP_SAFETY_MODE )
+ directive = IGNORE_LIVENESS_KEEP_SAFETY_MODE;
+ else
+ directive = IGNORE_SAFETY_KEEP_LIVENESS_ONE_LOOP_MODE;
+ }
+ break;
+ case 's':
+ if( directive == -1 )
+ directive = IGNORE_SAFETY_KEEP_LIVENESS_MODE;
+ else
+ {
+ if( directive != FULL_BIERE_ONE_LOOP_MODE )
+ goto usage;
+ assert(directive == FULL_BIERE_ONE_LOOP_MODE);
+ directive = IGNORE_SAFETY_KEEP_LIVENESS_ONE_LOOP_MODE;
+ }
+ break;
+ case 'l':
+ if( directive == -1 )
+ directive = IGNORE_LIVENESS_KEEP_SAFETY_MODE;
+ else
+ {
+ if( directive != FULL_BIERE_ONE_LOOP_MODE )
+ goto usage;
+ assert(directive == FULL_BIERE_ONE_LOOP_MODE);
+ directive = IGNORE_LIVENESS_KEEP_SAFETY_MODE;
+ }
+ break;
+ case 'h':
+ goto usage;
+ default:
+ goto usage;
+ }
+ }
+ }
+
+ if ( pNtk == NULL )
+ {
+ fprintf( pErr, "Empty network.\n" );
+ return 1;
+ }
+ if( !Abc_NtkIsStrash( pNtk ) )
+ {
+ printf("The input network was not strashed, strashing....\n");
+ pNtkTemp = Abc_NtkStrash( pNtk, 0, 0, 0 );
+ pNtkOld = pNtkTemp;
+ pAig = Abc_NtkToDar( pNtkTemp, 0, 1 );
+ vLive = populateLivenessVector( pNtk, pAig );
+ vFair = populateFairnessVector( pNtk, pAig );
+ vAssertSafety = populateSafetyAssertionVector( pNtk, pAig );
+ vAssumeSafety = populateSafetyAssumptionVector( pNtk, pAig );
+ }
+ else
+ {
+ pAig = Abc_NtkToDar( pNtk, 0, 1 );
+ pNtkOld = pNtk;
+ vLive = populateLivenessVector( pNtk, pAig );
+ vFair = populateFairnessVector( pNtk, pAig );
+ vAssertSafety = populateSafetyAssertionVector( pNtk, pAig );
+ vAssumeSafety = populateSafetyAssumptionVector( pNtk, pAig );
+ }
+
+ vFlops = prepareFlopVector( pAig, Aig_ManRegNum(pAig)%2 == 0? Aig_ManRegNum(pAig)/2 : (Aig_ManRegNum(pAig)-1)/2);
+
+ //vFlops = prepareFlopVector( pAig, 100 );
+
+ switch( directive )
+ {
+ case FULL_BIERE_MODE:
+ //if( Vec_PtrSize(vLive) == 0 && Vec_PtrSize(vAssertSafety) == 0 )
+ //{
+ // printf("Input circuit has NO safety and NO liveness property, original network is not disturbed\n");
+ // return 1;
+ //}
+ //else
+ //{
+ pAigNew = LivenessToSafetyTransformationAbs( FULL_BIERE_MODE, pNtk, pAig, vFlops, vLive, vFair, vAssertSafety, vAssumeSafety );
+ if( Aig_ManRegNum(pAigNew) != 0 )
+ printf("A new circuit is produced with\n\t2 POs - one for safety and one for liveness.\n\tone additional input is added (due to Biere's nondeterminism)\n\tshadow flops are not created if the original circuit is combinational\n\tnon-property POs are suppressed\n");
+ break;
+ //}
+ case FULL_BIERE_ONE_LOOP_MODE:
+ //if( Vec_PtrSize(vLive) == 0 && Vec_PtrSize(vAssertSafety) == 0 )
+ //{
+ // printf("Input circuit has NO safety and NO liveness property, original network is not disturbed\n");
+ // return 1;
+ //}
+ //else
+ //{
+ pAigNew = LivenessToSafetyTransformationOneStepLoop( FULL_BIERE_ONE_LOOP_MODE, pNtk, pAig, vLive, vFair, vAssertSafety, vAssumeSafety );
+ if( Aig_ManRegNum(pAigNew) != 0 )
+ printf("A new circuit is produced with\n\t2 POs - one for safety and one for liveness.\n\tone additional input is added (due to Biere's nondeterminism)\n\tshadow flops are not created\n\tnon-property POs are suppressed\n");
+ break;
+ //}
+ case IGNORE_LIVENESS_KEEP_SAFETY_MODE:
+ //if( Vec_PtrSize(vAssertSafety) == 0 )
+ //{
+ // printf("Input circuit has NO safety property, original network is not disturbed\n");
+ // return 1;
+ //}
+ //else
+ //{
+ pAigNew = LivenessToSafetyTransformationAbs( IGNORE_LIVENESS_KEEP_SAFETY_MODE, pNtk, pAig, vFlops, vLive, vFair, vAssertSafety, vAssumeSafety );
+ if( Aig_ManRegNum(pAigNew) != 0 )
+ printf("A new circuit is produced with\n\t1 PO - only for safety property; liveness properties are ignored, if any.\n\tno additional input is added (due to Biere's nondeterminism)\n\tshadow flops are not created\n\tnon-property POs are suppressed\n");
+ break;
+ //}
+ case IGNORE_SAFETY_KEEP_LIVENESS_MODE:
+ //if( Vec_PtrSize(vLive) == 0 )
+ //{
+ // printf("Input circuit has NO liveness property, original network is not disturbed\n");
+ // return 1;
+ //}
+ //else
+ //{
+ pAigNew = LivenessToSafetyTransformationAbs( IGNORE_SAFETY_KEEP_LIVENESS_MODE, pNtk, pAig, vFlops, vLive, vFair, vAssertSafety, vAssumeSafety );
+ if( Aig_ManRegNum(pAigNew) != 0 )
+ printf("A new circuit is produced with\n\t1 PO - only for liveness property; safety properties are ignored, if any.\n\tone additional input is added (due to Biere's nondeterminism)\n\tshadow flops are not created if the original circuit is combinational\n\tnon-property POs are suppressed\n");
+ break;
+ //}
+ case IGNORE_SAFETY_KEEP_LIVENESS_ONE_LOOP_MODE:
+ //if( Vec_PtrSize(vLive) == 0 )
+ //{
+ // printf("Input circuit has NO liveness property, original network is not disturbed\n");
+ // return 1;
+ //}
+ //else
+ //{
+ pAigNew = LivenessToSafetyTransformationOneStepLoop( IGNORE_SAFETY_KEEP_LIVENESS_ONE_LOOP_MODE, pNtk, pAig, vLive, vFair, vAssertSafety, vAssumeSafety );
+ if( Aig_ManRegNum(pAigNew) != 0 )
+ printf("New circuit is produced ignoring safety outputs!\nOnly liveness and fairness outputs are considered.\nShadow registers are not created\n");
+ break;
+ //}
+ }
+
+ pNtkNew = Abc_NtkFromAigPhase( pAigNew );
+ pNtkNew->pName = Aig_UtilStrsav( pAigNew->pName );
+
+ if ( !Abc_NtkCheck( pNtkNew ) )
+ fprintf( stdout, "Abc_NtkCreateCone(): Network check has failed.\n" );
+
+ updateNewNetworkNameManager( pNtkNew, pAigNew, vecPiNames,vecLoNames );
+ Abc_FrameSetCurrentNetwork( pAbc, pNtkNew );
+
+#if 0
+#ifndef DUPLICATE_CKT_DEBUG
+ Saig_ManForEachPi( pAigNew, pObj, i )
+ assert( strcmp( (char *)Vec_PtrEntry(vecPiNames, i), retrieveTruePiName( pNtk, pAig, pAigNew, pObj ) ) == 0 );
+ //printf("Name of %d-th Pi = %s, %s\n", i, retrieveTruePiName( pNtk, pAig, pAigNew, pObj ), (char *)Vec_PtrEntry(vecPiNames, i) );
+
+ Saig_ManForEachLo( pAigNew, pObj, i )
+ assert( strcmp( (char *)Vec_PtrEntry(vecLoNames, i), retrieveLOName( pNtk, pAig, pAigNew, pObj, vLive, vFair ) ) == 0 );
+#endif
+#endif
+
+ return 0;
+
+usage:
+ fprintf( stdout, "usage: l2s [-1lsh]\n" );
+ fprintf( stdout, "\t performs Armin Biere's live-to-safe transformation\n" );
+ fprintf( stdout, "\t-1 : no shadow logic, presume all loops are self loops\n");
+ fprintf( stdout, "\t-l : ignore liveness and fairness outputs\n");
+ fprintf( stdout, "\t-s : ignore safety assertions and assumptions\n");
+ fprintf( stdout, "\t-h : print command usage\n");
+ return 1;
+}
+
+Aig_Man_t * LivenessToSafetyTransformationWithLTL( int mode, Abc_Ntk_t * pNtk, Aig_Man_t * p,
+ Vec_Ptr_t *vLive, Vec_Ptr_t *vFair, Vec_Ptr_t *vAssertSafety, Vec_Ptr_t *vAssumeSafety,
+ int *numLtlProcessed, Vec_Ptr_t *ltlBuffer )
+{
+ Aig_Man_t * pNew;
+ int i, ii, iii, nRegCount;
+ Aig_Obj_t * pObjSavePi;
+ Aig_Obj_t *pObjSavedLo, *pObjSavedLi;
+ Aig_Obj_t *pObj, *pMatch;
+ Aig_Obj_t *pObjSaveOrSaved, *pObjSaveAndNotSaved, *pObjSavedLoAndEquality;
+ Aig_Obj_t *pObjShadowLo, *pObjShadowLi, *pObjShadowLiDriver;
+ Aig_Obj_t *pObjXor, *pObjXnor, *pObjAndAcc;
+ Aig_Obj_t *pObjLive, *pObjSafetyGate;
+ Aig_Obj_t *pObjSafetyPropertyOutput;
+ Aig_Obj_t *pObjOriginalSafetyPropertyOutput;
+ Aig_Obj_t *pDriverImage, *pArgument, *collectiveAssertSafety, *collectiveAssumeSafety;
+ Aig_Obj_t *pNegatedSafetyConjunction = NULL;
+ Aig_Obj_t *pObjSafetyAndLiveToSafety;
+ char *nodeName, *pFormula;
+ int piCopied = 0, liCopied = 0, loCopied = 0, liCreated = 0, loCreated = 0, piVecIndex = 0, liveLatch = 0, fairLatch = 0;
+ Vec_Ptr_t *vSignal, *vTopASTNodeArray;
+ ltlNode *pEnrtyGLOBALLY;
+ ltlNode *topNodeOfAST, *tempTopASTNode;
+ Vec_Vec_t *vAigGFMap;
+ Vec_Ptr_t *vSignalMemory, *vGFFlopMemory, *vPoForLtlProps;
+ Vec_Ptr_t *vecInputLtlFormulae;
+
+ vecPis = Vec_PtrAlloc( Saig_ManPiNum( p ) + 1);
+ vecPiNames = Vec_PtrAlloc( Saig_ManPiNum( p ) + 1);
+
+ vecLos = Vec_PtrAlloc( Saig_ManRegNum( p )*2 + 1 + Vec_PtrSize( vLive ) + Vec_PtrSize( vFair ) );
+ vecLoNames = Vec_PtrAlloc( Saig_ManRegNum( p )*2 + 1 + Vec_PtrSize( vLive ) + Vec_PtrSize( vFair ) );
+
+ //****************************************************************
+ //step0: Parsing the LTL formula
+ //****************************************************************
+ //Vec_PtrForEachEntry( char *, pNtk->vLtlProperties, pFormula, i )
+ // printf("\ninput LTL formula [%d] = %s\n", i, pFormula );
+
+
+#ifdef MULTIPLE_LTL_FORMULA
+
+
+ //***************************************************************************
+ //Reading input LTL formulae from Ntk data-structure and creating
+ //AST for them, Steps involved:
+ // parsing -> AST creation -> well-formedness check -> signal name check
+ //***************************************************************************
+
+ //resetting numLtlProcessed
+ *numLtlProcessed = 0;
+
+ if( mode == FULL_BIERE_MODE || mode == IGNORE_SAFETY_KEEP_LIVENESS_MODE )
+ {
+ //if( ltlBuffer )
+ vecInputLtlFormulae = ltlBuffer;
+ //vecInputLtlFormulae = pNtk->vLtlProperties;
+ if( vecInputLtlFormulae )
+ {
+ vTopASTNodeArray = Vec_PtrAlloc( Vec_PtrSize( vecInputLtlFormulae ) );
+ printf("\n");
+ Vec_PtrForEachEntry( char *, vecInputLtlFormulae, pFormula, i )
+ {
+ tempTopASTNode = parseFormulaCreateAST( pFormula );
+ //traverseAbstractSyntaxTree_postFix( tempTopASTNode );
+ if( tempTopASTNode )
+ {
+ printf("Formula %d: AST is created, ", i+1);
+ if( isWellFormed( tempTopASTNode ) )
+ printf("Well-formedness check PASSED, ");
+ else
+ {
+ printf("Well-formedness check FAILED!!\n");
+ printf("AST will be ignored for formula %d, no extra logic will be added for this formula\n", i+1 );
+ //do memory management to free the created AST
+ continue;
+ }
+ if( checkSignalNameExistence( pNtk, tempTopASTNode ) )
+ printf("Signal check PASSED\n");
+ else
+ {
+ printf("Signal check FAILED!!");
+ printf("AST will be ignored for formula %d, no extra logic will be added for this formula\n", i+1 );
+ //do memory management to free the created AST
+ continue;
+ }
+ Vec_PtrPush( vTopASTNodeArray, tempTopASTNode );
+ (*numLtlProcessed)++;
+ }
+ else
+ printf("\nNo AST has been created for formula %d, no extra logic will be added\n", i+1 );
+ }
+ }
+ printf("\n");
+ if( Vec_PtrSize( vTopASTNodeArray ) == 0 )
+ {
+ //printf("\nNo AST has been created for any formula; hence the circuit is left untouched\n");
+ printf("\nCurrently aborting, need to take care when Vec_PtrSize( vTopASTNodeArray ) == 0\n");
+ exit(0);
+ }
+ }
+
+ //****************************************************************
+ // Step1: create the new manager
+ // Note: The new manager is created with "2 * Aig_ManObjNumMax(p)"
+ // nodes, but this selection is arbitrary - need to be justified
+ //****************************************************************
+ pNew = Aig_ManStart( 2 * Aig_ManObjNumMax(p) );
+ pNew->pName = (char *)malloc( strlen( pNtk->pName ) + strlen("_l3s") + 1 );
+ sprintf(pNew->pName, "%s_%s", pNtk->pName, "l3s");
+ pNew->pSpec = NULL;
+
+ //****************************************************************
+ // Step 2: map constant nodes
+ //****************************************************************
+ pObj = Aig_ManConst1( p );
+ pObj->pData = Aig_ManConst1( pNew );
+
+ //****************************************************************
+ // Step 3: create true PIs
+ //****************************************************************
+ Saig_ManForEachPi( p, pObj, i )
+ {
+ piCopied++;
+ pObj->pData = Aig_ObjCreatePi(pNew);
+ Vec_PtrPush( vecPis, pObj->pData );
+ nodeName = Aig_UtilStrsav(Abc_ObjName( Abc_NtkPi( pNtk, i ) ));
+ Vec_PtrPush( vecPiNames, nodeName );
+ }
+
+ //****************************************************************
+ // Step 4: create the special Pi corresponding to SAVE
+ //****************************************************************
+ if( mode == FULL_BIERE_MODE || mode == IGNORE_SAFETY_KEEP_LIVENESS_MODE )
+ {
+ pObjSavePi = Aig_ObjCreatePi( pNew );
+ nodeName = "SAVE_BIERE",
+ Vec_PtrPush( vecPiNames, nodeName );
+ }
+
+ //****************************************************************
+ // Step 5: create register outputs
+ //****************************************************************
+ Saig_ManForEachLo( p, pObj, i )
+ {
+ loCopied++;
+ pObj->pData = Aig_ObjCreatePi(pNew);
+ Vec_PtrPush( vecLos, pObj->pData );
+ nodeName = Aig_UtilStrsav(Abc_ObjName( Abc_NtkCi( pNtk, Abc_NtkPiNum(pNtk) + i ) ));
+ Vec_PtrPush( vecLoNames, nodeName );
+ }
+
+ //****************************************************************
+ // Step 6: create "saved" register output
+ //****************************************************************
+ if( mode == FULL_BIERE_MODE || mode == IGNORE_SAFETY_KEEP_LIVENESS_MODE )
+ {
+ loCreated++;
+ pObjSavedLo = Aig_ObjCreatePi( pNew );
+ Vec_PtrPush( vecLos, pObjSavedLo );
+ nodeName = "SAVED_LO";
+ Vec_PtrPush( vecLoNames, nodeName );
+ }
+
+ //****************************************************************
+ // Step 7: create the OR gate and the AND gate directly fed by "SAVE" Pi
+ //****************************************************************
+ if( mode == FULL_BIERE_MODE || mode == IGNORE_SAFETY_KEEP_LIVENESS_MODE )
+ {
+ pObjSaveOrSaved = Aig_Or( pNew, pObjSavePi, pObjSavedLo );
+ pObjSaveAndNotSaved = Aig_And( pNew, pObjSavePi, Aig_Not(pObjSavedLo) );
+ }
+
+ //********************************************************************
+ // Step 8: create internal nodes
+ //********************************************************************
+ Aig_ManForEachNode( p, pObj, i )
+ {
+ pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
+ }
+
+
+ //********************************************************************
+ // Step 8.x : create PO for each safety assertions
+ // NOTE : Here the output is purposely inverted as it will be thrown to
+ // dprove
+ //********************************************************************
+ assert( pNegatedSafetyConjunction == NULL );
+ if( mode == FULL_BIERE_MODE || mode == IGNORE_LIVENESS_KEEP_SAFETY_MODE || mode == IGNORE_SAFETY_KEEP_LIVENESS_MODE)
+ {
+ if( Vec_PtrSize( vAssertSafety ) != 0 && Vec_PtrSize( vAssumeSafety ) == 0 )
+ {
+ pObjAndAcc = Aig_ManConst1( pNew );
+ Vec_PtrForEachEntry( Aig_Obj_t *, vAssertSafety, pObj, i )
+ {
+ pArgument = Aig_NotCond( (Aig_Obj_t *)Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0( pObj ) );
+ pObjAndAcc = Aig_And( pNew, pArgument, pObjAndAcc );
+ }
+ pNegatedSafetyConjunction = Aig_Not(pObjAndAcc);
+ if( mode == FULL_BIERE_MODE || mode == IGNORE_LIVENESS_KEEP_SAFETY_MODE )
+ pObjOriginalSafetyPropertyOutput = Aig_ObjCreatePo( pNew, Aig_Not(pObjAndAcc) );
+ }
+ else if( Vec_PtrSize( vAssertSafety ) != 0 && Vec_PtrSize( vAssumeSafety ) != 0 )
+ {
+ pObjAndAcc = Aig_ManConst1( pNew );
+ Vec_PtrForEachEntry( Aig_Obj_t *, vAssertSafety, pObj, i )
+ {
+ pArgument = Aig_NotCond( (Aig_Obj_t *)Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0( pObj ) );
+ pObjAndAcc = Aig_And( pNew, pArgument, pObjAndAcc );
+ }
+ collectiveAssertSafety = pObjAndAcc;
+
+ pObjAndAcc = Aig_ManConst1( pNew );
+ Vec_PtrForEachEntry( Aig_Obj_t *, vAssumeSafety, pObj, i )
+ {
+ pArgument = Aig_NotCond( (Aig_Obj_t *)Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0( pObj ) );
+ pObjAndAcc = Aig_And( pNew, pArgument, pObjAndAcc );
+ }
+ collectiveAssumeSafety = pObjAndAcc;
+ pNegatedSafetyConjunction = Aig_And( pNew, Aig_Not(collectiveAssertSafety), collectiveAssumeSafety );
+ if( mode == FULL_BIERE_MODE || mode == IGNORE_LIVENESS_KEEP_SAFETY_MODE )
+ pObjOriginalSafetyPropertyOutput = Aig_ObjCreatePo( pNew, Aig_And( pNew, Aig_Not(collectiveAssertSafety), collectiveAssumeSafety ) );
+ }
+ else
+ {
+ printf("WARNING!! No safety property is found, a new (negated) constant 1 output is created\n");
+ pNegatedSafetyConjunction = Aig_Not( Aig_ManConst1(pNew) );
+ if( mode == FULL_BIERE_MODE || mode == IGNORE_LIVENESS_KEEP_SAFETY_MODE )
+ pObjOriginalSafetyPropertyOutput = Aig_ObjCreatePo( pNew, Aig_Not( Aig_ManConst1(pNew) ) );
+ }
+ }
+ assert( pNegatedSafetyConjunction != NULL );
+
+ //********************************************************************
+ // Step 9: create the safety property output gate for the liveness properties
+ // discuss with Sat/Alan for an alternative implementation
+ //********************************************************************
+ if( mode == FULL_BIERE_MODE || mode == IGNORE_SAFETY_KEEP_LIVENESS_MODE )
+ {
+ vPoForLtlProps = Vec_PtrAlloc( Vec_PtrSize( vTopASTNodeArray ) );
+ if( Vec_PtrSize( vTopASTNodeArray ) )
+ {
+ //no effective AST for any input LTL property
+ //must do something graceful
+ }
+ for( i=0; i<Vec_PtrSize( vTopASTNodeArray ); i++ )
+ {
+ pObjSafetyPropertyOutput = Aig_ObjCreatePo( pNew, (Aig_Obj_t *)Aig_ObjFanin0(pObj)->pData );
+ Vec_PtrPush( vPoForLtlProps, pObjSafetyPropertyOutput );
+ }
+ }
+
+ //*************************************************************************************
+ // Step 10: Placeholder PO's were created for Liveness property outputs in the
+ // last step. FYI, # of new liveness property outputs = # of LTL properties in the circuit
+ // It is time for creation of loop LI's and other stuff
+ // Now creating register inputs for the original flops
+ //*************************************************************************************
+ nRegCount = 0;
+
+ Saig_ManForEachLo( p, pObj, i )
+ {
+ pMatch = Saig_ObjLoToLi( p, pObj );
+ Aig_ObjCreatePo( pNew, Aig_NotCond((Aig_Obj_t *)Aig_ObjFanin0(pMatch)->pData, Aig_ObjFaninC0( pMatch ) ) );
+ nRegCount++;
+ liCopied++;
+ }
+
+ //*************************************************************************************
+ // Step 11: create register input corresponding to the register "saved"
+ //*************************************************************************************
+ if( mode == FULL_BIERE_MODE || mode == IGNORE_SAFETY_KEEP_LIVENESS_MODE )
+ {
+ #ifndef DUPLICATE_CKT_DEBUG
+ pObjSavedLi = Aig_ObjCreatePo( pNew, pObjSaveOrSaved );
+ nRegCount++;
+ liCreated++;
+
+ pObjAndAcc = Aig_ManConst1( pNew );
+
+ //*************************************************************************************
+ // Step 11: create the family of shadow registers, then create the cascade of Xnor
+ // and And gates for the comparator
+ //*************************************************************************************
+ Saig_ManForEachLo( p, pObj, i )
+ {
+ //printf("\nKEMON RENDY = %s", Abc_ObjName( Abc_NtkCi( pNtk, Abc_NtkPiNum(pNtk) + i )) );
+ //top|route0_target0_queue_with_credit0_queue0
+ //top|route0_master0_queue2
+ // if( strcmp( Abc_ObjName( Abc_NtkCi( pNtk, Abc_NtkPiNum(pNtk) + i ) ), "top|route0_queue1_num[0]" ) == 0
+ // || strcmp( Abc_ObjName( Abc_NtkCi( pNtk, Abc_NtkPiNum(pNtk) + i ) ), "top|route0_queue1_num[1]" ) == 0 || strcmp( Abc_ObjName( Abc_NtkCi( pNtk, Abc_NtkPiNum(pNtk) + i ) ), "top|route0_queue1_num[2]" ) == 0 )
+ {
+ pObjShadowLo = Aig_ObjCreatePi( pNew );
+
+ #ifdef PROPAGATE_NAMES
+ Vec_PtrPush( vecLos, pObjShadowLo );
+ nodeName = (char *)malloc( strlen( Abc_ObjName( Abc_NtkCi( pNtk, Abc_NtkPiNum(pNtk) + i ) ) ) + 10 );
+ sprintf( nodeName, "%s__%s", Abc_ObjName( Abc_NtkCi( pNtk, Abc_NtkPiNum(pNtk) + i ) ), "SHADOW" );
+
+ Vec_PtrPush( vecLoNames, nodeName );
+ #endif
+
+ pObjShadowLiDriver = Aig_Mux( pNew, pObjSaveAndNotSaved, (Aig_Obj_t *)pObj->pData, pObjShadowLo );
+ pObjShadowLi = Aig_ObjCreatePo( pNew, pObjShadowLiDriver );
+ nRegCount++;
+ loCreated++; liCreated++;
+
+ pObjXor = Aig_Exor( pNew, (Aig_Obj_t *)pObj->pData, pObjShadowLo );
+ pObjXnor = Aig_Not( pObjXor );
+
+ pObjAndAcc = Aig_And( pNew, pObjXnor, pObjAndAcc );
+ }
+ }
+
+ // create the AND gate whose output will be the signal "looped"
+ pObjSavedLoAndEquality = Aig_And( pNew, pObjSavedLo, pObjAndAcc );
+
+ // create the master AND gate and corresponding AND and OR logic for the liveness properties
+
+ //*************************************************************************************
+ // Step 11: logic for LTL properties:- (looped & ~theta) where theta is the input ltl
+ // property
+ // Description of some data-structure:
+ //-------------------------------------------------------------------------------------
+ // Name | Type | Purpose
+ //-------------------------------------------------------------------------------------
+ // vSignalMemory | Vec_Ptr_t * | A vector across all ASTs of the LTL properties
+ // | | It remembers if OR+Latch for GF node has already been
+ // | | created for a particular signal.
+ // | |
+ // vGFFlopMemory | Vec_Ptr_t * | A vector across all ASTs of the LTL properties
+ // | | remembers if OR+Latch of a GF node has already been created
+ // | |
+ // vSignal | Vec_Ptr_t * | vector for each AST; contains pointers from GF nodes
+ // | | to AIG signals
+ // | |
+ // vAigGFMap | Vec_Vec_t * | vAigGFMap[ index ] = vector of GF nodes pointing to
+ // | | the same AIG node; "index" is the index of that
+ // | | AIG node in the vector vSignal
+ //*************************************************************************************
+
+ vSignalMemory = Vec_PtrAlloc(10);
+ vGFFlopMemory = Vec_PtrAlloc(10);
+
+ Vec_PtrForEachEntry( ltlNode *, vTopASTNodeArray, topNodeOfAST, iii )
+ {
+ vSignal = Vec_PtrAlloc( 10 );
+ vAigGFMap = Vec_VecAlloc( 10 );
+
+ //*************************************************************************************
+ //Step 11a: for the current AST, find out the leaf level Boolean signal pointers from
+ // the NEW aig.
+ //*************************************************************************************
+ populateBoolWithAigNodePtr( pNtk, p, pNew, topNodeOfAST );
+ assert( checkAllBoolHaveAIGPointer( topNodeOfAST ) );
+
+ //*************************************************************************************
+ //Step 11b: for each GF node, compute the pointer in AIG that it should point to
+ // In particular, if the subtree below GF is some Boolean crown (including the case
+ // of simple negation, create new logic and populate the AIG pointer in GF node
+ // accordingly
+ //*************************************************************************************
+ populateAigPointerUnitGF( pNew, topNodeOfAST, vSignal, vAigGFMap );
+
+ //*************************************************************************************
+ //Step 11c: everything below GF are computed. Now, it is time to create logic for individual
+ // GF nodes (i.e. the OR gate and the latch and the Boolean crown of the AST
+ //*************************************************************************************
+ Vec_PtrForEachEntry( Aig_Obj_t *, vSignal, pObj, i )
+ {
+ //*********************************************************
+ // Step 11c.1: if the OR+Latch of the particular signal is
+ // not already created, create it. It may have already been
+ // created from another property, so check it before creation
+ //*********************************************************
+ if( Vec_PtrFind( vSignalMemory, pObj ) == -1 )
+ {
+ liveLatch++;
+
+ pDriverImage = pObj;
+ pObjShadowLo = Aig_ObjCreatePi( pNew );
+ pObjShadowLiDriver = Aig_Or( pNew, pObjShadowLo, Aig_And( pNew, pDriverImage, pObjSaveOrSaved ) );
+ pObjShadowLi = Aig_ObjCreatePo( pNew, pObjShadowLiDriver );
+
+ nRegCount++;
+ loCreated++; liCreated++;
+
+ Vec_PtrPush( vSignalMemory, pObj );
+ Vec_PtrPush( vGFFlopMemory, pObjShadowLo );
+
+ #if 1
+ #ifdef PROPAGATE_NAMES
+ Vec_PtrPush( vecLos, pObjShadowLo );
+ //nodeName = (char *)malloc( strlen( Abc_ObjName( Abc_NtkPo( pNtk, getPoIndex( p, pObj ) ) ) ) + 12 );
+ //sprintf( nodeName, "%s__%s", Abc_ObjName( Abc_NtkPo( pNtk, getPoIndex( p, pObj ) ) ), "LIVENESS" );
+ nodeName = (char *)malloc( 20 );
+ sprintf( nodeName, "n%d__%s", Aig_ObjId(pObjShadowLo), "GF_flop" );
+ Vec_PtrPush( vecLoNames, nodeName );
+ #endif
+ #endif
+ }
+ else
+ pObjShadowLo = (Aig_Obj_t *)Vec_PtrEntry( vGFFlopMemory, Vec_PtrFind( vSignalMemory, pObj ) );
+
+ Vec_VecForEachEntryLevel( ltlNode *, vAigGFMap, pEnrtyGLOBALLY, ii, i )
+ setAIGNodePtrOfGloballyNode( pEnrtyGLOBALLY, pObjShadowLo);
+
+
+ //#ifdef PROPAGATE_NAMES
+ // Vec_PtrPush( vecLos, pObjShadowLo );
+ // nodeName = (char *)malloc( strlen( Abc_ObjName( Abc_NtkPo( pNtk, getPoIndex( p, pObj ) ) ) ) + 12 );
+ // sprintf( nodeName, "%s__%s", Abc_ObjName( Abc_NtkPo( pNtk, getPoIndex( p, pObj ) ) ), "LIVENESS" );
+ // Vec_PtrPush( vecLoNames, nodeName );
+ //#endif
+
+ }
+
+ //*********************************************************
+ //Step 11c.2: creating the Boolean crown
+ //*********************************************************
+ buildLogicFromLTLNode( pNew, topNodeOfAST );
+
+ //*********************************************************
+ //Step 11c.3: creating logic for (looped & ~theta) and patching
+ // it with the proper PO
+ //Note: if ALLOW_SAFETY_PROPERTIES is defined then the final AND
+ //gate is a conjunction of safety & liveness, i.e. SAFETY & (looped => theta)
+ //since ABC convention demands a NOT gate at the end, the property logic
+ //becomes !( SAFETY & (looped => theta) ) = !SAFETY + (looped & !theta)
+ //*********************************************************
+ pObjLive = retriveAIGPointerFromLTLNode( topNodeOfAST );
+ pObjSafetyGate = Aig_And( pNew, pObjSavedLoAndEquality, Aig_Not(pObjLive) );
+ #ifdef ALLOW_SAFETY_PROPERTIES
+ printf("liveness output is conjoined with safety assertions\n");
+ pObjSafetyAndLiveToSafety = Aig_Or( pNew, pObjSafetyGate, pNegatedSafetyConjunction );
+ pObjSafetyPropertyOutput = Vec_PtrEntry( vPoForLtlProps, iii );
+ Aig_ObjPatchFanin0( pNew, pObjSafetyPropertyOutput, pObjSafetyAndLiveToSafety );
+ #else
+ pObjSafetyPropertyOutput = Vec_PtrEntry( vPoForLtlProps, iii );
+ Aig_ObjPatchFanin0( pNew, pObjSafetyPropertyOutput, pObjSafetyGate );
+ #endif
+ //refreshing vSignal and vAigGFMap arrays
+ Vec_PtrFree( vSignal );
+ Vec_VecFree( vAigGFMap );
+ }
+
+ #endif
+ }
+#endif
+
+ Aig_ManSetRegNum( pNew, nRegCount );
+
+ Aig_ManPiCleanupBiere( pNew );
+ Aig_ManPoCleanupBiere( pNew );
+
+ Aig_ManCleanup( pNew );
+
+ assert( Aig_ManCheck( pNew ) );
+
+ if( mode == FULL_BIERE_MODE || mode == IGNORE_SAFETY_KEEP_LIVENESS_MODE )
+ {
+ assert((Aig_Obj_t *)Vec_PtrEntry(pNew->vPos, Saig_ManPoNum(pNew)+Aig_ObjPioNum(pObjSavedLo)-Saig_ManPiNum(p)-1) == pObjSavedLi);
+ assert( Saig_ManPiNum( p ) + 1 == Saig_ManPiNum( pNew ) );
+ //assert( Saig_ManRegNum( pNew ) == Saig_ManRegNum( p ) * 2 + 1 + liveLatch + fairLatch );
+ }
+
+
+ return pNew;
+}
+
+int Abc_CommandAbcLivenessToSafetyWithLTL( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ FILE * pOut, * pErr;
+ Abc_Ntk_t * pNtk, * pNtkTemp, *pNtkNew, *pNtkOld;
+ Aig_Man_t * pAig, *pAigNew;
+ int c;
+ Vec_Ptr_t * vLive, * vFair, *vAssertSafety, *vAssumeSafety;
+ int directive = -1;
+ char *ltfFormulaString = NULL;
+ int LTL_FLAG = 0, numOfLtlPropOutput;
+ Vec_Ptr_t *ltlBuffer;
+
+ pNtk = Abc_FrameReadNtk(pAbc);
+ pOut = Abc_FrameReadOut(pAbc);
+ pErr = Abc_FrameReadErr(pAbc);
+
+ if( argc == 1 )
+ {
+ assert( directive == -1 );
+ directive = FULL_BIERE_MODE;
+ }
+ else
+ {
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "1slhf" ) ) != EOF )
+ {
+ switch( c )
+ {
+ case '1':
+ if( directive == -1 )
+ directive = FULL_BIERE_ONE_LOOP_MODE;
+ else
+ {
+ assert( directive == IGNORE_LIVENESS_KEEP_SAFETY_MODE || directive == IGNORE_SAFETY_KEEP_LIVENESS_MODE );
+ if( directive == IGNORE_LIVENESS_KEEP_SAFETY_MODE )
+ directive = IGNORE_LIVENESS_KEEP_SAFETY_MODE;
+ else
+ directive = IGNORE_SAFETY_KEEP_LIVENESS_ONE_LOOP_MODE;
+ }
+ break;
+ case 's':
+ if( directive == -1 )
+ directive = IGNORE_SAFETY_KEEP_LIVENESS_MODE;
+ else
+ {
+ if( directive != FULL_BIERE_ONE_LOOP_MODE )
+ goto usage;
+ assert(directive == FULL_BIERE_ONE_LOOP_MODE);
+ directive = IGNORE_SAFETY_KEEP_LIVENESS_ONE_LOOP_MODE;
+ }
+ break;
+ case 'l':
+ if( directive == -1 )
+ directive = IGNORE_LIVENESS_KEEP_SAFETY_MODE;
+ else
+ {
+ if( directive != FULL_BIERE_ONE_LOOP_MODE )
+ goto usage;
+ assert(directive == FULL_BIERE_ONE_LOOP_MODE);
+ directive = IGNORE_LIVENESS_KEEP_SAFETY_MODE;
+ }
+ break;
+ case 'f':
+ //assert( argc >= 3 );
+ //vecLtlFormula = Vec_PtrAlloc( argc - 2 );
+ //if( argc >= 3 )
+ //{
+ // for( t=3; t<=argc; t++ )
+ // {
+ // printf("argv[%d] = %s\n", t-1, argv[t-1]);
+ // Vec_PtrPush( vecLtlFormula, argv[t-1] );
+ // }
+ //}
+ //printf("argv[argc] = %s\n", argv[argc-1]);
+ //ltfFormulaString = argv[2];
+
+ //LTL_FLAG = 1;
+ printf("\nILLEGAL FLAG: aborting....\n");
+ exit(0);
+ break;
+ case 'h':
+ goto usage;
+ default:
+ goto usage;
+ }
+ }
+ }
+
+ if ( pNtk == NULL )
+ {
+ fprintf( pErr, "Empty network.\n" );
+ return 1;
+ }
+ if( !Abc_NtkIsStrash( pNtk ) )
+ {
+ printf("The input network was not strashed, strashing....\n");
+ pNtkTemp = Abc_NtkStrash( pNtk, 0, 0, 0 );
+ pNtkOld = pNtkTemp;
+ pAig = Abc_NtkToDar( pNtkTemp, 0, 1 );
+ vLive = populateLivenessVector( pNtk, pAig );
+ vFair = populateFairnessVector( pNtk, pAig );
+ vAssertSafety = populateSafetyAssertionVector( pNtk, pAig );
+ vAssumeSafety = populateSafetyAssumptionVector( pNtk, pAig );
+ }
+ else
+ {
+ pAig = Abc_NtkToDar( pNtk, 0, 1 );
+ pNtkOld = pNtk;
+ vLive = populateLivenessVector( pNtk, pAig );
+ vFair = populateFairnessVector( pNtk, pAig );
+ vAssertSafety = populateSafetyAssertionVector( pNtk, pAig );
+ vAssumeSafety = populateSafetyAssumptionVector( pNtk, pAig );
+ }
+
+ if( pAbc->vLTLProperties_global != NULL )
+ ltlBuffer = pAbc->vLTLProperties_global;
+ else
+ ltlBuffer = NULL;
+
+ switch( directive )
+ {
+ case FULL_BIERE_MODE:
+ pAigNew = LivenessToSafetyTransformationWithLTL( FULL_BIERE_MODE, pNtk, pAig, vLive, vFair, vAssertSafety, vAssumeSafety, &numOfLtlPropOutput, ltlBuffer );
+ if( Aig_ManRegNum(pAigNew) != 0 )
+ printf("A new circuit is produced with\n\t%d POs - one for safety and %d for liveness.\n\tone additional input is added (due to Biere's nondeterminism)\n\tshadow flops are not created if the original circuit is combinational\n\tnon-property POs are suppressed\n", numOfLtlPropOutput+1, numOfLtlPropOutput);
+ break;
+
+ case FULL_BIERE_ONE_LOOP_MODE:
+ pAigNew = LivenessToSafetyTransformationOneStepLoop( FULL_BIERE_ONE_LOOP_MODE, pNtk, pAig, vLive, vFair, vAssertSafety, vAssumeSafety );
+ if( Aig_ManRegNum(pAigNew) != 0 )
+ printf("A new circuit is produced with\n\t2 POs - one for safety and one for liveness.\n\tone additional input is added (due to Biere's nondeterminism)\n\tshadow flops are not created\n\tnon-property POs are suppressed\n");
+ break;
+
+ case IGNORE_LIVENESS_KEEP_SAFETY_MODE:
+ pAigNew = LivenessToSafetyTransformationWithLTL( IGNORE_LIVENESS_KEEP_SAFETY_MODE, pNtk, pAig, vLive, vFair, vAssertSafety, vAssumeSafety, &numOfLtlPropOutput, ltlBuffer );
+ assert( numOfLtlPropOutput == 0 );
+ if( Aig_ManRegNum(pAigNew) != 0 )
+ printf("A new circuit is produced with\n\t1 PO - only for safety property; liveness properties are ignored, if any.\n\tno additional input is added (due to Biere's nondeterminism)\n\tshadow flops are not created\n\tnon-property POs are suppressed\n");
+ break;
+
+ case IGNORE_SAFETY_KEEP_LIVENESS_MODE:
+ pAigNew = LivenessToSafetyTransformationWithLTL( IGNORE_SAFETY_KEEP_LIVENESS_MODE, pNtk, pAig, vLive, vFair, vAssertSafety, vAssumeSafety, &numOfLtlPropOutput, ltlBuffer );
+ if( Aig_ManRegNum(pAigNew) != 0 )
+ printf("A new circuit is produced with\n\t%d PO - only for liveness property; safety properties are ignored, if any.\n\tone additional input is added (due to Biere's nondeterminism)\n\tshadow flops are not created if the original circuit is combinational\n\tnon-property POs are suppressed\n", numOfLtlPropOutput);
+ break;
+
+ case IGNORE_SAFETY_KEEP_LIVENESS_ONE_LOOP_MODE:
+ pAigNew = LivenessToSafetyTransformationOneStepLoop( IGNORE_SAFETY_KEEP_LIVENESS_ONE_LOOP_MODE, pNtk, pAig, vLive, vFair, vAssertSafety, vAssumeSafety );
+ if( Aig_ManRegNum(pAigNew) != 0 )
+ printf("New circuit is produced ignoring safety outputs!\nOnly liveness and fairness outputs are considered.\nShadow registers are not created\n");
+ break;
+ }
+
+#if 0
+ if( argc == 1 )
+ {
+ pAigNew = LivenessToSafetyTransformation( FULL_BIERE_MODE, pNtk, pAig, vLive, vFair, vAssertSafety, vAssumeSafety );
+ if( Aig_ManRegNum(pAigNew) != 0 )
+ printf("New circuit is produced considering all safety, liveness and fairness outputs.\nBiere's logic is created\n");
+ }
+ else
+ {
+ Extra_UtilGetoptReset();
+ c = Extra_UtilGetopt( argc, argv, "1lsh" );
+ if( c == '1' )
+ {
+ if ( pNtk == NULL )
+ {
+ fprintf( pErr, "Empty network.\n" );
+ return 1;
+ }
+ if( !Abc_NtkIsStrash( pNtk ) )
+ {
+ printf("The input network was not strashed, strashing....\n");
+ pNtkTemp = Abc_NtkStrash( pNtk, 0, 0, 0 );
+ pNtkOld = pNtkTemp;
+ pAig = Abc_NtkToDar( pNtkTemp, 0, 1 );
+ vLive = populateLivenessVector( pNtk, pAig );
+ vFair = populateFairnessVector( pNtk, pAig );
+ vAssertSafety = populateSafetyAssertionVector( pNtk, pAig );
+ vAssumeSafety = populateSafetyAssumptionVector( pNtk, pAig );
+ }
+ else
+ {
+ pAig = Abc_NtkToDar( pNtk, 0, 1 );
+ pNtkOld = pNtk;
+ vLive = populateLivenessVector( pNtk, pAig );
+ vFair = populateFairnessVector( pNtk, pAig );
+ vAssertSafety = populateSafetyAssertionVector( pNtk, pAig );
+ vAssumeSafety = populateSafetyAssumptionVector( pNtk, pAig );
+ }
+ pAigNew = LivenessToSafetyTransformationOneStepLoop( pNtk, pAig, vLive, vFair, vAssertSafety, vAssumeSafety );
+ }
+ else if( c == 'l' )
+ {
+ if ( pNtk == NULL )
+ {
+ fprintf( pErr, "Empty network.\n" );
+ return 1;
+ }
+ if( !Abc_NtkIsStrash( pNtk ) )
+ {
+ printf("The input network was not strashed, strashing....\n");
+ pNtkTemp = Abc_NtkStrash( pNtk, 0, 0, 0 );
+ pNtkOld = pNtkTemp;
+ pAig = Abc_NtkToDar( pNtkTemp, 0, 1 );
+ vLive = populateLivenessVector( pNtk, pAig );
+ vFair = populateFairnessVector( pNtk, pAig );
+ vAssertSafety = populateSafetyAssertionVector( pNtk, pAig );
+ vAssumeSafety = populateSafetyAssumptionVector( pNtk, pAig );
+ }
+ else
+ {
+ pAig = Abc_NtkToDar( pNtk, 0, 1 );
+ pNtkOld = pNtk;
+ vLive = populateLivenessVector( pNtk, pAig );
+ vFair = populateFairnessVector( pNtk, pAig );
+ vAssertSafety = populateSafetyAssertionVector( pNtk, pAig );
+ vAssumeSafety = populateSafetyAssumptionVector( pNtk, pAig );
+ }
+ pAigNew = LivenessToSafetyTransformation( IGNORE_LIVENESS_KEEP_SAFETY_MODE, pNtk, pAig, vLive, vFair, vAssertSafety, vAssumeSafety );
+ if( Aig_ManRegNum(pAigNew) != 0 )
+ printf("New circuit is produced ignoring liveness outputs!\nOnly safety outputs are kept.\nBiere's logic is not created\n");
+ }
+ else if( c == 's' )
+ {
+ if ( pNtk == NULL )
+ {
+ fprintf( pErr, "Empty network.\n" );
+ return 1;
+ }
+
+ if( !Abc_NtkIsStrash( pNtk ) )
+ {
+ printf("The input network was not strashed, strashing....\n");
+ pNtkTemp = Abc_NtkStrash( pNtk, 0, 0, 0 );
+ pNtkOld = pNtkTemp;
+ pAig = Abc_NtkToDar( pNtkTemp, 0, 1 );
+ vLive = populateLivenessVector( pNtk, pAig );
+ vFair = populateFairnessVector( pNtk, pAig );
+ vAssertSafety = populateSafetyAssertionVector( pNtk, pAig );
+ vAssumeSafety = populateSafetyAssumptionVector( pNtk, pAig );
+ }
+ else
+ {
+ pAig = Abc_NtkToDar( pNtk, 0, 1 );
+ pNtkOld = pNtk;
+ vLive = populateLivenessVector( pNtk, pAig );
+ vFair = populateFairnessVector( pNtk, pAig );
+ vAssertSafety = populateSafetyAssertionVector( pNtk, pAig );
+ vAssumeSafety = populateSafetyAssumptionVector( pNtk, pAig );
+ }
+ pAigNew = LivenessToSafetyTransformation( IGNORE_SAFETY_KEEP_LIVENESS_MODE, pNtk, pAig, vLive, vFair, vAssertSafety, vAssumeSafety );
+ if( Aig_ManRegNum(pAigNew) != 0 )
+ printf("New circuit is produced ignoring safety outputs!\nOnly liveness and fairness outputs are considered.\nBiere's logic is created\n");
+ }
+ else if( c == 'h' )
+ goto usage;
+ else
+ goto usage;
+ }
+#endif
+
+#if 0
+ Aig_ManPrintStats( pAigNew );
+ printf("\nDetail statistics*************************************\n");
+ printf("Number of true primary inputs = %d\n", Saig_ManPiNum( pAigNew ));
+ printf("Number of true primary outputs = %d\n", Saig_ManPoNum( pAigNew ));
+ printf("Number of true latch outputs = %d\n", Saig_ManCiNum( pAigNew ) - Saig_ManPiNum( pAigNew ));
+ printf("Number of true latch inputs = %d\n", Saig_ManCoNum( pAigNew ) - Saig_ManPoNum( pAigNew ));
+ printf("Numer of registers = %d\n", Saig_ManRegNum( pAigNew ) );
+ printf("\n*******************************************************\n");
+#endif
+
+ pNtkNew = Abc_NtkFromAigPhase( pAigNew );
+ pNtkNew->pName = Aig_UtilStrsav( pAigNew->pName );
+
+ if ( !Abc_NtkCheck( pNtkNew ) )
+ fprintf( stdout, "Abc_NtkCreateCone(): Network check has failed.\n" );
+
+ updateNewNetworkNameManager( pNtkNew, pAigNew, vecPiNames, vecLoNames );
+ Abc_FrameSetCurrentNetwork( pAbc, pNtkNew );
+
+#if 0
+#ifndef DUPLICATE_CKT_DEBUG
+ Saig_ManForEachPi( pAigNew, pObj, i )
+ assert( strcmp( (char *)Vec_PtrEntry(vecPiNames, i), retrieveTruePiName( pNtk, pAig, pAigNew, pObj ) ) == 0 );
+ //printf("Name of %d-th Pi = %s, %s\n", i, retrieveTruePiName( pNtk, pAig, pAigNew, pObj ), (char *)Vec_PtrEntry(vecPiNames, i) );
+
+ Saig_ManForEachLo( pAigNew, pObj, i )
+ assert( strcmp( (char *)Vec_PtrEntry(vecLoNames, i), retrieveLOName( pNtk, pAig, pAigNew, pObj, vLive, vFair ) ) == 0 );
+#endif
+#endif
+
+ return 0;
+
+usage:
+ fprintf( stdout, "usage: l3s [-1lsh]\n" );
+ fprintf( stdout, "\t performs Armin Biere's live-to-safe transformation\n" );
+ fprintf( stdout, "\t-1 : no shadow logic, presume all loops are self loops\n");
+ fprintf( stdout, "\t-l : ignore liveness and fairness outputs\n");
+ fprintf( stdout, "\t-s : ignore safety assertions and assumptions\n");
+ fprintf( stdout, "\t-h : print command usage\n");
+ return 1;
+}
+
+
+ABC_NAMESPACE_IMPL_END
diff --git a/src/aig/live/liveness_old.c b/src/aig/live/liveness_old.c
new file mode 100644
index 00000000..b3ddb1fc
--- /dev/null
+++ b/src/aig/live/liveness_old.c
@@ -0,0 +1,1756 @@
+#include <stdio.h>
+#include "main.h"
+#include "aig.h"
+#include "saig.h"
+#include <string.h>
+
+ABC_NAMESPACE_IMPL_START
+
+
+#define PROPAGATE_NAMES
+
+#define FULL_BIERE_MODE 0
+#define IGNORE_LIVENESS_KEEP_SAFETY_MODE 1
+#define IGNORE_SAFETY_KEEP_LIVENESS_MODE 2
+#define IGNORE_SAFETY_KEEP_LIVENESS_ONE_LOOP_MODE 3
+#define FULL_BIERE_ONE_LOOP_MODE 4
+//#define DUPLICATE_CKT_DEBUG
+
+extern Aig_Man_t * Abc_NtkToDar( Abc_Ntk_t * pNtk, int fExors, int fRegisters );
+extern Abc_Ntk_t * Abc_NtkFromAigPhase( Aig_Man_t * pMan );
+//char *strdup(const char *string);
+
+
+/*******************************************************************
+LAYOUT OF PI VECTOR:
+
++------------------------------------------------------------------------------------------------------------------------------------+
+| TRUE ORIGINAL PI (n) | SAVE(PI) (1) | ORIGINAL LO (k) | SAVED(LO) (1) | SHADOW_ORIGINAL LO (k) | LIVENESS LO (l) | FAIRNESS LO (f) |
++------------------------------------------------------------------------------------------------------------------------------------+
+<------------True PI----------------->|<----------------------------LO--------------------------------------------------------------->
+
+LAYOUT OF PO VECTOR:
+
++-----------------------------------------------------------------------------------------------------------+
+| SOLE PO (1) | ORIGINAL LI (k) | SAVED LI (1) | SHADOW_ORIGINAL LI (k) | LIVENESS LI (l) | FAIRNESS LI (f) |
++-----------------------------------------------------------------------------------------------------------+
+<--True PO--->|<--------------------------------------LI---------------------------------------------------->
+
+********************************************************************/
+
+
+static int nodeName_starts_with( Abc_Obj_t *pNode, const char *prefix )
+{
+ if( strstr( Abc_ObjName( pNode ), prefix ) == Abc_ObjName( pNode ) )
+ return 1;
+ else
+ return 0;
+}
+
+void printVecPtrOfString( Vec_Ptr_t *vec )
+{
+ int i;
+
+ for( i=0; i< Vec_PtrSize( vec ); i++ )
+ {
+ printf("vec[%d] = %s\n", i, (char *)Vec_PtrEntry(vec, i) );
+ }
+}
+
+int getPoIndex( Aig_Man_t *pAig, Aig_Obj_t *pPivot )
+{
+ int i;
+ Aig_Obj_t *pObj;
+
+ Saig_ManForEachPo( pAig, pObj, i )
+ {
+ if( pObj == pPivot )
+ return i;
+ }
+ return -1;
+}
+
+char * retrieveTruePiName( Abc_Ntk_t *pNtkOld, Aig_Man_t *pAigOld, Aig_Man_t *pAigNew, Aig_Obj_t *pObjPivot )
+{
+ Aig_Obj_t *pObjOld, *pObj;
+ Abc_Obj_t *pNode;
+ int index;
+
+ assert( Saig_ObjIsPi( pAigNew, pObjPivot ) );
+ Aig_ManForEachPi( pAigNew, pObj, index )
+ if( pObj == pObjPivot )
+ break;
+ assert( index < Aig_ManPiNum( pAigNew ) - Aig_ManRegNum( pAigNew ) );
+ if( index == Saig_ManPiNum( pAigNew ) - 1 )
+ return "SAVE_BIERE";
+ else
+ {
+ pObjOld = Aig_ManPi( pAigOld, index );
+ pNode = Abc_NtkPi( pNtkOld, index );
+ assert( pObjOld->pData == pObjPivot );
+ return Abc_ObjName( pNode );
+ }
+}
+
+char * retrieveLOName( Abc_Ntk_t *pNtkOld, Aig_Man_t *pAigOld, Aig_Man_t *pAigNew, Aig_Obj_t *pObjPivot, Vec_Ptr_t *vLive, Vec_Ptr_t * vFair )
+{
+ Aig_Obj_t *pObjOld, *pObj;
+ Abc_Obj_t *pNode;
+ int index, oldIndex, originalLatchNum = Saig_ManRegNum(pAigOld), strMatch, i;
+ char *dummyStr = (char *)malloc( sizeof(char) * 50 );
+
+ assert( Saig_ObjIsLo( pAigNew, pObjPivot ) );
+ Saig_ManForEachLo( pAigNew, pObj, index )
+ if( pObj == pObjPivot )
+ break;
+ if( index < originalLatchNum )
+ {
+ oldIndex = Saig_ManPiNum( pAigOld ) + index;
+ pObjOld = Aig_ManPi( pAigOld, oldIndex );
+ pNode = Abc_NtkCi( pNtkOld, oldIndex );
+ assert( pObjOld->pData == pObjPivot );
+ return Abc_ObjName( pNode );
+ }
+ else if( index == originalLatchNum )
+ return "SAVED_LO";
+ else if( index > originalLatchNum && index < 2 * originalLatchNum + 1 )
+ {
+ oldIndex = Saig_ManPiNum( pAigOld ) + index - originalLatchNum - 1;
+ pObjOld = Aig_ManPi( pAigOld, oldIndex );
+ pNode = Abc_NtkCi( pNtkOld, oldIndex );
+ sprintf( dummyStr, "%s__%s", Abc_ObjName( pNode ), "SHADOW");
+ return dummyStr;
+ }
+ else if( index >= 2 * originalLatchNum + 1 && index < 2 * originalLatchNum + 1 + Vec_PtrSize( vLive ) )
+ {
+ oldIndex = index - 2 * originalLatchNum - 1;
+ strMatch = 0;
+ dummyStr[0] = '\0';
+ Saig_ManForEachPo( pAigOld, pObj, i )
+ {
+ pNode = Abc_NtkPo( pNtkOld, i );
+ //if( strstr( Abc_ObjName( pNode ), "assert_fair" ) != NULL )
+ if( nodeName_starts_with( pNode, "assert_fair" ) )
+ {
+ if( strMatch == oldIndex )
+ {
+ sprintf( dummyStr, "%s__%s", Abc_ObjName( pNode ), "LIVENESS");
+ //return dummyStr;
+ break;
+ }
+ else
+ strMatch++;
+ }
+ }
+ assert( dummyStr[0] != '\0' );
+ return dummyStr;
+ }
+ else if( index >= 2 * originalLatchNum + 1 + Vec_PtrSize( vLive ) && index < 2 * originalLatchNum + 1 + Vec_PtrSize( vLive ) + Vec_PtrSize( vFair ) )
+ {
+ oldIndex = index - 2 * originalLatchNum - 1 - Vec_PtrSize( vLive );
+ strMatch = 0;
+ dummyStr[0] = '\0';
+ Saig_ManForEachPo( pAigOld, pObj, i )
+ {
+ pNode = Abc_NtkPo( pNtkOld, i );
+ //if( strstr( Abc_ObjName( pNode ), "assume_fair" ) != NULL )
+ if( nodeName_starts_with( pNode, "assume_fair" ) )
+ {
+ if( strMatch == oldIndex )
+ {
+ sprintf( dummyStr, "%s__%s", Abc_ObjName( pNode ), "FAIRNESS");
+ //return dummyStr;
+ break;
+ }
+ else
+ strMatch++;
+ }
+ }
+ assert( dummyStr[0] != '\0' );
+ return dummyStr;
+ }
+ else
+ return "UNKNOWN";
+}
+
+Vec_Ptr_t *vecPis, *vecPiNames;
+Vec_Ptr_t *vecLos, *vecLoNames;
+
+
+int Aig_ManPiCleanupBiere( Aig_Man_t * p )
+{
+ int k = 0, nPisOld = Aig_ManPiNum(p);
+
+ p->nObjs[AIG_OBJ_PI] = Vec_PtrSize( p->vPis );
+ if ( Aig_ManRegNum(p) )
+ p->nTruePis = Aig_ManPiNum(p) - Aig_ManRegNum(p);
+
+ return nPisOld - Aig_ManPiNum(p);
+}
+
+
+int Aig_ManPoCleanupBiere( Aig_Man_t * p )
+{
+ int k = 0, nPosOld = Aig_ManPoNum(p);
+
+ p->nObjs[AIG_OBJ_PO] = Vec_PtrSize( p->vPos );
+ if ( Aig_ManRegNum(p) )
+ p->nTruePos = Aig_ManPoNum(p) - Aig_ManRegNum(p);
+ return nPosOld - Aig_ManPoNum(p);
+}
+
+Aig_Man_t * LivenessToSafetyTransformation( int mode, Abc_Ntk_t * pNtk, Aig_Man_t * p,
+ Vec_Ptr_t *vLive, Vec_Ptr_t *vFair, Vec_Ptr_t *vAssertSafety, Vec_Ptr_t *vAssumeSafety )
+{
+ Aig_Man_t * pNew;
+ int i, nRegCount;
+ Aig_Obj_t * pObjSavePi;
+ Aig_Obj_t *pObjSavedLo, *pObjSavedLi;
+ Aig_Obj_t *pObj, *pMatch;
+ Aig_Obj_t *pObjSaveOrSaved, *pObjSaveAndNotSaved, *pObjSavedLoAndEquality;
+ Aig_Obj_t *pObjShadowLo, *pObjShadowLi, *pObjShadowLiDriver;
+ Aig_Obj_t *pObjXor, *pObjXnor, *pObjAndAcc;
+ Aig_Obj_t *pObjLive, *pObjFair, *pObjSafetyGate;
+ Aig_Obj_t *pObjSafetyPropertyOutput;
+ Aig_Obj_t *pObjOriginalSafetyPropertyOutput;
+ Aig_Obj_t *pDriverImage, *pArgument, *collectiveAssertSafety, *collectiveAssumeSafety;
+ char *nodeName;
+ int piCopied = 0, liCopied = 0, loCopied = 0, liCreated = 0, loCreated = 0, piVecIndex = 0, liveLatch = 0, fairLatch = 0;
+
+ vecPis = Vec_PtrAlloc( Saig_ManPiNum( p ) + 1);
+ vecPiNames = Vec_PtrAlloc( Saig_ManPiNum( p ) + 1);
+
+ vecLos = Vec_PtrAlloc( Saig_ManRegNum( p )*2 + 1 + Vec_PtrSize( vLive ) + Vec_PtrSize( vFair ) );
+ vecLoNames = Vec_PtrAlloc( Saig_ManRegNum( p )*2 + 1 + Vec_PtrSize( vLive ) + Vec_PtrSize( vFair ) );
+
+ //****************************************************************
+ // Step1: create the new manager
+ // Note: The new manager is created with "2 * Aig_ManObjNumMax(p)"
+ // nodes, but this selection is arbitrary - need to be justified
+ //****************************************************************
+ pNew = Aig_ManStart( 2 * Aig_ManObjNumMax(p) );
+ pNew->pName = (char *)malloc( strlen( pNtk->pName ) + strlen("_l2s") + 1 );
+ sprintf(pNew->pName, "%s_%s", pNtk->pName, "l2s");
+ pNew->pSpec = NULL;
+
+ //****************************************************************
+ // Step 2: map constant nodes
+ //****************************************************************
+ pObj = Aig_ManConst1( p );
+ pObj->pData = Aig_ManConst1( pNew );
+
+ //****************************************************************
+ // Step 3: create true PIs
+ //****************************************************************
+ Saig_ManForEachPi( p, pObj, i )
+ {
+ piCopied++;
+ pObj->pData = Aig_ObjCreatePi(pNew);
+ Vec_PtrPush( vecPis, pObj->pData );
+ nodeName = Aig_UtilStrsav(Abc_ObjName( Abc_NtkPi( pNtk, i ) ));
+ Vec_PtrPush( vecPiNames, nodeName );
+ }
+
+ //****************************************************************
+ // Step 4: create the special Pi corresponding to SAVE
+ //****************************************************************
+ if( mode == FULL_BIERE_MODE || mode == IGNORE_SAFETY_KEEP_LIVENESS_MODE )
+ {
+ pObjSavePi = Aig_ObjCreatePi( pNew );
+ nodeName = "SAVE_BIERE",
+ Vec_PtrPush( vecPiNames, nodeName );
+ }
+
+ //****************************************************************
+ // Step 5: create register outputs
+ //****************************************************************
+ Saig_ManForEachLo( p, pObj, i )
+ {
+ loCopied++;
+ pObj->pData = Aig_ObjCreatePi(pNew);
+ Vec_PtrPush( vecLos, pObj->pData );
+ nodeName = Aig_UtilStrsav(Abc_ObjName( Abc_NtkCi( pNtk, Abc_NtkPiNum(pNtk) + i ) ));
+ Vec_PtrPush( vecLoNames, nodeName );
+ }
+
+ //****************************************************************
+ // Step 6: create "saved" register output
+ //****************************************************************
+ if( mode == FULL_BIERE_MODE || mode == IGNORE_SAFETY_KEEP_LIVENESS_MODE )
+ {
+ loCreated++;
+ pObjSavedLo = Aig_ObjCreatePi( pNew );
+ Vec_PtrPush( vecLos, pObjSavedLo );
+ nodeName = "SAVED_LO";
+ Vec_PtrPush( vecLoNames, nodeName );
+ }
+
+ //****************************************************************
+ // Step 7: create the OR gate and the AND gate directly fed by "SAVE" Pi
+ //****************************************************************
+ if( mode == FULL_BIERE_MODE || mode == IGNORE_SAFETY_KEEP_LIVENESS_MODE )
+ {
+ pObjSaveOrSaved = Aig_Or( pNew, pObjSavePi, pObjSavedLo );
+ pObjSaveAndNotSaved = Aig_And( pNew, pObjSavePi, Aig_Not(pObjSavedLo) );
+ }
+
+ //********************************************************************
+ // Step 8: create internal nodes
+ //********************************************************************
+ Aig_ManForEachNode( p, pObj, i )
+ {
+ pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
+ }
+
+
+ //********************************************************************
+ // Step 8.x : create PO for each safety assertions
+ // NOTE : Here the output is purposely inverted as it will be thrown to
+ // dprove
+ //********************************************************************
+ if( mode == FULL_BIERE_MODE || mode == IGNORE_LIVENESS_KEEP_SAFETY_MODE )
+ {
+ if( Vec_PtrSize( vAssertSafety ) != 0 && Vec_PtrSize( vAssumeSafety ) == 0 )
+ {
+ pObjAndAcc = Aig_ManConst1( pNew );
+ Vec_PtrForEachEntry( Aig_Obj_t *, vAssertSafety, pObj, i )
+ {
+ pArgument = Aig_NotCond( (Aig_Obj_t *)Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0( pObj ) );
+ pObjAndAcc = Aig_And( pNew, pArgument, pObjAndAcc );
+ }
+ pObjOriginalSafetyPropertyOutput = Aig_ObjCreatePo( pNew, Aig_Not(pObjAndAcc) );
+ }
+ else if( Vec_PtrSize( vAssertSafety ) != 0 && Vec_PtrSize( vAssumeSafety ) != 0 )
+ {
+ pObjAndAcc = Aig_ManConst1( pNew );
+ Vec_PtrForEachEntry( Aig_Obj_t *, vAssertSafety, pObj, i )
+ {
+ pArgument = Aig_NotCond( (Aig_Obj_t *)Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0( pObj ) );
+ pObjAndAcc = Aig_And( pNew, pArgument, pObjAndAcc );
+ }
+ collectiveAssertSafety = pObjAndAcc;
+
+ pObjAndAcc = Aig_ManConst1( pNew );
+ Vec_PtrForEachEntry( Aig_Obj_t *, vAssumeSafety, pObj, i )
+ {
+ pArgument = Aig_NotCond( (Aig_Obj_t *)Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0( pObj ) );
+ pObjAndAcc = Aig_And( pNew, pArgument, pObjAndAcc );
+ }
+ collectiveAssumeSafety = pObjAndAcc;
+ pObjOriginalSafetyPropertyOutput = Aig_ObjCreatePo( pNew, Aig_And( pNew, Aig_Not(collectiveAssertSafety), collectiveAssumeSafety ) );
+ }
+ else
+ {
+ printf("WARNING!! No safety property is found, a new (negated) constant 1 output is created\n");
+ pObjOriginalSafetyPropertyOutput = Aig_ObjCreatePo( pNew, Aig_Not( Aig_ManConst1(pNew) ) );
+ }
+ }
+
+ //********************************************************************
+ // Step 9: create the safety property output gate for the liveness properties
+ // discuss with Sat/Alan for an alternative implementation
+ //********************************************************************
+ if( mode == FULL_BIERE_MODE || mode == IGNORE_SAFETY_KEEP_LIVENESS_MODE )
+ {
+ pObjSafetyPropertyOutput = Aig_ObjCreatePo( pNew, (Aig_Obj_t *)Aig_ObjFanin0(pObj)->pData );
+ }
+
+ // create register inputs for the original registers
+ nRegCount = 0;
+
+ Saig_ManForEachLo( p, pObj, i )
+ {
+ pMatch = Saig_ObjLoToLi( p, pObj );
+ Aig_ObjCreatePo( pNew, Aig_NotCond((Aig_Obj_t *)Aig_ObjFanin0(pMatch)->pData, Aig_ObjFaninC0( pMatch ) ) );
+ nRegCount++;
+ liCopied++;
+ }
+
+ // create register input corresponding to the register "saved"
+ if( mode == FULL_BIERE_MODE || mode == IGNORE_SAFETY_KEEP_LIVENESS_MODE )
+ {
+ #ifndef DUPLICATE_CKT_DEBUG
+ pObjSavedLi = Aig_ObjCreatePo( pNew, pObjSaveOrSaved );
+ nRegCount++;
+ liCreated++;
+
+ //Changed on October 13, 2009
+ //pObjAndAcc = NULL;
+ pObjAndAcc = Aig_ManConst1( pNew );
+
+ // create the family of shadow registers, then create the cascade of Xnor and And gates for the comparator
+ Saig_ManForEachLo( p, pObj, i )
+ {
+ pObjShadowLo = Aig_ObjCreatePi( pNew );
+
+ #ifdef PROPAGATE_NAMES
+ Vec_PtrPush( vecLos, pObjShadowLo );
+ nodeName = (char *)malloc( strlen( Abc_ObjName( Abc_NtkCi( pNtk, Abc_NtkPiNum(pNtk) + i ) ) ) + 10 );
+ sprintf( nodeName, "%s__%s", Abc_ObjName( Abc_NtkCi( pNtk, Abc_NtkPiNum(pNtk) + i ) ), "SHADOW" );
+
+ Vec_PtrPush( vecLoNames, nodeName );
+ #endif
+
+ pObjShadowLiDriver = Aig_Mux( pNew, pObjSaveAndNotSaved, (Aig_Obj_t *)pObj->pData, pObjShadowLo );
+ pObjShadowLi = Aig_ObjCreatePo( pNew, pObjShadowLiDriver );
+ nRegCount++;
+ loCreated++; liCreated++;
+
+ pObjXor = Aig_Exor( pNew, (Aig_Obj_t *)pObj->pData, pObjShadowLo );
+ pObjXnor = Aig_Not( pObjXor );
+
+ pObjAndAcc = Aig_And( pNew, pObjXnor, pObjAndAcc );
+ }
+
+ // create the AND gate whose output will be the signal "looped"
+ pObjSavedLoAndEquality = Aig_And( pNew, pObjSavedLo, pObjAndAcc );
+
+ // create the master AND gate and corresponding AND and OR logic for the liveness properties
+ pObjAndAcc = Aig_ManConst1( pNew );
+ if( vLive == NULL || Vec_PtrSize( vLive ) == 0 )
+ {
+ printf("Circuit without any liveness property\n");
+ }
+ else
+ {
+ Vec_PtrForEachEntry( Aig_Obj_t *, vLive, pObj, i )
+ {
+ liveLatch++;
+ pDriverImage = Aig_NotCond((Aig_Obj_t *)Aig_Regular(Aig_ObjChild0( pObj ))->pData, Aig_ObjFaninC0(pObj));
+ pObjShadowLo = Aig_ObjCreatePi( pNew );
+
+ #ifdef PROPAGATE_NAMES
+ Vec_PtrPush( vecLos, pObjShadowLo );
+ nodeName = (char *)malloc( strlen( Abc_ObjName( Abc_NtkPo( pNtk, getPoIndex( p, pObj ) ) ) ) + 12 );
+ sprintf( nodeName, "%s__%s", Abc_ObjName( Abc_NtkPo( pNtk, getPoIndex( p, pObj ) ) ), "LIVENESS" );
+ Vec_PtrPush( vecLoNames, nodeName );
+ #endif
+
+ pObjShadowLiDriver = Aig_Or( pNew, pObjShadowLo, Aig_And( pNew, pDriverImage, pObjSaveOrSaved ) );
+ pObjShadowLi = Aig_ObjCreatePo( pNew, pObjShadowLiDriver );
+ nRegCount++;
+ loCreated++; liCreated++;
+
+ pObjAndAcc = Aig_And( pNew, pObjShadowLo, pObjAndAcc );
+ }
+ }
+
+ pObjLive = pObjAndAcc;
+
+ pObjAndAcc = Aig_ManConst1( pNew );
+ if( vFair == NULL || Vec_PtrSize( vFair ) == 0 )
+ printf("Circuit without any fairness property\n");
+ else
+ {
+ Vec_PtrForEachEntry( Aig_Obj_t *, vFair, pObj, i )
+ {
+ fairLatch++;
+ pDriverImage = Aig_NotCond((Aig_Obj_t *)Aig_Regular(Aig_ObjChild0( pObj ))->pData, Aig_ObjFaninC0(pObj));
+ pObjShadowLo = Aig_ObjCreatePi( pNew );
+
+ #ifdef PROPAGATE_NAMES
+ Vec_PtrPush( vecLos, pObjShadowLo );
+ nodeName = (char *)malloc( strlen( Abc_ObjName( Abc_NtkPo( pNtk, getPoIndex( p, pObj ) ) ) ) + 12 );
+ sprintf( nodeName, "%s__%s", Abc_ObjName( Abc_NtkPo( pNtk, getPoIndex( p, pObj ) ) ), "FAIRNESS" );
+ Vec_PtrPush( vecLoNames, nodeName );
+ #endif
+
+ pObjShadowLiDriver = Aig_Or( pNew, pObjShadowLo, Aig_And( pNew, pDriverImage, pObjSaveOrSaved ) );
+ pObjShadowLi = Aig_ObjCreatePo( pNew, pObjShadowLiDriver );
+ nRegCount++;
+ loCreated++; liCreated++;
+
+ pObjAndAcc = Aig_And( pNew, pObjShadowLo, pObjAndAcc );
+ }
+ }
+
+ pObjFair = pObjAndAcc;
+
+ //pObjSafetyGate = Aig_Exor( pNew, Aig_Not(Aig_ManConst1( pNew )), Aig_And( pNew, pObjSavedLoAndEquality, Aig_And( pNew, pObjFair, Aig_Not( pObjLive ) ) ) );
+ //Following is the actual Biere translation
+ pObjSafetyGate = Aig_And( pNew, pObjSavedLoAndEquality, Aig_And( pNew, pObjFair, Aig_Not( pObjLive ) ) );
+
+ Aig_ObjPatchFanin0( pNew, pObjSafetyPropertyOutput, pObjSafetyGate );
+ #endif
+ }
+
+ Aig_ManSetRegNum( pNew, nRegCount );
+
+ Aig_ManPiCleanupBiere( pNew );
+ Aig_ManPoCleanupBiere( pNew );
+
+ Aig_ManCleanup( pNew );
+
+ assert( Aig_ManCheck( pNew ) );
+
+ if( mode == FULL_BIERE_MODE || mode == IGNORE_SAFETY_KEEP_LIVENESS_MODE )
+ {
+ assert((Aig_Obj_t *)Vec_PtrEntry(pNew->vPos, Saig_ManPoNum(pNew)+Aig_ObjPioNum(pObjSavedLo)-Saig_ManPiNum(p)-1) == pObjSavedLi);
+ assert( Saig_ManPiNum( p ) + 1 == Saig_ManPiNum( pNew ) );
+ assert( Saig_ManRegNum( pNew ) == Saig_ManRegNum( p ) * 2 + 1 + liveLatch + fairLatch );
+ }
+
+ return pNew;
+}
+
+
+
+
+
+Aig_Man_t * LivenessToSafetyTransformationAbs( int mode, Abc_Ntk_t * pNtk, Aig_Man_t * p, Vec_Int_t *vFlops,
+ Vec_Ptr_t *vLive, Vec_Ptr_t *vFair, Vec_Ptr_t *vAssertSafety, Vec_Ptr_t *vAssumeSafety )
+{
+ Aig_Man_t * pNew;
+ int i, nRegCount, iEntry;
+ Aig_Obj_t * pObjSavePi;
+ Aig_Obj_t *pObjSavedLo, *pObjSavedLi;
+ Aig_Obj_t *pObj, *pMatch;
+ Aig_Obj_t *pObjSaveOrSaved, *pObjSaveAndNotSaved, *pObjSavedLoAndEquality;
+ Aig_Obj_t *pObjShadowLo, *pObjShadowLi, *pObjShadowLiDriver;
+ Aig_Obj_t *pObjXor, *pObjXnor, *pObjAndAcc;
+ Aig_Obj_t *pObjLive, *pObjFair, *pObjSafetyGate;
+ Aig_Obj_t *pObjSafetyPropertyOutput;
+ Aig_Obj_t *pDriverImage, *pArgument, *collectiveAssertSafety, *collectiveAssumeSafety;
+ char *nodeName;
+ int piCopied = 0, liCopied = 0, loCopied = 0, liCreated = 0, loCreated = 0, piVecIndex = 0, liveLatch = 0, fairLatch = 0;
+
+ vecPis = Vec_PtrAlloc( Saig_ManPiNum( p ) + 1);
+ vecPiNames = Vec_PtrAlloc( Saig_ManPiNum( p ) + 1);
+
+ vecLos = Vec_PtrAlloc( Saig_ManRegNum( p ) + Vec_IntSize( vFlops ) + 1 + Vec_PtrSize( vLive ) + Vec_PtrSize( vFair ) );
+ vecLoNames = Vec_PtrAlloc( Saig_ManRegNum( p ) + Vec_IntSize( vFlops ) + 1 + Vec_PtrSize( vLive ) + Vec_PtrSize( vFair ) );
+
+ //****************************************************************
+ // Step1: create the new manager
+ // Note: The new manager is created with "2 * Aig_ManObjNumMax(p)"
+ // nodes, but this selection is arbitrary - need to be justified
+ //****************************************************************
+ pNew = Aig_ManStart( 2 * Aig_ManObjNumMax(p) );
+ pNew->pName = (char *)malloc( strlen( pNtk->pName ) + strlen("_l2s") + 1 );
+ sprintf(pNew->pName, "%s_%s", pNtk->pName, "l2s");
+ pNew->pSpec = NULL;
+
+ //****************************************************************
+ // Step 2: map constant nodes
+ //****************************************************************
+ pObj = Aig_ManConst1( p );
+ pObj->pData = Aig_ManConst1( pNew );
+
+ //****************************************************************
+ // Step 3: create true PIs
+ //****************************************************************
+ Saig_ManForEachPi( p, pObj, i )
+ {
+ piCopied++;
+ pObj->pData = Aig_ObjCreatePi(pNew);
+ Vec_PtrPush( vecPis, pObj->pData );
+ nodeName = Aig_UtilStrsav(Abc_ObjName( Abc_NtkPi( pNtk, i ) ));
+ Vec_PtrPush( vecPiNames, nodeName );
+ }
+
+ //****************************************************************
+ // Step 4: create the special Pi corresponding to SAVE
+ //****************************************************************
+ if( mode == FULL_BIERE_MODE || mode == IGNORE_SAFETY_KEEP_LIVENESS_MODE )
+ {
+ pObjSavePi = Aig_ObjCreatePi( pNew );
+ nodeName = "SAVE_BIERE",
+ Vec_PtrPush( vecPiNames, nodeName );
+ }
+
+ //****************************************************************
+ // Step 5: create register outputs
+ //****************************************************************
+ Saig_ManForEachLo( p, pObj, i )
+ {
+ loCopied++;
+ pObj->pData = Aig_ObjCreatePi(pNew);
+ Vec_PtrPush( vecLos, pObj->pData );
+ nodeName = Aig_UtilStrsav(Abc_ObjName( Abc_NtkCi( pNtk, Abc_NtkPiNum(pNtk) + i ) ));
+ Vec_PtrPush( vecLoNames, nodeName );
+ }
+
+ //****************************************************************
+ // Step 6: create "saved" register output
+ //****************************************************************
+ if( mode == FULL_BIERE_MODE || mode == IGNORE_SAFETY_KEEP_LIVENESS_MODE )
+ {
+ loCreated++;
+ pObjSavedLo = Aig_ObjCreatePi( pNew );
+ Vec_PtrPush( vecLos, pObjSavedLo );
+ nodeName = "SAVED_LO";
+ Vec_PtrPush( vecLoNames, nodeName );
+ }
+
+ //****************************************************************
+ // Step 7: create the OR gate and the AND gate directly fed by "SAVE" Pi
+ //****************************************************************
+ if( mode == FULL_BIERE_MODE || mode == IGNORE_SAFETY_KEEP_LIVENESS_MODE )
+ {
+ pObjSaveOrSaved = Aig_Or( pNew, pObjSavePi, pObjSavedLo );
+ pObjSaveAndNotSaved = Aig_And( pNew, pObjSavePi, Aig_Not(pObjSavedLo) );
+ }
+
+ //********************************************************************
+ // Step 8: create internal nodes
+ //********************************************************************
+ Aig_ManForEachNode( p, pObj, i )
+ {
+ pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
+ }
+
+
+ //********************************************************************
+ // Step 8.x : create PO for each safety assertions
+ // NOTE : Here the output is purposely inverted as it will be thrown to
+ // dprove
+ //********************************************************************
+ if( mode == FULL_BIERE_MODE || mode == IGNORE_LIVENESS_KEEP_SAFETY_MODE )
+ {
+ if( Vec_PtrSize( vAssertSafety ) != 0 && Vec_PtrSize( vAssumeSafety ) == 0 )
+ {
+ pObjAndAcc = Aig_ManConst1( pNew );
+ Vec_PtrForEachEntry( Aig_Obj_t *, vAssertSafety, pObj, i )
+ {
+ pArgument = Aig_NotCond( (Aig_Obj_t *)Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0( pObj ) );
+ pObjAndAcc = Aig_And( pNew, pArgument, pObjAndAcc );
+ }
+ Aig_ObjCreatePo( pNew, Aig_Not(pObjAndAcc) );
+ }
+ else if( Vec_PtrSize( vAssertSafety ) != 0 && Vec_PtrSize( vAssumeSafety ) != 0 )
+ {
+ pObjAndAcc = Aig_ManConst1( pNew );
+ Vec_PtrForEachEntry( Aig_Obj_t *, vAssertSafety, pObj, i )
+ {
+ pArgument = Aig_NotCond( (Aig_Obj_t *)Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0( pObj ) );
+ pObjAndAcc = Aig_And( pNew, pArgument, pObjAndAcc );
+ }
+ collectiveAssertSafety = pObjAndAcc;
+
+ pObjAndAcc = Aig_ManConst1( pNew );
+ Vec_PtrForEachEntry( Aig_Obj_t *, vAssumeSafety, pObj, i )
+ {
+ pArgument = Aig_NotCond( (Aig_Obj_t *)Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0( pObj ) );
+ pObjAndAcc = Aig_And( pNew, pArgument, pObjAndAcc );
+ }
+ collectiveAssumeSafety = pObjAndAcc;
+ Aig_ObjCreatePo( pNew, Aig_And( pNew, Aig_Not(collectiveAssertSafety), collectiveAssumeSafety ) );
+ }
+ else
+ {
+ printf("WARNING!! No safety property is found, a new (negated) constant 1 output is created\n");
+ Aig_ObjCreatePo( pNew, Aig_Not( Aig_ManConst1(pNew) ) );
+ }
+ }
+
+ //********************************************************************
+ // Step 9: create the safety property output gate for the liveness properties
+ // discuss with Sat/Alan for an alternative implementation
+ //********************************************************************
+ if( mode == FULL_BIERE_MODE || mode == IGNORE_SAFETY_KEEP_LIVENESS_MODE )
+ {
+ pObjSafetyPropertyOutput = Aig_ObjCreatePo( pNew, (Aig_Obj_t *)Aig_ObjFanin0(pObj)->pData );
+ }
+
+ // create register inputs for the original registers
+ nRegCount = 0;
+
+ Saig_ManForEachLo( p, pObj, i )
+ {
+ pMatch = Saig_ObjLoToLi( p, pObj );
+ Aig_ObjCreatePo( pNew, Aig_NotCond((Aig_Obj_t *)Aig_ObjFanin0(pMatch)->pData, Aig_ObjFaninC0( pMatch ) ) );
+ nRegCount++;
+ liCopied++;
+ }
+
+ // create register input corresponding to the register "saved"
+ if( mode == FULL_BIERE_MODE || mode == IGNORE_SAFETY_KEEP_LIVENESS_MODE )
+ {
+ #ifndef DUPLICATE_CKT_DEBUG
+ pObjSavedLi = Aig_ObjCreatePo( pNew, pObjSaveOrSaved );
+ nRegCount++;
+ liCreated++;
+
+ //Changed on October 13, 2009
+ //pObjAndAcc = NULL;
+ pObjAndAcc = Aig_ManConst1( pNew );
+
+ // create the family of shadow registers, then create the cascade of Xnor and And gates for the comparator
+ //Saig_ManForEachLo( p, pObj, i )
+ Saig_ManForEachLo( p, pObj, i )
+ {
+ printf("Flop[%d] = %s\n", i, Abc_ObjName( Abc_NtkCi( pNtk, Abc_NtkPiNum(pNtk) + i ) ) );
+ }
+ Vec_IntForEachEntry( vFlops, iEntry, i )
+ {
+ pObjShadowLo = Aig_ObjCreatePi( pNew );
+ pObj = Aig_ManLo( p, iEntry );
+
+ #ifdef PROPAGATE_NAMES
+ Vec_PtrPush( vecLos, pObjShadowLo );
+ nodeName = (char *)malloc( strlen( Abc_ObjName( Abc_NtkCi( pNtk, Abc_NtkPiNum(pNtk) + iEntry ) ) ) + 10 );
+ sprintf( nodeName, "%s__%s", Abc_ObjName( Abc_NtkCi( pNtk, Abc_NtkPiNum(pNtk) + iEntry ) ), "SHADOW" );
+ printf("Flop copied [%d] = %s\n", iEntry, nodeName );
+ Vec_PtrPush( vecLoNames, nodeName );
+ #endif
+
+ pObjShadowLiDriver = Aig_Mux( pNew, pObjSaveAndNotSaved, (Aig_Obj_t *)pObj->pData, pObjShadowLo );
+ pObjShadowLi = Aig_ObjCreatePo( pNew, pObjShadowLiDriver );
+ nRegCount++;
+ loCreated++; liCreated++;
+
+ pObjXor = Aig_Exor( pNew, (Aig_Obj_t *)pObj->pData, pObjShadowLo );
+ pObjXnor = Aig_Not( pObjXor );
+
+ pObjAndAcc = Aig_And( pNew, pObjXnor, pObjAndAcc );
+ }
+
+ // create the AND gate whose output will be the signal "looped"
+ pObjSavedLoAndEquality = Aig_And( pNew, pObjSavedLo, pObjAndAcc );
+
+ // create the master AND gate and corresponding AND and OR logic for the liveness properties
+ pObjAndAcc = Aig_ManConst1( pNew );
+ if( vLive == NULL || Vec_PtrSize( vLive ) == 0 )
+ {
+ printf("Circuit without any liveness property\n");
+ }
+ else
+ {
+ Vec_PtrForEachEntry( Aig_Obj_t *, vLive, pObj, i )
+ {
+ liveLatch++;
+ pDriverImage = Aig_NotCond((Aig_Obj_t *)Aig_Regular(Aig_ObjChild0( pObj ))->pData, Aig_ObjFaninC0(pObj));
+ pObjShadowLo = Aig_ObjCreatePi( pNew );
+
+ #ifdef PROPAGATE_NAMES
+ Vec_PtrPush( vecLos, pObjShadowLo );
+ nodeName = (char *)malloc( strlen( Abc_ObjName( Abc_NtkPo( pNtk, getPoIndex( p, pObj ) ) ) ) + 12 );
+ sprintf( nodeName, "%s__%s", Abc_ObjName( Abc_NtkPo( pNtk, getPoIndex( p, pObj ) ) ), "LIVENESS" );
+ Vec_PtrPush( vecLoNames, nodeName );
+ #endif
+
+ pObjShadowLiDriver = Aig_Or( pNew, pObjShadowLo, Aig_And( pNew, pDriverImage, pObjSaveOrSaved ) );
+ pObjShadowLi = Aig_ObjCreatePo( pNew, pObjShadowLiDriver );
+ nRegCount++;
+ loCreated++; liCreated++;
+
+ pObjAndAcc = Aig_And( pNew, pObjShadowLo, pObjAndAcc );
+ }
+ }
+
+ pObjLive = pObjAndAcc;
+
+ pObjAndAcc = Aig_ManConst1( pNew );
+ if( vFair == NULL || Vec_PtrSize( vFair ) == 0 )
+ printf("Circuit without any fairness property\n");
+ else
+ {
+ Vec_PtrForEachEntry( Aig_Obj_t *, vFair, pObj, i )
+ {
+ fairLatch++;
+ pDriverImage = Aig_NotCond((Aig_Obj_t *)Aig_Regular(Aig_ObjChild0( pObj ))->pData, Aig_ObjFaninC0(pObj));
+ pObjShadowLo = Aig_ObjCreatePi( pNew );
+
+ #ifdef PROPAGATE_NAMES
+ Vec_PtrPush( vecLos, pObjShadowLo );
+ nodeName = (char *)malloc( strlen( Abc_ObjName( Abc_NtkPo( pNtk, getPoIndex( p, pObj ) ) ) ) + 12 );
+ sprintf( nodeName, "%s__%s", Abc_ObjName( Abc_NtkPo( pNtk, getPoIndex( p, pObj ) ) ), "FAIRNESS" );
+ Vec_PtrPush( vecLoNames, nodeName );
+ #endif
+
+ pObjShadowLiDriver = Aig_Or( pNew, pObjShadowLo, Aig_And( pNew, pDriverImage, pObjSaveOrSaved ) );
+ pObjShadowLi = Aig_ObjCreatePo( pNew, pObjShadowLiDriver );
+ nRegCount++;
+ loCreated++; liCreated++;
+
+ pObjAndAcc = Aig_And( pNew, pObjShadowLo, pObjAndAcc );
+ }
+ }
+
+ pObjFair = pObjAndAcc;
+
+ //pObjSafetyGate = Aig_Exor( pNew, Aig_Not(Aig_ManConst1( pNew )), Aig_And( pNew, pObjSavedLoAndEquality, Aig_And( pNew, pObjFair, Aig_Not( pObjLive ) ) ) );
+ //Following is the actual Biere translation
+ pObjSafetyGate = Aig_And( pNew, pObjSavedLoAndEquality, Aig_And( pNew, pObjFair, Aig_Not( pObjLive ) ) );
+
+ Aig_ObjPatchFanin0( pNew, pObjSafetyPropertyOutput, pObjSafetyGate );
+ #endif
+ }
+
+ Aig_ManSetRegNum( pNew, nRegCount );
+
+ Aig_ManPiCleanupBiere( pNew );
+ Aig_ManPoCleanupBiere( pNew );
+
+ Aig_ManCleanup( pNew );
+
+ assert( Aig_ManCheck( pNew ) );
+
+ if( mode == FULL_BIERE_MODE || mode == IGNORE_SAFETY_KEEP_LIVENESS_MODE )
+ {
+ assert((Aig_Obj_t *)Vec_PtrEntry(pNew->vPos, Saig_ManPoNum(pNew)+Aig_ObjPioNum(pObjSavedLo)-Saig_ManPiNum(p)-1) == pObjSavedLi);
+ assert( Saig_ManPiNum( p ) + 1 == Saig_ManPiNum( pNew ) );
+ assert( Saig_ManRegNum( pNew ) == Saig_ManRegNum( p ) + Vec_IntSize( vFlops ) + 1 + liveLatch + fairLatch );
+ }
+
+ return pNew;
+}
+
+
+
+Aig_Man_t * LivenessToSafetyTransformationOneStepLoop( int mode, Abc_Ntk_t * pNtk, Aig_Man_t * p,
+ Vec_Ptr_t *vLive, Vec_Ptr_t *vFair, Vec_Ptr_t *vAssertSafety, Vec_Ptr_t *vAssumeSafety )
+{
+ Aig_Man_t * pNew;
+ int i, nRegCount;
+ Aig_Obj_t * pObjSavePi;
+ Aig_Obj_t *pObj, *pMatch;
+ Aig_Obj_t *pObjSavedLoAndEquality;
+ Aig_Obj_t *pObjXor, *pObjXnor, *pObjAndAcc, *pObjAndAccDummy;
+ Aig_Obj_t *pObjLive, *pObjFair, *pObjSafetyGate;
+ Aig_Obj_t *pObjSafetyPropertyOutput;
+ Aig_Obj_t *pDriverImage;
+ Aig_Obj_t *pObjCorrespondingLi;
+ Aig_Obj_t *pArgument;
+ Aig_Obj_t *collectiveAssertSafety, *collectiveAssumeSafety;
+
+ char *nodeName;
+ int piCopied = 0, liCopied = 0, loCopied = 0, liCreated = 0, loCreated = 0, piVecIndex = 0;
+
+ if( Aig_ManRegNum( p ) == 0 )
+ {
+ printf("The input AIG contains no register, returning the original AIG as it is\n");
+ return p;
+ }
+
+ vecPis = Vec_PtrAlloc( Saig_ManPiNum( p ) + 1);
+ vecPiNames = Vec_PtrAlloc( Saig_ManPiNum( p ) + 1);
+
+ vecLos = Vec_PtrAlloc( Saig_ManRegNum( p )*2 + 1 + Vec_PtrSize( vLive ) + Vec_PtrSize( vFair ) );
+ vecLoNames = Vec_PtrAlloc( Saig_ManRegNum( p )*2 + 1 + Vec_PtrSize( vLive ) + Vec_PtrSize( vFair ) );
+
+ //****************************************************************
+ // Step1: create the new manager
+ // Note: The new manager is created with "2 * Aig_ManObjNumMax(p)"
+ // nodes, but this selection is arbitrary - need to be justified
+ //****************************************************************
+ pNew = Aig_ManStart( 2 * Aig_ManObjNumMax(p) );
+ pNew->pName = Aig_UtilStrsav( "live2safe" );
+ pNew->pSpec = NULL;
+
+ //****************************************************************
+ // Step 2: map constant nodes
+ //****************************************************************
+ pObj = Aig_ManConst1( p );
+ pObj->pData = Aig_ManConst1( pNew );
+
+ //****************************************************************
+ // Step 3: create true PIs
+ //****************************************************************
+ Saig_ManForEachPi( p, pObj, i )
+ {
+ piCopied++;
+ pObj->pData = Aig_ObjCreatePi(pNew);
+ Vec_PtrPush( vecPis, pObj->pData );
+ nodeName = Aig_UtilStrsav(Abc_ObjName( Abc_NtkPi( pNtk, i ) ));
+ Vec_PtrPush( vecPiNames, nodeName );
+ }
+
+ //****************************************************************
+ // Step 4: create the special Pi corresponding to SAVE
+ //****************************************************************
+ if( mode == FULL_BIERE_ONE_LOOP_MODE || mode == IGNORE_SAFETY_KEEP_LIVENESS_ONE_LOOP_MODE )
+ {
+ pObjSavePi = Aig_ObjCreatePi( pNew );
+ nodeName = "SAVE_BIERE",
+ Vec_PtrPush( vecPiNames, nodeName );
+ }
+
+ //****************************************************************
+ // Step 5: create register outputs
+ //****************************************************************
+ Saig_ManForEachLo( p, pObj, i )
+ {
+ loCopied++;
+ pObj->pData = Aig_ObjCreatePi(pNew);
+ Vec_PtrPush( vecLos, pObj->pData );
+ nodeName = Aig_UtilStrsav(Abc_ObjName( Abc_NtkCi( pNtk, Abc_NtkPiNum(pNtk) + i ) ));
+ Vec_PtrPush( vecLoNames, nodeName );
+ }
+
+ //****************************************************************
+ // Step 6: create "saved" register output
+ //****************************************************************
+
+#if 0
+ loCreated++;
+ pObjSavedLo = Aig_ObjCreatePi( pNew );
+ Vec_PtrPush( vecLos, pObjSavedLo );
+ nodeName = "SAVED_LO";
+ Vec_PtrPush( vecLoNames, nodeName );
+#endif
+
+ //****************************************************************
+ // Step 7: create the OR gate and the AND gate directly fed by "SAVE" Pi
+ //****************************************************************
+#if 0
+ pObjSaveOrSaved = Aig_Or( pNew, pObjSavePi, pObjSavedLo );
+ pObjSaveAndNotSaved = Aig_And( pNew, pObjSavePi, Aig_Not(pObjSavedLo) );
+#endif
+
+ //********************************************************************
+ // Step 8: create internal nodes
+ //********************************************************************
+ Aig_ManForEachNode( p, pObj, i )
+ {
+ pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
+ }
+
+#if 0
+ //********************************************************************
+ // Step 8.x : create PO for each safety assertions
+ //********************************************************************
+ Vec_PtrForEachEntry( Aig_Obj_t *, vAssertSafety, pObj, i )
+ {
+ pObj->pData = Aig_ObjCreatePo( pNew, Aig_NotCond(Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0( pObj ) ) );
+ }
+#endif
+
+ if( mode == FULL_BIERE_ONE_LOOP_MODE || mode == IGNORE_LIVENESS_KEEP_SAFETY_MODE )
+ {
+ if( Vec_PtrSize( vAssertSafety ) != 0 && Vec_PtrSize( vAssumeSafety ) == 0 )
+ {
+ pObjAndAcc = NULL;
+ Vec_PtrForEachEntry( Aig_Obj_t *, vAssertSafety, pObj, i )
+ {
+ //pObj->pData = Aig_ObjCreatePo( pNew, Aig_NotCond(Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0( pObj ) ) );
+ pArgument = Aig_NotCond( (Aig_Obj_t *)Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0( pObj ) );
+ if( pObjAndAcc == NULL )
+ pObjAndAcc = pArgument;
+ else
+ {
+ pObjAndAccDummy = pObjAndAcc;
+ pObjAndAcc = Aig_And( pNew, pArgument, pObjAndAccDummy );
+ }
+ }
+ Aig_ObjCreatePo( pNew, Aig_Not(pObjAndAcc) );
+ }
+ else if( Vec_PtrSize( vAssertSafety ) != 0 && Vec_PtrSize( vAssumeSafety ) != 0 )
+ {
+ pObjAndAcc = NULL;
+ Vec_PtrForEachEntry( Aig_Obj_t *, vAssertSafety, pObj, i )
+ {
+ //pObj->pData = Aig_ObjCreatePo( pNew, Aig_NotCond(Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0( pObj ) ) );
+ pArgument = Aig_NotCond( (Aig_Obj_t *)Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0( pObj ) );
+ if( pObjAndAcc == NULL )
+ pObjAndAcc = pArgument;
+ else
+ {
+ pObjAndAccDummy = pObjAndAcc;
+ pObjAndAcc = Aig_And( pNew, pArgument, pObjAndAccDummy );
+ }
+ }
+ collectiveAssertSafety = pObjAndAcc;
+ pObjAndAcc = NULL;
+ Vec_PtrForEachEntry( Aig_Obj_t *, vAssumeSafety, pObj, i )
+ {
+ //pObj->pData = Aig_ObjCreatePo( pNew, Aig_NotCond(Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0( pObj ) ) );
+ pArgument = Aig_NotCond( (Aig_Obj_t *)Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0( pObj ) );
+ if( pObjAndAcc == NULL )
+ pObjAndAcc = pArgument;
+ else
+ {
+ pObjAndAccDummy = pObjAndAcc;
+ pObjAndAcc = Aig_And( pNew, pArgument, pObjAndAccDummy );
+ }
+ }
+ collectiveAssumeSafety = pObjAndAcc;
+ Aig_ObjCreatePo( pNew, Aig_And( pNew, Aig_Not(collectiveAssertSafety), collectiveAssumeSafety ) );
+ }
+ else
+ printf("No safety property is specified, hence no safety gate is created\n");
+ }
+
+ //********************************************************************
+ // Step 9: create the safety property output gate
+ // create the safety property output gate, this will be the sole true PO
+ // of the whole circuit, discuss with Sat/Alan for an alternative implementation
+ //********************************************************************
+
+ if( mode == FULL_BIERE_ONE_LOOP_MODE || mode == IGNORE_SAFETY_KEEP_LIVENESS_ONE_LOOP_MODE )
+ {
+ pObjSafetyPropertyOutput = Aig_ObjCreatePo( pNew, (Aig_Obj_t *)Aig_ObjFanin0(pObj)->pData );
+ }
+
+ // create register inputs for the original registers
+ nRegCount = 0;
+
+ Saig_ManForEachLo( p, pObj, i )
+ {
+ pMatch = Saig_ObjLoToLi( p, pObj );
+ //Aig_ObjCreatePo( pNew, Aig_ObjChild0Copy(pMatch) );
+ Aig_ObjCreatePo( pNew, Aig_NotCond((Aig_Obj_t *)Aig_ObjFanin0(pMatch)->pData, Aig_ObjFaninC0( pMatch ) ) );
+ nRegCount++;
+ liCopied++;
+ }
+
+#if 0
+ // create register input corresponding to the register "saved"
+ pObjSavedLi = Aig_ObjCreatePo( pNew, pObjSaveOrSaved );
+ nRegCount++;
+ liCreated++;7
+#endif
+
+ pObjAndAcc = NULL;
+
+ //****************************************************************************************************
+ //For detection of loop of length 1 we do not need any shadow register, we only need equality detector
+ //between Lo_j and Li_j and then a cascade of AND gates
+ //****************************************************************************************************
+
+ if( mode == FULL_BIERE_ONE_LOOP_MODE || mode == IGNORE_SAFETY_KEEP_LIVENESS_ONE_LOOP_MODE )
+ {
+ Saig_ManForEachLo( p, pObj, i )
+ {
+ pObjCorrespondingLi = Saig_ObjLoToLi( p, pObj );
+
+ pObjXor = Aig_Exor( pNew, (Aig_Obj_t *)pObj->pData, Aig_NotCond( (Aig_Obj_t *)Aig_ObjFanin0( pObjCorrespondingLi )->pData, Aig_ObjFaninC0( pObjCorrespondingLi ) ) );
+ pObjXnor = Aig_Not( pObjXor );
+
+ if( pObjAndAcc == NULL )
+ pObjAndAcc = pObjXnor;
+ else
+ {
+ pObjAndAccDummy = pObjAndAcc;
+ pObjAndAcc = Aig_And( pNew, pObjXnor, pObjAndAccDummy );
+ }
+ }
+
+ // create the AND gate whose output will be the signal "looped"
+ pObjSavedLoAndEquality = Aig_And( pNew, pObjSavePi, pObjAndAcc );
+
+ // create the master AND gate and corresponding AND and OR logic for the liveness properties
+ pObjAndAcc = NULL;
+ if( vLive == NULL || Vec_PtrSize( vLive ) == 0 )
+ printf("Circuit without any liveness property\n");
+ else
+ {
+ Vec_PtrForEachEntry( Aig_Obj_t *, vLive, pObj, i )
+ {
+ pDriverImage = Aig_NotCond((Aig_Obj_t *)Aig_Regular(Aig_ObjChild0( pObj ))->pData, Aig_ObjFaninC0(pObj));
+ if( pObjAndAcc == NULL )
+ pObjAndAcc = pDriverImage;
+ else
+ {
+ pObjAndAccDummy = pObjAndAcc;
+ pObjAndAcc = Aig_And( pNew, pDriverImage, pObjAndAccDummy );
+ }
+ }
+ }
+
+ if( pObjAndAcc != NULL )
+ pObjLive = pObjAndAcc;
+ else
+ pObjLive = Aig_ManConst1( pNew );
+
+ // create the master AND gate and corresponding AND and OR logic for the fairness properties
+ pObjAndAcc = NULL;
+ if( vFair == NULL || Vec_PtrSize( vFair ) == 0 )
+ printf("Circuit without any fairness property\n");
+ else
+ {
+ Vec_PtrForEachEntry( Aig_Obj_t *, vFair, pObj, i )
+ {
+ pDriverImage = Aig_NotCond((Aig_Obj_t *)Aig_Regular(Aig_ObjChild0( pObj ))->pData, Aig_ObjFaninC0(pObj));
+ if( pObjAndAcc == NULL )
+ pObjAndAcc = pDriverImage;
+ else
+ {
+ pObjAndAccDummy = pObjAndAcc;
+ pObjAndAcc = Aig_And( pNew, pDriverImage, pObjAndAccDummy );
+ }
+ }
+ }
+
+ if( pObjAndAcc != NULL )
+ pObjFair = pObjAndAcc;
+ else
+ pObjFair = Aig_ManConst1( pNew );
+
+ pObjSafetyGate = Aig_And( pNew, pObjSavedLoAndEquality, Aig_And( pNew, pObjFair, Aig_Not( pObjLive ) ) );
+
+ Aig_ObjPatchFanin0( pNew, pObjSafetyPropertyOutput, pObjSafetyGate );
+ }
+
+ Aig_ManSetRegNum( pNew, nRegCount );
+
+ //printf("\nSaig_ManPiNum = %d, Reg Num = %d, before everything, before Pi cleanup\n", Vec_PtrSize( pNew->vPis ), pNew->nRegs );
+
+ Aig_ManPiCleanupBiere( pNew );
+ Aig_ManPoCleanupBiere( pNew );
+
+ Aig_ManCleanup( pNew );
+
+ assert( Aig_ManCheck( pNew ) );
+
+ return pNew;
+}
+
+
+
+Vec_Ptr_t * populateLivenessVector( Abc_Ntk_t *pNtk, Aig_Man_t *pAig )
+{
+ Abc_Obj_t * pNode;
+ int i, liveCounter = 0;
+ Vec_Ptr_t * vLive;
+
+ vLive = Vec_PtrAlloc( 100 );
+ Abc_NtkForEachPo( pNtk, pNode, i )
+ //if( strstr( Abc_ObjName( pNode ), "assert_fair") != NULL )
+ if( nodeName_starts_with( pNode, "assert_fair" ) )
+ {
+ Vec_PtrPush( vLive, Aig_ManPo( pAig, i ) );
+ liveCounter++;
+ }
+ printf("Number of liveness property found = %d\n", liveCounter);
+ return vLive;
+}
+
+Vec_Ptr_t * populateFairnessVector( Abc_Ntk_t *pNtk, Aig_Man_t *pAig )
+{
+ Abc_Obj_t * pNode;
+ int i, fairCounter = 0;
+ Vec_Ptr_t * vFair;
+
+ vFair = Vec_PtrAlloc( 100 );
+ Abc_NtkForEachPo( pNtk, pNode, i )
+ //if( strstr( Abc_ObjName( pNode ), "assume_fair") != NULL )
+ if( nodeName_starts_with( pNode, "assume_fair" ) )
+ {
+ Vec_PtrPush( vFair, Aig_ManPo( pAig, i ) );
+ fairCounter++;
+ }
+ printf("Number of fairness property found = %d\n", fairCounter);
+ return vFair;
+}
+
+Vec_Ptr_t * populateSafetyAssertionVector( Abc_Ntk_t *pNtk, Aig_Man_t *pAig )
+{
+ Abc_Obj_t * pNode;
+ int i, assertSafetyCounter = 0;
+ Vec_Ptr_t * vAssertSafety;
+
+ vAssertSafety = Vec_PtrAlloc( 100 );
+ Abc_NtkForEachPo( pNtk, pNode, i )
+ //if( strstr( Abc_ObjName( pNode ), "Assert") != NULL )
+ if( nodeName_starts_with( pNode, "assert_safety" ) || nodeName_starts_with( pNode, "Assert" ))
+ {
+ Vec_PtrPush( vAssertSafety, Aig_ManPo( pAig, i ) );
+ assertSafetyCounter++;
+ }
+ printf("Number of safety property found = %d\n", assertSafetyCounter);
+ return vAssertSafety;
+}
+
+Vec_Ptr_t * populateSafetyAssumptionVector( Abc_Ntk_t *pNtk, Aig_Man_t *pAig )
+{
+ Abc_Obj_t * pNode;
+ int i, assumeSafetyCounter = 0;
+ Vec_Ptr_t * vAssumeSafety;
+
+ vAssumeSafety = Vec_PtrAlloc( 100 );
+ Abc_NtkForEachPo( pNtk, pNode, i )
+ //if( strstr( Abc_ObjName( pNode ), "Assert") != NULL )
+ if( nodeName_starts_with( pNode, "assume_safety" ) || nodeName_starts_with( pNode, "Assume" ))
+ {
+ Vec_PtrPush( vAssumeSafety, Aig_ManPo( pAig, i ) );
+ assumeSafetyCounter++;
+ }
+ printf("Number of assume_safety property found = %d\n", assumeSafetyCounter);
+ return vAssumeSafety;
+}
+
+void updateNewNetworkNameManager( Abc_Ntk_t *pNtk, Aig_Man_t *pAig, Vec_Ptr_t *vPiNames, Vec_Ptr_t *vLoNames )
+{
+ Aig_Obj_t *pObj;
+ Abc_Obj_t *pNode;
+ int i, ntkObjId;
+
+ pNtk->pManName = Nm_ManCreate( Abc_NtkCiNum( pNtk ) );
+
+ if( vPiNames )
+ {
+ Saig_ManForEachPi( pAig, pObj, i )
+ {
+ ntkObjId = Abc_NtkCi( pNtk, i )->Id;
+ //printf("Pi %d, Saved Name = %s, id = %d\n", i, Nm_ManStoreIdName( pNtk->pManName, ntkObjId, Aig_ObjType(pObj), Vec_PtrEntry(vPiNames, i), NULL ), ntkObjId);
+ Nm_ManStoreIdName( pNtk->pManName, ntkObjId, Aig_ObjType(pObj), (char *)Vec_PtrEntry(vPiNames, i), NULL );
+ }
+ }
+ if( vLoNames )
+ {
+ Saig_ManForEachLo( pAig, pObj, i )
+ {
+ ntkObjId = Abc_NtkCi( pNtk, Saig_ManPiNum( pAig ) + i )->Id;
+ //printf("Lo %d, Saved name = %s, id = %d\n", i, Nm_ManStoreIdName( pNtk->pManName, ntkObjId, Aig_ObjType(pObj), Vec_PtrEntry(vLoNames, i), NULL ), ntkObjId);
+ Nm_ManStoreIdName( pNtk->pManName, ntkObjId, Aig_ObjType(pObj), (char *)Vec_PtrEntry(vLoNames, i), NULL );
+ }
+ }
+
+ Abc_NtkForEachPo(pNtk, pNode, i)
+ {
+ Abc_ObjAssignName(pNode, "assert_safety_", Abc_ObjName(pNode) );
+ }
+
+ // assign latch input names
+ Abc_NtkForEachLatch(pNtk, pNode, i)
+ if ( Nm_ManFindNameById(pNtk->pManName, Abc_ObjFanin0(pNode)->Id) == NULL )
+ Abc_ObjAssignName( Abc_ObjFanin0(pNode), Abc_ObjName(Abc_ObjFanin0(pNode)), NULL );
+}
+
+
+int Abc_CommandAbcLivenessToSafety( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ FILE * pOut, * pErr;
+ Abc_Ntk_t * pNtk, * pNtkTemp, *pNtkNew, *pNtkOld;
+ Aig_Man_t * pAig, *pAigNew;
+ int c;
+ Vec_Ptr_t * vLive, * vFair, *vAssertSafety, *vAssumeSafety;
+ int directive = -1;
+
+ pNtk = Abc_FrameReadNtk(pAbc);
+ pOut = Abc_FrameReadOut(pAbc);
+ pErr = Abc_FrameReadErr(pAbc);
+
+ if( argc == 1 )
+ {
+ assert( directive == -1 );
+ directive = FULL_BIERE_MODE;
+ }
+ else
+ {
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "1slh" ) ) != EOF )
+ {
+ switch( c )
+ {
+ case '1':
+ if( directive == -1 )
+ directive = FULL_BIERE_ONE_LOOP_MODE;
+ else
+ {
+ assert( directive == IGNORE_LIVENESS_KEEP_SAFETY_MODE || directive == IGNORE_SAFETY_KEEP_LIVENESS_MODE );
+ if( directive == IGNORE_LIVENESS_KEEP_SAFETY_MODE )
+ directive = IGNORE_LIVENESS_KEEP_SAFETY_MODE;
+ else
+ directive = IGNORE_SAFETY_KEEP_LIVENESS_ONE_LOOP_MODE;
+ }
+ break;
+ case 's':
+ if( directive == -1 )
+ directive = IGNORE_SAFETY_KEEP_LIVENESS_MODE;
+ else
+ {
+ if( directive != FULL_BIERE_ONE_LOOP_MODE )
+ goto usage;
+ assert(directive == FULL_BIERE_ONE_LOOP_MODE);
+ directive = IGNORE_SAFETY_KEEP_LIVENESS_ONE_LOOP_MODE;
+ }
+ break;
+ case 'l':
+ if( directive == -1 )
+ directive = IGNORE_LIVENESS_KEEP_SAFETY_MODE;
+ else
+ {
+ if( directive != FULL_BIERE_ONE_LOOP_MODE )
+ goto usage;
+ assert(directive == FULL_BIERE_ONE_LOOP_MODE);
+ directive = IGNORE_LIVENESS_KEEP_SAFETY_MODE;
+ }
+ break;
+ case 'h':
+ goto usage;
+ default:
+ goto usage;
+ }
+ }
+ }
+
+ if ( pNtk == NULL )
+ {
+ fprintf( pErr, "Empty network.\n" );
+ return 1;
+ }
+ if( !Abc_NtkIsStrash( pNtk ) )
+ {
+ printf("The input network was not strashed, strashing....\n");
+ pNtkTemp = Abc_NtkStrash( pNtk, 0, 0, 0 );
+ pNtkOld = pNtkTemp;
+ pAig = Abc_NtkToDar( pNtkTemp, 0, 1 );
+ vLive = populateLivenessVector( pNtk, pAig );
+ vFair = populateFairnessVector( pNtk, pAig );
+ vAssertSafety = populateSafetyAssertionVector( pNtk, pAig );
+ vAssumeSafety = populateSafetyAssumptionVector( pNtk, pAig );
+ }
+ else
+ {
+ pAig = Abc_NtkToDar( pNtk, 0, 1 );
+ pNtkOld = pNtk;
+ vLive = populateLivenessVector( pNtk, pAig );
+ vFair = populateFairnessVector( pNtk, pAig );
+ vAssertSafety = populateSafetyAssertionVector( pNtk, pAig );
+ vAssumeSafety = populateSafetyAssumptionVector( pNtk, pAig );
+ }
+
+ switch( directive )
+ {
+ case FULL_BIERE_MODE:
+ //if( Vec_PtrSize(vLive) == 0 && Vec_PtrSize(vAssertSafety) == 0 )
+ //{
+ // printf("Input circuit has NO safety and NO liveness property, original network is not disturbed\n");
+ // return 1;
+ //}
+ //else
+ //{
+ pAigNew = LivenessToSafetyTransformation( FULL_BIERE_MODE, pNtk, pAig, vLive, vFair, vAssertSafety, vAssumeSafety );
+ if( Aig_ManRegNum(pAigNew) != 0 )
+ printf("A new circuit is produced with\n\t2 POs - one for safety and one for liveness.\n\tone additional input is added (due to Biere's nondeterminism)\n\tshadow flops are not created if the original circuit is combinational\n\tnon-property POs are suppressed\n");
+ break;
+ //}
+ case FULL_BIERE_ONE_LOOP_MODE:
+ //if( Vec_PtrSize(vLive) == 0 && Vec_PtrSize(vAssertSafety) == 0 )
+ //{
+ // printf("Input circuit has NO safety and NO liveness property, original network is not disturbed\n");
+ // return 1;
+ //}
+ //else
+ //{
+ pAigNew = LivenessToSafetyTransformationOneStepLoop( FULL_BIERE_ONE_LOOP_MODE, pNtk, pAig, vLive, vFair, vAssertSafety, vAssumeSafety );
+ if( Aig_ManRegNum(pAigNew) != 0 )
+ printf("A new circuit is produced with\n\t2 POs - one for safety and one for liveness.\n\tone additional input is added (due to Biere's nondeterminism)\n\tshadow flops are not created\n\tnon-property POs are suppressed\n");
+ break;
+ //}
+ case IGNORE_LIVENESS_KEEP_SAFETY_MODE:
+ //if( Vec_PtrSize(vAssertSafety) == 0 )
+ //{
+ // printf("Input circuit has NO safety property, original network is not disturbed\n");
+ // return 1;
+ //}
+ //else
+ //{
+ pAigNew = LivenessToSafetyTransformation( IGNORE_LIVENESS_KEEP_SAFETY_MODE, pNtk, pAig, vLive, vFair, vAssertSafety, vAssumeSafety );
+ if( Aig_ManRegNum(pAigNew) != 0 )
+ printf("A new circuit is produced with\n\t1 PO - only for safety property; liveness properties are ignored, if any.\n\tno additional input is added (due to Biere's nondeterminism)\n\tshadow flops are not created\n\tnon-property POs are suppressed\n");
+ break;
+ //}
+ case IGNORE_SAFETY_KEEP_LIVENESS_MODE:
+ //if( Vec_PtrSize(vLive) == 0 )
+ //{
+ // printf("Input circuit has NO liveness property, original network is not disturbed\n");
+ // return 1;
+ //}
+ //else
+ //{
+ pAigNew = LivenessToSafetyTransformation( IGNORE_SAFETY_KEEP_LIVENESS_MODE, pNtk, pAig, vLive, vFair, vAssertSafety, vAssumeSafety );
+ if( Aig_ManRegNum(pAigNew) != 0 )
+ printf("A new circuit is produced with\n\t1 PO - only for liveness property; safety properties are ignored, if any.\n\tone additional input is added (due to Biere's nondeterminism)\n\tshadow flops are not created if the original circuit is combinational\n\tnon-property POs are suppressed\n");
+ break;
+ //}
+ case IGNORE_SAFETY_KEEP_LIVENESS_ONE_LOOP_MODE:
+ //if( Vec_PtrSize(vLive) == 0 )
+ //{
+ // printf("Input circuit has NO liveness property, original network is not disturbed\n");
+ // return 1;
+ //}
+ //else
+ //{
+ pAigNew = LivenessToSafetyTransformationOneStepLoop( IGNORE_SAFETY_KEEP_LIVENESS_ONE_LOOP_MODE, pNtk, pAig, vLive, vFair, vAssertSafety, vAssumeSafety );
+ if( Aig_ManRegNum(pAigNew) != 0 )
+ printf("New circuit is produced ignoring safety outputs!\nOnly liveness and fairness outputs are considered.\nShadow registers are not created\n");
+ break;
+ //}
+ }
+
+#if 0
+ if( argc == 1 )
+ {
+ pAigNew = LivenessToSafetyTransformation( FULL_BIERE_MODE, pNtk, pAig, vLive, vFair, vAssertSafety, vAssumeSafety );
+ if( Aig_ManRegNum(pAigNew) != 0 )
+ printf("New circuit is produced considering all safety, liveness and fairness outputs.\nBiere's logic is created\n");
+ }
+ else
+ {
+ Extra_UtilGetoptReset();
+ c = Extra_UtilGetopt( argc, argv, "1lsh" );
+ if( c == '1' )
+ {
+ if ( pNtk == NULL )
+ {
+ fprintf( pErr, "Empty network.\n" );
+ return 1;
+ }
+ if( !Abc_NtkIsStrash( pNtk ) )
+ {
+ printf("The input network was not strashed, strashing....\n");
+ pNtkTemp = Abc_NtkStrash( pNtk, 0, 0, 0 );
+ pNtkOld = pNtkTemp;
+ pAig = Abc_NtkToDar( pNtkTemp, 0, 1 );
+ vLive = populateLivenessVector( pNtk, pAig );
+ vFair = populateFairnessVector( pNtk, pAig );
+ vAssertSafety = populateSafetyAssertionVector( pNtk, pAig );
+ vAssumeSafety = populateSafetyAssumptionVector( pNtk, pAig );
+ }
+ else
+ {
+ pAig = Abc_NtkToDar( pNtk, 0, 1 );
+ pNtkOld = pNtk;
+ vLive = populateLivenessVector( pNtk, pAig );
+ vFair = populateFairnessVector( pNtk, pAig );
+ vAssertSafety = populateSafetyAssertionVector( pNtk, pAig );
+ vAssumeSafety = populateSafetyAssumptionVector( pNtk, pAig );
+ }
+ pAigNew = LivenessToSafetyTransformationOneStepLoop( pNtk, pAig, vLive, vFair, vAssertSafety, vAssumeSafety );
+ }
+ else if( c == 'l' )
+ {
+ if ( pNtk == NULL )
+ {
+ fprintf( pErr, "Empty network.\n" );
+ return 1;
+ }
+ if( !Abc_NtkIsStrash( pNtk ) )
+ {
+ printf("The input network was not strashed, strashing....\n");
+ pNtkTemp = Abc_NtkStrash( pNtk, 0, 0, 0 );
+ pNtkOld = pNtkTemp;
+ pAig = Abc_NtkToDar( pNtkTemp, 0, 1 );
+ vLive = populateLivenessVector( pNtk, pAig );
+ vFair = populateFairnessVector( pNtk, pAig );
+ vAssertSafety = populateSafetyAssertionVector( pNtk, pAig );
+ vAssumeSafety = populateSafetyAssumptionVector( pNtk, pAig );
+ }
+ else
+ {
+ pAig = Abc_NtkToDar( pNtk, 0, 1 );
+ pNtkOld = pNtk;
+ vLive = populateLivenessVector( pNtk, pAig );
+ vFair = populateFairnessVector( pNtk, pAig );
+ vAssertSafety = populateSafetyAssertionVector( pNtk, pAig );
+ vAssumeSafety = populateSafetyAssumptionVector( pNtk, pAig );
+ }
+ pAigNew = LivenessToSafetyTransformation( IGNORE_LIVENESS_KEEP_SAFETY_MODE, pNtk, pAig, vLive, vFair, vAssertSafety, vAssumeSafety );
+ if( Aig_ManRegNum(pAigNew) != 0 )
+ printf("New circuit is produced ignoring liveness outputs!\nOnly safety outputs are kept.\nBiere's logic is not created\n");
+ }
+ else if( c == 's' )
+ {
+ if ( pNtk == NULL )
+ {
+ fprintf( pErr, "Empty network.\n" );
+ return 1;
+ }
+
+ if( !Abc_NtkIsStrash( pNtk ) )
+ {
+ printf("The input network was not strashed, strashing....\n");
+ pNtkTemp = Abc_NtkStrash( pNtk, 0, 0, 0 );
+ pNtkOld = pNtkTemp;
+ pAig = Abc_NtkToDar( pNtkTemp, 0, 1 );
+ vLive = populateLivenessVector( pNtk, pAig );
+ vFair = populateFairnessVector( pNtk, pAig );
+ vAssertSafety = populateSafetyAssertionVector( pNtk, pAig );
+ vAssumeSafety = populateSafetyAssumptionVector( pNtk, pAig );
+ }
+ else
+ {
+ pAig = Abc_NtkToDar( pNtk, 0, 1 );
+ pNtkOld = pNtk;
+ vLive = populateLivenessVector( pNtk, pAig );
+ vFair = populateFairnessVector( pNtk, pAig );
+ vAssertSafety = populateSafetyAssertionVector( pNtk, pAig );
+ vAssumeSafety = populateSafetyAssumptionVector( pNtk, pAig );
+ }
+ pAigNew = LivenessToSafetyTransformation( IGNORE_SAFETY_KEEP_LIVENESS_MODE, pNtk, pAig, vLive, vFair, vAssertSafety, vAssumeSafety );
+ if( Aig_ManRegNum(pAigNew) != 0 )
+ printf("New circuit is produced ignoring safety outputs!\nOnly liveness and fairness outputs are considered.\nBiere's logic is created\n");
+ }
+ else if( c == 'h' )
+ goto usage;
+ else
+ goto usage;
+ }
+#endif
+
+#if 0
+ Aig_ManPrintStats( pAigNew );
+ printf("\nDetail statistics*************************************\n");
+ printf("Number of true primary inputs = %d\n", Saig_ManPiNum( pAigNew ));
+ printf("Number of true primary outputs = %d\n", Saig_ManPoNum( pAigNew ));
+ printf("Number of true latch outputs = %d\n", Saig_ManCiNum( pAigNew ) - Saig_ManPiNum( pAigNew ));
+ printf("Number of true latch inputs = %d\n", Saig_ManCoNum( pAigNew ) - Saig_ManPoNum( pAigNew ));
+ printf("Numer of registers = %d\n", Saig_ManRegNum( pAigNew ) );
+ printf("\n*******************************************************\n");
+#endif
+
+ pNtkNew = Abc_NtkFromAigPhase( pAigNew );
+ pNtkNew->pName = Aig_UtilStrsav( pAigNew->pName );
+
+ if ( !Abc_NtkCheck( pNtkNew ) )
+ fprintf( stdout, "Abc_NtkCreateCone(): Network check has failed.\n" );
+
+ updateNewNetworkNameManager( pNtkNew, pAigNew, vecPiNames, vecLoNames );
+ Abc_FrameSetCurrentNetwork( pAbc, pNtkNew );
+
+#if 0
+#ifndef DUPLICATE_CKT_DEBUG
+ Saig_ManForEachPi( pAigNew, pObj, i )
+ assert( strcmp( (char *)Vec_PtrEntry(vecPiNames, i), retrieveTruePiName( pNtk, pAig, pAigNew, pObj ) ) == 0 );
+ //printf("Name of %d-th Pi = %s, %s\n", i, retrieveTruePiName( pNtk, pAig, pAigNew, pObj ), (char *)Vec_PtrEntry(vecPiNames, i) );
+
+ Saig_ManForEachLo( pAigNew, pObj, i )
+ assert( strcmp( (char *)Vec_PtrEntry(vecLoNames, i), retrieveLOName( pNtk, pAig, pAigNew, pObj, vLive, vFair ) ) == 0 );
+#endif
+#endif
+
+ return 0;
+
+usage:
+ fprintf( stdout, "usage: l2s [-1lsh]\n" );
+ fprintf( stdout, "\t performs Armin Biere's live-to-safe transformation\n" );
+ fprintf( stdout, "\t-1 : no shadow logic, presume all loops are self loops\n");
+ fprintf( stdout, "\t-l : ignore liveness and fairness outputs\n");
+ fprintf( stdout, "\t-s : ignore safety assertions and assumptions\n");
+ fprintf( stdout, "\t-h : print command usage\n");
+ return 1;
+}
+
+Vec_Int_t * prepareFlopVector( Aig_Man_t * pAig, int vectorLength )
+{
+ Vec_Int_t *vFlops;
+ int i;
+
+ vFlops = Vec_IntAlloc( vectorLength );
+
+ for( i=0; i<vectorLength; i++ )
+ Vec_IntPush( vFlops, i );
+
+#if 0
+ Vec_IntPush( vFlops, 19 );
+ Vec_IntPush( vFlops, 20 );
+ Vec_IntPush( vFlops, 23 );
+ Vec_IntPush( vFlops, 24 );
+ //Vec_IntPush( vFlops, 2 );
+ //Vec_IntPush( vFlops, 3 );
+ //Vec_IntPush( vFlops, 4 );
+ //Vec_IntPush( vFlops, 5 );
+ //Vec_IntPush( vFlops, 8 );
+ //Vec_IntPush( vFlops, 9 );
+ //Vec_IntPush( vFlops, 10 );
+ //Vec_IntPush( vFlops, 11 );
+ //Vec_IntPush( vFlops, 0 );
+ //Vec_IntPush( vFlops, 0 );
+#endif
+
+ return vFlops;
+}
+
+int Abc_CommandAbcLivenessToSafetyAbstraction( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ FILE * pOut, * pErr;
+ Abc_Ntk_t * pNtk, * pNtkTemp, *pNtkNew, *pNtkOld;
+ Aig_Man_t * pAig, *pAigNew;
+ int c;
+ Vec_Ptr_t * vLive, * vFair, *vAssertSafety, *vAssumeSafety;
+ int directive = -1;
+ Vec_Int_t * vFlops;
+
+ pNtk = Abc_FrameReadNtk(pAbc);
+ pOut = Abc_FrameReadOut(pAbc);
+ pErr = Abc_FrameReadErr(pAbc);
+
+ if( argc == 1 )
+ {
+ assert( directive == -1 );
+ directive = FULL_BIERE_MODE;
+ }
+ else
+ {
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "1slh" ) ) != EOF )
+ {
+ switch( c )
+ {
+ case '1':
+ if( directive == -1 )
+ directive = FULL_BIERE_ONE_LOOP_MODE;
+ else
+ {
+ assert( directive == IGNORE_LIVENESS_KEEP_SAFETY_MODE || directive == IGNORE_SAFETY_KEEP_LIVENESS_MODE );
+ if( directive == IGNORE_LIVENESS_KEEP_SAFETY_MODE )
+ directive = IGNORE_LIVENESS_KEEP_SAFETY_MODE;
+ else
+ directive = IGNORE_SAFETY_KEEP_LIVENESS_ONE_LOOP_MODE;
+ }
+ break;
+ case 's':
+ if( directive == -1 )
+ directive = IGNORE_SAFETY_KEEP_LIVENESS_MODE;
+ else
+ {
+ if( directive != FULL_BIERE_ONE_LOOP_MODE )
+ goto usage;
+ assert(directive == FULL_BIERE_ONE_LOOP_MODE);
+ directive = IGNORE_SAFETY_KEEP_LIVENESS_ONE_LOOP_MODE;
+ }
+ break;
+ case 'l':
+ if( directive == -1 )
+ directive = IGNORE_LIVENESS_KEEP_SAFETY_MODE;
+ else
+ {
+ if( directive != FULL_BIERE_ONE_LOOP_MODE )
+ goto usage;
+ assert(directive == FULL_BIERE_ONE_LOOP_MODE);
+ directive = IGNORE_LIVENESS_KEEP_SAFETY_MODE;
+ }
+ break;
+ case 'h':
+ goto usage;
+ default:
+ goto usage;
+ }
+ }
+ }
+
+ if ( pNtk == NULL )
+ {
+ fprintf( pErr, "Empty network.\n" );
+ return 1;
+ }
+ if( !Abc_NtkIsStrash( pNtk ) )
+ {
+ printf("The input network was not strashed, strashing....\n");
+ pNtkTemp = Abc_NtkStrash( pNtk, 0, 0, 0 );
+ pNtkOld = pNtkTemp;
+ pAig = Abc_NtkToDar( pNtkTemp, 0, 1 );
+ vLive = populateLivenessVector( pNtk, pAig );
+ vFair = populateFairnessVector( pNtk, pAig );
+ vAssertSafety = populateSafetyAssertionVector( pNtk, pAig );
+ vAssumeSafety = populateSafetyAssumptionVector( pNtk, pAig );
+ }
+ else
+ {
+ pAig = Abc_NtkToDar( pNtk, 0, 1 );
+ pNtkOld = pNtk;
+ vLive = populateLivenessVector( pNtk, pAig );
+ vFair = populateFairnessVector( pNtk, pAig );
+ vAssertSafety = populateSafetyAssertionVector( pNtk, pAig );
+ vAssumeSafety = populateSafetyAssumptionVector( pNtk, pAig );
+ }
+
+ vFlops = prepareFlopVector( pAig, Aig_ManRegNum(pAig)%2 == 0? Aig_ManRegNum(pAig)/2 : (Aig_ManRegNum(pAig)-1)/2);
+
+ //vFlops = prepareFlopVector( pAig, 100 );
+
+ switch( directive )
+ {
+ case FULL_BIERE_MODE:
+ //if( Vec_PtrSize(vLive) == 0 && Vec_PtrSize(vAssertSafety) == 0 )
+ //{
+ // printf("Input circuit has NO safety and NO liveness property, original network is not disturbed\n");
+ // return 1;
+ //}
+ //else
+ //{
+ pAigNew = LivenessToSafetyTransformationAbs( FULL_BIERE_MODE, pNtk, pAig, vFlops, vLive, vFair, vAssertSafety, vAssumeSafety );
+ if( Aig_ManRegNum(pAigNew) != 0 )
+ printf("A new circuit is produced with\n\t2 POs - one for safety and one for liveness.\n\tone additional input is added (due to Biere's nondeterminism)\n\tshadow flops are not created if the original circuit is combinational\n\tnon-property POs are suppressed\n");
+ break;
+ //}
+ case FULL_BIERE_ONE_LOOP_MODE:
+ //if( Vec_PtrSize(vLive) == 0 && Vec_PtrSize(vAssertSafety) == 0 )
+ //{
+ // printf("Input circuit has NO safety and NO liveness property, original network is not disturbed\n");
+ // return 1;
+ //}
+ //else
+ //{
+ pAigNew = LivenessToSafetyTransformationOneStepLoop( FULL_BIERE_ONE_LOOP_MODE, pNtk, pAig, vLive, vFair, vAssertSafety, vAssumeSafety );
+ if( Aig_ManRegNum(pAigNew) != 0 )
+ printf("A new circuit is produced with\n\t2 POs - one for safety and one for liveness.\n\tone additional input is added (due to Biere's nondeterminism)\n\tshadow flops are not created\n\tnon-property POs are suppressed\n");
+ break;
+ //}
+ case IGNORE_LIVENESS_KEEP_SAFETY_MODE:
+ //if( Vec_PtrSize(vAssertSafety) == 0 )
+ //{
+ // printf("Input circuit has NO safety property, original network is not disturbed\n");
+ // return 1;
+ //}
+ //else
+ //{
+ pAigNew = LivenessToSafetyTransformationAbs( IGNORE_LIVENESS_KEEP_SAFETY_MODE, pNtk, pAig, vFlops, vLive, vFair, vAssertSafety, vAssumeSafety );
+ if( Aig_ManRegNum(pAigNew) != 0 )
+ printf("A new circuit is produced with\n\t1 PO - only for safety property; liveness properties are ignored, if any.\n\tno additional input is added (due to Biere's nondeterminism)\n\tshadow flops are not created\n\tnon-property POs are suppressed\n");
+ break;
+ //}
+ case IGNORE_SAFETY_KEEP_LIVENESS_MODE:
+ //if( Vec_PtrSize(vLive) == 0 )
+ //{
+ // printf("Input circuit has NO liveness property, original network is not disturbed\n");
+ // return 1;
+ //}
+ //else
+ //{
+ pAigNew = LivenessToSafetyTransformationAbs( IGNORE_SAFETY_KEEP_LIVENESS_MODE, pNtk, pAig, vFlops, vLive, vFair, vAssertSafety, vAssumeSafety );
+ if( Aig_ManRegNum(pAigNew) != 0 )
+ printf("A new circuit is produced with\n\t1 PO - only for liveness property; safety properties are ignored, if any.\n\tone additional input is added (due to Biere's nondeterminism)\n\tshadow flops are not created if the original circuit is combinational\n\tnon-property POs are suppressed\n");
+ break;
+ //}
+ case IGNORE_SAFETY_KEEP_LIVENESS_ONE_LOOP_MODE:
+ //if( Vec_PtrSize(vLive) == 0 )
+ //{
+ // printf("Input circuit has NO liveness property, original network is not disturbed\n");
+ // return 1;
+ //}
+ //else
+ //{
+ pAigNew = LivenessToSafetyTransformationOneStepLoop( IGNORE_SAFETY_KEEP_LIVENESS_ONE_LOOP_MODE, pNtk, pAig, vLive, vFair, vAssertSafety, vAssumeSafety );
+ if( Aig_ManRegNum(pAigNew) != 0 )
+ printf("New circuit is produced ignoring safety outputs!\nOnly liveness and fairness outputs are considered.\nShadow registers are not created\n");
+ break;
+ //}
+ }
+
+ pNtkNew = Abc_NtkFromAigPhase( pAigNew );
+ pNtkNew->pName = Aig_UtilStrsav( pAigNew->pName );
+
+ if ( !Abc_NtkCheck( pNtkNew ) )
+ fprintf( stdout, "Abc_NtkCreateCone(): Network check has failed.\n" );
+
+ updateNewNetworkNameManager( pNtkNew, pAigNew, vecPiNames,vecLoNames );
+ Abc_FrameSetCurrentNetwork( pAbc, pNtkNew );
+
+#if 0
+#ifndef DUPLICATE_CKT_DEBUG
+ Saig_ManForEachPi( pAigNew, pObj, i )
+ assert( strcmp( (char *)Vec_PtrEntry(vecPiNames, i), retrieveTruePiName( pNtk, pAig, pAigNew, pObj ) ) == 0 );
+ //printf("Name of %d-th Pi = %s, %s\n", i, retrieveTruePiName( pNtk, pAig, pAigNew, pObj ), (char *)Vec_PtrEntry(vecPiNames, i) );
+
+ Saig_ManForEachLo( pAigNew, pObj, i )
+ assert( strcmp( (char *)Vec_PtrEntry(vecLoNames, i), retrieveLOName( pNtk, pAig, pAigNew, pObj, vLive, vFair ) ) == 0 );
+#endif
+#endif
+
+ return 0;
+
+usage:
+ fprintf( stdout, "usage: l2s [-1lsh]\n" );
+ fprintf( stdout, "\t performs Armin Biere's live-to-safe transformation\n" );
+ fprintf( stdout, "\t-1 : no shadow logic, presume all loops are self loops\n");
+ fprintf( stdout, "\t-l : ignore liveness and fairness outputs\n");
+ fprintf( stdout, "\t-s : ignore safety assertions and assumptions\n");
+ fprintf( stdout, "\t-h : print command usage\n");
+ return 1;
+}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/live/liveness_sim.c b/src/aig/live/liveness_sim.c
new file mode 100644
index 00000000..5e494b87
--- /dev/null
+++ b/src/aig/live/liveness_sim.c
@@ -0,0 +1,848 @@
+/**CFile****************************************************************
+
+ FileName [liveness_sim.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Liveness property checking.]
+
+ Synopsis [Main implementation module.]
+
+ Author [Sayak Ray]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - January 1, 2009.]
+
+ Revision [$Id: liveness_sim.c,v 1.00 2009/01/01 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include <stdio.h>
+#include "main.h"
+#include "aig.h"
+#include "saig.h"
+#include <string.h>
+
+ABC_NAMESPACE_IMPL_START
+
+
+#define PROPAGATE_NAMES
+//#define DUPLICATE_CKT_DEBUG
+
+extern Aig_Man_t * Abc_NtkToDar( Abc_Ntk_t * pNtk, int fExors, int fRegisters );
+extern Abc_Ntk_t * Abc_NtkFromAigPhase( Aig_Man_t * pMan );
+//char *strdup(const char *string);
+
+
+/*******************************************************************
+LAYOUT OF PI VECTOR:
+
++------------------------------------------------------------------------------------------------------------------------------------+
+| TRUE ORIGINAL PI (n) | SAVE(PI) (1) | ORIGINAL LO (k) | SAVED(LO) (1) | SHADOW_ORIGINAL LO (k) | LIVENESS LO (l) | FAIRNESS LO (f) |
++------------------------------------------------------------------------------------------------------------------------------------+
+<------------True PI----------------->|<----------------------------LO--------------------------------------------------------------->
+
+LAYOUT OF PO VECTOR:
+
++-----------------------------------------------------------------------------------------------------------+
+| SOLE PO (1) | ORIGINAL LI (k) | SAVED LI (1) | SHADOW_ORIGINAL LI (k) | LIVENESS LI (l) | FAIRNESS LI (f) |
++-----------------------------------------------------------------------------------------------------------+
+<--True PO--->|<--------------------------------------LI---------------------------------------------------->
+
+********************************************************************/
+
+static void printVecPtrOfString( Vec_Ptr_t *vec )
+{
+ int i;
+
+ for( i=0; i< Vec_PtrSize( vec ); i++ )
+ {
+ printf("vec[%d] = %s\n", i, (char *)Vec_PtrEntry(vec, i) );
+ }
+}
+
+static int getPoIndex( Aig_Man_t *pAig, Aig_Obj_t *pPivot )
+{
+ int i;
+ Aig_Obj_t *pObj;
+
+ Saig_ManForEachPo( pAig, pObj, i )
+ {
+ if( pObj == pPivot )
+ return i;
+ }
+ return -1;
+}
+
+static char * retrieveTruePiName( Abc_Ntk_t *pNtkOld, Aig_Man_t *pAigOld, Aig_Man_t *pAigNew, Aig_Obj_t *pObjPivot )
+{
+ Aig_Obj_t *pObjOld, *pObj;
+ Abc_Obj_t *pNode;
+ int index;
+
+ assert( Saig_ObjIsPi( pAigNew, pObjPivot ) );
+ Aig_ManForEachPi( pAigNew, pObj, index )
+ if( pObj == pObjPivot )
+ break;
+ assert( index < Aig_ManPiNum( pAigNew ) - Aig_ManRegNum( pAigNew ) );
+ if( index == Saig_ManPiNum( pAigNew ) - 1 )
+ return "SAVE_BIERE";
+ else
+ {
+ pObjOld = Aig_ManPi( pAigOld, index );
+ pNode = Abc_NtkPi( pNtkOld, index );
+ assert( pObjOld->pData == pObjPivot );
+ return Abc_ObjName( pNode );
+ }
+}
+
+static char * retrieveLOName( Abc_Ntk_t *pNtkOld, Aig_Man_t *pAigOld, Aig_Man_t *pAigNew, Aig_Obj_t *pObjPivot, Vec_Ptr_t *vLive, Vec_Ptr_t * vFair )
+{
+ Aig_Obj_t *pObjOld, *pObj;
+ Abc_Obj_t *pNode;
+ int index, oldIndex, originalLatchNum = Saig_ManRegNum(pAigOld), strMatch, i;
+ char *dummyStr = (char *)malloc( sizeof(char) * 50 );
+
+ assert( Saig_ObjIsLo( pAigNew, pObjPivot ) );
+ Saig_ManForEachLo( pAigNew, pObj, index )
+ if( pObj == pObjPivot )
+ break;
+ if( index < originalLatchNum )
+ {
+ oldIndex = Saig_ManPiNum( pAigOld ) + index;
+ pObjOld = Aig_ManPi( pAigOld, oldIndex );
+ pNode = Abc_NtkCi( pNtkOld, oldIndex );
+ assert( pObjOld->pData == pObjPivot );
+ return Abc_ObjName( pNode );
+ }
+ else if( index == originalLatchNum )
+ return "SAVED_LO";
+ else if( index > originalLatchNum && index < 2 * originalLatchNum + 1 )
+ {
+ oldIndex = Saig_ManPiNum( pAigOld ) + index - originalLatchNum - 1;
+ pObjOld = Aig_ManPi( pAigOld, oldIndex );
+ pNode = Abc_NtkCi( pNtkOld, oldIndex );
+ sprintf( dummyStr, "%s__%s", Abc_ObjName( pNode ), "SHADOW");
+ return dummyStr;
+ }
+ else if( index >= 2 * originalLatchNum + 1 && index < 2 * originalLatchNum + 1 + Vec_PtrSize( vLive ) )
+ {
+ oldIndex = index - 2 * originalLatchNum - 1;
+ strMatch = 0;
+ Saig_ManForEachPo( pAigOld, pObj, i )
+ {
+ pNode = Abc_NtkPo( pNtkOld, i );
+ if( strstr( Abc_ObjName( pNode ), "assert_fair" ) != NULL )
+ {
+ if( strMatch == oldIndex )
+ {
+ sprintf( dummyStr, "%s__%s", Abc_ObjName( pNode ), "LIVENESS");
+ return dummyStr;
+ }
+ else
+ strMatch++;
+ }
+ }
+ }
+ else if( index >= 2 * originalLatchNum + 1 + Vec_PtrSize( vLive ) && index < 2 * originalLatchNum + 1 + Vec_PtrSize( vLive ) + Vec_PtrSize( vFair ) )
+ {
+ oldIndex = index - 2 * originalLatchNum - 1 - Vec_PtrSize( vLive );
+ strMatch = 0;
+ Saig_ManForEachPo( pAigOld, pObj, i )
+ {
+ pNode = Abc_NtkPo( pNtkOld, i );
+ if( strstr( Abc_ObjName( pNode ), "assume_fair" ) != NULL )
+ {
+ if( strMatch == oldIndex )
+ {
+ sprintf( dummyStr, "%s__%s", Abc_ObjName( pNode ), "FAIRNESS");
+ return dummyStr;
+ }
+ else
+ strMatch++;
+ }
+ }
+ }
+ else
+ return "UNKNOWN";
+}
+
+extern Vec_Ptr_t *vecPis, *vecPiNames;
+extern Vec_Ptr_t *vecLos, *vecLoNames;
+
+
+static int Aig_ManPiCleanupBiere( Aig_Man_t * p )
+{
+ int k = 0, nPisOld = Aig_ManPiNum(p);
+
+ p->nObjs[AIG_OBJ_PI] = Vec_PtrSize( p->vPis );
+ if ( Aig_ManRegNum(p) )
+ p->nTruePis = Aig_ManPiNum(p) - Aig_ManRegNum(p);
+
+ return nPisOld - Aig_ManPiNum(p);
+}
+
+
+static int Aig_ManPoCleanupBiere( Aig_Man_t * p )
+{
+ int k = 0, nPosOld = Aig_ManPoNum(p);
+
+ p->nObjs[AIG_OBJ_PO] = Vec_PtrSize( p->vPos );
+ if ( Aig_ManRegNum(p) )
+ p->nTruePos = Aig_ManPoNum(p) - Aig_ManRegNum(p);
+ return nPosOld - Aig_ManPoNum(p);
+}
+
+static Aig_Man_t * LivenessToSafetyTransformationSim( Abc_Ntk_t * pNtk, Aig_Man_t * p, Vec_Ptr_t *vLive, Vec_Ptr_t *vFair )
+{
+ Aig_Man_t * pNew;
+ int i, nRegCount;
+ Aig_Obj_t * pObjSavePi;
+ Aig_Obj_t *pObjSavedLo, *pObjSavedLi;
+ Aig_Obj_t *pObj, *pMatch;
+ Aig_Obj_t *pObjSaveOrSaved, *pObjSavedLoAndEquality;
+ Aig_Obj_t *pObjShadowLo, *pObjShadowLi, *pObjShadowLiDriver;
+ Aig_Obj_t *pObjXor, *pObjXnor, *pObjAndAcc, *pObjAndAccDummy;
+ Aig_Obj_t *pObjLive, *pObjFair, *pObjSafetyGate;
+ Aig_Obj_t *pObjSafetyPropertyOutput;
+ Aig_Obj_t *pDriverImage;
+ char *nodeName;
+ int piCopied = 0, liCopied = 0, loCopied = 0, liCreated = 0, loCreated = 0, piVecIndex = 0, liveLatch = 0, fairLatch = 0;
+
+ vecPis = Vec_PtrAlloc( Saig_ManPiNum( p ) + 1);
+ vecPiNames = Vec_PtrAlloc( Saig_ManPiNum( p ) + 1);
+
+ vecLos = Vec_PtrAlloc( Saig_ManRegNum( p )*2 + 1 + Vec_PtrSize( vLive ) + Vec_PtrSize( vFair ) );
+ vecLoNames = Vec_PtrAlloc( Saig_ManRegNum( p )*2 + 1 + Vec_PtrSize( vLive ) + Vec_PtrSize( vFair ) );
+
+#ifdef DUPLICATE_CKT_DEBUG
+ printf("\nCode is compiled in DEBUG mode, the input-output behavior will be the same as the original circuit\n");
+ printf("Press any key to continue...");
+ scanf("%c", &c);
+#endif
+
+ //****************************************************************
+ // Step1: create the new manager
+ // Note: The new manager is created with "2 * Aig_ManObjNumMax(p)"
+ // nodes, but this selection is arbitrary - need to be justified
+ //****************************************************************
+ pNew = Aig_ManStart( 2 * Aig_ManObjNumMax(p) );
+ pNew->pName = Aig_UtilStrsav( "live2safe" );
+ pNew->pSpec = NULL;
+
+ //****************************************************************
+ // Step 2: map constant nodes
+ //****************************************************************
+ pObj = Aig_ManConst1( p );
+ pObj->pData = Aig_ManConst1( pNew );
+
+ //****************************************************************
+ // Step 3: create true PIs
+ //****************************************************************
+ Saig_ManForEachPi( p, pObj, i )
+ {
+ piCopied++;
+ pObj->pData = Aig_ObjCreatePi(pNew);
+ Vec_PtrPush( vecPis, pObj->pData );
+ nodeName = Aig_UtilStrsav(Abc_ObjName( Abc_NtkPi( pNtk, i ) ));
+ Vec_PtrPush( vecPiNames, nodeName );
+ }
+
+ //****************************************************************
+ // Step 4: create the special Pi corresponding to SAVE
+ //****************************************************************
+#ifndef DUPLICATE_CKT_DEBUG
+ pObjSavePi = Aig_ObjCreatePi( pNew );
+ nodeName = Aig_UtilStrsav("SAVE_BIERE"),
+ Vec_PtrPush( vecPiNames, nodeName );
+#endif
+
+ //****************************************************************
+ // Step 5: create register outputs
+ //****************************************************************
+ Saig_ManForEachLo( p, pObj, i )
+ {
+ loCopied++;
+ pObj->pData = Aig_ObjCreatePi(pNew);
+ Vec_PtrPush( vecLos, pObj->pData );
+ nodeName = Aig_UtilStrsav(Abc_ObjName( Abc_NtkCi( pNtk, Abc_NtkPiNum(pNtk) + i ) ));
+ Vec_PtrPush( vecLoNames, nodeName );
+ }
+
+ //****************************************************************
+ // Step 6: create "saved" register output
+ //****************************************************************
+#ifndef DUPLICATE_CKT_DEBUG
+ loCreated++;
+ pObjSavedLo = Aig_ObjCreatePi( pNew );
+ Vec_PtrPush( vecLos, pObjSavedLo );
+ nodeName = Aig_UtilStrsav("SAVED_LO");
+ Vec_PtrPush( vecLoNames, nodeName );
+#endif
+
+ //****************************************************************
+ // Step 7: create the OR gate and the AND gate directly fed by "SAVE" Pi
+ //****************************************************************
+#ifndef DUPLICATE_CKT_DEBUG
+ pObjSaveOrSaved = Aig_Or( pNew, pObjSavePi, pObjSavedLo );
+ //pObjSaveAndNotSaved = Aig_And( pNew, pObjSavePi, Aig_Not(pObjSavedLo) );
+#endif
+
+ //********************************************************************
+ // Step 8: create internal nodes
+ //********************************************************************
+ Aig_ManForEachNode( p, pObj, i )
+ {
+ pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
+ }
+
+ //********************************************************************
+ // Step 9: create the safety property output gate
+ // create the safety property output gate, this will be the sole true PO
+ // of the whole circuit, discuss with Sat/Alan for an alternative implementation
+ //********************************************************************
+#ifndef DUPLICATE_CKT_DEBUG
+ pObjSafetyPropertyOutput = Aig_ObjCreatePo( pNew, (Aig_Obj_t *)Aig_ObjFanin0(pObj)->pData );
+#endif
+
+ //********************************************************************
+ // DEBUG: To recreate the same circuit, at least from the input and output
+ // behavior, we need to copy the original PO
+ //********************************************************************
+#ifdef DUPLICATE_CKT_DEBUG
+ Saig_ManForEachPo( p, pObj, i )
+ {
+ Aig_ObjCreatePo( pNew, Aig_ObjChild0Copy(pObj) );
+ }
+#endif
+
+ // create register inputs for the original registers
+ nRegCount = 0;
+
+ Saig_ManForEachLo( p, pObj, i )
+ {
+ pMatch = Saig_ObjLoToLi( p, pObj );
+ //Aig_ObjCreatePo( pNew, Aig_ObjChild0Copy(pMatch) );
+ Aig_ObjCreatePo( pNew, Aig_NotCond((Aig_Obj_t *)Aig_ObjFanin0(pMatch)->pData, Aig_ObjFaninC0( pMatch ) ) );
+ nRegCount++;
+ liCopied++;
+ }
+
+ // create register input corresponding to the register "saved"
+#ifndef DUPLICATE_CKT_DEBUG
+ pObjSavedLi = Aig_ObjCreatePo( pNew, pObjSaveOrSaved );
+ nRegCount++;
+ liCreated++;
+
+ pObjAndAcc = NULL;
+
+ // create the family of shadow registers, then create the cascade of Xnor and And gates for the comparator
+ Saig_ManForEachLo( p, pObj, i )
+ {
+ pObjShadowLo = Aig_ObjCreatePi( pNew );
+
+#ifdef PROPAGATE_NAMES
+ Vec_PtrPush( vecLos, pObjShadowLo );
+ nodeName = (char *)malloc( strlen( Abc_ObjName( Abc_NtkCi( pNtk, Abc_NtkPiNum(pNtk) + i ) ) ) + 10 );
+ sprintf( nodeName, "%s__%s", Abc_ObjName( Abc_NtkCi( pNtk, Abc_NtkPiNum(pNtk) + i ) ), "SHADOW" );
+ Vec_PtrPush( vecLoNames, nodeName );
+#endif
+
+ pObjShadowLiDriver = Aig_Mux( pNew, pObjSavePi, (Aig_Obj_t *)pObj->pData, pObjShadowLo );
+ pObjShadowLi = Aig_ObjCreatePo( pNew, pObjShadowLiDriver );
+ nRegCount++;
+ loCreated++; liCreated++;
+
+ pObjXor = Aig_Exor( pNew, (Aig_Obj_t *)pObj->pData, pObjShadowLo );
+ pObjXnor = Aig_Not( pObjXor );
+ if( pObjAndAcc == NULL )
+ pObjAndAcc = pObjXnor;
+ else
+ {
+ pObjAndAccDummy = pObjAndAcc;
+ pObjAndAcc = Aig_And( pNew, pObjXnor, pObjAndAccDummy );
+ }
+ }
+
+ // create the AND gate whose output will be the signal "looped"
+ pObjSavedLoAndEquality = Aig_And( pNew, pObjSavedLo, pObjAndAcc );
+
+ // create the master AND gate and corresponding AND and OR logic for the liveness properties
+ pObjAndAcc = NULL;
+ if( vLive == NULL || Vec_PtrSize( vLive ) == 0 )
+ printf("\nCircuit without any liveness property\n");
+ else
+ {
+ Vec_PtrForEachEntry( Aig_Obj_t *, vLive, pObj, i )
+ {
+ //assert( Aig_ObjIsNode( Aig_ObjChild0( pObj ) ) );
+ //Aig_ObjPrint( pNew, pObj );
+ liveLatch++;
+ pDriverImage = Aig_NotCond((Aig_Obj_t *)Aig_Regular(Aig_ObjChild0( pObj ))->pData, Aig_ObjFaninC0(pObj));
+ pObjShadowLo = Aig_ObjCreatePi( pNew );
+
+#ifdef PROPAGATE_NAMES
+ Vec_PtrPush( vecLos, pObjShadowLo );
+ nodeName = (char *)malloc( strlen( Abc_ObjName( Abc_NtkPo( pNtk, getPoIndex( p, pObj ) ) ) ) + 12 );
+ sprintf( nodeName, "%s__%s", Abc_ObjName( Abc_NtkPo( pNtk, getPoIndex( p, pObj ) ) ), "LIVENESS" );
+ Vec_PtrPush( vecLoNames, nodeName );
+#endif
+
+ pObjShadowLiDriver = Aig_Or( pNew, Aig_Mux(pNew, pObjSavePi, Aig_Not(Aig_ManConst1(pNew)), pObjShadowLo),
+ Aig_And( pNew, pDriverImage, pObjSaveOrSaved ) );
+ pObjShadowLi = Aig_ObjCreatePo( pNew, pObjShadowLiDriver );
+ nRegCount++;
+ loCreated++; liCreated++;
+
+ if( pObjAndAcc == NULL )
+ pObjAndAcc = pObjShadowLo;
+ else
+ {
+ pObjAndAccDummy = pObjAndAcc;
+ pObjAndAcc = Aig_And( pNew, pObjShadowLo, pObjAndAccDummy );
+ }
+ }
+ }
+
+ if( pObjAndAcc != NULL )
+ pObjLive = pObjAndAcc;
+ else
+ pObjLive = Aig_ManConst1( pNew );
+
+ // create the master AND gate and corresponding AND and OR logic for the fairness properties
+ pObjAndAcc = NULL;
+ if( vFair == NULL || Vec_PtrSize( vFair ) == 0 )
+ printf("\nCircuit without any fairness property\n");
+ else
+ {
+ Vec_PtrForEachEntry( Aig_Obj_t *, vFair, pObj, i )
+ {
+ fairLatch++;
+ //assert( Aig_ObjIsNode( Aig_ObjChild0( pObj ) ) );
+ pDriverImage = Aig_NotCond((Aig_Obj_t *)Aig_Regular(Aig_ObjChild0( pObj ))->pData, Aig_ObjFaninC0(pObj));
+ pObjShadowLo = Aig_ObjCreatePi( pNew );
+
+#ifdef PROPAGATE_NAMES
+ Vec_PtrPush( vecLos, pObjShadowLo );
+ nodeName = (char *)malloc( strlen( Abc_ObjName( Abc_NtkPo( pNtk, getPoIndex( p, pObj ) ) ) ) + 12 );
+ sprintf( nodeName, "%s__%s", Abc_ObjName( Abc_NtkPo( pNtk, getPoIndex( p, pObj ) ) ), "FAIRNESS" );
+ Vec_PtrPush( vecLoNames, nodeName );
+#endif
+
+ pObjShadowLiDriver = Aig_Or( pNew, Aig_Mux(pNew, pObjSavePi, Aig_Not(Aig_ManConst1(pNew)), pObjShadowLo),
+ Aig_And( pNew, pDriverImage, pObjSaveOrSaved ) );
+ pObjShadowLi = Aig_ObjCreatePo( pNew, pObjShadowLiDriver );
+ nRegCount++;
+ loCreated++; liCreated++;
+
+ if( pObjAndAcc == NULL )
+ pObjAndAcc = pObjShadowLo;
+ else
+ {
+ pObjAndAccDummy = pObjAndAcc;
+ pObjAndAcc = Aig_And( pNew, pObjShadowLo, pObjAndAccDummy );
+ }
+ }
+ }
+
+ if( pObjAndAcc != NULL )
+ pObjFair = pObjAndAcc;
+ else
+ pObjFair = Aig_ManConst1( pNew );
+
+ //pObjSafetyGate = Aig_Exor( pNew, Aig_Not(Aig_ManConst1( pNew )), Aig_And( pNew, pObjSavedLoAndEquality, Aig_And( pNew, pObjFair, Aig_Not( pObjLive ) ) ) );
+ pObjSafetyGate = Aig_And( pNew, pObjSavedLoAndEquality, Aig_And( pNew, pObjFair, Aig_Not( pObjLive ) ) );
+
+ Aig_ObjPatchFanin0( pNew, pObjSafetyPropertyOutput, pObjSafetyGate );
+#endif
+
+ Aig_ManSetRegNum( pNew, nRegCount );
+
+ Aig_ManPiCleanupBiere( pNew );
+ Aig_ManPoCleanupBiere( pNew );
+
+ Aig_ManCleanup( pNew );
+ assert( Aig_ManCheck( pNew ) );
+
+#ifndef DUPLICATE_CKT_DEBUG
+ assert((Aig_Obj_t *)Vec_PtrEntry(pNew->vPos, Saig_ManPoNum(pNew)+Aig_ObjPioNum(pObjSavedLo)-Saig_ManPiNum(p)-1) == pObjSavedLi);
+ assert( Saig_ManPoNum( pNew ) == 1 );
+ assert( Saig_ManPiNum( p ) + 1 == Saig_ManPiNum( pNew ) );
+ assert( Saig_ManRegNum( pNew ) == Saig_ManRegNum( p ) * 2 + 1 + liveLatch + fairLatch );
+#endif
+
+ return pNew;
+}
+
+
+static Aig_Man_t * LivenessToSafetyTransformationOneStepLoopSim( Abc_Ntk_t * pNtk, Aig_Man_t * p, Vec_Ptr_t *vLive, Vec_Ptr_t *vFair )
+{
+ Aig_Man_t * pNew;
+ int i, nRegCount;
+ Aig_Obj_t * pObjSavePi;
+ Aig_Obj_t *pObj, *pMatch;
+ Aig_Obj_t *pObjSavedLoAndEquality;
+ Aig_Obj_t *pObjXor, *pObjXnor, *pObjAndAcc, *pObjAndAccDummy;
+ Aig_Obj_t *pObjLive, *pObjFair, *pObjSafetyGate;
+ Aig_Obj_t *pObjSafetyPropertyOutput;
+ Aig_Obj_t *pDriverImage;
+ Aig_Obj_t *pObjCorrespondingLi;
+
+
+ char *nodeName;
+ int piCopied = 0, liCopied = 0, loCopied = 0, liCreated = 0, loCreated = 0, piVecIndex = 0;
+
+ vecPis = Vec_PtrAlloc( Saig_ManPiNum( p ) + 1);
+ vecPiNames = Vec_PtrAlloc( Saig_ManPiNum( p ) + 1);
+
+ vecLos = Vec_PtrAlloc( Saig_ManRegNum( p )*2 + 1 + Vec_PtrSize( vLive ) + Vec_PtrSize( vFair ) );
+ vecLoNames = Vec_PtrAlloc( Saig_ManRegNum( p )*2 + 1 + Vec_PtrSize( vLive ) + Vec_PtrSize( vFair ) );
+
+ //****************************************************************
+ // Step1: create the new manager
+ // Note: The new manager is created with "2 * Aig_ManObjNumMax(p)"
+ // nodes, but this selection is arbitrary - need to be justified
+ //****************************************************************
+ pNew = Aig_ManStart( 2 * Aig_ManObjNumMax(p) );
+ pNew->pName = Aig_UtilStrsav( "live2safe" );
+ pNew->pSpec = NULL;
+
+ //****************************************************************
+ // Step 2: map constant nodes
+ //****************************************************************
+ pObj = Aig_ManConst1( p );
+ pObj->pData = Aig_ManConst1( pNew );
+
+ //****************************************************************
+ // Step 3: create true PIs
+ //****************************************************************
+ Saig_ManForEachPi( p, pObj, i )
+ {
+ piCopied++;
+ pObj->pData = Aig_ObjCreatePi(pNew);
+ Vec_PtrPush( vecPis, pObj->pData );
+ nodeName = Aig_UtilStrsav(Abc_ObjName( Abc_NtkPi( pNtk, i ) ));
+ Vec_PtrPush( vecPiNames, nodeName );
+ }
+
+ //****************************************************************
+ // Step 4: create the special Pi corresponding to SAVE
+ //****************************************************************
+ pObjSavePi = Aig_ObjCreatePi( pNew );
+ nodeName = "SAVE_BIERE",
+ Vec_PtrPush( vecPiNames, nodeName );
+
+ //****************************************************************
+ // Step 5: create register outputs
+ //****************************************************************
+ Saig_ManForEachLo( p, pObj, i )
+ {
+ loCopied++;
+ pObj->pData = Aig_ObjCreatePi(pNew);
+ Vec_PtrPush( vecLos, pObj->pData );
+ nodeName = Aig_UtilStrsav(Abc_ObjName( Abc_NtkCi( pNtk, Abc_NtkPiNum(pNtk) + i ) ));
+ Vec_PtrPush( vecLoNames, nodeName );
+ }
+
+ //****************************************************************
+ // Step 6: create "saved" register output
+ //****************************************************************
+
+#if 0
+ loCreated++;
+ pObjSavedLo = Aig_ObjCreatePi( pNew );
+ Vec_PtrPush( vecLos, pObjSavedLo );
+ nodeName = "SAVED_LO";
+ Vec_PtrPush( vecLoNames, nodeName );
+#endif
+
+ //****************************************************************
+ // Step 7: create the OR gate and the AND gate directly fed by "SAVE" Pi
+ //****************************************************************
+#if 0
+ pObjSaveOrSaved = Aig_Or( pNew, pObjSavePi, pObjSavedLo );
+ pObjSaveAndNotSaved = Aig_And( pNew, pObjSavePi, Aig_Not(pObjSavedLo) );
+#endif
+
+ //********************************************************************
+ // Step 8: create internal nodes
+ //********************************************************************
+ Aig_ManForEachNode( p, pObj, i )
+ {
+ pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
+ }
+
+ //********************************************************************
+ // Step 9: create the safety property output gate
+ // create the safety property output gate, this will be the sole true PO
+ // of the whole circuit, discuss with Sat/Alan for an alternative implementation
+ //********************************************************************
+
+ pObjSafetyPropertyOutput = Aig_ObjCreatePo( pNew, (Aig_Obj_t *)Aig_ObjFanin0(pObj)->pData );
+
+ // create register inputs for the original registers
+ nRegCount = 0;
+
+ Saig_ManForEachLo( p, pObj, i )
+ {
+ pMatch = Saig_ObjLoToLi( p, pObj );
+ //Aig_ObjCreatePo( pNew, Aig_ObjChild0Copy(pMatch) );
+ Aig_ObjCreatePo( pNew, Aig_NotCond((Aig_Obj_t *)Aig_ObjFanin0(pMatch)->pData, Aig_ObjFaninC0( pMatch ) ) );
+ nRegCount++;
+ liCopied++;
+ }
+
+#if 0
+ // create register input corresponding to the register "saved"
+ pObjSavedLi = Aig_ObjCreatePo( pNew, pObjSaveOrSaved );
+ nRegCount++;
+ liCreated++;
+#endif
+
+ pObjAndAcc = NULL;
+
+ //****************************************************************************************************
+ //For detection of loop of length 1 we do not need any shadow register, we only need equality detector
+ //between Lo_j and Li_j and then a cascade of AND gates
+ //****************************************************************************************************
+
+ Saig_ManForEachLo( p, pObj, i )
+ {
+ pObjCorrespondingLi = Saig_ObjLoToLi( p, pObj );
+
+ pObjXor = Aig_Exor( pNew, (Aig_Obj_t *)pObj->pData, Aig_NotCond( (Aig_Obj_t *)Aig_ObjFanin0( pObjCorrespondingLi )->pData, Aig_ObjFaninC0( pObjCorrespondingLi ) ) );
+ pObjXnor = Aig_Not( pObjXor );
+
+ if( pObjAndAcc == NULL )
+ pObjAndAcc = pObjXnor;
+ else
+ {
+ pObjAndAccDummy = pObjAndAcc;
+ pObjAndAcc = Aig_And( pNew, pObjXnor, pObjAndAccDummy );
+ }
+ }
+
+ // create the AND gate whose output will be the signal "looped"
+ pObjSavedLoAndEquality = Aig_And( pNew, pObjSavePi, pObjAndAcc );
+
+ // create the master AND gate and corresponding AND and OR logic for the liveness properties
+ pObjAndAcc = NULL;
+ if( vLive == NULL || Vec_PtrSize( vLive ) == 0 )
+ printf("\nCircuit without any liveness property\n");
+ else
+ {
+ Vec_PtrForEachEntry( Aig_Obj_t *, vLive, pObj, i )
+ {
+ pDriverImage = Aig_NotCond((Aig_Obj_t *)Aig_Regular(Aig_ObjChild0( pObj ))->pData, Aig_ObjFaninC0(pObj));
+ if( pObjAndAcc == NULL )
+ pObjAndAcc = pDriverImage;
+ else
+ {
+ pObjAndAccDummy = pObjAndAcc;
+ pObjAndAcc = Aig_And( pNew, pDriverImage, pObjAndAccDummy );
+ }
+ }
+ }
+
+ if( pObjAndAcc != NULL )
+ pObjLive = pObjAndAcc;
+ else
+ pObjLive = Aig_ManConst1( pNew );
+
+ // create the master AND gate and corresponding AND and OR logic for the fairness properties
+ pObjAndAcc = NULL;
+ if( vFair == NULL || Vec_PtrSize( vFair ) == 0 )
+ printf("\nCircuit without any fairness property\n");
+ else
+ {
+ Vec_PtrForEachEntry( Aig_Obj_t *, vFair, pObj, i )
+ {
+ pDriverImage = Aig_NotCond((Aig_Obj_t *)Aig_Regular(Aig_ObjChild0( pObj ))->pData, Aig_ObjFaninC0(pObj));
+ if( pObjAndAcc == NULL )
+ pObjAndAcc = pDriverImage;
+ else
+ {
+ pObjAndAccDummy = pObjAndAcc;
+ pObjAndAcc = Aig_And( pNew, pDriverImage, pObjAndAccDummy );
+ }
+ }
+ }
+
+ if( pObjAndAcc != NULL )
+ pObjFair = pObjAndAcc;
+ else
+ pObjFair = Aig_ManConst1( pNew );
+
+ pObjSafetyGate = Aig_And( pNew, pObjSavedLoAndEquality, Aig_And( pNew, pObjFair, Aig_Not( pObjLive ) ) );
+
+ Aig_ObjPatchFanin0( pNew, pObjSafetyPropertyOutput, pObjSafetyGate );
+
+ Aig_ManSetRegNum( pNew, nRegCount );
+
+ printf("\nSaig_ManPiNum = %d, Reg Num = %d, before everything, before Pi cleanup\n", Vec_PtrSize( pNew->vPis ), pNew->nRegs );
+
+ Aig_ManPiCleanupBiere( pNew );
+ Aig_ManPoCleanupBiere( pNew );
+
+ Aig_ManCleanup( pNew );
+
+ assert( Aig_ManCheck( pNew ) );
+
+ return pNew;
+}
+
+
+
+static Vec_Ptr_t * populateLivenessVector( Abc_Ntk_t *pNtk, Aig_Man_t *pAig )
+{
+ Abc_Obj_t * pNode;
+ int i, liveCounter = 0;
+ Vec_Ptr_t * vLive;
+
+ vLive = Vec_PtrAlloc( 100 );
+ Abc_NtkForEachPo( pNtk, pNode, i )
+ if( strstr( Abc_ObjName( pNode ), "assert_fair") != NULL )
+ {
+ Vec_PtrPush( vLive, Aig_ManPo( pAig, i ) );
+ liveCounter++;
+ }
+ printf("\nNumber of liveness property found = %d\n", liveCounter);
+ return vLive;
+}
+
+static Vec_Ptr_t * populateFairnessVector( Abc_Ntk_t *pNtk, Aig_Man_t *pAig )
+{
+ Abc_Obj_t * pNode;
+ int i, fairCounter = 0;
+ Vec_Ptr_t * vFair;
+
+ vFair = Vec_PtrAlloc( 100 );
+ Abc_NtkForEachPo( pNtk, pNode, i )
+ if( strstr( Abc_ObjName( pNode ), "assume_fair") != NULL )
+ {
+ Vec_PtrPush( vFair, Aig_ManPo( pAig, i ) );
+ fairCounter++;
+ }
+ printf("\nNumber of fairness property found = %d\n", fairCounter);
+ return vFair;
+}
+
+static void updateNewNetworkNameManager( Abc_Ntk_t *pNtk, Aig_Man_t *pAig, Vec_Ptr_t *vPiNames, Vec_Ptr_t *vLoNames )
+{
+ Aig_Obj_t *pObj;
+ int i, ntkObjId;
+
+ pNtk->pManName = Nm_ManCreate( Abc_NtkCiNum( pNtk ) );
+
+ Saig_ManForEachPi( pAig, pObj, i )
+ {
+ ntkObjId = Abc_NtkCi( pNtk, i )->Id;
+ //printf("Pi %d, Saved Name = %s, id = %d\n", i, Nm_ManStoreIdName( pNtk->pManName, ntkObjId, Aig_ObjType(pObj), Vec_PtrEntry(vPiNames, i), NULL ), ntkObjId);
+ Nm_ManStoreIdName( pNtk->pManName, ntkObjId, Aig_ObjType(pObj), (char *)Vec_PtrEntry(vPiNames, i), NULL );
+ }
+ Saig_ManForEachLo( pAig, pObj, i )
+ {
+ ntkObjId = Abc_NtkCi( pNtk, Saig_ManPiNum( pAig ) + i )->Id;
+ //printf("Lo %d, Saved name = %s, id = %d\n", i, Nm_ManStoreIdName( pNtk->pManName, ntkObjId, Aig_ObjType(pObj), Vec_PtrEntry(vLoNames, i), NULL ), ntkObjId);
+ Nm_ManStoreIdName( pNtk->pManName, ntkObjId, Aig_ObjType(pObj), (char *)Vec_PtrEntry(vLoNames, i), NULL );
+ }
+}
+
+
+int Abc_CommandAbcLivenessToSafetySim( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ FILE * pOut, * pErr;
+ Abc_Ntk_t * pNtk, * pNtkTemp, *pNtkNew, *pNtkOld;
+ Aig_Man_t * pAig, *pAigNew;
+ int c;
+ Vec_Ptr_t * vLive, * vFair;
+
+ pNtk = Abc_FrameReadNtk(pAbc);
+ pOut = Abc_FrameReadOut(pAbc);
+ pErr = Abc_FrameReadErr(pAbc);
+
+ if ( pNtk == NULL )
+ {
+ fprintf( pErr, "Empty network.\n" );
+ return 1;
+ }
+
+ if( !Abc_NtkIsStrash( pNtk ) )
+ {
+ printf("\nThe input network was not strashed, strashing....\n");
+ pNtkTemp = Abc_NtkStrash( pNtk, 0, 0, 0 );
+ pNtkOld = pNtkTemp;
+ pAig = Abc_NtkToDar( pNtkTemp, 0, 1 );
+ vLive = populateLivenessVector( pNtk, pAig );
+ vFair = populateFairnessVector( pNtk, pAig );
+ }
+ else
+ {
+ pAig = Abc_NtkToDar( pNtk, 0, 1 );
+ pNtkOld = pNtk;
+ vLive = populateLivenessVector( pNtk, pAig );
+ vFair = populateFairnessVector( pNtk, pAig );
+ }
+
+#if 0
+ Aig_ManPrintStats( pAig );
+ printf("\nDetail statistics*************************************\n");
+ printf("Number of true primary inputs = %d\n", Saig_ManPiNum( pAig ));
+ printf("Number of true primary outputs = %d\n", Saig_ManPoNum( pAig ));
+ printf("Number of true latch outputs = %d\n", Saig_ManCiNum( pAig ) - Saig_ManPiNum( pAig ));
+ printf("Number of true latch inputs = %d\n", Saig_ManCoNum( pAig ) - Saig_ManPoNum( pAig ));
+ printf("Numer of registers = %d\n", Saig_ManRegNum( pAig ) );
+ printf("\n*******************************************************\n");
+#endif
+
+ c = Extra_UtilGetopt( argc, argv, "1" );
+ if( c == '1' )
+ pAigNew = LivenessToSafetyTransformationOneStepLoopSim( pNtk, pAig, vLive, vFair );
+ else
+ pAigNew = LivenessToSafetyTransformationSim( pNtk, pAig, vLive, vFair );
+
+#if 0
+ Aig_ManPrintStats( pAigNew );
+ printf("\nDetail statistics*************************************\n");
+ printf("Number of true primary inputs = %d\n", Saig_ManPiNum( pAigNew ));
+ printf("Number of true primary outputs = %d\n", Saig_ManPoNum( pAigNew ));
+ printf("Number of true latch outputs = %d\n", Saig_ManCiNum( pAigNew ) - Saig_ManPiNum( pAigNew ));
+ printf("Number of true latch inputs = %d\n", Saig_ManCoNum( pAigNew ) - Saig_ManPoNum( pAigNew ));
+ printf("Numer of registers = %d\n", Saig_ManRegNum( pAigNew ) );
+ printf("\n*******************************************************\n");
+#endif
+
+ pNtkNew = Abc_NtkFromAigPhase( pAigNew );
+
+ if ( !Abc_NtkCheck( pNtkNew ) )
+ fprintf( stdout, "Abc_NtkCreateCone(): Network check has failed.\n" );
+
+ updateNewNetworkNameManager( pNtkNew, pAigNew, vecPiNames,vecLoNames );
+ Abc_FrameSetCurrentNetwork( pAbc, pNtkNew );
+
+ //Saig_ManForEachPi( pAigNew, pObj, i )
+ // printf("Name of %d-th Pi = %s\n", i, retrieveTruePiName( pNtk, pAig, pAigNew, pObj ) );
+
+ //Saig_ManForEachLo( pAigNew, pObj, i )
+ // printf("Name of %d-th Lo = %s\n", i, retrieveLOName( pNtk, pAig, pAigNew, pObj, vLive, vFair ) );
+
+ //printVecPtrOfString( vecPiNames );
+ //printVecPtrOfString( vecLoNames );
+
+#if 0
+#ifndef DUPLICATE_CKT_DEBUG
+ Saig_ManForEachPi( pAigNew, pObj, i )
+ assert( strcmp( (char *)Vec_PtrEntry(vecPiNames, i), retrieveTruePiName( pNtk, pAig, pAigNew, pObj ) ) == 0 );
+ //printf("Name of %d-th Pi = %s, %s\n", i, retrieveTruePiName( pNtk, pAig, pAigNew, pObj ), (char *)Vec_PtrEntry(vecPiNames, i) );
+
+ Saig_ManForEachLo( pAigNew, pObj, i )
+ assert( strcmp( (char *)Vec_PtrEntry(vecLoNames, i), retrieveLOName( pNtk, pAig, pAigNew, pObj, vLive, vFair ) ) == 0 );
+#endif
+#endif
+
+ return 0;
+
+}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/live/ltl_parser.c b/src/aig/live/ltl_parser.c
new file mode 100644
index 00000000..66d7f72d
--- /dev/null
+++ b/src/aig/live/ltl_parser.c
@@ -0,0 +1,838 @@
+/**CFile****************************************************************
+
+ FileName [ltl_parser.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Liveness property checking.]
+
+ Synopsis [LTL checker.]
+
+ Author [Sayak Ray]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - January 1, 2009.]
+
+ Revision [$Id: ltl_parser.c,v 1.00 2009/01/01 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+#include <stdlib.h>
+#include <aig.h>
+#include <abc.h>
+#include <mainInt.h>
+
+ABC_NAMESPACE_IMPL_START
+
+
+enum ltlToken { AND, OR, NOT, IMPLY, GLOBALLY, EVENTUALLY, NEXT, UNTIL, BOOL };
+enum ltlGrammerToken { OPERAND, LTL, BINOP, UOP };
+typedef enum ltlToken tokenType;
+typedef enum ltlGrammerToken ltlGrammerTokenType;
+
+struct ltlNode_t
+{
+ tokenType type;
+ char *name;
+ Aig_Obj_t *pObj;
+ struct ltlNode_t *left;
+ struct ltlNode_t *right;
+};
+
+typedef struct ltlNode_t ltlNode;
+
+ltlNode *generateTypedNode( tokenType new_type )
+//void generateTypedNode( ltlNode *new_node, tokenType new_type )
+{
+ ltlNode *new_node;
+
+ new_node = (ltlNode *)malloc( sizeof(ltlNode) );
+ if( new_node )
+ {
+ new_node->type = new_type;
+ new_node->pObj = NULL;
+ new_node->name = NULL;
+ new_node->left = NULL;
+ new_node->right = NULL;
+ }
+
+ return new_node;
+}
+
+Aig_Obj_t *buildLogicFromLTLNode_combinationalOnly( Aig_Man_t *pAig, ltlNode *pLtlNode );
+
+static inline int isNotVarNameSymbol( char c )
+{
+ return ( c == ' ' || c == '\t' || c == '\n' || c == ':' || c == '\0' );
+}
+
+void Abc_FrameCopyLTLDataBase( Abc_Frame_t *pAbc, Abc_Ntk_t * pNtk )
+{
+ char *pLtlFormula, *tempFormula;
+ int i;
+
+ if( pAbc->vLTLProperties_global != NULL )
+ {
+// printf("Deleting exisitng LTL database from the frame\n");
+ pAbc->vLTLProperties_global = NULL;
+ }
+ pAbc->vLTLProperties_global = Vec_PtrAlloc(Vec_PtrSize(pNtk->vLtlProperties));
+ Vec_PtrForEachEntry( char *, pNtk->vLtlProperties, pLtlFormula, i )
+ {
+ tempFormula = (char *)malloc( sizeof(char)*(strlen(pLtlFormula)+1) );
+ sprintf( tempFormula, "%s", pLtlFormula );
+ Vec_PtrPush( pAbc->vLTLProperties_global, tempFormula );
+ }
+}
+
+char *getVarName( char *suffixFormula, int startLoc, int *endLocation )
+{
+ int i = startLoc, length;
+ char *name;
+
+ if( isNotVarNameSymbol( suffixFormula[startLoc] ) )
+ return NULL;
+
+ while( !isNotVarNameSymbol( suffixFormula[i] ) )
+ i++;
+ *endLocation = i;
+ length = i - startLoc;
+ name = (char *)malloc( sizeof(char) * (length + 1));
+ for( i=0; i<length; i++ )
+ name[i] = suffixFormula[i+startLoc];
+ name[i] = '\0';
+
+ return name;
+}
+
+
+int startOfSuffixString = 0;
+
+int isUnexpectedEOS( char *formula, int index )
+{
+ assert( formula );
+ if( index >= (int)strlen( formula ) )
+ {
+ printf("\nInvalid LTL formula: unexpected end of string..." );
+ return 1;
+ }
+ return 0;
+}
+
+int isTemporalOperator( char *formula, int index )
+{
+ if( !(isUnexpectedEOS( formula, index ) || formula[ index ] == 'G' || formula[ index ] == 'F' || formula[ index ] == 'U' || formula[ index ] == 'X') )
+ {
+ printf("\nInvalid LTL formula: expecting temporal operator at the position %d....\n", index);
+ return 0;
+ }
+ return 1;
+}
+
+ltlNode *readLtlFormula( char *formula )
+{
+ char ch;
+ char *varName;
+ int formulaLength, rememberEnd;
+ int i = startOfSuffixString;
+ ltlNode *curr_node, *temp_node_left, *temp_node_right;
+ char prevChar;
+
+ formulaLength = strlen( formula );
+ if( isUnexpectedEOS( formula, startOfSuffixString ) )
+ {
+ printf("\nFAULTING POINT: formula = %s\nstartOfSuffixString = %d, formula[%d] = %c\n\n", formula, startOfSuffixString, startOfSuffixString - 1, formula[startOfSuffixString-1]);
+ return NULL;
+ }
+
+ while( i < formulaLength )
+ {
+ ch = formula[i];
+
+ switch(ch){
+ case ' ':
+ case '\n':
+ case '\r':
+ case '\t':
+ case '\v':
+ case '\f':
+ i++;
+ startOfSuffixString = i;
+ break;
+ case ':':
+ i++;
+ if( !isTemporalOperator( formula, i ) )
+ return NULL;
+ startOfSuffixString = i;
+ break;
+ case 'G':
+ prevChar = formula[i-1];
+ if( prevChar == ':' ) //i.e. 'G' is a temporal operator
+ {
+ i++;
+ startOfSuffixString = i;
+ temp_node_left = readLtlFormula( formula );
+ if( temp_node_left == NULL )
+ return NULL;
+ else
+ {
+ curr_node = generateTypedNode(GLOBALLY);
+ curr_node->left = temp_node_left;
+ return curr_node;
+ }
+ }
+ else //i.e. 'G' must be starting a variable name
+ {
+ varName = getVarName( formula, i, &rememberEnd );
+ if( !varName )
+ {
+ printf("\nInvalid LTL formula: expecting valid variable name token...aborting" );
+ return NULL;
+ }
+ curr_node = generateTypedNode(BOOL);
+ curr_node->name = varName;
+ i = rememberEnd;
+ startOfSuffixString = i;
+ return curr_node;
+ }
+ case 'F':
+ prevChar = formula[i-1];
+ if( prevChar == ':' ) //i.e. 'F' is a temporal operator
+ {
+ i++;
+ startOfSuffixString = i;
+ temp_node_left = readLtlFormula( formula );
+ if( temp_node_left == NULL )
+ return NULL;
+ else
+ {
+ curr_node = generateTypedNode(EVENTUALLY);
+ curr_node->left = temp_node_left;
+ return curr_node;
+ }
+ }
+ else //i.e. 'F' must be starting a variable name
+ {
+ varName = getVarName( formula, i, &rememberEnd );
+ if( !varName )
+ {
+ printf("\nInvalid LTL formula: expecting valid variable name token...aborting" );
+ return NULL;
+ }
+ curr_node = generateTypedNode(BOOL);
+ curr_node->name = varName;
+ i = rememberEnd;
+ startOfSuffixString = i;
+ return curr_node;
+ }
+ case 'X':
+ prevChar = formula[i-1];
+ if( prevChar == ':' ) //i.e. 'X' is a temporal operator
+ {
+ i++;
+ startOfSuffixString = i;
+ temp_node_left = readLtlFormula( formula );
+ if( temp_node_left == NULL )
+ return NULL;
+ else
+ {
+ curr_node = generateTypedNode(NEXT);
+ curr_node->left = temp_node_left;
+ return curr_node;
+ }
+ }
+ else //i.e. 'X' must be starting a variable name
+ {
+ varName = getVarName( formula, i, &rememberEnd );
+ if( !varName )
+ {
+ printf("\nInvalid LTL formula: expecting valid variable name token...aborting" );
+ return NULL;
+ }
+ curr_node = generateTypedNode(BOOL);
+ curr_node->name = varName;
+ i = rememberEnd;
+ startOfSuffixString = i;
+ return curr_node;
+ }
+ case 'U':
+ prevChar = formula[i-1];
+ if( prevChar == ':' ) //i.e. 'X' is a temporal operator
+ {
+ i++;
+ startOfSuffixString = i;
+ temp_node_left = readLtlFormula( formula );
+ if( temp_node_left == NULL )
+ return NULL;
+ temp_node_right = readLtlFormula( formula );
+ if( temp_node_right == NULL )
+ {
+ //need to do memory management: if right subtree is NULL then left
+ //subtree must be freed.
+ return NULL;
+ }
+ curr_node = generateTypedNode(UNTIL);
+ curr_node->left = temp_node_left;
+ curr_node->right = temp_node_right;
+ return curr_node;
+ }
+ else //i.e. 'U' must be starting a variable name
+ {
+ varName = getVarName( formula, i, &rememberEnd );
+ if( !varName )
+ {
+ printf("\nInvalid LTL formula: expecting valid variable name token...aborting" );
+ return NULL;
+ }
+ curr_node = generateTypedNode(BOOL);
+ curr_node->name = varName;
+ i = rememberEnd;
+ startOfSuffixString = i;
+ return curr_node;
+ }
+ case '+':
+ i++;
+ startOfSuffixString = i;
+ temp_node_left = readLtlFormula( formula );
+ if( temp_node_left == NULL )
+ return NULL;
+ temp_node_right = readLtlFormula( formula );
+ if( temp_node_right == NULL )
+ {
+ //need to do memory management: if right subtree is NULL then left
+ //subtree must be freed.
+ return NULL;
+ }
+ curr_node = generateTypedNode(OR);
+ curr_node->left = temp_node_left;
+ curr_node->right = temp_node_right;
+ return curr_node;
+ case '&':
+ i++;
+ startOfSuffixString = i;
+ temp_node_left = readLtlFormula( formula );
+ if( temp_node_left == NULL )
+ return NULL;
+ temp_node_right = readLtlFormula( formula );
+ if( temp_node_right == NULL )
+ {
+ //need to do memory management: if right subtree is NULL then left
+ //subtree must be freed.
+ return NULL;
+ }
+ curr_node = generateTypedNode(AND);
+ curr_node->left = temp_node_left;
+ curr_node->right = temp_node_right;
+ return curr_node;
+ case '!':
+ i++;
+ startOfSuffixString = i;
+ temp_node_left = readLtlFormula( formula );
+ if( temp_node_left == NULL )
+ return NULL;
+ else
+ {
+ curr_node = generateTypedNode(NOT);
+ curr_node->left = temp_node_left;
+ return curr_node;
+ }
+ default:
+ varName = getVarName( formula, i, &rememberEnd );
+ if( !varName )
+ {
+ printf("\nInvalid LTL formula: expecting valid variable name token...aborting" );
+ return NULL;
+ }
+ curr_node = generateTypedNode(BOOL);
+ curr_node->name = varName;
+ i = rememberEnd;
+ startOfSuffixString = i;
+ return curr_node;
+ }
+ }
+ return NULL;
+}
+
+void resetGlobalVar()
+{
+ startOfSuffixString = 0;
+}
+
+ltlNode *parseFormulaCreateAST( char *inputFormula )
+{
+ ltlNode *temp;
+
+ temp = readLtlFormula( inputFormula );
+ //if( temp == NULL )
+ // printf("\nAST creation failed for formula %s", inputFormula );
+ resetGlobalVar();
+ return temp;
+}
+
+void traverseAbstractSyntaxTree( ltlNode *node )
+{
+ switch(node->type){
+ case( AND ):
+ printf("& ");
+ assert( node->left != NULL );
+ assert( node->right != NULL );
+ traverseAbstractSyntaxTree( node->left );
+ traverseAbstractSyntaxTree( node->right );
+ return;
+ case( OR ):
+ printf("+ ");
+ assert( node->left != NULL );
+ assert( node->right != NULL );
+ traverseAbstractSyntaxTree( node->left );
+ traverseAbstractSyntaxTree( node->right );
+ return;
+ case( NOT ):
+ printf("~ ");
+ assert( node->left != NULL );
+ traverseAbstractSyntaxTree( node->left );
+ assert( node->right == NULL );
+ return;
+ case( GLOBALLY ):
+ printf("G ");
+ assert( node->left != NULL );
+ traverseAbstractSyntaxTree( node->left );
+ assert( node->right == NULL );
+ return;
+ case( EVENTUALLY ):
+ printf("F ");
+ assert( node->left != NULL );
+ traverseAbstractSyntaxTree( node->left );
+ assert( node->right == NULL );
+ return;
+ case( NEXT ):
+ printf("X ");
+ assert( node->left != NULL );
+ traverseAbstractSyntaxTree( node->left );
+ assert( node->right == NULL );
+ return;
+ case( UNTIL ):
+ printf("U ");
+ assert( node->left != NULL );
+ assert( node->right != NULL );
+ traverseAbstractSyntaxTree( node->left );
+ traverseAbstractSyntaxTree( node->right );
+ return;
+ case( BOOL ):
+ printf("%s ", node->name);
+ assert( node->left == NULL );
+ assert( node->right == NULL );
+ return;
+ default:
+ printf("\nUnsupported token type: Exiting execution\n");
+ exit(0);
+ }
+}
+
+void traverseAbstractSyntaxTree_postFix( ltlNode *node )
+{
+ switch(node->type){
+ case( AND ):
+ printf("( ");
+ assert( node->left != NULL );
+ assert( node->right != NULL );
+ traverseAbstractSyntaxTree_postFix( node->left );
+ printf("& ");
+ traverseAbstractSyntaxTree_postFix( node->right );
+ printf(") ");
+ return;
+ case( OR ):
+ printf("( ");
+ assert( node->left != NULL );
+ assert( node->right != NULL );
+ traverseAbstractSyntaxTree_postFix( node->left );
+ printf("+ ");
+ traverseAbstractSyntaxTree_postFix( node->right );
+ printf(") ");
+ return;
+ case( NOT ):
+ printf("~ ");
+ assert( node->left != NULL );
+ traverseAbstractSyntaxTree_postFix( node->left );
+ assert( node->right == NULL );
+ return;
+ case( GLOBALLY ):
+ printf("G ");
+ //printf("( ");
+ assert( node->left != NULL );
+ traverseAbstractSyntaxTree_postFix( node->left );
+ assert( node->right == NULL );
+ //printf(") ");
+ return;
+ case( EVENTUALLY ):
+ printf("F ");
+ //printf("( ");
+ assert( node->left != NULL );
+ traverseAbstractSyntaxTree_postFix( node->left );
+ assert( node->right == NULL );
+ //printf(") ");
+ return;
+ case( NEXT ):
+ printf("X ");
+ assert( node->left != NULL );
+ traverseAbstractSyntaxTree_postFix( node->left );
+ assert( node->right == NULL );
+ return;
+ case( UNTIL ):
+ printf("( ");
+ assert( node->left != NULL );
+ assert( node->right != NULL );
+ traverseAbstractSyntaxTree_postFix( node->left );
+ printf("U ");
+ traverseAbstractSyntaxTree_postFix( node->right );
+ printf(") ");
+ return;
+ case( BOOL ):
+ printf("%s ", node->name);
+ assert( node->left == NULL );
+ assert( node->right == NULL );
+ return;
+ default:
+ printf("\nUnsupported token type: Exiting execution\n");
+ exit(0);
+ }
+}
+
+void populateAigPointerUnitGF( Aig_Man_t *pAigNew, ltlNode *topASTNode, Vec_Ptr_t *vSignal, Vec_Vec_t *vAigGFMap )
+{
+ ltlNode *nextNode, *nextToNextNode;
+ int serialNumSignal;
+
+ switch( topASTNode->type ){
+ case AND:
+ case OR:
+ case IMPLY:
+ populateAigPointerUnitGF( pAigNew, topASTNode->left, vSignal, vAigGFMap );
+ populateAigPointerUnitGF( pAigNew, topASTNode->right, vSignal, vAigGFMap );
+ return;
+ case NOT:
+ populateAigPointerUnitGF( pAigNew, topASTNode->left, vSignal, vAigGFMap );
+ return;
+ case GLOBALLY:
+ nextNode = topASTNode->left;
+ assert( nextNode->type = EVENTUALLY );
+ nextToNextNode = nextNode->left;
+ if( nextToNextNode->type == BOOL )
+ {
+ assert( nextToNextNode->pObj );
+ serialNumSignal = Vec_PtrFind( vSignal, nextToNextNode->pObj );
+ if( serialNumSignal == -1 )
+ {
+ Vec_PtrPush( vSignal, nextToNextNode->pObj );
+ serialNumSignal = Vec_PtrFind( vSignal, nextToNextNode->pObj );
+ }
+ //Vec_PtrPush( vGLOBALLY, topASTNode );
+ Vec_VecPush( vAigGFMap, serialNumSignal, topASTNode );
+ }
+ else
+ {
+ assert( nextToNextNode->pObj == NULL );
+ buildLogicFromLTLNode_combinationalOnly( pAigNew, nextToNextNode );
+ serialNumSignal = Vec_PtrFind( vSignal, nextToNextNode->pObj );
+ if( serialNumSignal == -1 )
+ {
+ Vec_PtrPush( vSignal, nextToNextNode->pObj );
+ serialNumSignal = Vec_PtrFind( vSignal, nextToNextNode->pObj );
+ }
+ //Vec_PtrPush( vGLOBALLY, topASTNode );
+ Vec_VecPush( vAigGFMap, serialNumSignal, topASTNode );
+ }
+ return;
+ case BOOL:
+ return;
+ default:
+ printf("\nINVALID situation: aborting...\n");
+ exit(0);
+ }
+}
+
+Aig_Obj_t *buildLogicFromLTLNode_combinationalOnly( Aig_Man_t *pAigNew, ltlNode *pLtlNode )
+{
+ Aig_Obj_t *leftAigObj, *rightAigObj;
+
+ if( pLtlNode->pObj != NULL )
+ return pLtlNode->pObj;
+ else
+ {
+ assert( pLtlNode->type != BOOL );
+ switch( pLtlNode->type ){
+ case AND:
+ assert( pLtlNode->left ); assert( pLtlNode->right );
+ leftAigObj = buildLogicFromLTLNode_combinationalOnly( pAigNew, pLtlNode->left );
+ rightAigObj = buildLogicFromLTLNode_combinationalOnly( pAigNew, pLtlNode->right );
+ assert( leftAigObj ); assert( rightAigObj );
+ pLtlNode->pObj = Aig_And( pAigNew, leftAigObj, rightAigObj );
+ return pLtlNode->pObj;
+ case OR:
+ assert( pLtlNode->left ); assert( pLtlNode->right );
+ leftAigObj = buildLogicFromLTLNode_combinationalOnly( pAigNew, pLtlNode->left );
+ rightAigObj = buildLogicFromLTLNode_combinationalOnly( pAigNew, pLtlNode->right );
+ assert( leftAigObj ); assert( rightAigObj );
+ pLtlNode->pObj = Aig_Or( pAigNew, leftAigObj, rightAigObj );
+ return pLtlNode->pObj;
+ case NOT:
+ assert( pLtlNode->left ); assert( pLtlNode->right == NULL );
+ leftAigObj = buildLogicFromLTLNode_combinationalOnly( pAigNew, pLtlNode->left );
+ assert( leftAigObj );
+ pLtlNode->pObj = Aig_Not( leftAigObj );
+ return pLtlNode->pObj;
+ case GLOBALLY:
+ case EVENTUALLY:
+ case NEXT:
+ case UNTIL:
+ printf("FORBIDDEN node: ABORTING!!\n");
+ exit(0);
+ default:
+ printf("\nSerious ERROR: attempting to create AIG node from a temporal node\n");
+ exit(0);
+ }
+ }
+}
+
+Aig_Obj_t *buildLogicFromLTLNode( Aig_Man_t *pAig, ltlNode *pLtlNode )
+{
+ Aig_Obj_t *leftAigObj, *rightAigObj;
+
+ if( pLtlNode->pObj != NULL )
+ return pLtlNode->pObj;
+ else
+ {
+ assert( pLtlNode->type != BOOL );
+ switch( pLtlNode->type ){
+ case AND:
+ assert( pLtlNode->left ); assert( pLtlNode->right );
+ leftAigObj = buildLogicFromLTLNode( pAig, pLtlNode->left );
+ rightAigObj = buildLogicFromLTLNode( pAig, pLtlNode->right );
+ assert( leftAigObj ); assert( rightAigObj );
+ pLtlNode->pObj = Aig_And( pAig, leftAigObj, rightAigObj );
+ return pLtlNode->pObj;
+ case OR:
+ assert( pLtlNode->left ); assert( pLtlNode->right );
+ leftAigObj = buildLogicFromLTLNode( pAig, pLtlNode->left );
+ rightAigObj = buildLogicFromLTLNode( pAig, pLtlNode->right );
+ assert( leftAigObj ); assert( rightAigObj );
+ pLtlNode->pObj = Aig_Or( pAig, leftAigObj, rightAigObj );
+ return pLtlNode->pObj;
+ case NOT:
+ assert( pLtlNode->left ); assert( pLtlNode->right == NULL );
+ leftAigObj = buildLogicFromLTLNode( pAig, pLtlNode->left );
+ assert( leftAigObj );
+ pLtlNode->pObj = Aig_Not( leftAigObj );
+ return pLtlNode->pObj;
+ case GLOBALLY:
+ case EVENTUALLY:
+ case NEXT:
+ case UNTIL:
+ printf("\nAttempting to create circuit with missing AIG pointer in a TEMPORAL node: ABORTING!!\n");
+ exit(0);
+ default:
+ printf("\nSerious ERROR: attempting to create AIG node from a temporal node\n");
+ exit(0);
+ }
+ }
+}
+
+int isNonTemporalSubformula( ltlNode *topNode )
+{
+ switch( topNode->type ){
+ case AND:
+ case OR:
+ case IMPLY:
+ return isNonTemporalSubformula( topNode->left) && isNonTemporalSubformula( topNode->right ) ;
+ case NOT:
+ assert( topNode->right == NULL );
+ return isNonTemporalSubformula( topNode->left );
+ case BOOL:
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+int isWellFormed( ltlNode *topNode )
+{
+ ltlNode *nextNode;
+
+ switch( topNode->type ){
+ case AND:
+ case OR:
+ case IMPLY:
+ return isWellFormed( topNode->left) && isWellFormed( topNode->right ) ;
+ case NOT:
+ assert( topNode->right == NULL );
+ return isWellFormed( topNode->left );
+ case BOOL:
+ return 1;
+ case GLOBALLY:
+ nextNode = topNode->left;
+ assert( topNode->right == NULL );
+ if( nextNode->type != EVENTUALLY )
+ return 0;
+ else
+ {
+ assert( nextNode->right == NULL );
+ return isNonTemporalSubformula( nextNode->left );
+ }
+ default:
+ return 0;
+ }
+}
+
+int checkBooleanConstant( char *targetName )
+{
+ if( strcmp( targetName, "true" ) == 0 )
+ return 1;
+ if( strcmp( targetName, "false" ) == 0 )
+ return 0;
+ return -1;
+}
+
+int checkSignalNameExistence( Abc_Ntk_t *pNtk, ltlNode *topASTNode )
+{
+ char *targetName;
+ Abc_Obj_t * pNode;
+ int i;
+
+ switch( topASTNode->type ){
+ case BOOL:
+ targetName = topASTNode->name;
+ //printf("\nTrying to match name %s\n", targetName);
+ if( checkBooleanConstant( targetName ) != -1 )
+ return 1;
+ Abc_NtkForEachPo( pNtk, pNode, i )
+ {
+ if( strcmp( Abc_ObjName( pNode ), targetName ) == 0 )
+ {
+ //printf("\nVariable name \"%s\" MATCHED\n", targetName);
+ return 1;
+ }
+ }
+ printf("\nVariable name \"%s\" not found in the PO name list\n", targetName);
+ return 0;
+ case AND:
+ case OR:
+ case IMPLY:
+ case UNTIL:
+ assert( topASTNode->left != NULL );
+ assert( topASTNode->right != NULL );
+ return checkSignalNameExistence( pNtk, topASTNode->left ) && checkSignalNameExistence( pNtk, topASTNode->right );
+
+ case NOT:
+ case NEXT:
+ case GLOBALLY:
+ case EVENTUALLY:
+ assert( topASTNode->left != NULL );
+ assert( topASTNode->right == NULL );
+ return checkSignalNameExistence( pNtk, topASTNode->left );
+ default:
+ printf("\nUNSUPPORTED LTL NODE TYPE:: Aborting execution\n");
+ exit(0);
+ }
+}
+
+void populateBoolWithAigNodePtr( Abc_Ntk_t *pNtk, Aig_Man_t *pAigOld, Aig_Man_t *pAigNew, ltlNode *topASTNode )
+{
+ char *targetName;
+ Abc_Obj_t * pNode;
+ int i;
+ Aig_Obj_t *pObj, *pDriverImage;
+
+ switch( topASTNode->type ){
+ case BOOL:
+ targetName = topASTNode->name;
+ if( checkBooleanConstant( targetName ) == 1 )
+ {
+ topASTNode->pObj = Aig_ManConst1( pAigNew );
+ return;
+ }
+ if( checkBooleanConstant( targetName ) == 0 )
+ {
+ topASTNode->pObj = Aig_Not(topASTNode->pObj = Aig_ManConst1( pAigNew ));
+ return;
+ }
+ Abc_NtkForEachPo( pNtk, pNode, i )
+ if( strcmp( Abc_ObjName( pNode ), targetName ) == 0 )
+ {
+ pObj = Aig_ManPo( pAigOld, i );
+ assert( Aig_ObjIsPo( pObj ));
+ pDriverImage = Aig_NotCond((Aig_Obj_t *)Aig_Regular(Aig_ObjChild0( pObj ))->pData, Aig_ObjFaninC0(pObj));
+ topASTNode->pObj = pDriverImage;
+ return;
+ }
+ assert(0);
+ case AND:
+ case OR:
+ case IMPLY:
+ case UNTIL:
+ assert( topASTNode->left != NULL );
+ assert( topASTNode->right != NULL );
+ populateBoolWithAigNodePtr( pNtk, pAigOld, pAigNew, topASTNode->left );
+ populateBoolWithAigNodePtr( pNtk, pAigOld, pAigNew, topASTNode->right );
+ return;
+ case NOT:
+ case NEXT:
+ case GLOBALLY:
+ case EVENTUALLY:
+ assert( topASTNode->left != NULL );
+ assert( topASTNode->right == NULL );
+ populateBoolWithAigNodePtr( pNtk, pAigOld, pAigNew, topASTNode->left );
+ return;
+ default:
+ printf("\nUNSUPPORTED LTL NODE TYPE:: Aborting execution\n");
+ exit(0);
+ }
+}
+
+int checkAllBoolHaveAIGPointer( ltlNode *topASTNode )
+{
+
+ switch( topASTNode->type ){
+ case BOOL:
+ if( topASTNode->pObj != NULL )
+ return 1;
+ else
+ {
+ printf("\nfaulting PODMANDYO topASTNode->name = %s\n", topASTNode->name);
+ return 0;
+ }
+ case AND:
+ case OR:
+ case IMPLY:
+ case UNTIL:
+ assert( topASTNode->left != NULL );
+ assert( topASTNode->right != NULL );
+ return checkAllBoolHaveAIGPointer( topASTNode->left ) && checkAllBoolHaveAIGPointer( topASTNode->right );
+
+ case NOT:
+ case NEXT:
+ case GLOBALLY:
+ case EVENTUALLY:
+ assert( topASTNode->left != NULL );
+ assert( topASTNode->right == NULL );
+ return checkAllBoolHaveAIGPointer( topASTNode->left );
+ default:
+ printf("\nUNSUPPORTED LTL NODE TYPE:: Aborting execution\n");
+ exit(0);
+ }
+}
+
+void setAIGNodePtrOfGloballyNode( ltlNode *astNode, Aig_Obj_t *pObjLo )
+{
+ astNode->pObj = pObjLo;
+}
+
+Aig_Obj_t *retriveAIGPointerFromLTLNode( ltlNode *astNode )
+{
+ return astNode->pObj;
+}
+
+
+ABC_NAMESPACE_IMPL_END
diff --git a/src/aig/live/module.make b/src/aig/live/module.make
new file mode 100644
index 00000000..46a9ed3c
--- /dev/null
+++ b/src/aig/live/module.make
@@ -0,0 +1,3 @@
+SRC += src/aig/live/liveness.c \
+ src/aig/live/liveness_sim.c \
+ src/aig/live/ltl_parser.c
diff --git a/src/base/abci/abc_.c b/src/aig/llb/llb.c
index 75ec88c3..348c0622 100644
--- a/src/base/abci/abc_.c
+++ b/src/aig/llb/llb.c
@@ -1,10 +1,10 @@
/**CFile****************************************************************
- FileName [abc_.c]
+ FileName [llb.c]
SystemName [ABC: Logic synthesis and verification system.]
- PackageName [Network and node package.]
+ PackageName [BDD based reachability.]
Synopsis []
@@ -14,11 +14,14 @@
Date [Ver. 1.0. Started - June 20, 2005.]
- Revision [$Id: abc_.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+ Revision [$Id: llb.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
-#include "abc.h"
+#include "llbInt.h"
+
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -40,9 +43,10 @@
***********************************************************************/
-
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/llb/llb.h b/src/aig/llb/llb.h
new file mode 100644
index 00000000..2c8d1c19
--- /dev/null
+++ b/src/aig/llb/llb.h
@@ -0,0 +1,92 @@
+/**CFile****************************************************************
+
+ FileName [llb.h]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [BDD-based reachability.]
+
+ Synopsis [External declarations.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - May 8, 2010.]
+
+ Revision [$Id: llb.h,v 1.00 2010/05/08 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#ifndef __LLB_H__
+#define __LLB_H__
+
+
+////////////////////////////////////////////////////////////////////////
+/// INCLUDES ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// PARAMETERS ///
+////////////////////////////////////////////////////////////////////////
+
+
+
+ABC_NAMESPACE_HEADER_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// BASIC TYPES ///
+////////////////////////////////////////////////////////////////////////
+
+typedef struct Gia_ParLlb_t_ Gia_ParLlb_t;
+struct Gia_ParLlb_t_
+{
+ int nBddMax; // maximum BDD size
+ int nIterMax; // maximum iteration count
+ int nClusterMax; // maximum cluster size
+ int nHintDepth; // the number of times to cofactor
+ int HintFirst; // the number of first hint to use
+ int fUseFlow; // use flow computation
+ int nVolumeMax; // the largest volume
+ int nVolumeMin; // the smallest volume
+ int fReorder; // enable dynamic variable reordering
+ int fIndConstr; // extract inductive constraints
+ int fUsePivots; // use internal pivot variables
+ int fCluster; // use partition clustering
+ int fSchedule; // use cluster scheduling
+ int fVerbose; // print verbose information
+ int fVeryVerbose; // print dependency matrices
+ int fSilent; // do not print any infomation
+ int fSkipReach; // skip reachability (preparation phase only)
+ int fSkipOutCheck; // does not check the property output
+ int TimeLimit; // time limit for one reachability run
+ int TimeLimitGlo; // time limit for all reachability runs
+ // internal parameters
+ int TimeTarget; // the time to stop
+ int iFrame; // explored up to this frame
+};
+
+////////////////////////////////////////////////////////////////////////
+/// MACRO DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/*=== llbCore.c ==========================================================*/
+extern void Llb_ManSetDefaultParams( Gia_ParLlb_t * pPars );
+
+
+
+ABC_NAMESPACE_HEADER_END
+
+
+
+#endif
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
diff --git a/src/aig/nwk2/nwk_.c b/src/aig/llb/llbCex.c
index 81cffbbf..87059c0c 100644
--- a/src/aig/nwk2/nwk_.c
+++ b/src/aig/llb/llbCex.c
@@ -1,12 +1,12 @@
/**CFile****************************************************************
- FileName [nwk_.c]
+ FileName [llbCex.c]
SystemName [ABC: Logic synthesis and verification system.]
- PackageName [Netlist representation.]
+ PackageName [BDD based reachability.]
- Synopsis []
+ Synopsis [Deriving counter-example.]
Author [Alan Mishchenko]
@@ -14,11 +14,14 @@
Date [Ver. 1.0. Started - June 20, 2005.]
- Revision [$Id: nwk_.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+ Revision [$Id: llbCex.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
-#include "nwk.h"
+#include "llbInt.h"
+
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -39,9 +42,15 @@
SeeAlso []
***********************************************************************/
+Abc_Cex_t * Llb_ManDeriveCex( Llb_Man_t * p, DdNode * bInter, int iOutFail, int iIter )
+{
+ return NULL;
+}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/llb/llbCluster.c b/src/aig/llb/llbCluster.c
new file mode 100644
index 00000000..1d0153ce
--- /dev/null
+++ b/src/aig/llb/llbCluster.c
@@ -0,0 +1,357 @@
+/**CFile****************************************************************
+
+ FileName [llbCluster.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [BDD based reachability.]
+
+ Synopsis [Clustering algorithm.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: llbCluster.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "llbInt.h"
+#include "extra.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Llb_ManComputeCommonQuant( Llb_Mtr_t * p, int iCol1, int iCol2 )
+{
+ int iVar, Weight = 0;
+ for ( iVar = 0; iVar < p->nRows - p->nFfs; iVar++ )
+ {
+ // count each removed variable as 2
+ if ( p->pMatrix[iCol1][iVar] == 1 && p->pMatrix[iCol2][iVar] == 1 && p->pRowSums[iVar] == 2 )
+ Weight += 2;
+ // count each added variale as -1
+ else if ( (p->pMatrix[iCol1][iVar] == 1 && p->pMatrix[iCol2][iVar] == 0) ||
+ (p->pMatrix[iCol1][iVar] == 0 && p->pMatrix[iCol2][iVar] == 1) )
+ Weight--;
+ }
+ return Weight;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Llb_ManComputeBestQuant( Llb_Mtr_t * p )
+{
+ int i, k, WeightBest = -100000, WeightCur, RetValue = -1;
+ for ( i = 1; i < p->nCols-1; i++ )
+ for ( k = i+1; k < p->nCols-1; k++ )
+ {
+ if ( p->pColSums[i] == 0 || p->pColSums[i] > p->pMan->pPars->nClusterMax )
+ continue;
+ if ( p->pColSums[k] == 0 || p->pColSums[k] > p->pMan->pPars->nClusterMax )
+ continue;
+
+ WeightCur = Llb_ManComputeCommonQuant( p, i, k );
+ if ( WeightCur <= 0 )
+ continue;
+ if ( WeightBest < WeightCur )
+ {
+ WeightBest = WeightCur;
+ RetValue = (i << 16) | k;
+ }
+ }
+// printf( "Choosing best quant Weight %4d\n", WeightCur );
+ return RetValue;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+float ** Llb_ManComputeQuant( Llb_Mtr_t * p )
+{
+ float ** pCosts;
+ int i, k;
+ // alloc and clean
+ pCosts = (float **)Extra_ArrayAlloc( p->nCols, p->nCols, sizeof(float) );
+ for ( i = 0; i < p->nCols; i++ )
+ for ( k = 0; k < p->nCols; k++ )
+ pCosts[i][i] = 0.0;
+ // fill up
+ for ( i = 1; i < p->nCols-1; i++ )
+ for ( k = i+1; k < p->nCols-1; k++ )
+ pCosts[i][k] = pCosts[k][i] = Llb_ManComputeCommonQuant( p, i, k );
+ return pCosts;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+float Llb_ManComputeCommonAttr( Llb_Mtr_t * p, int iCol1, int iCol2 )
+{
+ int iVar, CountComm = 0, CountDiff = 0;
+ for ( iVar = 0; iVar < p->nRows - p->nFfs; iVar++ )
+ {
+ if ( p->pMatrix[iCol1][iVar] == 1 && p->pMatrix[iCol2][iVar] == 1 )
+ CountComm++;
+ else if ( p->pMatrix[iCol1][iVar] == 1 || p->pMatrix[iCol2][iVar] == 1 )
+ CountDiff++;
+ }
+/*
+ printf( "Attr cost for %4d and %4d: %4d %4d (%5.2f)\n",
+ iCol1, iCol2,
+ CountDiff, CountComm,
+ -1.0 * CountDiff / ( CountComm + CountDiff ) );
+*/
+ return -1.0 * CountDiff / ( CountComm + CountDiff );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Llb_ManComputeBestAttr( Llb_Mtr_t * p )
+{
+ float WeightBest = -100000, WeightCur;
+ int i, k, RetValue = -1;
+ for ( i = 1; i < p->nCols-1; i++ )
+ for ( k = i+1; k < p->nCols-1; k++ )
+ {
+ if ( p->pColSums[i] == 0 || p->pColSums[i] > p->pMan->pPars->nClusterMax )
+ continue;
+ if ( p->pColSums[k] == 0 || p->pColSums[k] > p->pMan->pPars->nClusterMax )
+ continue;
+ WeightCur = Llb_ManComputeCommonAttr( p, i, k );
+ if ( WeightBest < WeightCur )
+ {
+ WeightBest = WeightCur;
+ RetValue = (i << 16) | k;
+ }
+ }
+ return RetValue;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+float ** Llb_ManComputeAttr( Llb_Mtr_t * p )
+{
+ float ** pCosts;
+ int i, k;
+ // alloc and clean
+ pCosts = (float **)Extra_ArrayAlloc( p->nCols, p->nCols, sizeof(float) );
+ for ( i = 0; i < p->nCols; i++ )
+ for ( k = 0; k < p->nCols; k++ )
+ pCosts[i][i] = 0.0;
+ // fill up
+ for ( i = 1; i < p->nCols-1; i++ )
+ for ( k = i+1; k < p->nCols-1; k++ )
+ pCosts[i][k] = pCosts[k][i] = Llb_ManComputeCommonAttr( p, i, k );
+ return pCosts;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Returns the number of variables that will be saved.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_MtrCombineSelectedColumns( Llb_Mtr_t * p, int iGrp1, int iGrp2 )
+{
+ int iVar;
+ assert( iGrp1 >= 1 && iGrp1 < p->nCols - 1 );
+ assert( iGrp2 >= 1 && iGrp2 < p->nCols - 1 );
+ assert( p->pColGrps[iGrp1] != NULL );
+ assert( p->pColGrps[iGrp2] != NULL );
+ for ( iVar = 0; iVar < p->nRows; iVar++ )
+ {
+ if ( p->pMatrix[iGrp1][iVar] == 1 && p->pMatrix[iGrp2][iVar] == 1 )
+ p->pRowSums[iVar]--;
+ if ( p->pMatrix[iGrp1][iVar] == 0 && p->pMatrix[iGrp2][iVar] == 1 )
+ {
+ p->pMatrix[iGrp1][iVar] = 1;
+ p->pColSums[iGrp1]++;
+ }
+ if ( p->pMatrix[iGrp2][iVar] == 1 )
+ p->pMatrix[iGrp2][iVar] = 0;
+ }
+ p->pColSums[iGrp2] = 0;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Combines one pair of columns.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_ManClusterOne( Llb_Mtr_t * p, int iCol1, int iCol2 )
+{
+ int fVerbose = 0;
+ Llb_Grp_t * pGrp;
+ int iVar;
+
+ if ( fVerbose )
+ {
+ printf( "Combining %d and %d\n", iCol1, iCol2 );
+ for ( iVar = 0; iVar < p->nRows; iVar++ )
+ {
+ if ( p->pMatrix[iCol1][iVar] == 0 && p->pMatrix[iCol2][iVar] == 0 )
+ continue;
+ printf( "%3d : %c%c\n", iVar,
+ p->pMatrix[iCol1][iVar]? '*':' ',
+ p->pMatrix[iCol2][iVar]? '*':' ' );
+ }
+ }
+ pGrp = Llb_ManGroupsCombine( p->pColGrps[iCol1], p->pColGrps[iCol2] );
+ Llb_MtrCombineSelectedColumns( p, iCol1, iCol2 );
+ p->pColGrps[iCol1] = pGrp;
+ p->pColGrps[iCol2] = NULL;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Removes empty columns.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_ManClusterCompress( Llb_Mtr_t * p )
+{
+ int i, k = 0;
+ for ( i = 0; i < p->nCols; i++ )
+ {
+ if ( p->pColGrps[i] == NULL )
+ {
+ assert( p->pColSums[i] == 0 );
+ assert( p->pMatrix[i] != NULL );
+ ABC_FREE( p->pMatrix[i] );
+ continue;
+ }
+ p->pMatrix[k] = p->pMatrix[i];
+ p->pColGrps[k] = p->pColGrps[i];
+ p->pColSums[k] = p->pColSums[i];
+ k++;
+ }
+ p->nCols = k;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Combines one pair of columns.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_ManCluster( Llb_Mtr_t * p )
+{
+ int RetValue;
+ do
+ {
+ do {
+ RetValue = Llb_ManComputeBestQuant( p );
+ if ( RetValue > 0 )
+ Llb_ManClusterOne( p, RetValue >> 16, RetValue & 0xffff );
+ }
+ while ( RetValue > 0 );
+
+ RetValue = Llb_ManComputeBestAttr( p );
+ if ( RetValue > 0 )
+ Llb_ManClusterOne( p, RetValue >> 16, RetValue & 0xffff );
+
+ Llb_MtrVerifyMatrix( p );
+ }
+ while ( RetValue > 0 );
+
+ Llb_ManClusterCompress( p );
+
+ Llb_MtrVerifyMatrix( p );
+}
+
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/llb/llbConstr.c b/src/aig/llb/llbConstr.c
new file mode 100644
index 00000000..eabae3bc
--- /dev/null
+++ b/src/aig/llb/llbConstr.c
@@ -0,0 +1,313 @@
+/**CFile****************************************************************
+
+ FileName [llbConstr.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [BDD based reachability.]
+
+ Synopsis [Computing inductive constraints.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: llbConstr.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "llbInt.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Returns the array of constraint candidates.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Llb_ManCountEntries( Vec_Int_t * vCands )
+{
+ int i, Entry, Counter = 0;
+ Vec_IntForEachEntry( vCands, Entry, i )
+ Counter += ((Entry == 0) || (Entry == 1));
+ return Counter;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the array of constraint candidates.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_ManPrintEntries( Aig_Man_t * p, Vec_Int_t * vCands )
+{
+ int i, Entry;
+ if ( vCands == NULL )
+ {
+ printf( "There is no hints.\n" );
+ return;
+ }
+ Entry = Llb_ManCountEntries(vCands);
+ printf( "\n*** Using %d hint%s:\n", Entry, (Entry != 1 ? "s":"") );
+ Vec_IntForEachEntry( vCands, Entry, i )
+ {
+ if ( Entry != 0 && Entry != 1 )
+ continue;
+ printf( "%c", Entry ? '+' : '-' );
+ printf( "%-6d : ", i );
+ Aig_ObjPrint( p, Aig_ManObj(p, i) );
+ printf( "\n" );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Dereference BDD nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_ManDerefenceBdds( Aig_Man_t * p, DdManager * dd )
+{
+ Aig_Obj_t * pObj;
+ int i;
+ Aig_ManForEachObj( p, pObj, i )
+ Cudd_RecursiveDeref( dd, (DdNode *)pObj->pData );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the array of constraint candidates.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+DdNode * Llb_ManComputeIndCase_rec( Aig_Man_t * p, Aig_Obj_t * pObj, DdManager * dd, Vec_Ptr_t * vBdds )
+{
+ DdNode * bBdd0, * bBdd1;
+ DdNode * bFunc = (DdNode *)Vec_PtrEntry( vBdds, Aig_ObjId(pObj) );
+ if ( bFunc != NULL )
+ return bFunc;
+ assert( Aig_ObjIsNode(pObj) );
+ bBdd0 = Llb_ManComputeIndCase_rec( p, Aig_ObjFanin0(pObj), dd, vBdds );
+ bBdd1 = Llb_ManComputeIndCase_rec( p, Aig_ObjFanin1(pObj), dd, vBdds );
+ bBdd0 = Cudd_NotCond( bBdd0, Aig_ObjFaninC0(pObj) );
+ bBdd1 = Cudd_NotCond( bBdd1, Aig_ObjFaninC1(pObj) );
+ bFunc = Cudd_bddAnd( dd, bBdd0, bBdd1 ); Cudd_Ref( bFunc );
+ Vec_PtrWriteEntry( vBdds, Aig_ObjId(pObj), bFunc );
+ return bFunc;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the array of constraint candidates.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_ManComputeIndCase( Aig_Man_t * p, DdManager * dd, Vec_Int_t * vNodes )
+{
+ Vec_Ptr_t * vBdds;
+ Aig_Obj_t * pObj;
+ DdNode * bFunc;
+ int i, Entry;
+ vBdds = Vec_PtrStart( Aig_ManObjNumMax(p) );
+ bFunc = Cudd_ReadOne(dd); Cudd_Ref( bFunc );
+ Vec_PtrWriteEntry( vBdds, Aig_ObjId(Aig_ManConst1(p)), bFunc );
+ Saig_ManForEachPi( p, pObj, i )
+ {
+ bFunc = Cudd_bddIthVar( dd, Aig_ManPiNum(p) + i ); Cudd_Ref( bFunc );
+ Vec_PtrWriteEntry( vBdds, Aig_ObjId(pObj), bFunc );
+ }
+ Saig_ManForEachLi( p, pObj, i )
+ {
+ bFunc = (DdNode *)pObj->pData; Cudd_Ref( bFunc );
+ Vec_PtrWriteEntry( vBdds, Aig_ObjId(Saig_ObjLiToLo(p, pObj)), bFunc );
+ }
+ Vec_IntForEachEntry( vNodes, Entry, i )
+ {
+ if ( Entry != 0 && Entry != 1 )
+ continue;
+ pObj = Aig_ManObj( p, i );
+ bFunc = Llb_ManComputeIndCase_rec( p, pObj, dd, vBdds );
+ if ( Entry == 0 )
+ {
+// Extra_bddPrint( dd, Cudd_Not(pObj->pData) ); printf( "\n" );
+// Extra_bddPrint( dd, Cudd_Not(bFunc) ); printf( "\n" );
+ if ( !Cudd_bddLeq( dd, Cudd_Not(pObj->pData), Cudd_Not(bFunc) ) )
+ Vec_IntWriteEntry( vNodes, i, -1 );
+ }
+ else if ( Entry == 1 )
+ {
+// Extra_bddPrint( dd, pObj->pData ); printf( "\n" );
+// Extra_bddPrint( dd, bFunc ); printf( "\n" );
+ if ( !Cudd_bddLeq( dd, (DdNode *)pObj->pData, bFunc ) )
+ Vec_IntWriteEntry( vNodes, i, -1 );
+ }
+ }
+ Vec_PtrForEachEntry( DdNode *, vBdds, bFunc, i )
+ if ( bFunc )
+ Cudd_RecursiveDeref( dd, bFunc );
+ Vec_PtrFree( vBdds );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the array of constraint candidates.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Llb_ManComputeBaseCase( Aig_Man_t * p, DdManager * dd )
+{
+ Vec_Int_t * vNodes;
+ Aig_Obj_t * pObj, * pRoot;
+ int i;
+ pRoot = Aig_ManPo( p, 0 );
+ vNodes = Vec_IntStartFull( Aig_ManObjNumMax(p) );
+ Aig_ManForEachObj( p, pObj, i )
+ {
+ if ( !Aig_ObjIsNode(pObj) && !Aig_ObjIsPi(pObj) )
+ continue;
+ if ( Cudd_bddLeq( dd, (DdNode *)pObj->pData, Cudd_Not(pRoot->pData) ) )
+ Vec_IntWriteEntry( vNodes, i, 1 );
+ else if ( Cudd_bddLeq( dd, Cudd_Not((DdNode *)pObj->pData), Cudd_Not(pRoot->pData) ) )
+ Vec_IntWriteEntry( vNodes, i, 0 );
+ }
+ return vNodes;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Constructs global BDDs for each object in the AIG manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+DdManager * Llb_ManConstructGlobalBdds( Aig_Man_t * p )
+{
+ DdManager * dd;
+ DdNode * bBdd0, * bBdd1;
+ Aig_Obj_t * pObj;
+ int i;
+ dd = Cudd_Init( Aig_ManPiNum(p), 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 );
+ Cudd_AutodynEnable( dd, CUDD_REORDER_SYMM_SIFT );
+ pObj = Aig_ManConst1(p);
+ pObj->pData = Cudd_ReadOne(dd); Cudd_Ref( (DdNode *)pObj->pData );
+ Aig_ManForEachPi( p, pObj, i )
+ {
+ pObj->pData = Cudd_bddIthVar(dd, i); Cudd_Ref( (DdNode *)pObj->pData );
+ }
+ Aig_ManForEachNode( p, pObj, i )
+ {
+ bBdd0 = Cudd_NotCond( (DdNode *)Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0(pObj) );
+ bBdd1 = Cudd_NotCond( (DdNode *)Aig_ObjFanin1(pObj)->pData, Aig_ObjFaninC1(pObj) );
+ pObj->pData = Cudd_bddAnd( dd, bBdd0, bBdd1 ); Cudd_Ref( (DdNode *)pObj->pData );
+ }
+ Aig_ManForEachPo( p, pObj, i )
+ {
+ pObj->pData = Cudd_NotCond( (DdNode *)Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0(pObj) ); Cudd_Ref( (DdNode *)pObj->pData );
+ }
+ return dd;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Derives inductive constraints.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Llb_ManDeriveConstraints( Aig_Man_t * p )
+{
+ DdManager * dd;
+ Vec_Int_t * vNodes;
+ if ( Saig_ManPoNum(p) != 1 )
+ {
+ printf( "The AIG has %d property outputs.\n", Saig_ManPoNum(p) );
+ return NULL;
+ }
+ assert( Saig_ManPoNum(p) == 1 );
+ dd = Llb_ManConstructGlobalBdds( p );
+ vNodes = Llb_ManComputeBaseCase( p, dd );
+ if ( Llb_ManCountEntries(vNodes) > 0 )
+ Llb_ManComputeIndCase( p, dd, vNodes );
+ if ( Llb_ManCountEntries(vNodes) == 0 )
+ Vec_IntFreeP( &vNodes );
+ Llb_ManDerefenceBdds( p, dd );
+ Extra_StopManager( dd );
+ return vNodes;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Tests derived constraints.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_ManConstrTest( Aig_Man_t * p )
+{
+ Vec_Int_t * vNodes;
+ vNodes = Llb_ManDeriveConstraints( p );
+ Llb_ManPrintEntries( p, vNodes );
+ Vec_IntFreeP( &vNodes );
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/llb/llbCore.c b/src/aig/llb/llbCore.c
new file mode 100644
index 00000000..562a9800
--- /dev/null
+++ b/src/aig/llb/llbCore.c
@@ -0,0 +1,219 @@
+/**CFile****************************************************************
+
+ FileName [llbCore.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [BDD based reachability.]
+
+ Synopsis [Top-level procedure.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: llbCore.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "llbInt.h"
+#include "gia.h"
+#include "giaAig.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_ManSetDefaultParams( Gia_ParLlb_t * p )
+{
+ memset( p, 0, sizeof(Gia_ParLlb_t) );
+ p->nBddMax = 1000000;
+ p->nIterMax = 1000;
+ p->nClusterMax = 20;
+ p->nHintDepth = 0;
+ p->HintFirst = 0;
+ p->fUseFlow = 0; // use flow
+ p->nVolumeMax = 100; // max volume
+ p->nVolumeMin = 30; // min volume
+ p->fReorder = 1;
+ p->fIndConstr = 0;
+ p->fUsePivots = 0;
+ p->fCluster = 0;
+ p->fSchedule = 0;
+ p->fVerbose = 0;
+ p->fVeryVerbose = 0;
+ p->fSilent = 0;
+ p->TimeLimit = 0;
+// p->TimeLimit = 0;
+ p->TimeLimitGlo = 0;
+ p->TimeTarget = 0;
+ p->iFrame = -1;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Prints statistics about MFFCs.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_ManPrintAig( Llb_Man_t * p )
+{
+ Abc_Print( 1, "pi =%3d ", Saig_ManPiNum(p->pAig) );
+ Abc_Print( 1, "po =%3d ", Saig_ManPoNum(p->pAig) );
+ Abc_Print( 1, "ff =%3d ", Saig_ManRegNum(p->pAig) );
+ Abc_Print( 1, "int =%5d ", Vec_IntSize(p->vVar2Obj)-Aig_ManPiNum(p->pAig)-Saig_ManRegNum(p->pAig) );
+ Abc_Print( 1, "var =%5d ", Vec_IntSize(p->vVar2Obj) );
+ Abc_Print( 1, "part =%5d ", Vec_PtrSize(p->vGroups)-2 );
+ Abc_Print( 1, "and =%5d ", Aig_ManNodeNum(p->pAig) );
+ Abc_Print( 1, "lev =%4d ", Aig_ManLevelNum(p->pAig) );
+// Abc_Print( 1, "cut =%4d ", Llb_ManCrossCut(p->pAig) );
+ Abc_Print( 1, "\n" );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Llb_ManModelCheckAig( Aig_Man_t * pAigGlo, Gia_ParLlb_t * pPars, Vec_Int_t * vHints, DdManager ** pddGlo )
+{
+ Llb_Man_t * p = NULL;
+ Aig_Man_t * pAig;
+ int RetValue = -1;
+ int clk = clock();
+
+ if ( pPars->fIndConstr )
+ {
+ assert( vHints == NULL );
+ vHints = Llb_ManDeriveConstraints( pAigGlo );
+ }
+
+ // derive AIG for hints
+ if ( vHints == NULL )
+ pAig = Aig_ManDupSimple( pAigGlo );
+ else
+ {
+ if ( pPars->fVerbose )
+ Llb_ManPrintEntries( pAigGlo, vHints );
+ pAig = Aig_ManDupSimpleWithHints( pAigGlo, vHints );
+ }
+
+
+ if ( pPars->fUseFlow )
+ {
+// p = Llb_ManStartFlow( pAigGlo, pAig, pPars );
+ }
+ else
+ {
+ p = Llb_ManStart( pAigGlo, pAig, pPars );
+ if ( pPars->fVerbose )
+ {
+ Llb_ManPrintAig( p );
+ printf( "Original matrix: " );
+ Llb_MtrPrintMatrixStats( p->pMatrix );
+ if ( pPars->fVeryVerbose )
+ Llb_MtrPrint( p->pMatrix, 1 );
+ }
+ if ( pPars->fCluster )
+ {
+ Llb_ManCluster( p->pMatrix );
+ if ( pPars->fVerbose )
+ {
+ printf( "Matrix after clustering: " );
+ Llb_MtrPrintMatrixStats( p->pMatrix );
+ if ( pPars->fVeryVerbose )
+ Llb_MtrPrint( p->pMatrix, 1 );
+ }
+ }
+ if ( pPars->fSchedule )
+ {
+ Llb_MtrSchedule( p->pMatrix );
+ if ( pPars->fVerbose )
+ {
+ printf( "Matrix after scheduling: " );
+ Llb_MtrPrintMatrixStats( p->pMatrix );
+ if ( pPars->fVeryVerbose )
+ Llb_MtrPrint( p->pMatrix, 1 );
+ }
+ }
+ }
+
+ if ( !p->pPars->fSkipReach )
+ RetValue = Llb_ManReachability( p, vHints, pddGlo );
+ Llb_ManStop( p );
+
+ Abc_PrintTime( 1, "Time", clock() - clk );
+
+ if ( pPars->fIndConstr )
+ Vec_IntFreeP( &vHints );
+ return RetValue;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Llb_ManModelCheckGia( Gia_Man_t * pGia, Gia_ParLlb_t * pPars )
+{
+ Gia_Man_t * pGia2;
+ Aig_Man_t * pAig;
+ int RetValue = -1;
+ pGia2 = Gia_ManDupDfs( pGia );
+ pAig = Gia_ManToAigSimple( pGia2 );
+ Gia_ManStop( pGia2 );
+//Aig_ManShow( pAig, 0, NULL );
+
+ if ( pPars->nHintDepth == 0 )
+ RetValue = Llb_ManModelCheckAig( pAig, pPars, NULL, NULL );
+ else
+ RetValue = Llb_ManModelCheckAigWithHints( pAig, pPars );
+ Aig_ManStop( pAig );
+ return RetValue;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/llb/llbFlow.c b/src/aig/llb/llbFlow.c
new file mode 100644
index 00000000..55405c09
--- /dev/null
+++ b/src/aig/llb/llbFlow.c
@@ -0,0 +1,639 @@
+/**CFile****************************************************************
+
+ FileName [llbFlow.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [BDD based reachability.]
+
+ Synopsis [Flow computation.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: llbFlow.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "llbInt.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+typedef struct Llb_Flw_t_ Llb_Flw_t;
+struct Llb_Flw_t_
+{
+ unsigned Source : 1; // source of the graph
+ unsigned Sink : 1; // sink of the graph
+ unsigned Flow : 1; // node has flow
+ unsigned Mark : 1; // visited node
+ unsigned Id : 14; // ID of the corresponding node
+ unsigned nFanins : 14; // number of fanins
+ Llb_Flw_t * Fanins[0]; // fanins
+};
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Llb_Flw_t * Llb_FlwAlloc( Vec_Int_t * vMem, Vec_Ptr_t * vStore, int Id, int nFanins )
+{
+ Llb_Flw_t * p;
+ int nWords = (sizeof(Llb_Flw_t) + nFanins * sizeof(void *)) / sizeof(int);
+ p = (Llb_Flw_t *)Vec_IntFetch( vMem, nWords );
+ memset( p, 1, nWords * sizeof(int) );
+ p->Id = Id;
+ p->nFanins = 0;//nFanins;
+ Vec_PtrWriteEntry( vStore, Id, p );
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_FlwAddFanin( Llb_Flw_t * pFrom, Llb_Flw_t * pTo )
+{
+ pFrom->Fanins[pFrom->nFanins++] = pTo;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_AigCreateFlw( Aig_Man_t * p, Vec_Int_t ** pvMem, Vec_Ptr_t ** pvTops, Vec_Ptr_t ** pvBots )
+{
+ Llb_Flw_t * pFlwTop, * pFlwBot;
+ Vec_Ptr_t * vTops, * vBots;
+ Vec_Int_t * vMem;
+ Aig_Obj_t * pObj;
+ int i;
+ vMem = Vec_IntAlloc( Aig_ManObjNumMax(p) * (sizeof(Llb_Flw_t) + sizeof(void *) * 8) );
+ vBots = Vec_PtrStart( Aig_ManObjNumMax(p) );
+ vTops = Vec_PtrStart( Aig_ManObjNumMax(p) );
+ Aig_ManForEachObj( p, pObj, i )
+ {
+ pFlwBot = Llb_FlwAlloc( vMem, vBots, i, Aig_ObjIsPo(pObj) + 2 * Aig_ObjIsNode(pObj) );
+ pFlwTop = Llb_FlwAlloc( vMem, vTops, i, Aig_ObjRefs(pObj) + 1 );
+ Llb_FlwAddFanin( pFlwBot, pFlwTop );
+ Llb_FlwAddFanin( pFlwTop, pFlwBot );
+ Llb_FlwAddFanin( pFlwBot, (Llb_Flw_t *)Vec_PtrEntry(vTops, Aig_ObjFaninId0(pObj)) );
+ Llb_FlwAddFanin( pFlwBot, (Llb_Flw_t *)Vec_PtrEntry(vTops, Aig_ObjFaninId1(pObj)) );
+ Llb_FlwAddFanin( (Llb_Flw_t *)Vec_PtrEntry(vTops, Aig_ObjFaninId0(pObj)), pFlwBot );
+ Llb_FlwAddFanin( (Llb_Flw_t *)Vec_PtrEntry(vTops, Aig_ObjFaninId1(pObj)), pFlwBot );
+ }
+ Aig_ManForEachObj( p, pObj, i )
+ {
+ pFlwBot = (Llb_Flw_t *)Vec_PtrEntry( vBots, i );
+ pFlwTop = (Llb_Flw_t *)Vec_PtrEntry( vTops, i );
+ assert( pFlwBot->nFanins == (unsigned)Aig_ObjIsPo(pObj) + 2 * Aig_ObjIsNode(pObj) );
+ assert( pFlwTop->nFanins == (unsigned)Aig_ObjRefs(pObj) + 1 );
+ }
+ *pvMem = vMem;
+ *pvTops = vTops;
+ *pvBots = vBots;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_AigCleanMarks( Vec_Ptr_t * vFlw )
+{
+ Llb_Flw_t * pFlw;
+ int i;
+ Vec_PtrForEachEntry( Llb_Flw_t *, vFlw, pFlw, i )
+ pFlw->Mark = 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_AigCleanFlow( Vec_Ptr_t * vFlw )
+{
+ Llb_Flw_t * pFlw;
+ int i;
+ Vec_PtrForEachEntry( Llb_Flw_t *, vFlw, pFlw, i )
+ pFlw->Flow = 0;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Llb_AigCollectCut( Vec_Ptr_t * vNodes, Vec_Ptr_t * vBots, Vec_Ptr_t * vTops )
+{
+ Vec_Int_t * vCut;
+ Llb_Flw_t * pFlwBot, * pFlwTop;
+ Aig_Obj_t * pObj;
+ int i;
+ vCut = Vec_IntAlloc( 100 );
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
+ {
+ pFlwBot = (Llb_Flw_t *)Vec_PtrEntry( vBots, i );
+ pFlwTop = (Llb_Flw_t *)Vec_PtrEntry( vTops, i );
+ if ( pFlwBot->Mark && !pFlwTop->Mark )
+ Vec_IntPush( vCut, i );
+ }
+ return vCut;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Llb_AigPushFlow_rec( Llb_Flw_t * pFlw, Llb_Flw_t * pFlwPrev, Vec_Ptr_t * vMarked, Vec_Ptr_t * vFlowed )
+{
+ int i;
+ if ( pFlw->Mark )
+ return 0;
+ pFlw->Mark = 1;
+ Vec_PtrPush( vMarked, pFlw );
+ if ( pFlw->Source )
+ return 0;
+ if ( pFlw->Sink )
+ {
+ pFlw->Flow = 1;
+ Vec_PtrPush( vFlowed, pFlw );
+ return 1;
+ }
+// assert( Aig_ObjIsNode(pObj) );
+ for ( i = 0; i < (int)pFlw->nFanins; i++ )
+ {
+ if ( pFlw->Fanins[i] == pFlwPrev )
+ continue;
+ if ( Llb_AigPushFlow_rec( pFlw->Fanins[i], pFlw, vMarked, vFlowed ) )
+ break;
+ }
+ if ( i == (int)pFlw->nFanins )
+ return 0;
+ if ( i == 0 )
+ {
+ pFlw->Flow = 1;
+ Vec_PtrPush( vFlowed, pFlw );
+ }
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Llb_AigPushFlow( Vec_Ptr_t * vFlwBots, Vec_Ptr_t * vMarked, Vec_Ptr_t * vFlowed )
+{
+ Llb_Flw_t * pFlw;
+ int i, Counter = 0;
+ Vec_PtrForEachEntry( Llb_Flw_t *, vFlwBots, pFlw, i )
+ {
+ pFlw->Mark = 1;
+ if ( Llb_AigPushFlow_rec( pFlw->Fanins[0], pFlw, vMarked, vFlowed ) )
+ {
+ Counter++;
+ pFlw->Flow = 1;
+ Vec_PtrPush( vFlowed, pFlw );
+ }
+ }
+ return Counter;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Llb_AigFindMinCut( Vec_Ptr_t * vNodes, Vec_Ptr_t * vFlwBots, Vec_Ptr_t * vFlwTop, Vec_Ptr_t * vFlwBots2, Vec_Ptr_t * vFlwTop2 )
+{
+ Vec_Int_t * vCut;
+ Vec_Ptr_t * vMarked, * vFlowed;
+ int Value;
+ vMarked = Vec_PtrAlloc( 100 );
+ vFlowed = Vec_PtrAlloc( 100 );
+ Value = Llb_AigPushFlow( vFlwBots2, vMarked, vFlowed );
+ Llb_AigCleanMarks( vMarked );
+ Value = Llb_AigPushFlow( vFlwBots2, vMarked, vFlowed );
+ assert( Value == 0 );
+ vCut = Llb_AigCollectCut( vNodes, vFlwBots, vFlwTop );
+ Llb_AigCleanMarks( vMarked );
+ Llb_AigCleanFlow( vFlowed );
+ return vCut;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Ptr_t * Llb_AigCollectFlowTerminals( Aig_Man_t * p, Vec_Ptr_t * vFlws, Vec_Int_t * vCut )
+{
+ Vec_Ptr_t * pFlwRes;
+ Aig_Obj_t * pObj;
+ int i;
+ pFlwRes = Vec_PtrAlloc( Vec_IntSize(vCut) );
+ Aig_ManForEachNodeVec( p, vCut, pObj, i )
+ Vec_PtrPush( pFlwRes, Vec_PtrEntry( vFlws, Aig_ObjId(pObj) ) );
+ return pFlwRes;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_AigMarkFlowTerminals( Vec_Ptr_t * vFlws, int fSource, int fSink )
+{
+ Llb_Flw_t * pFlw;
+ int i;
+ Vec_PtrForEachEntry( Llb_Flw_t *, vFlws, pFlw, i )
+ {
+ pFlw->Source = fSource;
+ pFlw->Sink = fSink;
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Collects internal nodes in the DFS order.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_ManCollectNodes_rec( Aig_Man_t * p, Aig_Obj_t * pObj, Vec_Ptr_t * vNodes )
+{
+ if ( Aig_ObjIsTravIdCurrent(p, pObj) )
+ return;
+ Aig_ObjSetTravIdCurrent(p, pObj);
+ assert( Aig_ObjIsNode(pObj) );
+ Llb_ManCollectNodes_rec( p, Aig_ObjFanin0(pObj), vNodes );
+ Llb_ManCollectNodes_rec( p, Aig_ObjFanin1(pObj), vNodes );
+ Vec_PtrPush( vNodes, pObj );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Ptr_t * Llb_ManCollectNodes( Aig_Man_t * p, Vec_Int_t * vCut1, Vec_Int_t * vCut2 )
+{
+ Vec_Ptr_t * vNodes;
+ Aig_Obj_t * pObj;
+ int i;
+ Aig_ManIncrementTravId( p );
+ Aig_ManForEachNodeVec( p, vCut1, pObj, i )
+ Aig_ObjSetTravIdCurrent( p, pObj );
+ vNodes = Vec_PtrAlloc( Aig_ManObjNumMax(p) );
+ Aig_ManForEachNodeVec( p, vCut2, pObj, i )
+ Llb_ManCollectNodes_rec( p, pObj, vNodes );
+ return vNodes;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Collects internal nodes in the DFS order.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Llb_ManCountNodes_rec( Aig_Man_t * p, Aig_Obj_t * pObj )
+{
+ if ( Aig_ObjIsTravIdCurrent(p, pObj) )
+ return 0;
+ Aig_ObjSetTravIdCurrent(p, pObj);
+ assert( Aig_ObjIsNode(pObj) );
+ return 1 + Llb_ManCountNodes_rec( p, Aig_ObjFanin0(pObj) ) +
+ Llb_ManCountNodes_rec( p, Aig_ObjFanin1(pObj) );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Llb_ManCountNodes( Aig_Man_t * p, Vec_Int_t * vCut1, Vec_Int_t * vCut2 )
+{
+ Aig_Obj_t * pObj;
+ int i, Counter = 0;
+ Aig_ManIncrementTravId( p );
+ Aig_ManForEachNodeVec( p, vCut1, pObj, i )
+ Aig_ObjSetTravIdCurrent( p, pObj );
+ Aig_ManForEachNodeVec( p, vCut2, pObj, i )
+ Counter += Llb_ManCountNodes_rec( p, pObj );
+ return Counter;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes starting cuts.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Llb_ManComputeCioCut( Aig_Man_t * pAig, int fCollectCos )
+{
+ Vec_Int_t * vCut;
+ Aig_Obj_t * pObj;
+ int i;
+ vCut = Vec_IntAlloc( 500 );
+ if ( fCollectCos )
+ Aig_ManForEachPo( pAig, pObj, i )
+ Vec_IntPush( vCut, Aig_ObjId(pObj) );
+ else
+ Aig_ManForEachPi( pAig, pObj, i )
+ Vec_IntPush( vCut, Aig_ObjId(pObj) );
+ return vCut;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Inserts the new cut into the array.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_ManCutInsert( Aig_Man_t * p, Vec_Ptr_t * vCuts, Vec_Int_t * vVols, int iEntry, Vec_Int_t * vCutNew )
+{
+ Vec_Int_t * vCut1, * vCut2;
+ int Vol1, Vol2;
+ Vec_PtrInsert( vCuts, iEntry, vCutNew );
+ Vec_IntInsert( vVols, iEntry, -1 );
+ vCut1 = (Vec_Int_t *)Vec_PtrEntry( vCuts, iEntry );
+ vCut2 = (Vec_Int_t *)Vec_PtrEntry( vCuts, iEntry+1 );
+ Vol1 = Llb_ManCountNodes( p, vCut1, vCutNew );
+ Vol2 = Llb_ManCountNodes( p, vCutNew, vCut2 );
+ Vec_IntWriteEntry( vVols, iEntry-1, Vol1 );
+ Vec_IntWriteEntry( vVols, iEntry, Vol2 );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the set of cuts resulting from the flow computation.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Ptr_t * Llb_ManComputePartitioning( Aig_Man_t * p, int nVolumeMin, int nVolumeMax )
+{
+ Vec_Ptr_t * vCuts, * vFlwTops, * vFlwBots;
+ Vec_Int_t * vVols, * vCut1, * vCut2, * vCut, * vMem;
+ int nMaxValue, iEntry;
+ vCuts = Vec_PtrAlloc( 1000 );
+ vVols = Vec_IntAlloc( 1000 );
+ // prepare flow computation
+ Llb_AigCreateFlw( p, &vMem, &vFlwTops, &vFlwBots );
+ // start with regular cuts
+ Vec_PtrPush( vCuts, Llb_ManComputeCioCut(p, 0) );
+ Vec_PtrPush( vCuts, Llb_ManComputeCioCut(p, 1) );
+ Vec_IntPush( vVols, Aig_ManNodeNum(p) );
+ // split cuts with the largest volume
+ while ( (nMaxValue = Vec_IntFindMax(vVols)) > nVolumeMax )
+ {
+ Vec_Ptr_t * vNodes, * vFlwBots2, * vFlwTops2;
+ iEntry = Vec_IntFind( vVols, nMaxValue ); assert( iEntry >= 0 );
+ vCut1 = (Vec_Int_t *)Vec_PtrEntry( vCuts, iEntry );
+ vCut2 = (Vec_Int_t *)Vec_PtrEntry( vCuts, iEntry+1 );
+ // collect nodes
+ vNodes = Llb_ManCollectNodes( p, vCut1, vCut1 );
+ assert( Vec_PtrSize(vNodes) == nMaxValue );
+ assert( Llb_ManCountNodes(p, vCut1, vCut2) == nMaxValue );
+ // collect sources and sinks
+ vFlwBots2 = Llb_AigCollectFlowTerminals( p, vFlwBots, vCut1 );
+ vFlwTops2 = Llb_AigCollectFlowTerminals( p, vFlwTops, vCut2 );
+ // mark sources and sinks
+ Llb_AigMarkFlowTerminals( vFlwBots2, 1, 0 );
+ Llb_AigMarkFlowTerminals( vFlwTops2, 0, 1 );
+ vCut = Llb_AigFindMinCut( vNodes, vFlwBots, vFlwTops, vFlwBots2, vFlwTops2 );
+ Llb_AigMarkFlowTerminals( vFlwBots2, 0, 0 );
+ Llb_AigMarkFlowTerminals( vFlwTops2, 0, 0 );
+ // insert new cut
+ Llb_ManCutInsert( p, vCuts, vVols, iEntry+1, vCut );
+ // deallocate
+ Vec_PtrFree( vNodes );
+ Vec_PtrFree( vFlwBots2 );
+ Vec_PtrFree( vFlwTops2 );
+ }
+ Vec_IntFree( vMem );
+ Vec_PtrFree( vFlwTops );
+ Vec_PtrFree( vFlwBots );
+ return vCuts;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Llb_ManMarkPivotNodesFlow( Aig_Man_t * p, Vec_Ptr_t * vCuts )
+{
+ Vec_Int_t * vVar2Obj, * vCut;
+ Aig_Obj_t * pObj;
+ int i, k;
+ // mark inputs/outputs
+ Aig_ManForEachPi( p, pObj, i )
+ pObj->fMarkA = 1;
+ Saig_ManForEachLi( p, pObj, i )
+ pObj->fMarkA = 1;
+
+ // mark internal pivot nodes
+ Vec_PtrForEachEntry( Vec_Int_t *, vCuts, vCut, i )
+ Aig_ManForEachNodeVec( p, vCut, pObj, k )
+ pObj->fMarkA = 1;
+
+ // assign variable numbers
+ Aig_ManConst1(p)->fMarkA = 0;
+ vVar2Obj = Vec_IntAlloc( 100 );
+ Aig_ManForEachPi( p, pObj, i )
+ Vec_IntPush( vVar2Obj, Aig_ObjId(pObj) );
+ Aig_ManForEachNode( p, pObj, i )
+ if ( pObj->fMarkA )
+ Vec_IntPush( vVar2Obj, Aig_ObjId(pObj) );
+ Saig_ManForEachLi( p, pObj, i )
+ Vec_IntPush( vVar2Obj, Aig_ObjId(pObj) );
+ return vVar2Obj;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the set of cuts resulting from the flow computation.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_ManPartitionUsingFlow( Llb_Man_t * p, Vec_Ptr_t * vCuts )
+{
+ Vec_Int_t * vCut1, * vCut2;
+ int i;
+ vCut1 = (Vec_Int_t *)Vec_PtrEntry( vCuts, 0 );
+ Vec_PtrForEachEntryStart( Vec_Int_t *, vCuts, vCut1, i, 1 )
+ {
+ vCut2 = (Vec_Int_t *)Vec_PtrEntry( vCuts, i );
+ Llb_ManGroupCreateFromCuts( p, vCut1, vCut2 );
+ vCut1 = vCut2;
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Llb_Man_t * Llb_ManStartFlow( Aig_Man_t * pAigGlo, Aig_Man_t * pAig, Gia_ParLlb_t * pPars )
+{
+ Vec_Ptr_t * vCuts;
+ Llb_Man_t * p;
+ vCuts = Llb_ManComputePartitioning( pAig, pPars->nVolumeMin, pPars->nVolumeMax );
+ Aig_ManCleanMarkA( pAig );
+ p = ABC_CALLOC( Llb_Man_t, 1 );
+ p->pAigGlo = pAigGlo;
+ p->pPars = pPars;
+ p->pAig = pAig;
+ p->vVar2Obj = Llb_ManMarkPivotNodesFlow( p->pAig, vCuts );
+ p->vObj2Var = Vec_IntInvert( p->vVar2Obj, -1 );
+ Llb_ManPrepareVarMap( p );
+ Aig_ManCleanMarkA( pAig );
+ Llb_ManPartitionUsingFlow( p, vCuts );
+ Vec_VecFreeP( (Vec_Vec_t **)&vCuts );
+ return p;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/llb/llbHint.c b/src/aig/llb/llbHint.c
new file mode 100644
index 00000000..acc674c8
--- /dev/null
+++ b/src/aig/llb/llbHint.c
@@ -0,0 +1,226 @@
+/**CFile****************************************************************
+
+ FileName [llbHint.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [BDD based reachability.]
+
+ Synopsis [Cofactors the circuit w.r.t. the high-fanout variables.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: llbHint.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "llbInt.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Returns CI index with the largest number of fanouts.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Llb_ManMaxFanoutCi( Aig_Man_t * pAig )
+{
+ Aig_Obj_t * pObj;
+ int i, WeightMax = -ABC_INFINITY, iInput = -1;
+ Aig_ManForEachPi( pAig, pObj, i )
+ if ( WeightMax < Aig_ObjRefs(pObj) )
+ {
+ WeightMax = Aig_ObjRefs(pObj);
+ iInput = i;
+ }
+ assert( iInput >= 0 );
+ return iInput;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Derives AIG whose PI is substituted by a constant.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Man_t * Llb_ManPerformHints( Aig_Man_t * pAig, int nHintDepth )
+{
+ Aig_Man_t * pNew, * pTemp;
+ int i, iInput;
+ pNew = Aig_ManDupDfs( pAig );
+ for ( i = 0; i < nHintDepth; i++ )
+ {
+ iInput = Llb_ManMaxFanoutCi( pNew );
+ Abc_Print( 1, "%d %3d\n", i, iInput );
+ pNew = Aig_ManDupCof( pTemp = pNew, iInput, 1 );
+ Aig_ManStop( pTemp );
+ }
+ return pNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns CI index with the largest number of fanouts.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Llb_ManCollectHighFanoutObjects( Aig_Man_t * pAig, int nCandMax, int fCisOnly )
+{
+ Vec_Int_t * vFanouts, * vResult;
+ Aig_Obj_t * pObj;
+ int i, fChanges, PivotValue;
+// int Entry;
+ // collect fanout counts
+ vFanouts = Vec_IntAlloc( 100 );
+ Aig_ManForEachObj( pAig, pObj, i )
+ {
+// if ( !Aig_ObjIsPi(pObj) && (fCisOnly || !Aig_ObjIsNode(pObj)) )
+ if ( !Saig_ObjIsLo(pAig,pObj) && (fCisOnly || !Aig_ObjIsNode(pObj)) )
+ continue;
+ Vec_IntPush( vFanouts, Aig_ObjRefs(pObj) );
+ }
+ Vec_IntSort( vFanouts, 1 );
+ // pick the separator
+ nCandMax = ABC_MIN( nCandMax, Vec_IntSize(vFanouts) - 1 );
+ PivotValue = Vec_IntEntry( vFanouts, nCandMax );
+ Vec_IntFree( vFanouts );
+ // collect obj satisfying the constraints
+ vResult = Vec_IntAlloc( 100 );
+ Aig_ManForEachObj( pAig, pObj, i )
+ {
+// if ( !Aig_ObjIsPi(pObj) && (fCisOnly || !Aig_ObjIsNode(pObj)) )
+ if ( !Saig_ObjIsLo(pAig,pObj) && (fCisOnly || !Aig_ObjIsNode(pObj)) )
+ continue;
+ if ( Aig_ObjRefs(pObj) < PivotValue )
+ continue;
+ Vec_IntPush( vResult, Aig_ObjId(pObj) );
+ }
+ assert( Vec_IntSize(vResult) >= nCandMax );
+ // order in the decreasing order of fanouts
+ do
+ {
+ fChanges = 0;
+ for ( i = 0; i < Vec_IntSize(vResult) - 1; i++ )
+ if ( Aig_ObjRefs(Aig_ManObj(pAig, Vec_IntEntry(vResult, i))) <
+ Aig_ObjRefs(Aig_ManObj(pAig, Vec_IntEntry(vResult, i+1))) )
+ {
+ int Temp = Vec_IntEntry( vResult, i );
+ Vec_IntWriteEntry( vResult, i, Vec_IntEntry(vResult, i+1) );
+ Vec_IntWriteEntry( vResult, i+1, Temp );
+ fChanges = 1;
+ }
+ }
+ while ( fChanges );
+/*
+ Vec_IntForEachEntry( vResult, Entry, i )
+ printf( "%d ", Aig_ObjRefs(Aig_ManObj(pAig, Entry)) );
+printf( "\n" );
+*/
+ return vResult;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Derives AIG whose PI is substituted by a constant.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Llb_ManModelCheckAigWithHints( Aig_Man_t * pAigGlo, Gia_ParLlb_t * pPars )
+{
+ DdManager * ddGlo = NULL;
+ Vec_Int_t * vHints;
+ Vec_Int_t * vHFCands;
+ int i, Entry, RetValue = -1;
+ int clk = clock();
+ assert( pPars->nHintDepth > 0 );
+/*
+ // perform reachability without hints
+ RetValue = Llb_ManModelCheckAig( pAigGlo, pPars, NULL, NULL );
+ if ( RetValue >= 0 )
+ return RetValue;
+*/
+ // create hints representation
+ vHFCands = Llb_ManCollectHighFanoutObjects( pAigGlo, pPars->nHintDepth+pPars->HintFirst, 1 );
+ vHints = Vec_IntStartFull( Aig_ManObjNumMax(pAigGlo) );
+ // add one hint at a time till the problem is solved
+ Vec_IntForEachEntryStart( vHFCands, Entry, i, pPars->HintFirst )
+ {
+ Vec_IntWriteEntry( vHints, Entry, 1 ); // change to 1 to start from zero cof!!!
+ // solve under hints
+ RetValue = Llb_ManModelCheckAig( pAigGlo, pPars, vHints, &ddGlo );
+ if ( RetValue == 0 )
+ goto Finish;
+ if ( RetValue == 1 )
+ break;
+ }
+ if ( RetValue == -1 )
+ goto Finish;
+ // undo the hints one at a time
+ for ( ; i >= pPars->HintFirst; i-- )
+ {
+ Entry = Vec_IntEntry( vHFCands, i );
+ Vec_IntWriteEntry( vHints, Entry, -1 );
+ // solve under relaxed hints
+ RetValue = Llb_ManModelCheckAig( pAigGlo, pPars, vHints, &ddGlo );
+ if ( RetValue == 0 )
+ goto Finish;
+ if ( RetValue == 1 )
+ continue;
+ break;
+ }
+Finish:
+ if ( ddGlo )
+ {
+ if ( ddGlo->bReached )
+ Cudd_RecursiveDeref( ddGlo, ddGlo->bReached );
+ Extra_StopManager( ddGlo );
+ }
+ Vec_IntFreeP( &vHFCands );
+ Vec_IntFreeP( &vHints );
+ if ( pPars->fVerbose )
+ Abc_PrintTime( 1, "Total runtime", clock() - clk );
+ return RetValue;
+}
+
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/llb/llbInt.h b/src/aig/llb/llbInt.h
new file mode 100644
index 00000000..dc448954
--- /dev/null
+++ b/src/aig/llb/llbInt.h
@@ -0,0 +1,162 @@
+/**CFile****************************************************************
+
+ FileName [llbInt.h]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [BDD-based reachability.]
+
+ Synopsis [External declarations.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - May 8, 2010.]
+
+ Revision [$Id: llbInt.h,v 1.00 2010/05/08 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#ifndef __LLB_INT_H__
+#define __LLB_INT_H__
+
+
+////////////////////////////////////////////////////////////////////////
+/// INCLUDES ///
+////////////////////////////////////////////////////////////////////////
+
+#include <stdio.h>
+#include "aig.h"
+#include "saig.h"
+#include "cuddInt.h"
+#include "extra.h"
+#include "llb.h"
+
+////////////////////////////////////////////////////////////////////////
+/// PARAMETERS ///
+////////////////////////////////////////////////////////////////////////
+
+
+
+ABC_NAMESPACE_HEADER_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// BASIC TYPES ///
+////////////////////////////////////////////////////////////////////////
+
+typedef struct Llb_Man_t_ Llb_Man_t;
+typedef struct Llb_Mtr_t_ Llb_Mtr_t;
+typedef struct Llb_Grp_t_ Llb_Grp_t;
+
+struct Llb_Man_t_
+{
+ Gia_ParLlb_t * pPars; // parameters
+ Aig_Man_t * pAigGlo; // initial AIG manager (owned by the caller)
+ Aig_Man_t * pAig; // derived AIG manager (created in this package)
+ DdManager * dd; // BDD manager
+ DdManager * ddG; // BDD manager
+ Vec_Int_t * vObj2Var; // mapping AIG ObjId into BDD var index
+ Vec_Int_t * vVar2Obj; // mapping BDD var index into AIG ObjId
+ Vec_Ptr_t * vGroups; // group Id into group pointer
+ Llb_Mtr_t * pMatrix; // dependency matrix
+ // image computation
+ Vec_Int_t * vVarBegs; // the first group where the var appears
+ Vec_Int_t * vVarEnds; // the last group where the var appears
+ // variable mapping
+ Vec_Int_t * vNs2Glo; // next state variables into global variables
+ Vec_Int_t * vGlo2Cs; // global variables into current state variables
+ // flow computation
+// Vec_Int_t * vMem;
+// Vec_Ptr_t * vTops;
+// Vec_Ptr_t * vBots;
+// Vec_Ptr_t * vCuts;
+};
+
+struct Llb_Mtr_t_
+{
+ int nPis; // number of primary inputs
+ int nFfs; // number of flip-flops
+ int nRows; // number of rows
+ int nCols; // number of columns
+ int * pColSums; // sum of values in a column
+ Llb_Grp_t ** pColGrps; // group structure for each col
+ int * pRowSums; // sum of values in a row
+ char ** pMatrix; // dependency matrix
+ Llb_Man_t * pMan; // manager
+ // partial product
+ char * pProdVars; // variables in the partial product
+ int * pProdNums; // var counts in the remaining partitions
+};
+
+struct Llb_Grp_t_
+{
+ int Id; // group ID
+ Vec_Ptr_t * vIns; // input AIG objs
+ Vec_Ptr_t * vOuts; // output AIG objs
+ Vec_Ptr_t * vNodes; // internal AIG objs
+ Llb_Man_t * pMan; // manager
+ Llb_Grp_t * pPrev; // previous group
+ Llb_Grp_t * pNext; // next group
+};
+
+////////////////////////////////////////////////////////////////////////
+/// MACRO DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/*=== llbCex.c =======================================================*/
+extern Abc_Cex_t * Llb_ManDeriveCex( Llb_Man_t * p, DdNode * bInter, int iOutFail, int iIter );
+/*=== llbConstr.c ======================================================*/
+extern Vec_Int_t * Llb_ManDeriveConstraints( Aig_Man_t * p );
+extern void Llb_ManPrintEntries( Aig_Man_t * p, Vec_Int_t * vCands );
+/*=== llbCore.c ======================================================*/
+extern int Llb_ManModelCheckAig( Aig_Man_t * pAigGlo, Gia_ParLlb_t * pPars, Vec_Int_t * vHints, DdManager ** pddGlo );
+/*=== llbCluster.c ======================================================*/
+extern void Llb_ManCluster( Llb_Mtr_t * p );
+/*=== llbFlow.c ======================================================*/
+extern Llb_Man_t * Llb_ManStartFlow( Aig_Man_t * pAigGlo, Aig_Man_t * pAig, Gia_ParLlb_t * pPars );
+/*=== llbHint.c ======================================================*/
+extern int Llb_ManReachabilityWithHints( Llb_Man_t * p );
+extern int Llb_ManModelCheckAigWithHints( Aig_Man_t * pAigGlo, Gia_ParLlb_t * pPars );
+/*=== llbMan.c =======================================================*/
+extern void Llb_ManPrepareVarMap( Llb_Man_t * p );
+extern Llb_Man_t * Llb_ManStart( Aig_Man_t * pAigGlo, Aig_Man_t * pAig, Gia_ParLlb_t * pPars );
+extern void Llb_ManStop( Llb_Man_t * p );
+/*=== llbMatrix.c ====================================================*/
+extern void Llb_MtrVerifyMatrix( Llb_Mtr_t * p );
+extern Llb_Mtr_t * Llb_MtrCreate( Llb_Man_t * p );
+extern void Llb_MtrFree( Llb_Mtr_t * p );
+extern void Llb_MtrPrint( Llb_Mtr_t * p, int fOrder );
+extern void Llb_MtrPrintMatrixStats( Llb_Mtr_t * p );
+/*=== llbPart.c ======================================================*/
+extern Llb_Grp_t * Llb_ManGroupAlloc( Llb_Man_t * pMan );
+extern void Llb_ManGroupStop( Llb_Grp_t * p );
+extern void Llb_ManPrepareGroups( Llb_Man_t * pMan );
+extern Llb_Grp_t * Llb_ManGroupsCombine( Llb_Grp_t * p1, Llb_Grp_t * p2 );
+extern Llb_Grp_t * Llb_ManGroupCreateFromCuts( Llb_Man_t * pMan, Vec_Int_t * vCut1, Vec_Int_t * vCut2 );
+extern void Llb_ManPrepareVarLimits( Llb_Man_t * p );
+/*=== llbPivot.c =====================================================*/
+extern int Llb_ManTracePaths( Aig_Man_t * p, Aig_Obj_t * pPivot );
+extern Vec_Int_t * Llb_ManMarkPivotNodes( Aig_Man_t * p, int fUseInternal );
+/*=== llbReach.c =====================================================*/
+extern int Llb_ManReachability( Llb_Man_t * p, Vec_Int_t * vHints, DdManager ** pddGlo );
+/*=== llbSched.c =====================================================*/
+extern void Llb_MtrSchedule( Llb_Mtr_t * p );
+
+
+
+ABC_NAMESPACE_HEADER_END
+
+
+
+#endif
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
diff --git a/src/aig/llb/llbMan.c b/src/aig/llb/llbMan.c
new file mode 100644
index 00000000..cd6fd3ff
--- /dev/null
+++ b/src/aig/llb/llbMan.c
@@ -0,0 +1,189 @@
+/**CFile****************************************************************
+
+ FileName [llbMan.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [BDD based reachability.]
+
+ Synopsis [Reachability manager.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: llbMan.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "llbInt.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_ManPrepareVarMap( Llb_Man_t * p )
+{
+ Aig_Obj_t * pObjLi, * pObjLo;
+ int i, iVarLi, iVarLo;
+ assert( p->vNs2Glo == NULL );
+ assert( p->vGlo2Cs == NULL );
+ p->vNs2Glo = Vec_IntStartFull( Vec_IntSize(p->vVar2Obj) );
+ p->vGlo2Cs = Vec_IntStartFull( Aig_ManRegNum(p->pAig) );
+ Saig_ManForEachLiLo( p->pAig, pObjLi, pObjLo, i )
+ {
+ iVarLi = Vec_IntEntry(p->vObj2Var, Aig_ObjId(pObjLi));
+ iVarLo = Vec_IntEntry(p->vObj2Var, Aig_ObjId(pObjLo));
+ assert( iVarLi >= 0 && iVarLi < Vec_IntSize(p->vVar2Obj) );
+ assert( iVarLo >= 0 && iVarLo < Vec_IntSize(p->vVar2Obj) );
+ Vec_IntWriteEntry( p->vNs2Glo, iVarLi, i );
+ Vec_IntWriteEntry( p->vGlo2Cs, i, iVarLo );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_ManPrepareVarLimits( Llb_Man_t * p )
+{
+ Llb_Grp_t * pGroup;
+ Aig_Obj_t * pVar;
+ int i, k;
+ assert( p->vVarBegs == NULL );
+ assert( p->vVarEnds == NULL );
+ p->vVarEnds = Vec_IntStart( Aig_ManObjNumMax(p->pAig) );
+ p->vVarBegs = Vec_IntStart( Aig_ManObjNumMax(p->pAig) );
+ Vec_IntFill( p->vVarBegs, Aig_ManObjNumMax(p->pAig), p->pMatrix->nCols );
+
+ for ( i = 0; i < p->pMatrix->nCols; i++ )
+ {
+ pGroup = p->pMatrix->pColGrps[i];
+
+ Vec_PtrForEachEntry( Aig_Obj_t *, pGroup->vIns, pVar, k )
+ if ( Vec_IntEntry(p->vVarBegs, pVar->Id) > i )
+ Vec_IntWriteEntry( p->vVarBegs, pVar->Id, i );
+ Vec_PtrForEachEntry( Aig_Obj_t *, pGroup->vOuts, pVar, k )
+ if ( Vec_IntEntry(p->vVarBegs, pVar->Id) > i )
+ Vec_IntWriteEntry( p->vVarBegs, pVar->Id, i );
+
+ Vec_PtrForEachEntry( Aig_Obj_t *, pGroup->vIns, pVar, k )
+ if ( Vec_IntEntry(p->vVarEnds, pVar->Id) < i )
+ Vec_IntWriteEntry( p->vVarEnds, pVar->Id, i );
+ Vec_PtrForEachEntry( Aig_Obj_t *, pGroup->vOuts, pVar, k )
+ if ( Vec_IntEntry(p->vVarEnds, pVar->Id) < i )
+ Vec_IntWriteEntry( p->vVarEnds, pVar->Id, i );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_ManStop( Llb_Man_t * p )
+{
+ Llb_Grp_t * pGrp;
+ int i;
+
+// Vec_IntFreeP( &p->vMem );
+// Vec_PtrFreeP( &p->vTops );
+// Vec_PtrFreeP( &p->vBots );
+// Vec_VecFreeP( (Vec_Vec_t **)&p->vCuts );
+
+ if ( p->pMatrix )
+ Llb_MtrFree( p->pMatrix );
+ Vec_PtrForEachEntry( Llb_Grp_t *, p->vGroups, pGrp, i )
+ Llb_ManGroupStop( pGrp );
+ Vec_PtrFreeP( &p->vGroups );
+ Vec_IntFreeP( &p->vVar2Obj );
+ Vec_IntFreeP( &p->vObj2Var );
+ Vec_IntFreeP( &p->vVarBegs );
+ Vec_IntFreeP( &p->vVarEnds );
+ Vec_IntFreeP( &p->vNs2Glo );
+ Vec_IntFreeP( &p->vGlo2Cs );
+// Vec_IntFreeP( &p->vHints );
+ if ( p->dd )
+ {
+ Extra_StopManager( p->dd );
+ }
+ if ( p->ddG )
+ {
+ if ( p->ddG->bReached )
+ Cudd_RecursiveDeref( p->ddG, p->ddG->bReached );
+ Extra_StopManager( p->ddG );
+ }
+ Aig_ManStop( p->pAig );
+ ABC_FREE( p );
+}
+
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Llb_Man_t * Llb_ManStart( Aig_Man_t * pAigGlo, Aig_Man_t * pAig, Gia_ParLlb_t * pPars )
+{
+ Llb_Man_t * p;
+ Aig_ManCleanMarkA( pAig );
+ p = ABC_CALLOC( Llb_Man_t, 1 );
+ p->pAigGlo = pAigGlo;
+ p->pPars = pPars;
+ p->pAig = pAig;
+ p->vVar2Obj = Llb_ManMarkPivotNodes( p->pAig, pPars->fUsePivots );
+ p->vObj2Var = Vec_IntInvert( p->vVar2Obj, -1 );
+ Llb_ManPrepareVarMap( p );
+ Llb_ManPrepareGroups( p );
+ Aig_ManCleanMarkA( pAig );
+ p->pMatrix = Llb_MtrCreate( p );
+ p->pMatrix->pMan = p;
+ return p;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/llb/llbMatrix.c b/src/aig/llb/llbMatrix.c
new file mode 100644
index 00000000..484ee690
--- /dev/null
+++ b/src/aig/llb/llbMatrix.c
@@ -0,0 +1,430 @@
+/**CFile****************************************************************
+
+ FileName [llbMatrix.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [BDD based reachability.]
+
+ Synopsis [Partition clustering as a matrix problem.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: llbMatrix.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "llbInt.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+// 0123 nCols
+// +--------------------->
+// pi 0 | 111 row0 pRowSums[0]
+// pi 1 | 1 11 row1 pRowSums[1]
+// pi 2 | 1 11 row2 pRowSums[2]
+// CS |1 1
+// CS |1 111
+// CS |111 111
+// int | 11111
+// int | 111
+// int | 111
+// int | 111
+// NS | 11 11
+// NS | 11 1
+// NS | 111
+// nRows |
+// v
+// cccc pColSums[0]
+// oooo pColSums[1]
+// llll pColSums[2]
+// 0123 pColSums[3]
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Verify columns.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_MtrVerifyRowsAll( Llb_Mtr_t * p )
+{
+ int iRow, iCol, Counter;
+ for ( iCol = 0; iCol < p->nCols; iCol++ )
+ {
+ Counter = 0;
+ for ( iRow = 0; iRow < p->nRows; iRow++ )
+ if ( p->pMatrix[iCol][iRow] == 1 )
+ Counter++;
+ assert( Counter == p->pColSums[iCol] );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Verify columns.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_MtrVerifyColumnsAll( Llb_Mtr_t * p )
+{
+ int iRow, iCol, Counter;
+ for ( iRow = 0; iRow < p->nRows; iRow++ )
+ {
+ Counter = 0;
+ for ( iCol = 0; iCol < p->nCols; iCol++ )
+ if ( p->pMatrix[iCol][iRow] == 1 )
+ Counter++;
+ assert( Counter == p->pRowSums[iRow] );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Verify columns.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_MtrVerifyMatrix( Llb_Mtr_t * p )
+{
+ Llb_MtrVerifyRowsAll( p );
+ Llb_MtrVerifyColumnsAll( p );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Sort variables in the order of removal.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int * Llb_MtrFindVarOrder( Llb_Mtr_t * p )
+{
+ int * pOrder, * pLast;
+ int i, k, fChanges, Temp;
+ pOrder = ABC_CALLOC( int, p->nRows );
+ pLast = ABC_CALLOC( int, p->nRows );
+ for ( i = 0; i < p->nRows; i++ )
+ {
+ pOrder[i] = i;
+ for ( k = p->nCols - 1; k >= 0; k-- )
+ if ( p->pMatrix[k][i] )
+ {
+ pLast[i] = k;
+ break;
+ }
+ }
+ do
+ {
+ fChanges = 0;
+ for ( i = 0; i < p->nRows - 1; i++ )
+ if ( pLast[i] > pLast[i+1] )
+ {
+ Temp = pOrder[i];
+ pOrder[i] = pOrder[i+1];
+ pOrder[i+1] = Temp;
+
+ Temp = pLast[i];
+ pLast[i] = pLast[i+1];
+ pLast[i+1] = Temp;
+
+ fChanges = 1;
+ }
+ }
+ while ( fChanges );
+ ABC_FREE( pLast );
+ return pOrder;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns type of a variable.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+char * Llb_MtrVarName( Llb_Mtr_t * p, int iVar )
+{
+ static char Buffer[10];
+ if ( iVar < p->nPis )
+ strcpy( Buffer, "pi" );
+ else if ( iVar < p->nPis + p->nFfs )
+ strcpy( Buffer, "CS" );
+ else if ( iVar >= p->nRows - p->nFfs )
+ strcpy( Buffer, "NS" );
+ else
+ strcpy( Buffer, "int" );
+ return Buffer;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates one column with vars in the array.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_MtrPrint( Llb_Mtr_t * p, int fOrder )
+{
+ int * pOrder = NULL;
+ int i, iRow, iCol;
+ if ( fOrder )
+ pOrder = Llb_MtrFindVarOrder( p );
+ for ( i = 0; i < p->nRows; i++ )
+ {
+ iRow = pOrder ? pOrder[i] : i;
+ printf( "%3d : ", iRow );
+ printf( "%3d ", p->pRowSums[iRow] );
+ printf( "%3s ", Llb_MtrVarName(p, iRow) );
+ for ( iCol = 0; iCol < p->nCols; iCol++ )
+ printf( "%c", p->pMatrix[iCol][iRow] ? '*' : ' ' );
+ printf( "\n" );
+ }
+ ABC_FREE( pOrder );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Verify columns.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_MtrPrintMatrixStats( Llb_Mtr_t * p )
+{
+ int iVar, iGrp, iGrp1, iGrp2, Span = 0, nCutSize = 0, nCutSizeMax = 0;
+ int * pGrp1 = ABC_CALLOC( int, p->nRows );
+ int * pGrp2 = ABC_CALLOC( int, p->nRows );
+ for ( iVar = 0; iVar < p->nRows; iVar++ )
+ {
+ if ( p->pRowSums[iVar] == 0 )
+ continue;
+ for ( iGrp1 = 0; iGrp1 < p->nCols; iGrp1++ )
+ if ( p->pMatrix[iGrp1][iVar] == 1 )
+ break;
+ for ( iGrp2 = p->nCols - 1; iGrp2 >= 0; iGrp2-- )
+ if ( p->pMatrix[iGrp2][iVar] == 1 )
+ break;
+ assert( iGrp1 <= iGrp2 );
+ pGrp1[iVar] = iGrp1;
+ pGrp2[iVar] = iGrp2;
+ Span += iGrp2 - iGrp1;
+ }
+ // compute span
+ for ( iGrp = 0; iGrp < p->nCols; iGrp++ )
+ {
+ for ( iVar = 0; iVar < p->nRows; iVar++ )
+ if ( pGrp1[iVar] == iGrp )
+ nCutSize++;
+ if ( nCutSizeMax < nCutSize )
+ nCutSizeMax = nCutSize;
+ for ( iVar = 0; iVar < p->nRows; iVar++ )
+ if ( pGrp2[iVar] == iGrp )
+ nCutSize--;
+ }
+ ABC_FREE( pGrp1 );
+ ABC_FREE( pGrp2 );
+ printf( "[%4d x %4d] Life-span =%6.2f Max-cut =%5d\n",
+ p->nCols, p->nRows, 1.0*Span/p->nRows, nCutSizeMax );
+ if ( nCutSize )
+ Abc_Print( -1, "Cut size is not zero (%d).\n", nCutSize );
+}
+
+
+
+/**Function*************************************************************
+
+ Synopsis [Starts the matrix representation.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Llb_Mtr_t * Llb_MtrAlloc( int nPis, int nFfs, int nCols, int nRows )
+{
+ Llb_Mtr_t * p;
+ int i;
+ p = ABC_CALLOC( Llb_Mtr_t, 1 );
+ p->nPis = nPis;
+ p->nFfs = nFfs;
+ p->nRows = nRows;
+ p->nCols = nCols;
+ p->pRowSums = ABC_CALLOC( int, nRows );
+ p->pColSums = ABC_CALLOC( int, nCols );
+ p->pColGrps = ABC_CALLOC( Llb_Grp_t *, nCols );
+ p->pMatrix = ABC_CALLOC( char *, nCols );
+ for ( i = 0; i < nCols; i++ )
+ p->pMatrix[i] = ABC_CALLOC( char, nRows );
+ // partial product
+ p->pProdVars = ABC_CALLOC( char, nRows ); // variables in the partial product
+ p->pProdNums = ABC_CALLOC( int, nRows ); // var counts in the remaining partitions
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Stops the matrix representation.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_MtrFree( Llb_Mtr_t * p )
+{
+ int i;
+ ABC_FREE( p->pProdVars );
+ ABC_FREE( p->pProdNums );
+ for ( i = 0; i < p->nCols; i++ )
+ ABC_FREE( p->pMatrix[i] );
+ ABC_FREE( p->pRowSums );
+ ABC_FREE( p->pColSums );
+ ABC_FREE( p->pMatrix );
+ ABC_FREE( p->pColGrps );
+ ABC_FREE( p );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates one column with vars in the array.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_MtrAddColumn( Llb_Mtr_t * p, Llb_Grp_t * pGrp )
+{
+ Aig_Obj_t * pVar;
+ int i, iRow, iCol = pGrp->Id;
+ assert( iCol >= 0 && iCol < p->nCols );
+ p->pColGrps[iCol] = pGrp;
+ Vec_PtrForEachEntry( Aig_Obj_t *, pGrp->vIns, pVar, i )
+ {
+ iRow = Vec_IntEntry( pGrp->pMan->vObj2Var, Aig_ObjId(pVar) );
+ assert( iRow >= 0 && iRow < p->nRows );
+ p->pMatrix[iCol][iRow] = 1;
+ p->pColSums[iCol]++;
+ p->pRowSums[iRow]++;
+ }
+ Vec_PtrForEachEntry( Aig_Obj_t *, pGrp->vOuts, pVar, i )
+ {
+ iRow = Vec_IntEntry( pGrp->pMan->vObj2Var, Aig_ObjId(pVar) );
+ assert( iRow >= 0 && iRow < p->nRows );
+ p->pMatrix[iCol][iRow] = 1;
+ p->pColSums[iCol]++;
+ p->pRowSums[iRow]++;
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Matrix reduce.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_MtrRemoveSingletonRows( Llb_Mtr_t * p )
+{
+ int i, k;
+ for ( i = 0; i < p->nRows; i++ )
+ if ( p->pRowSums[i] < 2 )
+ {
+ p->pRowSums[i] = 0;
+ for ( k = 0; k < p->nCols; k++ )
+ {
+ if ( p->pMatrix[k][i] == 1 )
+ {
+ p->pMatrix[k][i] = 0;
+ p->pColSums[k]--;
+ }
+ }
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Matrix reduce.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Llb_Mtr_t * Llb_MtrCreate( Llb_Man_t * p )
+{
+ Llb_Mtr_t * pMatrix;
+ Llb_Grp_t * pGroup;
+ int i;
+ pMatrix = Llb_MtrAlloc( Saig_ManPiNum(p->pAig), Saig_ManRegNum(p->pAig),
+ Vec_PtrSize(p->vGroups), Vec_IntSize(p->vVar2Obj) );
+ Vec_PtrForEachEntry( Llb_Grp_t *, p->vGroups, pGroup, i )
+ Llb_MtrAddColumn( pMatrix, pGroup );
+// Llb_MtrRemoveSingletonRows( pMatrix );
+ return pMatrix;
+}
+
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/llb/llbPart.c b/src/aig/llb/llbPart.c
new file mode 100644
index 00000000..41de27d8
--- /dev/null
+++ b/src/aig/llb/llbPart.c
@@ -0,0 +1,474 @@
+/**CFile****************************************************************
+
+ FileName [llbPart.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [BDD based reachability.]
+
+ Synopsis [Initial partition computation.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: llbPart.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "llbInt.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Llb_Grp_t * Llb_ManGroupAlloc( Llb_Man_t * pMan )
+{
+ Llb_Grp_t * p;
+ p = ABC_CALLOC( Llb_Grp_t, 1 );
+ p->pMan = pMan;
+ p->vIns = Vec_PtrAlloc( 8 );
+ p->vOuts = Vec_PtrAlloc( 8 );
+ p->Id = Vec_PtrSize( pMan->vGroups );
+ Vec_PtrPush( pMan->vGroups, p );
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_ManGroupStop( Llb_Grp_t * p )
+{
+ if ( p == NULL )
+ return;
+ Vec_PtrWriteEntry( p->pMan->vGroups, p->Id, NULL );
+ Vec_PtrFreeP( &p->vIns );
+ Vec_PtrFreeP( &p->vOuts );
+ Vec_PtrFreeP( &p->vNodes );
+ ABC_FREE( p );
+}
+
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_ManGroupCollect_rec( Aig_Man_t * pAig, Aig_Obj_t * pObj, Vec_Ptr_t * vNodes )
+{
+ if ( Aig_ObjIsTravIdCurrent(pAig, pObj) )
+ return;
+ Aig_ObjSetTravIdCurrent(pAig, pObj);
+ if ( Aig_ObjIsConst1(pObj) )
+ return;
+ if ( Aig_ObjIsPo(pObj) )
+ {
+ Llb_ManGroupCollect_rec( pAig, Aig_ObjFanin0(pObj), vNodes );
+ return;
+ }
+ assert( Aig_ObjIsAnd(pObj) );
+ Llb_ManGroupCollect_rec( pAig, Aig_ObjFanin0(pObj), vNodes );
+ Llb_ManGroupCollect_rec( pAig, Aig_ObjFanin1(pObj), vNodes );
+ Vec_PtrPush( vNodes, pObj );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Collects the support of MFFC.]
+
+ Description [Returns the number of internal nodes in the MFFC.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Ptr_t * Llb_ManGroupCollect( Llb_Grp_t * pGroup )
+{
+ Vec_Ptr_t * vNodes;
+ Aig_Obj_t * pObj;
+ int i;
+ vNodes = Vec_PtrAlloc( 100 );
+ Aig_ManIncrementTravId( pGroup->pMan->pAig );
+ Vec_PtrForEachEntry( Aig_Obj_t *, pGroup->vIns, pObj, i )
+ Aig_ObjSetTravIdCurrent( pGroup->pMan->pAig, pObj );
+ Vec_PtrForEachEntry( Aig_Obj_t *, pGroup->vOuts, pObj, i )
+ Aig_ObjSetTravIdPrevious( pGroup->pMan->pAig, pObj );
+ Vec_PtrForEachEntry( Aig_Obj_t *, pGroup->vOuts, pObj, i )
+ Llb_ManGroupCollect_rec( pGroup->pMan->pAig, pObj, vNodes );
+ return vNodes;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_ManGroupCreate_rec( Aig_Man_t * pAig, Aig_Obj_t * pObj, Vec_Ptr_t * vSupp )
+{
+ if ( Aig_ObjIsTravIdCurrent(pAig, pObj) )
+ return;
+ Aig_ObjSetTravIdCurrent(pAig, pObj);
+ if ( Aig_ObjIsConst1(pObj) )
+ return;
+ if ( pObj->fMarkA )
+ {
+ Vec_PtrPush( vSupp, pObj );
+ return;
+ }
+ assert( Aig_ObjIsAnd(pObj) );
+ Llb_ManGroupCreate_rec( pAig, Aig_ObjFanin0(pObj), vSupp );
+ Llb_ManGroupCreate_rec( pAig, Aig_ObjFanin1(pObj), vSupp );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Llb_Grp_t * Llb_ManGroupCreate( Llb_Man_t * pMan, Aig_Obj_t * pObj )
+{
+ Llb_Grp_t * p;
+ assert( pObj->fMarkA == 1 );
+ // derive group
+ p = Llb_ManGroupAlloc( pMan );
+ Vec_PtrPush( p->vOuts, pObj );
+ Aig_ManIncrementTravId( pMan->pAig );
+ if ( Aig_ObjIsPo(pObj) )
+ Llb_ManGroupCreate_rec( pMan->pAig, Aig_ObjFanin0(pObj), p->vIns );
+ else
+ {
+ Llb_ManGroupCreate_rec( pMan->pAig, Aig_ObjFanin0(pObj), p->vIns );
+ Llb_ManGroupCreate_rec( pMan->pAig, Aig_ObjFanin1(pObj), p->vIns );
+ }
+ // derive internal objects
+ assert( p->vNodes == NULL );
+ p->vNodes = Llb_ManGroupCollect( p );
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Llb_Grp_t * Llb_ManGroupCreateFirst( Llb_Man_t * pMan )
+{
+ Llb_Grp_t * p;
+ Aig_Obj_t * pObj;
+ int i;
+ p = Llb_ManGroupAlloc( pMan );
+ Saig_ManForEachLo( pMan->pAig, pObj, i )
+ Vec_PtrPush( p->vOuts, pObj );
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Llb_Grp_t * Llb_ManGroupCreateLast( Llb_Man_t * pMan )
+{
+ Llb_Grp_t * p;
+ Aig_Obj_t * pObj;
+ int i;
+ p = Llb_ManGroupAlloc( pMan );
+ Saig_ManForEachLi( pMan->pAig, pObj, i )
+ Vec_PtrPush( p->vIns, pObj );
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Llb_Grp_t * Llb_ManGroupsCombine( Llb_Grp_t * p1, Llb_Grp_t * p2 )
+{
+ Llb_Grp_t * p;
+ Aig_Obj_t * pObj;
+ int i;
+ p = Llb_ManGroupAlloc( p1->pMan );
+ // create inputs
+ Vec_PtrForEachEntry( Aig_Obj_t *, p1->vIns, pObj, i )
+ Vec_PtrPush( p->vIns, pObj );
+ Vec_PtrForEachEntry( Aig_Obj_t *, p2->vIns, pObj, i )
+ Vec_PtrPushUnique( p->vIns, pObj );
+ // create outputs
+ Vec_PtrForEachEntry( Aig_Obj_t *, p1->vOuts, pObj, i )
+ Vec_PtrPush( p->vOuts, pObj );
+ Vec_PtrForEachEntry( Aig_Obj_t *, p2->vOuts, pObj, i )
+ Vec_PtrPushUnique( p->vOuts, pObj );
+
+ // derive internal objects
+ assert( p->vNodes == NULL );
+ p->vNodes = Llb_ManGroupCollect( p );
+ return p;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_ManGroupMarkNodes_rec( Aig_Man_t * p, Aig_Obj_t * pObj )
+{
+ if ( Aig_ObjIsTravIdCurrent(p, pObj) )
+ return;
+ if ( Aig_ObjIsTravIdPrevious(p, pObj) )
+ {
+ Aig_ObjSetTravIdCurrent(p, pObj);
+ return;
+ }
+ Aig_ObjSetTravIdCurrent(p, pObj);
+ assert( Aig_ObjIsNode(pObj) );
+ Llb_ManGroupMarkNodes_rec( p, Aig_ObjFanin0(pObj) );
+ Llb_ManGroupMarkNodes_rec( p, Aig_ObjFanin1(pObj) );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates group from two cuts derived by the flow computation.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Llb_Grp_t * Llb_ManGroupCreateFromCuts( Llb_Man_t * pMan, Vec_Int_t * vCut1, Vec_Int_t * vCut2 )
+{
+ Llb_Grp_t * p;
+ Aig_Obj_t * pObj;
+ int i;
+ p = Llb_ManGroupAlloc( pMan );
+
+ // mark Cut1
+ Aig_ManIncrementTravId( pMan->pAig );
+ Aig_ManForEachNodeVec( pMan->pAig, vCut1, pObj, i )
+ Aig_ObjSetTravIdCurrent( pMan->pAig, pObj );
+ // collect unmarked Cut2
+ Aig_ManForEachNodeVec( pMan->pAig, vCut2, pObj, i )
+ if ( !Aig_ObjIsTravIdCurrent( pMan->pAig, pObj ) )
+ Vec_PtrPush( p->vOuts, pObj );
+
+ // mark nodes reachable from Cut2
+ Aig_ManIncrementTravId( pMan->pAig );
+ Aig_ManForEachNodeVec( pMan->pAig, vCut2, pObj, i )
+ Llb_ManGroupMarkNodes_rec( pMan->pAig, pObj );
+ // collect marked Cut1
+ Aig_ManForEachNodeVec( pMan->pAig, vCut1, pObj, i )
+ if ( Aig_ObjIsTravIdCurrent( pMan->pAig, pObj ) )
+ Vec_PtrPush( p->vIns, pObj );
+
+ // derive internal objects
+ assert( p->vNodes == NULL );
+ p->vNodes = Llb_ManGroupCollect( p );
+ return p;
+}
+
+
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_ManPrepareGroups( Llb_Man_t * pMan )
+{
+ Aig_Obj_t * pObj;
+ int i;
+ assert( pMan->vGroups == NULL );
+ pMan->vGroups = Vec_PtrAlloc( 1000 );
+ Llb_ManGroupCreateFirst( pMan );
+ Aig_ManForEachNode( pMan->pAig, pObj, i )
+ {
+ if ( pObj->fMarkA )
+ Llb_ManGroupCreate( pMan, pObj );
+ }
+ Saig_ManForEachLi( pMan->pAig, pObj, i )
+ {
+ if ( pObj->fMarkA )
+ Llb_ManGroupCreate( pMan, pObj );
+ }
+ Llb_ManGroupCreateLast( pMan );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_ManPrintSpan( Llb_Man_t * p )
+{
+ Llb_Grp_t * pGroup;
+ Aig_Obj_t * pVar;
+ int i, k, Span = 0, SpanMax = 0;
+ Vec_PtrForEachEntry( Llb_Grp_t *, p->vGroups, pGroup, i )
+ {
+ Vec_PtrForEachEntry( Aig_Obj_t *, pGroup->vIns, pVar, k )
+ if ( Vec_IntEntry(p->vVarBegs, pVar->Id) == i )
+ Span++;
+ Vec_PtrForEachEntry( Aig_Obj_t *, pGroup->vOuts, pVar, k )
+ if ( Vec_IntEntry(p->vVarBegs, pVar->Id) == i )
+ Span++;
+
+ SpanMax = ABC_MAX( SpanMax, Span );
+printf( "%d ", Span );
+
+ Vec_PtrForEachEntry( Aig_Obj_t *, pGroup->vIns, pVar, k )
+ if ( Vec_IntEntry(p->vVarEnds, pVar->Id) == i )
+ Span--;
+ Vec_PtrForEachEntry( Aig_Obj_t *, pGroup->vOuts, pVar, k )
+ if ( Vec_IntEntry(p->vVarEnds, pVar->Id) == i )
+ Span--;
+ }
+printf( "\n" );
+printf( "Max = %d\n", SpanMax );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Llb_ManGroupHasVar( Llb_Man_t * p, int iGroup, int iVar )
+{
+ Llb_Grp_t * pGroup = (Llb_Grp_t *)Vec_PtrEntry( p->vGroups, iGroup );
+ Aig_Obj_t * pObj;
+ int i;
+ Vec_PtrForEachEntry( Aig_Obj_t *, pGroup->vIns, pObj, i )
+ if ( pObj->Id == iVar )
+ return 1;
+ Vec_PtrForEachEntry( Aig_Obj_t *, pGroup->vOuts, pObj, i )
+ if ( pObj->Id == iVar )
+ return 1;
+ return 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_ManPrintHisto( Llb_Man_t * p )
+{
+ Aig_Obj_t * pObj;
+ int i, k;
+ Aig_ManForEachObj( p->pAig, pObj, i )
+ {
+ if ( Vec_IntEntry(p->vObj2Var, i) < 0 )
+ continue;
+ printf( "%3d :", i );
+ for ( k = 0; k < Vec_IntEntry(p->vVarBegs, i); k++ )
+ printf( " " );
+ for ( ; k <= Vec_IntEntry(p->vVarEnds, i); k++ )
+ printf( "%c", Llb_ManGroupHasVar(p, k, i)? '*':'-' );
+ printf( "\n" );
+ }
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/llb/llbPivot.c b/src/aig/llb/llbPivot.c
new file mode 100644
index 00000000..6a6fb321
--- /dev/null
+++ b/src/aig/llb/llbPivot.c
@@ -0,0 +1,254 @@
+/**CFile****************************************************************
+
+ FileName [llbPivot.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [BDD based reachability.]
+
+ Synopsis [Determining pivot variables.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: llbPivot.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "llbInt.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Llb_ManTracePaths_rec( Aig_Man_t * p, Aig_Obj_t * pObj, Aig_Obj_t * pPivot )
+{
+ Aig_Obj_t * pFanout;
+ int k, iFan;
+ if ( Aig_ObjIsTravIdPrevious(p, pObj) )
+ return 0;
+ if ( Aig_ObjIsTravIdCurrent(p, pObj) )
+ return 1;
+ if ( Saig_ObjIsLi(p, pObj) )
+ return 0;
+ if ( Saig_ObjIsPo(p, pObj) )
+ return 0;
+ if ( pObj == pPivot )
+ return 1;
+ assert( Aig_ObjIsCand(pObj) );
+ Aig_ObjForEachFanout( p, pObj, pFanout, iFan, k )
+ if ( !Llb_ManTracePaths_rec( p, pFanout, pPivot ) )
+ {
+ Aig_ObjSetTravIdPrevious(p, pObj);
+ return 0;
+ }
+ Aig_ObjSetTravIdCurrent(p, pObj);
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Llb_ManTracePaths( Aig_Man_t * p, Aig_Obj_t * pPivot )
+{
+ Aig_Obj_t * pObj;
+ int i, Counter = 0;
+ Aig_ManIncrementTravId( p ); // prev = visited with path to LI (value 0)
+ Aig_ManIncrementTravId( p ); // cur = visited w/o path to LI (value 1)
+ Saig_ManForEachLo( p, pObj, i )
+ Counter += Llb_ManTracePaths_rec( p, pObj, pPivot );
+ return Counter;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_ManTestCuts( Aig_Man_t * p )
+{
+ Aig_Obj_t * pObj;
+ int i, Count;
+ Aig_ManFanoutStart( p );
+ Aig_ManForEachNode( p, pObj, i )
+ {
+ if ( Aig_ObjRefs(pObj) <= 1 )
+ continue;
+ Count = Llb_ManTracePaths( p, pObj );
+ printf( "Obj =%5d. Lev =%3d. Fanout =%5d. Count = %3d.\n",
+ i, Aig_ObjLevel(pObj), Aig_ObjRefs(pObj), Count );
+ }
+ Aig_ManFanoutStop( p );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_ManLabelLiCones_rec( Aig_Man_t * p, Aig_Obj_t * pObj )
+{
+ if ( pObj->fMarkB )
+ return;
+ pObj->fMarkB = 1;
+ assert( Aig_ObjIsNode(pObj) );
+ Llb_ManLabelLiCones_rec( p, Aig_ObjFanin0(pObj) );
+ Llb_ManLabelLiCones_rec( p, Aig_ObjFanin1(pObj) );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Determine starting cut-points.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_ManLabelLiCones( Aig_Man_t * p )
+{
+ Aig_Obj_t * pObj;
+ int i;
+ // mark const and PIs
+ Aig_ManConst1(p)->fMarkB = 1;
+ Aig_ManForEachPi( p, pObj, i )
+ pObj->fMarkB = 1;
+ // mark cones
+ Saig_ManForEachLi( p, pObj, i )
+ Llb_ManLabelLiCones_rec( p, Aig_ObjFanin0(pObj) );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Determine starting cut-points.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_ManMarkInternalPivots( Aig_Man_t * p )
+{
+ Vec_Ptr_t * vMuxes;
+ Aig_Obj_t * pObj;
+ int i, Counter = 0;
+
+ // remove refs due to MUXes
+ vMuxes = Aig_ManMuxesCollect( p );
+ Aig_ManMuxesDeref( p, vMuxes );
+
+ // mark nodes feeding into LIs
+ Aig_ManCleanMarkB( p );
+ Llb_ManLabelLiCones( p );
+
+ // mark internal nodes
+ Aig_ManFanoutStart( p );
+ Aig_ManForEachNode( p, pObj, i )
+ if ( pObj->fMarkB && pObj->nRefs > 1 )
+ {
+ if ( Llb_ManTracePaths(p, pObj) > 0 )
+ pObj->fMarkA = 1;
+ Counter++;
+ }
+ Aig_ManFanoutStop( p );
+// printf( "TracePath tried = %d.\n", Counter );
+
+ // mark nodes feeding into LIs
+ Aig_ManCleanMarkB( p );
+
+ // add refs due to MUXes
+ Aig_ManMuxesRef( p, vMuxes );
+ Vec_PtrFree( vMuxes );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Determine starting cut-points.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Llb_ManMarkPivotNodes( Aig_Man_t * p, int fUseInternal )
+{
+ Vec_Int_t * vVar2Obj;
+ Aig_Obj_t * pObj;
+ int i;
+ // mark inputs/outputs
+ Aig_ManForEachPi( p, pObj, i )
+ pObj->fMarkA = 1;
+ Saig_ManForEachLi( p, pObj, i )
+ pObj->fMarkA = 1;
+
+ // mark internal pivot nodes
+ if ( fUseInternal )
+ Llb_ManMarkInternalPivots( p );
+
+ // assign variable numbers
+ Aig_ManConst1(p)->fMarkA = 0;
+ vVar2Obj = Vec_IntAlloc( 100 );
+ Aig_ManForEachPi( p, pObj, i )
+ Vec_IntPush( vVar2Obj, Aig_ObjId(pObj) );
+ Aig_ManForEachNode( p, pObj, i )
+ if ( pObj->fMarkA )
+ Vec_IntPush( vVar2Obj, Aig_ObjId(pObj) );
+ Saig_ManForEachLi( p, pObj, i )
+ Vec_IntPush( vVar2Obj, Aig_ObjId(pObj) );
+ return vVar2Obj;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/llb/llbReach.c b/src/aig/llb/llbReach.c
new file mode 100644
index 00000000..7c12a88c
--- /dev/null
+++ b/src/aig/llb/llbReach.c
@@ -0,0 +1,620 @@
+/**CFile****************************************************************
+
+ FileName [llbReach.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [BDD based reachability.]
+
+ Synopsis [Reachability analysis.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: llbReach.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "llbInt.h"
+#include "extra.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Derives global BDD for the node.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+DdNode * Llb_ManConstructOutBdd( Aig_Man_t * pAig, Aig_Obj_t * pNode, DdManager * dd )
+{
+ DdNode * bBdd0, * bBdd1, * bFunc;
+ Vec_Ptr_t * vNodes;
+ Aig_Obj_t * pObj;
+ int i;
+ if ( Aig_ObjFanin0(pNode) == Aig_ManConst1(pAig) )
+ return Cudd_NotCond( Cudd_ReadOne(dd), Aig_ObjFaninC0(pNode) );
+ vNodes = Aig_ManDfsNodes( pAig, &pNode, 1 );
+ assert( Vec_PtrSize(vNodes) > 0 );
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
+ {
+ if ( !Aig_ObjIsNode(pObj) )
+ continue;
+ bBdd0 = Cudd_NotCond( Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0(pObj) );
+ bBdd1 = Cudd_NotCond( Aig_ObjFanin1(pObj)->pData, Aig_ObjFaninC1(pObj) );
+ pObj->pData = Cudd_bddAnd( dd, bBdd0, bBdd1 ); Cudd_Ref( (DdNode *)pObj->pData );
+ }
+ bFunc = (DdNode *)pObj->pData; Cudd_Ref( bFunc );
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
+ {
+ if ( !Aig_ObjIsNode(pObj) )
+ continue;
+ Cudd_RecursiveDeref( dd, (DdNode *)pObj->pData );
+ }
+ Vec_PtrFree( vNodes );
+ if ( Aig_ObjIsPo(pNode) )
+ bFunc = Cudd_NotCond( bFunc, Aig_ObjFaninC0(pNode) );
+ Cudd_Deref( bFunc );
+ return bFunc;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Derives BDD for the group.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+DdNode * Llb_ManConstructGroupBdd( Llb_Man_t * p, Llb_Grp_t * pGroup )
+{
+ Aig_Obj_t * pObj;
+ DdNode * bBdd0, * bBdd1, * bRes, * bXor, * bTemp;
+ int i;
+ Aig_ManConst1(p->pAig)->pData = Cudd_ReadOne( p->dd );
+ Vec_PtrForEachEntry( Aig_Obj_t *, pGroup->vIns, pObj, i )
+ pObj->pData = Cudd_bddIthVar( p->dd, Vec_IntEntry(p->vObj2Var, Aig_ObjId(pObj)) );
+ Vec_PtrForEachEntry( Aig_Obj_t *, pGroup->vNodes, pObj, i )
+ {
+ bBdd0 = Cudd_NotCond( Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0(pObj) );
+ bBdd1 = Cudd_NotCond( Aig_ObjFanin1(pObj)->pData, Aig_ObjFaninC1(pObj) );
+ pObj->pData = Cudd_bddAnd( p->dd, bBdd0, bBdd1 ); Cudd_Ref( (DdNode *)pObj->pData );
+ }
+ bRes = Cudd_ReadOne( p->dd ); Cudd_Ref( bRes );
+ Vec_PtrForEachEntry( Aig_Obj_t *, pGroup->vOuts, pObj, i )
+ {
+ if ( Aig_ObjIsPo(pObj) )
+ bBdd0 = Cudd_NotCond( Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0(pObj) );
+ else
+ bBdd0 = (DdNode *)pObj->pData;
+ bBdd1 = Cudd_bddIthVar( p->dd, Vec_IntEntry(p->vObj2Var, Aig_ObjId(pObj)) );
+ bXor = Cudd_bddXor( p->dd, bBdd0, bBdd1 ); Cudd_Ref( bXor );
+ bRes = Cudd_bddAnd( p->dd, bTemp = bRes, Cudd_Not(bXor) ); Cudd_Ref( bRes );
+ Cudd_RecursiveDeref( p->dd, bTemp );
+ Cudd_RecursiveDeref( p->dd, bXor );
+ }
+ Vec_PtrForEachEntry( Aig_Obj_t *, pGroup->vNodes, pObj, i )
+ Cudd_RecursiveDeref( p->dd, (DdNode *)pObj->pData );
+ Cudd_Deref( bRes );
+ return bRes;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Derives quantification cube.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+DdNode * Llb_ManConstructQuantCubeIntern( Llb_Man_t * p, Llb_Grp_t * pGroup, int iGrpPlace )
+{
+ Aig_Obj_t * pObj;
+ DdNode * bRes, * bTemp, * bVar;
+ int i, iGroupFirst, iGroupLast;
+ bRes = Cudd_ReadOne( p->dd ); Cudd_Ref( bRes );
+ Vec_PtrForEachEntry( Aig_Obj_t *, pGroup->vIns, pObj, i )
+ {
+ iGroupFirst = Vec_IntEntry(p->vVarBegs, Aig_ObjId(pObj));
+ iGroupLast = Vec_IntEntry(p->vVarEnds, Aig_ObjId(pObj));
+ assert( iGroupFirst <= iGroupLast );
+ if ( iGroupFirst < iGroupLast )
+ continue;
+ bVar = Cudd_bddIthVar( p->dd, Vec_IntEntry(p->vObj2Var, Aig_ObjId(pObj)) );
+ bRes = Cudd_bddAnd( p->dd, bTemp = bRes, bVar ); Cudd_Ref( bRes );
+ Cudd_RecursiveDeref( p->dd, bTemp );
+ }
+ Vec_PtrForEachEntry( Aig_Obj_t *, pGroup->vOuts, pObj, i )
+ {
+ iGroupFirst = Vec_IntEntry(p->vVarBegs, Aig_ObjId(pObj));
+ iGroupLast = Vec_IntEntry(p->vVarEnds, Aig_ObjId(pObj));
+ assert( iGroupFirst <= iGroupLast );
+ if ( iGroupFirst < iGroupLast )
+ continue;
+ bVar = Cudd_bddIthVar( p->dd, Vec_IntEntry(p->vObj2Var, Aig_ObjId(pObj)) );
+ bRes = Cudd_bddAnd( p->dd, bTemp = bRes, bVar ); Cudd_Ref( bRes );
+ Cudd_RecursiveDeref( p->dd, bTemp );
+ }
+ Cudd_Deref( bRes );
+ return bRes;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Derives quantification cube.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+DdNode * Llb_ManConstructQuantCube( Llb_Man_t * p, Llb_Grp_t * pGroup, int iGrpPlace )
+{
+ Aig_Obj_t * pObj;
+ DdNode * bRes, * bTemp, * bVar;
+ int i, iGroupLast;
+ bRes = Cudd_ReadOne( p->dd ); Cudd_Ref( bRes );
+ Vec_PtrForEachEntry( Aig_Obj_t *, pGroup->vIns, pObj, i )
+ {
+ iGroupLast = Vec_IntEntry(p->vVarEnds, Aig_ObjId(pObj));
+ assert( iGroupLast >= iGrpPlace );
+ if ( iGroupLast > iGrpPlace )
+ continue;
+ bVar = Cudd_bddIthVar( p->dd, Vec_IntEntry(p->vObj2Var, Aig_ObjId(pObj)) );
+ bRes = Cudd_bddAnd( p->dd, bTemp = bRes, bVar ); Cudd_Ref( bRes );
+ Cudd_RecursiveDeref( p->dd, bTemp );
+ }
+ Vec_PtrForEachEntry( Aig_Obj_t *, pGroup->vOuts, pObj, i )
+ {
+ iGroupLast = Vec_IntEntry(p->vVarEnds, Aig_ObjId(pObj));
+ assert( iGroupLast >= iGrpPlace );
+ if ( iGroupLast > iGrpPlace )
+ continue;
+ bVar = Cudd_bddIthVar( p->dd, Vec_IntEntry(p->vObj2Var, Aig_ObjId(pObj)) );
+ bRes = Cudd_bddAnd( p->dd, bTemp = bRes, bVar ); Cudd_Ref( bRes );
+ Cudd_RecursiveDeref( p->dd, bTemp );
+ }
+ Cudd_Deref( bRes );
+ return bRes;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+DdNode * Llb_ManComputeInitState( Llb_Man_t * p, DdManager * dd )
+{
+ Aig_Obj_t * pObj;
+ DdNode * bRes, * bVar, * bTemp;
+ int i, iVar;
+ bRes = Cudd_ReadOne( dd ); Cudd_Ref( bRes );
+ Saig_ManForEachLo( p->pAig, pObj, i )
+ {
+ iVar = (dd == p->ddG) ? i : Vec_IntEntry(p->vObj2Var, Aig_ObjId(pObj));
+ bVar = Cudd_bddIthVar( dd, iVar );
+ bRes = Cudd_bddAnd( dd, bTemp = bRes, Cudd_Not(bVar) ); Cudd_Ref( bRes );
+ Cudd_RecursiveDeref( dd, bTemp );
+ }
+ Cudd_Deref( bRes );
+ return bRes;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+DdNode * Llb_ManComputeImage( Llb_Man_t * p, DdNode * bInit )
+{
+ int fCheckSupport = 0;
+ Llb_Grp_t * pGroup;
+ DdNode * bImage, * bGroup, * bCube, * bTemp;
+ int i;
+ bImage = bInit; Cudd_Ref( bImage );
+ for ( i = 1; i < p->pMatrix->nCols-1; i++ )
+ {
+ // compute group BDD
+ pGroup = p->pMatrix->pColGrps[i];
+ bGroup = Llb_ManConstructGroupBdd( p, pGroup ); Cudd_Ref( bGroup );
+ // quantify variables appearing only in this group
+ bCube = Llb_ManConstructQuantCubeIntern( p, pGroup, i ); Cudd_Ref( bCube );
+ bGroup = Cudd_bddExistAbstract( p->dd, bTemp = bGroup, bCube ); Cudd_Ref( bGroup );
+ Cudd_RecursiveDeref( p->dd, bTemp );
+ Cudd_RecursiveDeref( p->dd, bCube );
+ // perform partial product
+ bCube = Llb_ManConstructQuantCube( p, pGroup, i ); Cudd_Ref( bCube );
+ bImage = Cudd_bddAndAbstract( p->dd, bTemp = bImage, bGroup, bCube ); Cudd_Ref( bImage );
+ Cudd_RecursiveDeref( p->dd, bTemp );
+ Cudd_RecursiveDeref( p->dd, bGroup );
+ Cudd_RecursiveDeref( p->dd, bCube );
+ // chech runtime
+ if ( p->pPars->TimeTarget && clock() >= p->pPars->TimeTarget )
+ {
+ Cudd_RecursiveDeref( p->dd, bImage );
+ return NULL;
+ }
+ }
+
+ // make sure image depends on next state vars
+ if ( fCheckSupport )
+ {
+ bCube = Cudd_Support( p->dd, bImage ); Cudd_Ref( bCube );
+ for ( bTemp = bCube; bTemp != p->dd->one; bTemp = cuddT(bTemp) )
+ {
+ int ObjId = Vec_IntEntry( p->vVar2Obj, bTemp->index );
+ Aig_Obj_t * pObj = Aig_ManObj( p->pAig, ObjId );
+ if ( !Saig_ObjIsLi(p->pAig, pObj) )
+ printf( "Var %d assigned to obj %d that is not LI\n", bTemp->index, ObjId );
+ }
+ Cudd_RecursiveDeref( p->dd, bCube );
+ }
+ Cudd_Deref( bImage );
+ return bImage;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+DdNode * Llb_ManCreateConstraints( Llb_Man_t * p, Vec_Int_t * vHints, int fUseNsVars )
+{
+ DdNode * bConstr, * bFunc, * bTemp;
+ Aig_Obj_t * pObj;
+ int i, Entry;
+ if ( vHints == NULL )
+ return Cudd_ReadOne( p->dd );
+ assert( Aig_ManPiNum(p->pAig) == Aig_ManPiNum(p->pAigGlo) );
+ // assign const and PI nodes to the original AIG
+ Aig_ManCleanData( p->pAig );
+ Aig_ManConst1( p->pAig )->pData = Cudd_ReadOne( p->dd );
+ Saig_ManForEachPi( p->pAig, pObj, i )
+ pObj->pData = Cudd_bddIthVar( p->dd, Vec_IntEntry(p->vObj2Var,Aig_ObjId(pObj)) );
+ Saig_ManForEachLo( p->pAig, pObj, i )
+ {
+ if ( fUseNsVars )
+ Entry = Vec_IntEntry( p->vObj2Var, Aig_ObjId(Saig_ObjLoToLi(p->pAig, pObj)) );
+ else
+ Entry = Vec_IntEntry( p->vObj2Var, Aig_ObjId(pObj) );
+ pObj->pData = Cudd_bddIthVar( p->dd, Entry );
+ }
+ // transfer them to the global AIG
+ Aig_ManCleanData( p->pAigGlo );
+ Aig_ManConst1( p->pAigGlo )->pData = Cudd_ReadOne( p->dd );
+ Aig_ManForEachPi( p->pAigGlo, pObj, i )
+ pObj->pData = Aig_ManPi(p->pAig, i)->pData;
+ // derive consraints
+ bConstr = Cudd_ReadOne( p->dd ); Cudd_Ref( bConstr );
+ Vec_IntForEachEntry( vHints, Entry, i )
+ {
+ if ( Entry != 0 && Entry != 1 )
+ continue;
+ bFunc = Llb_ManConstructOutBdd( p->pAigGlo, Aig_ManObj(p->pAigGlo, i), p->dd ); Cudd_Ref( bFunc );
+ bFunc = Cudd_NotCond( bFunc, Entry ); // restrict to not constraint
+ // make the product
+ bConstr = Cudd_bddAnd( p->dd, bTemp = bConstr, bFunc ); Cudd_Ref( bConstr );
+ Cudd_RecursiveDeref( p->dd, bTemp );
+ Cudd_RecursiveDeref( p->dd, bFunc );
+ }
+ Cudd_Deref( bConstr );
+ return bConstr;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Perform reachability with hints and returns reached states in ppGlo.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Llb_ManReachability( Llb_Man_t * p, Vec_Int_t * vHints, DdManager ** pddGlo )
+{
+ int fCheckOutputs = !p->pPars->fSkipOutCheck;
+ int fInternalReorder = 0;
+ int * pNs2Glo = Vec_IntArray( p->vNs2Glo );
+ int * pGlo2Cs = Vec_IntArray( p->vGlo2Cs );
+ DdNode * bCurrent, * bReached, * bNext, * bTemp, * bCube;
+ DdNode * bConstrCs, * bConstrNs;
+ int clk2, clk = clock(), nIters, nBddSize = 0, iOutFail = -1;
+ int nThreshold = 10000;
+
+ // compute time to stop
+ if ( p->pPars->TimeLimit )
+ p->pPars->TimeTarget = clock() + p->pPars->TimeLimit * CLOCKS_PER_SEC;
+ else
+ p->pPars->TimeTarget = 0;
+
+ // define variable limits
+ Llb_ManPrepareVarLimits( p );
+
+ // start the managers
+ assert( p->dd == NULL );
+ assert( p->ddG == NULL );
+ p->dd = Cudd_Init( Vec_IntSize(p->vVar2Obj), 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 );
+ if ( pddGlo && *pddGlo )
+ p->ddG = *pddGlo, *pddGlo = NULL;
+ else
+ p->ddG = Cudd_Init( Aig_ManRegNum(p->pAig), 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 );
+
+ if ( p->pPars->fReorder )
+ {
+ Cudd_AutodynEnable( p->dd, CUDD_REORDER_SYMM_SIFT );
+ Cudd_AutodynEnable( p->ddG, CUDD_REORDER_SYMM_SIFT );
+ }
+ else
+ {
+ Cudd_AutodynDisable( p->dd );
+ Cudd_AutodynDisable( p->ddG );
+ }
+
+ // derive constraints
+ bConstrCs = Llb_ManCreateConstraints( p, vHints, 0 ); Cudd_Ref( bConstrCs );
+ bConstrNs = Llb_ManCreateConstraints( p, vHints, 1 ); Cudd_Ref( bConstrNs );
+//Extra_bddPrint( p->dd, bConstrCs ); printf( "\n" );
+//Extra_bddPrint( p->dd, bConstrNs ); printf( "\n" );
+
+ // perform reachability analysis
+ // compute the starting set of states
+ if ( p->ddG->bReached )
+ {
+ bReached = p->ddG->bReached; p->ddG->bReached = NULL;
+ bCurrent = Extra_TransferPermute( p->ddG, p->dd, bReached, pGlo2Cs ); Cudd_Ref( bCurrent );
+ }
+ else
+ {
+ bReached = Llb_ManComputeInitState( p, p->ddG ); Cudd_Ref( bReached );
+ bCurrent = Llb_ManComputeInitState( p, p->dd ); Cudd_Ref( bCurrent );
+ }
+//Extra_bddPrintSupport( p->ddG, bReached ); printf( "\n" );
+//Extra_bddPrintSupport( p->dd, bCurrent ); printf( "\n" );
+
+//Extra_bddPrintSupport( p->dd, bCurrent ); printf( "\n" );
+ for ( nIters = 0; nIters < p->pPars->nIterMax; nIters++ )
+ {
+ clk2 = clock();
+ // check the runtime limit
+ if ( p->pPars->TimeLimit && clock() >= p->pPars->TimeTarget )
+ {
+ if ( !p->pPars->fSilent )
+ printf( "Reached timeout during image computation (%d seconds).\n", p->pPars->TimeLimit );
+ p->pPars->iFrame = nIters - 1;
+ Cudd_RecursiveDeref( p->dd, bCurrent ); bCurrent = NULL;
+ Cudd_RecursiveDeref( p->dd, bConstrCs ); bConstrCs = NULL;
+ Cudd_RecursiveDeref( p->dd, bConstrNs ); bConstrNs = NULL;
+ Cudd_RecursiveDeref( p->ddG, bReached ); bReached = NULL;
+ return -1;
+ }
+
+ // check outputs
+ if ( fCheckOutputs )
+ {
+ Aig_Obj_t * pObj;
+ int i;
+ Aig_ManConst1( p->pAigGlo )->pData = Cudd_ReadOne( p->dd );
+ Aig_ManForEachPi( p->pAig, pObj, i )
+ pObj->pData = Cudd_bddIthVar( p->dd, Vec_IntEntry(p->vObj2Var,Aig_ObjId(pObj)) );
+ Aig_ManForEachPi( p->pAigGlo, pObj, i )
+ pObj->pData = Aig_ManPi(p->pAig, i)->pData;
+
+//Extra_bddPrintSupport( p->dd, bCurrent ); printf( "\n" );
+ for ( iOutFail = 0; iOutFail < Saig_ManPoNum(p->pAig); iOutFail++ )
+ {
+ DdNode * bFunc, * bInter;
+ bFunc = Llb_ManConstructOutBdd( p->pAigGlo, Aig_ManPo(p->pAigGlo, iOutFail), p->dd ); Cudd_Ref( bFunc );
+//Extra_bddPrint( p->dd, bFunc ); printf( "\n" );
+ if ( Cudd_bddLeq( p->dd, bCurrent, Cudd_Not(bFunc) ) ) // no cex
+ {
+ Cudd_RecursiveDeref( p->dd, bFunc );
+ continue;
+ }
+ bInter = Cudd_bddIntersect( p->dd, bCurrent, bFunc ); Cudd_Ref( bInter );
+ assert( p->pAig->pSeqModel == NULL );
+ p->pAig->pSeqModel = Llb_ManDeriveCex( p, bInter, iOutFail, nIters );
+ Cudd_RecursiveDeref( p->dd, bInter );
+ Cudd_RecursiveDeref( p->dd, bFunc );
+ break;
+ }
+ if ( iOutFail < Saig_ManPoNum(p->pAig) )
+ {
+ if ( !p->pPars->fSilent )
+ printf( "Output %d was asserted in frame %d (use \"write_counter\" to dump a witness). ", iOutFail, nIters );
+ Cudd_RecursiveDeref( p->ddG, bReached ); bReached = NULL;
+ Cudd_RecursiveDeref( p->dd, bCurrent ); bCurrent = NULL;
+ p->pPars->iFrame = nIters;
+ break;
+ }
+ }
+
+ // restrict reachable states using constraints
+ if ( vHints )
+ {
+ bCurrent = Cudd_bddAnd( p->dd, bTemp = bCurrent, bConstrCs ); Cudd_Ref( bCurrent );
+ Cudd_RecursiveDeref( p->dd, bTemp );
+ }
+
+ // quantify variables appearing only in the init state
+ bCube = Llb_ManConstructQuantCubeIntern( p, (Llb_Grp_t *)Vec_PtrEntry(p->vGroups,0), 0 ); Cudd_Ref( bCube );
+ bCurrent = Cudd_bddExistAbstract( p->dd, bTemp = bCurrent, bCube ); Cudd_Ref( bCurrent );
+ Cudd_RecursiveDeref( p->dd, bTemp );
+ Cudd_RecursiveDeref( p->dd, bCube );
+
+ // compute the next states
+ bNext = Llb_ManComputeImage( p, bCurrent );
+ if ( bNext == NULL )
+ {
+ if ( !p->pPars->fSilent )
+ printf( "Reached timeout during image computation (%d seconds).\n", p->pPars->TimeLimit );
+ p->pPars->iFrame = nIters - 1;
+ Cudd_RecursiveDeref( p->dd, bCurrent ); bCurrent = NULL;
+ Cudd_RecursiveDeref( p->dd, bConstrCs ); bConstrCs = NULL;
+ Cudd_RecursiveDeref( p->dd, bConstrNs ); bConstrNs = NULL;
+ Cudd_RecursiveDeref( p->ddG, bReached ); bReached = NULL;
+ return -1;
+ }
+ Cudd_Ref( bNext );
+ Cudd_RecursiveDeref( p->dd, bCurrent ); bCurrent = NULL;
+
+ // restrict reachable states using constraints
+ if ( vHints )
+ {
+ bNext = Cudd_bddAnd( p->dd, bTemp = bNext, bConstrNs ); Cudd_Ref( bNext );
+ Cudd_RecursiveDeref( p->dd, bTemp );
+ }
+//Extra_bddPrintSupport( p->dd, bNext ); printf( "\n" );
+
+ // remap these states into the current state vars
+ bNext = Extra_TransferPermute( p->dd, p->ddG, bTemp = bNext, pNs2Glo ); Cudd_Ref( bNext );
+ Cudd_RecursiveDeref( p->dd, bTemp );
+
+ // check if there are any new states
+ if ( Cudd_bddLeq( p->ddG, bNext, bReached ) ) // implication = no new states
+ {
+ Cudd_RecursiveDeref( p->ddG, bNext ); bNext = NULL;
+ break;
+ }
+
+ // check the BDD size
+ nBddSize = Cudd_DagSize(bNext);
+ if ( nBddSize > p->pPars->nBddMax )
+ {
+ Cudd_RecursiveDeref( p->ddG, bNext ); bNext = NULL;
+ break;
+ }
+
+ // get the new states
+ bCurrent = Cudd_bddAnd( p->ddG, bNext, Cudd_Not(bReached) ); Cudd_Ref( bCurrent );
+ // minimize the new states with the reached states
+// bCurrent = Cudd_bddConstrain( p->ddG, bTemp = bCurrent, Cudd_Not(bReached) ); Cudd_Ref( bCurrent );
+// bCurrent = Cudd_bddRestrict( p->ddG, bTemp = bCurrent, Cudd_Not(bReached) ); Cudd_Ref( bCurrent );
+// Cudd_RecursiveDeref( p->ddG, bTemp );
+//printf( "Initial BDD =%7d. Constrained BDD =%7d.\n", Cudd_DagSize(bTemp), Cudd_DagSize(bCurrent) );
+ // remap these states into the current state vars
+ bCurrent = Extra_TransferPermute( p->ddG, p->dd, bTemp = bCurrent, pGlo2Cs ); Cudd_Ref( bCurrent );
+ Cudd_RecursiveDeref( p->ddG, bTemp );
+
+ // add to the reached states
+ bReached = Cudd_bddOr( p->ddG, bTemp = bReached, bNext ); Cudd_Ref( bReached );
+ Cudd_RecursiveDeref( p->ddG, bTemp );
+ Cudd_RecursiveDeref( p->ddG, bNext );
+ bNext = NULL;
+
+ if ( p->pPars->fVerbose )
+ {
+ fprintf( stdout, "F =%3d : ", nIters );
+ fprintf( stdout, "Image =%6d ", nBddSize );
+ fprintf( stdout, "%8d (%4d %3d) ",
+ Cudd_ReadKeys(p->dd), Cudd_ReadReorderings(p->dd), Cudd_ReadGarbageCollections(p->dd) );
+ fprintf( stdout, "Reach =%6d ", Cudd_DagSize(bReached) );
+ fprintf( stdout, "%8d (%4d %3d) ",
+ Cudd_ReadKeys(p->ddG), Cudd_ReadReorderings(p->ddG), Cudd_ReadGarbageCollections(p->ddG) );
+ }
+ if ( fInternalReorder && p->pPars->fReorder && nBddSize > nThreshold )
+ {
+ if ( p->pPars->fVerbose )
+ fprintf( stdout, "Reordering... Before = %5d. ", Cudd_DagSize(bReached) );
+ Cudd_ReduceHeap( p->dd, CUDD_REORDER_SYMM_SIFT, 100 );
+// Cudd_AutodynDisable( p->dd );
+ if ( p->pPars->fVerbose )
+ fprintf( stdout, "After = %5d.\r", Cudd_DagSize(bReached) );
+ nThreshold *= 2;
+ }
+ if ( p->pPars->fVerbose )
+// fprintf( stdout, "\r" );
+// fprintf( stdout, "\n" );
+ Abc_PrintTime( 1, "T", clock() - clk2 );
+ }
+ Cudd_RecursiveDeref( p->dd, bConstrCs ); bConstrCs = NULL;
+ Cudd_RecursiveDeref( p->dd, bConstrNs ); bConstrNs = NULL;
+ if ( bReached == NULL )
+ return 0; // reachable
+ assert( bCurrent == NULL );
+ if ( bCurrent )
+ Cudd_RecursiveDeref( p->dd, bCurrent );
+ // report the stats
+ if ( p->pPars->fVerbose )
+ {
+ double nMints = Cudd_CountMinterm(p->ddG, bReached, Saig_ManRegNum(p->pAig) );
+ if ( nIters >= p->pPars->nIterMax || nBddSize > p->pPars->nBddMax )
+ fprintf( stdout, "Reachability analysis is stopped after %d frames.\n", nIters );
+ else
+ fprintf( stdout, "Reachability analysis completed after %d frames.\n", nIters );
+ fprintf( stdout, "Reachable states = %.0f. (Ratio = %.4f %%)\n", nMints, 100.0*nMints/pow(2.0, Saig_ManRegNum(p->pAig)) );
+ fflush( stdout );
+ }
+ if ( nIters >= p->pPars->nIterMax || nBddSize > p->pPars->nBddMax )
+ {
+ if ( !p->pPars->fSilent )
+ printf( "Verified only for states reachable in %d frames. ", nIters );
+ Cudd_RecursiveDeref( p->ddG, bReached );
+ return -1; // undecided
+ }
+ if ( pddGlo )
+ {
+ assert( p->ddG->bReached == NULL );
+ p->ddG->bReached = bReached; bReached = NULL;
+ assert( *pddGlo == NULL );
+ *pddGlo = p->ddG; p->ddG = NULL;
+ }
+ else
+ Cudd_RecursiveDeref( p->ddG, bReached );
+ if ( !p->pPars->fSilent )
+ printf( "The miter is proved unreachable after %d iterations. ", nIters );
+ p->pPars->iFrame = nIters - 1;
+ return 1; // unreachable
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/llb/llbSched.c b/src/aig/llb/llbSched.c
new file mode 100644
index 00000000..0f7b9fab
--- /dev/null
+++ b/src/aig/llb/llbSched.c
@@ -0,0 +1,257 @@
+/**CFile****************************************************************
+
+ FileName [llb.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [BDD based reachability.]
+
+ Synopsis []
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: llb.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "llbInt.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Swaps two rows.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_MtrSwapColumns( Llb_Mtr_t * p, int iCol1, int iCol2 )
+{
+ Llb_Grp_t * pGemp;
+ char * pTemp;
+ int iTemp;
+ assert( iCol1 >= 0 && iCol1 < p->nCols );
+ assert( iCol2 >= 0 && iCol2 < p->nCols );
+ if ( iCol1 == iCol2 )
+ return;
+ assert( iCol1 != iCol2 );
+ // swap col groups
+ pGemp = p->pColGrps[iCol1];
+ p->pColGrps[iCol1] = p->pColGrps[iCol2];
+ p->pColGrps[iCol2] = pGemp;
+ // swap col vectors
+ pTemp = p->pMatrix[iCol1];
+ p->pMatrix[iCol1] = p->pMatrix[iCol2];
+ p->pMatrix[iCol2] = pTemp;
+ // swap col sums
+ iTemp = p->pColSums[iCol1];
+ p->pColSums[iCol1] = p->pColSums[iCol2];
+ p->pColSums[iCol2] = iTemp;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Find columns which brings as few vars as possible.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Llb_MtrFindBestColumn( Llb_Mtr_t * p, int iGrpStart )
+{
+ int Cost, Cost2, CostBest = ABC_INFINITY, Cost2Best = ABC_INFINITY;
+ int WeightCur, WeightBest = -ABC_INFINITY, iGrp, iGrpBest = -1;
+ int k, c, iVar, Counter;
+ // find partition that reduces partial product as much as possible
+ for ( iVar = 0; iVar < p->nRows - p->nFfs; iVar++ )
+ {
+ if ( p->pRowSums[iVar] < 2 )
+ continue;
+ // look at present variables that can be quantified
+ if ( !(p->pProdVars[iVar] == 1 && p->pProdNums[iVar] == 1) )
+ continue;
+ // check that it appears in one partition only
+ Counter = 0;
+ for ( c = iGrpStart; c < p->nCols-1; c++ )
+ if ( p->pMatrix[c][iVar] == 1 )
+ {
+ iGrp = c;
+ Counter++;
+ }
+ assert( Counter == 1 );
+ if ( Counter != 1 )
+ Abc_Print( -1, "Llb_MtrFindBestColumn() Internal error!\n" );
+ // find weight of this column
+ WeightCur = 0;
+ for ( k = 0; k < p->nRows; k++ )
+ {
+ // increase weight if variable k will be quantified from partial product
+ if ( p->pProdVars[k] == 1 && p->pMatrix[iGrp][k] == 1 && p->pProdNums[k] == 1 )
+ WeightCur += 2;
+ // decrease weight if variable k will be added to partial product
+ if ( p->pProdVars[k] == 0 && p->pMatrix[iGrp][k] == 1 )
+ WeightCur--;
+ }
+ if ( WeightCur > 0 && WeightBest < WeightCur )
+ {
+ WeightBest = WeightCur;
+ iGrpBest = iGrp;
+ }
+ }
+ if ( iGrpBest >= 0 )
+ return iGrpBest;
+ // could not find the group with any vars to quantify
+ // select the group that contains as few extra variables as possible
+ // if there is a tie, select variables that appear in less groups than others
+ for ( iGrp = iGrpStart; iGrp < p->nCols-1; iGrp++ )
+ {
+ Cost = Cost2 = 0;
+ for ( k = 0; k < p->nRows; k++ )
+ if ( p->pProdVars[k] == 0 && p->pMatrix[iGrp][k] == 1 )
+ {
+ Cost++;
+ Cost2 += p->pProdNums[k];
+ }
+ if ( CostBest > Cost ||
+ (CostBest == Cost && Cost2 > Cost2Best) )
+ {
+ CostBest = Cost;
+ Cost2Best = Cost2;
+ iGrpBest = iGrp;
+ }
+ }
+ return iGrpBest;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the number of variables that will be saved.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_MtrUseSelectedColumn( Llb_Mtr_t * p, int iCol )
+{
+ int iVar;
+ assert( iCol >= 1 && iCol < p->nCols - 1 );
+ for ( iVar = 0; iVar < p->nRows; iVar++ )
+ {
+ if ( p->pMatrix[iCol][iVar] == 0 )
+ continue;
+ if ( p->pProdVars[iVar] == 1 && p->pProdNums[iVar] == 1 )
+ {
+ p->pProdVars[iVar] = 0;
+ p->pProdNums[iVar] = 0;
+ continue;
+ }
+ if ( p->pProdVars[iVar] == 0 )
+ {
+ p->pProdVars[iVar] = 1;
+ p->pProdNums[iVar] = p->pRowSums[iVar];
+ }
+ p->pProdNums[iVar]--;
+ assert( p->pProdNums[iVar] >= 0 );
+ if ( p->pProdNums[iVar] < 0 )
+ Abc_Print( -1, "Llb_MtrUseSelectedColumn() Internal error!\n" );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Verify columns.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_MtrVerifyColumns( Llb_Mtr_t * p, int iGrpStart )
+{
+ int iVar, iGrp, Counter;
+ for ( iVar = 0; iVar < p->nRows; iVar++ )
+ {
+ if ( p->pProdVars[iVar] == 0 )
+ continue;
+ Counter = 0;
+ for ( iGrp = iGrpStart; iGrp < p->nCols; iGrp++ )
+ if ( p->pMatrix[iGrp][iVar] == 1 )
+ Counter++;
+ assert( Counter == p->pProdNums[iVar] );
+ if ( Counter != p->pProdNums[iVar] )
+ Abc_Print( -1, "Llb_MtrVerifyColumns(): Internal error.\n" );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Matrix reduce.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Llb_MtrSchedule( Llb_Mtr_t * p )
+{
+ int iGrp, iGrpBest, i;
+ // start partial product
+ for ( i = 0; i < p->nRows; i++ )
+ {
+ if ( i >= p->nPis && i < p->nPis + p->nFfs )
+ {
+ p->pProdVars[i] = 1;
+ p->pProdNums[i] = p->pRowSums[i] - 1;
+ }
+ else
+ {
+ p->pProdVars[i] = 0;
+ p->pProdNums[i] = p->pRowSums[i];
+ }
+ }
+ // order the partitions
+ Llb_MtrVerifyMatrix( p );
+ for ( iGrp = 1; iGrp < p->nCols-1; iGrp++ )
+ {
+ Llb_MtrVerifyColumns( p, iGrp );
+ iGrpBest = Llb_MtrFindBestColumn( p, iGrp );
+ Llb_MtrUseSelectedColumn( p, iGrpBest );
+ Llb_MtrSwapColumns( p, iGrp, iGrpBest );
+ }
+ Llb_MtrVerifyMatrix( p );
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/llb/module.make b/src/aig/llb/module.make
new file mode 100644
index 00000000..60b6ce07
--- /dev/null
+++ b/src/aig/llb/module.make
@@ -0,0 +1,11 @@
+SRC += src/aig/llb/llbCex.c \
+ src/aig/llb/llbCluster.c \
+ src/aig/llb/llbConstr.c \
+ src/aig/llb/llbCore.c \
+ src/aig/llb/llbHint.c \
+ src/aig/llb/llbMan.c \
+ src/aig/llb/llbMatrix.c \
+ src/aig/llb/llbPart.c \
+ src/aig/llb/llbPivot.c \
+ src/aig/llb/llbReach.c \
+ src/aig/llb/llbSched.c
diff --git a/src/aig/mem/mem.c b/src/aig/mem/mem.c
index 99d918e9..28d7e86e 100644
--- a/src/aig/mem/mem.c
+++ b/src/aig/mem/mem.c
@@ -22,9 +22,12 @@
#include <stdlib.h>
#include <string.h>
#include <assert.h>
-#include "abc_global.h"
+
#include "mem.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -36,7 +39,7 @@ struct Mem_Fixed_t_
int nEntriesAlloc; // the total number of entries allocated
int nEntriesUsed; // the number of entries in use
int nEntriesMax; // the max number of entries in use
- char * pEntriesFree; // the linked list of ABC_FREE entries
+ char * pEntriesFree; // the linked list of free entries
// this is where the memory is stored
int nChunkSize; // the size of one chunk
@@ -53,8 +56,8 @@ struct Mem_Flex_t_
{
// information about individual entries
int nEntriesUsed; // the number of entries allocated
- char * pCurrent; // the current pointer to ABC_FREE memory
- char * pEnd; // the first entry outside the ABC_FREE memory
+ char * pCurrent; // the current pointer to free memory
+ char * pEnd; // the first entry outside the free memory
// this is where the memory is stored
int nChunkSize; // the size of one chunk
@@ -164,7 +167,7 @@ char * Mem_FixedEntryFetch( Mem_Fixed_t * p )
char * pTemp;
int i;
- // check if there are still ABC_FREE entries
+ // check if there are still free entries
if ( p->nEntriesUsed == p->nEntriesAlloc )
{ // need to allocate more entries
assert( p->pEntriesFree == NULL );
@@ -193,7 +196,7 @@ char * Mem_FixedEntryFetch( Mem_Fixed_t * p )
p->nEntriesUsed++;
if ( p->nEntriesMax < p->nEntriesUsed )
p->nEntriesMax = p->nEntriesUsed;
- // return the first entry in the ABC_FREE entry list
+ // return the first entry in the free entry list
pTemp = p->pEntriesFree;
p->pEntriesFree = *((char **)pTemp);
return pTemp;
@@ -214,7 +217,7 @@ void Mem_FixedEntryRecycle( Mem_Fixed_t * p, char * pEntry )
{
// decrement the counter of used entries
p->nEntriesUsed--;
- // add the entry to the linked list of ABC_FREE entries
+ // add the entry to the linked list of free entries
*((char **)pEntry) = p->pEntriesFree;
p->pEntriesFree = pEntry;
}
@@ -248,7 +251,7 @@ void Mem_FixedRestart( Mem_Fixed_t * p )
}
// set the last link
*((char **)pTemp) = NULL;
- // set the ABC_FREE entry list
+ // set the free entry list
p->pEntriesFree = p->pChunks[0];
// set the correct statistics
p->nMemoryAlloc = p->nEntrySize * p->nChunkSize;
@@ -366,7 +369,7 @@ void Mem_FlexStop( Mem_Flex_t * p, int fVerbose )
char * Mem_FlexEntryFetch( Mem_Flex_t * p, int nBytes )
{
char * pTemp;
- // check if there are still ABC_FREE entries
+ // check if there are still free entries
if ( p->pCurrent == NULL || p->pCurrent + nBytes > p->pEnd )
{ // need to allocate more entries
if ( p->nChunks == p->nChunksAlloc )
@@ -597,3 +600,5 @@ int Mem_StepReadMemUsage( Mem_Step_t * p )
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/mem/mem.h b/src/aig/mem/mem.h
index d43e5fc3..15cb56fe 100644
--- a/src/aig/mem/mem.h
+++ b/src/aig/mem/mem.h
@@ -21,9 +21,10 @@
#ifndef __MEM_H__
#define __MEM_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include "abc_global.h"
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -59,9 +60,11 @@ extern char * Mem_StepEntryFetch( Mem_Step_t * p, int nBytes );
extern void Mem_StepEntryRecycle( Mem_Step_t * p, char * pEntry, int nBytes );
extern int Mem_StepReadMemUsage( Mem_Step_t * p );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/aig/mfx/mfx.h b/src/aig/mfx/mfx.h
index 09c4f039..9d2c6795 100644
--- a/src/aig/mfx/mfx.h
+++ b/src/aig/mfx/mfx.h
@@ -21,6 +21,7 @@
#ifndef __MFX_H__
#define __MFX_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -29,9 +30,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -68,10 +70,12 @@ struct Mfx_Par_t_
/*=== mfxCore.c ==========================================================*/
extern void Mfx_ParsDefault( Mfx_Par_t * pPars );
-
-#ifdef __cplusplus
-}
-#endif
+extern int Mfx_Perform( Nwk_Man_t * pNtk, Mfx_Par_t * pPars, If_Lib_t * pLutLib );
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/aig/mfx/mfxCore.c b/src/aig/mfx/mfxCore.c
index e0f6dd82..77f35580 100644
--- a/src/aig/mfx/mfxCore.c
+++ b/src/aig/mfx/mfxCore.c
@@ -21,6 +21,9 @@
#include "mfxInt.h"
#include "bar.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -158,7 +161,7 @@ clk = clock();
p->timeCnf += clock() - clk;
// create the SAT problem
clk = clock();
- p->pSat = Cnf_DataWriteIntoSolver( p->pCnf, 1, 0 );
+ p->pSat = (sat_solver *)Cnf_DataWriteIntoSolver( p->pCnf, 1, 0 );
if ( p->pSat == NULL )
return 0;
// solve the SAT problem
@@ -217,7 +220,7 @@ Vec_Int_t * Nwk_ManPowerEstimate( Nwk_Man_t * pNtk, int fProbOne )
pSwitching = (float *)vSwitching->pArray;
Nwk_ManForEachObj( pNtk, pObjAbc, i )
{
- if ( (pObjAig = Aig_Regular(pObjAbc->pCopy)) )
+ if ( (pObjAig = Aig_Regular((Aig_Obj_t *)pObjAbc->pCopy)) )
pProbability[pObjAbc->Id] = pSwitching[pObjAig->Id];
}
Vec_IntFree( vSwitching );
@@ -339,7 +342,7 @@ int Mfx_Perform( Nwk_Man_t * pNtk, Mfx_Par_t * pPars, If_Lib_t * pLutLib )
p->nTotConfLevel = 0;
p->nTimeOutsLevel = 0;
clk2 = clock();
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, vNodes, pObj, i )
{
if ( p->pPars->nDepthMax && pObj->Level > p->pPars->nDepthMax )
break;
@@ -386,3 +389,5 @@ int Mfx_Perform( Nwk_Man_t * pNtk, Mfx_Par_t * pPars, If_Lib_t * pLutLib )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/mfx/mfxDiv.c b/src/aig/mfx/mfxDiv.c
index 33f55ecb..35872da2 100644
--- a/src/aig/mfx/mfxDiv.c
+++ b/src/aig/mfx/mfxDiv.c
@@ -20,6 +20,9 @@
#include "mfxInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -201,7 +204,7 @@ Vec_Ptr_t * Mfx_ComputeDivisors( Mfx_Man_t * p, Nwk_Obj_t * pNode, float tArriva
// count the number of PIs
nTrueSupp = 0;
- Vec_PtrForEachEntry( vCone, pObj, k )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, vCone, pObj, k )
nTrueSupp += Nwk_ObjIsCi(pObj);
// printf( "%d(%d) ", Vec_PtrSize(p->vSupp), m );
@@ -221,7 +224,7 @@ Vec_Ptr_t * Mfx_ComputeDivisors( Mfx_Man_t * p, Nwk_Obj_t * pNode, float tArriva
// start collecting the divisors
vDivs = Vec_PtrAlloc( p->pPars->nDivMax );
- Vec_PtrForEachEntry( vCone, pObj, k )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, vCone, pObj, k )
{
if ( !Nwk_ObjIsTravIdPrevious(pObj) )
continue;
@@ -235,7 +238,7 @@ Vec_Ptr_t * Mfx_ComputeDivisors( Mfx_Man_t * p, Nwk_Obj_t * pNode, float tArriva
// explore the fanouts of already collected divisors
if ( Vec_PtrSize(vDivs) < p->pPars->nDivMax )
- Vec_PtrForEachEntry( vDivs, pObj, k )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, vDivs, pObj, k )
{
// consider fanouts of this node
Nwk_ObjForEachFanout( pObj, pFanout, f )
@@ -262,7 +265,7 @@ Vec_Ptr_t * Mfx_ComputeDivisors( Mfx_Man_t * p, Nwk_Obj_t * pNode, float tArriva
if ( m < Nwk_ObjFaninNum(pFanout) )
continue;
// make sure this divisor in not among the nodes
-// Vec_PtrForEachEntry( p->vNodes, pFanin, m )
+// Vec_PtrForEachEntry( Aig_Obj_t *, p->vNodes, pFanin, m )
// assert( pFanout != pFanin );
// add the node to the divisors
Vec_PtrPush( vDivs, pFanout );
@@ -278,7 +281,7 @@ Vec_Ptr_t * Mfx_ComputeDivisors( Mfx_Man_t * p, Nwk_Obj_t * pNode, float tArriva
}
// sort the divisors by level in the increasing order
- Vec_PtrSort( vDivs, Nwk_NodeCompareLevelsIncrease );
+ Vec_PtrSort( vDivs, (int (*)(void))Nwk_NodeCompareLevelsIncrease );
// add the fanins of the node
Nwk_ObjForEachFanin( pNode, pFanin, k )
@@ -301,3 +304,5 @@ Vec_Ptr_t * Mfx_ComputeDivisors( Mfx_Man_t * p, Nwk_Obj_t * pNode, float tArriva
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/mfx/mfxInt.h b/src/aig/mfx/mfxInt.h
index 4263724c..1fcf4e91 100644
--- a/src/aig/mfx/mfxInt.h
+++ b/src/aig/mfx/mfxInt.h
@@ -21,6 +21,7 @@
#ifndef __MFX_INT_H__
#define __MFX_INT_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -37,9 +38,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
#define MFX_FANIN_MAX 12
@@ -151,9 +153,11 @@ extern double Mfx_ConstraintRatio( Mfx_Man_t * p, Nwk_Obj_t * pNode );
extern Vec_Ptr_t * Mfx_ComputeRoots( Nwk_Obj_t * pNode, int nWinTfoMax, int nFanoutLimit );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/aig/mfx/mfxInter.c b/src/aig/mfx/mfxInter.c
index 3e1e3de2..2263398d 100644
--- a/src/aig/mfx/mfxInter.c
+++ b/src/aig/mfx/mfxInter.c
@@ -21,6 +21,9 @@
#include "mfxInt.h"
#include "kit.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -94,7 +97,7 @@ sat_solver * Mfx_CreateSolverResub( Mfx_Man_t * p, int * pCands, int nCands, int
// collect the outputs of the divisors
Vec_IntClear( p->vProjVars );
- Vec_PtrForEachEntryStart( p->pAigWin->vPos, pObjPo, i, Aig_ManPoNum(p->pAigWin) - Vec_PtrSize(p->vDivs) )
+ Vec_PtrForEachEntryStart( Aig_Obj_t *, p->pAigWin->vPos, pObjPo, i, Aig_ManPoNum(p->pAigWin) - Vec_PtrSize(p->vDivs) )
{
assert( p->pCnf->pVarNums[pObjPo->Id] >= 0 );
Vec_IntPush( p->vProjVars, p->pCnf->pVarNums[pObjPo->Id] );
@@ -229,7 +232,7 @@ unsigned * Mfx_InterplateTruth( Mfx_Man_t * p, int * pCands, int nCands, int fIn
return NULL;
}
// get the learned clauses
- pCnf = sat_solver_store_release( pSat );
+ pCnf = (Sto_Man_t *)sat_solver_store_release( pSat );
sat_solver_delete( pSat );
// set the global variables
@@ -329,7 +332,7 @@ Hop_Obj_t * Mfx_Interplate( Mfx_Man_t * p, int * pCands, int nCands )
return NULL;
}
// get the learned clauses
- pCnf = sat_solver_store_release( pSat );
+ pCnf = (Sto_Man_t *)sat_solver_store_release( pSat );
sat_solver_delete( pSat );
// set the global variables
@@ -359,3 +362,5 @@ Hop_Obj_t * Mfx_Interplate( Mfx_Man_t * p, int * pCands, int nCands )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/mfx/mfxMan.c b/src/aig/mfx/mfxMan.c
index 2af3d573..9d9994bf 100644
--- a/src/aig/mfx/mfxMan.c
+++ b/src/aig/mfx/mfxMan.c
@@ -20,6 +20,9 @@
#include "mfxInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -186,3 +189,5 @@ void Mfx_ManStop( Mfx_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/mfx/mfxResub.c b/src/aig/mfx/mfxResub.c
index a9ed23a0..83673661 100644
--- a/src/aig/mfx/mfxResub.c
+++ b/src/aig/mfx/mfxResub.c
@@ -20,6 +20,9 @@
#include "mfxInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -46,7 +49,7 @@ void Mfx_UpdateNetwork( Mfx_Man_t * p, Nwk_Obj_t * pObj, Vec_Ptr_t * vFanins, Ho
// create the new node
pObjNew = Nwk_ManCreateNode( pObj->pMan, Vec_PtrSize(vFanins), Nwk_ObjFanoutNum(pObj) );
pObjNew->pFunc = pFunc;
- Vec_PtrForEachEntry( vFanins, pFanin, k )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, vFanins, pFanin, k )
Nwk_ObjAddFanin( pObjNew, pFanin );
// replace the old node by the new node
Nwk_ManUpdate( pObj, pObjNew, p->vLevels );
@@ -110,7 +113,7 @@ int Mfx_TryResubOnce( Mfx_Man_t * p, int * pCands, int nCands )
// store the counter-example
Vec_IntForEachEntry( p->vProjVars, iVar, i )
{
- pData = Vec_PtrEntry( p->vDivCexes, i );
+ pData = (unsigned *)Vec_PtrEntry( p->vDivCexes, i );
if ( !sat_solver_var_value( p->pSat, iVar ) ) // remove 0s!!!
{
assert( Aig_InfoHasBit(pData, p->nCexes) );
@@ -213,7 +216,7 @@ p->timeInt += clock() - clk;
printf( "%3d: %2d ", p->nCexes, iVar );
for ( i = 0; i < Vec_PtrSize(p->vDivs); i++ )
{
- pData = Vec_PtrEntry( p->vDivCexes, i );
+ pData = (unsigned *)Vec_PtrEntry( p->vDivCexes, i );
printf( "%d", Aig_InfoHasBit(pData, p->nCexes-1) );
}
printf( "\n" );
@@ -226,12 +229,12 @@ p->timeInt += clock() - clk;
{
if ( p->pPars->fPower )
{
- Nwk_Obj_t * pDiv = Vec_PtrEntry(p->vDivs, iVar);
+ Nwk_Obj_t * pDiv = (Nwk_Obj_t *)Vec_PtrEntry(p->vDivs, iVar);
// only accept the divisor if it is "cool"
if ( pProbab[Nwk_ObjId(pDiv)] >= 0.2 )
continue;
}
- pData = Vec_PtrEntry( p->vDivCexes, iVar );
+ pData = (unsigned *)Vec_PtrEntry( p->vDivCexes, iVar );
for ( w = 0; w < nWords; w++ )
if ( pData[w] != ~0 )
break;
@@ -356,7 +359,7 @@ p->timeInt += clock() - clk;
printf( "%3d: %2d %2d ", p->nCexes, iVar, iVar2 );
for ( i = 0; i < Vec_PtrSize(p->vDivs); i++ )
{
- pData = Vec_PtrEntry( p->vDivCexes, i );
+ pData = (unsigned *)Vec_PtrEntry( p->vDivCexes, i );
printf( "%d", Aig_InfoHasBit(pData, p->nCexes-1) );
}
printf( "\n" );
@@ -368,10 +371,10 @@ p->timeInt += clock() - clk;
fBreak = 0;
for ( iVar = 1; iVar < Vec_PtrSize(p->vDivs)-Nwk_ObjFaninNum(pNode); iVar++ )
{
- pData = Vec_PtrEntry( p->vDivCexes, iVar );
+ pData = (unsigned *)Vec_PtrEntry( p->vDivCexes, iVar );
for ( iVar2 = 0; iVar2 < iVar; iVar2++ )
{
- pData2 = Vec_PtrEntry( p->vDivCexes, iVar2 );
+ pData2 = (unsigned *)Vec_PtrEntry( p->vDivCexes, iVar2 );
for ( w = 0; w < nWords; w++ )
if ( (pData[w] | pData2[w]) != ~0 )
break;
@@ -559,3 +562,5 @@ int Mfx_ResubNode2( Mfx_Man_t * p, Nwk_Obj_t * pNode )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/mfx/mfxSat.c b/src/aig/mfx/mfxSat.c
index ce8d580b..dc4cd862 100644
--- a/src/aig/mfx/mfxSat.c
+++ b/src/aig/mfx/mfxSat.c
@@ -20,6 +20,9 @@
#include "mfxInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -90,7 +93,7 @@ int Mfx_SolveSat( Mfx_Man_t * p, Nwk_Obj_t * pNode )
int RetValue, i;
// collect projection variables
Vec_IntClear( p->vProjVars );
- Vec_PtrForEachEntryStart( p->pAigWin->vPos, pObjPo, i, Aig_ManPoNum(p->pAigWin) - Nwk_ObjFaninNum(pNode) )
+ Vec_PtrForEachEntryStart( Aig_Obj_t *, p->pAigWin->vPos, pObjPo, i, Aig_ManPoNum(p->pAigWin) - Nwk_ObjFaninNum(pNode) )
{
assert( p->pCnf->pVarNums[pObjPo->Id] >= 0 );
Vec_IntPush( p->vProjVars, p->pCnf->pVarNums[pObjPo->Id] );
@@ -138,3 +141,5 @@ int Mfx_SolveSat( Mfx_Man_t * p, Nwk_Obj_t * pNode )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/mfx/mfxStrash.c b/src/aig/mfx/mfxStrash.c
index 5cb6452f..f750523d 100644
--- a/src/aig/mfx/mfxStrash.c
+++ b/src/aig/mfx/mfxStrash.c
@@ -20,6 +20,9 @@
#include "mfxInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -84,7 +87,7 @@ void Nwk_ConvertHopToAig( Nwk_Obj_t * pObjOld, Aig_Man_t * pMan )
Hop_ManPi(pHopMan, i)->pData = pFanin->pCopy;
// construct the AIG
Nwk_ConvertHopToAig_rec( Hop_Regular(pRoot), pMan );
- pObjOld->pCopy = (Nwk_Obj_t *)Aig_NotCond( Hop_Regular(pRoot)->pData, Hop_IsComplement(pRoot) );
+ pObjOld->pCopy = (Nwk_Obj_t *)Aig_NotCond( (Aig_Obj_t *)Hop_Regular(pRoot)->pData, Hop_IsComplement(pRoot) );
Hop_ConeUnmark_rec( Hop_Regular(pRoot) );
// assign the fanin nodes
@@ -92,7 +95,7 @@ void Nwk_ConvertHopToAig( Nwk_Obj_t * pObjOld, Aig_Man_t * pMan )
Hop_ManPi(pHopMan, i)->pData = pFanin->pNext;
// construct the AIG
Nwk_ConvertHopToAig_rec( Hop_Regular(pRoot), pMan );
- pObjOld->pNext = (Nwk_Obj_t *)Aig_NotCond( Hop_Regular(pRoot)->pData, Hop_IsComplement(pRoot) );
+ pObjOld->pNext = (Nwk_Obj_t *)Aig_NotCond( (Aig_Obj_t *)Hop_Regular(pRoot)->pData, Hop_IsComplement(pRoot) );
Hop_ConeUnmark_rec( Hop_Regular(pRoot) );
}
@@ -113,19 +116,19 @@ Aig_Obj_t * Mfx_ConstructAig_rec( Mfx_Man_t * p, Nwk_Obj_t * pNode, Aig_Man_t *
Nwk_Obj_t * pObj;
int i;
// assign AIG nodes to the leaves
- Vec_PtrForEachEntry( p->vSupp, pObj, i )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, p->vSupp, pObj, i )
pObj->pCopy = pObj->pNext = (Nwk_Obj_t *)Aig_ObjCreatePi( pMan );
// strash intermediate nodes
Nwk_ManIncrementTravId( pNode->pMan );
- Vec_PtrForEachEntry( p->vNodes, pObj, i )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, p->vNodes, pObj, i )
{
Nwk_ConvertHopToAig( pObj, pMan );
if ( pObj == pNode )
- pObj->pNext = Aig_Not(pObj->pNext);
+ pObj->pNext = Aig_Not((Aig_Obj_t *)pObj->pNext);
}
// create the observability condition
pRoot = Aig_ManConst0(pMan);
- Vec_PtrForEachEntry( p->vRoots, pObj, i )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, p->vRoots, pObj, i )
{
pExor = Aig_Exor( pMan, (Aig_Obj_t *)pObj->pCopy, (Aig_Obj_t *)pObj->pNext );
pRoot = Aig_Or( pMan, pRoot, pExor );
@@ -148,19 +151,19 @@ Aig_Obj_t * Mfx_ConstructCare_rec( Aig_Man_t * pCare, Aig_Obj_t * pObj, Aig_Man_
{
Aig_Obj_t * pObj0, * pObj1;
if ( Aig_ObjIsTravIdCurrent( pCare, pObj ) )
- return pObj->pData;
+ return (Aig_Obj_t *)pObj->pData;
Aig_ObjSetTravIdCurrent( pCare, pObj );
if ( Aig_ObjIsPi(pObj) )
- return pObj->pData = NULL;
+ return (Aig_Obj_t *)(pObj->pData = NULL);
pObj0 = Mfx_ConstructCare_rec( pCare, Aig_ObjFanin0(pObj), pMan );
if ( pObj0 == NULL )
- return pObj->pData = NULL;
+ return (Aig_Obj_t *)(pObj->pData = NULL);
pObj1 = Mfx_ConstructCare_rec( pCare, Aig_ObjFanin1(pObj), pMan );
if ( pObj1 == NULL )
- return pObj->pData = NULL;
+ return (Aig_Obj_t *)(pObj->pData = NULL);
pObj0 = Aig_NotCond( pObj0, Aig_ObjFaninC0(pObj) );
pObj1 = Aig_NotCond( pObj1, Aig_ObjFaninC1(pObj) );
- return pObj->pData = Aig_And( pMan, pObj0, pObj1 );
+ return (Aig_Obj_t *)(pObj->pData = Aig_And( pMan, pObj0, pObj1 ));
}
/**Function*************************************************************
@@ -213,16 +216,16 @@ Aig_Man_t * Mfx_ConstructAig( Mfx_Man_t * p, Nwk_Obj_t * pNode )
{
// mark the care set
Aig_ManIncrementTravId( p->pCare );
- Vec_PtrForEachEntry( p->vSupp, pFanin, i )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, p->vSupp, pFanin, i )
{
pPi = Aig_ManPi( p->pCare, pFanin->PioId );
Aig_ObjSetTravIdCurrent( p->pCare, pPi );
pPi->pData = pFanin->pCopy;
}
// construct the constraints
- Vec_PtrForEachEntry( p->vSupp, pFanin, i )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, p->vSupp, pFanin, i )
{
- vOuts = Vec_PtrEntry( p->vSuppsInv, pFanin->PioId );
+ vOuts = (Vec_Int_t *)Vec_PtrEntry( p->vSuppsInv, pFanin->PioId );
Vec_IntForEachEntry( vOuts, iOut, k )
{
pPo = Aig_ManPo( p->pCare, iOut );
@@ -258,7 +261,7 @@ Aig_Man_t * Mfx_ConstructAig( Mfx_Man_t * p, Nwk_Obj_t * pNode )
pObjAig = (Aig_Obj_t *)pNode->pCopy;
Aig_ObjCreatePo( pMan, pObjAig );
// construct the divisors
- Vec_PtrForEachEntry( p->vDivs, pFanin, i )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, p->vDivs, pFanin, i )
{
pObjAig = (Aig_Obj_t *)pFanin->pCopy;
Aig_ObjCreatePo( pMan, pObjAig );
@@ -300,7 +303,7 @@ Aig_Man_t * Nwk_AigForConstraints( Mfx_Man_t * p, Nwk_Obj_t * pNode )
pMan = Aig_ManStart( 1000 );
// mark the care set
Aig_ManIncrementTravId( p->pCare );
- Vec_PtrForEachEntry( p->vSupp, pFanin, i )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, p->vSupp, pFanin, i )
{
pPi = Aig_ManPi( p->pCare, pFanin->PioId );
Aig_ObjSetTravIdCurrent( p->pCare, pPi );
@@ -308,9 +311,9 @@ Aig_Man_t * Nwk_AigForConstraints( Mfx_Man_t * p, Nwk_Obj_t * pNode )
}
// construct the constraints
pObjRoot = Aig_ManConst1(pMan);
- Vec_PtrForEachEntry( p->vSupp, pFanin, i )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, p->vSupp, pFanin, i )
{
- vOuts = Vec_PtrEntry( p->vSuppsInv, pFanin->PioId );
+ vOuts = (Vec_Int_t *)Vec_PtrEntry( p->vSuppsInv, pFanin->PioId );
Vec_IntForEachEntry( vOuts, iOut, k )
{
pPo = Aig_ManPo( p->pCare, iOut );
@@ -337,3 +340,5 @@ Aig_Man_t * Nwk_AigForConstraints( Mfx_Man_t * p, Nwk_Obj_t * pNode )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/mfx/mfxWin.c b/src/aig/mfx/mfxWin.c
index e84a9b90..7cb3c53d 100644
--- a/src/aig/mfx/mfxWin.c
+++ b/src/aig/mfx/mfxWin.c
@@ -20,6 +20,9 @@
#include "mfxInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -110,3 +113,5 @@ Vec_Ptr_t * Mfx_ComputeRoots( Nwk_Obj_t * pNode, int nWinTfoMax, int nFanoutLimi
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/mfx/mfx_.c b/src/aig/mfx/mfx_.c
index 32caf7ff..2682fa42 100644
--- a/src/aig/mfx/mfx_.c
+++ b/src/aig/mfx/mfx_.c
@@ -20,6 +20,9 @@
#include "mfsInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -45,3 +48,5 @@
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ntl/ntl.h b/src/aig/ntl/ntl.h
index 5407fcf8..c0d701e0 100644
--- a/src/aig/ntl/ntl.h
+++ b/src/aig/ntl/ntl.h
@@ -21,6 +21,7 @@
#ifndef __NTL_H__
#define __NTL_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -33,15 +34,12 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+ABC_NAMESPACE_HEADER_START
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
-typedef struct Ntl_Man_t_ Ntl_Man_t;
typedef struct Ntl_Mod_t_ Ntl_Mod_t;
typedef struct Ntl_Reg_t_ Ntl_Reg_t;
typedef struct Ntl_Obj_t_ Ntl_Obj_t;
@@ -144,7 +142,7 @@ struct Ntl_Obj_t_
unsigned Id : 28; // object ID
int nFanins; // the number of fanins
int nFanouts; // the number of fanouts
-// int Reset; // reset of the flop
+ int Reset; // reset of the flop
union { // functionality
Ntl_Mod_t * pImplem; // model (for boxes)
char * pSop; // SOP (for logic nodes)
@@ -165,7 +163,7 @@ struct Ntl_Net_t_
union {
void * pCopy2; // the copy of this object
float dTemp; // other data
-// int iTemp; // other data
+ int iTemp; // other data
};
Ntl_Obj_t * pDriver; // driver of the net
unsigned NetId : 27; // unique ID of the net
@@ -254,16 +252,16 @@ static inline int Ntl_ObjIsSeqRoot( Ntl_Obj_t * p ) { return Ntl_O
#define Ntl_ManForEachModel( p, pMod, i ) \
for ( i = 0; (i < Vec_PtrSize(p->vModels)) && (((pMod) = (Ntl_Mod_t*)Vec_PtrEntry(p->vModels, i)), 1); i++ )
#define Ntl_ManForEachCiNet( p, pNet, i ) \
- Vec_PtrForEachEntry( p->vCis, pNet, i )
+ Vec_PtrForEachEntry( Ntl_Net_t *, p->vCis, pNet, i )
#define Ntl_ManForEachCoNet( p, pNet, i ) \
- Vec_PtrForEachEntry( p->vCos, pNet, i )
+ Vec_PtrForEachEntry( Ntl_Net_t *, p->vCos, pNet, i )
#define Ntl_ModelForEachPi( pNwk, pObj, i ) \
for ( i = 0; (i < Vec_PtrSize(pNwk->vPis)) && (((pObj) = (Ntl_Obj_t*)Vec_PtrEntry(pNwk->vPis, i)), 1); i++ )
#define Ntl_ModelForEachPo( pNwk, pObj, i ) \
for ( i = 0; (i < Vec_PtrSize(pNwk->vPos)) && (((pObj) = (Ntl_Obj_t*)Vec_PtrEntry(pNwk->vPos, i)), 1); i++ )
#define Ntl_ModelForEachNet( pNwk, pNet, i ) \
- Vec_PtrForEachEntry( pNwk->vNets, pNet, i ) \
+ Vec_PtrForEachEntry( Ntl_Net_t *, pNwk->vNets, pNet, i ) \
if ( pNet == NULL ) {} else
#define Ntl_ModelForEachObj( pNwk, pObj, i ) \
for ( i = 0; (i < Vec_PtrSize(pNwk->vObjs)) && (((pObj) = (Ntl_Obj_t*)Vec_PtrEntry(pNwk->vObjs, i)), 1); i++ ) \
@@ -365,7 +363,7 @@ extern ABC_DLL Ntl_Obj_t * Ntl_ModelCreateBox( Ntl_Mod_t * pModel, int nFani
extern ABC_DLL Ntl_Obj_t * Ntl_ModelDupObj( Ntl_Mod_t * pModel, Ntl_Obj_t * pOld );
extern ABC_DLL Ntl_Obj_t * Ntl_ModelCreatePiWithName( Ntl_Mod_t * pModel, char * pName );
extern ABC_DLL char * Ntl_ManStoreName( Ntl_Man_t * p, char * pName );
-extern ABC_DLL char * Ntl_ManStoreSop( Aig_MmFlex_t * pMan, char * pSop );
+extern ABC_DLL char * Ntl_ManStoreSop( Aig_MmFlex_t * pMan, const char * pSop );
extern ABC_DLL char * Ntl_ManStoreFileName( Ntl_Man_t * p, char * pFileName );
extern ABC_DLL int Ntl_ManObjWhichFanout( Ntl_Obj_t * pNode, Ntl_Net_t * pFanout );
/*=== ntlSweep.c ==========================================================*/
@@ -387,11 +385,12 @@ extern ABC_DLL Ntl_Mod_t * Ntl_ManFindModel( Ntl_Man_t * p, const char * pNa
/*=== ntlTime.c ==========================================================*/
extern ABC_DLL Tim_Man_t * Ntl_ManCreateTiming( Ntl_Man_t * p );
/*=== ntlReadBlif.c ==========================================================*/
-extern ABC_DLL Ntl_Man_t * Ioa_ReadBlif( char * pFileName, int fCheck );
+extern ABC_DLL Ntl_Man_t * Ntl_ManReadBlif( char * pFileName, int fCheck );
/*=== ntlWriteBlif.c ==========================================================*/
-extern ABC_DLL void Ioa_WriteBlif( Ntl_Man_t * p, char * pFileName );
-extern ABC_DLL void Ioa_WriteBlifLogic( Nwk_Man_t * pNtk, Ntl_Man_t * p, char * pFileName );
+extern ABC_DLL void Ntl_ManWriteBlif( Ntl_Man_t * p, char * pFileName );
+extern ABC_DLL void Ntl_WriteBlifLogic( Nwk_Man_t * pNtk, Ntl_Man_t * p, char * pFileName );
/*=== ntlUtil.c ==========================================================*/
+extern ABC_DLL int Ntl_FileIsType( char * pFileName, char * pS1, char * pS2, char * pS3 );
extern ABC_DLL int Ntl_ModelGetFaninMax( Ntl_Mod_t * pRoot );
extern ABC_DLL Ntl_Net_t * Ntl_ModelFindSimpleNet( Ntl_Net_t * pNetCo );
extern ABC_DLL int Ntl_ManCountSimpleCoDrivers( Ntl_Man_t * p );
@@ -413,9 +412,11 @@ extern ABC_DLL int Ntl_ModelCheckNetsAreNotMarked( Ntl_Mod_t * pMode
extern ABC_DLL void Ntl_ModelClearNets( Ntl_Mod_t * pModel );
extern ABC_DLL void Ntl_ManRemoveUselessNets( Ntl_Man_t * p );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/aig/ntl/ntlCheck.c b/src/aig/ntl/ntlCheck.c
index 82ef388b..7aecf878 100644
--- a/src/aig/ntl/ntlCheck.c
+++ b/src/aig/ntl/ntlCheck.c
@@ -21,6 +21,9 @@
#include "ntl.h"
#include "aig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -319,7 +322,7 @@ void Ntl_ModelFixNonDrivenNets( Ntl_Mod_t * pModel )
if ( Vec_PtrSize(vNets) > 0 )
{
printf( "Warning: Constant-0 drivers added to %d non-driven nets in network \"%s\": ", Vec_PtrSize(vNets), pModel->pName );
- Vec_PtrForEachEntry( vNets, pNet, i )
+ Vec_PtrForEachEntry( Ntl_Net_t *, vNets, pNet, i )
{
printf( "%s%s", (i? ", ": ""), pNet->pName );
if ( i == 3 )
@@ -372,3 +375,5 @@ void Ntl_ModelTransformLatches( Ntl_Mod_t * pModel )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ntl/ntlCore.c b/src/aig/ntl/ntlCore.c
index b170cdad..c09bac0f 100644
--- a/src/aig/ntl/ntlCore.c
+++ b/src/aig/ntl/ntlCore.c
@@ -20,6 +20,10 @@
#include "ntl.h"
#include "dch.h"
+#include "dar.h"
+
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -42,10 +46,11 @@
***********************************************************************/
Aig_Man_t * Ntl_ManPerformChoicing( Aig_Man_t * pAig, int fBalance, int fUpdateLevel, int fConstruct, int nConfMax, int nLevelMax, int fVerbose )
{
- extern Aig_Man_t * Dar_ManBalance( Aig_Man_t * pAig, int fUpdateLevel );
- extern Aig_Man_t * Dar_ManCompress( Aig_Man_t * pAig, int fBalance, int fUpdateLevel, int fPower, int fVerbose );
- extern Aig_Man_t * Dar_ManChoice( Aig_Man_t * pAig, int fBalance, int fUpdateLevel, int fConstruct, int nConfMax, int nLevelMax, int fVerbose );
+// extern Aig_Man_t * Dar_ManBalance( Aig_Man_t * pAig, int fUpdateLevel );
+// extern Aig_Man_t * Dar_ManCompress( Aig_Man_t * pAig, int fBalance, int fUpdateLevel, int fPower, int fVerbose );
+// extern Aig_Man_t * Dar_ManChoice( Aig_Man_t * pAig, int fBalance, int fUpdateLevel, int fConstruct, int nConfMax, int nLevelMax, int fVerbose );
Aig_Man_t * pTemp;
+
// perform synthesis
//printf( "Pre-synthesis AIG: " );
//Aig_ManPrintStats( pAig );
@@ -54,6 +59,7 @@ Aig_Man_t * Ntl_ManPerformChoicing( Aig_Man_t * pAig, int fBalance, int fUpdateL
pTemp = Dar_ManChoice( pAig, fBalance, fUpdateLevel, fConstruct, nConfMax, nLevelMax, fVerbose );
//printf( "Post-synthesis AIG: " );
//Aig_ManPrintStats( pTemp );
+
return pTemp;
}
@@ -70,8 +76,22 @@ Aig_Man_t * Ntl_ManPerformChoicing( Aig_Man_t * pAig, int fBalance, int fUpdateL
***********************************************************************/
Aig_Man_t * Ntl_ManPerformChoicingNew( Aig_Man_t * pAig, Dch_Pars_t * pPars )
{
- extern Aig_Man_t * Dar_ManChoiceNew( Aig_Man_t * pAig, Dch_Pars_t * pPars );
- return Dar_ManChoiceNew( pAig, pPars );
+// extern Aig_Man_t * Dar_ManChoiceNew( Aig_Man_t * pAig, Dch_Pars_t * pPars );
+ Aig_Man_t * pTemp;
+/*
+ Aig_Obj_t * pObj;
+ int i;
+ Aig_ManForEachPi( pAig, pObj, i )
+ printf( "%d ", pObj->Level );
+ printf( "\n" );
+*/
+ pTemp = Dar_ManChoiceNew( pAig, pPars );
+/*
+ Aig_ManForEachPi( pTemp, pObj, i )
+ printf( "%d ", pObj->Level );
+ printf( "\n" );
+*/
+ return pTemp;
}
/**Function*************************************************************
@@ -128,3 +148,5 @@ int Ntl_ManInsertTestIf( Ntl_Man_t * p, Aig_Man_t * pAig )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ntl/ntlEc.c b/src/aig/ntl/ntlEc.c
index 0d41006e..d82ac71e 100644
--- a/src/aig/ntl/ntlEc.c
+++ b/src/aig/ntl/ntlEc.c
@@ -19,6 +19,10 @@
***********************************************************************/
#include "ntl.h"
+#include "saig.h"
+
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -273,8 +277,8 @@ void Ntl_ManPrepareCec( char * pFileName1, char * pFileName2, Aig_Man_t ** ppAig
{
Ntl_Man_t * pMan1, * pMan2;
// read the netlists
- pMan1 = Ioa_ReadBlif( pFileName1, 1 );
- pMan2 = Ioa_ReadBlif( pFileName2, 1 );
+ pMan1 = Ntl_ManReadBlif( pFileName1, 1 );
+ pMan2 = Ntl_ManReadBlif( pFileName2, 1 );
if ( !pMan1 || !pMan2 )
{
if ( pMan1 ) Ntl_ManFree( pMan1 );
@@ -301,14 +305,14 @@ void Ntl_ManPrepareCec( char * pFileName1, char * pFileName2, Aig_Man_t ** ppAig
***********************************************************************/
Aig_Man_t * Ntl_ManPrepareSec( char * pFileName1, char * pFileName2 )
{
- extern Aig_Man_t * Saig_ManCreateMiter( Aig_Man_t * p1, Aig_Man_t * p2, int Oper );
+// extern Aig_Man_t * Saig_ManCreateMiter( Aig_Man_t * p1, Aig_Man_t * p2, int Oper );
Aig_Man_t * pAig1, * pAig2, * pAig;
Ntl_Man_t * pMan1, * pMan2;
Ntl_Mod_t * pModel1, * pModel2;
// read the netlists
- pMan1 = Ioa_ReadBlif( pFileName1, 1 );
- pMan2 = Ioa_ReadBlif( pFileName2, 1 );
+ pMan1 = Ntl_ManReadBlif( pFileName1, 1 );
+ pMan2 = Ntl_ManReadBlif( pFileName2, 1 );
if ( !pMan1 || !pMan2 )
{
if ( pMan1 ) Ntl_ManFree( pMan1 );
@@ -366,3 +370,5 @@ Aig_Man_t * Ntl_ManPrepareSec( char * pFileName1, char * pFileName2 )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ntl/ntlExtract.c b/src/aig/ntl/ntlExtract.c
index ae278585..a6268b2c 100644
--- a/src/aig/ntl/ntlExtract.c
+++ b/src/aig/ntl/ntlExtract.c
@@ -22,6 +22,9 @@
#include "dec.h"
#include "kit.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -59,9 +62,9 @@ Aig_Obj_t * Ntl_ConvertSopToAigInternal( Aig_Man_t * pMan, Ntl_Obj_t * pNode, ch
{
pNet = Ntl_ObjFanin( pNode, i );
if ( Value == '1' )
- pAnd = Aig_And( pMan, pAnd, pNet->pCopy );
+ pAnd = Aig_And( pMan, pAnd, (Aig_Obj_t *)pNet->pCopy );
else if ( Value == '0' )
- pAnd = Aig_And( pMan, pAnd, Aig_Not(pNet->pCopy) );
+ pAnd = Aig_And( pMan, pAnd, Aig_Not((Aig_Obj_t *)pNet->pCopy) );
}
// add to the sum of cubes
pSum = Aig_Or( pMan, pSum, pAnd );
@@ -93,16 +96,16 @@ Aig_Obj_t * Ntl_GraphToNetworkAig( Aig_Man_t * pMan, Dec_Graph_t * pGraph )
return Aig_NotCond( Aig_ManConst1(pMan), Dec_GraphIsComplement(pGraph) );
// check for a literal
if ( Dec_GraphIsVar(pGraph) )
- return Aig_NotCond( Dec_GraphVar(pGraph)->pFunc, Dec_GraphIsComplement(pGraph) );
+ return Aig_NotCond( (Aig_Obj_t *)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 );
+ pAnd0 = Aig_NotCond( (Aig_Obj_t *)Dec_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl );
+ pAnd1 = Aig_NotCond( (Aig_Obj_t *)Dec_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl );
pNode->pFunc = Aig_And( pMan, pAnd0, pAnd1 );
}
// complement the result if necessary
- return Aig_NotCond( pNode->pFunc, Dec_GraphIsComplement(pGraph) );
+ return Aig_NotCond( (Aig_Obj_t *)pNode->pFunc, Dec_GraphIsComplement(pGraph) );
}
/**Function*************************************************************
@@ -183,16 +186,16 @@ int Ntl_ManExtract_rec( Ntl_Man_t * p, Ntl_Net_t * pNet )
Vec_IntPush( p->vBox1Cios, Aig_ManPoNum(p->pAig) );
Ntl_ObjForEachFanin( pObj, pNetFanin, i )
{
- LevelCur = Aig_ObjLevel( Aig_Regular(pNetFanin->pCopy) );
+ LevelCur = Aig_ObjLevel( Aig_Regular((Aig_Obj_t *)pNetFanin->pCopy) );
LevelMax = ABC_MAX( LevelMax, LevelCur );
Vec_PtrPush( p->vCos, pNetFanin );
- Aig_ObjCreatePo( p->pAig, pNetFanin->pCopy );
+ Aig_ObjCreatePo( p->pAig, (Aig_Obj_t *)pNetFanin->pCopy );
}
Ntl_ObjForEachFanout( pObj, pNetFanin, i )
{
Vec_PtrPush( p->vCis, pNetFanin );
pNetFanin->pCopy = Aig_ObjCreatePi( p->pAig );
- Aig_ObjSetLevel( pNetFanin->pCopy, LevelMax + 1 );
+ Aig_ObjSetLevel( (Aig_Obj_t *)pNetFanin->pCopy, LevelMax + 1 );
}
}
Vec_PtrPush( p->vVisNodes, pObj );
@@ -264,7 +267,7 @@ Aig_Man_t * Ntl_ManExtract( Ntl_Man_t * p )
return 0;
}
Vec_PtrPush( p->vCos, pNet );
- Aig_ObjCreatePo( p->pAig, pNet->pCopy );
+ Aig_ObjCreatePo( p->pAig, (Aig_Obj_t *)pNet->pCopy );
}
}
// visit dangling boxes
@@ -306,9 +309,9 @@ Aig_Man_t * Ntl_ManExtract( Ntl_Man_t * p )
SeeAlso []
***********************************************************************/
-int Ntl_ManCollapseBoxComb_rec( Ntl_Man_t * p, Ntl_Obj_t * pBox, int fSeq )
+int Ntl_ManCollapseBoxComb_rec( Ntl_Man_t * p, Ntl_Obj_t * pBox )
{
- extern int Ntl_ManCollapse_rec( Ntl_Man_t * p, Ntl_Net_t * pNet, int fSeq );
+ extern int Ntl_ManCollapse_rec( Ntl_Man_t * p, Ntl_Net_t * pNet );
Ntl_Mod_t * pModel = pBox->pImplem;
Ntl_Obj_t * pObj;
Ntl_Net_t * pNet, * pNetBox;
@@ -329,7 +332,7 @@ int Ntl_ManCollapseBoxComb_rec( Ntl_Man_t * p, Ntl_Obj_t * pBox, int fSeq )
Ntl_ModelForEachPo( pModel, pObj, i )
{
pNet = Ntl_ObjFanin0(pObj);
- if ( !Ntl_ManCollapse_rec( p, pNet, fSeq ) )
+ if ( !Ntl_ManCollapse_rec( p, pNet ) )
return 0;
pNetBox = Ntl_ObjFanout( pBox, i );
pNetBox->pCopy = pNet->pCopy;
@@ -348,9 +351,9 @@ int Ntl_ManCollapseBoxComb_rec( Ntl_Man_t * p, Ntl_Obj_t * pBox, int fSeq )
SeeAlso []
***********************************************************************/
-int Ntl_ManCollapseBoxSeq1_rec( Ntl_Man_t * p, Ntl_Obj_t * pBox, int fSeq )
+int Ntl_ManCollapseBoxSeq1_rec( Ntl_Man_t * p, Ntl_Obj_t * pBox )
{
- extern int Ntl_ManCollapse_rec( Ntl_Man_t * p, Ntl_Net_t * pNet, int fSeq );
+ extern int Ntl_ManCollapse_rec( Ntl_Man_t * p, Ntl_Net_t * pNet );
Ntl_Mod_t * pModel = pBox->pImplem;
Ntl_Obj_t * pObj;
Ntl_Net_t * pNet, * pNetBox;
@@ -365,18 +368,18 @@ int Ntl_ManCollapseBoxSeq1_rec( Ntl_Man_t * p, Ntl_Obj_t * pBox, int fSeq )
{
pNet = Ntl_ObjFanout0(pObj);
pNet->pCopy = Aig_ObjCreatePi( p->pAig );
- if ( fSeq && Ntl_ObjIsInit1( pObj ) )
- pNet->pCopy = Aig_Not(pNet->pCopy);
+ if ( Ntl_ObjIsInit1( pObj ) )
+ pNet->pCopy = Aig_Not((Aig_Obj_t *)pNet->pCopy);
pNet->nVisits = 2;
// remember the class of this register
Vec_IntPush( p->vRegClasses, p->pNal ? pBox->iTemp : pObj->LatchId.regClass );
-// Vec_IntPush( p->vRstClasses, p->pNal ? pBox->Reset : -1 );
+ Vec_IntPush( p->vRstClasses, p->pNal ? pBox->Reset : -1 );
}
// compute AIG for the internal nodes
Ntl_ModelForEachPo( pModel, pObj, i )
{
pNet = Ntl_ObjFanin0(pObj);
- if ( !Ntl_ManCollapse_rec( p, pNet, fSeq ) )
+ if ( !Ntl_ManCollapse_rec( p, pNet ) )
return 0;
pNetBox = Ntl_ObjFanout( pBox, i );
pNetBox->pCopy = pNet->pCopy;
@@ -395,9 +398,9 @@ int Ntl_ManCollapseBoxSeq1_rec( Ntl_Man_t * p, Ntl_Obj_t * pBox, int fSeq )
SeeAlso []
***********************************************************************/
-int Ntl_ManCollapseBoxSeq2_rec( Ntl_Man_t * p, Ntl_Obj_t * pBox, int fSeq, int iFirstPi )
+int Ntl_ManCollapseBoxSeq2_rec( Ntl_Man_t * p, Ntl_Obj_t * pBox, int iFirstPi )
{
- extern int Ntl_ManCollapse_rec( Ntl_Man_t * p, Ntl_Net_t * pNet, int fSeq );
+ extern int Ntl_ManCollapse_rec( Ntl_Man_t * p, Ntl_Net_t * pNet );
Ntl_Mod_t * pModel = pBox->pImplem;
Ntl_Obj_t * pObj;
Ntl_Net_t * pNet, * pNetBox;
@@ -420,20 +423,20 @@ int Ntl_ManCollapseBoxSeq2_rec( Ntl_Man_t * p, Ntl_Obj_t * pBox, int fSeq, int i
{
pNet = Ntl_ObjFanout0(pObj);
pNet->pCopy = Aig_ManPi( p->pAig, iFirstPi++ );
- if ( fSeq && Ntl_ObjIsInit1( pObj ) )
- pNet->pCopy = Aig_Not(pNet->pCopy);
+ if ( Ntl_ObjIsInit1( pObj ) )
+ pNet->pCopy = Aig_Not((Aig_Obj_t *)pNet->pCopy);
pNet->nVisits = 2;
}
// compute AIGs for the registers
Ntl_ModelForEachLatch( pModel, pObj, i )
{
pNet = Ntl_ObjFanin0(pObj);
- if ( !Ntl_ManCollapse_rec( p, pNet, fSeq ) )
+ if ( !Ntl_ManCollapse_rec( p, pNet ) )
return 0;
- if ( fSeq && Ntl_ObjIsInit1( pObj ) )
- Aig_ObjCreatePo( p->pAig, Aig_Not(pNet->pCopy) );
+ if ( Ntl_ObjIsInit1( pObj ) )
+ Aig_ObjCreatePo( p->pAig, Aig_Not((Aig_Obj_t *)pNet->pCopy) );
else
- Aig_ObjCreatePo( p->pAig, pNet->pCopy );
+ Aig_ObjCreatePo( p->pAig, (Aig_Obj_t *)pNet->pCopy );
}
return 1;
}
@@ -449,7 +452,7 @@ int Ntl_ManCollapseBoxSeq2_rec( Ntl_Man_t * p, Ntl_Obj_t * pBox, int fSeq, int i
SeeAlso []
***********************************************************************/
-int Ntl_ManCollapse_rec( Ntl_Man_t * p, Ntl_Net_t * pNet, int fSeq )
+int Ntl_ManCollapse_rec( Ntl_Man_t * p, Ntl_Net_t * pNet )
{
Ntl_Obj_t * pObj;
Ntl_Net_t * pNetFanin;
@@ -467,13 +470,13 @@ int Ntl_ManCollapse_rec( Ntl_Man_t * p, Ntl_Net_t * pNet, int fSeq )
assert( Ntl_ObjIsNode(pObj) || Ntl_ObjIsBox(pObj) );
// visit the input nets of the box
Ntl_ObjForEachFanin( pObj, pNetFanin, i )
- if ( !Ntl_ManCollapse_rec( p, pNetFanin, fSeq ) )
+ if ( !Ntl_ManCollapse_rec( p, pNetFanin ) )
return 0;
// add box inputs/outputs to COs/CIs
if ( Ntl_ObjIsBox(pObj) )
{
assert( Ntl_BoxIsWhite(pObj) && Ntl_BoxIsComb(pObj) );
- if ( !Ntl_ManCollapseBoxComb_rec( p, pObj, fSeq ) )
+ if ( !Ntl_ManCollapseBoxComb_rec( p, pObj ) )
return 0;
}
if ( Ntl_ObjIsNode(pObj) )
@@ -533,7 +536,7 @@ Aig_Man_t * Ntl_ManCollapse( Ntl_Man_t * p, int fSeq )
if ( !(Ntl_BoxIsSeq(pBox) && Ntl_BoxIsWhite(pBox)) )
continue;
Vec_IntPush( p->vBox1Cios, Aig_ManPiNum(p->pAig) );
- Ntl_ManCollapseBoxSeq1_rec( p, pBox, fSeq );
+ Ntl_ManCollapseBoxSeq1_rec( p, pBox );
Ntl_ObjForEachFanout( pBox, pNet, k )
pNet->nVisits = 2;
}
@@ -541,12 +544,12 @@ Aig_Man_t * Ntl_ManCollapse( Ntl_Man_t * p, int fSeq )
// derive the outputs
Ntl_ManForEachCoNet( p, pNet, i )
{
- if ( !Ntl_ManCollapse_rec( p, pNet, fSeq ) )
+ if ( !Ntl_ManCollapse_rec( p, pNet ) )
{
printf( "Ntl_ManCollapse(): Error: Combinational loop is detected.\n" );
return 0;
}
- Aig_ObjCreatePo( p->pAig, pNet->pCopy );
+ Aig_ObjCreatePo( p->pAig, (Aig_Obj_t *)pNet->pCopy );
}
nTruePos = Aig_ManPoNum(p->pAig);
// create outputs of seq boxes
@@ -556,12 +559,12 @@ Aig_Man_t * Ntl_ManCollapse( Ntl_Man_t * p, int fSeq )
if ( !(Ntl_BoxIsSeq(pBox) && Ntl_BoxIsWhite(pBox)) )
continue;
Ntl_ObjForEachFanin( pBox, pNet, k )
- if ( !Ntl_ManCollapse_rec( p, pNet, fSeq ) )
+ if ( !Ntl_ManCollapse_rec( p, pNet ) )
{
printf( "Ntl_ManCollapse(): Error: Combinational loop is detected.\n" );
return 0;
}
- Ntl_ManCollapseBoxSeq2_rec( p, pBox, fSeq, Vec_IntEntry(p->vBox1Cios, iBox++) );
+ Ntl_ManCollapseBoxSeq2_rec( p, pBox, Vec_IntEntry(p->vBox1Cios, iBox++) );
}
}
// make sure registers are added correctly
@@ -700,13 +703,13 @@ Nwk_Obj_t * Ntl_ManExtractNwk_rec( Ntl_Man_t * p, Ntl_Net_t * pNet, Nwk_Man_t *
Nwk_Obj_t * pNode;
int i;
if ( pNet->fMark )
- return pNet->pCopy2;
+ return (Nwk_Obj_t *)pNet->pCopy2;
pNet->fMark = 1;
pNode = Nwk_ManCreateNode( pNtk, Ntl_ObjFaninNum(pNet->pDriver), (int)(long)pNet->pCopy );
Ntl_ObjForEachFanin( pNet->pDriver, pFaninNet, i )
{
Ntl_ManExtractNwk_rec( p, pFaninNet, pNtk, vCover, vMemory );
- Nwk_ObjAddFanin( pNode, pFaninNet->pCopy2 );
+ Nwk_ObjAddFanin( pNode, (Nwk_Obj_t *)pFaninNet->pCopy2 );
}
if ( Ntl_ObjFaninNum(pNet->pDriver) == 0 || Kit_PlaGetVarNum(pNet->pDriver->pSop) == 0 )
pNode->pFunc = Hop_NotCond( Hop_ManConst1(pNtk->pManHop), Kit_PlaIsConst0(pNet->pDriver->pSop) );
@@ -717,7 +720,7 @@ Nwk_Obj_t * Ntl_ManExtractNwk_rec( Ntl_Man_t * p, Ntl_Net_t * pNet, Nwk_Man_t *
if ( Kit_PlaIsComplement(pNet->pDriver->pSop) )
pNode->pFunc = Hop_Not(pNode->pFunc);
}
- return pNet->pCopy2 = pNode;
+ return (Nwk_Obj_t *)(pNet->pCopy2 = pNode);
}
/**Function*************************************************************
@@ -780,24 +783,24 @@ Nwk_Man_t * Ntl_ManExtractNwk( Ntl_Man_t * p, Aig_Man_t * pAig, Tim_Man_t * pMan
{
if ( Aig_ObjIsPi(pAnd) )
{
- pNet = pAnd->pData;
+ pNet = (Ntl_Net_t *)pAnd->pData;
pNet->fMark = 1;
pNet->pCopy2 = Nwk_ManCreateCi( pNtk, (int)(long)pNet->pCopy );
}
else if ( Aig_ObjIsPo(pAnd) )
{
- pNet = pAnd->pData;
+ pNet = (Ntl_Net_t *)pAnd->pData;
pNode = Nwk_ManCreateCo( pNtk );
if ( (pNetSimple = Ntl_ModelFindSimpleNet( pNet )) )
{
pNetSimple->pCopy2 = Ntl_ManExtractNwk_rec( p, pNetSimple, pNtk, vCover, vMemory );
- Nwk_ObjAddFanin( pNode, pNetSimple->pCopy2 );
+ Nwk_ObjAddFanin( pNode, (Nwk_Obj_t *)pNetSimple->pCopy2 );
pNode->fInvert = Kit_PlaIsInv( pNet->pDriver->pSop );
}
else
{
pNet->pCopy2 = Ntl_ManExtractNwk_rec( p, pNet, pNtk, vCover, vMemory );
- Nwk_ObjAddFanin( pNode, pNet->pCopy2 );
+ Nwk_ObjAddFanin( pNode, (Nwk_Obj_t *)pNet->pCopy2 );
pNode->fInvert = (Nwk_ObjFanin0(pNode)->pFunc == Hop_ManConst0(pNtk->pManHop)); // fixed on June 7, 2009
}
}
@@ -818,7 +821,7 @@ Nwk_Man_t * Ntl_ManExtractNwk( Ntl_Man_t * p, Aig_Man_t * pAig, Tim_Man_t * pMan
/**Function*************************************************************
Synopsis [Extracts logic newtork out of the netlist.]
-
+
Description []
SideEffects []
@@ -831,7 +834,7 @@ Nwk_Man_t * Ntl_ManReadNwk( char * pFileName, Aig_Man_t * pAig, Tim_Man_t * pMan
Nwk_Man_t * pNtk;
Ntl_Man_t * pNtl;
Ntl_Mod_t * pRoot;
- pNtl = Ioa_ReadBlif( pFileName, 1 );
+ pNtl = Ntl_ManReadBlif( pFileName, 1 );
if ( pNtl == NULL )
{
printf( "Ntl_ManReadNwk(): Reading BLIF has failed.\n" );
@@ -870,3 +873,5 @@ Nwk_Man_t * Ntl_ManReadNwk( char * pFileName, Aig_Man_t * pAig, Tim_Man_t * pMan
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ntl/ntlFraig.c b/src/aig/ntl/ntlFraig.c
index 1d7ac393..34bc81ec 100644
--- a/src/aig/ntl/ntlFraig.c
+++ b/src/aig/ntl/ntlFraig.c
@@ -23,6 +23,9 @@
#include "ssw.h"
#include "dch.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -66,12 +69,12 @@ void Ntl_ManUpdateNoMergeReprs( Aig_Man_t * pAig, Aig_Obj_t ** pReprs )
if ( pRepresNew != NULL )
continue;
// get the net of the representative node
- pNet = pRepres->pData;
+ pNet = (Ntl_Net_t *)pRepres->pData;
assert( pRepres->pData != NULL );
if ( Ntl_ObjIsBox(pNet->pDriver) && pNet->pDriver->pImplem->attrNoMerge )
{
// the net belongs to the no-merge box
- pNetObj = pObj->pData;
+ pNetObj = (Ntl_Net_t *)pObj->pData;
if ( Ntl_ObjIsBox(pNetObj->pDriver) && pNetObj->pDriver->pImplem->attrNoMerge )
continue;
// the object's net does not belong to the no-merge box
@@ -130,7 +133,7 @@ Aig_Obj_t ** Ntl_ManFraigDeriveClasses( Aig_Man_t * pAig, Ntl_Man_t * pNew, Aig_
// remember pointers to the nets of pNew
Aig_ManForEachObj( pAig, pObj, i )
- pObj->pNext = pObj->pData;
+ pObj->pNext = (Aig_Obj_t *)pObj->pData;
// map the AIG managers
Aig_ManForEachObj( pAig, pObj, i )
@@ -139,8 +142,8 @@ Aig_Obj_t ** Ntl_ManFraigDeriveClasses( Aig_Man_t * pAig, Ntl_Man_t * pNew, Aig_
pObj->pData = Aig_ManConst1(pAigCol);
else if ( !Aig_ObjIsPo(pObj) )
{
- pNet = pObj->pData;
- pObjCol = Aig_Regular(pNet->pCopy);
+ pNet = (Ntl_Net_t *)pObj->pData;
+ pObjCol = Aig_Regular((Aig_Obj_t *)pNet->pCopy);
pObj->pData = pObjCol;
}
}
@@ -155,7 +158,7 @@ Aig_Obj_t ** Ntl_ManFraigDeriveClasses( Aig_Man_t * pAig, Ntl_Man_t * pNew, Aig_
{
if ( Aig_ObjIsPo(pObj) )
continue;
- pObjCol = pObj->pData;
+ pObjCol = (Aig_Obj_t *)pObj->pData;
if ( pObjCol == NULL )
continue;
if ( pMapBack[pObjCol->Id] == NULL )
@@ -170,7 +173,7 @@ Aig_Obj_t ** Ntl_ManFraigDeriveClasses( Aig_Man_t * pAig, Ntl_Man_t * pNew, Aig_
if ( Aig_ObjIsPo(pObj) )
continue;
// get the collapsed node
- pObjCol = pObj->pData;
+ pObjCol = (Aig_Obj_t *)pObj->pData;
if ( pObjCol == NULL )
continue;
// get the representative of the collapsed node
@@ -230,8 +233,8 @@ void Ntl_ManReduce( Ntl_Man_t * p, Aig_Man_t * pAig )
if ( pObjRepr == NULL )
continue;
assert( pObj != pObjRepr );
- pNet = pObj->pData;
- pNetRepr = pObjRepr->pData;
+ pNet = (Ntl_Net_t *)pObj->pData;
+ pNetRepr = (Ntl_Net_t *)pObjRepr->pData;
// consider special cases, when the net should not be reduced
if ( Ntl_ObjIsBox(pNet->pDriver) )
{
@@ -267,8 +270,8 @@ void Ntl_ManReduce( Ntl_Man_t * p, Aig_Man_t * pAig )
pNetRepr->pCopy = Aig_ManConst1(pAig);
}
// get the complemented attributes of the nets
- fCompl = Aig_IsComplement(pNet->pCopy) ^ Aig_Regular(pNet->pCopy)->fPhase ^
- Aig_IsComplement(pNetRepr->pCopy) ^ Aig_Regular(pNetRepr->pCopy)->fPhase;
+ fCompl = Aig_IsComplement((Aig_Obj_t *)pNet->pCopy) ^ Aig_Regular((Aig_Obj_t *)pNet->pCopy)->fPhase ^
+ Aig_IsComplement((Aig_Obj_t *)pNetRepr->pCopy) ^ Aig_Regular((Aig_Obj_t *)pNetRepr->pCopy)->fPhase;
// create interter/buffer driven by the representative net
pNode = Ntl_ModelCreateNode( pRoot, 1 );
pNode->pSop = fCompl? Ntl_ManStoreSop( p->pMemSops, "0 1\n" ) : Ntl_ManStoreSop( p->pMemSops, "1 1\n" );
@@ -322,7 +325,7 @@ void Ntl_ManResetComplemented( Ntl_Man_t * p, Aig_Man_t * pAigCol )
{
if ( Ntl_ObjIsInit1( pObj ) )
{
- pObjCol = Ntl_ObjFanout0(pObj)->pCopy;
+ pObjCol = (Aig_Obj_t *)Ntl_ObjFanout0(pObj)->pCopy;
assert( pObjCol->fPhase == 0 );
pObjCol->fPhase = 1;
}
@@ -353,7 +356,20 @@ Ntl_Man_t * Ntl_ManFinalize( Ntl_Man_t * pNew, Aig_Man_t * pAig, Aig_Man_t * pAi
pAig->nReprsAlloc = Aig_ManObjNumMax(pAig);
if ( fVerbose )
printf( "Equivalences: Collapsed = %5d. Extracted = %5d.\n", Aig_ManCountReprs(pAigCol), Aig_ManCountReprs(pAig) );
-
+/*
+{
+ Aig_Obj_t * pObj;
+ int i;
+ Aig_ManForEachObj( pAig, pObj, i )
+ if ( pAig->pReprs[i] != NULL )
+ printf( "%s%d->%s%d ",
+ (Aig_ObjIsPi(pObj)? "pi": ""),
+ pObj->Id,
+ (Aig_ObjIsPi(pAig->pReprs[i])? "pi": ""),
+ pAig->pReprs[i]->Id );
+ printf( "\n" );
+}
+*/
// implement equivalence classes and remove dangling nodes
Ntl_ManReduce( pNew, pAig );
Ntl_ManSweep( pNew, fVerbose );
@@ -503,7 +519,7 @@ Aig_Man_t * Ntl_ManAigToRst( Ntl_Man_t * pNtl, Aig_Man_t * p )
if ( iRstNum < 0 )
continue;
assert( iRstNum < nResets );
- pObj->pData = Aig_And( pNew, pObj->pData, Aig_ManPi(pNew, iRstNum) ); // could be NOT(pi)
+ pObj->pData = Aig_And( pNew, (Aig_Obj_t *)pObj->pData, Aig_ManPi(pNew, iRstNum) ); // could be NOT(pi)
Counter++;
}
else if ( Aig_ObjIsConst1(pObj) )
@@ -578,7 +594,7 @@ void Ntl_ManRemapClassesScorr( Ntl_Man_t * pNtl, Aig_Man_t * p, Aig_Man_t * pNew
// map things back
Aig_ManForEachObj( p, pObj, i )
{
- pObjNew = pObj->pData;
+ pObjNew = (Aig_Obj_t *)pObj->pData;
assert( pObjNew != NULL && !Aig_IsComplement(pObjNew) );
pObjNew->pData = pObj;
}
@@ -588,8 +604,8 @@ void Ntl_ManRemapClassesScorr( Ntl_Man_t * pNtl, Aig_Man_t * p, Aig_Man_t * pNew
pObjNewRepr = pNew->pReprs[pObjNew->Id];
if ( pObjNewRepr == NULL )
continue;
- pObj = pObjNew->pData;
- pObjRepr = pObjNewRepr->pData;
+ pObj = (Aig_Obj_t *)pObjNew->pData;
+ pObjRepr = (Aig_Obj_t *)pObjNewRepr->pData;
assert( Aig_ObjId(pObjRepr) < Aig_ObjId(pObj) );
Aig_ObjCreateRepr( p, pObjRepr, pObj );
}
@@ -787,6 +803,8 @@ Ntl_Man_t * Ntl_ManScorr( Ntl_Man_t * p, Ssw_Pars_t * pPars )
}
else
{
+ pPars->fVerbose = 1;
+
pTemp = Ssw_SignalCorrespondence( pAigCol, pPars );
Aig_ManStop( pTemp );
}
@@ -872,7 +890,7 @@ void Ntl_ManAttachWhiteBoxes( Ntl_Man_t * p, Aig_Man_t * pAigCol, Aig_Man_t * pA
if ( pNet->pCopy == NULL )
continue;
// skip the outputs that are not preserved after merging equivalence
- if ( Aig_Regular(pNet->pCopy2)->pData == NULL )
+ if ( Aig_Regular((Aig_Obj_t *)pNet->pCopy2)->pData == NULL )
continue;
break;
}
@@ -982,3 +1000,5 @@ Ntl_Man_t * Ntl_ManSsw2( Ntl_Man_t * p, Fra_Ssw_t * pPars )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ntl/ntlInsert.c b/src/aig/ntl/ntlInsert.c
index 750eb8f7..8b0e3493 100644
--- a/src/aig/ntl/ntlInsert.c
+++ b/src/aig/ntl/ntlInsert.c
@@ -21,6 +21,9 @@
#include "ntl.h"
#include "kit.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -65,7 +68,7 @@ Ntl_Man_t * Ntl_ManInsertMapping( Ntl_Man_t * p, Vec_Ptr_t * vMapping, Aig_Man_t
// create a new node for each LUT
vCover = Vec_IntAlloc( 1 << 16 );
nDigits = Aig_Base10Log( Vec_PtrSize(vMapping) );
- Vec_PtrForEachEntry( vMapping, pLut, i )
+ Vec_PtrForEachEntry( Ntl_Lut_t *, vMapping, pLut, i )
{
pNode = Ntl_ModelCreateNode( pRoot, pLut->nFanins );
pNode->pSop = Kit_PlaFromTruth( p->pMemSops, pLut->pTruth, pLut->nFanins, vCover );
@@ -73,7 +76,7 @@ Ntl_Man_t * Ntl_ManInsertMapping( Ntl_Man_t * p, Vec_Ptr_t * vMapping, Aig_Man_t
{
for ( k = 0; k < pLut->nFanins; k++ )
{
- pNet = Vec_PtrEntry( vCopies, pLut->pFanins[k] );
+ pNet = (Ntl_Net_t *)Vec_PtrEntry( vCopies, pLut->pFanins[k] );
if ( pNet == NULL )
{
printf( "Ntl_ManInsert(): Internal error: Net not found.\n" );
@@ -108,9 +111,9 @@ Ntl_Man_t * Ntl_ManInsertMapping( Ntl_Man_t * p, Vec_Ptr_t * vMapping, Aig_Man_t
if ( pNetCo->fMark )
continue;
pNetCo->fMark = 1;
- pNet = Vec_PtrEntry( vCopies, Aig_Regular(pNetCo->pCopy)->Id );
+ pNet = (Ntl_Net_t *)Vec_PtrEntry( vCopies, Aig_Regular((Aig_Obj_t *)pNetCo->pCopy)->Id );
pNode = Ntl_ModelCreateNode( pRoot, 1 );
- pNode->pSop = Aig_IsComplement(pNetCo->pCopy)? Ntl_ManStoreSop( p->pMemSops, "0 1\n" ) : Ntl_ManStoreSop( p->pMemSops, "1 1\n" );
+ pNode->pSop = Aig_IsComplement((Aig_Obj_t *)pNetCo->pCopy)? Ntl_ManStoreSop( p->pMemSops, "0 1\n" ) : Ntl_ManStoreSop( p->pMemSops, "1 1\n" );
Ntl_ObjSetFanin( pNode, pNet, 0 );
// update the CO driver net
assert( pNetCo->pDriver == NULL );
@@ -187,8 +190,8 @@ Ntl_Man_t * Ntl_ManInsertAig( Ntl_Man_t * p, Aig_Man_t * pAig )
return 0;
}
pNode = Ntl_ModelCreateNode( pRoot, 2 );
- Ntl_ObjSetFanin( pNode, Aig_ObjFanin0(pObj)->pData, 0 );
- Ntl_ObjSetFanin( pNode, Aig_ObjFanin1(pObj)->pData, 1 );
+ Ntl_ObjSetFanin( pNode, (Ntl_Net_t *)Aig_ObjFanin0(pObj)->pData, 0 );
+ Ntl_ObjSetFanin( pNode, (Ntl_Net_t *)Aig_ObjFanin1(pObj)->pData, 1 );
if ( Aig_ObjFaninC0(pObj) && Aig_ObjFaninC1(pObj) )
pNode->pSop = Ntl_ManStoreSop( p->pMemSops, "00 1\n" );
else if ( Aig_ObjFaninC0(pObj) && !Aig_ObjFaninC1(pObj) )
@@ -224,7 +227,7 @@ Ntl_Man_t * Ntl_ManInsertAig( Ntl_Man_t * p, Aig_Man_t * pAig )
pObj = Aig_ManPo( pAig, i );
pFanin = Aig_ObjFanin0( pObj );
// get the net driving the driver
- pNet = pFanin->pData;
+ pNet = (Ntl_Net_t *)pFanin->pData;
pNode = Ntl_ModelCreateNode( pRoot, 1 );
pNode->pSop = Aig_ObjFaninC0(pObj)? Ntl_ManStoreSop( p->pMemSops, "0 1\n" ) : Ntl_ManStoreSop( p->pMemSops, "1 1\n" );
Ntl_ObjSetFanin( pNode, pNet, 0 );
@@ -317,7 +320,7 @@ Ntl_Man_t * Ntl_ManInsertNtk2( Ntl_Man_t * p, Nwk_Man_t * pNtk )
nDigits = Aig_Base10Log( Nwk_ManNodeNum(pNtk) );
// go through the nodes in the topological order
vObjs = Nwk_ManDfs( pNtk );
- Vec_PtrForEachEntry( vObjs, pObj, i )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, vObjs, pObj, i )
{
if ( !Nwk_ObjIsNode(pObj) )
continue;
@@ -351,7 +354,7 @@ Ntl_Man_t * Ntl_ManInsertNtk2( Ntl_Man_t * p, Nwk_Man_t * pNtk )
{
Nwk_ObjForEachFanin( pObj, pFanin, k )
{
- pNet = pFanin->pCopy;
+ pNet = (Ntl_Net_t *)pFanin->pCopy;
if ( pNet == NULL )
{
printf( "Ntl_ManInsertNtk(): Internal error: Net not found.\n" );
@@ -404,7 +407,7 @@ Ntl_Man_t * Ntl_ManInsertNtk2( Ntl_Man_t * p, Nwk_Man_t * pNtk )
pObj = Nwk_ManCo( pNtk, i );
pFanin = Nwk_ObjFanin0( pObj );
// get the net driving this PO
- pNet = pFanin->pCopy;
+ pNet = (Ntl_Net_t *)pFanin->pCopy;
if ( pNet == NULL ) // constant net
{
assert( fWriteConstants );
@@ -500,7 +503,7 @@ Ntl_Man_t * Ntl_ManInsertNtk( Ntl_Man_t * p, Nwk_Man_t * pNtk )
nDigits = Aig_Base10Log( Nwk_ManNodeNum(pNtk) );
// go through the nodes in the topological order
vObjs = Nwk_ManDfs( pNtk );
- Vec_PtrForEachEntry( vObjs, pObj, i )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, vObjs, pObj, i )
{
if ( !Nwk_ObjIsNode(pObj) )
continue;
@@ -512,7 +515,7 @@ Ntl_Man_t * Ntl_ManInsertNtk( Ntl_Man_t * p, Nwk_Man_t * pNtk )
{
Nwk_ObjForEachFanin( pObj, pFanin, k )
{
- pNet = pFanin->pCopy;
+ pNet = (Ntl_Net_t *)pFanin->pCopy;
if ( pNet == NULL )
{
printf( "Ntl_ManInsertNtk(): Internal error: Net not found.\n" );
@@ -562,7 +565,7 @@ Ntl_Man_t * Ntl_ManInsertNtk( Ntl_Man_t * p, Nwk_Man_t * pNtk )
pObj = Nwk_ManCo( pNtk, i );
pFanin = Nwk_ObjFanin0( pObj );
// get the net driving this PO
- pNet = pFanin->pCopy;
+ pNet = (Ntl_Net_t *)pFanin->pCopy;
if ( Nwk_ObjFanoutNum(pFanin) == 1 && Ntl_ObjIsNode(pNet->pDriver) )
{
pNode = pNet->pDriver;
@@ -607,3 +610,5 @@ Ntl_Man_t * Ntl_ManInsertNtk( Ntl_Man_t * p, Nwk_Man_t * pNtk )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ntl/ntlMan.c b/src/aig/ntl/ntlMan.c
index b5ad7815..45fb7226 100644
--- a/src/aig/ntl/ntlMan.c
+++ b/src/aig/ntl/ntlMan.c
@@ -20,6 +20,9 @@
#include "ntl.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -108,7 +111,7 @@ Ntl_Man_t * Ntl_ManStartFrom( Ntl_Man_t * pOld )
pNew = Ntl_ManAlloc();
pNew->pName = Ntl_ManStoreFileName( pNew, pOld->pName );
pNew->pSpec = Ntl_ManStoreName( pNew, pOld->pName );
- Vec_PtrForEachEntry( pOld->vModels, pModel, i )
+ Vec_PtrForEachEntry( Ntl_Mod_t *, pOld->vModels, pModel, i )
{
if ( i == 0 )
{
@@ -119,10 +122,10 @@ Ntl_Man_t * Ntl_ManStartFrom( Ntl_Man_t * pOld )
else
pModel->pCopy = Ntl_ModelDup( pNew, pModel );
}
- Vec_PtrForEachEntry( pOld->vModels, pModel, i )
+ Vec_PtrForEachEntry( Ntl_Mod_t *, pOld->vModels, pModel, i )
Ntl_ModelForEachBox( pModel, pBox, k )
{
- ((Ntl_Obj_t *)pBox->pCopy)->pImplem = pBox->pImplem->pCopy;
+ ((Ntl_Obj_t *)pBox->pCopy)->pImplem = (Ntl_Mod_t *)pBox->pImplem->pCopy;
((Ntl_Obj_t *)pBox->pCopy)->iTemp = pBox->iTemp;
// ((Ntl_Obj_t *)pBox->pCopy)->Reset = pBox->Reset;
}
@@ -158,11 +161,11 @@ Ntl_Man_t * Ntl_ManDup( Ntl_Man_t * pOld )
pNew = Ntl_ManAlloc();
pNew->pName = Ntl_ManStoreFileName( pNew, pOld->pName );
pNew->pSpec = Ntl_ManStoreName( pNew, pOld->pName );
- Vec_PtrForEachEntry( pOld->vModels, pModel, i )
+ Vec_PtrForEachEntry( Ntl_Mod_t *, pOld->vModels, pModel, i )
pModel->pCopy = Ntl_ModelDup( pNew, pModel );
- Vec_PtrForEachEntry( pOld->vModels, pModel, i )
+ Vec_PtrForEachEntry( Ntl_Mod_t *, pOld->vModels, pModel, i )
Ntl_ModelForEachBox( pModel, pBox, k )
- ((Ntl_Obj_t *)pBox->pCopy)->pImplem = pBox->pImplem->pCopy;
+ ((Ntl_Obj_t *)pBox->pCopy)->pImplem = (Ntl_Mod_t *)pBox->pImplem->pCopy;
Ntl_ManForEachCiNet( pOld, pNet, i )
Vec_PtrPush( pNew->vCis, pNet->pCopy );
Ntl_ManForEachCoNet( pOld, pNet, i )
@@ -195,12 +198,12 @@ Ntl_Man_t * Ntl_ManDupCollapseLuts( Ntl_Man_t * pOld )
pNew = Ntl_ManAlloc();
pNew->pName = Ntl_ManStoreFileName( pNew, pOld->pName );
pNew->pSpec = Ntl_ManStoreName( pNew, pOld->pName );
- Vec_PtrForEachEntry( pOld->vModels, pModel, i )
+ Vec_PtrForEachEntry( Ntl_Mod_t *, pOld->vModels, pModel, i )
pModel->pCopy = Ntl_ModelDupCollapseLuts( pNew, pModel );
- Vec_PtrForEachEntry( pOld->vModels, pModel, i )
+ Vec_PtrForEachEntry( Ntl_Mod_t *, pOld->vModels, pModel, i )
Ntl_ModelForEachBox( pModel, pBox, k )
if ( pBox->pCopy )
- ((Ntl_Obj_t *)pBox->pCopy)->pImplem = pBox->pImplem->pCopy;
+ ((Ntl_Obj_t *)pBox->pCopy)->pImplem = (Ntl_Mod_t *)pBox->pImplem->pCopy;
// Ntl_ManForEachCiNet( pOld, pNet, i )
// Vec_PtrPush( pNew->vCis, pNet->pCopy );
// Ntl_ManForEachCoNet( pOld, pNet, i )
@@ -301,10 +304,16 @@ void Nwk_ManPrintStatsShort( Ntl_Man_t * p, Aig_Man_t * pAig, Nwk_Man_t * pNtk )
Ntl_ModelForEachBox( pRoot, pObj, i )
if ( strcmp(pObj->pImplem->pName, "dff") == 0 )
Counter++;
+ if ( Counter == 0 )
+ {
+ Ntl_ModelForEachBox( pRoot, pObj, i )
+ Counter += (pObj->pImplem->attrWhite && !pObj->pImplem->attrComb);
+ }
printf( "%-15s : ", p->pName );
printf( "pi =%5d ", Ntl_ModelPiNum(pRoot) );
printf( "po =%5d ", Ntl_ModelPoNum(pRoot) );
printf( "ff =%5d ", Counter );
+ printf( "box =%6d ", Ntl_ModelBoxNum(pRoot) );
if ( pAig != NULL )
{
Counter = Aig_ManChoiceNum( pAig );
@@ -314,7 +323,7 @@ void Nwk_ManPrintStatsShort( Ntl_Man_t * p, Aig_Man_t * pAig, Nwk_Man_t * pNtk )
printf( "aig =%7d ", Aig_ManNodeNum(pAig) );
}
if ( pNtk == NULL )
- printf( "Mapping is not available.\n" );
+ printf( "No mapping.\n" );
else
{
printf( "lut =%5d ", Nwk_ManNodeNum(pNtk) );
@@ -509,7 +518,7 @@ void Ntl_ManPrintTypes( Ntl_Man_t * p )
printf( "CLOCK STATISTICS:\n" );
Vec_VecForEachLevel( pModel->vClockFlops, vFlops, i )
{
- pNet = Vec_PtrEntry( pModel->vClocks, i );
+ pNet = (Ntl_Net_t *)Vec_PtrEntry( pModel->vClocks, i );
printf( "Clock %2d : Name = %30s Flops = %6d.\n", i+1, pNet->pName, Vec_PtrSize(vFlops) );
}
}
@@ -562,7 +571,7 @@ void Ntl_ManPrintClocks( Ntl_Man_t * p )
printf( "CLOCK STATISTICS:\n" );
Vec_VecForEachLevel( pModel->vClockFlops, vFlops, i )
{
- pNet = Vec_PtrEntry( pModel->vClocks, i );
+ pNet = (Ntl_Net_t *)Vec_PtrEntry( pModel->vClocks, i );
printf( "Clock %2d : Name = %30s Flops = %6d.\n", i+1, pNet->pName, Vec_PtrSize(vFlops) );
if ( i == 10 )
{
@@ -599,7 +608,7 @@ void Ntl_ManPrintResets( Ntl_Man_t * p )
printf( "RESET STATISTICS:\n" );
Vec_VecForEachLevel( pModel->vResetFlops, vFlops, i )
{
- pNet = Vec_PtrEntry( pModel->vResets, i );
+ pNet = (Ntl_Net_t *)Vec_PtrEntry( pModel->vResets, i );
printf( "Reset %2d : Name = %30s Flops = %6d.\n", i+1, pNet->pName, Vec_PtrSize(vFlops) );
if ( i == 10 )
{
@@ -690,7 +699,7 @@ Ntl_Mod_t * Ntl_ModelStartFrom( Ntl_Man_t * pManNew, Ntl_Mod_t * pModelOld )
else if ( pNet->fMark )
{
pNet->pCopy = Ntl_ModelFindOrCreateNet( pModelNew, pNet->pName );
- ((Ntl_Net_t *)pNet->pCopy)->pDriver = pNet->pDriver->pCopy;
+ ((Ntl_Net_t *)pNet->pCopy)->pDriver = (Ntl_Obj_t *)pNet->pDriver->pCopy;
}
else
pNet->pCopy = NULL;
@@ -703,14 +712,14 @@ Ntl_Mod_t * Ntl_ModelStartFrom( Ntl_Man_t * pManNew, Ntl_Mod_t * pModelOld )
continue;
Ntl_ObjForEachFanin( pObj, pNet, k )
if ( pNet->pCopy != NULL )
- Ntl_ObjSetFanin( pObj->pCopy, pNet->pCopy, k );
+ Ntl_ObjSetFanin( (Ntl_Obj_t *)pObj->pCopy, (Ntl_Net_t *)pNet->pCopy, k );
Ntl_ObjForEachFanout( pObj, pNet, k )
if ( pNet->pCopy != NULL )
- Ntl_ObjSetFanout( pObj->pCopy, pNet->pCopy, k );
+ Ntl_ObjSetFanout( (Ntl_Obj_t *)pObj->pCopy, (Ntl_Net_t *)pNet->pCopy, k );
if ( Ntl_ObjIsLatch(pObj) )
{
((Ntl_Obj_t *)pObj->pCopy)->LatchId = pObj->LatchId;
- ((Ntl_Obj_t *)pObj->pCopy)->pClock = pObj->pClock->pCopy;
+ ((Ntl_Obj_t *)pObj->pCopy)->pClock = (Ntl_Net_t *)pObj->pClock->pCopy;
}
}
pModelNew->vDelays = pModelOld->vDelays? Vec_IntDup( pModelOld->vDelays ) : NULL;
@@ -753,19 +762,19 @@ Ntl_Mod_t * Ntl_ModelDup( Ntl_Man_t * pManNew, Ntl_Mod_t * pModelOld )
assert( !pModelOld->attrWhite );
continue;
}
- ((Ntl_Net_t *)pNet->pCopy)->pDriver = pNet->pDriver->pCopy;
+ ((Ntl_Net_t *)pNet->pCopy)->pDriver = (Ntl_Obj_t *)pNet->pDriver->pCopy;
assert( pNet->pDriver->pCopy != NULL );
}
Ntl_ModelForEachObj( pModelOld, pObj, i )
{
Ntl_ObjForEachFanin( pObj, pNet, k )
- Ntl_ObjSetFanin( pObj->pCopy, pNet->pCopy, k );
+ Ntl_ObjSetFanin( (Ntl_Obj_t *)pObj->pCopy, (Ntl_Net_t *)pNet->pCopy, k );
Ntl_ObjForEachFanout( pObj, pNet, k )
- Ntl_ObjSetFanout( pObj->pCopy, pNet->pCopy, k );
+ Ntl_ObjSetFanout( (Ntl_Obj_t *)pObj->pCopy, (Ntl_Net_t *)pNet->pCopy, k );
if ( Ntl_ObjIsLatch(pObj) )
{
((Ntl_Obj_t *)pObj->pCopy)->LatchId = pObj->LatchId;
- ((Ntl_Obj_t *)pObj->pCopy)->pClock = pObj->pClock? pObj->pClock->pCopy : NULL;
+ ((Ntl_Obj_t *)pObj->pCopy)->pClock = pObj->pClock? (Ntl_Net_t *)pObj->pClock->pCopy : NULL;
}
if ( Ntl_ObjIsNode(pObj) )
((Ntl_Obj_t *)pObj->pCopy)->pSop = Ntl_ManStoreSop( pManNew->pMemSops, pObj->pSop );
@@ -821,7 +830,7 @@ Ntl_Mod_t * Ntl_ModelDupCollapseLuts( Ntl_Man_t * pManNew, Ntl_Mod_t * pModelOld
}
if ( Ntl_ObjIsLutBox(pNet->pDriver) )
continue;
- ((Ntl_Net_t *)pNet->pCopy)->pDriver = pNet->pDriver->pCopy;
+ ((Ntl_Net_t *)pNet->pCopy)->pDriver = (Ntl_Obj_t *)pNet->pDriver->pCopy;
assert( pNet->pDriver->pCopy != NULL );
}
Ntl_ModelForEachObj( pModelOld, pObj, i )
@@ -848,33 +857,33 @@ Ntl_Mod_t * Ntl_ModelDupCollapseLuts( Ntl_Man_t * pManNew, Ntl_Mod_t * pModelOld
continue;
sprintf( pNameBuf, "box%d_%s", i, pNet->pName );
pNet->pCopy = Ntl_ModelFindOrCreateNet( pModelNew, pNameBuf ); // change name!!!
- ((Ntl_Net_t *)pNet->pCopy)->pDriver = pNet->pDriver->pCopy;
+ ((Ntl_Net_t *)pNet->pCopy)->pDriver = (Ntl_Obj_t *)pNet->pDriver->pCopy;
}
// connect nodes
Ntl_ModelForEachNode( pModelBox, pObjBox, k )
{
Ntl_ObjForEachFanin( pObjBox, pNet, m )
- Ntl_ObjSetFanin( pObjBox->pCopy, pNet->pCopy, m );
+ Ntl_ObjSetFanin( (Ntl_Obj_t *)pObjBox->pCopy, (Ntl_Net_t *)pNet->pCopy, m );
Ntl_ObjForEachFanout( pObjBox, pNet, m )
- Ntl_ObjSetFanout( pObjBox->pCopy, pNet->pCopy, m );
+ Ntl_ObjSetFanout( (Ntl_Obj_t *)pObjBox->pCopy, (Ntl_Net_t *)pNet->pCopy, m );
((Ntl_Obj_t *)pObjBox->pCopy)->pSop = Ntl_ManStoreSop( pManNew->pMemSops, pObjBox->pSop );
}
// connect the PO nets
Ntl_ModelForEachPo( pModelBox, pObjBox, k )
- ((Ntl_Net_t *)Ntl_ObjFanin0(pObjBox)->pCopy)->pDriver = Ntl_ObjFanin0(pObjBox)->pDriver->pCopy;
+ ((Ntl_Net_t *)Ntl_ObjFanin0(pObjBox)->pCopy)->pDriver = (Ntl_Obj_t *)Ntl_ObjFanin0(pObjBox)->pDriver->pCopy;
assert( pObj->pCopy == NULL );
Counter++;
}
else
{
Ntl_ObjForEachFanin( pObj, pNet, k )
- Ntl_ObjSetFanin( pObj->pCopy, pNet->pCopy, k );
+ Ntl_ObjSetFanin( (Ntl_Obj_t *)pObj->pCopy, (Ntl_Net_t *)pNet->pCopy, k );
Ntl_ObjForEachFanout( pObj, pNet, k )
- Ntl_ObjSetFanout( pObj->pCopy, pNet->pCopy, k );
+ Ntl_ObjSetFanout( (Ntl_Obj_t *)pObj->pCopy, (Ntl_Net_t *)pNet->pCopy, k );
if ( Ntl_ObjIsLatch(pObj) )
{
((Ntl_Obj_t *)pObj->pCopy)->LatchId = pObj->LatchId;
- ((Ntl_Obj_t *)pObj->pCopy)->pClock = pObj->pClock? pObj->pClock->pCopy : NULL;
+ ((Ntl_Obj_t *)pObj->pCopy)->pClock = pObj->pClock? (Ntl_Net_t *)pObj->pClock->pCopy : NULL;
}
if ( Ntl_ObjIsNode(pObj) )
((Ntl_Obj_t *)pObj->pCopy)->pSop = Ntl_ManStoreSop( pManNew->pMemSops, pObj->pSop );
@@ -1055,3 +1064,5 @@ int Ntl_ModelCountInv( Ntl_Mod_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ntl/ntlMap.c b/src/aig/ntl/ntlMap.c
index 10e7dd17..0ce8549d 100644
--- a/src/aig/ntl/ntlMap.c
+++ b/src/aig/ntl/ntlMap.c
@@ -22,6 +22,9 @@
#include "kit.h"
#include "if.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -80,14 +83,14 @@ Vec_Ptr_t * Ntl_MappingFromAig( Aig_Man_t * p )
vMapping = Ntl_MappingAlloc( Aig_ManAndNum(p) + (int)(Aig_ManConst1(p)->nRefs > 0), 2 );
if ( Aig_ManConst1(p)->nRefs > 0 )
{
- pLut = Vec_PtrEntry( vMapping, k++ );
+ pLut = (Ntl_Lut_t *)Vec_PtrEntry( vMapping, k++ );
pLut->Id = 0;
pLut->nFanins = 0;
memset( pLut->pTruth, 0xFF, nBytes );
}
Aig_ManForEachNode( p, pObj, i )
{
- pLut = Vec_PtrEntry( vMapping, k++ );
+ pLut = (Ntl_Lut_t *)Vec_PtrEntry( vMapping, k++ );
pLut->Id = pObj->Id;
pLut->nFanins = 2;
pLut->pFanins[0] = Aig_ObjFaninId0(pObj);
@@ -200,7 +203,7 @@ If_Man_t * Ntl_ManToIf( Aig_Man_t * p, If_Par_t * pPars )
pIfMan->nLevelMax = (int)pNode->Level;
}
else if ( Aig_ObjIsPo(pNode) )
- pNode->pData = If_ManCreateCo( pIfMan, If_NotCond( Aig_ObjFanin0(pNode)->pData, Aig_ObjFaninC0(pNode) ) );
+ pNode->pData = If_ManCreateCo( pIfMan, If_NotCond( (If_Obj_t *)Aig_ObjFanin0(pNode)->pData, Aig_ObjFaninC0(pNode) ) );
else if ( Aig_ObjIsConst1(pNode) )
Aig_ManConst1(p)->pData = If_ManConst1( pIfMan );
else // add the node to the mapper
@@ -214,7 +217,7 @@ If_Man_t * Ntl_ManToIf( Aig_Man_t * p, If_Par_t * pPars )
// If_ManCreateChoice( pIfMan, (If_Obj_t *)pNode->pData );
// }
{
- If_Obj_t * pIfObj = pNode->pData;
+ If_Obj_t * pIfObj = (If_Obj_t *)pNode->pData;
assert( !If_IsComplement(pIfObj) );
assert( pIfObj->Id == pNode->Id );
}
@@ -255,7 +258,7 @@ Vec_Ptr_t * Ntl_ManFromIf( Aig_Man_t * p, If_Man_t * pMan )
continue;
if ( Aig_ObjIsPi(pObj) && pObj->pData == NULL )
continue;
- pNode = pObj->pData;
+ pNode = (If_Obj_t *)pObj->pData;
assert( pNode != NULL );
Vec_IntWriteEntry( vIfToAig, pNode->Id, pObj->Id );
}
@@ -267,19 +270,19 @@ Vec_Ptr_t * Ntl_ManFromIf( Aig_Man_t * p, If_Man_t * pMan )
nLuts = 0;
if ( Aig_ManConst1(p)->nRefs > 0 )
{
- pLut = Vec_PtrEntry( vMapping, nLuts++ );
+ pLut = (Ntl_Lut_t *)Vec_PtrEntry( vMapping, nLuts++ );
pLut->Id = 0;
pLut->nFanins = 0;
memset( pLut->pTruth, 0xFF, 4 * nWords );
}
- Vec_PtrForEachEntry( vIfMap, pNode, i )
+ Vec_PtrForEachEntry( If_Obj_t *, vIfMap, pNode, i )
{
// get the best cut
pCutBest = If_ObjCutBest(pNode);
nLeaves = If_CutLeaveNum( pCutBest );
ppLeaves = If_CutLeaves( pCutBest );
// fill the LUT
- pLut = Vec_PtrEntry( vMapping, nLuts++ );
+ pLut = (Ntl_Lut_t *)Vec_PtrEntry( vMapping, nLuts++ );
pLut->Id = Vec_IntEntry( vIfToAig, pNode->Id );
pLut->nFanins = nLeaves;
If_CutForEachLeaf( pMan, pCutBest, pLeaf, k )
@@ -339,3 +342,5 @@ Vec_Ptr_t * Ntl_MappingIf( Ntl_Man_t * pMan, Aig_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ntl/ntlNames.c b/src/aig/ntl/ntlNames.c
new file mode 100644
index 00000000..fa91711d
--- /dev/null
+++ b/src/aig/ntl/ntlNames.c
@@ -0,0 +1,471 @@
+/**CFile****************************************************************
+
+ FileName [ntlNames.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Netlist representation.]
+
+ Synopsis [Data-structure for storing hiNamrchical object names.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: ntlNames.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "ntl.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+// name object
+typedef struct Ntl_ObjNam_t_ Ntl_ObjNam_t;
+struct Ntl_ObjNam_t_
+{
+ int iPrev; // prefix of this name
+ int iNext; // the next name in the hash table
+ char pName[0]; // name characters
+};
+
+// name manager
+typedef struct Ntl_ManNam_t_ Ntl_ManNam_t;
+struct Ntl_ManNam_t_
+{
+ // info storage for names
+ char * pStore; // storage for name objects
+ int nStore; // the size of allocated storage
+ int iHandle; // the current free handle
+ int nHandles; // the number of handles
+ int nRefs; // reference counter for the manager
+ // hash table for names
+ int nBins;
+ unsigned * pBins;
+ // temporaries
+ Vec_Str_t * vName; // storage for returned name
+};
+
+static inline Ntl_ObjNam_t * Ntl_ManNamObj( Ntl_ManNam_t * p, int h ) { assert( !(h & 3) ); return (Ntl_ObjNam_t *)(p->pStore + h); }
+static inline int Ntl_ManNamObjHandle( Ntl_ManNam_t * p, Ntl_ObjNam_t * pObj ) { return ((char *)pObj) - p->pStore; }
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Creates manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Ntl_ManNam_t * Ntl_ManNamStart()
+{
+ Ntl_ManNam_t * p;
+ p = ABC_CALLOC( Ntl_ManNam_t, 1 );
+ p->nStore = (1 << 20);
+ p->pStore = ABC_ALLOC( char, p->nStore );
+ p->iHandle = 4;
+ p->nBins = Aig_PrimeCudd( 500000 );
+ p->pBins = ABC_CALLOC( unsigned, p->nBins );
+ p->vName = Vec_StrAlloc( 1000 );
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Deletes manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Ntl_ManNamStop( Ntl_ManNam_t * p )
+{
+ Vec_StrFree( p->vName );
+ ABC_FREE( p->pStore );
+ ABC_FREE( p->pBins );
+ ABC_FREE( p );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Deletes manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Ntl_ManNamReportMemUsage( Ntl_ManNam_t * p )
+{
+ return sizeof(Ntl_ManNam_t) + p->nStore + sizeof(int) * p->nBins + sizeof(int) * Vec_StrSize(p->vName);
+}
+
+/**Function*************************************************************
+
+ Synopsis [References the manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Ntl_ManNamRef( Ntl_ManNam_t * p )
+{
+ p->nRefs++;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Dereferences the manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Ntl_ManNamDeref( Ntl_ManNam_t * p )
+{
+ if ( --p->nRefs == 0 )
+ Ntl_ManNamStop( p );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns object with the given handle.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+
+
+/**Function*************************************************************
+
+ Synopsis [Computes hash value of the node using its simulation info.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Ntl_ManNamStrHash( char * pStr, int Length, int nTableSize )
+{
+ static int s_FPrimes[128] = {
+ 1009, 1049, 1093, 1151, 1201, 1249, 1297, 1361, 1427, 1459,
+ 1499, 1559, 1607, 1657, 1709, 1759, 1823, 1877, 1933, 1997,
+ 2039, 2089, 2141, 2213, 2269, 2311, 2371, 2411, 2467, 2543,
+ 2609, 2663, 2699, 2741, 2797, 2851, 2909, 2969, 3037, 3089,
+ 3169, 3221, 3299, 3331, 3389, 3461, 3517, 3557, 3613, 3671,
+ 3719, 3779, 3847, 3907, 3943, 4013, 4073, 4129, 4201, 4243,
+ 4289, 4363, 4441, 4493, 4549, 4621, 4663, 4729, 4793, 4871,
+ 4933, 4973, 5021, 5087, 5153, 5227, 5281, 5351, 5417, 5471,
+ 5519, 5573, 5651, 5693, 5749, 5821, 5861, 5923, 6011, 6073,
+ 6131, 6199, 6257, 6301, 6353, 6397, 6481, 6563, 6619, 6689,
+ 6737, 6803, 6863, 6917, 6977, 7027, 7109, 7187, 7237, 7309,
+ 7393, 7477, 7523, 7561, 7607, 7681, 7727, 7817, 7877, 7933,
+ 8011, 8039, 8059, 8081, 8093, 8111, 8123, 8147
+ };
+ unsigned uHash;
+ int i;
+ uHash = 0;
+ for ( i = 0; i < Length; i++ )
+ if ( i & 1 )
+ uHash *= pStr[i] * s_FPrimes[i & 0x7F];
+ else
+ uHash ^= pStr[i] * s_FPrimes[i & 0x7F];
+ return uHash % nTableSize;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Compares two strings to be equal.]
+
+ Description [Returns 1 if the strings match.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Ntl_ManNamStrCompare_rec( Ntl_ManNam_t * p, char * pStr, int Length, Ntl_ObjNam_t * pThis )
+{
+ Ntl_ObjNam_t * pNext = (pThis->iPrev)? Ntl_ManNamObj(p, pThis->iPrev) : NULL;
+ int LengthNew = strlen(pThis->pName);
+ if ( !strncmp( pThis->pName, pStr + Length - LengthNew, LengthNew ) )
+ return 0;
+ if ( pNext == NULL )
+ return 1;
+ return Ntl_ManNamStrCompare_rec( p, pStr, Length - LengthNew, pNext );
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Returns the place of this state in the table or NULL if it exists.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline unsigned * Ntl_ManNamStrHashFind( Ntl_ManNam_t * p, char * pStr, int Length, int * pHandle )
+{
+ Ntl_ObjNam_t * pThis;
+ unsigned * pPlace = p->pBins + Ntl_ManNamStrHash( pStr, Length, p->nBins );
+ for ( pThis = (*pPlace)? Ntl_ManNamObj(p, *pPlace) : NULL; pThis;
+ pPlace = (unsigned *)&pThis->iNext, pThis = (*pPlace)? Ntl_ManNamObj(p, *pPlace) : NULL )
+ if ( !Ntl_ManNamStrCompare_rec( p, pStr, Length, pThis ) )
+ {
+ *pHandle = Ntl_ManNamObjHandle( p, pThis );
+ return NULL;
+ }
+ *pHandle = -1;
+ return pPlace;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Resizes the hash table.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Ntl_ManNamStrHashResize( Ntl_ManNam_t * p )
+{
+ Ntl_ObjNam_t * pThis;
+ unsigned * pBinsOld, * piPlace;
+ int nBinsOld, iNext, iHandle, Counter, i;
+ assert( p->pBins != NULL );
+ // replace the table
+ pBinsOld = p->pBins;
+ nBinsOld = p->nBins;
+ p->nBins = Aig_PrimeCudd( 3 * p->nBins );
+ p->pBins = ABC_CALLOC( unsigned, p->nBins );
+ // rehash the entries from the old table
+ Counter = 0;
+ for ( i = 0; i < nBinsOld; i++ )
+ for ( pThis = (pBinsOld[i]? Ntl_ManNamObj(p, pBinsOld[i]) : NULL),
+ iNext = (pThis? pThis->iNext : 0);
+ pThis; pThis = (iNext? Ntl_ManNamObj(p, iNext) : NULL),
+ iNext = (pThis? pThis->iNext : 0) )
+ {
+ pThis->iNext = 0;
+ piPlace = Ntl_ManNamStrHashFind( p, pThis->pName, strlen(pThis->pName), &iHandle );
+ assert( *piPlace == 0 ); // should not be there
+ *piPlace = Ntl_ManNamObjHandle( p, pThis );
+ Counter++;
+ }
+ assert( Counter == p->nHandles );
+ ABC_FREE( pBinsOld );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the handle of a new object to represent the name.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Ntl_ManNamStrGrow_rec( Ntl_ManNam_t * p, char * pStr, int Length, unsigned * piPlace )
+{
+ Ntl_ObjNam_t * pThis;
+ char * pStrNew;
+ int Separ, LengthNew;
+ int iHandle;
+ assert( Length > 0 );
+ // find the separator symbol
+ for ( Separ = Length - 2; Separ >= 0 && pStr[Separ] != '/'; Separ-- );
+ pStrNew = (Separ == -1) ? pStr : pStr + Separ + 1;
+ LengthNew = Length - (pStrNew - pStr);
+ // realloc memory if needed
+ if ( p->iHandle + (int)sizeof(Ntl_ObjNam_t) + LengthNew+5 > p->nStore )
+ {
+ int OffSet;
+ if ( (char *)piPlace > p->pStore && (char *)piPlace < p->pStore + p->nStore )
+ OffSet = (char *)piPlace - p->pStore;
+ else
+ OffSet = -1;
+ p->nStore *= 2;
+ p->pStore = ABC_REALLOC( char, p->pStore, p->nStore );
+ if ( OffSet >= 0 )
+ piPlace = (unsigned *)(p->pStore + OffSet);
+ }
+ // new entry is created
+ p->nHandles++;
+ *piPlace = p->iHandle;
+ pThis = Ntl_ManNamObj( p, p->iHandle );
+ p->iHandle += sizeof(Ntl_ObjNam_t) + 4 * Aig_BitWordNum( 8*(LengthNew+1) );
+ pThis->iNext = 0;
+ pThis->iPrev = 0;
+ strncpy( pThis->pName, pStrNew, LengthNew );
+ pThis->pName[LengthNew] = 0;
+ // expand hash table if needed
+// if ( p->nHandles > 2 * p->nBins )
+// Ntl_ManNamStrHashResize( p );
+ // create previous object if needed
+ if ( Separ >= 0 )
+ {
+ assert( pStr[Separ] == '/' );
+ Separ++;
+ piPlace = Ntl_ManNamStrHashFind( p, pStr, Separ, &iHandle );
+ if ( piPlace != NULL )
+ iHandle = Ntl_ManNamStrGrow_rec( p, pStr, Separ, piPlace );
+ pThis->iPrev = iHandle;
+ }
+ return Ntl_ManNamObjHandle( p, pThis );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Finds or adds the given name to storage.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Ntl_ManNamStrFind( Ntl_ManNam_t * p, char * pStr )
+{
+ int iHandle;
+ Ntl_ManNamStrHashFind( p, pStr, strlen(pStr), &iHandle );
+ return iHandle;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Finds or adds the given name to storage.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+unsigned Ntl_ManNamStrFindOrAdd( Ntl_ManNam_t * p, char * pStr )
+{
+ unsigned * piPlace;
+ int iHandle, Length = strlen(pStr);
+ assert( Length > 0 );
+ piPlace = Ntl_ManNamStrHashFind( p, pStr, Length, &iHandle );
+ if ( piPlace == NULL )
+ return iHandle;
+ assert( *piPlace == 0 );
+ return Ntl_ManNamStrGrow_rec( p, pStr, Length, piPlace );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns name from handle.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+char * Ntl_ManNamStr( Ntl_ManNam_t * p, int h )
+{
+ Ntl_ObjNam_t * pObj;
+ int k;
+ assert( h && h < p->iHandle );
+ Vec_StrClear( p->vName );
+ for ( pObj = Ntl_ManNamObj( p, h ); pObj; pObj = pObj->iPrev ? Ntl_ManNamObj(p, pObj->iPrev) : NULL )
+ for ( k = strlen(pObj->pName) - 1; k >= 0; k-- )
+ Vec_StrPush( p->vName, pObj->pName[k] );
+ Vec_StrReverseOrder( p->vName );
+ Vec_StrPush( p->vName, 0 );
+ return Vec_StrArray( p->vName );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Testing procedure for the manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Ntl_ManNamTest( Ntl_Man_t * pNtl )
+{
+ Ntl_ManNam_t * p;
+ Ntl_Mod_t * pRoot;
+ Ntl_Net_t * pNet;
+ int Memory;
+ int i, iHandle;
+ int clk = clock();
+
+ p = Ntl_ManNamStart();
+printf( "a" );
+ Memory = 0;
+ pRoot = Ntl_ManRootModel( pNtl );
+ Ntl_ModelForEachNet( pRoot, pNet, i )
+ {
+ Memory += strlen(pNet->pName) + 1;
+ iHandle = Ntl_ManNamStrFindOrAdd( p, pNet->pName );
+
+// printf( "Before = %s\n", pNet->pName );
+// printf( "After = %s\n", Ntl_ManNamStr(p, iHandle) );
+ }
+ printf( "Net =%7d. Handle =%8d. ", Vec_PtrSize(pRoot->vNets), p->nHandles );
+ printf( "Mem old = %7.2f Mb. Mem new = %7.2f Mb.\n",
+ 1.0 * Memory / (1 << 20), 1.0 * Ntl_ManNamReportMemUsage(p) / (1 << 20) );
+ ABC_PRT( "Time", clock() - clk );
+printf( "b" );
+
+ Ntl_ManNamStop( p );
+}
+
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ntl/ntlObj.c b/src/aig/ntl/ntlObj.c
index 1915d650..209974aa 100644
--- a/src/aig/ntl/ntlObj.c
+++ b/src/aig/ntl/ntlObj.c
@@ -20,6 +20,9 @@
#include "ntl.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -160,7 +163,7 @@ Ntl_Obj_t * Ntl_ModelCreateBox( Ntl_Mod_t * pModel, int nFanins, int nFanouts )
p->Type = NTL_OBJ_BOX;
p->nFanins = nFanins;
p->nFanouts = nFanouts;
-// p->Reset = -1;
+ p->Reset = -1;
pModel->nObjs[NTL_OBJ_BOX]++;
return p;
}
@@ -246,7 +249,7 @@ char * Ntl_ManStoreName( Ntl_Man_t * p, char * pName )
SeeAlso []
***********************************************************************/
-char * Ntl_ManStoreSop( Aig_MmFlex_t * pMan, char * pSop )
+char * Ntl_ManStoreSop( Aig_MmFlex_t * pMan, const char * pSop )
{
char * pStore;
pStore = Aig_MmFlexEntryFetch( pMan, strlen(pSop) + 1 );
@@ -312,3 +315,5 @@ int Ntl_ManObjWhichFanout( Ntl_Obj_t * pNode, Ntl_Net_t * pFanout )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ntl/ntlReadBlif.c b/src/aig/ntl/ntlReadBlif.c
index 2e8a8096..103f8540 100644
--- a/src/aig/ntl/ntlReadBlif.c
+++ b/src/aig/ntl/ntlReadBlif.c
@@ -24,14 +24,17 @@
#include "bzlib.h"
#include "zlib.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
-typedef struct Ioa_ReadMod_t_ Ioa_ReadMod_t; // parsing model
-typedef struct Ioa_ReadMan_t_ Ioa_ReadMan_t; // parsing manager
+typedef struct Ntl_ReadMod_t_ Ntl_ReadMod_t; // parsing model
+typedef struct Ntl_ReadMan_t_ Ntl_ReadMan_t; // parsing manager
-struct Ioa_ReadMod_t_
+struct Ntl_ReadMod_t_
{
// file lines
char * pFirst; // .model line
@@ -53,10 +56,10 @@ struct Ioa_ReadMod_t_
// the resulting network
Ntl_Mod_t * pNtk;
// the parent manager
- Ioa_ReadMan_t * pMan;
+ Ntl_ReadMan_t * pMan;
};
-struct Ioa_ReadMan_t_
+struct Ntl_ReadMan_t_
{
// general info about file
char * pFileName; // the name of the file
@@ -66,7 +69,7 @@ struct Ioa_ReadMan_t_
Ntl_Man_t * pDesign; // the design under construction
// intermediate storage for models
Vec_Ptr_t * vModels; // vector of models
- Ioa_ReadMod_t * pLatest; // the current model
+ Ntl_ReadMod_t * pLatest; // the current model
// current processing info
Vec_Ptr_t * vTokens; // the current tokens
Vec_Ptr_t * vTokens2; // the current tokens
@@ -79,28 +82,28 @@ struct Ioa_ReadMan_t_
};
// static functions
-static Ioa_ReadMan_t * Ioa_ReadAlloc();
-static void Ioa_ReadFree( Ioa_ReadMan_t * p );
-static Ioa_ReadMod_t * Ioa_ReadModAlloc();
-static void Ioa_ReadModFree( Ioa_ReadMod_t * p );
-static char * Ioa_ReadLoadFile( char * pFileName );
-static char * Ioa_ReadLoadFileBz2( char * pFileName );
-static char * Ioa_ReadLoadFileGz( char * pFileName );
-static void Ioa_ReadReadPreparse( Ioa_ReadMan_t * p );
-static int Ioa_ReadReadInterfaces( Ioa_ReadMan_t * p );
-static Ntl_Man_t * Ioa_ReadParse( Ioa_ReadMan_t * p );
-static int Ioa_ReadParseLineModel( Ioa_ReadMod_t * p, char * pLine );
-static int Ioa_ReadParseLineAttrib( Ioa_ReadMod_t * p, char * pLine );
-static int Ioa_ReadParseLineInputs( Ioa_ReadMod_t * p, char * pLine );
-static int Ioa_ReadParseLineOutputs( Ioa_ReadMod_t * p, char * pLine );
-static int Ioa_ReadParseLineLatch( Ioa_ReadMod_t * p, char * pLine );
-static int Ioa_ReadParseLineSubckt( Ioa_ReadMod_t * p, char * pLine );
-static int Ioa_ReadParseLineDelay( Ioa_ReadMod_t * p, char * pLine );
-static int Ioa_ReadParseLineTimes( Ioa_ReadMod_t * p, char * pLine, int fOutput );
-static int Ioa_ReadParseLineNamesBlif( Ioa_ReadMod_t * p, char * pLine );
-
-static int Ioa_ReadCharIsSpace( char s ) { return s == ' ' || s == '\t' || s == '\r' || s == '\n'; }
-static int Ioa_ReadCharIsSopSymb( char s ) { return s == '0' || s == '1' || s == '-' || s == '\r' || s == '\n'; }
+static Ntl_ReadMan_t * Ntl_ReadAlloc();
+static void Ntl_ReadFree( Ntl_ReadMan_t * p );
+static Ntl_ReadMod_t * Ntl_ReadModAlloc();
+static void Ntl_ReadModFree( Ntl_ReadMod_t * p );
+static char * Ntl_ReadLoadFile( char * pFileName );
+static char * Ntl_ReadLoadFileBz2( char * pFileName );
+static char * Ntl_ReadLoadFileGz( char * pFileName );
+static void Ntl_ReadReadPreparse( Ntl_ReadMan_t * p );
+static int Ntl_ReadReadInterfaces( Ntl_ReadMan_t * p );
+static Ntl_Man_t * Ntl_ReadParse( Ntl_ReadMan_t * p );
+static int Ntl_ReadParseLineModel( Ntl_ReadMod_t * p, char * pLine );
+static int Ntl_ReadParseLineAttrib( Ntl_ReadMod_t * p, char * pLine );
+static int Ntl_ReadParseLineInputs( Ntl_ReadMod_t * p, char * pLine );
+static int Ntl_ReadParseLineOutputs( Ntl_ReadMod_t * p, char * pLine );
+static int Ntl_ReadParseLineLatch( Ntl_ReadMod_t * p, char * pLine );
+static int Ntl_ReadParseLineSubckt( Ntl_ReadMod_t * p, char * pLine );
+static int Ntl_ReadParseLineDelay( Ntl_ReadMod_t * p, char * pLine );
+static int Ntl_ReadParseLineTimes( Ntl_ReadMod_t * p, char * pLine, int fOutput );
+static int Ntl_ReadParseLineNamesBlif( Ntl_ReadMod_t * p, char * pLine );
+
+static int Ntl_ReadCharIsSpace( char s ) { return s == ' ' || s == '\t' || s == '\r' || s == '\n'; }
+static int Ntl_ReadCharIsSopSymb( char s ) { return s == '0' || s == '1' || s == '-' || s == '\r' || s == '\n'; }
////////////////////////////////////////////////////////////////////////
@@ -118,61 +121,64 @@ static int Ioa_ReadCharIsSopSymb( char s ) { return s == '0' || s
SeeAlso []
***********************************************************************/
-Ntl_Man_t * Ioa_ReadBlif( char * pFileName, int fCheck )
+Ntl_Man_t * Ntl_ManReadBlif( char * pFileName, int fCheck )
{
FILE * pFile;
- Ioa_ReadMan_t * p;
+ Ntl_ReadMan_t * p;
Ntl_Man_t * pDesign;
-// int nNodes;
-
+ if ( !Ntl_FileIsType(pFileName, ".blif", ".blif.gz", ".blif.bz2") )
+ {
+ printf( "Wrong file format\n" );
+ return NULL;
+ }
// check that the file is available
pFile = fopen( pFileName, "rb" );
if ( pFile == NULL )
{
- printf( "Ioa_ReadBlif(): The file is unavailable (absent or open).\n" );
+ printf( "Ntl_ManReadBlif(): The file is unavailable (absent or open).\n" );
return 0;
}
fclose( pFile );
// start the file reader
- p = Ioa_ReadAlloc();
+ p = Ntl_ReadAlloc();
p->pFileName = pFileName;
if ( !strncmp(pFileName+strlen(pFileName)-4,".bz2",4) )
- p->pBuffer = Ioa_ReadLoadFileBz2( pFileName );
+ p->pBuffer = Ntl_ReadLoadFileBz2( pFileName );
else if ( !strncmp(pFileName+strlen(pFileName)-3,".gz",3) )
- p->pBuffer = Ioa_ReadLoadFileGz( pFileName );
+ p->pBuffer = Ntl_ReadLoadFileGz( pFileName );
else
- p->pBuffer = Ioa_ReadLoadFile( pFileName );
+ p->pBuffer = Ntl_ReadLoadFile( pFileName );
if ( p->pBuffer == NULL )
{
- Ioa_ReadFree( p );
+ Ntl_ReadFree( p );
return NULL;
}
// set the design name
- p->pDesign = Ntl_ManAlloc( pFileName );
+ p->pDesign = Ntl_ManAlloc();
p->pDesign->pName = Ntl_ManStoreFileName( p->pDesign, pFileName );
p->pDesign->pSpec = Ntl_ManStoreName( p->pDesign, pFileName );
// prepare the file for parsing
- Ioa_ReadReadPreparse( p );
+ Ntl_ReadReadPreparse( p );
// parse interfaces of each network
- if ( !Ioa_ReadReadInterfaces( p ) )
+ if ( !Ntl_ReadReadInterfaces( p ) )
{
if ( p->sError[0] )
fprintf( stdout, "%s\n", p->sError );
- Ioa_ReadFree( p );
+ Ntl_ReadFree( p );
return NULL;
}
// construct the network
- pDesign = Ioa_ReadParse( p );
+ pDesign = Ntl_ReadParse( p );
if ( p->sError[0] )
fprintf( stdout, "%s\n", p->sError );
if ( pDesign == NULL )
{
- Ioa_ReadFree( p );
+ Ntl_ReadFree( p );
return NULL;
}
p->pDesign = NULL;
- Ioa_ReadFree( p );
+ Ntl_ReadFree( p );
// pDesign should be linked to all models of the design
// make sure that everything is okay with the network structure
@@ -180,7 +186,7 @@ Ntl_Man_t * Ioa_ReadBlif( char * pFileName, int fCheck )
{
if ( !Ntl_ManCheck( pDesign ) )
{
- printf( "Ioa_ReadBlif: The check has failed for design %s.\n", pDesign->pName );
+ printf( "Ntl_ReadBlif: The check has failed for design %s.\n", pDesign->pName );
Ntl_ManFree( pDesign );
return NULL;
}
@@ -189,7 +195,7 @@ Ntl_Man_t * Ioa_ReadBlif( char * pFileName, int fCheck )
// transform the design by removing the CO drivers
// if ( (nNodes = Ntl_ManReconnectCoDrivers(pDesign)) )
// printf( "The design was transformed by removing %d buf/inv CO drivers.\n", nNodes );
-//Ioa_WriteBlif( pDesign, "_temp_.blif" );
+//Ntl_ManWriteBlif( pDesign, "_temp_.blif" );
/*
{
Aig_Man_t * p = Ntl_ManCollapseSeq( pDesign );
@@ -210,11 +216,11 @@ Ntl_Man_t * Ioa_ReadBlif( char * pFileName, int fCheck )
SeeAlso []
***********************************************************************/
-static Ioa_ReadMan_t * Ioa_ReadAlloc()
+static Ntl_ReadMan_t * Ntl_ReadAlloc()
{
- Ioa_ReadMan_t * p;
- p = ABC_ALLOC( Ioa_ReadMan_t, 1 );
- memset( p, 0, sizeof(Ioa_ReadMan_t) );
+ Ntl_ReadMan_t * p;
+ p = ABC_ALLOC( Ntl_ReadMan_t, 1 );
+ memset( p, 0, sizeof(Ntl_ReadMan_t) );
p->vLines = Vec_PtrAlloc( 512 );
p->vModels = Vec_PtrAlloc( 512 );
p->vTokens = Vec_PtrAlloc( 512 );
@@ -234,9 +240,9 @@ static Ioa_ReadMan_t * Ioa_ReadAlloc()
SeeAlso []
***********************************************************************/
-static void Ioa_ReadFree( Ioa_ReadMan_t * p )
+static void Ntl_ReadFree( Ntl_ReadMan_t * p )
{
- Ioa_ReadMod_t * pMod;
+ Ntl_ReadMod_t * pMod;
int i;
if ( p->pDesign )
Ntl_ManFree( p->pDesign );
@@ -246,8 +252,8 @@ static void Ioa_ReadFree( Ioa_ReadMan_t * p )
Vec_PtrFree( p->vLines );
if ( p->vModels )
{
- Vec_PtrForEachEntry( p->vModels, pMod, i )
- Ioa_ReadModFree( pMod );
+ Vec_PtrForEachEntry( Ntl_ReadMod_t *, p->vModels, pMod, i )
+ Ntl_ReadModFree( pMod );
Vec_PtrFree( p->vModels );
}
Vec_PtrFree( p->vTokens );
@@ -267,11 +273,11 @@ static void Ioa_ReadFree( Ioa_ReadMan_t * p )
SeeAlso []
***********************************************************************/
-static Ioa_ReadMod_t * Ioa_ReadModAlloc()
+static Ntl_ReadMod_t * Ntl_ReadModAlloc()
{
- Ioa_ReadMod_t * p;
- p = ABC_ALLOC( Ioa_ReadMod_t, 1 );
- memset( p, 0, sizeof(Ioa_ReadMod_t) );
+ Ntl_ReadMod_t * p;
+ p = ABC_ALLOC( Ntl_ReadMod_t, 1 );
+ memset( p, 0, sizeof(Ntl_ReadMod_t) );
p->vInputs = Vec_PtrAlloc( 8 );
p->vOutputs = Vec_PtrAlloc( 8 );
p->vLatches = Vec_PtrAlloc( 8 );
@@ -294,7 +300,7 @@ static Ioa_ReadMod_t * Ioa_ReadModAlloc()
SeeAlso []
***********************************************************************/
-static void Ioa_ReadModFree( Ioa_ReadMod_t * p )
+static void Ntl_ReadModFree( Ntl_ReadMod_t * p )
{
Vec_PtrFree( p->vInputs );
Vec_PtrFree( p->vOutputs );
@@ -320,7 +326,7 @@ static void Ioa_ReadModFree( Ioa_ReadMod_t * p )
SeeAlso []
***********************************************************************/
-static int Ioa_ReadCountChars( char * pLine, char Char )
+static int Ntl_ReadCountChars( char * pLine, char Char )
{
char * pCur;
int Counter = 0;
@@ -341,7 +347,7 @@ static int Ioa_ReadCountChars( char * pLine, char Char )
SeeAlso []
***********************************************************************/
-static void Ioa_ReadCollectTokens( Vec_Ptr_t * vTokens, char * pInput, char * pOutput )
+static void Ntl_ReadCollectTokens( Vec_Ptr_t * vTokens, char * pInput, char * pOutput )
{
char * pCur;
Vec_PtrClear( vTokens );
@@ -365,15 +371,15 @@ static void Ioa_ReadCollectTokens( Vec_Ptr_t * vTokens, char * pInput, char * pO
SeeAlso []
***********************************************************************/
-static void Ioa_ReadSplitIntoTokens( Vec_Ptr_t * vTokens, char * pLine, char Stop )
+static void Ntl_ReadSplitIntoTokens( Vec_Ptr_t * vTokens, char * pLine, char Stop )
{
char * pCur;
// clear spaces
for ( pCur = pLine; *pCur != Stop; pCur++ )
- if ( Ioa_ReadCharIsSpace(*pCur) )
+ if ( Ntl_ReadCharIsSpace(*pCur) )
*pCur = 0;
// collect tokens
- Ioa_ReadCollectTokens( vTokens, pLine, pCur );
+ Ntl_ReadCollectTokens( vTokens, pLine, pCur );
}
/**Function*************************************************************
@@ -387,15 +393,15 @@ static void Ioa_ReadSplitIntoTokens( Vec_Ptr_t * vTokens, char * pLine, char Sto
SeeAlso []
***********************************************************************/
-static void Ioa_ReadSplitIntoTokensAndClear( Vec_Ptr_t * vTokens, char * pLine, char Stop, char Char )
+static void Ntl_ReadSplitIntoTokensAndClear( Vec_Ptr_t * vTokens, char * pLine, char Stop, char Char )
{
char * pCur;
// clear spaces
for ( pCur = pLine; *pCur != Stop; pCur++ )
- if ( Ioa_ReadCharIsSpace(*pCur) || *pCur == Char )
+ if ( Ntl_ReadCharIsSpace(*pCur) || *pCur == Char )
*pCur = 0;
// collect tokens
- Ioa_ReadCollectTokens( vTokens, pLine, pCur );
+ Ntl_ReadCollectTokens( vTokens, pLine, pCur );
}
/**Function*************************************************************
@@ -409,11 +415,11 @@ static void Ioa_ReadSplitIntoTokensAndClear( Vec_Ptr_t * vTokens, char * pLine,
SeeAlso []
***********************************************************************/
-static int Ioa_ReadGetLine( Ioa_ReadMan_t * p, char * pToken )
+static int Ntl_ReadGetLine( Ntl_ReadMan_t * p, char * pToken )
{
char * pLine;
int i;
- Vec_PtrForEachEntry( p->vLines, pLine, i )
+ Vec_PtrForEachEntry( char *, p->vLines, pLine, i )
if ( pToken < pLine )
return i;
return -1;
@@ -430,7 +436,7 @@ static int Ioa_ReadGetLine( Ioa_ReadMan_t * p, char * pToken )
SeeAlso []
***********************************************************************/
-static char * Ioa_ReadLoadFile( char * pFileName )
+static char * Ntl_ReadLoadFile( char * pFileName )
{
FILE * pFile;
int nFileSize;
@@ -438,14 +444,14 @@ static char * Ioa_ReadLoadFile( char * pFileName )
pFile = fopen( pFileName, "rb" );
if ( pFile == NULL )
{
- printf( "Ioa_ReadLoadFile(): The file is unavailable (absent or open).\n" );
+ printf( "Ntl_ReadLoadFile(): The file is unavailable (absent or open).\n" );
return NULL;
}
fseek( pFile, 0, SEEK_END );
nFileSize = ftell( pFile );
if ( nFileSize == 0 )
{
- printf( "Ioa_ReadLoadFile(): The file is empty.\n" );
+ printf( "Ntl_ReadLoadFile(): The file is empty.\n" );
return NULL;
}
pContents = ABC_ALLOC( char, nFileSize + 10 );
@@ -475,7 +481,7 @@ typedef struct buflist {
struct buflist * next;
} buflist;
-static char * Ioa_ReadLoadFileBz2( char * pFileName )
+static char * Ntl_ReadLoadFileBz2( char * pFileName )
{
FILE * pFile;
int nFileSize = 0;
@@ -488,12 +494,12 @@ static char * Ioa_ReadLoadFileBz2( char * pFileName )
pFile = fopen( pFileName, "rb" );
if ( pFile == NULL )
{
- printf( "Ioa_ReadLoadFileBz2(): The file is unavailable (absent or open).\n" );
+ printf( "Ntl_ReadLoadFileBz2(): The file is unavailable (absent or open).\n" );
return NULL;
}
b = BZ2_bzReadOpen(&bzError,pFile,0,0,NULL,0);
if (bzError != BZ_OK) {
- printf( "Ioa_ReadLoadFileBz2(): BZ2_bzReadOpen() failed with error %d.\n",bzError );
+ printf( "Ntl_ReadLoadFileBz2(): BZ2_bzReadOpen() failed with error %d.\n",bzError );
return NULL;
}
do {
@@ -525,7 +531,7 @@ static char * Ioa_ReadLoadFileBz2( char * pFileName )
nFileSize = ftell( pFile );
if ( nFileSize == 0 )
{
- printf( "Ioa_ReadLoadFileBz2(): The file is empty.\n" );
+ printf( "Ntl_ReadLoadFileBz2(): The file is empty.\n" );
return NULL;
}
pContents = ABC_ALLOC( char, nFileSize + 10 );
@@ -533,7 +539,7 @@ static char * Ioa_ReadLoadFileBz2( char * pFileName )
fread( pContents, nFileSize, 1, pFile );
} else {
// Some other error.
- printf( "Ioa_ReadLoadFileBz2(): Unable to read the compressed BLIF.\n" );
+ printf( "Ntl_ReadLoadFileBz2(): Unable to read the compressed BLIF.\n" );
return NULL;
}
fclose( pFile );
@@ -554,13 +560,13 @@ static char * Ioa_ReadLoadFileBz2( char * pFileName )
SeeAlso []
***********************************************************************/
-static char * Ioa_ReadLoadFileGz( char * pFileName )
+static char * Ntl_ReadLoadFileGz( char * pFileName )
{
const int READ_BLOCK_SIZE = 100000;
FILE * pFile;
char * pContents;
int amtRead, readBlock, nFileSize = READ_BLOCK_SIZE;
- pFile = gzopen( pFileName, "rb" ); // if pFileName doesn't end in ".gz" then this acts as a passthrough to fopen
+ pFile = (FILE *)gzopen( pFileName, "rb" ); // if pFileName doesn't end in ".gz" then this acts as a passthrough to fopen
pContents = ABC_ALLOC( char, nFileSize );
readBlock = 0;
while ((amtRead = gzread(pFile, pContents + readBlock * READ_BLOCK_SIZE, READ_BLOCK_SIZE)) == READ_BLOCK_SIZE) {
@@ -593,7 +599,7 @@ static char * Ioa_ReadLoadFileGz( char * pFileName )
SeeAlso []
***********************************************************************/
-static void Ioa_ReadReadPreparse( Ioa_ReadMan_t * p )
+static void Ntl_ReadReadPreparse( Ntl_ReadMan_t * p )
{
char * pCur, * pPrev;
int i, fComment = 0;
@@ -617,13 +623,13 @@ static void Ioa_ReadReadPreparse( Ioa_ReadMan_t * p )
}
// unfold the line extensions and sort lines by directive
- Vec_PtrForEachEntry( p->vLines, pCur, i )
+ Vec_PtrForEachEntry( char *, p->vLines, pCur, i )
{
if ( *pCur == 0 )
continue;
// find previous non-space character
for ( pPrev = pCur - 2; pPrev >= p->pBuffer; pPrev-- )
- if ( !Ioa_ReadCharIsSpace(*pPrev) )
+ if ( !Ntl_ReadCharIsSpace(*pPrev) )
break;
// if it is the line extender, overwrite it with spaces
if ( pPrev >= p->pBuffer && *pPrev == '\\' )
@@ -634,7 +640,7 @@ static void Ioa_ReadReadPreparse( Ioa_ReadMan_t * p )
continue;
}
// skip spaces at the beginning of the line
- while ( Ioa_ReadCharIsSpace(*pCur++) );
+ while ( Ntl_ReadCharIsSpace(*pCur++) );
// parse directives
if ( *(pCur-1) != '.' )
continue;
@@ -672,14 +678,14 @@ static void Ioa_ReadReadPreparse( Ioa_ReadMan_t * p )
p->pLatest->fBlackBox = 1;
else if ( !strncmp(pCur, "model", 5) )
{
- p->pLatest = Ioa_ReadModAlloc();
+ p->pLatest = Ntl_ReadModAlloc();
p->pLatest->pFirst = pCur;
p->pLatest->pMan = p;
}
else if ( !strncmp(pCur, "attrib", 6) )
{
if ( p->pLatest->pAttrib != NULL )
- fprintf( stdout, "Line %d: Skipping second .attrib line for this model.\n", Ioa_ReadGetLine(p, pCur) );
+ fprintf( stdout, "Line %d: Skipping second .attrib line for this model.\n", Ntl_ReadGetLine(p, pCur) );
else
p->pLatest->pAttrib = pCur;
}
@@ -691,7 +697,7 @@ static void Ioa_ReadReadPreparse( Ioa_ReadMan_t * p )
}
else if ( !strncmp(pCur, "exdc", 4) )
{
- fprintf( stdout, "Line %d: Skipping EXDC network.\n", Ioa_ReadGetLine(p, pCur) );
+ fprintf( stdout, "Line %d: Skipping EXDC network.\n", Ntl_ReadGetLine(p, pCur) );
break;
}
else if ( !strncmp(pCur, "no_merge", 8) )
@@ -703,7 +709,7 @@ static void Ioa_ReadReadPreparse( Ioa_ReadMan_t * p )
pCur--;
if ( pCur[strlen(pCur)-1] == '\r' )
pCur[strlen(pCur)-1] = 0;
- fprintf( stdout, "Line %d: Skipping line \"%s\".\n", Ioa_ReadGetLine(p, pCur), pCur );
+ fprintf( stdout, "Line %d: Skipping line \"%s\".\n", Ntl_ReadGetLine(p, pCur), pCur );
}
}
}
@@ -719,41 +725,41 @@ static void Ioa_ReadReadPreparse( Ioa_ReadMan_t * p )
SeeAlso []
***********************************************************************/
-static int Ioa_ReadReadInterfaces( Ioa_ReadMan_t * p )
+static int Ntl_ReadReadInterfaces( Ntl_ReadMan_t * p )
{
- Ioa_ReadMod_t * pMod;
+ Ntl_ReadMod_t * pMod;
char * pLine;
int i, k;
// iterate through the models
- Vec_PtrForEachEntry( p->vModels, pMod, i )
+ Vec_PtrForEachEntry( Ntl_ReadMod_t *, p->vModels, pMod, i )
{
// parse the model
- if ( !Ioa_ReadParseLineModel( pMod, pMod->pFirst ) )
+ if ( !Ntl_ReadParseLineModel( pMod, pMod->pFirst ) )
return 0;
// parse the model attributes
- if ( pMod->pAttrib && !Ioa_ReadParseLineAttrib( pMod, pMod->pAttrib ) )
+ if ( pMod->pAttrib && !Ntl_ReadParseLineAttrib( pMod, pMod->pAttrib ) )
return 0;
// parse no-merge
if ( pMod->fNoMerge )
pMod->pNtk->attrNoMerge = 1;
// parse the inputs
- Vec_PtrForEachEntry( pMod->vInputs, pLine, k )
- if ( !Ioa_ReadParseLineInputs( pMod, pLine ) )
+ Vec_PtrForEachEntry( char *, pMod->vInputs, pLine, k )
+ if ( !Ntl_ReadParseLineInputs( pMod, pLine ) )
return 0;
// parse the outputs
- Vec_PtrForEachEntry( pMod->vOutputs, pLine, k )
- if ( !Ioa_ReadParseLineOutputs( pMod, pLine ) )
+ Vec_PtrForEachEntry( char *, pMod->vOutputs, pLine, k )
+ if ( !Ntl_ReadParseLineOutputs( pMod, pLine ) )
return 0;
// parse the delay info
Ntl_ModelSetPioNumbers( pMod->pNtk );
- Vec_PtrForEachEntry( pMod->vDelays, pLine, k )
- if ( !Ioa_ReadParseLineDelay( pMod, pLine ) )
+ Vec_PtrForEachEntry( char *, pMod->vDelays, pLine, k )
+ if ( !Ntl_ReadParseLineDelay( pMod, pLine ) )
return 0;
- Vec_PtrForEachEntry( pMod->vTimeInputs, pLine, k )
- if ( !Ioa_ReadParseLineTimes( pMod, pLine, 0 ) )
+ Vec_PtrForEachEntry( char *, pMod->vTimeInputs, pLine, k )
+ if ( !Ntl_ReadParseLineTimes( pMod, pLine, 0 ) )
return 0;
- Vec_PtrForEachEntry( pMod->vTimeOutputs, pLine, k )
- if ( !Ioa_ReadParseLineTimes( pMod, pLine, 1 ) )
+ Vec_PtrForEachEntry( char *, pMod->vTimeOutputs, pLine, k )
+ if ( !Ntl_ReadParseLineTimes( pMod, pLine, 1 ) )
return 0;
// report timing line stats
if ( pMod->fInArr && pMod->fInReq )
@@ -780,26 +786,26 @@ static int Ioa_ReadReadInterfaces( Ioa_ReadMan_t * p )
SeeAlso []
***********************************************************************/
-static Ntl_Man_t * Ioa_ReadParse( Ioa_ReadMan_t * p )
+static Ntl_Man_t * Ntl_ReadParse( Ntl_ReadMan_t * p )
{
Ntl_Man_t * pDesign;
- Ioa_ReadMod_t * pMod;
+ Ntl_ReadMod_t * pMod;
char * pLine;
int i, k;
// iterate through the models
- Vec_PtrForEachEntry( p->vModels, pMod, i )
+ Vec_PtrForEachEntry( Ntl_ReadMod_t *, p->vModels, pMod, i )
{
// parse the latches
- Vec_PtrForEachEntry( pMod->vLatches, pLine, k )
- if ( !Ioa_ReadParseLineLatch( pMod, pLine ) )
+ Vec_PtrForEachEntry( char *, pMod->vLatches, pLine, k )
+ if ( !Ntl_ReadParseLineLatch( pMod, pLine ) )
return NULL;
// parse the nodes
- Vec_PtrForEachEntry( pMod->vNames, pLine, k )
- if ( !Ioa_ReadParseLineNamesBlif( pMod, pLine ) )
+ Vec_PtrForEachEntry( char *, pMod->vNames, pLine, k )
+ if ( !Ntl_ReadParseLineNamesBlif( pMod, pLine ) )
return NULL;
// parse the subcircuits
- Vec_PtrForEachEntry( pMod->vSubckts, pLine, k )
- if ( !Ioa_ReadParseLineSubckt( pMod, pLine ) )
+ Vec_PtrForEachEntry( char *, pMod->vSubckts, pLine, k )
+ if ( !Ntl_ReadParseLineSubckt( pMod, pLine ) )
return NULL;
// finalize the network
Ntl_ModelFixNonDrivenNets( pMod->pNtk );
@@ -807,7 +813,7 @@ static Ntl_Man_t * Ioa_ReadParse( Ioa_ReadMan_t * p )
if ( i == 0 )
return NULL;
// update the design name
- pMod = Vec_PtrEntry( p->vModels, 0 );
+ pMod = (Ntl_ReadMod_t *)Vec_PtrEntry( p->vModels, 0 );
if ( Ntl_ModelLatchNum(pMod->pNtk) > 0 )
Ntl_ModelTransformLatches( pMod->pNtk );
p->pDesign->pName = Ntl_ManStoreName( p->pDesign, pMod->pNtk->pName );
@@ -828,22 +834,22 @@ static Ntl_Man_t * Ioa_ReadParse( Ioa_ReadMan_t * p )
SeeAlso []
***********************************************************************/
-static int Ioa_ReadParseLineModel( Ioa_ReadMod_t * p, char * pLine )
+static int Ntl_ReadParseLineModel( Ntl_ReadMod_t * p, char * pLine )
{
Vec_Ptr_t * vTokens = p->pMan->vTokens;
char * pToken;
- Ioa_ReadSplitIntoTokens( vTokens, pLine, '\0' );
- pToken = Vec_PtrEntry( vTokens, 0 );
+ Ntl_ReadSplitIntoTokens( vTokens, pLine, '\0' );
+ pToken = (char *)Vec_PtrEntry( vTokens, 0 );
assert( !strcmp(pToken, "model") );
if ( Vec_PtrSize(vTokens) != 2 )
{
- sprintf( p->pMan->sError, "Line %d: The number of entries (%d) in .model line is different from two.", Ioa_ReadGetLine(p->pMan, pToken), Vec_PtrSize(vTokens) );
+ sprintf( p->pMan->sError, "Line %d: The number of entries (%d) in .model line is different from two.", Ntl_ReadGetLine(p->pMan, pToken), Vec_PtrSize(vTokens) );
return 0;
}
- p->pNtk = Ntl_ModelAlloc( p->pMan->pDesign, Vec_PtrEntry(vTokens, 1) );
+ p->pNtk = Ntl_ModelAlloc( p->pMan->pDesign, (char *)Vec_PtrEntry(vTokens, 1) );
if ( p->pNtk == NULL )
{
- sprintf( p->pMan->sError, "Line %d: Model %s already exists.", Ioa_ReadGetLine(p->pMan, pToken), (char*)Vec_PtrEntry(vTokens, 1) );
+ sprintf( p->pMan->sError, "Line %d: Model %s already exists.", Ntl_ReadGetLine(p->pMan, pToken), (char*)Vec_PtrEntry(vTokens, 1) );
return 0;
}
return 1;
@@ -860,17 +866,17 @@ static int Ioa_ReadParseLineModel( Ioa_ReadMod_t * p, char * pLine )
SeeAlso []
***********************************************************************/
-static int Ioa_ReadParseLineAttrib( Ioa_ReadMod_t * p, char * pLine )
+static int Ntl_ReadParseLineAttrib( Ntl_ReadMod_t * p, char * pLine )
{
Vec_Ptr_t * vTokens = p->pMan->vTokens;
char * pToken;
int i;
- Ioa_ReadSplitIntoTokens( vTokens, pLine, '\0' );
- pToken = Vec_PtrEntry( vTokens, 0 );
+ Ntl_ReadSplitIntoTokens( vTokens, pLine, '\0' );
+ pToken = (char *)Vec_PtrEntry( vTokens, 0 );
assert( !strncmp(pToken, "attrib", 6) );
- Vec_PtrForEachEntryStart( vTokens, pToken, i, 1 )
+ Vec_PtrForEachEntryStart( char *, vTokens, pToken, i, 1 )
{
- pToken = Vec_PtrEntry( vTokens, i );
+ pToken = (char *)Vec_PtrEntry( vTokens, i );
if ( strcmp( pToken, "white" ) == 0 )
p->pNtk->attrWhite = 1;
else if ( strcmp( pToken, "black" ) == 0 )
@@ -889,7 +895,7 @@ static int Ioa_ReadParseLineAttrib( Ioa_ReadMod_t * p, char * pLine )
p->pNtk->attrKeep = 0;
else
{
- sprintf( p->pMan->sError, "Line %d: Unknown attribute (%s) in the .attrib line of model %s.", Ioa_ReadGetLine(p->pMan, pToken), pToken, p->pNtk->pName );
+ sprintf( p->pMan->sError, "Line %d: Unknown attribute (%s) in the .attrib line of model %s.", Ntl_ReadGetLine(p->pMan, pToken), pToken, p->pNtk->pName );
return 0;
}
}
@@ -907,23 +913,23 @@ static int Ioa_ReadParseLineAttrib( Ioa_ReadMod_t * p, char * pLine )
SeeAlso []
***********************************************************************/
-static int Ioa_ReadParseLineInputs( Ioa_ReadMod_t * p, char * pLine )
+static int Ntl_ReadParseLineInputs( Ntl_ReadMod_t * p, char * pLine )
{
Ntl_Net_t * pNet;
Ntl_Obj_t * pObj;
Vec_Ptr_t * vTokens = p->pMan->vTokens;
char * pToken;
int i;
- Ioa_ReadSplitIntoTokens( vTokens, pLine, '\0' );
- pToken = Vec_PtrEntry(vTokens, 0);
+ Ntl_ReadSplitIntoTokens( vTokens, pLine, '\0' );
+ pToken = (char *)Vec_PtrEntry(vTokens, 0);
assert( !strcmp(pToken, "inputs") );
- Vec_PtrForEachEntryStart( vTokens, pToken, i, 1 )
+ Vec_PtrForEachEntryStart( char *, vTokens, pToken, i, 1 )
{
pObj = Ntl_ModelCreatePi( p->pNtk );
pNet = Ntl_ModelFindOrCreateNet( p->pNtk, pToken );
if ( !Ntl_ModelSetNetDriver( pObj, pNet ) )
{
- sprintf( p->pMan->sError, "Line %d: Net %s already has a driver.", Ioa_ReadGetLine(p->pMan, pToken), pNet->pName );
+ sprintf( p->pMan->sError, "Line %d: Net %s already has a driver.", Ntl_ReadGetLine(p->pMan, pToken), pNet->pName );
return 0;
}
}
@@ -941,17 +947,17 @@ static int Ioa_ReadParseLineInputs( Ioa_ReadMod_t * p, char * pLine )
SeeAlso []
***********************************************************************/
-static int Ioa_ReadParseLineOutputs( Ioa_ReadMod_t * p, char * pLine )
+static int Ntl_ReadParseLineOutputs( Ntl_ReadMod_t * p, char * pLine )
{
Ntl_Net_t * pNet;
Ntl_Obj_t * pObj;
Vec_Ptr_t * vTokens = p->pMan->vTokens;
char * pToken;
int i;
- Ioa_ReadSplitIntoTokens( vTokens, pLine, '\0' );
- pToken = Vec_PtrEntry(vTokens, 0);
+ Ntl_ReadSplitIntoTokens( vTokens, pLine, '\0' );
+ pToken = (char *)Vec_PtrEntry(vTokens, 0);
assert( !strcmp(pToken, "outputs") );
- Vec_PtrForEachEntryStart( vTokens, pToken, i, 1 )
+ Vec_PtrForEachEntryStart( char *, vTokens, pToken, i, 1 )
{
pNet = Ntl_ModelFindOrCreateNet( p->pNtk, pToken );
pObj = Ntl_ModelCreatePo( p->pNtk, pNet );
@@ -971,46 +977,47 @@ static int Ioa_ReadParseLineOutputs( Ioa_ReadMod_t * p, char * pLine )
SeeAlso []
***********************************************************************/
-static int Ioa_ReadParseLineLatch( Ioa_ReadMod_t * p, char * pLine )
+static int Ntl_ReadParseLineLatch( Ntl_ReadMod_t * p, char * pLine )
{
Vec_Ptr_t * vTokens = p->pMan->vTokens;
Ntl_Net_t * pNetLi, * pNetLo;
Ntl_Obj_t * pObj;
char * pToken, * pNameLi, * pNameLo;
- Ioa_ReadSplitIntoTokens( vTokens, pLine, '\0' );
- pToken = Vec_PtrEntry(vTokens,0);
+ Ntl_ReadSplitIntoTokens( vTokens, pLine, '\0' );
+ pToken = (char *)Vec_PtrEntry(vTokens,0);
assert( !strcmp(pToken, "latch") );
if ( Vec_PtrSize(vTokens) < 3 )
{
- sprintf( p->pMan->sError, "Line %d: Latch does not have input name and output name.", Ioa_ReadGetLine(p->pMan, pToken) );
+ sprintf( p->pMan->sError, "Line %d: Latch does not have input name and output name.", Ntl_ReadGetLine(p->pMan, pToken) );
return 0;
}
// create latch
- pNameLi = Vec_PtrEntry( vTokens, 1 );
- pNameLo = Vec_PtrEntry( vTokens, 2 );
+ pNameLi = (char *)Vec_PtrEntry( vTokens, 1 );
+ pNameLo = (char *)Vec_PtrEntry( vTokens, 2 );
pNetLi = Ntl_ModelFindOrCreateNet( p->pNtk, pNameLi );
pNetLo = Ntl_ModelFindOrCreateNet( p->pNtk, pNameLo );
pObj = Ntl_ModelCreateLatch( p->pNtk );
pObj->pFanio[0] = pNetLi;
if ( !Ntl_ModelSetNetDriver( pObj, pNetLo ) )
{
- sprintf( p->pMan->sError, "Line %d: Net %s already has a driver.", Ioa_ReadGetLine(p->pMan, pToken), pNetLo->pName );
+ sprintf( p->pMan->sError, "Line %d: Net %s already has a driver.", Ntl_ReadGetLine(p->pMan, pToken), pNetLo->pName );
return 0;
}
// get initial value
if ( Vec_PtrSize(vTokens) > 3 )
- pObj->LatchId.regInit = atoi( Vec_PtrEntry(vTokens,Vec_PtrSize(vTokens)-1) );
+ pObj->LatchId.regInit = atoi( (char *)Vec_PtrEntry(vTokens,Vec_PtrSize(vTokens)-1) );
else
pObj->LatchId.regInit = 2;
if ( pObj->LatchId.regInit < 0 || pObj->LatchId.regInit > 2 )
{
- sprintf( p->pMan->sError, "Line %d: Initial state of the latch is incorrect \"%s\".", Ioa_ReadGetLine(p->pMan, pToken), (char*)Vec_PtrEntry(vTokens,3) );
+ sprintf( p->pMan->sError, "Line %d: Initial state of the latch is incorrect \"%s\".", Ntl_ReadGetLine(p->pMan, pToken), (char*)Vec_PtrEntry(vTokens,3) );
return 0;
}
// get the register class
- if ( Vec_PtrSize(vTokens) == 6 )
+// if ( Vec_PtrSize(vTokens) == 6 )
+ if ( Vec_PtrSize(vTokens) == 5 || Vec_PtrSize(vTokens) == 6 )
{
- pToken = Vec_PtrEntry(vTokens,3);
+ pToken = (char *)Vec_PtrEntry(vTokens,3);
if ( strcmp( pToken, "fe" ) == 0 )
pObj->LatchId.regType = 1;
else if ( strcmp( pToken, "re" ) == 0 )
@@ -1025,19 +1032,20 @@ static int Ioa_ReadParseLineLatch( Ioa_ReadMod_t * p, char * pLine )
pObj->LatchId.regClass = atoi(pToken);
else
{
- sprintf( p->pMan->sError, "Line %d: Type/class of the latch is incorrect \"%s\".", Ioa_ReadGetLine(p->pMan, pToken), pToken );
+ sprintf( p->pMan->sError, "Line %d: Type/class of the latch is incorrect \"%s\".", Ntl_ReadGetLine(p->pMan, pToken), pToken );
return 0;
}
}
if ( pObj->LatchId.regClass < 0 || pObj->LatchId.regClass > (1<<24) )
{
- sprintf( p->pMan->sError, "Line %d: Class of the latch is incorrect \"%s\".", Ioa_ReadGetLine(p->pMan, pToken), (char*)Vec_PtrEntry(vTokens,3) );
+ sprintf( p->pMan->sError, "Line %d: Class of the latch is incorrect \"%s\".", Ntl_ReadGetLine(p->pMan, pToken), (char*)Vec_PtrEntry(vTokens,3) );
return 0;
}
// get the clock
- if ( Vec_PtrSize(vTokens) == 5 || Vec_PtrSize(vTokens) == 6 )
+// if ( Vec_PtrSize(vTokens) == 5 || Vec_PtrSize(vTokens) == 6 )
+ if ( Vec_PtrSize(vTokens) == 6 )
{
- pToken = Vec_PtrEntry(vTokens,Vec_PtrSize(vTokens)-2);
+ pToken = (char *)Vec_PtrEntry(vTokens,Vec_PtrSize(vTokens)-2);
pNetLi = Ntl_ModelFindOrCreateNet( p->pNtk, pToken );
pObj->pClock = pNetLi;
}
@@ -1055,7 +1063,7 @@ static int Ioa_ReadParseLineLatch( Ioa_ReadMod_t * p, char * pLine )
SeeAlso []
***********************************************************************/
-static int Ioa_ReadParseLineSubckt( Ioa_ReadMod_t * p, char * pLine )
+static int Ntl_ReadParseLineSubckt( Ntl_ReadMod_t * p, char * pLine )
{
Vec_Ptr_t * vTokens = p->pMan->vTokens;
Ntl_Mod_t * pModel;
@@ -1065,17 +1073,17 @@ static int Ioa_ReadParseLineSubckt( Ioa_ReadMod_t * p, char * pLine )
int nEquals, i, k;
// split the line into tokens
- nEquals = Ioa_ReadCountChars( pLine, '=' );
- Ioa_ReadSplitIntoTokensAndClear( vTokens, pLine, '\0', '=' );
- pToken = Vec_PtrEntry(vTokens,0);
+ nEquals = Ntl_ReadCountChars( pLine, '=' );
+ Ntl_ReadSplitIntoTokensAndClear( vTokens, pLine, '\0', '=' );
+ pToken = (char *)Vec_PtrEntry(vTokens,0);
assert( !strcmp(pToken, "subckt") );
// get the model for this box
- pName = Vec_PtrEntry(vTokens,1);
+ pName = (char *)Vec_PtrEntry(vTokens,1);
pModel = Ntl_ManFindModel( p->pMan->pDesign, pName );
if ( pModel == NULL )
{
- sprintf( p->pMan->sError, "Line %d: Cannot find the model for subcircuit %s.", Ioa_ReadGetLine(p->pMan, pToken), pName );
+ sprintf( p->pMan->sError, "Line %d: Cannot find the model for subcircuit %s.", Ntl_ReadGetLine(p->pMan, pToken), pName );
return 0;
}
/*
@@ -1087,9 +1095,9 @@ static int Ioa_ReadParseLineSubckt( Ioa_ReadMod_t * p, char * pLine )
pToken = Vec_PtrEntry( vTokens, Vec_PtrSize(vTokens) - 1 );
for ( ; *pToken; pToken++ );
for ( ; *pToken == 0; pToken++ );
- Ioa_ReadSplitIntoTokensAndClear( vTokens2, pToken, '\0', '=' );
+ Ntl_ReadSplitIntoTokensAndClear( vTokens2, pToken, '\0', '=' );
// assert( Vec_PtrSize( vTokens2 ) == 2 );
- Vec_PtrForEachEntry( vTokens2, pToken, i )
+ Vec_PtrForEachEntry( char *, vTokens2, pToken, i )
Vec_PtrPush( vTokens, pToken );
nEquals += Vec_PtrSize(vTokens2)/2;
Vec_PtrFree( vTokens2 );
@@ -1099,7 +1107,7 @@ static int Ioa_ReadParseLineSubckt( Ioa_ReadMod_t * p, char * pLine )
if ( nEquals != Ntl_ModelPiNum(pModel) + Ntl_ModelPoNum(pModel) )
{
sprintf( p->pMan->sError, "Line %d: The number of ports (%d) in .subckt %s differs from the sum of PIs and POs of the model (%d).",
- Ioa_ReadGetLine(p->pMan, pToken), nEquals, pName, Ntl_ModelPiNum(pModel) + Ntl_ModelPoNum(pModel) );
+ Ntl_ReadGetLine(p->pMan, pToken), nEquals, pName, Ntl_ModelPiNum(pModel) + Ntl_ModelPoNum(pModel) );
return 0;
}
@@ -1119,7 +1127,7 @@ static int Ioa_ReadParseLineSubckt( Ioa_ReadMod_t * p, char * pLine )
if ( k == nEquals )
{
sprintf( p->pMan->sError, "Line %d: Cannot find PI \"%s\" of the model \"%s\" as a formal input of the subcircuit.",
- Ioa_ReadGetLine(p->pMan, pToken), pName, pModel->pName );
+ Ntl_ReadGetLine(p->pMan, pToken), pName, pModel->pName );
return 0;
}
// create the BI with the actual name
@@ -1136,7 +1144,7 @@ static int Ioa_ReadParseLineSubckt( Ioa_ReadMod_t * p, char * pLine )
if ( k == nEquals )
{
sprintf( p->pMan->sError, "Line %d: Cannot find PO \"%s\" of the model \"%s\" as a formal output of the subcircuit.",
- Ioa_ReadGetLine(p->pMan, pToken), pName, pModel->pName );
+ Ntl_ReadGetLine(p->pMan, pToken), pName, pModel->pName );
return 0;
}
// create the BI with the actual name
@@ -1157,54 +1165,54 @@ static int Ioa_ReadParseLineSubckt( Ioa_ReadMod_t * p, char * pLine )
SeeAlso []
***********************************************************************/
-static int Ioa_ReadParseLineDelay( Ioa_ReadMod_t * p, char * pLine )
+static int Ntl_ReadParseLineDelay( Ntl_ReadMod_t * p, char * pLine )
{
Vec_Ptr_t * vTokens = p->pMan->vTokens;
int RetValue1, RetValue2, Number1, Number2, Temp;
char * pToken, * pTokenNum;
float Delay;
assert( sizeof(float) == sizeof(int) );
- Ioa_ReadSplitIntoTokens( vTokens, pLine, '\0' );
- pToken = Vec_PtrEntry(vTokens,0);
+ Ntl_ReadSplitIntoTokens( vTokens, pLine, '\0' );
+ pToken = (char *)Vec_PtrEntry(vTokens,0);
assert( !strcmp(pToken, "delay") );
if ( Vec_PtrSize(vTokens) < 2 && Vec_PtrSize(vTokens) > 4 )
{
- sprintf( p->pMan->sError, "Line %d: Delay line does not have a valid number of parameters (1, 2, or 3).", Ioa_ReadGetLine(p->pMan, pToken) );
+ sprintf( p->pMan->sError, "Line %d: Delay line does not have a valid number of parameters (1, 2, or 3).", Ntl_ReadGetLine(p->pMan, pToken) );
return 0;
}
// find the delay number
- pTokenNum = Vec_PtrEntryLast(vTokens);
+ pTokenNum = (char *)Vec_PtrEntryLast(vTokens);
Delay = atof( pTokenNum );
if ( Delay == 0.0 && pTokenNum[0] != '0' )
{
- sprintf( p->pMan->sError, "Line %d: Delay value (%s) appears to be invalid.", Ioa_ReadGetLine(p->pMan, pToken), (char*)Vec_PtrEntryLast(vTokens) );
+ sprintf( p->pMan->sError, "Line %d: Delay value (%s) appears to be invalid.", Ntl_ReadGetLine(p->pMan, pToken), (char*)Vec_PtrEntryLast(vTokens) );
return 0;
}
// find the PI/PO numbers
RetValue1 = 0; Number1 = -1;
if ( Vec_PtrSize(vTokens) > 2 )
{
- RetValue1 = Ntl_ModelFindPioNumber( p->pNtk, 0, 0, Vec_PtrEntry(vTokens, 1), &Number1 );
+ RetValue1 = Ntl_ModelFindPioNumber( p->pNtk, 0, 0, (char *)Vec_PtrEntry(vTokens, 1), &Number1 );
if ( RetValue1 == 0 )
{
- sprintf( p->pMan->sError, "Line %d: Cannot find signal \"%s\" among PIs/POs.", Ioa_ReadGetLine(p->pMan, pToken), (char*)Vec_PtrEntry(vTokens, 1) );
+ sprintf( p->pMan->sError, "Line %d: Cannot find signal \"%s\" among PIs/POs.", Ntl_ReadGetLine(p->pMan, pToken), (char*)Vec_PtrEntry(vTokens, 1) );
return 0;
}
}
RetValue2 = 0; Number2 = -1;
if ( Vec_PtrSize(vTokens) > 3 )
{
- RetValue2 = Ntl_ModelFindPioNumber( p->pNtk, 0, 0, Vec_PtrEntry(vTokens, 2), &Number2 );
+ RetValue2 = Ntl_ModelFindPioNumber( p->pNtk, 0, 0, (char *)Vec_PtrEntry(vTokens, 2), &Number2 );
if ( RetValue2 == 0 )
{
- sprintf( p->pMan->sError, "Line %d: Cannot find signal \"%s\" among PIs/POs.", Ioa_ReadGetLine(p->pMan, pToken), (char*)Vec_PtrEntry(vTokens, 2) );
+ sprintf( p->pMan->sError, "Line %d: Cannot find signal \"%s\" among PIs/POs.", Ntl_ReadGetLine(p->pMan, pToken), (char*)Vec_PtrEntry(vTokens, 2) );
return 0;
}
}
if ( RetValue1 == RetValue2 && RetValue1 )
{
sprintf( p->pMan->sError, "Line %d: Both signals \"%s\" and \"%s\" listed appear to be PIs or POs.",
- Ioa_ReadGetLine(p->pMan, pToken), (char*)Vec_PtrEntry(vTokens, 1), (char*)Vec_PtrEntry(vTokens, 2) );
+ Ntl_ReadGetLine(p->pMan, pToken), (char*)Vec_PtrEntry(vTokens, 1), (char*)Vec_PtrEntry(vTokens, 2) );
return 0;
}
if ( RetValue2 < RetValue1 )
@@ -1234,26 +1242,26 @@ static int Ioa_ReadParseLineDelay( Ioa_ReadMod_t * p, char * pLine )
SeeAlso []
***********************************************************************/
-static int Ioa_ReadParseLineTimes( Ioa_ReadMod_t * p, char * pLine, int fOutput )
+static int Ntl_ReadParseLineTimes( Ntl_ReadMod_t * p, char * pLine, int fOutput )
{
Vec_Ptr_t * vTokens = p->pMan->vTokens;
int RetValue, Number = -1;
char * pToken, * pTokenNum;
float Delay;
assert( sizeof(float) == sizeof(int) );
- Ioa_ReadSplitIntoTokens( vTokens, pLine, '\0' );
- pToken = Vec_PtrEntry(vTokens,0);
+ Ntl_ReadSplitIntoTokens( vTokens, pLine, '\0' );
+ pToken = (char *)Vec_PtrEntry(vTokens,0);
if ( fOutput )
assert( !strncmp(pToken, "output_", 7) );
else
assert( !strncmp(pToken, "input_", 6) );
if ( Vec_PtrSize(vTokens) != 2 && Vec_PtrSize(vTokens) != 3 )
{
- sprintf( p->pMan->sError, "Line %d: Delay line does not have a valid number of parameters (2 or 3).", Ioa_ReadGetLine(p->pMan, pToken) );
+ sprintf( p->pMan->sError, "Line %d: Delay line does not have a valid number of parameters (2 or 3).", Ntl_ReadGetLine(p->pMan, pToken) );
return 0;
}
// find the delay number
- pTokenNum = Vec_PtrEntryLast(vTokens);
+ pTokenNum = (char *)Vec_PtrEntryLast(vTokens);
if ( !strcmp( pTokenNum, "-inf" ) )
Delay = -TIM_ETERNITY;
else if ( !strcmp( pTokenNum, "inf" ) )
@@ -1262,7 +1270,7 @@ static int Ioa_ReadParseLineTimes( Ioa_ReadMod_t * p, char * pLine, int fOutput
Delay = atof( pTokenNum );
if ( Delay == 0.0 && pTokenNum[0] != '0' )
{
- sprintf( p->pMan->sError, "Line %d: Delay value (%s) appears to be invalid.", Ioa_ReadGetLine(p->pMan, pToken), (char*)Vec_PtrEntryLast(vTokens) );
+ sprintf( p->pMan->sError, "Line %d: Delay value (%s) appears to be invalid.", Ntl_ReadGetLine(p->pMan, pToken), (char*)Vec_PtrEntryLast(vTokens) );
return 0;
}
// find the PI/PO numbers
@@ -1270,10 +1278,10 @@ static int Ioa_ReadParseLineTimes( Ioa_ReadMod_t * p, char * pLine, int fOutput
{
if ( Vec_PtrSize(vTokens) == 3 )
{
- RetValue = Ntl_ModelFindPioNumber( p->pNtk, 0, 1, Vec_PtrEntry(vTokens, 1), &Number );
+ RetValue = Ntl_ModelFindPioNumber( p->pNtk, 0, 1, (char *)Vec_PtrEntry(vTokens, 1), &Number );
if ( RetValue == 0 )
{
- sprintf( p->pMan->sError, "Line %d: Cannot find signal \"%s\" among POs.", Ioa_ReadGetLine(p->pMan, pToken), (char*)Vec_PtrEntry(vTokens, 1) );
+ sprintf( p->pMan->sError, "Line %d: Cannot find signal \"%s\" among POs.", Ntl_ReadGetLine(p->pMan, pToken), (char*)Vec_PtrEntry(vTokens, 1) );
return 0;
}
}
@@ -1287,10 +1295,10 @@ static int Ioa_ReadParseLineTimes( Ioa_ReadMod_t * p, char * pLine, int fOutput
{
if ( Vec_PtrSize(vTokens) == 3 )
{
- RetValue = Ntl_ModelFindPioNumber( p->pNtk, 1, 0, Vec_PtrEntry(vTokens, 1), &Number );
+ RetValue = Ntl_ModelFindPioNumber( p->pNtk, 1, 0, (char *)Vec_PtrEntry(vTokens, 1), &Number );
if ( RetValue == 0 )
{
- sprintf( p->pMan->sError, "Line %d: Cannot find signal \"%s\" among PIs.", Ioa_ReadGetLine(p->pMan, pToken), (char*)Vec_PtrEntry(vTokens, 1) );
+ sprintf( p->pMan->sError, "Line %d: Cannot find signal \"%s\" among PIs.", Ntl_ReadGetLine(p->pMan, pToken), (char*)Vec_PtrEntry(vTokens, 1) );
return 0;
}
}
@@ -1315,7 +1323,7 @@ static int Ioa_ReadParseLineTimes( Ioa_ReadMod_t * p, char * pLine, int fOutput
SeeAlso []
***********************************************************************/
-static char * Ioa_ReadParseTableBlif( Ioa_ReadMod_t * p, char * pTable, int nFanins )
+static char * Ntl_ReadParseTableBlif( Ntl_ReadMod_t * p, char * pTable, int nFanins )
{
Vec_Ptr_t * vTokens = p->pMan->vTokens;
Vec_Str_t * vFunc = p->pMan->vFunc;
@@ -1325,52 +1333,52 @@ static char * Ioa_ReadParseTableBlif( Ioa_ReadMod_t * p, char * pTable, int nFan
p->pMan->nTablesRead++;
// get the tokens
- Ioa_ReadSplitIntoTokens( vTokens, pTable, '.' );
+ Ntl_ReadSplitIntoTokens( vTokens, pTable, '.' );
if ( Vec_PtrSize(vTokens) == 0 )
return Ntl_ManStoreSop( p->pMan->pDesign->pMemSops, " 0\n" );
if ( Vec_PtrSize(vTokens) == 1 )
{
- pOutput = Vec_PtrEntry( vTokens, 0 );
+ pOutput = (char *)Vec_PtrEntry( vTokens, 0 );
if ( *pOutput == '\"' )
return Ntl_ManStoreSop( p->pMan->pDesign->pMemSops, pOutput );
if ( ((pOutput[0] - '0') & 0x8E) || pOutput[1] )
{
- sprintf( p->pMan->sError, "Line %d: Constant table has wrong output value \"%s\".", Ioa_ReadGetLine(p->pMan, pOutput), pOutput );
+ sprintf( p->pMan->sError, "Line %d: Constant table has wrong output value \"%s\".", Ntl_ReadGetLine(p->pMan, pOutput), pOutput );
return NULL;
}
return Ntl_ManStoreSop( p->pMan->pDesign->pMemSops, (pOutput[0] == '0') ? " 0\n" : " 1\n" );
}
- pProduct = Vec_PtrEntry( vTokens, 0 );
+ pProduct = (char *)Vec_PtrEntry( vTokens, 0 );
if ( Vec_PtrSize(vTokens) % 2 == 1 )
{
- sprintf( p->pMan->sError, "Line %d: Table has odd number of tokens (%d).", Ioa_ReadGetLine(p->pMan, pProduct), Vec_PtrSize(vTokens) );
+ sprintf( p->pMan->sError, "Line %d: Table has odd number of tokens (%d).", Ntl_ReadGetLine(p->pMan, pProduct), Vec_PtrSize(vTokens) );
return NULL;
}
// parse the table
Vec_StrClear( vFunc );
for ( i = 0; i < Vec_PtrSize(vTokens)/2; i++ )
{
- pProduct = Vec_PtrEntry( vTokens, 2*i + 0 );
- pOutput = Vec_PtrEntry( vTokens, 2*i + 1 );
+ pProduct = (char *)Vec_PtrEntry( vTokens, 2*i + 0 );
+ pOutput = (char *)Vec_PtrEntry( vTokens, 2*i + 1 );
if ( strlen(pProduct) != (unsigned)nFanins )
{
- sprintf( p->pMan->sError, "Line %d: Cube \"%s\" has size different from the fanin count (%d).", Ioa_ReadGetLine(p->pMan, pProduct), pProduct, nFanins );
+ sprintf( p->pMan->sError, "Line %d: Cube \"%s\" has size different from the fanin count (%d).", Ntl_ReadGetLine(p->pMan, pProduct), pProduct, nFanins );
return NULL;
}
if ( ((pOutput[0] - '0') & 0x8E) || pOutput[1] )
{
- sprintf( p->pMan->sError, "Line %d: Output value \"%s\" is incorrect.", Ioa_ReadGetLine(p->pMan, pProduct), pOutput );
+ sprintf( p->pMan->sError, "Line %d: Output value \"%s\" is incorrect.", Ntl_ReadGetLine(p->pMan, pProduct), pOutput );
return NULL;
}
if ( Polarity == -1 )
Polarity = pOutput[0] - '0';
else if ( Polarity != pOutput[0] - '0' )
{
- sprintf( p->pMan->sError, "Line %d: Output value \"%s\" differs from the value in the first line of the table (%d).", Ioa_ReadGetLine(p->pMan, pProduct), pOutput, Polarity );
+ sprintf( p->pMan->sError, "Line %d: Output value \"%s\" differs from the value in the first line of the table (%d).", Ntl_ReadGetLine(p->pMan, pProduct), pOutput, Polarity );
return NULL;
}
// parse one product
- Vec_StrAppend( vFunc, pProduct );
+ Vec_StrPrintStr( vFunc, pProduct );
Vec_StrPush( vFunc, ' ' );
Vec_StrPush( vFunc, pOutput[0] );
Vec_StrPush( vFunc, '\n' );
@@ -1390,36 +1398,36 @@ static char * Ioa_ReadParseTableBlif( Ioa_ReadMod_t * p, char * pTable, int nFan
SeeAlso []
***********************************************************************/
-static int Ioa_ReadParseLineNamesBlif( Ioa_ReadMod_t * p, char * pLine )
+static int Ntl_ReadParseLineNamesBlif( Ntl_ReadMod_t * p, char * pLine )
{
Vec_Ptr_t * vTokens = p->pMan->vTokens;
Ntl_Obj_t * pNode;
Ntl_Net_t * pNetOut, * pNetIn;
char * pNameOut, * pNameIn;
int i;
- Ioa_ReadSplitIntoTokens( vTokens, pLine, '\0' );
+ Ntl_ReadSplitIntoTokens( vTokens, pLine, '\0' );
// parse the mapped node
// if ( !strcmp(Vec_PtrEntry(vTokens,0), "gate") )
-// return Ioa_ReadParseLineGateBlif( p, vTokens );
+// return Ntl_ReadParseLineGateBlif( p, vTokens );
// parse the regular name line
- assert( !strcmp(Vec_PtrEntry(vTokens,0), "names") );
- pNameOut = Vec_PtrEntryLast( vTokens );
+ assert( !strcmp((char *)Vec_PtrEntry(vTokens,0), "names") );
+ pNameOut = (char *)Vec_PtrEntryLast( vTokens );
pNetOut = Ntl_ModelFindOrCreateNet( p->pNtk, pNameOut );
// create fanins
pNode = Ntl_ModelCreateNode( p->pNtk, Vec_PtrSize(vTokens) - 2 );
for ( i = 0; i < Vec_PtrSize(vTokens) - 2; i++ )
{
- pNameIn = Vec_PtrEntry(vTokens, i+1);
+ pNameIn = (char *)Vec_PtrEntry(vTokens, i+1);
pNetIn = Ntl_ModelFindOrCreateNet( p->pNtk, pNameIn );
Ntl_ObjSetFanin( pNode, pNetIn, i );
}
if ( !Ntl_ModelSetNetDriver( pNode, pNetOut ) )
{
- sprintf( p->pMan->sError, "Line %d: Signal \"%s\" is defined more than once.", Ioa_ReadGetLine(p->pMan, pNameOut), pNameOut );
+ sprintf( p->pMan->sError, "Line %d: Signal \"%s\" is defined more than once.", Ntl_ReadGetLine(p->pMan, pNameOut), pNameOut );
return 0;
}
// parse the table of this node
- pNode->pSop = Ioa_ReadParseTableBlif( p, pNameOut + strlen(pNameOut), pNode->nFanins );
+ pNode->pSop = Ntl_ReadParseTableBlif( p, pNameOut + strlen(pNameOut), pNode->nFanins );
if ( pNode->pSop == NULL )
return 0;
pNode->pSop = Ntl_ManStoreSop( p->pNtk->pMan->pMemSops, pNode->pSop );
@@ -1432,3 +1440,5 @@ static int Ioa_ReadParseLineNamesBlif( Ioa_ReadMod_t * p, char * pLine )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ntl/ntlSweep.c b/src/aig/ntl/ntlSweep.c
index b2c700fb..29e40f30 100644
--- a/src/aig/ntl/ntlSweep.c
+++ b/src/aig/ntl/ntlSweep.c
@@ -20,6 +20,9 @@
#include "ntl.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -207,3 +210,5 @@ int Ntl_ManSweep( Ntl_Man_t * p, int fVerbose )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ntl/ntlTable.c b/src/aig/ntl/ntlTable.c
index 0b87c8be..23207081 100644
--- a/src/aig/ntl/ntlTable.c
+++ b/src/aig/ntl/ntlTable.c
@@ -20,6 +20,9 @@
#include "ntl.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -55,7 +58,9 @@ static unsigned Ntl_HashString( const char * pName, int TableSize )
Ntl_Net_t * Ntl_ModelCreateNet( Ntl_Mod_t * p, const char * pName )
{
Ntl_Net_t * pNet;
- pNet = (Ntl_Net_t *)Aig_MmFlexEntryFetch( p->pMan->pMemObjs, sizeof(Ntl_Net_t) + strlen(pName) + 1 );
+ int nSize = sizeof(Ntl_Net_t) + strlen(pName) + 1;
+ nSize = (nSize / sizeof(char*) + ((nSize % sizeof(char*)) > 0)) * sizeof(char*); // added by Saurabh on Sep 3, 2009
+ pNet = (Ntl_Net_t *)Aig_MmFlexEntryFetch( p->pMan->pMemObjs, nSize );
memset( pNet, 0, sizeof(Ntl_Net_t) );
strcpy( pNet->pName, pName );
pNet->NetId = Vec_PtrSize( p->vNets );
@@ -362,7 +367,7 @@ int Ntl_ModelFindPioNumber( Ntl_Mod_t * p, int fPiOnly, int fPoOnly, const char
}
if ( fPoOnly )
{
- pTerm = pNet->pCopy;
+ pTerm = (Ntl_Obj_t *)pNet->pCopy;
if ( pTerm && Ntl_ObjIsPo(pTerm) )
{
*pNumber = pTerm->iTemp;
@@ -370,7 +375,7 @@ int Ntl_ModelFindPioNumber( Ntl_Mod_t * p, int fPiOnly, int fPoOnly, const char
}
return 0;
}
- pTerm = pNet->pCopy;
+ pTerm = (Ntl_Obj_t *)pNet->pCopy;
if ( pTerm && Ntl_ObjIsPo(pTerm) )
{
*pNumber = pTerm->iTemp;
@@ -545,3 +550,5 @@ Ntl_Mod_t * Ntl_ManFindModel( Ntl_Man_t * p, const char * pName )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ntl/ntlTime.c b/src/aig/ntl/ntlTime.c
index f9fadaa8..7a531482 100644
--- a/src/aig/ntl/ntlTime.c
+++ b/src/aig/ntl/ntlTime.c
@@ -20,6 +20,9 @@
#include "ntl.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -217,7 +220,7 @@ Tim_Man_t * Ntl_ManCreateTiming( Ntl_Man_t * p )
// set up the boxes
iBox = 0;
curPi = p->iLastCi;
- Vec_PtrForEachEntry( p->vVisNodes, pObj, i )
+ Vec_PtrForEachEntry( Ntl_Obj_t *, p->vVisNodes, pObj, i )
{
if ( !Ntl_ObjIsBox(pObj) )
continue;
@@ -238,3 +241,5 @@ Tim_Man_t * Ntl_ManCreateTiming( Ntl_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ntl/ntlUtil.c b/src/aig/ntl/ntlUtil.c
index 0bd86247..c3c6fd49 100644
--- a/src/aig/ntl/ntlUtil.c
+++ b/src/aig/ntl/ntlUtil.c
@@ -20,6 +20,9 @@
#include "ntl.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -30,6 +33,32 @@
/**Function*************************************************************
+ Synopsis [Returns one if the file has a given extension.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Ntl_FileIsType( char * pFileName, char * pS1, char * pS2, char * pS3 )
+{
+ int lenS, lenF = strlen(pFileName);
+ lenS = pS1 ? strlen(pS1) : 0;
+ if ( lenS && lenF > lenS && !strncmp( pFileName+lenF-lenS, pS1, lenS ) )
+ return 1;
+ lenS = pS2 ? strlen(pS2) : 0;
+ if ( lenS && lenF > lenS && !strncmp( pFileName+lenF-lenS, pS2, lenS ) )
+ return 1;
+ lenS = pS3 ? strlen(pS3) : 0;
+ if ( lenS && lenF > lenS && !strncmp( pFileName+lenF-lenS, pS3, lenS ) )
+ return 1;
+ return 0;
+}
+
+/**Function*************************************************************
+
Synopsis [Reads the maximum number of fanins.]
Description []
@@ -419,7 +448,7 @@ Vec_Vec_t * Ntl_ManTransformRegClasses( Ntl_Man_t * pMan, int nSizeMax, int fVer
if ( fVerbose )
{
printf( "The number of selected register clases = %d.\n", Vec_PtrSize(vParts) );
- Vec_PtrForEachEntry( vParts, vPart, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vParts, vPart, i )
printf( "(%d, %d) ", i, Vec_IntSize(vPart) );
printf( "\n" );
}
@@ -704,3 +733,5 @@ void Ntl_ManRemoveUselessNets( Ntl_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ntl/ntlWriteBlif.c b/src/aig/ntl/ntlWriteBlif.c
index e6e4cbdd..f9b2781f 100644
--- a/src/aig/ntl/ntlWriteBlif.c
+++ b/src/aig/ntl/ntlWriteBlif.c
@@ -27,6 +27,9 @@
#include "bzlib.h"
#include "zlib.h"
+ABC_NAMESPACE_IMPL_START
+
+
#ifdef _WIN32
#define vsnprintf _vsnprintf
#endif
@@ -50,7 +53,7 @@
SeeAlso []
***********************************************************************/
-void Ioa_WriteBlifModel( FILE * pFile, Ntl_Mod_t * pModel, int fMain )
+void Ntl_ManWriteBlifModel( FILE * pFile, Ntl_Mod_t * pModel, int fMain )
{
Ntl_Obj_t * pObj;
Ntl_Net_t * pNet;
@@ -195,7 +198,7 @@ void Ioa_WriteBlifModel( FILE * pFile, Ntl_Mod_t * pModel, int fMain )
SeeAlso []
***********************************************************************/
-void Ioa_WriteBlif_old( Ntl_Man_t * p, char * pFileName )
+void Ntl_ManWriteBlif_old( Ntl_Man_t * p, char * pFileName )
{
FILE * pFile;
Ntl_Mod_t * pModel;
@@ -204,13 +207,13 @@ void Ioa_WriteBlif_old( Ntl_Man_t * p, char * pFileName )
pFile = fopen( pFileName, "w" );
if ( pFile == NULL )
{
- fprintf( stdout, "Ioa_WriteBlif(): Cannot open the output file \"%s\".\n", pFileName );
+ fprintf( stdout, "Ntl_ManWriteBlif(): Cannot open the output file \"%s\".\n", pFileName );
return;
}
- fprintf( pFile, "# Benchmark \"%s\" written by ABC-8 on %s\n", p->pName, Ioa_TimeStamp() );
+ fprintf( pFile, "# Benchmark \"%s\" written by ABC-8 on %s\n", p->pName, Aig_TimeStamp() );
// write the models
Ntl_ManForEachModel( p, pModel, i )
- Ioa_WriteBlifModel( pFile, pModel, i==0 );
+ Ntl_ManWriteBlifModel( pFile, pModel, i==0 );
// close the file
fclose( pFile );
}
@@ -226,11 +229,11 @@ void Ioa_WriteBlif_old( Ntl_Man_t * p, char * pFileName )
SeeAlso []
***********************************************************************/
-void Ioa_WriteBlifLogic( Nwk_Man_t * pNtk, Ntl_Man_t * p, char * pFileName )
+void Ntl_ManWriteBlifLogic( Nwk_Man_t * pNtk, Ntl_Man_t * p, char * pFileName )
{
Ntl_Man_t * pNew;
pNew = Ntl_ManInsertNtk( p, pNtk );
- Ioa_WriteBlif( pNew, pFileName );
+ Ntl_ManWriteBlif( pNew, pFileName );
Ntl_ManFree( pNew );
}
@@ -277,7 +280,7 @@ int fprintfBz2(bz2file * b, char * fmt, ...) {
}
BZ2_bzWrite( &bzError, b->b, b->buf, b->nBytes );
if (bzError == BZ_IO_ERROR) {
- fprintf( stdout, "Ioa_WriteBlif(): I/O error writing to compressed stream.\n" );
+ fprintf( stdout, "Ntl_ManWriteBlif(): I/O error writing to compressed stream.\n" );
return -1;
}
return b->nBytes;
@@ -302,7 +305,7 @@ int fprintfBz2(bz2file * b, char * fmt, ...) {
SeeAlso []
***********************************************************************/
-void Ioa_WriteBlifModelGz( gzFile pFile, Ntl_Mod_t * pModel, int fMain )
+void Ntl_ManWriteBlifModelGz( gzFile pFile, Ntl_Mod_t * pModel, int fMain )
{
Ntl_Obj_t * pObj;
Ntl_Net_t * pNet;
@@ -447,7 +450,7 @@ void Ioa_WriteBlifModelGz( gzFile pFile, Ntl_Mod_t * pModel, int fMain )
SeeAlso []
***********************************************************************/
-void Ioa_WriteBlifGz( Ntl_Man_t * p, char * pFileName )
+void Ntl_ManWriteBlifGz( Ntl_Man_t * p, char * pFileName )
{
Ntl_Mod_t * pModel;
int i;
@@ -457,14 +460,14 @@ void Ioa_WriteBlifGz( Ntl_Man_t * p, char * pFileName )
pFile = gzopen( pFileName, "wb" ); // if pFileName doesn't end in ".gz" then this acts as a passthrough to fopen
if ( pFile == NULL )
{
- fprintf( stdout, "Ioa_WriteBlif(): Cannot open the output file \"%s\".\n", pFileName );
+ fprintf( stdout, "Ntl_ManWriteBlif(): Cannot open the output file \"%s\".\n", pFileName );
return;
}
- gzprintf( pFile, "# Benchmark \"%s\" written by ABC-8 on %s\n", p->pName, Ioa_TimeStamp() );
+ gzprintf( pFile, "# Benchmark \"%s\" written by ABC-8 on %s\n", p->pName, Aig_TimeStamp() );
// write the models
Ntl_ManForEachModel( p, pModel, i )
- Ioa_WriteBlifModelGz( pFile, pModel, i==0 );
+ Ntl_ManWriteBlifModelGz( pFile, pModel, i==0 );
// close the file
gzclose( pFile );
}
@@ -481,7 +484,7 @@ void Ioa_WriteBlifGz( Ntl_Man_t * p, char * pFileName )
SeeAlso []
***********************************************************************/
-void Ioa_WriteBlifModelBz2( bz2file * b, Ntl_Mod_t * pModel, int fMain )
+void Ntl_ManWriteBlifModelBz2( bz2file * b, Ntl_Mod_t * pModel, int fMain )
{
Ntl_Obj_t * pObj;
Ntl_Net_t * pNet;
@@ -626,12 +629,12 @@ void Ioa_WriteBlifModelBz2( bz2file * b, Ntl_Mod_t * pModel, int fMain )
SeeAlso []
***********************************************************************/
-void Ioa_WriteBlif( Ntl_Man_t * p, char * pFileName )
+void Ntl_ManWriteBlif( Ntl_Man_t * p, char * pFileName )
{
Ntl_Mod_t * pModel;
int i, bzError;
bz2file b;
- if ( p->pNal && strncmp(pFileName+strlen(pFileName)-5,".blif",5) )
+ if ( p->pNal && !Ntl_FileIsType(pFileName, ".blif", ".blif.gz", ".blif.bz2") )
{
p->pNalW( p, pFileName );
return;
@@ -639,7 +642,7 @@ void Ioa_WriteBlif( Ntl_Man_t * p, char * pFileName )
// write the GZ file
if (!strncmp(pFileName+strlen(pFileName)-3,".gz",3))
{
- Ioa_WriteBlifGz( p, pFileName );
+ Ntl_ManWriteBlifGz( p, pFileName );
return;
}
@@ -651,7 +654,7 @@ void Ioa_WriteBlif( Ntl_Man_t * p, char * pFileName )
b.f = fopen( pFileName, "wb" );
if ( b.f == NULL )
{
- fprintf( stdout, "Ioa_WriteBlif(): Cannot open the output file \"%s\".\n", pFileName );
+ fprintf( stdout, "Ntl_ManWriteBlif(): Cannot open the output file \"%s\".\n", pFileName );
ABC_FREE(b.buf);
return;
}
@@ -659,22 +662,22 @@ void Ioa_WriteBlif( Ntl_Man_t * p, char * pFileName )
b.b = BZ2_bzWriteOpen( &bzError, b.f, 9, 0, 0 );
if ( bzError != BZ_OK ) {
BZ2_bzWriteClose( &bzError, b.b, 0, NULL, NULL );
- fprintf( stdout, "Ioa_WriteBlif(): Cannot start compressed stream.\n" );
+ fprintf( stdout, "Ntl_ManWriteBlif(): Cannot start compressed stream.\n" );
fclose( b.f );
ABC_FREE(b.buf);
return;
}
}
- fprintfBz2( &b, "# Benchmark \"%s\" written by ABC-8 on %s\n", p->pName, Ioa_TimeStamp() );
+ fprintfBz2( &b, "# Benchmark \"%s\" written by ABC-8 on %s\n", p->pName, Aig_TimeStamp() );
// write the models
Ntl_ManForEachModel( p, pModel, i )
- Ioa_WriteBlifModelBz2( &b, pModel, i==0 );
+ Ntl_ManWriteBlifModelBz2( &b, pModel, i==0 );
// close the file
if (b.b) {
BZ2_bzWriteClose( &bzError, b.b, 0, NULL, NULL );
if (bzError == BZ_IO_ERROR) {
- fprintf( stdout, "Ioa_WriteBlif(): I/O error closing compressed stream.\n" );
+ fprintf( stdout, "Ntl_ManWriteBlif(): I/O error closing compressed stream.\n" );
fclose( b.f );
ABC_FREE(b.buf);
return;
@@ -690,3 +693,5 @@ void Ioa_WriteBlif( Ntl_Man_t * p, char * pFileName )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ntl/ntl_.c b/src/aig/ntl/ntl_.c
index 4b3ad684..9b0b1d0a 100644
--- a/src/aig/ntl/ntl_.c
+++ b/src/aig/ntl/ntl_.c
@@ -20,6 +20,9 @@
#include "ntl.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -45,3 +48,5 @@
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ntl/ntlnwk.h b/src/aig/ntl/ntlnwk.h
new file mode 100644
index 00000000..0b07f243
--- /dev/null
+++ b/src/aig/ntl/ntlnwk.h
@@ -0,0 +1,113 @@
+/**CFile****************************************************************
+
+ FileName [ntlnwk.h]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Netlist and network representation.]
+
+ Synopsis [External declarations.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: ntlnwk.h,v 1.3 2008/10/24 14:18:44 mjarvin Exp $]
+
+***********************************************************************/
+
+#ifndef __NTLNWK_H__
+#define __NTLNWK_H__
+
+
+////////////////////////////////////////////////////////////////////////
+/// INCLUDES ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// PARAMETERS ///
+////////////////////////////////////////////////////////////////////////
+
+ABC_NAMESPACE_HEADER_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// BASIC TYPES ///
+////////////////////////////////////////////////////////////////////////
+
+typedef struct Ntl_Man_t_ Ntl_Man_t;
+typedef struct Nwk_Man_t_ Nwk_Man_t;
+
+////////////////////////////////////////////////////////////////////////
+/// MACRO DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// INLINED FUNCTIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// ITERATORS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+extern ABC_DLL Ntl_Man_t * Ntl_ManReadBlif( char * pFileName, int fCheck );
+extern ABC_DLL void Ntl_ManWriteBlif( Ntl_Man_t * p, char * pFileName );
+
+extern ABC_DLL Tim_Man_t * Ntl_ManReadTimeMan( Ntl_Man_t * p );
+extern ABC_DLL Ntl_Man_t * Ntl_ManDup( Ntl_Man_t * p );
+extern ABC_DLL void Ntl_ManFree( Ntl_Man_t * p );
+extern ABC_DLL int Ntl_ManIsComb( Ntl_Man_t * p );
+extern ABC_DLL void Ntl_ManPrintStats( Ntl_Man_t * p );
+extern ABC_DLL int Ntl_ManSweep( Ntl_Man_t * p, int fVerbose );
+extern ABC_DLL Ntl_Man_t * Ntl_ManInsertNtk( Ntl_Man_t * p, Nwk_Man_t * pNtk );
+extern ABC_DLL Ntl_Man_t * Ntl_ManInsertAig( Ntl_Man_t * p, Aig_Man_t * pAig );
+extern ABC_DLL Aig_Man_t * Ntl_ManExtract( Ntl_Man_t * p );
+extern ABC_DLL Aig_Man_t * Ntl_ManCollapse( Ntl_Man_t * p, int fSeq );
+extern ABC_DLL Aig_Man_t * Ntl_ManCollapseSeq( Ntl_Man_t * p, int nMinDomSize, int fVerbose );
+extern ABC_DLL Ntl_Man_t * Ntl_ManDupCollapseLuts( Ntl_Man_t * p );
+extern ABC_DLL Ntl_Man_t * Ntl_ManFraig( Ntl_Man_t * p, int nPartSize, int nConfLimit, int nLevelMax, int fUseCSat, int fVerbose );
+extern ABC_DLL void Ntl_ManPrepareCecMans( Ntl_Man_t * pMan1, Ntl_Man_t * pMan2, Aig_Man_t ** ppAig1, Aig_Man_t ** ppAig2 );
+extern ABC_DLL Vec_Ptr_t * Ntl_ManCollectCiNames( Ntl_Man_t * p );
+extern ABC_DLL Vec_Ptr_t * Ntl_ManCollectCoNames( Ntl_Man_t * p );
+extern ABC_DLL Ntl_Man_t * Ntl_ManScl( Ntl_Man_t * p, int fLatchConst, int fLatchEqual, int fVerbose );
+extern ABC_DLL Ntl_Man_t * Ntl_ManLcorr( Ntl_Man_t * p, int nConfMax, int fScorrGia, int fUseCSat, int fVerbose );
+extern ABC_DLL Ntl_Man_t * Ntl_ManSsw( Ntl_Man_t * p, Fra_Ssw_t * pPars );
+extern ABC_DLL Ntl_Man_t * Ntl_ManScorr( Ntl_Man_t * p, Ssw_Pars_t * pPars );
+extern ABC_DLL void Ntl_ManTransformInitValues( Ntl_Man_t * p );
+
+extern ABC_DLL void Ntl_ManPrepareCec( char * pFileName1, char * pFileName2, Aig_Man_t ** ppMan1, Aig_Man_t ** ppMan2 );
+extern ABC_DLL Aig_Man_t * Ntl_ManPrepareSec( char * pFileName1, char * pFileName2 );
+
+extern ABC_DLL Nwk_Man_t * Ntl_ManExtractNwk( Ntl_Man_t * p, Aig_Man_t * pAig, Tim_Man_t * pManTime );
+extern ABC_DLL Nwk_Man_t * Ntl_ManReadNwk( char * pFileName, Aig_Man_t * pAig, Tim_Man_t * pManTime );
+extern ABC_DLL void Nwk_ManPrintStats( Nwk_Man_t * p, If_Lib_t * pLutLib, int fSaveBest, int fDumpResult, int fPower, Ntl_Man_t * pNtl );
+extern ABC_DLL void Nwk_ManPrintStatsShort( Ntl_Man_t * p, Aig_Man_t * pAig, Nwk_Man_t * pNtk );
+extern ABC_DLL void Nwk_ManPrintFanioNew( Nwk_Man_t * p );
+extern ABC_DLL Nwk_Man_t * Nwk_MappingIf( Aig_Man_t * p, Tim_Man_t * pManTime, If_Par_t * pPars );
+extern ABC_DLL void Nwk_ManSetIfParsDefault( If_Par_t * pPars );
+extern ABC_DLL void Nwk_ManBidecResyn( Nwk_Man_t * p, int fVerbose );
+extern ABC_DLL Aig_Man_t * Nwk_ManSpeedup( Nwk_Man_t * p, int fUseLutLib, int Percentage, int Degree, int fVerbose, int fVeryVerbose );
+extern ABC_DLL Aig_Man_t * Nwk_ManStrash( Nwk_Man_t * p );
+extern ABC_DLL Vec_Int_t * Nwk_ManLutMerge( Nwk_Man_t * p, void * pPars );
+extern ABC_DLL int Nwk_ManCheck( Nwk_Man_t * p );
+extern ABC_DLL void Nwk_ManDumpBlif( Nwk_Man_t * p, char * pFileName, Vec_Ptr_t * vCiNames, Vec_Ptr_t * vCoNames );
+extern ABC_DLL void Nwk_ManFree( Nwk_Man_t * p );
+
+
+
+ABC_NAMESPACE_HEADER_END
+
+
+
+#endif
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
diff --git a/src/aig/nwk/nwk.h b/src/aig/nwk/nwk.h
index c8cc91cb..acbcbf4a 100644
--- a/src/aig/nwk/nwk.h
+++ b/src/aig/nwk/nwk.h
@@ -20,6 +20,7 @@
#ifndef __NWK_H__
#define __NWK_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
@@ -31,19 +32,20 @@
#include "if.h"
#include "bdc.h"
+#include "fra.h"
+#include "ssw.h"
+#include "ntlnwk.h"
+
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+ABC_NAMESPACE_HEADER_START
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
-typedef struct Nwk_Man_t_ Nwk_Man_t;
typedef struct Nwk_Obj_t_ Nwk_Obj_t;
// object types
@@ -175,23 +177,23 @@ static inline int Nwk_ManTimeMore( float f1, float f2, float Eps ) { r
////////////////////////////////////////////////////////////////////////
#define Nwk_ManForEachCi( p, pObj, i ) \
- Vec_PtrForEachEntry( p->vCis, pObj, i )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, p->vCis, pObj, i )
#define Nwk_ManForEachCo( p, pObj, i ) \
- Vec_PtrForEachEntry( p->vCos, pObj, i )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, p->vCos, pObj, i )
#define Nwk_ManForEachPi( p, pObj, i ) \
- Vec_PtrForEachEntry( p->vCis, pObj, i ) \
+ Vec_PtrForEachEntry( Nwk_Obj_t *, p->vCis, pObj, i ) \
if ( !Nwk_ObjIsPi(pObj) ) {} else
#define Nwk_ManForEachPo( p, pObj, i ) \
- Vec_PtrForEachEntry( p->vCos, pObj, i ) \
+ Vec_PtrForEachEntry( Nwk_Obj_t *, p->vCos, pObj, i ) \
if ( !Nwk_ObjIsPo(pObj) ) {} else
#define Nwk_ManForEachObj( p, pObj, i ) \
- for ( i = 0; (i < Vec_PtrSize(p->vObjs)) && (((pObj) = Vec_PtrEntry(p->vObjs, i)), 1); i++ ) \
+ for ( i = 0; (i < Vec_PtrSize(p->vObjs)) && (((pObj) = (Nwk_Obj_t *)Vec_PtrEntry(p->vObjs, i)), 1); i++ ) \
if ( pObj == NULL ) {} else
#define Nwk_ManForEachNode( p, pObj, i ) \
- for ( i = 0; (i < Vec_PtrSize(p->vObjs)) && (((pObj) = Vec_PtrEntry(p->vObjs, i)), 1); i++ ) \
+ for ( i = 0; (i < Vec_PtrSize(p->vObjs)) && (((pObj) = (Nwk_Obj_t *)Vec_PtrEntry(p->vObjs, i)), 1); i++ ) \
if ( (pObj) == NULL || !Nwk_ObjIsNode(pObj) ) {} else
#define Nwk_ManForEachLatch( p, pObj, i ) \
- for ( i = 0; (i < Vec_PtrSize(p->vObjs)) && (((pObj) = Vec_PtrEntry(p->vObjs, i)), 1); i++ ) \
+ for ( i = 0; (i < Vec_PtrSize(p->vObjs)) && (((pObj) = (Nwk_Obj_t *)Vec_PtrEntry(p->vObjs, i)), 1); i++ ) \
if ( (pObj) == NULL || !Nwk_ObjIsLatch(pObj) ) {} else
#define Nwk_ObjForEachFanin( pObj, pFanin, i ) \
@@ -201,13 +203,13 @@ static inline int Nwk_ManTimeMore( float f1, float f2, float Eps ) { r
// sequential iterators
#define Nwk_ManForEachPiSeq( p, pObj, i ) \
- Vec_PtrForEachEntryStop( p->vCis, pObj, i, (p)->nTruePis )
+ Vec_PtrForEachEntryStop( Nwk_Obj_t *, p->vCis, pObj, i, (p)->nTruePis )
#define Nwk_ManForEachPoSeq( p, pObj, i ) \
- Vec_PtrForEachEntryStop( p->vCos, pObj, i, (p)->nTruePos )
+ Vec_PtrForEachEntryStop( Nwk_Obj_t *, p->vCos, pObj, i, (p)->nTruePos )
#define Nwk_ManForEachLoSeq( p, pObj, i ) \
- for ( i = 0; (i < (p)->nLatches) && (((pObj) = Vec_PtrEntry(p->vCis, i+(p)->nTruePis)), 1); i++ )
+ for ( i = 0; (i < (p)->nLatches) && (((pObj) = (Nwk_Obj_t *)Vec_PtrEntry(p->vCis, i+(p)->nTruePis)), 1); i++ )
#define Nwk_ManForEachLiSeq( p, pObj, i ) \
- for ( i = 0; (i < (p)->nLatches) && (((pObj) = Vec_PtrEntry(p->vCos, i+(p)->nTruePos)), 1); i++ )
+ for ( i = 0; (i < (p)->nLatches) && (((pObj) = (Nwk_Obj_t *)Vec_PtrEntry(p->vCos, i+(p)->nTruePos)), 1); i++ )
#define Nwk_ManForEachLiLoSeq( p, pObjLi, pObjLo, i ) \
for ( i = 0; (i < (p)->nLatches) && (((pObjLi) = Nwk_ManCo(p, i+(p)->nTruePos)), 1) \
&& (((pObjLo) = Nwk_ManCi(p, i+(p)->nTruePis)), 1); i++ )
@@ -253,7 +255,7 @@ extern ABC_DLL Vec_Ptr_t * Nwk_ManRetimeCutBackward( Nwk_Man_t * pMan, int n
extern ABC_DLL Nwk_Man_t * Nwk_ManAlloc();
extern ABC_DLL void Nwk_ManFree( Nwk_Man_t * p );
extern ABC_DLL float Nwl_ManComputeTotalSwitching( Nwk_Man_t * pNtk );
-extern ABC_DLL void Nwk_ManPrintStats( Nwk_Man_t * p, If_Lib_t * pLutLib, int fSaveBest, int fDumpResult, int fPower, void * pNtl );
+extern ABC_DLL void Nwk_ManPrintStats( Nwk_Man_t * p, If_Lib_t * pLutLib, int fSaveBest, int fDumpResult, int fPower, Ntl_Man_t * pNtl );
/*=== nwkMap.c ============================================================*/
extern ABC_DLL Nwk_Man_t * Nwk_MappingIf( Aig_Man_t * p, Tim_Man_t * pManTime, If_Par_t * pPars );
/*=== nwkObj.c ============================================================*/
@@ -291,9 +293,11 @@ extern ABC_DLL void Nwk_ManCleanMarks( Nwk_Man_t * pNtk );
extern ABC_DLL void Nwk_ManMinimumBase( Nwk_Man_t * pNtk, int fVerbose );
extern ABC_DLL void Nwk_ManRemoveDupFanins( Nwk_Man_t * pNtk, int fVerbose );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/aig/nwk/nwkAig.c b/src/aig/nwk/nwkAig.c
index 7421348a..54e84237 100644
--- a/src/aig/nwk/nwkAig.c
+++ b/src/aig/nwk/nwkAig.c
@@ -20,6 +20,9 @@
#include "nwk.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -57,13 +60,13 @@ Nwk_Man_t * Nwk_ManDeriveFromAig( Aig_Man_t * p )
Aig_ManForEachNode( p, pObj, i )
{
pObj->pData = Nwk_ManCreateNode( pNtk, 2, pObj->nRefs );
- Nwk_ObjAddFanin( pObj->pData, Aig_ObjFanin0(pObj)->pData );
- Nwk_ObjAddFanin( pObj->pData, Aig_ObjFanin1(pObj)->pData );
+ Nwk_ObjAddFanin( (Nwk_Obj_t *)pObj->pData, (Nwk_Obj_t *)Aig_ObjFanin0(pObj)->pData );
+ Nwk_ObjAddFanin( (Nwk_Obj_t *)pObj->pData, (Nwk_Obj_t *)Aig_ObjFanin1(pObj)->pData );
}
Aig_ManForEachPo( p, pObj, i )
{
pObj->pData = Nwk_ManCreateCo( pNtk );
- Nwk_ObjAddFanin( pObj->pData, Aig_ObjFanin0(pObj)->pData );
+ Nwk_ObjAddFanin( (Nwk_Obj_t *)pObj->pData, (Nwk_Obj_t *)Aig_ObjFanin0(pObj)->pData );
}
return pNtk;
}
@@ -93,7 +96,7 @@ Vec_Ptr_t * Nwk_ManDeriveRetimingCut( Aig_Man_t * p, int fForward, int fVerbose
vNodes = Nwk_ManRetimeCutBackward( pNtk, Aig_ManRegNum(p), fVerbose );
Aig_ManForEachObj( p, pObj, i )
((Nwk_Obj_t *)pObj->pData)->pCopy = pObj;
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, vNodes, pNode, i )
Vec_PtrWriteEntry( vNodes, i, pNode->pCopy );
Nwk_ManFree( pNtk );
assert( Vec_PtrSize(vNodes) <= Aig_ManRegNum(p) );
@@ -105,3 +108,5 @@ Vec_Ptr_t * Nwk_ManDeriveRetimingCut( Aig_Man_t * p, int fForward, int fVerbose
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/nwk/nwkBidec.c b/src/aig/nwk/nwkBidec.c
index 13abf81f..567b904b 100644
--- a/src/aig/nwk/nwkBidec.c
+++ b/src/aig/nwk/nwkBidec.c
@@ -20,6 +20,9 @@
#include "nwk.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -44,7 +47,7 @@ static inline void Extra_TruthSharp( unsigned * pOut, unsigned * pIn0, unsigned
pOut[w] = pIn0[w] & ~pIn1[w];
}
-static inline Hop_Obj_t * Bdc_FunCopyHop( Bdc_Fun_t * pObj ) { return Hop_NotCond( Bdc_FuncCopy(Bdc_Regular(pObj)), Bdc_IsComplement(pObj) ); }
+static inline Hop_Obj_t * Bdc_FunCopyHop( Bdc_Fun_t * pObj ) { return Hop_NotCond( (Hop_Obj_t *)Bdc_FuncCopy(Bdc_Regular(pObj)), Bdc_IsComplement(pObj) ); }
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
@@ -170,3 +173,5 @@ void Nwk_ManBidecResyn( Nwk_Man_t * pNtk, int fVerbose )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/nwk/nwkCheck.c b/src/aig/nwk/nwkCheck.c
index f20d61f2..24a0d513 100644
--- a/src/aig/nwk/nwkCheck.c
+++ b/src/aig/nwk/nwkCheck.c
@@ -20,6 +20,9 @@
#include "nwk.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -69,3 +72,5 @@ int Nwk_ManCheck( Nwk_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/nwk/nwkDfs.c b/src/aig/nwk/nwkDfs.c
index ec4ad440..59752c59 100644
--- a/src/aig/nwk/nwkDfs.c
+++ b/src/aig/nwk/nwkDfs.c
@@ -20,6 +20,9 @@
#include "nwk.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -657,3 +660,5 @@ int Nwk_ObjMffcLabel( Nwk_Obj_t * pNode )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/nwk/nwkFanio.c b/src/aig/nwk/nwkFanio.c
index daea19d5..2a12f5bf 100644
--- a/src/aig/nwk/nwkFanio.c
+++ b/src/aig/nwk/nwkFanio.c
@@ -20,6 +20,9 @@
#include "nwk.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -279,7 +282,7 @@ void Nwk_ObjTransferFanout( Nwk_Obj_t * pNodeFrom, Nwk_Obj_t * pNodeTo )
nFanoutsOld = Nwk_ObjFanoutNum(pNodeTo);
Nwk_ObjCollectFanouts( pNodeFrom, vFanouts );
// patch the fanin of each of them
- Vec_PtrForEachEntry( vFanouts, pTemp, i )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, vFanouts, pTemp, i )
Nwk_ObjPatchFanin( pTemp, pNodeFrom, pNodeTo );
assert( Nwk_ObjFanoutNum(pNodeFrom) == 0 );
assert( Nwk_ObjFanoutNum(pNodeTo) == nFanoutsOld + Vec_PtrSize(vFanouts) );
@@ -313,3 +316,5 @@ void Nwk_ObjReplace( Nwk_Obj_t * pNodeOld, Nwk_Obj_t * pNodeNew )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/nwk/nwkFlow.c b/src/aig/nwk/nwkFlow.c
index 5efd0233..3961e5c2 100644
--- a/src/aig/nwk/nwkFlow.c
+++ b/src/aig/nwk/nwkFlow.c
@@ -20,6 +20,9 @@
#include "nwk.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*
This code is based on the papers:
A. Hurst, A. Mishchenko, and R. Brayton, "Fast minimum-register retiming
@@ -33,7 +36,7 @@
////////////////////////////////////////////////////////////////////////
// predecessors
-static inline Nwk_Obj_t * Nwk_ObjPred( Nwk_Obj_t * pObj ) { return pObj->pCopy; }
+static inline Nwk_Obj_t * Nwk_ObjPred( Nwk_Obj_t * pObj ) { return (Nwk_Obj_t *)pObj->pCopy; }
static inline int Nwk_ObjSetPred( Nwk_Obj_t * pObj, Nwk_Obj_t * p ) { pObj->pCopy = p; return 1; }
// sink
static inline int Nwk_ObjIsSink( Nwk_Obj_t * pObj ) { return pObj->MarkA; }
@@ -393,7 +396,7 @@ int Nwk_ManRetimeVerifyCutForward( Nwk_Man_t * pMan, Vec_Ptr_t * vNodes )
Nwk_Obj_t * pObj;
int i;
// mark the nodes
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, vNodes, pObj, i )
{
assert( pObj->MarkA == 0 );
pObj->MarkA = 1;
@@ -404,7 +407,7 @@ int Nwk_ManRetimeVerifyCutForward( Nwk_Man_t * pMan, Vec_Ptr_t * vNodes )
if ( !Nwk_ManVerifyCut_rec( pObj ) )
printf( "Nwk_ManRetimeVerifyCutForward(): Internal cut verification failed.\n" );
// unmark the nodes
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, vNodes, pObj, i )
pObj->MarkA = 0;
return 1;
}
@@ -599,3 +602,5 @@ Vec_Ptr_t * Nwk_ManRetimeCutBackward( Nwk_Man_t * pMan, int nLatches, int fVerbo
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/nwk/nwkFlow_depth.c b/src/aig/nwk/nwkFlow_depth.c
index a457631c..6c2e7eb9 100644
--- a/src/aig/nwk/nwkFlow_depth.c
+++ b/src/aig/nwk/nwkFlow_depth.c
@@ -20,6 +20,9 @@
#include "nwk.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*
This code is based on the papers:
A. Hurst, A. Mishchenko, and R. Brayton, "Fast minimum-register retiming
@@ -414,7 +417,7 @@ int Nwk_ManRetimeVerifyCutForward( Nwk_Man_t * pMan, Vec_Ptr_t * vNodes )
Nwk_Obj_t * pObj;
int i;
// mark the nodes
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, vNodes, pObj, i )
{
assert( pObj->MarkA == 0 );
pObj->MarkA = 1;
@@ -425,7 +428,7 @@ int Nwk_ManRetimeVerifyCutForward( Nwk_Man_t * pMan, Vec_Ptr_t * vNodes )
if ( !Nwk_ManVerifyCut_rec( pObj ) )
printf( "Nwk_ManRetimeVerifyCutForward(): Internal cut verification failed.\n" );
// unmark the nodes
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, vNodes, pObj, i )
pObj->MarkA = 0;
return 1;
}
@@ -624,3 +627,5 @@ Vec_Ptr_t * Nwk_ManRetimeCutBackward( Nwk_Man_t * pMan, int nLatches, int fVerbo
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/nwk/nwkMan.c b/src/aig/nwk/nwkMan.c
index 8f971871..2e2a3e56 100644
--- a/src/aig/nwk/nwkMan.c
+++ b/src/aig/nwk/nwkMan.c
@@ -20,6 +20,9 @@
#include "nwk.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -117,7 +120,7 @@ void Nwk_ManPrintLutSizes( Nwk_Man_t * p, If_Lib_t * pLutLib )
***********************************************************************/
int Nwk_ManCompareAndSaveBest( Nwk_Man_t * pNtk, void * pNtl )
{
- extern void Ioa_WriteBlifLogic( Nwk_Man_t * pNtk, void * pNtl, char * pFileName );
+// extern void Ntl_WriteBlifLogic( Nwk_Man_t * pNtk, void * pNtl, char * pFileName );
extern void Nwk_ManDumpBlif( Nwk_Man_t * pNtk, char * pFileName, Vec_Ptr_t * vPiNames, Vec_Ptr_t * vPoNames );
static struct ParStruct {
char * pName; // name of the best saved network
@@ -154,7 +157,7 @@ int Nwk_ManCompareAndSaveBest( Nwk_Man_t * pNtk, void * pNtl )
ParsBest.nPis = ParsNew.nPis;
ParsBest.nPos = ParsNew.nPos;
// write the network
-// Ioa_WriteBlifLogic( pNtk, pNtl, "best.blif" );
+// Ntl_WriteBlifLogic( pNtk, pNtl, "best.blif" );
// Nwk_ManDumpBlif( pNtk, "best_map.blif", NULL, NULL );
return 1;
}
@@ -209,14 +212,14 @@ float Nwl_ManComputeTotalSwitching( Nwk_Man_t * pNtk )
pSwitching = (float *)vSwitching->pArray;
Nwk_ManForEachObj( pNtk, pObjAbc, i )
{
- if ( (pObjAig = Aig_Regular(pObjAbc->pCopy)) )
+ if ( (pObjAig = Aig_Regular((Aig_Obj_t *)pObjAbc->pCopy)) )
Result += Nwk_ObjFanoutNum(pObjAbc) * pSwitching[pObjAig->Id];
}
Vec_IntFree( vSwitching );
Aig_ManStop( pAig );
return Result;
}
-
+
/**Function*************************************************************
Synopsis [Prints stats of the manager.]
@@ -228,18 +231,18 @@ float Nwl_ManComputeTotalSwitching( Nwk_Man_t * pNtk )
SeeAlso []
***********************************************************************/
-void Nwk_ManPrintStats( Nwk_Man_t * pNtk, If_Lib_t * pLutLib, int fSaveBest, int fDumpResult, int fPower, void * pNtl )
+void Nwk_ManPrintStats( Nwk_Man_t * pNtk, If_Lib_t * pLutLib, int fSaveBest, int fDumpResult, int fPower, Ntl_Man_t * pNtl )
{
- extern int Ntl_ManLatchNum( void * p );
- extern void Ioa_WriteBlifLogic( Nwk_Man_t * pNtk, void * pNtl, char * pFileName );
+// extern int Ntl_ManLatchNum( Ntl_Man_t * p );
+// extern void Ntl_ManWriteBlifLogic( Nwk_Man_t * pNtk, void * pNtl, char * pFileName );
if ( fSaveBest )
Nwk_ManCompareAndSaveBest( pNtk, pNtl );
if ( fDumpResult )
{
char Buffer[1000] = {0};
- char * pNameGen = pNtk->pSpec? Nwk_FileNameGeneric( pNtk->pSpec ) : "nameless_";
+ const char * pNameGen = pNtk->pSpec? Nwk_FileNameGeneric( pNtk->pSpec ) : "nameless_";
sprintf( Buffer, "%s_dump.blif", pNameGen );
- Ioa_WriteBlifLogic( pNtk, pNtl, Buffer );
+// Ntl_ManWriteBlifLogic( pNtk, pNtl, Buffer );
// sprintf( Buffer, "%s_dump_map.blif", pNameGen );
// Nwk_ManDumpBlif( pNtk, Buffer, NULL, NULL );
if ( pNtk->pSpec ) ABC_FREE( pNameGen );
@@ -251,7 +254,7 @@ void Nwk_ManPrintStats( Nwk_Man_t * pNtk, If_Lib_t * pLutLib, int fSaveBest, int
printf( "po = %5d ", Nwk_ManPoNum(pNtk) );
printf( "ci = %5d ", Nwk_ManCiNum(pNtk) );
printf( "co = %5d ", Nwk_ManCoNum(pNtk) );
- printf( "lat = %5d ", Ntl_ManLatchNum(pNtl) );
+// printf( "lat = %5d ", Ntl_ManLatchNum(pNtl) );
printf( "node = %5d ", Nwk_ManNodeNum(pNtk) );
printf( "edge = %5d ", Nwk_ManGetTotalFanins(pNtk) );
printf( "aig = %6d ", Nwk_ManGetAigNodeNum(pNtk) );
@@ -271,3 +274,5 @@ void Nwk_ManPrintStats( Nwk_Man_t * pNtk, If_Lib_t * pLutLib, int fSaveBest, int
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/nwk/nwkMap.c b/src/aig/nwk/nwkMap.c
index 5812358b..22f25dbc 100644
--- a/src/aig/nwk/nwkMap.c
+++ b/src/aig/nwk/nwkMap.c
@@ -21,6 +21,9 @@
#include "nwk.h"
#include "if.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -126,21 +129,24 @@ If_Man_t * Nwk_ManToIf( Aig_Man_t * p, If_Par_t * pPars, Vec_Ptr_t * vAigToIf )
Aig_ManForEachObj( p, pNode, i )
{
if ( Aig_ObjIsAnd(pNode) )
+ {
pIfObj = If_ManCreateAnd( pIfMan,
- If_NotCond( Aig_ObjFanin0(pNode)->pData, Aig_ObjFaninC0(pNode) ),
- If_NotCond( Aig_ObjFanin1(pNode)->pData, Aig_ObjFaninC1(pNode) ) );
+ If_NotCond( (If_Obj_t *)Aig_ObjFanin0(pNode)->pData, Aig_ObjFaninC0(pNode) ),
+ If_NotCond( (If_Obj_t *)Aig_ObjFanin1(pNode)->pData, Aig_ObjFaninC1(pNode) ) );
+// printf( "no%d=%d\n ", If_ObjId(pIfObj), If_ObjLevel(pIfObj) );
+ }
else if ( Aig_ObjIsPi(pNode) )
{
pIfObj = If_ManCreateCi( pIfMan );
If_ObjSetLevel( pIfObj, Aig_ObjLevel(pNode) );
-// printf( "pi=%d ", pIfObj->Level );
+// printf( "pi%d=%d\n ", If_ObjId(pIfObj), If_ObjLevel(pIfObj) );
if ( pIfMan->nLevelMax < (int)pIfObj->Level )
pIfMan->nLevelMax = (int)pIfObj->Level;
}
else if ( Aig_ObjIsPo(pNode) )
{
- pIfObj = If_ManCreateCo( pIfMan, If_NotCond( Aig_ObjFanin0(pNode)->pData, Aig_ObjFaninC0(pNode) ) );
-// printf( "po=%d ", pIfObj->Level );
+ pIfObj = If_ManCreateCo( pIfMan, If_NotCond( (If_Obj_t *)Aig_ObjFanin0(pNode)->pData, Aig_ObjFaninC0(pNode) ) );
+// printf( "po%d=%d\n ", If_ObjId(pIfObj), If_ObjLevel(pIfObj) );
}
else if ( Aig_ObjIsConst1(pNode) )
pIfObj = If_ManConst1( pIfMan );
@@ -157,8 +163,8 @@ If_Man_t * Nwk_ManToIf( Aig_Man_t * p, If_Par_t * pPars, Vec_Ptr_t * vAigToIf )
{
pIfMan->nChoices++;
for ( pPrev = pNode, pFanin = Aig_ObjEquiv(p, pNode); pFanin; pPrev = pFanin, pFanin = Aig_ObjEquiv(p, pFanin) )
- If_ObjSetChoice( pPrev->pData, pFanin->pData );
- If_ManCreateChoice( pIfMan, pNode->pData );
+ If_ObjSetChoice( (If_Obj_t *)pPrev->pData, (If_Obj_t *)pFanin->pData );
+ If_ManCreateChoice( pIfMan, (If_Obj_t *)pNode->pData );
}
// assert( If_ObjLevel(pIfObj) == Aig_ObjLevel(pNode) );
}
@@ -188,14 +194,14 @@ Hop_Obj_t * Nwk_NodeIfToHop2_rec( Hop_Man_t * pHopMan, If_Man_t * pIfMan, If_Obj
pCut = If_ObjCutBest(pIfObj);
// if the cut is visited, return the result
if ( If_CutData(pCut) )
- return If_CutData(pCut);
+ return (Hop_Obj_t *)If_CutData(pCut);
// mark the node as visited
Vec_PtrPush( vVisited, pCut );
// insert the worst case
If_CutSetData( pCut, (void *)1 );
// skip in case of primary input
if ( If_ObjIsCi(pIfObj) )
- return If_CutData(pCut);
+ return (Hop_Obj_t *)If_CutData(pCut);
// compute the functions of the children
for ( pTemp = pIfObj; pTemp; pTemp = pTemp->pEquiv )
{
@@ -212,7 +218,7 @@ Hop_Obj_t * Nwk_NodeIfToHop2_rec( Hop_Man_t * pHopMan, If_Man_t * pIfMan, If_Obj
If_CutSetData( pCut, gFunc );
break;
}
- return If_CutData(pCut);
+ return (Hop_Obj_t *)If_CutData(pCut);
}
/**Function*************************************************************
@@ -250,7 +256,7 @@ Hop_Obj_t * Nwk_NodeIfToHop( Hop_Man_t * pHopMan, If_Man_t * pIfMan, If_Obj_t *
// clean the cuts
If_CutForEachLeaf( pIfMan, pCut, pLeaf, i )
If_CutSetData( If_ObjCutBest(pLeaf), NULL );
- Vec_PtrForEachEntry( pIfMan->vTemp, pCut, i )
+ Vec_PtrForEachEntry( If_Cut_t *, pIfMan->vTemp, pCut, i )
If_CutSetData( pCut, NULL );
return gFunc;
}
@@ -284,7 +290,7 @@ Nwk_Man_t * Nwk_ManFromIf( If_Man_t * pIfMan, Aig_Man_t * p, Vec_Ptr_t * vAigToI
vIfToAig = Vec_PtrStart( If_ManObjNum(pIfMan) );
Aig_ManForEachObj( p, pObj, i )
{
- pIfObj = Vec_PtrEntry( vAigToIf, i );
+ pIfObj = (If_Obj_t *)Vec_PtrEntry( vAigToIf, i );
Vec_PtrWriteEntry( vIfToAig, pIfObj->Id, pObj );
}
// construct the network
@@ -296,7 +302,7 @@ Nwk_Man_t * Nwk_ManFromIf( If_Man_t * pIfMan, Aig_Man_t * p, Vec_Ptr_t * vAigToI
// pNtk->nTruePos = Nwk_ManCoNum(pNtk) - pNtk->nLatches;
Aig_ManForEachObj( p, pObj, i )
{
- pIfObj = Vec_PtrEntry( vAigToIf, i );
+ pIfObj = (If_Obj_t *)Vec_PtrEntry( vAigToIf, i );
if ( pIfObj->nRefs == 0 && !If_ObjIsTerm(pIfObj) )
continue;
if ( Aig_ObjIsNode(pObj) )
@@ -308,8 +314,8 @@ Nwk_Man_t * Nwk_ManFromIf( If_Man_t * pIfMan, Aig_Man_t * p, Vec_Ptr_t * vAigToI
pObjNew = Nwk_ManCreateNode( pNtk, nLeaves, pIfObj->nRefs );
for ( k = 0; k < nLeaves; k++ )
{
- pObjRepr = Vec_PtrEntry( vIfToAig, ppLeaves[k] );
- Nwk_ObjAddFanin( pObjNew, pObjRepr->pData );
+ pObjRepr = (Aig_Obj_t *)Vec_PtrEntry( vIfToAig, ppLeaves[k] );
+ Nwk_ObjAddFanin( pObjNew, (Nwk_Obj_t *)pObjRepr->pData );
}
// get the functionality
pObjNew->pFunc = Nwk_NodeIfToHop( pNtk->pManHop, pIfMan, pIfObj );
@@ -320,7 +326,7 @@ Nwk_Man_t * Nwk_ManFromIf( If_Man_t * pIfMan, Aig_Man_t * p, Vec_Ptr_t * vAigToI
{
pObjNew = Nwk_ManCreateCo( pNtk );
pObjNew->fInvert = Aig_ObjFaninC0(pObj);
- Nwk_ObjAddFanin( pObjNew, Aig_ObjFanin0(pObj)->pData );
+ Nwk_ObjAddFanin( pObjNew, (Nwk_Obj_t *)Aig_ObjFanin0(pObj)->pData );
//printf( "%d ", pObjNew->Id );
}
else if ( Aig_ObjIsConst1(pObj) )
@@ -365,6 +371,7 @@ Nwk_Man_t * Nwk_MappingIf( Aig_Man_t * p, Tim_Man_t * pManTime, If_Par_t * pPars
if ( pIfMan == NULL )
return NULL;
pIfMan->pManTim = Tim_ManDup( pManTime, 0 );
+ pIfMan->pPars->fCutMin = 0; // is not compatible with deriving result
if ( !If_ManPerformMapping( pIfMan ) )
{
If_ManStop( pIfMan );
@@ -385,3 +392,5 @@ Nwk_Man_t * Nwk_MappingIf( Aig_Man_t * p, Tim_Man_t * pManTime, If_Par_t * pPars
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/nwk/nwkMerge.c b/src/aig/nwk/nwkMerge.c
index bc7826e1..9a4f2f8c 100644
--- a/src/aig/nwk/nwkMerge.c
+++ b/src/aig/nwk/nwkMerge.c
@@ -21,6 +21,9 @@
#include "nwk.h"
#include "nwkMerge.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -787,7 +790,7 @@ void Nwk_ManCollectCircle( Vec_Ptr_t * vStart, Vec_Ptr_t * vNext, int nFanMax )
Nwk_Obj_t * pObj, * pNext;
int i, k;
Vec_PtrClear( vNext );
- Vec_PtrForEachEntry( vStart, pObj, i )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, vStart, pObj, i )
{
Nwk_ObjForEachFanin( pObj, pNext, k )
{
@@ -845,7 +848,7 @@ void Nwk_ManCollectNonOverlapCands( Nwk_Obj_t * pLut, Vec_Ptr_t * vStart, Vec_Pt
vStart = vNext;
vNext = vTemp;
// collect the nodes in vStart
- Vec_PtrForEachEntry( vStart, pObj, k )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, vStart, pObj, k )
Vec_PtrPush( vCands, pObj );
}
@@ -867,7 +870,7 @@ void Nwk_ManCollectNonOverlapCands( Nwk_Obj_t * pLut, Vec_Ptr_t * vStart, Vec_Pt
// - they have no more than the given number of fanins
// - they have no more than the given diff in delay
k = 0;
- Vec_PtrForEachEntry( vCands, pObj, i )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, vCands, pObj, i )
{
if ( Nwk_ObjIsTravIdCurrent(pObj) )
continue;
@@ -963,8 +966,9 @@ void Nwk_ManCollectOverlapCands( Nwk_Obj_t * pLut, Vec_Ptr_t * vCands, Nwk_LMPar
SeeAlso []
***********************************************************************/
-Vec_Int_t * Nwk_ManLutMerge( Nwk_Man_t * pNtk, Nwk_LMPars_t * pPars )
+Vec_Int_t * Nwk_ManLutMerge( Nwk_Man_t * pNtk, void * pParsInit )
{
+ Nwk_LMPars_t * pPars = (Nwk_LMPars_t *)pParsInit;
Nwk_Grf_t * p;
Vec_Int_t * vResult;
Vec_Ptr_t * vStart, * vNext, * vCands1, * vCands2;
@@ -992,9 +996,9 @@ Vec_Int_t * Nwk_ManLutMerge( Nwk_Man_t * pNtk, Nwk_LMPars_t * pPars )
continue;
nCands += Vec_PtrSize(vCands1) + Vec_PtrSize(vCands2);
// save candidates
- Vec_PtrForEachEntry( vCands1, pCand, k )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, vCands1, pCand, k )
Nwk_ManGraphHashEdge( p, Nwk_ObjId(pLut), Nwk_ObjId(pCand) );
- Vec_PtrForEachEntry( vCands2, pCand, k )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, vCands2, pCand, k )
Nwk_ManGraphHashEdge( p, Nwk_ObjId(pLut), Nwk_ObjId(pCand) );
// print statistics about this node
if ( pPars->fVeryVerbose )
@@ -1036,3 +1040,5 @@ Vec_Int_t * Nwk_ManLutMerge( Nwk_Man_t * pNtk, Nwk_LMPars_t * pPars )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/nwk/nwkMerge.h b/src/aig/nwk/nwkMerge.h
index ab39ec39..f6be760f 100644
--- a/src/aig/nwk/nwkMerge.h
+++ b/src/aig/nwk/nwkMerge.h
@@ -21,6 +21,7 @@
#ifndef __NWK_MERGE_H__
#define __NWK_MERGE_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -29,9 +30,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
#define NWK_MAX_LIST 16
@@ -137,9 +139,11 @@ extern ABC_DLL void Nwk_ManGraphHashEdge( Nwk_Grf_t * p, int iLut1, int
extern ABC_DLL void Nwk_ManGraphSolve( Nwk_Grf_t * p );
extern ABC_DLL int Nwk_ManLutMergeGraphTest( char * pFileName );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/aig/nwk/nwkObj.c b/src/aig/nwk/nwkObj.c
index 58587f07..e5930087 100644
--- a/src/aig/nwk/nwkObj.c
+++ b/src/aig/nwk/nwkObj.c
@@ -20,6 +20,9 @@
#include "nwk.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -157,7 +160,7 @@ void Nwk_ManDeleteNode( Nwk_Obj_t * pObj )
assert( Nwk_ObjFanoutNum(pObj) == 0 );
// delete fanins
Nwk_ObjCollectFanins( pObj, vNodes );
- Vec_PtrForEachEntry( vNodes, pTemp, i )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, vNodes, pTemp, i )
Nwk_ObjDeleteFanin( pObj, pTemp );
// remove from the list of objects
Vec_PtrWriteEntry( pObj->pMan->vObjs, pObj->Id, NULL );
@@ -186,7 +189,7 @@ void Nwk_ManDeleteNode_rec( Nwk_Obj_t * pObj )
vNodes = Vec_PtrAlloc( 100 );
Nwk_ObjCollectFanins( pObj, vNodes );
Nwk_ManDeleteNode( pObj );
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, vNodes, pObj, i )
if ( Nwk_ObjIsNode(pObj) && Nwk_ObjFanoutNum(pObj) == 0 )
Nwk_ManDeleteNode_rec( pObj );
Vec_PtrFree( vNodes );
@@ -197,3 +200,5 @@ void Nwk_ManDeleteNode_rec( Nwk_Obj_t * pObj )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/nwk/nwkSpeedup.c b/src/aig/nwk/nwkSpeedup.c
index 54e4d414..335d50f8 100644
--- a/src/aig/nwk/nwkSpeedup.c
+++ b/src/aig/nwk/nwkSpeedup.c
@@ -20,6 +20,9 @@
#include "nwk.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -74,9 +77,9 @@ void Aig_ManSpeedupNode( Nwk_Man_t * pNtk, Aig_Man_t * pAig, Nwk_Obj_t * pNode,
int nCofs, i, k, nSkip;
// quit of regulars are the same
- Vec_PtrForEachEntry( vLeaves, pObj, i )
- Vec_PtrForEachEntry( vLeaves, pObj2, k )
- if ( i != k && Aig_Regular(pObj->pCopy) == Aig_Regular(pObj2->pCopy) )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, vLeaves, pObj, i )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, vLeaves, pObj2, k )
+ if ( i != k && Aig_Regular((Aig_Obj_t *)pObj->pCopy) == Aig_Regular((Aig_Obj_t *)pObj2->pCopy) )
{
// printf( "Identical after structural hashing!!!\n" );
return;
@@ -86,13 +89,13 @@ void Aig_ManSpeedupNode( Nwk_Man_t * pNtk, Aig_Man_t * pAig, Nwk_Obj_t * pNode,
vNodes = Vec_PtrAlloc( 100 );
Aig_ManIncrementTravId( pAig );
Aig_ObjSetTravIdCurrent( pAig, Aig_ManConst1(pAig) );
- Vec_PtrForEachEntry( vLeaves, pObj, i )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, vLeaves, pObj, i )
{
- pAnd = pObj->pCopy;
+ pAnd = (Aig_Obj_t *)pObj->pCopy;
Aig_ObjSetTravIdCurrent( pAig, Aig_Regular(pAnd) );
}
// traverse from the root node
- pAnd = pNode->pCopy;
+ pAnd = (Aig_Obj_t *)pNode->pCopy;
if ( !Aig_ManSpeedupNode_rec( pAig, Aig_Regular(pAnd), vNodes ) )
{
// printf( "Bad node!!!\n" );
@@ -104,21 +107,21 @@ void Aig_ManSpeedupNode( Nwk_Man_t * pNtk, Aig_Man_t * pAig, Nwk_Obj_t * pNode,
nCofs = (1 << Vec_PtrSize(vTimes));
for ( i = 0; i < nCofs; i++ )
{
- Vec_PtrForEachEntry( vLeaves, pObj, k )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, vLeaves, pObj, k )
{
- pAnd = pObj->pCopy;
+ pAnd = (Aig_Obj_t *)pObj->pCopy;
Aig_Regular(pAnd)->pData = Aig_Regular(pAnd);
}
- Vec_PtrForEachEntry( vTimes, pObj, k )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, vTimes, pObj, k )
{
- pAnd = pObj->pCopy;
+ pAnd = (Aig_Obj_t *)pObj->pCopy;
Aig_Regular(pAnd)->pData = Aig_NotCond( Aig_ManConst1(pAig), ((i & (1<<k)) == 0) );
}
- Vec_PtrForEachEntry( vNodes, pTemp, k )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pTemp, k )
pTemp->pData = Aig_And( pAig, Aig_ObjChild0Copy(pTemp), Aig_ObjChild1Copy(pTemp) );
// save the result
- pAnd = pNode->pCopy;
- ppCofs[i] = Aig_NotCond( Aig_Regular(pAnd)->pData, Aig_IsComplement(pAnd) );
+ pAnd = (Aig_Obj_t *)pNode->pCopy;
+ ppCofs[i] = Aig_NotCond( (Aig_Obj_t *)Aig_Regular(pAnd)->pData, Aig_IsComplement(pAnd) );
}
Vec_PtrFree( vNodes );
@@ -126,16 +129,16 @@ void Aig_ManSpeedupNode( Nwk_Man_t * pNtk, Aig_Man_t * pAig, Nwk_Obj_t * pNode,
//Nwk_ObjAddFanin( Nwk_ManCreatePo(pAig), ppCofs[1] );
// collect the resulting tree
- Vec_PtrForEachEntry( vTimes, pObj, k )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, vTimes, pObj, k )
for ( nSkip = (1<<k), i = 0; i < nCofs; i += 2*nSkip )
{
- pAnd = pObj->pCopy;
+ pAnd = (Aig_Obj_t *)pObj->pCopy;
ppCofs[i] = Aig_Mux( pAig, Aig_Regular(pAnd), ppCofs[i+nSkip], ppCofs[i] );
}
//Nwk_ObjAddFanin( Nwk_ManCreatePo(pAig), ppCofs[0] );
// create choice node
- pAnd = Aig_Regular(pNode->pCopy); // repr
+ pAnd = Aig_Regular((Aig_Obj_t *)pNode->pCopy); // repr
pTemp = Aig_Regular(ppCofs[0]); // new
if ( Aig_ObjEquiv(pAig, pAnd) == NULL && Aig_ObjEquiv(pAig, pTemp) == NULL && !Aig_ObjCheckTfi(pAig, pTemp, pAnd) )
pAig->pEquivs[pAnd->Id] = pTemp;
@@ -204,12 +207,20 @@ Aig_Man_t * Nwk_ManSpeedup( Nwk_Man_t * pNtk, int fUseLutLib, int Percentage, in
Nwk_Obj_t * pNode, * pFanin, * pFanin2;
Aig_Obj_t * pAnd;
If_Lib_t * pTempLib = pNtk->pLutLib;
+ Tim_Man_t * pTempTim = NULL;
float tDelta, tArrival;
int i, k, k2, Counter, CounterRes, nTimeCris;
unsigned * puTCEdges;
// perform delay trace
if ( !fUseLutLib )
+ {
pNtk->pLutLib = NULL;
+ if ( pNtk->pManTime )
+ {
+ pTempTim = pNtk->pManTime;
+ pNtk->pManTime = Tim_ManDup( pTempTim, 1 );
+ }
+ }
tArrival = Nwk_ManDelayTraceLut( pNtk );
tDelta = fUseLutLib ? tArrival*Percentage/100.0 : 1.0;
if ( fVerbose )
@@ -302,8 +313,8 @@ Aig_Man_t * Nwk_ManSpeedup( Nwk_Man_t * pNtk, int fUseLutLib, int Percentage, in
// order the fanins in the increasing order of criticalily
if ( Vec_PtrSize(vTimeCries) > 1 )
{
- pFanin = Vec_PtrEntry( vTimeCries, 0 );
- pFanin2 = Vec_PtrEntry( vTimeCries, 1 );
+ pFanin = (Nwk_Obj_t *)Vec_PtrEntry( vTimeCries, 0 );
+ pFanin2 = (Nwk_Obj_t *)Vec_PtrEntry( vTimeCries, 1 );
if ( Nwk_ObjSlack(pFanin) < Nwk_ObjSlack(pFanin2) )
{
Vec_PtrWriteEntry( vTimeCries, 0, pFanin2 );
@@ -312,15 +323,15 @@ Aig_Man_t * Nwk_ManSpeedup( Nwk_Man_t * pNtk, int fUseLutLib, int Percentage, in
}
if ( Vec_PtrSize(vTimeCries) > 2 )
{
- pFanin = Vec_PtrEntry( vTimeCries, 1 );
- pFanin2 = Vec_PtrEntry( vTimeCries, 2 );
+ pFanin = (Nwk_Obj_t *)Vec_PtrEntry( vTimeCries, 1 );
+ pFanin2 = (Nwk_Obj_t *)Vec_PtrEntry( vTimeCries, 2 );
if ( Nwk_ObjSlack(pFanin) < Nwk_ObjSlack(pFanin2) )
{
Vec_PtrWriteEntry( vTimeCries, 1, pFanin2 );
Vec_PtrWriteEntry( vTimeCries, 2, pFanin );
}
- pFanin = Vec_PtrEntry( vTimeCries, 0 );
- pFanin2 = Vec_PtrEntry( vTimeCries, 1 );
+ pFanin = (Nwk_Obj_t *)Vec_PtrEntry( vTimeCries, 0 );
+ pFanin2 = (Nwk_Obj_t *)Vec_PtrEntry( vTimeCries, 1 );
if ( Nwk_ObjSlack(pFanin) < Nwk_ObjSlack(pFanin2) )
{
Vec_PtrWriteEntry( vTimeCries, 0, pFanin2 );
@@ -348,6 +359,11 @@ Aig_Man_t * Nwk_ManSpeedup( Nwk_Man_t * pNtk, int fUseLutLib, int Percentage, in
// put back the library
if ( !fUseLutLib )
pNtk->pLutLib = pTempLib;
+ if ( pTempTim )
+ {
+ Tim_ManStop( pNtk->pManTime );
+ pNtk->pManTime = pTempTim;
+ }
// reconstruct the network
pAig = Aig_ManDupDfs( pTemp = pAig );
@@ -362,3 +378,5 @@ Aig_Man_t * Nwk_ManSpeedup( Nwk_Man_t * pNtk, int fUseLutLib, int Percentage, in
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/nwk/nwkStrash.c b/src/aig/nwk/nwkStrash.c
index 6c2a3677..54f1f027 100644
--- a/src/aig/nwk/nwkStrash.c
+++ b/src/aig/nwk/nwkStrash.c
@@ -20,6 +20,9 @@
#include "nwk.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -79,7 +82,7 @@ Aig_Obj_t * Nwk_ManStrashNode( Aig_Man_t * p, Nwk_Obj_t * pObj )
Nwk_ManStrashNode_rec( p, Hop_Regular(pRoot) );
Hop_ConeUnmark_rec( Hop_Regular(pRoot) );
// return the final node
- return Aig_NotCond( Hop_Regular(pRoot)->pData, Hop_IsComplement(pRoot) );
+ return Aig_NotCond( (Aig_Obj_t *)Hop_Regular(pRoot)->pData, Hop_IsComplement(pRoot) );
}
/**Function*************************************************************
@@ -103,25 +106,25 @@ Aig_Man_t * Nwk_ManStrash( Nwk_Man_t * pNtk )
pMan = Aig_ManStart( Nwk_ManGetAigNodeNum(pNtk) );
pMan->pName = Aig_UtilStrsav( pNtk->pName );
pMan->pSpec = Aig_UtilStrsav( pNtk->pSpec );
- pMan->pManTime = Tim_ManDup( pNtk->pManTime, 1 );
- Tim_ManIncrementTravId( pMan->pManTime );
+ pMan->pManTime = Tim_ManDup( (Tim_Man_t *)pNtk->pManTime, 1 );
+ Tim_ManIncrementTravId( (Tim_Man_t *)pMan->pManTime );
Nwk_ManForEachObj( pNtk, pObj, i )
pObj->pCopy = NULL;
// Nwk_ManForEachObj( pNtk, pObj, i )
vObjs = Nwk_ManDfs( pNtk );
- Vec_PtrForEachEntry( vObjs, pObj, i )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, vObjs, pObj, i )
{
if ( Nwk_ObjIsCi(pObj) )
{
pObjNew = Aig_ObjCreatePi(pMan);
- Level = Tim_ManGetCiArrival( pMan->pManTime, pObj->PioId );
+ Level = Tim_ManGetCiArrival( (Tim_Man_t *)pMan->pManTime, pObj->PioId );
Aig_ObjSetLevel( pObjNew, Level );
}
else if ( Nwk_ObjIsCo(pObj) )
{
- pObjNew = Aig_ObjCreatePo( pMan, Aig_NotCond(Nwk_ObjFanin0(pObj)->pCopy, pObj->fInvert) );
+ pObjNew = Aig_ObjCreatePo( pMan, Aig_NotCond((Aig_Obj_t *)Nwk_ObjFanin0(pObj)->pCopy, pObj->fInvert) );
Level = Aig_ObjLevel( pObjNew );
- Tim_ManSetCoArrival( pMan->pManTime, pObj->PioId, (float)Level );
+ Tim_ManSetCoArrival( (Tim_Man_t *)pMan->pManTime, pObj->PioId, (float)Level );
}
else if ( Nwk_ObjIsNode(pObj) )
{
@@ -142,3 +145,5 @@ Aig_Man_t * Nwk_ManStrash( Nwk_Man_t * pNtk )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/nwk/nwkTiming.c b/src/aig/nwk/nwkTiming.c
index 5c53038c..53591ee8 100644
--- a/src/aig/nwk/nwkTiming.c
+++ b/src/aig/nwk/nwkTiming.c
@@ -20,6 +20,9 @@
#include "nwk.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -349,13 +352,13 @@ float Nwk_ManDelayTraceLut( Nwk_Man_t * pNtk )
Tim_ManIncrementTravId( pNtk->pManTime );
// Nwk_ManForEachObj( pNtk, pObj, i )
vObjs = Nwk_ManDfs( pNtk );
- Vec_PtrForEachEntry( vObjs, pObj, i )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, vObjs, pObj, i )
{
tArrival = Nwk_NodeComputeArrival( pObj, fUseSorting );
- if ( Nwk_ObjIsCo(pObj) && pNtk->pManTime )
- Tim_ManSetCoArrival( pNtk->pManTime, pObj->PioId, tArrival );
if ( Nwk_ObjIsCi(pObj) && pNtk->pManTime )
tArrival = Tim_ManGetCiArrival( pNtk->pManTime, pObj->PioId );
+ if ( Nwk_ObjIsCo(pObj) && pNtk->pManTime )
+ Tim_ManSetCoArrival( pNtk->pManTime, pObj->PioId, tArrival );
Nwk_ObjSetArrival( pObj, tArrival );
}
Vec_PtrFree( vObjs );
@@ -379,7 +382,7 @@ float Nwk_ManDelayTraceLut( Nwk_Man_t * pNtk )
}
// propagate the required times
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, vNodes, pObj, i )
{
if ( Nwk_ObjIsNode(pObj) )
{
@@ -518,8 +521,8 @@ void Nwk_NodeUpdateAddToQueue( Vec_Ptr_t * vQueue, Nwk_Obj_t * pObj, int iCurren
Vec_PtrPush( vQueue, pObj );
for ( i = Vec_PtrSize(vQueue) - 1; i > iCurrent + 1; i-- )
{
- pTemp1 = vQueue->pArray[i];
- pTemp2 = vQueue->pArray[i-1];
+ pTemp1 = (Nwk_Obj_t *)vQueue->pArray[i];
+ pTemp2 = (Nwk_Obj_t *)vQueue->pArray[i-1];
if ( fArrival )
{
if ( Nwk_ObjLevel(pTemp2) <= Nwk_ObjLevel(pTemp1) )
@@ -536,8 +539,8 @@ void Nwk_NodeUpdateAddToQueue( Vec_Ptr_t * vQueue, Nwk_Obj_t * pObj, int iCurren
// verification
for ( i = iCurrent + 1; i < Vec_PtrSize(vQueue) - 1; i++ )
{
- pTemp1 = vQueue->pArray[i];
- pTemp2 = vQueue->pArray[i+1];
+ pTemp1 = (Nwk_Obj_t *)vQueue->pArray[i];
+ pTemp2 = (Nwk_Obj_t *)vQueue->pArray[i+1];
if ( fArrival )
assert( Nwk_ObjLevel(pTemp1) <= Nwk_ObjLevel(pTemp2) );
else
@@ -575,7 +578,7 @@ void Nwk_NodeUpdateArrival( Nwk_Obj_t * pObj )
// process objects
if ( pManTime )
Tim_ManIncrementTravId( pManTime );
- Vec_PtrForEachEntry( vQueue, pTemp, iCur )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, vQueue, pTemp, iCur )
{
pTemp->MarkA = 0;
tArrival = Nwk_NodeComputeArrival( pTemp, 1 );
@@ -659,7 +662,7 @@ void Nwk_NodeUpdateRequired( Nwk_Obj_t * pObj )
// process objects
if ( pManTime )
Tim_ManIncrementTravId( pManTime );
- Vec_PtrForEachEntry( vQueue, pTemp, iCur )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, vQueue, pTemp, iCur )
{
pTemp->MarkA = 0;
tRequired = Nwk_NodeComputeRequired( pTemp, 1 );
@@ -773,7 +776,7 @@ void Nwk_ManUpdateLevel( Nwk_Obj_t * pObj )
Vec_PtrPush( vQueue, pObj );
pObj->MarkA = 1;
// process objects
- Vec_PtrForEachEntry( vQueue, pTemp, iCur )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, vQueue, pTemp, iCur )
{
pTemp->MarkA = 0;
LevelNew = Nwk_ObjLevelNew( pTemp );
@@ -887,3 +890,5 @@ void Nwk_ManUpdate( Nwk_Obj_t * pObj, Nwk_Obj_t * pObjNew, Vec_Vec_t * vLevels )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/nwk/nwkUtil.c b/src/aig/nwk/nwkUtil.c
index 9fc292ea..a1948031 100644
--- a/src/aig/nwk/nwkUtil.c
+++ b/src/aig/nwk/nwkUtil.c
@@ -18,9 +18,12 @@
***********************************************************************/
+#include <math.h>
#include "nwk.h"
#include "kit.h"
-#include <math.h>
+
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -295,7 +298,7 @@ void Nwk_ManDumpBlif( Nwk_Man_t * pNtk, char * pFileName, Vec_Ptr_t * vPiNames,
vTruth = Vec_IntAlloc( 1 << 16 );
vCover = Vec_IntAlloc( 1 << 16 );
vNodes = Nwk_ManDfs( pNtk );
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, vNodes, pObj, i )
{
if ( !Nwk_ObjIsNode(pObj) )
continue;
@@ -425,7 +428,7 @@ void Nwk_ManPrintFanioNew( Nwk_Man_t * pNtk )
printf( "%15d : ", k );
else
{
- sprintf( Buffer, "%d - %d", (int)pow(10, k/10) * (k%10), (int)pow(10, k/10) * (k%10+1) - 1 );
+ sprintf( Buffer, "%d - %d", (int)pow((double)10, k/10) * (k%10), (int)pow((double)10, k/10) * (k%10+1) - 1 );
printf( "%15s : ", Buffer );
}
if ( vFanins->pArray[k] == 0 )
@@ -636,3 +639,5 @@ void Nwk_ManRemoveDupFanins( Nwk_Man_t * pNtk, int fVerbose )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/nwk/nwk_.c b/src/aig/nwk/nwk_.c
index 81cffbbf..882b077c 100644
--- a/src/aig/nwk/nwk_.c
+++ b/src/aig/nwk/nwk_.c
@@ -20,6 +20,9 @@
#include "nwk.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -45,3 +48,5 @@
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/nwk2/module.make b/src/aig/nwk2/module.make
deleted file mode 100644
index 226a68ef..00000000
--- a/src/aig/nwk2/module.make
+++ /dev/null
@@ -1,7 +0,0 @@
-SRC += src/aig/nwk/nwkCheck.c \
- src/aig/nwk/nwkDfs.c \
- src/aig/nwk/nwkFanio.c \
- src/aig/nwk/nwkMan.c \
- src/aig/nwk/nwkMerge.c \
- src/aig/nwk/nwkObj.c \
- src/aig/nwk/nwkUtil.c
diff --git a/src/aig/nwk2/nwk.h b/src/aig/nwk2/nwk.h
deleted file mode 100644
index 36d483fc..00000000
--- a/src/aig/nwk2/nwk.h
+++ /dev/null
@@ -1,278 +0,0 @@
-/**CFile****************************************************************
-
- FileName [nwk.h]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Logic network representation.]
-
- Synopsis [External declarations.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - June 20, 2005.]
-
- Revision [$Id: nwk.h,v 1.1 2008/05/14 22:13:09 wudenni Exp $]
-
-***********************************************************************/
-
-#ifndef __NWK_H__
-#define __NWK_H__
-
-////////////////////////////////////////////////////////////////////////
-/// INCLUDES ///
-////////////////////////////////////////////////////////////////////////
-
-#include "aig.h"
-#include "hop.h"
-#include "tim.h"
-
-////////////////////////////////////////////////////////////////////////
-/// PARAMETERS ///
-////////////////////////////////////////////////////////////////////////
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-////////////////////////////////////////////////////////////////////////
-/// BASIC TYPES ///
-////////////////////////////////////////////////////////////////////////
-
-typedef struct Nwk_Man_t_ Nwk_Man_t;
-typedef struct Nwk_Obj_t_ Nwk_Obj_t;
-
-// object types
-typedef enum {
- NWK_OBJ_NONE, // 0: non-existant object
- NWK_OBJ_CI, // 1: combinational input
- NWK_OBJ_CO, // 2: combinational output
- NWK_OBJ_NODE, // 3: logic node
- NWK_OBJ_LATCH, // 4: register
- NWK_OBJ_VOID // 5: unused object
-} Nwk_Type_t;
-
-struct Nwk_Man_t_
-{
- // models of this design
- char * pName; // the name of this design
- char * pSpec; // the name of input file
- // node representation
- Vec_Ptr_t * vCis; // the primary inputs of the extracted part
- Vec_Ptr_t * vCos; // the primary outputs of the extracted part
- Vec_Ptr_t * vObjs; // the objects in the topological order
- int nObjs[NWK_OBJ_VOID]; // counter of objects of each type
- int nFanioPlus; // the number of extra fanins/fanouts alloc by default
- // functionality, timing, memory, etc
- Hop_Man_t * pManHop; // the functionality representation
- Tim_Man_t * pManTime; // the timing manager
-// If_Lib_t * pLutLib; // the LUT library
- Aig_MmFlex_t * pMemObjs; // memory for objects
- Vec_Ptr_t * vTemp; // array used for incremental updates
- int nTravIds; // the counter of traversal IDs
- int nRealloced; // the number of realloced nodes
- // sequential information
- int nLatches; // the total number of latches
- int nTruePis; // the number of true primary inputs
- int nTruePos; // the number of true primary outputs
-};
-
-struct Nwk_Obj_t_
-{
- Nwk_Man_t * pMan; // the manager
- Hop_Obj_t * pFunc; // functionality
- void * pCopy; // temporary pointer
- union {
- void * pNext; // temporary pointer
- int iTemp; // temporary number
- };
- // node information
- unsigned Type : 3; // object type
- unsigned fInvert : 1; // complemented attribute
- unsigned MarkA : 1; // temporary mark
- unsigned MarkB : 1; // temporary mark
- unsigned MarkC : 1; // temporary mark
- unsigned PioId : 25; // number of this node in the PI/PO list
- int Id; // unique ID
- int TravId; // traversal ID
- // timing information
- int Level; // the topological level
- float tArrival; // the arrival time
- float tRequired; // the required time
- float tSlack; // the slack
- // fanin/fanout representation
- int nFanins; // the number of fanins
- int nFanouts; // the number of fanouts
- int nFanioAlloc; // the number of allocated fanins/fanouts
- Nwk_Obj_t ** pFanio; // fanins/fanouts
-};
-
-////////////////////////////////////////////////////////////////////////
-/// MACRO DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-
-////////////////////////////////////////////////////////////////////////
-/// INLINED FUNCTIONS ///
-////////////////////////////////////////////////////////////////////////
-
-static inline int Nwk_ManCiNum( Nwk_Man_t * p ) { return p->nObjs[NWK_OBJ_CI]; }
-static inline int Nwk_ManCoNum( Nwk_Man_t * p ) { return p->nObjs[NWK_OBJ_CO]; }
-static inline int Nwk_ManNodeNum( Nwk_Man_t * p ) { return p->nObjs[NWK_OBJ_NODE]; }
-static inline int Nwk_ManLatchNum( Nwk_Man_t * p ) { return p->nObjs[NWK_OBJ_LATCH]; }
-static inline int Nwk_ManObjNumMax( Nwk_Man_t * p ) { return Vec_PtrSize(p->vObjs); }
-
-static inline Nwk_Obj_t * Nwk_ManCi( Nwk_Man_t * p, int i ) { return (Nwk_Obj_t *)Vec_PtrEntry( p->vCis, i ); }
-static inline Nwk_Obj_t * Nwk_ManCo( Nwk_Man_t * p, int i ) { return (Nwk_Obj_t *)Vec_PtrEntry( p->vCos, i ); }
-static inline Nwk_Obj_t * Nwk_ManObj( Nwk_Man_t * p, int i ) { return (Nwk_Obj_t *)Vec_PtrEntry( p->vObjs, i ); }
-
-static inline int Nwk_ObjId( Nwk_Obj_t * p ) { return p->Id; }
-static inline int Nwk_ObjPioNum( Nwk_Obj_t * p ) { return p->PioId; }
-static inline int Nwk_ObjFaninNum( Nwk_Obj_t * p ) { return p->nFanins; }
-static inline int Nwk_ObjFanoutNum( Nwk_Obj_t * p ) { return p->nFanouts; }
-
-static inline Nwk_Obj_t * Nwk_ObjFanin0( Nwk_Obj_t * p ) { return p->pFanio[0]; }
-static inline Nwk_Obj_t * Nwk_ObjFanout0( Nwk_Obj_t * p ) { return p->pFanio[p->nFanins]; }
-static inline Nwk_Obj_t * Nwk_ObjFanin( Nwk_Obj_t * p, int i ) { return p->pFanio[i]; }
-static inline Nwk_Obj_t * Nwk_ObjFanout( Nwk_Obj_t * p, int i ) { return p->pFanio[p->nFanins+1]; }
-
-static inline int Nwk_ObjIsNone( Nwk_Obj_t * p ) { return p->Type == NWK_OBJ_NONE; }
-static inline int Nwk_ObjIsCi( Nwk_Obj_t * p ) { return p->Type == NWK_OBJ_CI; }
-static inline int Nwk_ObjIsCo( Nwk_Obj_t * p ) { return p->Type == NWK_OBJ_CO; }
-static inline int Nwk_ObjIsNode( Nwk_Obj_t * p ) { return p->Type == NWK_OBJ_NODE; }
-static inline int Nwk_ObjIsLatch( Nwk_Obj_t * p ) { return p->Type == NWK_OBJ_LATCH; }
-static inline int Nwk_ObjIsPi( Nwk_Obj_t * p ) { return Nwk_ObjIsCi(p) && (p->pMan->pManTime == NULL || Tim_ManBoxForCi(p->pMan->pManTime, p->PioId) == -1); }
-static inline int Nwk_ObjIsPo( Nwk_Obj_t * p ) { return Nwk_ObjIsCo(p) && (p->pMan->pManTime == NULL || Tim_ManBoxForCo(p->pMan->pManTime, p->PioId) == -1); }
-static inline int Nwk_ObjIsLi( Nwk_Obj_t * p ) { return p->pMan->nTruePos && Nwk_ObjIsCo(p) && (int)p->PioId >= p->pMan->nTruePos; }
-static inline int Nwk_ObjIsLo( Nwk_Obj_t * p ) { return p->pMan->nTruePis && Nwk_ObjIsCi(p) && (int)p->PioId >= p->pMan->nTruePis; }
-
-static inline float Nwk_ObjArrival( Nwk_Obj_t * pObj ) { return pObj->tArrival; }
-static inline float Nwk_ObjRequired( Nwk_Obj_t * pObj ) { return pObj->tRequired; }
-static inline float Nwk_ObjSlack( Nwk_Obj_t * pObj ) { return pObj->tSlack; }
-static inline void Nwk_ObjSetArrival( Nwk_Obj_t * pObj, float Time ) { pObj->tArrival = Time; }
-static inline void Nwk_ObjSetRequired( Nwk_Obj_t * pObj, float Time ) { pObj->tRequired = Time; }
-static inline void Nwk_ObjSetSlack( Nwk_Obj_t * pObj, float Time ) { pObj->tSlack = Time; }
-
-static inline int Nwk_ObjLevel( Nwk_Obj_t * pObj ) { return pObj->Level; }
-static inline void Nwk_ObjSetLevel( Nwk_Obj_t * pObj, int Level ) { pObj->Level = Level; }
-
-static inline void Nwk_ObjSetTravId( Nwk_Obj_t * pObj, int TravId ) { pObj->TravId = TravId; }
-static inline void Nwk_ObjSetTravIdCurrent( Nwk_Obj_t * pObj ) { pObj->TravId = pObj->pMan->nTravIds; }
-static inline void Nwk_ObjSetTravIdPrevious( Nwk_Obj_t * pObj ) { pObj->TravId = pObj->pMan->nTravIds - 1; }
-static inline int Nwk_ObjIsTravIdCurrent( Nwk_Obj_t * pObj ) { return pObj->TravId == pObj->pMan->nTravIds; }
-static inline int Nwk_ObjIsTravIdPrevious( Nwk_Obj_t * pObj ) { return pObj->TravId == pObj->pMan->nTravIds - 1; }
-
-static inline int Nwk_ManTimeEqual( float f1, float f2, float Eps ) { return (f1 < f2 + Eps) && (f2 < f1 + Eps); }
-static inline int Nwk_ManTimeLess( float f1, float f2, float Eps ) { return (f1 < f2 + Eps); }
-static inline int Nwk_ManTimeMore( float f1, float f2, float Eps ) { return (f1 + Eps > f2); }
-
-////////////////////////////////////////////////////////////////////////
-/// ITERATORS ///
-////////////////////////////////////////////////////////////////////////
-
-#define Nwk_ManForEachCi( p, pObj, i ) \
- Vec_PtrForEachEntry( p->vCis, pObj, i )
-#define Nwk_ManForEachCo( p, pObj, i ) \
- Vec_PtrForEachEntry( p->vCos, pObj, i )
-#define Nwk_ManForEachPi( p, pObj, i ) \
- Vec_PtrForEachEntry( p->vCis, pObj, i ) \
- if ( !Nwk_ObjIsPi(pObj) ) {} else
-#define Nwk_ManForEachPo( p, pObj, i ) \
- Vec_PtrForEachEntry( p->vCos, pObj, i ) \
- if ( !Nwk_ObjIsPo(pObj) ) {} else
-#define Nwk_ManForEachObj( p, pObj, i ) \
- for ( i = 0; (i < Vec_PtrSize(p->vObjs)) && (((pObj) = Vec_PtrEntry(p->vObjs, i)), 1); i++ ) \
- if ( pObj == NULL ) {} else
-#define Nwk_ManForEachNode( p, pObj, i ) \
- for ( i = 0; (i < Vec_PtrSize(p->vObjs)) && (((pObj) = Vec_PtrEntry(p->vObjs, i)), 1); i++ ) \
- if ( (pObj) == NULL || !Nwk_ObjIsNode(pObj) ) {} else
-#define Nwk_ManForEachLatch( p, pObj, i ) \
- for ( i = 0; (i < Vec_PtrSize(p->vObjs)) && (((pObj) = Vec_PtrEntry(p->vObjs, i)), 1); i++ ) \
- if ( (pObj) == NULL || !Nwk_ObjIsLatch(pObj) ) {} else
-
-#define Nwk_ObjForEachFanin( pObj, pFanin, i ) \
- for ( i = 0; (i < (int)(pObj)->nFanins) && ((pFanin) = (pObj)->pFanio[i]); i++ )
-#define Nwk_ObjForEachFanout( pObj, pFanout, i ) \
- for ( i = 0; (i < (int)(pObj)->nFanouts) && ((pFanout) = (pObj)->pFanio[(pObj)->nFanins+i]); i++ )
-
-// sequential iterators
-#define Nwk_ManForEachPiSeq( p, pObj, i ) \
- Vec_PtrForEachEntryStop( p->vCis, pObj, i, (p)->nTruePis )
-#define Nwk_ManForEachPoSeq( p, pObj, i ) \
- Vec_PtrForEachEntryStop( p->vCos, pObj, i, (p)->nTruePos )
-#define Nwk_ManForEachLoSeq( p, pObj, i ) \
- for ( i = 0; (i < (p)->nLatches) && (((pObj) = Vec_PtrEntry(p->vCis, i+(p)->nTruePis)), 1); i++ )
-#define Nwk_ManForEachLiSeq( p, pObj, i ) \
- for ( i = 0; (i < (p)->nLatches) && (((pObj) = Vec_PtrEntry(p->vCos, i+(p)->nTruePos)), 1); i++ )
-#define Nwk_ManForEachLiLoSeq( p, pObjLi, pObjLo, i ) \
- for ( i = 0; (i < (p)->nLatches) && (((pObjLi) = Nwk_ManCo(p, i+(p)->nTruePos)), 1) \
- && (((pObjLo) = Nwk_ManCi(p, i+(p)->nTruePis)), 1); i++ )
-
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/*=== nwkCheck.c ==========================================================*/
-extern int Nwk_ManCheck( Nwk_Man_t * p );
-/*=== nwkDfs.c ==========================================================*/
-extern int Nwk_ManVerifyTopoOrder( Nwk_Man_t * pNtk );
-extern int Nwk_ManLevelBackup( Nwk_Man_t * pNtk );
-extern int Nwk_ManLevel( Nwk_Man_t * pNtk );
-extern int Nwk_ManLevelMax( Nwk_Man_t * pNtk );
-extern Vec_Vec_t * Nwk_ManLevelize( Nwk_Man_t * pNtk );
-extern Vec_Ptr_t * Nwk_ManDfs( Nwk_Man_t * pNtk );
-extern Vec_Ptr_t * Nwk_ManDfsNodes( Nwk_Man_t * pNtk, Nwk_Obj_t ** ppNodes, int nNodes );
-extern Vec_Ptr_t * Nwk_ManDfsReverse( Nwk_Man_t * pNtk );
-extern Vec_Ptr_t * Nwk_ManSupportNodes( Nwk_Man_t * pNtk, Nwk_Obj_t ** ppNodes, int nNodes );
-extern void Nwk_ManSupportSum( Nwk_Man_t * pNtk );
-extern int Nwk_ObjMffcLabel( Nwk_Obj_t * pNode );
-/*=== nwkFanio.c ==========================================================*/
-extern void Nwk_ObjCollectFanins( Nwk_Obj_t * pNode, Vec_Ptr_t * vNodes );
-extern void Nwk_ObjCollectFanouts( Nwk_Obj_t * pNode, Vec_Ptr_t * vNodes );
-extern int Nwk_ObjFindFanin( Nwk_Obj_t * pObj, Nwk_Obj_t * pFanin );
-extern int Nwk_ObjFindFanout( Nwk_Obj_t * pObj, Nwk_Obj_t * pFanout );
-extern void Nwk_ObjAddFanin( Nwk_Obj_t * pObj, Nwk_Obj_t * pFanin );
-extern void Nwk_ObjDeleteFanin( Nwk_Obj_t * pObj, Nwk_Obj_t * pFanin );
-extern void Nwk_ObjPatchFanin( Nwk_Obj_t * pObj, Nwk_Obj_t * pFaninOld, Nwk_Obj_t * pFaninNew );
-extern void Nwk_ObjTransferFanout( Nwk_Obj_t * pNodeFrom, Nwk_Obj_t * pNodeTo );
-extern void Nwk_ObjReplace( Nwk_Obj_t * pNodeOld, Nwk_Obj_t * pNodeNew );
-/*=== nwkMan.c ============================================================*/
-extern Nwk_Man_t * Nwk_ManAlloc();
-extern void Nwk_ManFree( Nwk_Man_t * p );
-//extern void Nwk_ManPrintStats( Nwk_Man_t * p, If_Lib_t * pLutLib, int fSaveBest, int fDumpResult, int fPower, void * pNtl );
-/*=== nwkObj.c ============================================================*/
-extern Nwk_Obj_t * Nwk_ManCreateCi( Nwk_Man_t * pMan, int nFanouts );
-extern Nwk_Obj_t * Nwk_ManCreateCo( Nwk_Man_t * pMan );
-extern Nwk_Obj_t * Nwk_ManCreateNode( Nwk_Man_t * pMan, int nFanins, int nFanouts );
-extern Nwk_Obj_t * Nwk_ManCreateBox( Nwk_Man_t * pMan, int nFanins, int nFanouts );
-extern Nwk_Obj_t * Nwk_ManCreateLatch( Nwk_Man_t * pMan );
-extern void Nwk_ManDeleteNode( Nwk_Obj_t * pObj );
-extern void Nwk_ManDeleteNode_rec( Nwk_Obj_t * pObj );
-/*=== nwkUtil.c ============================================================*/
-extern void Nwk_ManIncrementTravId( Nwk_Man_t * pNtk );
-extern int Nwk_ManGetFaninMax( Nwk_Man_t * pNtk );
-extern int Nwk_ManGetTotalFanins( Nwk_Man_t * pNtk );
-extern int Nwk_ManPiNum( Nwk_Man_t * pNtk );
-extern int Nwk_ManPoNum( Nwk_Man_t * pNtk );
-extern int Nwk_ManGetAigNodeNum( Nwk_Man_t * pNtk );
-extern int Nwk_NodeCompareLevelsIncrease( Nwk_Obj_t ** pp1, Nwk_Obj_t ** pp2 );
-extern int Nwk_NodeCompareLevelsDecrease( Nwk_Obj_t ** pp1, Nwk_Obj_t ** pp2 );
-extern void Nwk_ObjPrint( Nwk_Obj_t * pObj );
-extern void Nwk_ManDumpBlif( Nwk_Man_t * pNtk, char * pFileName, Vec_Ptr_t * vCiNames, Vec_Ptr_t * vCoNames );
-extern void Nwk_ManPrintFanioNew( Nwk_Man_t * pNtk );
-extern void Nwk_ManCleanMarks( Nwk_Man_t * pNtk );
-extern void Nwk_ManMinimumBase( Nwk_Man_t * pNtk, int fVerbose );
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
diff --git a/src/aig/nwk2/nwkCheck.c b/src/aig/nwk2/nwkCheck.c
deleted file mode 100644
index 6922e439..00000000
--- a/src/aig/nwk2/nwkCheck.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/**CFile****************************************************************
-
- FileName [nwkCheck.c]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Logic network representation.]
-
- Synopsis [Consistency checking procedures.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - June 20, 2005.]
-
- Revision [$Id: nwkCheck.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#include "nwk.h"
-
-////////////////////////////////////////////////////////////////////////
-/// DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
- Synopsis [Checking the logic network for consistency.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Nwk_ManCheck( Nwk_Man_t * p )
-{
- Nwk_Obj_t * pObj;
- int i, k, m;
- // check if the nodes have duplicated fanins
- Nwk_ManForEachNode( p, pObj, i )
- {
- for ( k = 0; k < pObj->nFanins; k++ )
- for ( m = k + 1; m < pObj->nFanins; m++ )
- if ( pObj->pFanio[k] == pObj->pFanio[m] )
- printf( "Node %d has duplicated fanin %d.\n", pObj->Id, pObj->pFanio[k]->Id );
- }
-/*
- // check if all nodes are in the correct fanin/fanout relationship
- Nwk_ManForEachObj( p, pObj, i )
- {
- Nwk_ObjForEachFanin( pObj, pNext, k )
- if ( Nwk_ObjFindFanout( pNext, pObj ) == -1 )
- printf( "Nwk_ManCheck(): Object %d has fanin %d which does not have a corresponding fanout.\n", pObj->Id, pNext->Id );
- Nwk_ObjForEachFanout( pObj, pNext, k )
- if ( Nwk_ObjFindFanin( pNext, pObj ) == -1 )
- printf( "Nwk_ManCheck(): Object %d has fanout %d which does not have a corresponding fanin.\n", pObj->Id, pNext->Id );
- }
-*/
- return 1;
-}
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
-
diff --git a/src/aig/nwk2/nwkDfs.c b/src/aig/nwk2/nwkDfs.c
deleted file mode 100644
index c1c77349..00000000
--- a/src/aig/nwk2/nwkDfs.c
+++ /dev/null
@@ -1,659 +0,0 @@
-/**CFile****************************************************************
-
- FileName [nwkDfs.c]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Logic network representation.]
-
- Synopsis [DFS traversals.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - June 20, 2005.]
-
- Revision [$Id: nwkDfs.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#include "nwk.h"
-
-////////////////////////////////////////////////////////////////////////
-/// DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
- Synopsis [Verifies that the objects are in a topo order.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Nwk_ManVerifyTopoOrder( Nwk_Man_t * pNtk )
-{
- Nwk_Obj_t * pObj, * pNext;
- int i, k, iBox, iTerm1, nTerms;
- Nwk_ManIncrementTravId( pNtk );
- Nwk_ManForEachObj( pNtk, pObj, i )
- {
- if ( Nwk_ObjIsNode(pObj) || Nwk_ObjIsCo(pObj) )
- {
- Nwk_ObjForEachFanin( pObj, pNext, k )
- {
- if ( !Nwk_ObjIsTravIdCurrent(pNext) )
- {
- printf( "Node %d has fanin %d that is not in a topological order.\n", pObj->Id, pNext->Id );
- return 0;
- }
- }
- }
- else if ( Nwk_ObjIsCi(pObj) )
- {
- if ( pNtk->pManTime )
- {
- iBox = Tim_ManBoxForCi( pNtk->pManTime, pObj->PioId );
- if ( iBox >= 0 ) // this is not a true PI
- {
- iTerm1 = Tim_ManBoxInputFirst( pNtk->pManTime, iBox );
- nTerms = Tim_ManBoxInputNum( pNtk->pManTime, iBox );
- for ( k = 0; k < nTerms; k++ )
- {
- pNext = Nwk_ManCo( pNtk, iTerm1 + k );
- if ( !Nwk_ObjIsTravIdCurrent(pNext) )
- {
- printf( "Box %d has input %d that is not in a topological order.\n", iBox, pNext->Id );
- return 0;
- }
- }
- }
- }
- }
- else
- assert( 0 );
- Nwk_ObjSetTravIdCurrent( pObj );
- }
- return 1;
-}
-
-/**Function*************************************************************
-
- Synopsis [Computes the number of logic levels not counting PIs/POs.]
-
- Description [Assumes that white boxes have unit level.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Nwk_ManLevelBackup( Nwk_Man_t * pNtk )
-{
- Tim_Man_t * pManTimeUnit;
- Nwk_Obj_t * pObj, * pFanin;
- int i, k, LevelMax, Level;
- assert( Nwk_ManVerifyTopoOrder(pNtk) );
- // clean the levels
- Nwk_ManForEachObj( pNtk, pObj, i )
- Nwk_ObjSetLevel( pObj, 0 );
- // perform level computation
- LevelMax = 0;
- pManTimeUnit = pNtk->pManTime ? Tim_ManDupUnit( pNtk->pManTime ) : NULL;
- if ( pManTimeUnit )
- Tim_ManIncrementTravId( pManTimeUnit );
- Nwk_ManForEachObj( pNtk, pObj, i )
- {
- if ( Nwk_ObjIsCi(pObj) )
- {
- Level = pManTimeUnit? (int)Tim_ManGetCiArrival( pManTimeUnit, pObj->PioId ) : 0;
- Nwk_ObjSetLevel( pObj, Level );
- }
- else if ( Nwk_ObjIsCo(pObj) )
- {
- Level = Nwk_ObjLevel( Nwk_ObjFanin0(pObj) );
- if ( pManTimeUnit )
- Tim_ManSetCoArrival( pManTimeUnit, pObj->PioId, (float)Level );
- Nwk_ObjSetLevel( pObj, Level );
- if ( LevelMax < Nwk_ObjLevel(pObj) )
- LevelMax = Nwk_ObjLevel(pObj);
- }
- else if ( Nwk_ObjIsNode(pObj) )
- {
- Level = 0;
- Nwk_ObjForEachFanin( pObj, pFanin, k )
- if ( Level < Nwk_ObjLevel(pFanin) )
- Level = Nwk_ObjLevel(pFanin);
- Nwk_ObjSetLevel( pObj, Level + 1 );
- }
- else
- assert( 0 );
- }
- // set the old timing manager
- if ( pManTimeUnit )
- Tim_ManStop( pManTimeUnit );
- return LevelMax;
-}
-
-/**Function*************************************************************
-
- Synopsis [Computes the number of logic levels not counting PIs/POs.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Nwk_ManLevel_rec( Nwk_Obj_t * pObj )
-{
- Tim_Man_t * pManTime = pObj->pMan->pManTime;
- Nwk_Obj_t * pNext;
- int i, iBox, iTerm1, nTerms, LevelMax = 0;
- if ( Nwk_ObjIsTravIdCurrent( pObj ) )
- return;
- Nwk_ObjSetTravIdCurrent( pObj );
- if ( Nwk_ObjIsCi(pObj) )
- {
- if ( pManTime )
- {
- iBox = Tim_ManBoxForCi( pManTime, pObj->PioId );
- if ( iBox >= 0 ) // this is not a true PI
- {
- iTerm1 = Tim_ManBoxInputFirst( pManTime, iBox );
- nTerms = Tim_ManBoxInputNum( pManTime, iBox );
- for ( i = 0; i < nTerms; i++ )
- {
- pNext = Nwk_ManCo(pObj->pMan, iTerm1 + i);
- Nwk_ManLevel_rec( pNext );
- if ( LevelMax < Nwk_ObjLevel(pNext) )
- LevelMax = Nwk_ObjLevel(pNext);
- }
- LevelMax++;
- }
- }
- }
- else if ( Nwk_ObjIsNode(pObj) || Nwk_ObjIsCo(pObj) )
- {
- Nwk_ObjForEachFanin( pObj, pNext, i )
- {
- Nwk_ManLevel_rec( pNext );
- if ( LevelMax < Nwk_ObjLevel(pNext) )
- LevelMax = Nwk_ObjLevel(pNext);
- }
- if ( Nwk_ObjIsNode(pObj) && Nwk_ObjFaninNum(pObj) > 0 )
- LevelMax++;
- }
- else
- assert( 0 );
- Nwk_ObjSetLevel( pObj, LevelMax );
-}
-
-/**Function*************************************************************
-
- Synopsis [Computes the number of logic levels not counting PIs/POs.]
-
- Description [Does not assume that the objects are in a topo order.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Nwk_ManLevel( Nwk_Man_t * pNtk )
-{
- Nwk_Obj_t * pObj;
- int i, LevelMax = 0;
- Nwk_ManForEachObj( pNtk, pObj, i )
- Nwk_ObjSetLevel( pObj, 0 );
- Nwk_ManIncrementTravId( pNtk );
- Nwk_ManForEachPo( pNtk, pObj, i )
- {
- Nwk_ManLevel_rec( pObj );
- if ( LevelMax < Nwk_ObjLevel(pObj) )
- LevelMax = Nwk_ObjLevel(pObj);
- }
- Nwk_ManForEachCi( pNtk, pObj, i )
- {
- Nwk_ManLevel_rec( pObj );
- if ( LevelMax < Nwk_ObjLevel(pObj) )
- LevelMax = Nwk_ObjLevel(pObj);
- }
- return LevelMax;
-}
-
-/**Function*************************************************************
-
- Synopsis [Computes the number of logic levels not counting PIs/POs.]
-
- Description [Does not assume that the objects are in a topo order.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Nwk_ManLevelMax( Nwk_Man_t * pNtk )
-{
- Nwk_Obj_t * pObj;
- int i, LevelMax = 0;
- Nwk_ManForEachPo( pNtk, pObj, i )
- if ( LevelMax < Nwk_ObjLevel(pObj) )
- LevelMax = Nwk_ObjLevel(pObj);
- return LevelMax;
-}
-
-/**Function*************************************************************
-
- Synopsis [Returns the array of objects in the AIG manager ordered by level.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Vec_Vec_t * Nwk_ManLevelize( Nwk_Man_t * pNtk )
-{
- Nwk_Obj_t * pObj;
- Vec_Vec_t * vLevels;
- int nLevels, i;
-// assert( Nwk_ManVerifyLevel(pNtk) );
- nLevels = Nwk_ManLevelMax( pNtk );
- vLevels = Vec_VecStart( nLevels + 1 );
- Nwk_ManForEachNode( pNtk, pObj, i )
- {
- assert( Nwk_ObjLevel(pObj) <= nLevels );
- Vec_VecPush( vLevels, Nwk_ObjLevel(pObj), pObj );
- }
- return vLevels;
-}
-
-
-
-/**Function*************************************************************
-
- Synopsis [Performs DFS for one node.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Nwk_ManDfs_rec( Nwk_Obj_t * pObj, Vec_Ptr_t * vNodes )
-{
- Nwk_Obj_t * pNext;
- int i;
- if ( Nwk_ObjIsTravIdCurrent( pObj ) )
- return;
- Nwk_ObjSetTravIdCurrent( pObj );
- Nwk_ObjForEachFanin( pObj, pNext, i )
- Nwk_ManDfs_rec( pNext, vNodes );
- Vec_PtrPush( vNodes, pObj );
-}
-
-/**Function*************************************************************
-
- Synopsis [Returns the DFS ordered array of all objects except latches.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Vec_Ptr_t * Nwk_ManDfs( Nwk_Man_t * pNtk )
-{
- Vec_Ptr_t * vNodes;
- Nwk_Obj_t * pObj;
- int i;
- Nwk_ManIncrementTravId( pNtk );
- vNodes = Vec_PtrAlloc( 100 );
- Nwk_ManForEachObj( pNtk, pObj, i )
- {
- if ( Nwk_ObjIsCi(pObj) )
- {
- Nwk_ObjSetTravIdCurrent( pObj );
- Vec_PtrPush( vNodes, pObj );
- }
- else if ( Nwk_ObjIsCo(pObj) )
- Nwk_ManDfs_rec( pObj, vNodes );
- }
- return vNodes;
-}
-
-/**Function*************************************************************
-
- Synopsis [Performs DFS for one node.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Nwk_ManDfsNodes_rec( Nwk_Obj_t * pObj, Vec_Ptr_t * vNodes )
-{
- Nwk_Obj_t * pNext;
- int i;
- if ( Nwk_ObjIsTravIdCurrent( pObj ) )
- return;
- Nwk_ObjSetTravIdCurrent( pObj );
- if ( Nwk_ObjIsCi(pObj) )
- return;
- assert( Nwk_ObjIsNode(pObj) );
- Nwk_ObjForEachFanin( pObj, pNext, i )
- Nwk_ManDfsNodes_rec( pNext, vNodes );
- Vec_PtrPush( vNodes, pObj );
-}
-
-/**Function*************************************************************
-
- Synopsis [Returns the set of internal nodes rooted in the given nodes.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Vec_Ptr_t * Nwk_ManDfsNodes( Nwk_Man_t * pNtk, Nwk_Obj_t ** ppNodes, int nNodes )
-{
- Vec_Ptr_t * vNodes;
- int i;
- // set the traversal ID
- Nwk_ManIncrementTravId( pNtk );
- // start the array of nodes
- vNodes = Vec_PtrAlloc( 100 );
- // go through the PO nodes and call for each of them
- for ( i = 0; i < nNodes; i++ )
- if ( Nwk_ObjIsCo(ppNodes[i]) )
- Nwk_ManDfsNodes_rec( Nwk_ObjFanin0(ppNodes[i]), vNodes );
- else
- Nwk_ManDfsNodes_rec( ppNodes[i], vNodes );
- return vNodes;
-}
-
-/**Function*************************************************************
-
- Synopsis [Performs DFS for one node.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Nwk_ManDfsReverse_rec( Nwk_Obj_t * pObj, Vec_Ptr_t * vNodes )
-{
- Nwk_Obj_t * pNext;
- int i, iBox, iTerm1, nTerms;
- if ( Nwk_ObjIsTravIdCurrent( pObj ) )
- return;
- Nwk_ObjSetTravIdCurrent( pObj );
- if ( Nwk_ObjIsCo(pObj) )
- {
- if ( pObj->pMan->pManTime )
- {
- iBox = Tim_ManBoxForCo( pObj->pMan->pManTime, pObj->PioId );
- if ( iBox >= 0 ) // this is not a true PO
- {
- iTerm1 = Tim_ManBoxOutputFirst( pObj->pMan->pManTime, iBox );
- nTerms = Tim_ManBoxOutputNum( pObj->pMan->pManTime, iBox );
- for ( i = 0; i < nTerms; i++ )
- {
- pNext = Nwk_ManCi(pObj->pMan, iTerm1 + i);
- Nwk_ManDfsReverse_rec( pNext, vNodes );
- }
- }
- }
- }
- else if ( Nwk_ObjIsNode(pObj) || Nwk_ObjIsCi(pObj) )
- {
- Nwk_ObjForEachFanout( pObj, pNext, i )
- Nwk_ManDfsReverse_rec( pNext, vNodes );
- }
- else
- assert( 0 );
- Vec_PtrPush( vNodes, pObj );
-}
-
-/**Function*************************************************************
-
- Synopsis [Returns the DFS ordered array of all objects except latches.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Vec_Ptr_t * Nwk_ManDfsReverse( Nwk_Man_t * pNtk )
-{
- Vec_Ptr_t * vNodes;
- Nwk_Obj_t * pObj;
- int i;
- Nwk_ManIncrementTravId( pNtk );
- vNodes = Vec_PtrAlloc( 100 );
- Nwk_ManForEachPi( pNtk, pObj, i )
- Nwk_ManDfsReverse_rec( pObj, vNodes );
- // add nodes without fanins
- Nwk_ManForEachNode( pNtk, pObj, i )
- if ( Nwk_ObjFaninNum(pObj) == 0 && !Nwk_ObjIsTravIdCurrent(pObj) )
- Vec_PtrPush( vNodes, pObj );
- return vNodes;
-}
-
-/**Function*************************************************************
-
- Synopsis [Performs DFS for one node.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Nwk_ManSupportNodes_rec( Nwk_Obj_t * pNode, Vec_Ptr_t * vNodes )
-{
- Nwk_Obj_t * pFanin;
- int i;
- // if this node is already visited, skip
- if ( Nwk_ObjIsTravIdCurrent( pNode ) )
- return;
- // mark the node as visited
- Nwk_ObjSetTravIdCurrent( pNode );
- // collect the CI
- if ( Nwk_ObjIsCi(pNode) )
- {
- Vec_PtrPush( vNodes, pNode );
- return;
- }
- assert( Nwk_ObjIsNode( pNode ) );
- // visit the transitive fanin of the node
- Nwk_ObjForEachFanin( pNode, pFanin, i )
- Nwk_ManSupportNodes_rec( pFanin, vNodes );
-}
-
-/**Function*************************************************************
-
- Synopsis [Returns the set of CI nodes in the support of the given nodes.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Vec_Ptr_t * Nwk_ManSupportNodes( Nwk_Man_t * pNtk, Nwk_Obj_t ** ppNodes, int nNodes )
-{
- Vec_Ptr_t * vNodes;
- int i;
- // set the traversal ID
- Nwk_ManIncrementTravId( pNtk );
- // start the array of nodes
- vNodes = Vec_PtrAlloc( 100 );
- // go through the PO nodes and call for each of them
- for ( i = 0; i < nNodes; i++ )
- if ( Nwk_ObjIsCo(ppNodes[i]) )
- Nwk_ManSupportNodes_rec( Nwk_ObjFanin0(ppNodes[i]), vNodes );
- else
- Nwk_ManSupportNodes_rec( ppNodes[i], vNodes );
- return vNodes;
-}
-
-/**Function*************************************************************
-
- Synopsis [Computes the sum total of supports of all outputs.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Nwk_ManSupportSum( Nwk_Man_t * pNtk )
-{
- Vec_Ptr_t * vSupp;
- Nwk_Obj_t * pObj;
- int i, nTotalSupps = 0;
- Nwk_ManForEachCo( pNtk, pObj, i )
- {
- vSupp = Nwk_ManSupportNodes( pNtk, &pObj, 1 );
- nTotalSupps += Vec_PtrSize( vSupp );
- Vec_PtrFree( vSupp );
- }
- printf( "Total supports = %d.\n", nTotalSupps );
-}
-
-
-/**Function*************************************************************
-
- Synopsis [Dereferences the node's MFFC.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Nwk_ObjDeref_rec( Nwk_Obj_t * pNode )
-{
- Nwk_Obj_t * pFanin;
- int i, Counter = 1;
- if ( Nwk_ObjIsCi(pNode) )
- return 0;
- Nwk_ObjForEachFanin( pNode, pFanin, i )
- {
- assert( pFanin->nFanouts > 0 );
- if ( --pFanin->nFanouts == 0 )
- Counter += Nwk_ObjDeref_rec( pFanin );
- }
- return Counter;
-}
-
-/**Function*************************************************************
-
- Synopsis [References the node's MFFC.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Nwk_ObjRef_rec( Nwk_Obj_t * pNode )
-{
- Nwk_Obj_t * pFanin;
- int i, Counter = 1;
- if ( Nwk_ObjIsCi(pNode) )
- return 0;
- Nwk_ObjForEachFanin( pNode, pFanin, i )
- {
- if ( pFanin->nFanouts++ == 0 )
- Counter += Nwk_ObjRef_rec( pFanin );
- }
- return Counter;
-}
-
-/**Function*************************************************************
-
- Synopsis [Collects the internal and boundary nodes in the derefed MFFC.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Nwk_ObjMffcLabel_rec( Nwk_Obj_t * pNode, int fTopmost )
-{
- Nwk_Obj_t * pFanin;
- int i;
- // add to the new support nodes
- if ( !fTopmost && (Nwk_ObjIsCi(pNode) || pNode->nFanouts > 0) )
- return;
- // skip visited nodes
- if ( Nwk_ObjIsTravIdCurrent(pNode) )
- return;
- Nwk_ObjSetTravIdCurrent(pNode);
- // recur on the children
- Nwk_ObjForEachFanin( pNode, pFanin, i )
- Nwk_ObjMffcLabel_rec( pFanin, 0 );
- // collect the internal node
-// printf( "%d ", pNode->Id );
-}
-
-/**Function*************************************************************
-
- Synopsis [Collects the internal nodes of the MFFC limited by cut.]
-
- Description []
-
- SideEffects [Increments the trav ID and marks visited nodes.]
-
- SeeAlso []
-
-***********************************************************************/
-int Nwk_ObjMffcLabel( Nwk_Obj_t * pNode )
-{
- int Count1, Count2;
- // dereference the node
- Count1 = Nwk_ObjDeref_rec( pNode );
- // collect the nodes inside the MFFC
- Nwk_ManIncrementTravId( pNode->pMan );
- Nwk_ObjMffcLabel_rec( pNode, 1 );
- // reference it back
- Count2 = Nwk_ObjRef_rec( pNode );
- assert( Count1 == Count2 );
- return Count1;
-}
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
-
diff --git a/src/aig/nwk2/nwkFanio.c b/src/aig/nwk2/nwkFanio.c
deleted file mode 100644
index 30037a83..00000000
--- a/src/aig/nwk2/nwkFanio.c
+++ /dev/null
@@ -1,309 +0,0 @@
-/**CFile****************************************************************
-
- FileName [nwkFanio.c]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Logic network representation.]
-
- Synopsis [Manipulation of fanins/fanouts.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - June 20, 2005.]
-
- Revision [$Id: nwkFanio.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#include "nwk.h"
-
-////////////////////////////////////////////////////////////////////////
-/// DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
- Synopsis [Collects fanins of the node.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Nwk_ObjCollectFanins( Nwk_Obj_t * pNode, Vec_Ptr_t * vNodes )
-{
- Nwk_Obj_t * pFanin;
- int i;
- Vec_PtrClear(vNodes);
- Nwk_ObjForEachFanin( pNode, pFanin, i )
- Vec_PtrPush( vNodes, pFanin );
-}
-
-/**Function*************************************************************
-
- Synopsis [Collects fanouts of the node.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Nwk_ObjCollectFanouts( Nwk_Obj_t * pNode, Vec_Ptr_t * vNodes )
-{
- Nwk_Obj_t * pFanout;
- int i;
- Vec_PtrClear(vNodes);
- Nwk_ObjForEachFanout( pNode, pFanout, i )
- Vec_PtrPush( vNodes, pFanout );
-}
-
-/**Function*************************************************************
-
- Synopsis [Returns the number of the fanin of the node.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Nwk_ObjFindFanin( Nwk_Obj_t * pObj, Nwk_Obj_t * pFanin )
-{
- Nwk_Obj_t * pTemp;
- int i;
- Nwk_ObjForEachFanin( pObj, pTemp, i )
- if ( pTemp == pFanin )
- return i;
- return -1;
-}
-
-/**Function*************************************************************
-
- Synopsis [Returns the number of the fanout of the node.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Nwk_ObjFindFanout( Nwk_Obj_t * pObj, Nwk_Obj_t * pFanout )
-{
- Nwk_Obj_t * pTemp;
- int i;
- Nwk_ObjForEachFanout( pObj, pTemp, i )
- if ( pTemp == pFanout )
- return i;
- return -1;
-}
-
-/**Function*************************************************************
-
- Synopsis [Returns 1 if the node has to be reallocated.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline int Nwk_ObjReallocIsNeeded( Nwk_Obj_t * pObj )
-{
- return pObj->nFanins + pObj->nFanouts == pObj->nFanioAlloc;
-}
-
-/**Function*************************************************************
-
- Synopsis [Reallocates the object.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static Nwk_Obj_t * Nwk_ManReallocNode( Nwk_Obj_t * pObj )
-{
- Nwk_Obj_t ** pFanioOld = pObj->pFanio;
- assert( Nwk_ObjReallocIsNeeded(pObj) );
- pObj->pFanio = (Nwk_Obj_t **)Aig_MmFlexEntryFetch( pObj->pMan->pMemObjs, 2 * pObj->nFanioAlloc * sizeof(Nwk_Obj_t *) );
- memmove( pObj->pFanio, pFanioOld, pObj->nFanioAlloc * sizeof(Nwk_Obj_t *) );
- pObj->nFanioAlloc *= 2;
- pObj->pMan->nRealloced++;
- return NULL;
-}
-
-/**Function*************************************************************
-
- Synopsis [Creates fanout/fanin relationship between the nodes.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Nwk_ObjAddFanin( Nwk_Obj_t * pObj, Nwk_Obj_t * pFanin )
-{
- int i;
- assert( pObj->pMan == pFanin->pMan );
- assert( pObj->Id >= 0 && pFanin->Id >= 0 );
- if ( Nwk_ObjReallocIsNeeded(pObj) )
- Nwk_ManReallocNode( pObj );
- if ( Nwk_ObjReallocIsNeeded(pFanin) )
- Nwk_ManReallocNode( pFanin );
- for ( i = pObj->nFanins + pObj->nFanouts; i > pObj->nFanins; i-- )
- pObj->pFanio[i] = pObj->pFanio[i-1];
- pObj->pFanio[pObj->nFanins++] = pFanin;
- pFanin->pFanio[pFanin->nFanins + pFanin->nFanouts++] = pObj;
- pObj->Level = ABC_MAX( pObj->Level, pFanin->Level + Nwk_ObjIsNode(pObj) );
-}
-
-/**Function*************************************************************
-
- Synopsis [Removes fanout/fanin relationship between the nodes.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Nwk_ObjDeleteFanin( Nwk_Obj_t * pObj, Nwk_Obj_t * pFanin )
-{
- int i, k, Limit;
- // remove pFanin from the fanin list of pObj
- Limit = pObj->nFanins + pObj->nFanouts;
- for ( k = i = 0; i < Limit; i++ )
- if ( pObj->pFanio[i] != pFanin )
- pObj->pFanio[k++] = pObj->pFanio[i];
- assert( i == k + 1 ); // if it fails, likely because of duplicated fanin
- pObj->nFanins--;
- // remove pObj from the fanout list of pFanin
- Limit = pFanin->nFanins + pFanin->nFanouts;
- for ( k = i = pFanin->nFanins; i < Limit; i++ )
- if ( pFanin->pFanio[i] != pObj )
- pFanin->pFanio[k++] = pFanin->pFanio[i];
- assert( i == k + 1 ); // if it fails, likely because of duplicated fanout
- pFanin->nFanouts--;
-}
-
-/**Function*************************************************************
-
- Synopsis [Replaces a fanin of the node.]
-
- Description [The node is pObj. An old fanin of this node (pFaninOld) has to be
- replaced by a new fanin (pFaninNew). Assumes that the node and the old fanin
- are not complemented. The new fanin can be complemented. In this case, the
- polarity of the new fanin will change, compared to the polarity of the old fanin.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Nwk_ObjPatchFanin( Nwk_Obj_t * pObj, Nwk_Obj_t * pFaninOld, Nwk_Obj_t * pFaninNew )
-{
- int i, k, iFanin, Limit;
- assert( pFaninOld != pFaninNew );
- assert( pObj != pFaninOld );
- assert( pObj != pFaninNew );
- assert( pObj->pMan == pFaninOld->pMan );
- assert( pObj->pMan == pFaninNew->pMan );
- // update the fanin
- iFanin = Nwk_ObjFindFanin( pObj, pFaninOld );
- if ( iFanin == -1 )
- {
- printf( "Nwk_ObjPatchFanin(); Error! Node %d is not among", pFaninOld->Id );
- printf( " the fanins of node %d...\n", pObj->Id );
- return;
- }
- pObj->pFanio[iFanin] = pFaninNew;
- // remove pObj from the fanout list of pFaninOld
- Limit = pFaninOld->nFanins + pFaninOld->nFanouts;
- for ( k = i = pFaninOld->nFanins; i < Limit; i++ )
- if ( pFaninOld->pFanio[i] != pObj )
- pFaninOld->pFanio[k++] = pFaninOld->pFanio[i];
- pFaninOld->nFanouts--;
- // add pObj to the fanout list of pFaninNew
- if ( Nwk_ObjReallocIsNeeded(pFaninNew) )
- Nwk_ManReallocNode( pFaninNew );
- pFaninNew->pFanio[pFaninNew->nFanins + pFaninNew->nFanouts++] = pObj;
-}
-
-
-/**Function*************************************************************
-
- Synopsis [Transfers fanout from the old node to the new node.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Nwk_ObjTransferFanout( Nwk_Obj_t * pNodeFrom, Nwk_Obj_t * pNodeTo )
-{
- Vec_Ptr_t * vFanouts = pNodeFrom->pMan->vTemp;
- Nwk_Obj_t * pTemp;
- int nFanoutsOld, i;
- assert( !Nwk_ObjIsCo(pNodeFrom) && !Nwk_ObjIsCo(pNodeTo) );
- assert( pNodeFrom->pMan == pNodeTo->pMan );
- assert( pNodeFrom != pNodeTo );
- assert( Nwk_ObjFanoutNum(pNodeFrom) > 0 );
- // get the fanouts of the old node
- nFanoutsOld = Nwk_ObjFanoutNum(pNodeTo);
- Nwk_ObjCollectFanouts( pNodeFrom, vFanouts );
- // patch the fanin of each of them
- Vec_PtrForEachEntry( vFanouts, pTemp, i )
- Nwk_ObjPatchFanin( pTemp, pNodeFrom, pNodeTo );
- assert( Nwk_ObjFanoutNum(pNodeFrom) == 0 );
- assert( Nwk_ObjFanoutNum(pNodeTo) == nFanoutsOld + Vec_PtrSize(vFanouts) );
-}
-
-/**Function*************************************************************
-
- Synopsis [Replaces the node by a new node.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Nwk_ObjReplace( Nwk_Obj_t * pNodeOld, Nwk_Obj_t * pNodeNew )
-{
- assert( pNodeOld->pMan == pNodeNew->pMan );
- assert( pNodeOld != pNodeNew );
- assert( Nwk_ObjFanoutNum(pNodeOld) > 0 );
- // transfer the fanouts to the old node
- Nwk_ObjTransferFanout( pNodeOld, pNodeNew );
- // remove the old node
- Nwk_ManDeleteNode_rec( pNodeOld );
-}
-
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
-
diff --git a/src/aig/nwk2/nwkMan.c b/src/aig/nwk2/nwkMan.c
deleted file mode 100644
index cd73f866..00000000
--- a/src/aig/nwk2/nwkMan.c
+++ /dev/null
@@ -1,239 +0,0 @@
-/**CFile****************************************************************
-
- FileName [nwkMan.c]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Logic network representation.]
-
- Synopsis [Network manager.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - June 20, 2005.]
-
- Revision [$Id: nwkMan.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#include "nwk.h"
-
-////////////////////////////////////////////////////////////////////////
-/// DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
- Synopsis [Allocates the manager.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Nwk_Man_t * Nwk_ManAlloc()
-{
- Nwk_Man_t * p;
- p = ALLOC( Nwk_Man_t, 1 );
- memset( p, 0, sizeof(Nwk_Man_t) );
- p->vCis = Vec_PtrAlloc( 1000 );
- p->vCos = Vec_PtrAlloc( 1000 );
- p->vObjs = Vec_PtrAlloc( 1000 );
- p->vTemp = Vec_PtrAlloc( 1000 );
- p->nFanioPlus = 2;
- p->pMemObjs = Aig_MmFlexStart();
- p->pManHop = Hop_ManStart();
- return p;
-}
-
-/**Function*************************************************************
-
- Synopsis [Deallocates the manager.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Nwk_ManFree( Nwk_Man_t * p )
-{
-// printf( "The number of realloced nodes = %d.\n", p->nRealloced );
- if ( p->pName ) free( p->pName );
- if ( p->pSpec ) free( p->pSpec );
- if ( p->vCis ) Vec_PtrFree( p->vCis );
- if ( p->vCos ) Vec_PtrFree( p->vCos );
- if ( p->vObjs ) Vec_PtrFree( p->vObjs );
- if ( p->vTemp ) Vec_PtrFree( p->vTemp );
- if ( p->pManTime ) Tim_ManStop( p->pManTime );
- if ( p->pMemObjs ) Aig_MmFlexStop( p->pMemObjs, 0 );
- if ( p->pManHop ) Hop_ManStop( p->pManHop );
- free( p );
-}
-
-/**Function*************************************************************
-
- Synopsis [Prints stats of the manager.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-/*
-void Nwk_ManPrintLutSizes( Nwk_Man_t * p, If_Lib_t * pLutLib )
-{
- Nwk_Obj_t * pObj;
- int i, Counters[256] = {0};
- Nwk_ManForEachNode( p, pObj, i )
- Counters[Nwk_ObjFaninNum(pObj)]++;
- printf( "LUTs by size: " );
- for ( i = 0; i <= pLutLib->LutMax; i++ )
- printf( "%d:%d ", i, Counters[i] );
-}
-*/
-
-/**Function*************************************************************
-
- Synopsis [If the network is best, saves it in "best.blif" and returns 1.]
-
- Description [If the networks are incomparable, saves the new network,
- returns its parameters in the internal parameter structure, and returns 1.
- If the new network is not a logic network, quits without saving and returns 0.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Nwk_ManCompareAndSaveBest( Nwk_Man_t * pNtk, void * pNtl )
-{
- extern void Ioa_WriteBlifLogic( Nwk_Man_t * pNtk, void * pNtl, char * pFileName );
- extern void Nwk_ManDumpBlif( Nwk_Man_t * pNtk, char * pFileName, Vec_Ptr_t * vPiNames, Vec_Ptr_t * vPoNames );
- static struct ParStruct {
- char * pName; // name of the best saved network
- int Depth; // depth of the best saved network
- int Flops; // flops in the best saved network
- int Nodes; // nodes in the best saved network
- int nPis; // the number of primary inputs
- int nPos; // the number of primary outputs
- } ParsNew, ParsBest = { 0 };
- // free storage for the name
- if ( pNtk == NULL )
- {
- FREE( ParsBest.pName );
- return 0;
- }
- // get the parameters
- ParsNew.Depth = Nwk_ManLevel( pNtk );
- ParsNew.Flops = Nwk_ManLatchNum( pNtk );
- ParsNew.Nodes = Nwk_ManNodeNum( pNtk );
- ParsNew.nPis = Nwk_ManPiNum( pNtk );
- ParsNew.nPos = Nwk_ManPoNum( pNtk );
- // reset the parameters if the network has the same name
- if ( ParsBest.pName == NULL ||
- strcmp(ParsBest.pName, pNtk->pName) ||
- ParsBest.Depth > ParsNew.Depth ||
- (ParsBest.Depth == ParsNew.Depth && ParsBest.Flops > ParsNew.Flops) ||
- (ParsBest.Depth == ParsNew.Depth && ParsBest.Flops == ParsNew.Flops && ParsBest.Nodes > ParsNew.Nodes) )
- {
- FREE( ParsBest.pName );
- ParsBest.pName = Aig_UtilStrsav( pNtk->pName );
- ParsBest.Depth = ParsNew.Depth;
- ParsBest.Flops = ParsNew.Flops;
- ParsBest.Nodes = ParsNew.Nodes;
- ParsBest.nPis = ParsNew.nPis;
- ParsBest.nPos = ParsNew.nPos;
- // write the network
-// Ioa_WriteBlifLogic( pNtk, pNtl, "best.blif" );
-// Nwk_ManDumpBlif( pNtk, "best_map.blif", NULL, NULL );
- return 1;
- }
- return 0;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-char * Nwk_FileNameGeneric( char * FileName )
-{
- char * pDot, * pRes;
- pRes = Aig_UtilStrsav( FileName );
- if ( (pDot = strrchr( pRes, '.' )) )
- *pDot = 0;
- return pRes;
-}
-
-/**Function*************************************************************
-
- Synopsis [Prints stats of the manager.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-/*
-void Nwk_ManPrintStats( Nwk_Man_t * pNtk, If_Lib_t * pLutLib, int fSaveBest, int fDumpResult, int fPower, void * pNtl )
-{
- extern int Ntl_ManLatchNum( void * p );
- extern void Ioa_WriteBlifLogic( Nwk_Man_t * pNtk, void * pNtl, char * pFileName );
- if ( fSaveBest )
- Nwk_ManCompareAndSaveBest( pNtk, pNtl );
- if ( fDumpResult )
- {
- char Buffer[1000] = {0};
- char * pNameGen = pNtk->pSpec? Nwk_FileNameGeneric( pNtk->pSpec ) : "nameless_";
- sprintf( Buffer, "%s_dump.blif", pNameGen );
- Ioa_WriteBlifLogic( pNtk, pNtl, Buffer );
-// sprintf( Buffer, "%s_dump_map.blif", pNameGen );
-// Nwk_ManDumpBlif( pNtk, Buffer, NULL, NULL );
- if ( pNtk->pSpec ) free( pNameGen );
- }
-
- pNtk->pLutLib = pLutLib;
- printf( "%-15s : ", pNtk->pName );
- printf( "pi = %5d ", Nwk_ManPiNum(pNtk) );
- printf( "po = %5d ", Nwk_ManPoNum(pNtk) );
- printf( "ci = %5d ", Nwk_ManCiNum(pNtk) );
- printf( "co = %5d ", Nwk_ManCoNum(pNtk) );
- printf( "lat = %5d ", Ntl_ManLatchNum(pNtl) );
- printf( "node = %5d ", Nwk_ManNodeNum(pNtk) );
- printf( "edge = %5d ", Nwk_ManGetTotalFanins(pNtk) );
- printf( "aig = %6d ", Nwk_ManGetAigNodeNum(pNtk) );
- printf( "lev = %3d ", Nwk_ManLevel(pNtk) );
-// printf( "lev2 = %3d ", Nwk_ManLevelBackup(pNtk) );
- printf( "delay = %5.2f ", Nwk_ManDelayTraceLut(pNtk) );
- Nwk_ManPrintLutSizes( pNtk, pLutLib );
- printf( "\n" );
-// Nwk_ManDelayTracePrint( pNtk, pLutLib );
- fflush( stdout );
-}
-*/
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
-
diff --git a/src/aig/nwk2/nwkMerge.c b/src/aig/nwk2/nwkMerge.c
deleted file mode 100644
index 1a5255d3..00000000
--- a/src/aig/nwk2/nwkMerge.c
+++ /dev/null
@@ -1,993 +0,0 @@
-/**CFile****************************************************************
-
- FileName [nwkMerge.c]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Netlist representation.]
-
- Synopsis [LUT merging algorithm.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - June 20, 2005.]
-
- Revision [$Id: nwkMerge.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#include "nwk.h"
-#include "nwkMerge.h"
-
-////////////////////////////////////////////////////////////////////////
-/// DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
- Synopsis [Allocates the graph.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Nwk_Grf_t * Nwk_ManGraphAlloc( int nVertsMax )
-{
- Nwk_Grf_t * p;
- p = ALLOC( Nwk_Grf_t, 1 );
- memset( p, 0, sizeof(Nwk_Grf_t) );
- p->nVertsMax = nVertsMax;
- p->nEdgeHash = Aig_PrimeCudd( 3 * nVertsMax );
- p->pEdgeHash = CALLOC( Nwk_Edg_t *, p->nEdgeHash );
- p->pMemEdges = Aig_MmFixedStart( sizeof(Nwk_Edg_t), p->nEdgeHash );
- p->vPairs = Vec_IntAlloc( 1000 );
- return p;
-}
-
-/**Function*************************************************************
-
- Synopsis [Deallocates the graph.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Nwk_ManGraphFree( Nwk_Grf_t * p )
-{
- if ( p->vPairs ) Vec_IntFree( p->vPairs );
- if ( p->pMemEdges ) Aig_MmFixedStop( p->pMemEdges, 0 );
- if ( p->pMemVerts ) Aig_MmFlexStop( p->pMemVerts, 0 );
- FREE( p->pVerts );
- FREE( p->pEdgeHash );
- FREE( p->pMapLut2Id );
- FREE( p->pMapId2Lut );
- free( p );
-}
-
-/**Function*************************************************************
-
- Synopsis [Prepares the graph for solving the problem.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Nwk_ManGraphReportMemoryUsage( Nwk_Grf_t * p )
-{
- p->nMemBytes1 =
- sizeof(Nwk_Grf_t) +
- sizeof(void *) * p->nEdgeHash +
- sizeof(int) * (p->nObjs + p->nVertsMax) +
- sizeof(Nwk_Edg_t) * p->nEdges;
- p->nMemBytes2 =
- sizeof(Nwk_Vrt_t) * p->nVerts +
- sizeof(int) * 2 * p->nEdges;
- printf( "Memory usage stats: Preprocessing = %.2f Mb. Solving = %.2f Mb.\n",
- 1.0 * p->nMemBytes1 / (1<<20), 1.0 * p->nMemBytes2 / (1<<20) );
-}
-
-
-/**Function*************************************************************
-
- Synopsis [Finds or adds the edge to the graph.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Nwk_ManGraphHashEdge( Nwk_Grf_t * p, int iLut1, int iLut2 )
-{
- Nwk_Edg_t * pEntry;
- unsigned Key;
- if ( iLut1 == iLut2 )
- return;
- if ( iLut1 > iLut2 )
- {
- Key = iLut1;
- iLut1 = iLut2;
- iLut2 = Key;
- }
- assert( iLut1 < iLut2 );
- if ( p->nObjs < iLut2 )
- p->nObjs = iLut2;
- Key = (unsigned)(741457 * iLut1 + 4256249 * iLut2) % p->nEdgeHash;
- for ( pEntry = p->pEdgeHash[Key]; pEntry; pEntry = pEntry->pNext )
- if ( pEntry->iNode1 == iLut1 && pEntry->iNode2 == iLut2 )
- return;
- pEntry = (Nwk_Edg_t *)Aig_MmFixedEntryFetch( p->pMemEdges );
- pEntry->iNode1 = iLut1;
- pEntry->iNode2 = iLut2;
- pEntry->pNext = p->pEdgeHash[Key];
- p->pEdgeHash[Key] = pEntry;
- p->nEdges++;
-}
-
-/**Function*************************************************************
-
- Synopsis [Adds one entry to the list.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Nwk_ManGraphListAdd( Nwk_Grf_t * p, int * pList, Nwk_Vrt_t * pVertex )
-{
- if ( *pList )
- {
- Nwk_Vrt_t * pHead;
- pHead = p->pVerts[*pList];
- pVertex->iPrev = 0;
- pVertex->iNext = pHead->Id;
- pHead->iPrev = pVertex->Id;
- }
- *pList = pVertex->Id;
-}
-
-/**Function*************************************************************
-
- Synopsis [Deletes one entry from the list.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Nwk_ManGraphListDelete( Nwk_Grf_t * p, int * pList, Nwk_Vrt_t * pVertex )
-{
- assert( *pList );
- if ( pVertex->iPrev )
- {
-// assert( p->pVerts[pVertex->iPrev]->iNext == pVertex->Id );
- p->pVerts[pVertex->iPrev]->iNext = pVertex->iNext;
- }
- if ( pVertex->iNext )
- {
-// assert( p->pVerts[pVertex->iNext]->iPrev == pVertex->Id );
- p->pVerts[pVertex->iNext]->iPrev = pVertex->iPrev;
- }
- if ( *pList == pVertex->Id )
- *pList = pVertex->iNext;
- pVertex->iPrev = pVertex->iNext = 0;
-}
-
-/**Function*************************************************************
-
- Synopsis [Inserts the edge into one of the linked lists.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Nwk_ManGraphListInsert( Nwk_Grf_t * p, Nwk_Vrt_t * pVertex )
-{
- Nwk_Vrt_t * pNext;
- assert( pVertex->nEdges > 0 );
-
- if ( pVertex->nEdges == 1 )
- {
- pNext = p->pVerts[ pVertex->pEdges[0] ];
- if ( pNext->nEdges >= NWK_MAX_LIST )
- Nwk_ManGraphListAdd( p, p->pLists1 + NWK_MAX_LIST, pVertex );
- else
- Nwk_ManGraphListAdd( p, p->pLists1 + pNext->nEdges, pVertex );
- }
- else
- {
- if ( pVertex->nEdges >= NWK_MAX_LIST )
- Nwk_ManGraphListAdd( p, p->pLists2 + NWK_MAX_LIST, pVertex );
- else
- Nwk_ManGraphListAdd( p, p->pLists2 + pVertex->nEdges, pVertex );
- }
-}
-
-/**Function*************************************************************
-
- Synopsis [Extracts the edge from one of the linked lists.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Nwk_ManGraphListExtract( Nwk_Grf_t * p, Nwk_Vrt_t * pVertex )
-{
- Nwk_Vrt_t * pNext;
- assert( pVertex->nEdges > 0 );
-
- if ( pVertex->nEdges == 1 )
- {
- pNext = p->pVerts[ pVertex->pEdges[0] ];
- if ( pNext->nEdges >= NWK_MAX_LIST )
- Nwk_ManGraphListDelete( p, p->pLists1 + NWK_MAX_LIST, pVertex );
- else
- Nwk_ManGraphListDelete( p, p->pLists1 + pNext->nEdges, pVertex );
- }
- else
- {
- if ( pVertex->nEdges >= NWK_MAX_LIST )
- Nwk_ManGraphListDelete( p, p->pLists2 + NWK_MAX_LIST, pVertex );
- else
- Nwk_ManGraphListDelete( p, p->pLists2 + pVertex->nEdges, pVertex );
- }
-}
-
-/**Function*************************************************************
-
- Synopsis [Prepares the graph for solving the problem.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Nwk_ManGraphPrepare( Nwk_Grf_t * p )
-{
- Nwk_Edg_t * pEntry;
- Nwk_Vrt_t * pVertex;
- int * pnEdges, nBytes, i;
- // allocate memory for the present objects
- p->pMapLut2Id = ALLOC( int, p->nObjs+1 );
- p->pMapId2Lut = ALLOC( int, p->nVertsMax+1 );
- memset( p->pMapLut2Id, 0xff, sizeof(int) * (p->nObjs+1) );
- memset( p->pMapId2Lut, 0xff, sizeof(int) * (p->nVertsMax+1) );
- // mark present objects
- Nwk_GraphForEachEdge( p, pEntry, i )
- {
- assert( pEntry->iNode1 <= p->nObjs );
- assert( pEntry->iNode2 <= p->nObjs );
- p->pMapLut2Id[ pEntry->iNode1 ] = 0;
- p->pMapLut2Id[ pEntry->iNode2 ] = 0;
- }
- // map objects
- p->nVerts = 0;
- for ( i = 0; i <= p->nObjs; i++ )
- {
- if ( p->pMapLut2Id[i] == 0 )
- {
- p->pMapLut2Id[i] = ++p->nVerts;
- p->pMapId2Lut[p->nVerts] = i;
- }
- }
- // count the edges and mark present objects
- pnEdges = CALLOC( int, p->nVerts+1 );
- Nwk_GraphForEachEdge( p, pEntry, i )
- {
- // translate into vertices
- assert( pEntry->iNode1 <= p->nObjs );
- assert( pEntry->iNode2 <= p->nObjs );
- pEntry->iNode1 = p->pMapLut2Id[pEntry->iNode1];
- pEntry->iNode2 = p->pMapLut2Id[pEntry->iNode2];
- // count the edges
- assert( pEntry->iNode1 <= p->nVerts );
- assert( pEntry->iNode2 <= p->nVerts );
- pnEdges[pEntry->iNode1]++;
- pnEdges[pEntry->iNode2]++;
- }
- // allocate the real graph
- p->pMemVerts = Aig_MmFlexStart();
- p->pVerts = ALLOC( Nwk_Vrt_t *, p->nVerts + 1 );
- p->pVerts[0] = NULL;
- for ( i = 1; i <= p->nVerts; i++ )
- {
- assert( pnEdges[i] > 0 );
- nBytes = sizeof(Nwk_Vrt_t) + sizeof(int) * pnEdges[i];
- p->pVerts[i] = (Nwk_Vrt_t *)Aig_MmFlexEntryFetch( p->pMemVerts, nBytes );
- memset( p->pVerts[i], 0, nBytes );
- p->pVerts[i]->Id = i;
- }
- // add edges to the real graph
- Nwk_GraphForEachEdge( p, pEntry, i )
- {
- pVertex = p->pVerts[pEntry->iNode1];
- pVertex->pEdges[ pVertex->nEdges++ ] = pEntry->iNode2;
- pVertex = p->pVerts[pEntry->iNode2];
- pVertex->pEdges[ pVertex->nEdges++ ] = pEntry->iNode1;
- }
- // put vertices into the data structure
- for ( i = 1; i <= p->nVerts; i++ )
- {
- assert( p->pVerts[i]->nEdges == pnEdges[i] );
- Nwk_ManGraphListInsert( p, p->pVerts[i] );
- }
- // clean up
- Aig_MmFixedStop( p->pMemEdges, 0 ); p->pMemEdges = NULL;
- FREE( p->pEdgeHash );
-// p->nEdgeHash = 0;
- free( pnEdges );
-}
-
-/**Function*************************************************************
-
- Synopsis [Updates the problem after pulling out one edge.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Nwk_ManGraphCheckLists( Nwk_Grf_t * p )
-{
- Nwk_Vrt_t * pVertex, * pNext;
- int i, j;
- assert( p->pLists1[0] == 0 );
- for ( i = 1; i <= NWK_MAX_LIST; i++ )
- if ( p->pLists1[i] )
- {
- pVertex = p->pVerts[ p->pLists1[i] ];
- assert( pVertex->nEdges == 1 );
- pNext = p->pVerts[ pVertex->pEdges[0] ];
- assert( pNext->nEdges == i || pNext->nEdges > NWK_MAX_LIST );
- }
- // find the next vertext to extract
- assert( p->pLists2[0] == 0 );
- assert( p->pLists2[1] == 0 );
- for ( j = 2; j <= NWK_MAX_LIST; j++ )
- if ( p->pLists2[j] )
- {
- pVertex = p->pVerts[ p->pLists2[j] ];
- assert( pVertex->nEdges == j || pVertex->nEdges > NWK_MAX_LIST );
- }
-}
-
-/**Function*************************************************************
-
- Synopsis [Extracts the edge from one of the linked lists.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Nwk_ManGraphVertexRemoveEdge( Nwk_Vrt_t * pThis, Nwk_Vrt_t * pNext )
-{
- int k;
- for ( k = 0; k < pThis->nEdges; k++ )
- if ( pThis->pEdges[k] == pNext->Id )
- break;
- assert( k < pThis->nEdges );
- pThis->nEdges--;
- for ( ; k < pThis->nEdges; k++ )
- pThis->pEdges[k] = pThis->pEdges[k+1];
-}
-
-/**Function*************************************************************
-
- Synopsis [Updates the problem after pulling out one edge.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Nwk_ManGraphUpdate( Nwk_Grf_t * p, Nwk_Vrt_t * pVertex, Nwk_Vrt_t * pNext )
-{
- Nwk_Vrt_t * pChanged, * pOther;
- int i, k;
-// Nwk_ManGraphCheckLists( p );
- Nwk_ManGraphListExtract( p, pVertex );
- Nwk_ManGraphListExtract( p, pNext );
- // update neihbors of pVertex
- Nwk_VertexForEachAdjacent( p, pVertex, pChanged, i )
- {
- if ( pChanged == pNext )
- continue;
- Nwk_ManGraphListExtract( p, pChanged );
- // move those that use this one
- if ( pChanged->nEdges > 1 )
- Nwk_VertexForEachAdjacent( p, pChanged, pOther, k )
- {
- if ( pOther == pVertex || pOther->nEdges > 1 )
- continue;
- assert( pOther->nEdges == 1 );
- Nwk_ManGraphListExtract( p, pOther );
- pChanged->nEdges--;
- Nwk_ManGraphListInsert( p, pOther );
- pChanged->nEdges++;
- }
- // remove the edge
- Nwk_ManGraphVertexRemoveEdge( pChanged, pVertex );
- // add the changed vertex back
- if ( pChanged->nEdges > 0 )
- Nwk_ManGraphListInsert( p, pChanged );
- }
- // update neihbors of pNext
- Nwk_VertexForEachAdjacent( p, pNext, pChanged, i )
- {
- if ( pChanged == pVertex )
- continue;
- Nwk_ManGraphListExtract( p, pChanged );
- // move those that use this one
- if ( pChanged->nEdges > 1 )
- Nwk_VertexForEachAdjacent( p, pChanged, pOther, k )
- {
- if ( pOther == pNext || pOther->nEdges > 1 )
- continue;
- assert( pOther->nEdges == 1 );
- Nwk_ManGraphListExtract( p, pOther );
- pChanged->nEdges--;
- Nwk_ManGraphListInsert( p, pOther );
- pChanged->nEdges++;
- }
- // remove the edge
- Nwk_ManGraphVertexRemoveEdge( pChanged, pNext );
- // add the changed vertex back
- if ( pChanged->nEdges > 0 )
- Nwk_ManGraphListInsert( p, pChanged );
- }
- // add to the result
- if ( pVertex->Id < pNext->Id )
- {
- Vec_IntPush( p->vPairs, p->pMapId2Lut[pVertex->Id] );
- Vec_IntPush( p->vPairs, p->pMapId2Lut[pNext->Id] );
- }
- else
- {
- Vec_IntPush( p->vPairs, p->pMapId2Lut[pNext->Id] );
- Vec_IntPush( p->vPairs, p->pMapId2Lut[pVertex->Id] );
- }
-// Nwk_ManGraphCheckLists( p );
-}
-
-/**Function*************************************************************
-
- Synopsis [Counts the number of entries in the list.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Nwk_ManGraphListLength( Nwk_Grf_t * p, int List )
-{
- Nwk_Vrt_t * pThis;
- int fVerbose = 0;
- int Counter = 0;
- Nwk_ListForEachVertex( p, List, pThis )
- {
- if ( fVerbose && Counter < 20 )
- printf( "%d ", p->pVerts[pThis->pEdges[0]]->nEdges );
- Counter++;
- }
- if ( fVerbose )
- printf( "\n" );
- return Counter;
-}
-
-/**Function*************************************************************
-
- Synopsis [Returns the adjacent vertex with the mininum number of edges.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Nwk_Vrt_t * Nwk_ManGraphListFindMinEdge( Nwk_Grf_t * p, Nwk_Vrt_t * pVert )
-{
- Nwk_Vrt_t * pThis, * pMinCost = NULL;
- int k;
- Nwk_VertexForEachAdjacent( p, pVert, pThis, k )
- {
- if ( pMinCost == NULL || pMinCost->nEdges > pThis->nEdges )
- pMinCost = pThis;
- }
- return pMinCost;
-}
-
-/**Function*************************************************************
-
- Synopsis [Finds the best vertext in the list.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Nwk_Vrt_t * Nwk_ManGraphListFindMin( Nwk_Grf_t * p, int List )
-{
- Nwk_Vrt_t * pThis, * pMinCost = NULL;
- int k, Counter = 10000, BestCost = 1000000;
- Nwk_ListForEachVertex( p, List, pThis )
- {
- for ( k = 0; k < pThis->nEdges; k++ )
- {
- if ( pMinCost == NULL || BestCost > p->pVerts[pThis->pEdges[k]]->nEdges )
- {
- BestCost = p->pVerts[pThis->pEdges[k]]->nEdges;
- pMinCost = pThis;
- }
- }
- if ( --Counter == 0 )
- break;
- }
- return pMinCost;
-}
-
-/**Function*************************************************************
-
- Synopsis [Solves the problem by extracting one edge at a time.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Nwk_ManGraphSolve( Nwk_Grf_t * p )
-{
- Nwk_Vrt_t * pVertex, * pNext;
- int i, j;
- Nwk_ManGraphPrepare( p );
- while ( 1 )
- {
- // find the next vertex to extract
- assert( p->pLists1[0] == 0 );
- for ( i = 1; i <= NWK_MAX_LIST; i++ )
- if ( p->pLists1[i] )
- {
-// printf( "%d ", i );
-// printf( "ListA = %2d. Length = %5d.\n", i, Nwk_ManGraphListLength(p,p->pLists1[i]) );
- pVertex = p->pVerts[ p->pLists1[i] ];
- assert( pVertex->nEdges == 1 );
- pNext = p->pVerts[ pVertex->pEdges[0] ];
- Nwk_ManGraphUpdate( p, pVertex, pNext );
- break;
- }
- if ( i < NWK_MAX_LIST + 1 )
- continue;
- // find the next vertex to extract
- assert( p->pLists2[0] == 0 );
- assert( p->pLists2[1] == 0 );
- for ( j = 2; j <= NWK_MAX_LIST; j++ )
- if ( p->pLists2[j] )
- {
-// printf( "***%d ", j );
-// printf( "ListB = %2d. Length = %5d.\n", j, Nwk_ManGraphListLength(p,p->pLists2[j]) );
- pVertex = Nwk_ManGraphListFindMin( p, p->pLists2[j] );
- assert( pVertex->nEdges == j || j == NWK_MAX_LIST );
- pNext = Nwk_ManGraphListFindMinEdge( p, pVertex );
- Nwk_ManGraphUpdate( p, pVertex, pNext );
- break;
- }
- if ( j == NWK_MAX_LIST + 1 )
- break;
- }
-}
-
-/**Function*************************************************************
-
- Synopsis [Reads graph from file.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Nwk_Grf_t * Nwk_ManLutMergeReadGraph( char * pFileName )
-{
- Nwk_Grf_t * p;
- FILE * pFile;
- char Buffer[100];
- int nNodes, nEdges, iNode1, iNode2;
- pFile = fopen( pFileName, "r" );
- fscanf( pFile, "%s %d", Buffer, &nNodes );
- fscanf( pFile, "%s %d", Buffer, &nEdges );
- p = Nwk_ManGraphAlloc( nNodes );
- while ( fscanf( pFile, "%s %d %d", Buffer, &iNode1, &iNode2 ) == 3 )
- Nwk_ManGraphHashEdge( p, iNode1, iNode2 );
- assert( p->nEdges == nEdges );
- fclose( pFile );
- return p;
-}
-
-/**Function*************************************************************
-
- Synopsis [Solves the graph coming from file.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Nwk_ManLutMergeGraphTest( char * pFileName )
-{
- int nPairs;
- Nwk_Grf_t * p;
- int clk = clock();
- p = Nwk_ManLutMergeReadGraph( pFileName );
- PRT( "Reading", clock() - clk );
- clk = clock();
- Nwk_ManGraphSolve( p );
- printf( "GRAPH: Nodes = %6d. Edges = %6d. Pairs = %6d. ",
- p->nVerts, p->nEdges, Vec_IntSize(p->vPairs)/2 );
- PRT( "Solving", clock() - clk );
- nPairs = Vec_IntSize(p->vPairs)/2;
- Nwk_ManGraphReportMemoryUsage( p );
- Nwk_ManGraphFree( p );
- return nPairs;
-}
-
-
-
-
-/**Function*************************************************************
-
- Synopsis [Marks the fanins of the node with the current trav ID.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Nwk_ManMarkFanins_rec( Nwk_Obj_t * pLut, int nLevMin )
-{
- Nwk_Obj_t * pNext;
- int i;
- if ( !Nwk_ObjIsNode(pLut) )
- return;
- if ( Nwk_ObjIsTravIdCurrent( pLut ) )
- return;
- Nwk_ObjSetTravIdCurrent( pLut );
- if ( Nwk_ObjLevel(pLut) < nLevMin )
- return;
- Nwk_ObjForEachFanin( pLut, pNext, i )
- Nwk_ManMarkFanins_rec( pNext, nLevMin );
-}
-
-/**Function*************************************************************
-
- Synopsis [Marks the fanouts of the node with the current trav ID.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Nwk_ManMarkFanouts_rec( Nwk_Obj_t * pLut, int nLevMax, int nFanMax )
-{
- Nwk_Obj_t * pNext;
- int i;
- if ( !Nwk_ObjIsNode(pLut) )
- return;
- if ( Nwk_ObjIsTravIdCurrent( pLut ) )
- return;
- Nwk_ObjSetTravIdCurrent( pLut );
- if ( Nwk_ObjLevel(pLut) > nLevMax )
- return;
- if ( Nwk_ObjFanoutNum(pLut) > nFanMax )
- return;
- Nwk_ObjForEachFanout( pLut, pNext, i )
- Nwk_ManMarkFanouts_rec( pNext, nLevMax, nFanMax );
-}
-
-/**Function*************************************************************
-
- Synopsis [Collects the circle of nodes around the given set.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Nwk_ManCollectCircle( Vec_Ptr_t * vStart, Vec_Ptr_t * vNext, int nFanMax )
-{
- Nwk_Obj_t * pObj, * pNext;
- int i, k;
- Vec_PtrClear( vNext );
- Vec_PtrForEachEntry( vStart, pObj, i )
- {
- Nwk_ObjForEachFanin( pObj, pNext, k )
- {
- if ( !Nwk_ObjIsNode(pNext) )
- continue;
- if ( Nwk_ObjIsTravIdCurrent( pNext ) )
- continue;
- Nwk_ObjSetTravIdCurrent( pNext );
- Vec_PtrPush( vNext, pNext );
- }
- Nwk_ObjForEachFanout( pObj, pNext, k )
- {
- if ( !Nwk_ObjIsNode(pNext) )
- continue;
- if ( Nwk_ObjIsTravIdCurrent( pNext ) )
- continue;
- Nwk_ObjSetTravIdCurrent( pNext );
- if ( Nwk_ObjFanoutNum(pNext) > nFanMax )
- continue;
- Vec_PtrPush( vNext, pNext );
- }
- }
-}
-
-/**Function*************************************************************
-
- Synopsis [Collects the circle of nodes removes from the given one.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Nwk_ManCollectNonOverlapCands( Nwk_Obj_t * pLut, Vec_Ptr_t * vStart, Vec_Ptr_t * vNext, Vec_Ptr_t * vCands, Nwk_LMPars_t * pPars )
-{
- Vec_Ptr_t * vTemp;
- Nwk_Obj_t * pObj;
- int i, k;
- Vec_PtrClear( vCands );
- if ( pPars->nMaxSuppSize - Nwk_ObjFaninNum(pLut) <= 1 )
- return;
-
- // collect nodes removed by this distance
- assert( pPars->nMaxDistance > 0 );
- Vec_PtrClear( vStart );
- Vec_PtrPush( vStart, pLut );
- Nwk_ManIncrementTravId( pLut->pMan );
- Nwk_ObjSetTravIdCurrent( pLut );
- for ( i = 1; i <= pPars->nMaxDistance; i++ )
- {
- Nwk_ManCollectCircle( vStart, vNext, pPars->nMaxFanout );
- vTemp = vStart;
- vStart = vNext;
- vNext = vTemp;
- // collect the nodes in vStart
- Vec_PtrForEachEntry( vStart, pObj, k )
- Vec_PtrPush( vCands, pObj );
- }
-
- // mark the TFI/TFO nodes
- Nwk_ManIncrementTravId( pLut->pMan );
- if ( pPars->fUseTfiTfo )
- Nwk_ObjSetTravIdCurrent( pLut );
- else
- {
- Nwk_ObjSetTravIdPrevious( pLut );
- Nwk_ManMarkFanins_rec( pLut, Nwk_ObjLevel(pLut) - pPars->nMaxDistance );
- Nwk_ObjSetTravIdPrevious( pLut );
- Nwk_ManMarkFanouts_rec( pLut, Nwk_ObjLevel(pLut) + pPars->nMaxDistance, pPars->nMaxFanout );
- }
-
- // collect nodes satisfying the following conditions:
- // - they are close enough in terms of distance
- // - they are not in the TFI/TFO of the LUT
- // - they have no more than the given number of fanins
- // - they have no more than the given diff in delay
- k = 0;
- Vec_PtrForEachEntry( vCands, pObj, i )
- {
- if ( Nwk_ObjIsTravIdCurrent(pObj) )
- continue;
- if ( Nwk_ObjFaninNum(pLut) + Nwk_ObjFaninNum(pObj) > pPars->nMaxSuppSize )
- continue;
- if ( Nwk_ObjLevel(pLut) - Nwk_ObjLevel(pObj) > pPars->nMaxLevelDiff ||
- Nwk_ObjLevel(pObj) - Nwk_ObjLevel(pLut) > pPars->nMaxLevelDiff )
- continue;
- Vec_PtrWriteEntry( vCands, k++, pObj );
- }
- Vec_PtrShrink( vCands, k );
-}
-
-
-/**Function*************************************************************
-
- Synopsis [Count the total number of fanins.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Nwk_ManCountTotalFanins( Nwk_Obj_t * pLut, Nwk_Obj_t * pCand )
-{
- Nwk_Obj_t * pFanin;
- int i, nCounter = Nwk_ObjFaninNum(pLut);
- Nwk_ObjForEachFanin( pCand, pFanin, i )
- nCounter += !pFanin->MarkC;
- return nCounter;
-}
-
-/**Function*************************************************************
-
- Synopsis [Collects overlapping candidates.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Nwl_ManCollectOverlapCands( Nwk_Obj_t * pLut, Vec_Ptr_t * vCands, Nwk_LMPars_t * pPars )
-{
- Nwk_Obj_t * pFanin, * pObj;
- int i, k;
- // mark fanins of pLut
- Nwk_ObjForEachFanin( pLut, pFanin, i )
- pFanin->MarkC = 1;
- // collect the matching fanouts of each fanin of the node
- Vec_PtrClear( vCands );
- Nwk_ManIncrementTravId( pLut->pMan );
- Nwk_ObjSetTravIdCurrent( pLut );
- Nwk_ObjForEachFanin( pLut, pFanin, i )
- {
- if ( !Nwk_ObjIsNode(pFanin) )
- continue;
- if ( Nwk_ObjFanoutNum(pFanin) > pPars->nMaxFanout )
- continue;
- Nwk_ObjForEachFanout( pFanin, pObj, k )
- {
- if ( !Nwk_ObjIsNode(pObj) )
- continue;
- if ( Nwk_ObjIsTravIdCurrent( pObj ) )
- continue;
- Nwk_ObjSetTravIdCurrent( pObj );
- // check the difference in delay
- if ( Nwk_ObjLevel(pLut) - Nwk_ObjLevel(pObj) > pPars->nMaxLevelDiff ||
- Nwk_ObjLevel(pObj) - Nwk_ObjLevel(pLut) > pPars->nMaxLevelDiff )
- continue;
- // check the total number of fanins of the node
- if ( Nwk_ManCountTotalFanins(pLut, pObj) > pPars->nMaxSuppSize )
- continue;
- Vec_PtrPush( vCands, pObj );
- }
- }
- // unmark fanins of pLut
- Nwk_ObjForEachFanin( pLut, pFanin, i )
- pFanin->MarkC = 0;
-}
-
-/**Function*************************************************************
-
- Synopsis [Performs LUT merging with parameters.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Vec_Int_t * Nwk_ManLutMerge( Nwk_Man_t * pNtk, Nwk_LMPars_t * pPars )
-{
- Nwk_Grf_t * p;
- Vec_Int_t * vResult;
- Vec_Ptr_t * vStart, * vNext, * vCands1, * vCands2;
- Nwk_Obj_t * pLut, * pCand;
- int i, k, nVertsMax, nCands, clk = clock();
- // count the number of vertices
- nVertsMax = 0;
- Nwk_ManForEachNode( pNtk, pLut, i )
- nVertsMax += (int)(Nwk_ObjFaninNum(pLut) <= pPars->nMaxLutSize);
- p = Nwk_ManGraphAlloc( nVertsMax );
- // create graph
- vStart = Vec_PtrAlloc( 1000 );
- vNext = Vec_PtrAlloc( 1000 );
- vCands1 = Vec_PtrAlloc( 1000 );
- vCands2 = Vec_PtrAlloc( 1000 );
- nCands = 0;
- Nwk_ManForEachNode( pNtk, pLut, i )
- {
- if ( Nwk_ObjFaninNum(pLut) > pPars->nMaxLutSize )
- continue;
- Nwl_ManCollectOverlapCands( pLut, vCands1, pPars );
- if ( pPars->fUseDiffSupp )
- Nwk_ManCollectNonOverlapCands( pLut, vStart, vNext, vCands2, pPars );
- if ( Vec_PtrSize(vCands1) == 0 && Vec_PtrSize(vCands2) == 0 )
- continue;
- nCands += Vec_PtrSize(vCands1) + Vec_PtrSize(vCands2);
- // save candidates
- Vec_PtrForEachEntry( vCands1, pCand, k )
- Nwk_ManGraphHashEdge( p, Nwk_ObjId(pLut), Nwk_ObjId(pCand) );
- Vec_PtrForEachEntry( vCands2, pCand, k )
- Nwk_ManGraphHashEdge( p, Nwk_ObjId(pLut), Nwk_ObjId(pCand) );
- // print statistics about this node
- if ( pPars->fVeryVerbose )
- printf( "Node %6d : Fanins = %d. Fanouts = %3d. Cand1 = %3d. Cand2 = %3d.\n",
- Nwk_ObjId(pLut), Nwk_ObjFaninNum(pLut), Nwk_ObjFaninNum(pLut),
- Vec_PtrSize(vCands1), Vec_PtrSize(vCands2) );
- }
- Vec_PtrFree( vStart );
- Vec_PtrFree( vNext );
- Vec_PtrFree( vCands1 );
- Vec_PtrFree( vCands2 );
- if ( pPars->fVerbose )
- {
- printf( "Mergable LUTs = %6d. Total cands = %6d. ", p->nVertsMax, nCands );
- PRT( "Deriving graph", clock() - clk );
- }
- // solve the graph problem
- clk = clock();
- Nwk_ManGraphSolve( p );
- if ( pPars->fVerbose )
- {
- printf( "GRAPH: Nodes = %6d. Edges = %6d. Pairs = %6d. ",
- p->nVerts, p->nEdges, Vec_IntSize(p->vPairs)/2 );
- PRT( "Solving", clock() - clk );
- Nwk_ManGraphReportMemoryUsage( p );
- }
- vResult = p->vPairs; p->vPairs = NULL;
- Nwk_ManGraphFree( p );
- return vResult;
-}
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
-
diff --git a/src/aig/nwk2/nwkMerge.h b/src/aig/nwk2/nwkMerge.h
deleted file mode 100644
index f5697f6e..00000000
--- a/src/aig/nwk2/nwkMerge.h
+++ /dev/null
@@ -1,149 +0,0 @@
-/**CFile****************************************************************
-
- FileName [nwkMerge.h]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Logic network representation.]
-
- Synopsis [External declarations.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - June 20, 2005.]
-
- Revision [$Id: nwkMerge.h,v 1.1 2008/05/14 22:13:09 wudenni Exp $]
-
-***********************************************************************/
-
-#ifndef __NWK_MERGE_H__
-#define __NWK_MERGE_H__
-
-////////////////////////////////////////////////////////////////////////
-/// INCLUDES ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-/// PARAMETERS ///
-////////////////////////////////////////////////////////////////////////
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define NWK_MAX_LIST 16
-
-////////////////////////////////////////////////////////////////////////
-/// BASIC TYPES ///
-////////////////////////////////////////////////////////////////////////
-
-// the LUT merging parameters
-typedef struct Nwk_LMPars_t_ Nwk_LMPars_t;
-struct Nwk_LMPars_t_
-{
- int nMaxLutSize; // the max LUT size for merging (N=5)
- int nMaxSuppSize; // the max total support size after merging (S=5)
- int nMaxDistance; // the max number of nodes separating LUTs
- int nMaxLevelDiff; // the max difference in levels
- int nMaxFanout; // the max number of fanouts to traverse
- int fUseDiffSupp; // enables the use of nodes with different support
- int fUseTfiTfo; // enables the use of TFO/TFO nodes as candidates
- int fVeryVerbose; // enables additional verbose output
- int fVerbose; // enables verbose output
-};
-
-// edge of the graph
-typedef struct Nwk_Edg_t_ Nwk_Edg_t;
-struct Nwk_Edg_t_
-{
- int iNode1; // the first node
- int iNode2; // the second node
- Nwk_Edg_t * pNext; // the next edge
-};
-
-// vertex of the graph
-typedef struct Nwk_Vrt_t_ Nwk_Vrt_t;
-struct Nwk_Vrt_t_
-{
- int Id; // the vertex number
- int iPrev; // the previous vertex in the list
- int iNext; // the next vertex in the list
- int nEdges; // the number of edges
- int pEdges[0]; // the array of edges
-};
-
-// the connectivity graph
-typedef struct Nwk_Grf_t_ Nwk_Grf_t;
-struct Nwk_Grf_t_
-{
- // preliminary graph representation
- int nObjs; // the number of objects
- int nVertsMax; // the upper bound on the number of vertices
- int nEdgeHash; // an approximate number of edges
- Nwk_Edg_t ** pEdgeHash; // hash table for edges
- Aig_MmFixed_t * pMemEdges; // memory for edges
- // graph representation
- int nEdges; // the number of edges
- int nVerts; // the number of vertices
- Nwk_Vrt_t ** pVerts; // the array of vertices
- Aig_MmFlex_t * pMemVerts; // memory for vertices
- // intermediate data
- int pLists1[NWK_MAX_LIST+1]; // lists of nodes with one edge
- int pLists2[NWK_MAX_LIST+1]; // lists of nodes with more than one edge
- // the results of matching
- Vec_Int_t * vPairs; // pairs matched in the graph
- // object mappings
- int * pMapLut2Id; // LUT numbers into vertex IDs
- int * pMapId2Lut; // vertex IDs into LUT numbers
- // other things
- int nMemBytes1; // memory usage in bytes
- int nMemBytes2; // memory usage in bytes
-};
-
-////////////////////////////////////////////////////////////////////////
-/// MACRO DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-#define Nwk_GraphForEachEdge( p, pEdge, k ) \
- for ( k = 0; k < p->nEdgeHash; k++ ) \
- for ( pEdge = p->pEdgeHash[k]; pEdge; pEdge = pEdge->pNext )
-
-#define Nwk_ListForEachVertex( p, List, pVrt ) \
- for ( pVrt = List? p->pVerts[List] : NULL; pVrt; \
- pVrt = pVrt->iNext? p->pVerts[pVrt->iNext] : NULL )
-
-#define Nwk_VertexForEachAdjacent( p, pVrt, pNext, k ) \
- for ( k = 0; (k < pVrt->nEdges) && (((pNext) = p->pVerts[pVrt->pEdges[k]]), 1); k++ )
-
-////////////////////////////////////////////////////////////////////////
-/// INLINED FUNCTIONS ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-/// ITERATORS ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/*=== nwkMerge.c ==========================================================*/
-extern Nwk_Grf_t * Nwk_ManGraphAlloc( int nVertsMax );
-extern void Nwk_ManGraphFree( Nwk_Grf_t * p );
-extern void Nwk_ManGraphReportMemoryUsage( Nwk_Grf_t * p );
-extern void Nwk_ManGraphHashEdge( Nwk_Grf_t * p, int iLut1, int iLut2 );
-extern void Nwk_ManGraphSolve( Nwk_Grf_t * p );
-extern int Nwk_ManLutMergeGraphTest( char * pFileName );
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
diff --git a/src/aig/nwk2/nwkObj.c b/src/aig/nwk2/nwkObj.c
deleted file mode 100644
index 58587f07..00000000
--- a/src/aig/nwk2/nwkObj.c
+++ /dev/null
@@ -1,199 +0,0 @@
-/**CFile****************************************************************
-
- FileName [nwkObj.c]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Logic network representation.]
-
- Synopsis [Manipulation of objects.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - June 20, 2005.]
-
- Revision [$Id: nwkObj.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#include "nwk.h"
-
-////////////////////////////////////////////////////////////////////////
-/// DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
- Synopsis [Creates an object.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Nwk_Obj_t * Nwk_ManCreateObj( Nwk_Man_t * p, int nFanins, int nFanouts )
-{
- Nwk_Obj_t * pObj;
- pObj = (Nwk_Obj_t *)Aig_MmFlexEntryFetch( p->pMemObjs, sizeof(Nwk_Obj_t) + (nFanins + nFanouts + p->nFanioPlus) * sizeof(Nwk_Obj_t *) );
- memset( pObj, 0, sizeof(Nwk_Obj_t) );
- pObj->pFanio = (Nwk_Obj_t **)((char *)pObj + sizeof(Nwk_Obj_t));
- pObj->Id = Vec_PtrSize( p->vObjs );
- Vec_PtrPush( p->vObjs, pObj );
- pObj->pMan = p;
- pObj->nFanioAlloc = nFanins + nFanouts + p->nFanioPlus;
- return pObj;
-}
-
-
-/**Function*************************************************************
-
- Synopsis [Creates a primary input.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Nwk_Obj_t * Nwk_ManCreateCi( Nwk_Man_t * p, int nFanouts )
-{
- Nwk_Obj_t * pObj;
- pObj = Nwk_ManCreateObj( p, 1, nFanouts );
- pObj->PioId = Vec_PtrSize( p->vCis );
- Vec_PtrPush( p->vCis, pObj );
- pObj->Type = NWK_OBJ_CI;
- p->nObjs[NWK_OBJ_CI]++;
- return pObj;
-}
-
-/**Function*************************************************************
-
- Synopsis [Creates a primary output.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Nwk_Obj_t * Nwk_ManCreateCo( Nwk_Man_t * p )
-{
- Nwk_Obj_t * pObj;
- pObj = Nwk_ManCreateObj( p, 1, 1 );
- pObj->PioId = Vec_PtrSize( p->vCos );
- Vec_PtrPush( p->vCos, pObj );
- pObj->Type = NWK_OBJ_CO;
- p->nObjs[NWK_OBJ_CO]++;
- return pObj;
-}
-
-/**Function*************************************************************
-
- Synopsis [Creates a latch.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Nwk_Obj_t * Nwk_ManCreateLatch( Nwk_Man_t * p )
-{
- Nwk_Obj_t * pObj;
- pObj = Nwk_ManCreateObj( p, 1, 1 );
- pObj->Type = NWK_OBJ_LATCH;
- p->nObjs[NWK_OBJ_LATCH]++;
- return pObj;
-}
-
-/**Function*************************************************************
-
- Synopsis [Creates a node.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Nwk_Obj_t * Nwk_ManCreateNode( Nwk_Man_t * p, int nFanins, int nFanouts )
-{
- Nwk_Obj_t * pObj;
- pObj = Nwk_ManCreateObj( p, nFanins, nFanouts );
- pObj->Type = NWK_OBJ_NODE;
- p->nObjs[NWK_OBJ_NODE]++;
- return pObj;
-}
-
-
-/**Function*************************************************************
-
- Synopsis [Deletes the node.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Nwk_ManDeleteNode( Nwk_Obj_t * pObj )
-{
- Vec_Ptr_t * vNodes = pObj->pMan->vTemp;
- Nwk_Obj_t * pTemp;
- int i;
- assert( Nwk_ObjFanoutNum(pObj) == 0 );
- // delete fanins
- Nwk_ObjCollectFanins( pObj, vNodes );
- Vec_PtrForEachEntry( vNodes, pTemp, i )
- Nwk_ObjDeleteFanin( pObj, pTemp );
- // remove from the list of objects
- Vec_PtrWriteEntry( pObj->pMan->vObjs, pObj->Id, NULL );
- pObj->pMan->nObjs[pObj->Type]--;
- memset( pObj, 0, sizeof(Nwk_Obj_t) );
- pObj->Id = -1;
-}
-
-/**Function*************************************************************
-
- Synopsis [Deletes the node and MFFC of the node.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Nwk_ManDeleteNode_rec( Nwk_Obj_t * pObj )
-{
- Vec_Ptr_t * vNodes;
- int i;
- assert( !Nwk_ObjIsCi(pObj) );
- assert( Nwk_ObjFanoutNum(pObj) == 0 );
- vNodes = Vec_PtrAlloc( 100 );
- Nwk_ObjCollectFanins( pObj, vNodes );
- Nwk_ManDeleteNode( pObj );
- Vec_PtrForEachEntry( vNodes, pObj, i )
- if ( Nwk_ObjIsNode(pObj) && Nwk_ObjFanoutNum(pObj) == 0 )
- Nwk_ManDeleteNode_rec( pObj );
- Vec_PtrFree( vNodes );
-}
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
-
diff --git a/src/aig/nwk2/nwkUtil.c b/src/aig/nwk2/nwkUtil.c
deleted file mode 100644
index 5473e628..00000000
--- a/src/aig/nwk2/nwkUtil.c
+++ /dev/null
@@ -1,515 +0,0 @@
-/**CFile****************************************************************
-
- FileName [nwkUtil.c]
-
- SystemName [ABC: Logic synthesis and verification system.]
-
- PackageName [Logic network representation.]
-
- Synopsis [Various utilities.]
-
- Author [Alan Mishchenko]
-
- Affiliation [UC Berkeley]
-
- Date [Ver. 1.0. Started - June 20, 2005.]
-
- Revision [$Id: nwkUtil.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
-
-***********************************************************************/
-
-#include "nwk.h"
-#include "kit.h"
-#include <math.h>
-
-////////////////////////////////////////////////////////////////////////
-/// DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
- Synopsis [Increments the current traversal ID of the network.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Nwk_ManIncrementTravId( Nwk_Man_t * pNtk )
-{
- Nwk_Obj_t * pObj;
- int i;
- if ( pNtk->nTravIds >= (1<<26)-1 )
- {
- pNtk->nTravIds = 0;
- Nwk_ManForEachObj( pNtk, pObj, i )
- pObj->TravId = 0;
- }
- pNtk->nTravIds++;
-}
-
-/**Function*************************************************************
-
- Synopsis [Reads the maximum number of fanins of a node.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Nwk_ManGetFaninMax( Nwk_Man_t * pNtk )
-{
- Nwk_Obj_t * pNode;
- int i, nFaninsMax = 0;
- Nwk_ManForEachNode( pNtk, pNode, i )
- {
- if ( nFaninsMax < Nwk_ObjFaninNum(pNode) )
- nFaninsMax = Nwk_ObjFaninNum(pNode);
- }
- return nFaninsMax;
-}
-
-/**Function*************************************************************
-
- Synopsis [Reads the total number of all fanins.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Nwk_ManGetTotalFanins( Nwk_Man_t * pNtk )
-{
- Nwk_Obj_t * pNode;
- int i, nFanins = 0;
- Nwk_ManForEachNode( pNtk, pNode, i )
- nFanins += Nwk_ObjFaninNum(pNode);
- return nFanins;
-}
-
-
-/**Function*************************************************************
-
- Synopsis [Returns the number of true PIs.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Nwk_ManPiNum( Nwk_Man_t * pNtk )
-{
- Nwk_Obj_t * pNode;
- int i, Counter = 0;
- Nwk_ManForEachCi( pNtk, pNode, i )
- Counter += Nwk_ObjIsPi( pNode );
- return Counter;
-}
-
-/**Function*************************************************************
-
- Synopsis [Returns the number of true POs.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Nwk_ManPoNum( Nwk_Man_t * pNtk )
-{
- Nwk_Obj_t * pNode;
- int i, Counter = 0;
- Nwk_ManForEachCo( pNtk, pNode, i )
- Counter += Nwk_ObjIsPo( pNode );
- return Counter;
-}
-
-/**Function*************************************************************
-
- Synopsis [Reads the number of AIG nodes.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Nwk_ManGetAigNodeNum( Nwk_Man_t * pNtk )
-{
- Nwk_Obj_t * pNode;
- int i, nNodes = 0;
- Nwk_ManForEachNode( pNtk, pNode, i )
- {
- if ( pNode->pFunc == NULL )
- {
- printf( "Nwk_ManGetAigNodeNum(): Local AIG of node %d is not assigned.\n", pNode->Id );
- continue;
- }
- if ( Nwk_ObjFaninNum(pNode) < 2 )
- continue;
- nNodes += Hop_DagSize( pNode->pFunc );
- }
- return nNodes;
-}
-
-/**Function*************************************************************
-
- Synopsis [Procedure used for sorting the nodes in increasing order of levels.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Nwk_NodeCompareLevelsIncrease( Nwk_Obj_t ** pp1, Nwk_Obj_t ** pp2 )
-{
- int Diff = (*pp1)->Level - (*pp2)->Level;
- if ( Diff < 0 )
- return -1;
- if ( Diff > 0 )
- return 1;
- return 0;
-}
-
-/**Function*************************************************************
-
- Synopsis [Procedure used for sorting the nodes in decreasing order of levels.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Nwk_NodeCompareLevelsDecrease( Nwk_Obj_t ** pp1, Nwk_Obj_t ** pp2 )
-{
- int Diff = (*pp1)->Level - (*pp2)->Level;
- if ( Diff > 0 )
- return -1;
- if ( Diff < 0 )
- return 1;
- return 0;
-}
-
-/**Function*************************************************************
-
- Synopsis [Prints the objects.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Nwk_ObjPrint( Nwk_Obj_t * pObj )
-{
- Nwk_Obj_t * pNext;
- int i;
- printf( "ObjId = %5d. ", pObj->Id );
- if ( Nwk_ObjIsPi(pObj) )
- printf( "PI" );
- if ( Nwk_ObjIsPo(pObj) )
- printf( "PO" );
- if ( Nwk_ObjIsNode(pObj) )
- printf( "Node" );
- printf( " Fanins = " );
- Nwk_ObjForEachFanin( pObj, pNext, i )
- printf( "%d ", pNext->Id );
- printf( " Fanouts = " );
- Nwk_ObjForEachFanout( pObj, pNext, i )
- printf( "%d ", pNext->Id );
- printf( "\n" );
-}
-
-/**Function*************************************************************
-
- Synopsis [Dumps the BLIF file for the network.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Nwk_ManDumpBlif( Nwk_Man_t * pNtk, char * pFileName, Vec_Ptr_t * vPiNames, Vec_Ptr_t * vPoNames )
-{
- FILE * pFile;
- Vec_Ptr_t * vNodes;
- Vec_Int_t * vTruth;
- Vec_Int_t * vCover;
- Nwk_Obj_t * pObj, * pFanin;
- Aig_MmFlex_t * pMem;
- char * pSop = NULL;
- unsigned * pTruth;
- int i, k, nDigits;
- if ( Nwk_ManPoNum(pNtk) == 0 )
- {
- printf( "Nwk_ManDumpBlif(): Network does not have POs.\n" );
- return;
- }
- // collect nodes in the DFS order
- nDigits = Aig_Base10Log( Nwk_ManObjNumMax(pNtk) );
- // write the file
- pFile = fopen( pFileName, "w" );
- fprintf( pFile, "# BLIF file written by procedure Nwk_ManDumpBlif()\n" );
-// fprintf( pFile, "# http://www.eecs.berkeley.edu/~alanmi/abc/\n" );
- fprintf( pFile, ".model %s\n", pNtk->pName );
- // write PIs
- fprintf( pFile, ".inputs" );
- Nwk_ManForEachCi( pNtk, pObj, i )
- if ( vPiNames )
- fprintf( pFile, " %s", (char*)Vec_PtrEntry(vPiNames, i) );
- else
- fprintf( pFile, " n%0*d", nDigits, pObj->Id );
- fprintf( pFile, "\n" );
- // write POs
- fprintf( pFile, ".outputs" );
- Nwk_ManForEachCo( pNtk, pObj, i )
- if ( vPoNames )
- fprintf( pFile, " %s", (char*)Vec_PtrEntry(vPoNames, i) );
- else
- fprintf( pFile, " n%0*d", nDigits, pObj->Id );
- fprintf( pFile, "\n" );
- // write nodes
- pMem = Aig_MmFlexStart();
- vTruth = Vec_IntAlloc( 1 << 16 );
- vCover = Vec_IntAlloc( 1 << 16 );
- vNodes = Nwk_ManDfs( pNtk );
- Vec_PtrForEachEntry( vNodes, pObj, i )
- {
- if ( !Nwk_ObjIsNode(pObj) )
- continue;
- // derive SOP for the AIG
- pTruth = Hop_ManConvertAigToTruth( pNtk->pManHop, Hop_Regular(pObj->pFunc), Nwk_ObjFaninNum(pObj), vTruth, 0 );
- if ( Hop_IsComplement(pObj->pFunc) )
- Kit_TruthNot( pTruth, pTruth, Nwk_ObjFaninNum(pObj) );
- pSop = Kit_PlaFromTruth( pMem, pTruth, Nwk_ObjFaninNum(pObj), vCover );
- // write the node
- fprintf( pFile, ".names" );
- if ( !Kit_TruthIsConst0(pTruth, Nwk_ObjFaninNum(pObj)) && !Kit_TruthIsConst1(pTruth, Nwk_ObjFaninNum(pObj)) )
- {
- Nwk_ObjForEachFanin( pObj, pFanin, k )
- if ( vPiNames && Nwk_ObjIsPi(pFanin) )
- fprintf( pFile, " %s", (char*)Vec_PtrEntry(vPiNames, Nwk_ObjPioNum(pFanin)) );
- else
- fprintf( pFile, " n%0*d", nDigits, pFanin->Id );
- }
- fprintf( pFile, " n%0*d\n", nDigits, pObj->Id );
- // write the function
- fprintf( pFile, "%s", pSop );
- }
- Vec_IntFree( vCover );
- Vec_IntFree( vTruth );
- Vec_PtrFree( vNodes );
- Aig_MmFlexStop( pMem, 0 );
- // write POs
- Nwk_ManForEachCo( pNtk, pObj, i )
- {
- fprintf( pFile, ".names" );
- if ( vPiNames && Nwk_ObjIsPi(Nwk_ObjFanin0(pObj)) )
- fprintf( pFile, " %s", (char*)Vec_PtrEntry(vPiNames, Nwk_ObjPioNum(Nwk_ObjFanin0(pObj))) );
- else
- fprintf( pFile, " n%0*d", nDigits, Nwk_ObjFanin0(pObj)->Id );
- if ( vPoNames )
- fprintf( pFile, " %s\n", (char*)Vec_PtrEntry(vPoNames, Nwk_ObjPioNum(pObj)) );
- else
- fprintf( pFile, " n%0*d\n", nDigits, pObj->Id );
- fprintf( pFile, "%d 1\n", !pObj->fInvert );
- }
- fprintf( pFile, ".end\n\n" );
- fclose( pFile );
-}
-
-/**Function*************************************************************
-
- Synopsis [Prints the distribution of fanins/fanouts in the network.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Nwk_ManPrintFanioNew( Nwk_Man_t * pNtk )
-{
- char Buffer[100];
- Nwk_Obj_t * pNode;
- Vec_Int_t * vFanins, * vFanouts;
- int nFanins, nFanouts, nFaninsMax, nFanoutsMax, nFaninsAll, nFanoutsAll;
- int i, k, nSizeMax;
-
- // determine the largest fanin and fanout
- nFaninsMax = nFanoutsMax = 0;
- nFaninsAll = nFanoutsAll = 0;
- Nwk_ManForEachNode( pNtk, pNode, i )
- {
- nFanins = Nwk_ObjFaninNum(pNode);
- nFanouts = Nwk_ObjFanoutNum(pNode);
- nFaninsAll += nFanins;
- nFanoutsAll += nFanouts;
- nFaninsMax = ABC_MAX( nFaninsMax, nFanins );
- nFanoutsMax = ABC_MAX( nFanoutsMax, nFanouts );
- }
-
- // allocate storage for fanin/fanout numbers
- nSizeMax = ABC_MAX( 10 * (Aig_Base10Log(nFaninsMax) + 1), 10 * (Aig_Base10Log(nFanoutsMax) + 1) );
- vFanins = Vec_IntStart( nSizeMax );
- vFanouts = Vec_IntStart( nSizeMax );
-
- // count the number of fanins and fanouts
- Nwk_ManForEachNode( pNtk, pNode, i )
- {
- nFanins = Nwk_ObjFaninNum(pNode);
- nFanouts = Nwk_ObjFanoutNum(pNode);
-// nFanouts = Nwk_NodeMffcSize(pNode);
-
- if ( nFanins < 10 )
- Vec_IntAddToEntry( vFanins, nFanins, 1 );
- else if ( nFanins < 100 )
- Vec_IntAddToEntry( vFanins, 10 + nFanins/10, 1 );
- else if ( nFanins < 1000 )
- Vec_IntAddToEntry( vFanins, 20 + nFanins/100, 1 );
- else if ( nFanins < 10000 )
- Vec_IntAddToEntry( vFanins, 30 + nFanins/1000, 1 );
- else if ( nFanins < 100000 )
- Vec_IntAddToEntry( vFanins, 40 + nFanins/10000, 1 );
- else if ( nFanins < 1000000 )
- Vec_IntAddToEntry( vFanins, 50 + nFanins/100000, 1 );
- else if ( nFanins < 10000000 )
- Vec_IntAddToEntry( vFanins, 60 + nFanins/1000000, 1 );
-
- if ( nFanouts < 10 )
- Vec_IntAddToEntry( vFanouts, nFanouts, 1 );
- else if ( nFanouts < 100 )
- Vec_IntAddToEntry( vFanouts, 10 + nFanouts/10, 1 );
- else if ( nFanouts < 1000 )
- Vec_IntAddToEntry( vFanouts, 20 + nFanouts/100, 1 );
- else if ( nFanouts < 10000 )
- Vec_IntAddToEntry( vFanouts, 30 + nFanouts/1000, 1 );
- else if ( nFanouts < 100000 )
- Vec_IntAddToEntry( vFanouts, 40 + nFanouts/10000, 1 );
- else if ( nFanouts < 1000000 )
- Vec_IntAddToEntry( vFanouts, 50 + nFanouts/100000, 1 );
- else if ( nFanouts < 10000000 )
- Vec_IntAddToEntry( vFanouts, 60 + nFanouts/1000000, 1 );
- }
-
- printf( "The distribution of fanins and fanouts in the network:\n" );
- printf( " Number Nodes with fanin Nodes with fanout\n" );
- for ( k = 0; k < nSizeMax; k++ )
- {
- if ( vFanins->pArray[k] == 0 && vFanouts->pArray[k] == 0 )
- continue;
- if ( k < 10 )
- printf( "%15d : ", k );
- else
- {
- sprintf( Buffer, "%d - %d", (int)pow(10, k/10) * (k%10), (int)pow(10, k/10) * (k%10+1) - 1 );
- printf( "%15s : ", Buffer );
- }
- if ( vFanins->pArray[k] == 0 )
- printf( " " );
- else
- printf( "%12d ", vFanins->pArray[k] );
- printf( " " );
- if ( vFanouts->pArray[k] == 0 )
- printf( " " );
- else
- printf( "%12d ", vFanouts->pArray[k] );
- printf( "\n" );
- }
- Vec_IntFree( vFanins );
- Vec_IntFree( vFanouts );
-
- printf( "Fanins: Max = %d. Ave = %.2f. Fanouts: Max = %d. Ave = %.2f.\n",
- nFaninsMax, 1.0*nFaninsAll/Nwk_ManNodeNum(pNtk),
- nFanoutsMax, 1.0*nFanoutsAll/Nwk_ManNodeNum(pNtk) );
-}
-
-/**Function*************************************************************
-
- Synopsis [Cleans the temporary marks of the nodes.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Nwk_ManCleanMarks( Nwk_Man_t * pMan )
-{
- Nwk_Obj_t * pObj;
- int i;
- Nwk_ManForEachObj( pMan, pObj, i )
- pObj->MarkA = pObj->MarkB = 0;
-}
-
-/**Function*************************************************************
-
- Synopsis [Minimizes the support of all nodes.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Nwk_ManMinimumBase( Nwk_Man_t * pNtk, int fVerbose )
-{
- unsigned * pTruth;
- Vec_Int_t * vTruth;
- Nwk_Obj_t * pObj, * pFanin, * pObjNew;
- int uSupp, nSuppSize, i, k, Counter = 0;
- vTruth = Vec_IntAlloc( 1 << 16 );
- Nwk_ManForEachNode( pNtk, pObj, i )
- {
- pTruth = Hop_ManConvertAigToTruth( pNtk->pManHop, Hop_Regular(pObj->pFunc), Nwk_ObjFaninNum(pObj), vTruth, 0 );
- nSuppSize = Kit_TruthSupportSize(pTruth, Nwk_ObjFaninNum(pObj));
- if ( nSuppSize == Nwk_ObjFaninNum(pObj) )
- continue;
- Counter++;
- uSupp = Kit_TruthSupport( pTruth, Nwk_ObjFaninNum(pObj) );
- // create new node with the given support
- pObjNew = Nwk_ManCreateNode( pNtk, nSuppSize, Nwk_ObjFanoutNum(pObj) );
- Nwk_ObjForEachFanin( pObj, pFanin, k )
- if ( uSupp & (1 << k) )
- Nwk_ObjAddFanin( pObjNew, pFanin );
- pObjNew->pFunc = Hop_Remap( pNtk->pManHop, pObj->pFunc, uSupp, Nwk_ObjFaninNum(pObj) );
- if ( fVerbose )
- printf( "Reducing node %d fanins from %d to %d.\n",
- pObj->Id, Nwk_ObjFaninNum(pObj), Nwk_ObjFaninNum(pObjNew) );
- Nwk_ObjReplace( pObj, pObjNew );
- }
- if ( fVerbose && Counter )
- printf( "Support minimization reduced support of %d nodes.\n", Counter );
- Vec_IntFree( vTruth );
-}
-
-////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
-////////////////////////////////////////////////////////////////////////
-
-
diff --git a/src/aig/rwt/rwt.h b/src/aig/rwt/rwt.h
index 9efdc421..5410c9de 100644
--- a/src/aig/rwt/rwt.h
+++ b/src/aig/rwt/rwt.h
@@ -21,21 +21,28 @@
#ifndef __RWT_H__
#define __RWT_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
-#include "mem.h"
-#include "extra.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
#include "vec.h"
+#include "extra.h"
+#include "mem.h"
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -144,9 +151,11 @@ extern char * Rwt_ManGetPractical( Rwt_Man_t * p );
extern Rwt_Node_t * Rwt_ManAddVar( Rwt_Man_t * p, unsigned uTruth, int fPrecompute );
extern void Rwt_ManIncTravId( Rwt_Man_t * p );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/aig/rwt/rwtDec.c b/src/aig/rwt/rwtDec.c
index 2f183913..a26e474d 100644
--- a/src/aig/rwt/rwtDec.c
+++ b/src/aig/rwt/rwtDec.c
@@ -21,6 +21,9 @@
#include "rwt.h"
#include "deco.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -66,7 +69,7 @@ void Rwt_ManPreprocess( Rwt_Man_t * p )
}
}
// compute decomposition forms for each node and verify them
- Vec_VecForEachEntry( p->vClasses, pNode, i, k )
+ Vec_VecForEachEntry( Rwt_Node_t *, p->vClasses, pNode, i, k )
{
pGraph = Rwt_NodePreprocess( p, pNode );
pNode->pNext = (Rwt_Node_t *)pGraph;
@@ -148,3 +151,5 @@ Dec_Edge_t Rwt_TravCollect_rec( Rwt_Man_t * p, Rwt_Node_t * pNode, Dec_Graph_t *
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/rwt/rwtMan.c b/src/aig/rwt/rwtMan.c
index 87074e6e..12caa87f 100644
--- a/src/aig/rwt/rwtMan.c
+++ b/src/aig/rwt/rwtMan.c
@@ -21,6 +21,9 @@
#include "rwt.h"
#include "deco.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -149,7 +152,7 @@ void Rwt_ManStop( Rwt_Man_t * p )
{
Rwt_Node_t * pNode;
int i, k;
- Vec_VecForEachEntry( p->vClasses, pNode, i, k )
+ Vec_VecForEachEntry( Rwt_Node_t *, p->vClasses, pNode, i, k )
Dec_GraphFree( (Dec_Graph_t *)pNode->pNext );
}
if ( p->vClasses ) Vec_VecFree( p->vClasses );
@@ -356,3 +359,5 @@ void Rwt_Precompute()
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/rwt/rwtUtil.c b/src/aig/rwt/rwtUtil.c
index b0b653bd..6cdaf657 100644
--- a/src/aig/rwt/rwtUtil.c
+++ b/src/aig/rwt/rwtUtil.c
@@ -20,287 +20,14 @@
#include "rwt.h"
-////////////////////////////////////////////////////////////////////////
-/// DECLARATIONS ///
-////////////////////////////////////////////////////////////////////////
-
-// precomputed data
-#ifdef _WIN32
-unsigned short s_RwtPracticalClasses[];
-unsigned short s_RwtAigSubgraphs[];
-#else
-static unsigned short s_RwtPracticalClasses[];
-static unsigned short s_RwtAigSubgraphs[];
-#endif
-
-////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFINITIONS ///
-////////////////////////////////////////////////////////////////////////
-
-/**Function*************************************************************
-
- Synopsis [Adds the node to the end of the list.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Rwt_ListAddToTail( Rwt_Node_t ** ppList, Rwt_Node_t * pNode )
-{
- Rwt_Node_t * pTemp;
- // find the last one
- for ( pTemp = *ppList; pTemp; pTemp = pTemp->pNext )
- ppList = &pTemp->pNext;
- // attach at the end
- *ppList = pNode;
-}
-
-/**Function*************************************************************
-
- Synopsis [Adds one node.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Rwt_Node_t * Rwt_ManAddVar( Rwt_Man_t * p, unsigned uTruth, int fPrecompute )
-{
- Rwt_Node_t * pNew;
- pNew = (Rwt_Node_t *)Mem_FixedEntryFetch( p->pMmNode );
- pNew->Id = p->vForest->nSize;
- pNew->TravId = 0;
- pNew->uTruth = uTruth;
- pNew->Level = 0;
- pNew->Volume = 0;
- pNew->fUsed = 1;
- pNew->fExor = 0;
- pNew->p0 = NULL;
- pNew->p1 = NULL;
- pNew->pNext = NULL;
- Vec_PtrPush( p->vForest, pNew );
- if ( fPrecompute )
- Rwt_ListAddToTail( p->pTable + uTruth, pNew );
- return pNew;
-}
-
-/**Function*************************************************************
-
- Synopsis [Adds one node.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Rwt_Node_t * Rwt_ManAddNode( Rwt_Man_t * p, Rwt_Node_t * p0, Rwt_Node_t * p1, int fExor, int Level, int Volume )
-{
- Rwt_Node_t * pNew;
- unsigned uTruth;
- // compute truth table, leve, volume
- p->nConsidered++;
- if ( fExor )
- uTruth = (p0->uTruth ^ p1->uTruth);
- else
- uTruth = (Rwt_IsComplement(p0)? ~Rwt_Regular(p0)->uTruth : Rwt_Regular(p0)->uTruth) &
- (Rwt_IsComplement(p1)? ~Rwt_Regular(p1)->uTruth : Rwt_Regular(p1)->uTruth) & 0xFFFF;
- // create the new node
- pNew = (Rwt_Node_t *)Mem_FixedEntryFetch( p->pMmNode );
- pNew->Id = p->vForest->nSize;
- pNew->TravId = 0;
- pNew->uTruth = uTruth;
- pNew->Level = Level;
- pNew->Volume = Volume;
- pNew->fUsed = 0;
- pNew->fExor = fExor;
- pNew->p0 = p0;
- pNew->p1 = p1;
- pNew->pNext = NULL;
- Vec_PtrPush( p->vForest, pNew );
- // do not add if the node is not essential
- if ( uTruth != p->puCanons[uTruth] )
- return pNew;
-
- // add to the list
- p->nAdded++;
- if ( p->pTable[uTruth] == NULL )
- p->nClasses++;
- Rwt_ListAddToTail( p->pTable + uTruth, pNew );
- return pNew;
-}
-
-/**Function*************************************************************
-
- Synopsis [Adds one node.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Rwt_Trav_rec( Rwt_Man_t * p, Rwt_Node_t * pNode, int * pVolume )
-{
- if ( pNode->fUsed || pNode->TravId == p->nTravIds )
- return;
- pNode->TravId = p->nTravIds;
- (*pVolume)++;
- if ( pNode->fExor )
- (*pVolume)++;
- Rwt_Trav_rec( p, Rwt_Regular(pNode->p0), pVolume );
- Rwt_Trav_rec( p, Rwt_Regular(pNode->p1), pVolume );
-}
-
-/**Function*************************************************************
-
- Synopsis [Adds one node.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Rwt_ManIncTravId( Rwt_Man_t * p )
-{
- Rwt_Node_t * pNode;
- int i;
- if ( p->nTravIds++ < 0x8FFFFFFF )
- return;
- Vec_PtrForEachEntry( p->vForest, pNode, i )
- pNode->TravId = 0;
- p->nTravIds = 1;
-}
-
-/**Function*************************************************************
-
- Synopsis [Adds one node.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Rwt_ManNodeVolume( Rwt_Man_t * p, Rwt_Node_t * p0, Rwt_Node_t * p1 )
-{
- int Volume = 0;
- Rwt_ManIncTravId( p );
- Rwt_Trav_rec( p, p0, &Volume );
- Rwt_Trav_rec( p, p1, &Volume );
- return Volume;
-}
-
-/**Function*************************************************************
-
- Synopsis [Loads data.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Rwt_ManLoadFromArray( Rwt_Man_t * p, int fVerbose )
-{
- unsigned short * pArray = s_RwtAigSubgraphs;
- Rwt_Node_t * p0, * p1;
- unsigned Entry0, Entry1;
- int Level, Volume, nEntries, fExor;
- int i, clk = clock();
-
- // reconstruct the forest
- for ( i = 0; ; i++ )
- {
- Entry0 = pArray[2*i + 0];
- Entry1 = pArray[2*i + 1];
- if ( Entry0 == 0 && Entry1 == 0 )
- break;
- // get EXOR flag
- fExor = (Entry0 & 1);
- Entry0 >>= 1;
- // get the nodes
- p0 = p->vForest->pArray[Entry0 >> 1];
- p1 = p->vForest->pArray[Entry1 >> 1];
- // compute the level and volume of the new nodes
- Level = 1 + RWT_MAX( p0->Level, p1->Level );
- Volume = 1 + Rwt_ManNodeVolume( p, p0, p1 );
- // set the complemented attributes
- p0 = Rwt_NotCond( p0, (Entry0 & 1) );
- p1 = Rwt_NotCond( p1, (Entry1 & 1) );
- // add the node
-// Rwt_ManTryNode( p, p0, p1, Level, Volume );
- Rwt_ManAddNode( p, p0, p1, fExor, Level, Volume + fExor );
- }
- nEntries = i - 1;
- if ( fVerbose )
- {
- printf( "The number of classes = %d. Canonical nodes = %d.\n", p->nClasses, p->nAdded );
- printf( "The number of nodes loaded = %d. ", nEntries ); ABC_PRT( "Loading", clock() - clk );
- }
-}
-
-/**Function*************************************************************
-
- Synopsis [Create practical classes.]
-
- Description []
-
- SideEffects []
+ABC_NAMESPACE_IMPL_START
- SeeAlso []
-
-***********************************************************************/
-char * Rwt_ManGetPractical( Rwt_Man_t * p )
-{
- char * pPractical;
- int i;
- pPractical = ABC_ALLOC( char, p->nFuncs );
- memset( pPractical, 0, sizeof(char) * p->nFuncs );
- pPractical[0] = 1;
- for ( i = 1; ; i++ )
- {
- if ( s_RwtPracticalClasses[i] == 0 )
- break;
- pPractical[ s_RwtPracticalClasses[i] ] = 1;
- }
- return pPractical;
-}
////////////////////////////////////////////////////////////////////////
-/// END OF FILE ///
+/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
-// the following 135 practical NPN classes of 4-variable functions were computed
-// by considering all 4-input cuts appearing in IWLS, MCNC, and ISCAS benchmarks
-static unsigned short s_RwtPracticalClasses[] =
-{
- 0x0000, 0x0001, 0x0003, 0x0006, 0x0007, 0x000f, 0x0016, 0x0017, 0x0018, 0x0019, 0x001b,
- 0x001e, 0x001f, 0x003c, 0x003d, 0x003f, 0x0069, 0x006b, 0x006f, 0x007e, 0x007f, 0x00ff,
- 0x0116, 0x0118, 0x0119, 0x011a, 0x011b, 0x011e, 0x011f, 0x012c, 0x012d, 0x012f, 0x013c,
- 0x013d, 0x013e, 0x013f, 0x0168, 0x0169, 0x016f, 0x017f, 0x0180, 0x0181, 0x0182, 0x0183,
- 0x0186, 0x0189, 0x018b, 0x018f, 0x0198, 0x0199, 0x019b, 0x01a8, 0x01a9, 0x01aa, 0x01ab,
- 0x01ac, 0x01ad, 0x01ae, 0x01af, 0x01bf, 0x01e9, 0x01ea, 0x01eb, 0x01ee, 0x01ef, 0x01fe,
- 0x033c, 0x033d, 0x033f, 0x0356, 0x0357, 0x0358, 0x0359, 0x035a, 0x035b, 0x035f, 0x0368,
- 0x0369, 0x036c, 0x036e, 0x037d, 0x03c0, 0x03c1, 0x03c3, 0x03c7, 0x03cf, 0x03d4, 0x03d5,
- 0x03d7, 0x03d8, 0x03d9, 0x03dc, 0x03dd, 0x03de, 0x03fc, 0x0660, 0x0661, 0x0666, 0x0669,
- 0x066f, 0x0676, 0x067e, 0x0690, 0x0696, 0x0697, 0x069f, 0x06b1, 0x06b6, 0x06f0, 0x06f2,
- 0x06f6, 0x06f9, 0x0776, 0x0778, 0x07b0, 0x07b1, 0x07b4, 0x07bc, 0x07f0, 0x07f2, 0x07f8,
- 0x0ff0, 0x1683, 0x1696, 0x1698, 0x169e, 0x16e9, 0x178e, 0x17e8, 0x18e7, 0x19e6, 0x1be4,
- 0x1ee1, 0x3cc3, 0x6996, 0x0000
-};
-
+// precomputed data
static unsigned short s_RwtAigSubgraphs[] =
{
0x0008,0x0002, 0x000a,0x0002, 0x0008,0x0003, 0x000a,0x0003, 0x0009,0x0002,
@@ -663,3 +390,273 @@ static unsigned short s_RwtAigSubgraphs[] =
};
+static unsigned short s_RwtPracticalClasses[] =
+{
+ 0x0000, 0x0001, 0x0003, 0x0006, 0x0007, 0x000f, 0x0016, 0x0017, 0x0018, 0x0019, 0x001b,
+ 0x001e, 0x001f, 0x003c, 0x003d, 0x003f, 0x0069, 0x006b, 0x006f, 0x007e, 0x007f, 0x00ff,
+ 0x0116, 0x0118, 0x0119, 0x011a, 0x011b, 0x011e, 0x011f, 0x012c, 0x012d, 0x012f, 0x013c,
+ 0x013d, 0x013e, 0x013f, 0x0168, 0x0169, 0x016f, 0x017f, 0x0180, 0x0181, 0x0182, 0x0183,
+ 0x0186, 0x0189, 0x018b, 0x018f, 0x0198, 0x0199, 0x019b, 0x01a8, 0x01a9, 0x01aa, 0x01ab,
+ 0x01ac, 0x01ad, 0x01ae, 0x01af, 0x01bf, 0x01e9, 0x01ea, 0x01eb, 0x01ee, 0x01ef, 0x01fe,
+ 0x033c, 0x033d, 0x033f, 0x0356, 0x0357, 0x0358, 0x0359, 0x035a, 0x035b, 0x035f, 0x0368,
+ 0x0369, 0x036c, 0x036e, 0x037d, 0x03c0, 0x03c1, 0x03c3, 0x03c7, 0x03cf, 0x03d4, 0x03d5,
+ 0x03d7, 0x03d8, 0x03d9, 0x03dc, 0x03dd, 0x03de, 0x03fc, 0x0660, 0x0661, 0x0666, 0x0669,
+ 0x066f, 0x0676, 0x067e, 0x0690, 0x0696, 0x0697, 0x069f, 0x06b1, 0x06b6, 0x06f0, 0x06f2,
+ 0x06f6, 0x06f9, 0x0776, 0x0778, 0x07b0, 0x07b1, 0x07b4, 0x07bc, 0x07f0, 0x07f2, 0x07f8,
+ 0x0ff0, 0x1683, 0x1696, 0x1698, 0x169e, 0x16e9, 0x178e, 0x17e8, 0x18e7, 0x19e6, 0x1be4,
+ 0x1ee1, 0x3cc3, 0x6996, 0x0000
+};
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Adds the node to the end of the list.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Rwt_ListAddToTail( Rwt_Node_t ** ppList, Rwt_Node_t * pNode )
+{
+ Rwt_Node_t * pTemp;
+ // find the last one
+ for ( pTemp = *ppList; pTemp; pTemp = pTemp->pNext )
+ ppList = &pTemp->pNext;
+ // attach at the end
+ *ppList = pNode;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Adds one node.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Rwt_Node_t * Rwt_ManAddVar( Rwt_Man_t * p, unsigned uTruth, int fPrecompute )
+{
+ Rwt_Node_t * pNew;
+ pNew = (Rwt_Node_t *)Mem_FixedEntryFetch( p->pMmNode );
+ pNew->Id = p->vForest->nSize;
+ pNew->TravId = 0;
+ pNew->uTruth = uTruth;
+ pNew->Level = 0;
+ pNew->Volume = 0;
+ pNew->fUsed = 1;
+ pNew->fExor = 0;
+ pNew->p0 = NULL;
+ pNew->p1 = NULL;
+ pNew->pNext = NULL;
+ Vec_PtrPush( p->vForest, pNew );
+ if ( fPrecompute )
+ Rwt_ListAddToTail( p->pTable + uTruth, pNew );
+ return pNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Adds one node.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Rwt_Node_t * Rwt_ManAddNode( Rwt_Man_t * p, Rwt_Node_t * p0, Rwt_Node_t * p1, int fExor, int Level, int Volume )
+{
+ Rwt_Node_t * pNew;
+ unsigned uTruth;
+ // compute truth table, leve, volume
+ p->nConsidered++;
+ if ( fExor )
+ uTruth = (p0->uTruth ^ p1->uTruth);
+ else
+ uTruth = (Rwt_IsComplement(p0)? ~Rwt_Regular(p0)->uTruth : Rwt_Regular(p0)->uTruth) &
+ (Rwt_IsComplement(p1)? ~Rwt_Regular(p1)->uTruth : Rwt_Regular(p1)->uTruth) & 0xFFFF;
+ // create the new node
+ pNew = (Rwt_Node_t *)Mem_FixedEntryFetch( p->pMmNode );
+ pNew->Id = p->vForest->nSize;
+ pNew->TravId = 0;
+ pNew->uTruth = uTruth;
+ pNew->Level = Level;
+ pNew->Volume = Volume;
+ pNew->fUsed = 0;
+ pNew->fExor = fExor;
+ pNew->p0 = p0;
+ pNew->p1 = p1;
+ pNew->pNext = NULL;
+ Vec_PtrPush( p->vForest, pNew );
+ // do not add if the node is not essential
+ if ( uTruth != p->puCanons[uTruth] )
+ return pNew;
+
+ // add to the list
+ p->nAdded++;
+ if ( p->pTable[uTruth] == NULL )
+ p->nClasses++;
+ Rwt_ListAddToTail( p->pTable + uTruth, pNew );
+ return pNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Adds one node.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Rwt_Trav_rec( Rwt_Man_t * p, Rwt_Node_t * pNode, int * pVolume )
+{
+ if ( pNode->fUsed || pNode->TravId == p->nTravIds )
+ return;
+ pNode->TravId = p->nTravIds;
+ (*pVolume)++;
+ if ( pNode->fExor )
+ (*pVolume)++;
+ Rwt_Trav_rec( p, Rwt_Regular(pNode->p0), pVolume );
+ Rwt_Trav_rec( p, Rwt_Regular(pNode->p1), pVolume );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Adds one node.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Rwt_ManIncTravId( Rwt_Man_t * p )
+{
+ Rwt_Node_t * pNode;
+ int i;
+ if ( p->nTravIds++ < 0x8FFFFFFF )
+ return;
+ Vec_PtrForEachEntry( Rwt_Node_t *, p->vForest, pNode, i )
+ pNode->TravId = 0;
+ p->nTravIds = 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Adds one node.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Rwt_ManNodeVolume( Rwt_Man_t * p, Rwt_Node_t * p0, Rwt_Node_t * p1 )
+{
+ int Volume = 0;
+ Rwt_ManIncTravId( p );
+ Rwt_Trav_rec( p, p0, &Volume );
+ Rwt_Trav_rec( p, p1, &Volume );
+ return Volume;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Loads data.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Rwt_ManLoadFromArray( Rwt_Man_t * p, int fVerbose )
+{
+ unsigned short * pArray = s_RwtAigSubgraphs;
+ Rwt_Node_t * p0, * p1;
+ unsigned Entry0, Entry1;
+ int Level, Volume, nEntries, fExor;
+ int i, clk = clock();
+
+ // reconstruct the forest
+ for ( i = 0; ; i++ )
+ {
+ Entry0 = pArray[2*i + 0];
+ Entry1 = pArray[2*i + 1];
+ if ( Entry0 == 0 && Entry1 == 0 )
+ break;
+ // get EXOR flag
+ fExor = (Entry0 & 1);
+ Entry0 >>= 1;
+ // get the nodes
+ p0 = (Rwt_Node_t *)p->vForest->pArray[Entry0 >> 1];
+ p1 = (Rwt_Node_t *)p->vForest->pArray[Entry1 >> 1];
+ // compute the level and volume of the new nodes
+ Level = 1 + RWT_MAX( p0->Level, p1->Level );
+ Volume = 1 + Rwt_ManNodeVolume( p, p0, p1 );
+ // set the complemented attributes
+ p0 = Rwt_NotCond( p0, (Entry0 & 1) );
+ p1 = Rwt_NotCond( p1, (Entry1 & 1) );
+ // add the node
+// Rwt_ManTryNode( p, p0, p1, Level, Volume );
+ Rwt_ManAddNode( p, p0, p1, fExor, Level, Volume + fExor );
+ }
+ nEntries = i - 1;
+ if ( fVerbose )
+ {
+ printf( "The number of classes = %d. Canonical nodes = %d.\n", p->nClasses, p->nAdded );
+ printf( "The number of nodes loaded = %d. ", nEntries ); ABC_PRT( "Loading", clock() - clk );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Create practical classes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+char * Rwt_ManGetPractical( Rwt_Man_t * p )
+{
+ char * pPractical;
+ int i;
+ pPractical = ABC_ALLOC( char, p->nFuncs );
+ memset( pPractical, 0, sizeof(char) * p->nFuncs );
+ pPractical[0] = 1;
+ for ( i = 1; ; i++ )
+ {
+ if ( s_RwtPracticalClasses[i] == 0 )
+ break;
+ pPractical[ s_RwtPracticalClasses[i] ] = 1;
+ }
+ return pPractical;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+// the following 135 practical NPN classes of 4-variable functions were computed
+// by considering all 4-input cuts appearing in IWLS, MCNC, and ISCAS benchmarks
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/saig/module.make b/src/aig/saig/module.make
index e583bcfe..88935121 100644
--- a/src/aig/saig/module.make
+++ b/src/aig/saig/module.make
@@ -1,12 +1,17 @@
SRC += src/aig/saig/saigAbs.c \
+ src/aig/saig/saigAbs2.c \
src/aig/saig/saigBmc.c \
src/aig/saig/saigBmc2.c \
+ src/aig/saig/saigBmc3.c \
src/aig/saig/saigCone.c \
+ src/aig/saig/saigConstr.c \
+ src/aig/saig/saigConstr2.c \
src/aig/saig/saigDup.c \
src/aig/saig/saigHaig.c \
src/aig/saig/saigInd.c \
src/aig/saig/saigIoa.c \
src/aig/saig/saigMiter.c \
+ src/aig/saig/saigPba.c \
src/aig/saig/saigPhase.c \
src/aig/saig/saigRetFwd.c \
src/aig/saig/saigRetMin.c \
diff --git a/src/aig/saig/saig.h b/src/aig/saig/saig.h
index f72a3074..fc85d52a 100644
--- a/src/aig/saig/saig.h
+++ b/src/aig/saig/saig.h
@@ -21,6 +21,7 @@
#ifndef __SAIG_H__
#define __SAIG_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -32,9 +33,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -43,26 +45,57 @@ extern "C" {
typedef struct Sec_MtrStatus_t_ Sec_MtrStatus_t;
struct Sec_MtrStatus_t_
{
- int nInputs; // the total number of inputs
- int nNodes; // the total number of nodes
- int nOutputs; // the total number of outputs
- int nUnsat; // the number of UNSAT outputs
- int nSat; // the number of SAT outputs
- int nUndec; // the number of undecided outputs
- int iOut; // the satisfied output
+ int nInputs; // the total number of inputs
+ int nNodes; // the total number of nodes
+ int nOutputs; // the total number of outputs
+ int nUnsat; // the number of UNSAT outputs
+ int nSat; // the number of SAT outputs
+ int nUndec; // the number of undecided outputs
+ int iOut; // the satisfied output
+};
+
+typedef struct Saig_ParBmc_t_ Saig_ParBmc_t;
+struct Saig_ParBmc_t_
+{
+ int nStart; // starting timeframe
+ int nFramesMax; // maximum number of timeframes
+ int nConfLimit; // maximum number of conflicts at a node
+ int nTimeOut; // approximate timeout in seconds
+ int fSolveAll; // does not stop at the first SAT output
+ int fDropSatOuts; // replace sat outputs by constant 0
+ int fVerbose; // verbose
+ int iFrame; // explored up to this frame
+ int nFailOuts; // the number of failed outputs
+};
+
+typedef struct Saig_ParBbr_t_ Saig_ParBbr_t;
+struct Saig_ParBbr_t_
+{
+ int TimeLimit;
+ int nBddMax;
+ int nIterMax;
+ int fPartition;
+ int fReorder;
+ int fReorderImage;
+ int fVerbose;
+ int fSilent;
+ int fSkipOutCheck;// skip output checking
+ int iFrame; // explored up to this frame
};
+
////////////////////////////////////////////////////////////////////////
/// MACRO DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
-static inline int Saig_ManPiNum( Aig_Man_t * p ) { return p->nTruePis; }
-static inline int Saig_ManPoNum( Aig_Man_t * p ) { return p->nTruePos; }
-static inline int Saig_ManCiNum( Aig_Man_t * p ) { return p->nTruePis + p->nRegs; }
-static inline int Saig_ManCoNum( Aig_Man_t * p ) { return p->nTruePos + p->nRegs; }
-static inline int Saig_ManRegNum( Aig_Man_t * p ) { return p->nRegs; }
-static inline Aig_Obj_t * Saig_ManLo( Aig_Man_t * p, int i ) { return (Aig_Obj_t *)Vec_PtrEntry(p->vPis, Saig_ManPiNum(p)+i); }
-static inline Aig_Obj_t * Saig_ManLi( Aig_Man_t * p, int i ) { return (Aig_Obj_t *)Vec_PtrEntry(p->vPos, Saig_ManPoNum(p)+i); }
+static inline int Saig_ManPiNum( Aig_Man_t * p ) { return p->nTruePis; }
+static inline int Saig_ManPoNum( Aig_Man_t * p ) { return p->nTruePos; }
+static inline int Saig_ManCiNum( Aig_Man_t * p ) { return p->nTruePis + p->nRegs; }
+static inline int Saig_ManCoNum( Aig_Man_t * p ) { return p->nTruePos + p->nRegs; }
+static inline int Saig_ManRegNum( Aig_Man_t * p ) { return p->nRegs; }
+static inline int Saig_ManConstrNum( Aig_Man_t * p ) { return p->nConstrs; }
+static inline Aig_Obj_t * Saig_ManLo( Aig_Man_t * p, int i ) { return (Aig_Obj_t *)Vec_PtrEntry(p->vPis, Saig_ManPiNum(p)+i); }
+static inline Aig_Obj_t * Saig_ManLi( Aig_Man_t * p, int i ) { return (Aig_Obj_t *)Vec_PtrEntry(p->vPos, Saig_ManPoNum(p)+i); }
static inline int Saig_ObjIsPi( Aig_Man_t * p, Aig_Obj_t * pObj ) { return Aig_ObjIsPi(pObj) && Aig_ObjPioNum(pObj) < Saig_ManPiNum(p); }
static inline int Saig_ObjIsPo( Aig_Man_t * p, Aig_Obj_t * pObj ) { return Aig_ObjIsPo(pObj) && Aig_ObjPioNum(pObj) < Saig_ManPoNum(p); }
@@ -73,14 +106,14 @@ static inline Aig_Obj_t * Saig_ObjLiToLo( Aig_Man_t * p, Aig_Obj_t * pObj ) {
// iterator over the primary inputs/outputs
#define Saig_ManForEachPi( p, pObj, i ) \
- Vec_PtrForEachEntryStop( p->vPis, pObj, i, Saig_ManPiNum(p) )
+ Vec_PtrForEachEntryStop( Aig_Obj_t *, p->vPis, pObj, i, Saig_ManPiNum(p) )
#define Saig_ManForEachPo( p, pObj, i ) \
- Vec_PtrForEachEntryStop( p->vPos, pObj, i, Saig_ManPoNum(p) )
+ Vec_PtrForEachEntryStop( Aig_Obj_t *, p->vPos, pObj, i, Saig_ManPoNum(p) )
// iterator over the latch inputs/outputs
#define Saig_ManForEachLo( p, pObj, i ) \
- for ( i = 0; (i < Saig_ManRegNum(p)) && (((pObj) = Vec_PtrEntry(p->vPis, i+Saig_ManPiNum(p))), 1); i++ )
+ for ( i = 0; (i < Saig_ManRegNum(p)) && (((pObj) = (Aig_Obj_t *)Vec_PtrEntry(p->vPis, i+Saig_ManPiNum(p))), 1); i++ )
#define Saig_ManForEachLi( p, pObj, i ) \
- for ( i = 0; (i < Saig_ManRegNum(p)) && (((pObj) = Vec_PtrEntry(p->vPos, i+Saig_ManPoNum(p))), 1); i++ )
+ for ( i = 0; (i < Saig_ManRegNum(p)) && (((pObj) = (Aig_Obj_t *)Vec_PtrEntry(p->vPos, i+Saig_ManPoNum(p))), 1); i++ )
// iterator over the latch input and outputs
#define Saig_ManForEachLiLo( p, pObjLi, pObjLo, i ) \
for ( i = 0; (i < Saig_ManRegNum(p)) && (((pObjLi) = Saig_ManLi(p, i)), 1) \
@@ -89,21 +122,36 @@ static inline Aig_Obj_t * Saig_ObjLiToLo( Aig_Man_t * p, Aig_Obj_t * pObj ) {
////////////////////////////////////////////////////////////////////////
/// FUNCTION DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
-
+
/*=== sswAbs.c ==========================================================*/
+extern Aig_Man_t * Saig_ManCexAbstraction( Aig_Man_t * p, Gia_ParAbs_t * pPars );
+/*=== sswAbs2.c ==========================================================*/
+extern Aig_Man_t * Saig_ManConCexAbstraction( Aig_Man_t * p, Gia_ParAbs_t * pPars );
+/*=== sswPba.c ==========================================================*/
extern Aig_Man_t * Saig_ManProofAbstraction( Aig_Man_t * p, Gia_ParAbs_t * pPars );
/*=== saigBmc.c ==========================================================*/
extern int Saig_ManBmcSimple( Aig_Man_t * pAig, int nFrames, int nSizeMax, int nBTLimit, int fRewrite, int fVerbose, int * piFrame, int nCofFanLit );
-extern void Saig_BmcPerform( Aig_Man_t * pAig, int nStart, int nFramesMax, int nNodesMax, int nTimeOut, int nConfMaxOne, int nConfMaxAll, int fVerbose, int fVerbOverwrite );
+extern int Saig_BmcPerform( Aig_Man_t * pAig, int nStart, int nFramesMax, int nNodesMax, int nTimeOut, int nConfMaxOne, int nConfMaxAll, int fVerbose, int fVerbOverwrite, int * piFrames );
+/*=== saigBmc3.c ==========================================================*/
+extern void Saig_ParBmcSetDefaultParams( Saig_ParBmc_t * p );
+extern int Saig_ManBmcScalable( Aig_Man_t * pAig, Saig_ParBmc_t * pPars );
/*=== saigCone.c ==========================================================*/
extern void Saig_ManPrintCones( Aig_Man_t * p );
+/*=== saigConstr.c ==========================================================*/
+extern Aig_Man_t * Saig_ManDupUnfoldConstrs( Aig_Man_t * pAig );
+extern Aig_Man_t * Saig_ManDupFoldConstrs( Aig_Man_t * pAig, Vec_Int_t * vConstrs );
+extern int Saig_ManDetectConstrTest( Aig_Man_t * p );
+extern void Saig_ManDetectConstrFuncTest( Aig_Man_t * p, int nFrames, int nConfs, int nProps, int fOldAlgo, int fVerbose );
+/*=== saigConstr2.c ==========================================================*/
+extern Aig_Man_t * Saig_ManDupFoldConstrsFunc( Aig_Man_t * pAig, int fCompl, int fVerbose );
+extern Aig_Man_t * Saig_ManDupUnfoldConstrsFunc( Aig_Man_t * pAig, int nFrames, int nConfs, int nProps, int fOldAlgo, int fVerbose );
/*=== saigDup.c ==========================================================*/
extern Aig_Man_t * Said_ManDupOrpos( Aig_Man_t * p );
-extern Aig_Man_t * Saig_ManAbstraction( Aig_Man_t * pAig, Vec_Int_t * vFlops );
+extern Aig_Man_t * Saig_ManDeriveAbstraction( Aig_Man_t * pAig, Vec_Int_t * vFlops );
/*=== saigHaig.c ==========================================================*/
extern Aig_Man_t * Saig_ManHaigRecord( Aig_Man_t * p, int nIters, int nSteps, int fRetimingOnly, int fAddBugs, int fUseCnf, int fVerbose );
/*=== saigInd.c ==========================================================*/
-extern int Saig_ManInduction( Aig_Man_t * p, int nFramesMax, int nConfMax, int fVerbose );
+extern int Saig_ManInduction( Aig_Man_t * p, int nFramesMax, int nConfMax, int fUnique, int fUniqueAll, int fVerbose, int fVeryVerbose );
/*=== saigIoa.c ==========================================================*/
extern void Saig_ManDumpBlif( Aig_Man_t * p, char * pFileName );
extern Aig_Man_t * Saig_ManReadBlif( char * pFileName );
@@ -115,6 +163,7 @@ extern Aig_Man_t * Saig_ManDualRail( Aig_Man_t * p, int fMiter );
extern Aig_Man_t * Saig_ManCreateMiterTwo( Aig_Man_t * pOld, Aig_Man_t * pNew, int nFrames );
extern int Saig_ManDemiterSimple( Aig_Man_t * p, Aig_Man_t ** ppAig0, Aig_Man_t ** ppAig1 );
extern int Saig_ManDemiterSimpleDiff( Aig_Man_t * p, Aig_Man_t ** ppAig0, Aig_Man_t ** ppAig1 );
+extern int Ssw_SecSpecialMiter( Aig_Man_t * p0, Aig_Man_t * p1, int nFrames, int fVerbose );
/*=== saigPhase.c ==========================================================*/
extern Aig_Man_t * Saig_ManPhaseAbstract( Aig_Man_t * p, Vec_Int_t * vInits, int nFrames, int nPref, int fIgnore, int fPrint, int fVerbose );
/*=== saigRetFwd.c ==========================================================*/
@@ -128,8 +177,8 @@ extern int Saig_ManRetimeSteps( Aig_Man_t * p, int nSteps, int fFo
/*=== saigScl.c ==========================================================*/
extern void Saig_ManReportUselessRegisters( Aig_Man_t * pAig );
/*=== saigSimExt.c ==========================================================*/
-//extern Vec_Int_t * Saig_ManExtendCounterExample( Aig_Man_t * p, int iFirstPi, Ssw_Cex_t * pCex, Vec_Ptr_t * vSimInfo );
-//extern Vec_Int_t * Saig_ManExtendCounterExampleTest( Aig_Man_t * p, int iFirstPi, Ssw_Cex_t * pCex );
+extern Vec_Int_t * Saig_ManExtendCounterExample( Aig_Man_t * p, int iFirstPi, Abc_Cex_t * pCex, Vec_Ptr_t * vSimInfo, int fVerbose );
+extern Vec_Int_t * Saig_ManExtendCounterExampleTest( Aig_Man_t * p, int iFirstPi, Abc_Cex_t * pCex, int fVerbose );
/*=== saigSimMv.c ==========================================================*/
extern int Saig_MvManSimulate( Aig_Man_t * pAig, int fVerbose );
/*=== saigStrSim.c ==========================================================*/
@@ -145,9 +194,11 @@ extern Aig_Man_t * Saig_ManWindowExtract( Aig_Man_t * p, Aig_Obj_t * pObj,
extern Aig_Man_t * Saig_ManWindowInsert( Aig_Man_t * p, Aig_Obj_t * pObj, int nDist, Aig_Man_t * pWnd );
extern Aig_Obj_t * Saig_ManFindPivot( Aig_Man_t * p );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/aig/saig/saigAbs.c b/src/aig/saig/saigAbs.c
index 2fac60f5..194add25 100644
--- a/src/aig/saig/saigAbs.c
+++ b/src/aig/saig/saigAbs.c
@@ -6,7 +6,7 @@
PackageName [Sequential AIG package.]
- Synopsis [Proof-based abstraction.]
+ Synopsis [Counter-example-based abstraction.]
Author [Alan Mishchenko]
@@ -19,110 +19,24 @@
***********************************************************************/
#include "saig.h"
-
-#include "cnf.h"
-#include "satSolver.h"
-#include "satStore.h"
#include "ssw.h"
-#include "ioa.h"
#include "fra.h"
+#include "bbr.h"
+
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
-static inline char Saig_AbsVisited( Vec_Str_t * p, int nObjs, Aig_Obj_t * pObj, int i ) { return Vec_StrGetEntry( p, nObjs*i+pObj->Id ); }
-static inline void Saig_AbsSetVisited( Vec_Str_t * p, int nObjs, Aig_Obj_t * pObj, int i ) { Vec_StrSetEntry( p, nObjs*i+pObj->Id, (char)1 ); }
-
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
- Synopsis [Finds the set of clauses involved in the UNSAT core.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Vec_Int_t * Saig_AbsSolverUnsatCore( sat_solver * pSat, int nConfMax, int fVerbose )
-{
- Vec_Int_t * vCore;
- void * pSatCnf;
- Intp_Man_t * pManProof;
- int RetValue, clk = clock();
- // solve the problem
- RetValue = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)nConfMax, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
- if ( RetValue == l_Undef )
- {
- printf( "Conflict limit is reached.\n" );
- return NULL;
- }
- if ( RetValue == l_True )
- {
- printf( "The BMC problem is SAT.\n" );
- return NULL;
- }
- if ( fVerbose )
- {
- printf( "SAT solver returned UNSAT after %d conflicts. ", pSat->stats.conflicts );
- ABC_PRT( "Time", clock() - clk );
- }
- assert( RetValue == l_False );
- pSatCnf = sat_solver_store_release( pSat );
- // derive the UNSAT core
- clk = clock();
- pManProof = Intp_ManAlloc();
- vCore = Intp_ManUnsatCore( pManProof, pSatCnf, 0 );
- Intp_ManFree( pManProof );
- Sto_ManFree( pSatCnf );
- if ( fVerbose )
- {
- printf( "SAT core contains %d clauses (out of %d). ", Vec_IntSize(vCore), pSat->stats.clauses );
- ABC_PRT( "Time", clock() - clk );
- }
- return vCore;
-}
-
-
-/**Function*************************************************************
-
- Synopsis [Mark visited nodes recursively.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Saig_AbsMarkVisited_rec( Aig_Man_t * p, Vec_Str_t * vObj2Visit, Aig_Obj_t * pObj, int i )
-{
- if ( Saig_AbsVisited( vObj2Visit, Aig_ManObjNumMax(p), pObj, i ) )
- return 1;
- Saig_AbsSetVisited( vObj2Visit, Aig_ManObjNumMax(p), pObj, i );
- if ( Saig_ObjIsPi( p, pObj ) )
- return 1;
- if ( Saig_ObjIsLo( p, pObj ) )
- {
- if ( i == 0 )
- return 1;
- return Saig_AbsMarkVisited_rec( p, vObj2Visit, Saig_ObjLoToLi(p, pObj), i-1 );
- }
- if ( Aig_ObjIsPo( pObj ) )
- return Saig_AbsMarkVisited_rec( p, vObj2Visit, Aig_ObjFanin0(pObj), i );
- Saig_AbsMarkVisited_rec( p, vObj2Visit, Aig_ObjFanin0(pObj), i );
- Saig_AbsMarkVisited_rec( p, vObj2Visit, Aig_ObjFanin1(pObj), i );
- return 1;
-}
-
-/**Function*************************************************************
-
- Synopsis [Mark visited nodes.]
+ Synopsis [Collects internal nodes in the DFS order.]
Description []
@@ -131,47 +45,29 @@ int Saig_AbsMarkVisited_rec( Aig_Man_t * p, Vec_Str_t * vObj2Visit, Aig_Obj_t *
SeeAlso []
***********************************************************************/
-Vec_Str_t * Saig_AbsMarkVisited( Aig_Man_t * p, int nFramesMax )
+int Saig_ManFindFirstFlop_rec( Aig_Man_t * p, Aig_Obj_t * pObj )
{
- Vec_Str_t * vObj2Visit;
- Aig_Obj_t * pObj;
- int i, f;
- vObj2Visit = Vec_StrStart( Aig_ManObjNumMax(p) * nFramesMax );
-// Saig_ManForEachLo( p, pObj, i )
-// Saig_AbsSetVisited( vObj2Visit, Aig_ManObjNumMax(p), pObj, 0 );
- for ( f = 0; f < nFramesMax; f++ )
+ int RetValue;
+ if ( Aig_ObjIsTravIdCurrent(p, pObj) )
+ return -1;
+ Aig_ObjSetTravIdCurrent(p, pObj);
+ if ( Saig_ObjIsPi(p, pObj) )
+ return -1;
+ if ( Saig_ObjIsLo(p, pObj) )
{
- Saig_AbsSetVisited( vObj2Visit, Aig_ManObjNumMax(p), Aig_ManConst1(p), f );
- Saig_ManForEachPo( p, pObj, i )
- Saig_AbsMarkVisited_rec( p, vObj2Visit, pObj, f );
+ assert( Aig_ObjPioNum(pObj) >= Saig_ManPiNum(p) );
+ return Aig_ObjPioNum(pObj)-Saig_ManPiNum(p);
}
- return vObj2Visit;
-}
-
-/**Function*************************************************************
-
- Synopsis [Performs the actual construction of the output.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Aig_Obj_t * Saig_AbsCreateFrames_rec( Aig_Man_t * pFrame, Aig_Obj_t * pObj )
-{
- if ( pObj->pData )
- return pObj->pData;
assert( Aig_ObjIsNode(pObj) );
- Saig_AbsCreateFrames_rec( pFrame, Aig_ObjFanin0(pObj) );
- Saig_AbsCreateFrames_rec( pFrame, Aig_ObjFanin1(pObj) );
- return pObj->pData = Aig_And( pFrame, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
+ RetValue = Saig_ManFindFirstFlop_rec( p, Aig_ObjFanin0(pObj) );
+ if ( RetValue >= 0 )
+ return RetValue;
+ return Saig_ManFindFirstFlop_rec( p, Aig_ObjFanin1(pObj) );
}
/**Function*************************************************************
- Synopsis [Derives a vector of AIG managers, one for each frame.]
+ Synopsis [Returns the index of the flop that appears in the support.]
Description []
@@ -180,462 +76,12 @@ Aig_Obj_t * Saig_AbsCreateFrames_rec( Aig_Man_t * pFrame, Aig_Obj_t * pObj )
SeeAlso []
***********************************************************************/
-Vec_Ptr_t * Saig_AbsCreateFrames( Aig_Man_t * p, int nFramesMax, int fVerbose )
+int Saig_ManFindFirstFlop( Aig_Man_t * p )
{
- Vec_Ptr_t * vFrames, * vLoObjs, * vLiObjs;
- Vec_Str_t * vObj2Visit;
- Aig_Man_t * pFrame;
- Aig_Obj_t * pObj;
- int f, i;
- vObj2Visit = Saig_AbsMarkVisited( p, nFramesMax );
- vFrames = Vec_PtrAlloc( nFramesMax );
- vLoObjs = Vec_PtrAlloc( 100 );
- vLiObjs = Vec_PtrAlloc( 100 );
- for ( f = 0; f < nFramesMax; f++ )
- {
- Aig_ManCleanData( p );
- pFrame = Aig_ManStart( 1000 );
- Aig_ManConst1(p)->pData = Aig_ManConst1(pFrame);
- // create PIs
- Vec_PtrClear( vLoObjs );
- Vec_PtrClear( vLiObjs );
- Aig_ManForEachPi( p, pObj, i )
- {
- if ( Saig_AbsVisited( vObj2Visit, Aig_ManObjNumMax(p), pObj, f ) )
- {
- pObj->pData = Aig_ObjCreatePi(pFrame);
- if ( i >= Saig_ManPiNum(p) )
- Vec_PtrPush( vLoObjs, pObj );
- }
- }
- // remember the number of (implicit) registers in this frame
- pFrame->nAsserts = Vec_PtrSize(vLoObjs);
- // create POs
- Aig_ManForEachPo( p, pObj, i )
- {
- if ( Saig_AbsVisited( vObj2Visit, Aig_ManObjNumMax(p), pObj, f ) )
- {
- Saig_AbsCreateFrames_rec( pFrame, Aig_ObjFanin0(pObj) );
- pObj->pData = Aig_ObjCreatePo( pFrame, Aig_ObjChild0Copy(pObj) );
- if ( i >= Saig_ManPoNum(p) )
- Vec_PtrPush( vLiObjs, pObj );
- }
- }
-// Vec_PtrPush( vFrames, Cnf_Derive(pFrame, Aig_ManPoNum(pFrame)) );
- Vec_PtrPush( vFrames, Cnf_DeriveSimple(pFrame, Aig_ManPoNum(pFrame)) );
- // set the new PIs to point to the corresponding registers
- Aig_ManCleanData( pFrame );
- Vec_PtrForEachEntry( vLoObjs, pObj, i )
- ((Aig_Obj_t *)pObj->pData)->pData = pObj;
- Vec_PtrForEachEntry( vLiObjs, pObj, i )
- ((Aig_Obj_t *)pObj->pData)->pData = pObj;
- if ( fVerbose )
- printf( "%3d : PI =%8d. PO =%8d. Flop =%8d. Node =%8d.\n",
- f, Aig_ManPiNum(pFrame), Aig_ManPoNum(pFrame), pFrame->nAsserts, Aig_ManNodeNum(pFrame) );
- }
- Vec_PtrFree( vLoObjs );
- Vec_PtrFree( vLiObjs );
- Vec_StrFree( vObj2Visit );
- return vFrames;
-}
-
-/**Function*************************************************************
+ Aig_ManIncrementTravId( p );
+ Aig_ObjSetTravIdCurrent( p, Aig_ManConst1(p) );
+ return Saig_ManFindFirstFlop_rec( p, Aig_ObjFanin0(Aig_ManPo(p, 0)) );
- Synopsis [Derives a vector of AIG managers, one for each frame.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-sat_solver * Saig_AbsCreateSolverDyn( Aig_Man_t * p, Vec_Ptr_t * vFrames )
-{
- sat_solver * pSat;
- Cnf_Dat_t * pCnf, * pCnfPrev;
- Vec_Int_t * vPoLits;
- Aig_Obj_t * pObjPo, * pObjLi, * pObjLo;
- int f, i, Lit, Lits[2], iVarOld, iVarNew, nSatVars, nRegisters;
- // start array of output literals
- vPoLits = Vec_IntAlloc( 100 );
- // count the number of CNF variables
- nSatVars = 0;
- Vec_PtrForEachEntry( vFrames, pCnf, f )
- nSatVars += pCnf->nVars;
-
- // create the SAT solver
- pSat = sat_solver_new();
- sat_solver_store_alloc( pSat );
- sat_solver_setnvars( pSat, nSatVars );
-
- // add clauses for the timeframes
- nSatVars = 0;
-// Vec_PtrForEachEntryReverse( vFrames, pCnf, f )
- Vec_PtrForEachEntry( vFrames, pCnf, f )
- {
- // lift clauses of this CNF
- Cnf_DataLift( pCnf, nSatVars );
- nSatVars += pCnf->nVars;
- // copy clauses into the manager
- for ( i = 0; i < pCnf->nClauses; i++ )
- {
- if ( !sat_solver_addclause( pSat, pCnf->pClauses[i], pCnf->pClauses[i+1] ) )
- {
- printf( "The BMC problem is trivially UNSAT.\n" );
- sat_solver_delete( pSat );
- Vec_IntFree( vPoLits );
- return NULL;
- }
- }
- // remember output literal
- Aig_ManForEachPo( pCnf->pMan, pObjPo, i )
- {
- if ( i == Saig_ManPoNum(p) )
- break;
- Vec_IntPush( vPoLits, toLit(pCnf->pVarNums[pObjPo->Id]) );
- }
- }
-
- // add auxiliary clauses (output, connectors, initial)
- // add output clause
- if ( !sat_solver_addclause( pSat, Vec_IntArray(vPoLits), Vec_IntArray(vPoLits) + Vec_IntSize(vPoLits) ) )
- {
- printf( "SAT solver is not created correctly.\n" );
- assert( 0 );
- }
- Vec_IntFree( vPoLits );
-
- // add connecting clauses
- pCnfPrev = Vec_PtrEntry( vFrames, 0 );
- Vec_PtrForEachEntryStart( vFrames, pCnf, f, 1 )
- {
- nRegisters = pCnf->pMan->nAsserts;
- assert( nRegisters <= Aig_ManPoNum(pCnfPrev->pMan) );
- assert( nRegisters <= Aig_ManPiNum(pCnf->pMan) );
- for ( i = 0; i < nRegisters; i++ )
- {
- pObjLi = Aig_ManPo( pCnfPrev->pMan, Aig_ManPoNum(pCnfPrev->pMan) - nRegisters + i );
- pObjLo = Aig_ManPi( pCnf->pMan, Aig_ManPiNum(pCnf->pMan) - nRegisters + i );
- // get variable numbers
- iVarOld = pCnfPrev->pVarNums[pObjLi->Id];
- iVarNew = pCnf->pVarNums[pObjLo->Id];
- // add clauses connecting existing variables
- Lits[0] = toLitCond( iVarOld, 0 );
- Lits[1] = toLitCond( iVarNew, 1 );
- if ( !sat_solver_addclause( pSat, Lits, Lits+2 ) )
- assert( 0 );
- Lits[0] = toLitCond( iVarOld, 1 );
- Lits[1] = toLitCond( iVarNew, 0 );
- if ( !sat_solver_addclause( pSat, Lits, Lits+2 ) )
- assert( 0 );
- }
- pCnfPrev = pCnf;
- }
- // add unit clauses
- pCnf = Vec_PtrEntry( vFrames, 0 );
- nRegisters = pCnf->pMan->nAsserts;
- for ( i = 0; i < nRegisters; i++ )
- {
- pObjLo = Aig_ManPi( pCnf->pMan, Aig_ManPiNum(pCnf->pMan) - nRegisters + i );
- assert( pCnf->pVarNums[pObjLo->Id] >= 0 );
- Lit = toLitCond( pCnf->pVarNums[pObjLo->Id], 1 );
- if ( !sat_solver_addclause( pSat, &Lit, &Lit+1 ) )
- assert( 0 );
- }
- sat_solver_store_mark_roots( pSat );
- return pSat;
-}
-
-
-/**Function*************************************************************
-
- Synopsis [Creates SAT solver for BMC.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-sat_solver * Saig_AbsCreateSolver( Cnf_Dat_t * pCnf, int nFrames )
-{
- sat_solver * pSat;
- Vec_Int_t * vPoLits;
- Aig_Obj_t * pObjPo, * pObjLi, * pObjLo;
- int f, i, Lit, Lits[2], iVarOld, iVarNew;
- // start array of output literals
- vPoLits = Vec_IntAlloc( nFrames * Saig_ManPoNum(pCnf->pMan) );
- // create the SAT solver
- pSat = sat_solver_new();
- sat_solver_store_alloc( pSat );
- sat_solver_setnvars( pSat, pCnf->nVars * nFrames );
-
- // add clauses for the timeframes
- for ( f = 0; f < nFrames; f++ )
- {
- for ( i = 0; i < pCnf->nClauses; i++ )
- {
- if ( !sat_solver_addclause( pSat, pCnf->pClauses[i], pCnf->pClauses[i+1] ) )
- {
- printf( "The BMC problem is trivially UNSAT.\n" );
- sat_solver_delete( pSat );
- Vec_IntFree( vPoLits );
- return NULL;
- }
- }
- // remember output literal
- Saig_ManForEachPo( pCnf->pMan, pObjPo, i )
- Vec_IntPush( vPoLits, toLit(pCnf->pVarNums[pObjPo->Id]) );
- // lift CNF to the next frame
- Cnf_DataLift( pCnf, pCnf->nVars );
- }
- // put CNF back to the original level
- Cnf_DataLift( pCnf, - pCnf->nVars * nFrames );
-
- // add auxiliary clauses (output, connectors, initial)
- // add output clause
- if ( !sat_solver_addclause( pSat, Vec_IntArray(vPoLits), Vec_IntArray(vPoLits) + Vec_IntSize(vPoLits) ) )
- assert( 0 );
- Vec_IntFree( vPoLits );
- // add connecting clauses
- for ( f = 0; f < nFrames; f++ )
- {
- // connect to the previous timeframe
- if ( f > 0 )
- {
- Saig_ManForEachLiLo( pCnf->pMan, pObjLi, pObjLo, i )
- {
- iVarOld = pCnf->pVarNums[pObjLi->Id] - pCnf->nVars;
- iVarNew = pCnf->pVarNums[pObjLo->Id];
- // add clauses connecting existing variables
- Lits[0] = toLitCond( iVarOld, 0 );
- Lits[1] = toLitCond( iVarNew, 1 );
- if ( !sat_solver_addclause( pSat, Lits, Lits+2 ) )
- assert( 0 );
- Lits[0] = toLitCond( iVarOld, 1 );
- Lits[1] = toLitCond( iVarNew, 0 );
- if ( !sat_solver_addclause( pSat, Lits, Lits+2 ) )
- assert( 0 );
- }
- }
- // lift CNF to the next frame
- Cnf_DataLift( pCnf, pCnf->nVars );
- }
- // put CNF back to the original level
- Cnf_DataLift( pCnf, - pCnf->nVars * nFrames );
- // add unit clauses
- Saig_ManForEachLo( pCnf->pMan, pObjLo, i )
- {
- assert( pCnf->pVarNums[pObjLo->Id] >= 0 );
- Lit = toLitCond( pCnf->pVarNums[pObjLo->Id], 1 );
- if ( !sat_solver_addclause( pSat, &Lit, &Lit+1 ) )
- assert( 0 );
- }
- sat_solver_store_mark_roots( pSat );
- return pSat;
-}
-
-/**Function*************************************************************
-
- Synopsis [Performs proof-based abstraction using BMC of the given depth.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Vec_Int_t * Saig_AbsCollectRegistersDyn( Aig_Man_t * p, Vec_Ptr_t * vFrames, Vec_Int_t * vCore )
-{
- Aig_Obj_t * pObj;
- Cnf_Dat_t * pCnf;
- Vec_Int_t * vFlops;
- int * pVars, * pFlops;
- int i, f, iClause, iReg, * piLit, nSatVars, nSatClauses;
- // count the number of CNF variables
- nSatVars = 0;
- Vec_PtrForEachEntry( vFrames, pCnf, f )
- nSatVars += pCnf->nVars;
- // mark register variables
- pVars = ABC_ALLOC( int, nSatVars );
- for ( i = 0; i < nSatVars; i++ )
- pVars[i] = -1;
- Vec_PtrForEachEntry( vFrames, pCnf, f )
- {
- Aig_ManForEachPi( pCnf->pMan, pObj, i )
- {
- assert( pCnf->pVarNums[pObj->Id] >= 0 );
- assert( pCnf->pVarNums[pObj->Id] < nSatVars );
- if ( pObj->pData == NULL )
- continue;
- iReg = Aig_ObjPioNum(pObj->pData) - Saig_ManPiNum(p);
- assert( iReg >= 0 && iReg < Aig_ManRegNum(p) );
- pVars[ pCnf->pVarNums[pObj->Id] ] = iReg;
- }
- Aig_ManForEachPo( pCnf->pMan, pObj, i )
- {
- assert( pCnf->pVarNums[pObj->Id] >= 0 );
- assert( pCnf->pVarNums[pObj->Id] < nSatVars );
- if ( pObj->pData == NULL )
- continue;
- iReg = Aig_ObjPioNum(pObj->pData) - Saig_ManPoNum(p);
- assert( iReg >= 0 && iReg < Aig_ManRegNum(p) );
- pVars[ pCnf->pVarNums[pObj->Id] ] = iReg;
- }
- }
- // mark used registers
- pFlops = ABC_CALLOC( int, Aig_ManRegNum(p) );
- Vec_IntForEachEntry( vCore, iClause, i )
- {
- nSatClauses = 0;
- Vec_PtrForEachEntry( vFrames, pCnf, f )
- {
- if ( iClause < nSatClauses + pCnf->nClauses )
- break;
- nSatClauses += pCnf->nClauses;
- }
- if ( f == Vec_PtrSize(vFrames) )
- continue;
- iClause = iClause - nSatClauses;
- assert( iClause >= 0 );
- assert( iClause < pCnf->nClauses );
- // consider the clause
- for ( piLit = pCnf->pClauses[iClause]; piLit < pCnf->pClauses[iClause+1]; piLit++ )
- {
- iReg = pVars[ lit_var(*piLit) ];
- if ( iReg >= 0 )
- pFlops[iReg] = 1;
- }
- }
- // collect registers
- vFlops = Vec_IntAlloc( Aig_ManRegNum(p) );
- for ( i = 0; i < Aig_ManRegNum(p); i++ )
- if ( pFlops[i] )
- Vec_IntPush( vFlops, i );
- ABC_FREE( pFlops );
- ABC_FREE( pVars );
- return vFlops;
-}
-
-/**Function*************************************************************
-
- Synopsis [Performs proof-based abstraction using BMC of the given depth.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Vec_Int_t * Saig_AbsCollectRegisters( Cnf_Dat_t * pCnf, int nFrames, Vec_Int_t * vCore )
-{
- Aig_Obj_t * pObj;
- Vec_Int_t * vFlops;
- int * pVars, * pFlops;
- int i, iClause, iReg, * piLit;
- // mark register variables
- pVars = ABC_ALLOC( int, pCnf->nVars );
- for ( i = 0; i < pCnf->nVars; i++ )
- pVars[i] = -1;
- Saig_ManForEachLi( pCnf->pMan, pObj, i )
- pVars[ pCnf->pVarNums[pObj->Id] ] = i;
- Saig_ManForEachLo( pCnf->pMan, pObj, i )
- pVars[ pCnf->pVarNums[pObj->Id] ] = i;
- // mark used registers
- pFlops = ABC_CALLOC( int, Aig_ManRegNum(pCnf->pMan) );
- Vec_IntForEachEntry( vCore, iClause, i )
- {
- // skip auxiliary clauses
- if ( iClause >= pCnf->nClauses * nFrames )
- continue;
- // consider the clause
- iClause = iClause % pCnf->nClauses;
- for ( piLit = pCnf->pClauses[iClause]; piLit < pCnf->pClauses[iClause+1]; piLit++ )
- {
- iReg = pVars[ lit_var(*piLit) ];
- if ( iReg >= 0 )
- pFlops[iReg] = 1;
- }
- }
- // collect registers
- vFlops = Vec_IntAlloc( Aig_ManRegNum(pCnf->pMan) );
- for ( i = 0; i < Aig_ManRegNum(pCnf->pMan); i++ )
- if ( pFlops[i] )
- Vec_IntPush( vFlops, i );
- ABC_FREE( pFlops );
- ABC_FREE( pVars );
- return vFlops;
-}
-
-/**Function*************************************************************
-
- Synopsis [Performs proof-based abstraction using BMC of the given depth.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Saig_AbsFreeCnfs( Vec_Ptr_t * vFrames )
-{
- Cnf_Dat_t * pCnf;
- int i;
- Vec_PtrForEachEntry( vFrames, pCnf, i )
- {
- Aig_ManStop( pCnf->pMan );
- Cnf_DataFree( pCnf );
- }
- Vec_PtrFree( vFrames );
-}
-
-/**Function*************************************************************
-
- Synopsis [Performs proof-based abstraction using BMC of the given depth.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Saig_AbsExtendOneStep( Aig_Man_t * p, Vec_Int_t * vFlops )
-{
- Vec_Ptr_t * vFlopPtrs, * vSupp;
- Aig_Obj_t * pObj;
- int i, Entry;
- // collect latch inputs
- vFlopPtrs = Vec_PtrAlloc( 1000 );
- Vec_IntForEachEntry( vFlops, Entry, i )
- {
- Vec_PtrPush( vFlopPtrs, Saig_ManLi(p, Entry) );
- pObj = Saig_ManLo(p, Entry);
- pObj->fMarkA = 1;
- }
- // collect latch outputs
- vSupp = Vec_PtrAlloc( 1000 );
- Aig_SupportNodes( p, (Aig_Obj_t **)Vec_PtrArray(vFlopPtrs), Vec_PtrSize(vFlopPtrs), vSupp );
- Vec_PtrFree( vFlopPtrs );
- // mark influencing flops
- Vec_PtrForEachEntry( vSupp, pObj, i )
- pObj->fMarkA = 1;
- Vec_PtrFree( vSupp );
- // reload flops
- Vec_IntClear( vFlops );
- Aig_ManForEachPi( p, pObj, i )
- {
- if ( pObj->fMarkA == 0 )
- continue;
- pObj->fMarkA = 0;
- if ( Aig_ObjPioNum(pObj)-Saig_ManPiNum(p) >= 0 )
- Vec_IntPush( vFlops, Aig_ObjPioNum(pObj)-Saig_ManPiNum(p) );
- }
}
/**Function*************************************************************
@@ -649,11 +95,15 @@ void Saig_AbsExtendOneStep( Aig_Man_t * p, Vec_Int_t * vFlops )
SeeAlso []
***********************************************************************/
-Ssw_Cex_t * Saig_ManCexShrink( Aig_Man_t * p, Aig_Man_t * pAbs, Ssw_Cex_t * pCexAbs )
+Abc_Cex_t * Saig_ManCexRemap( Aig_Man_t * p, Aig_Man_t * pAbs, Abc_Cex_t * pCexAbs )
{
- Ssw_Cex_t * pCex;
+ Abc_Cex_t * pCex;
Aig_Obj_t * pObj;
int i, f;
+ if ( !Ssw_SmlRunCounterExample( pAbs, pCexAbs ) )
+ printf( "Saig_ManCexRemap(): The intial counter-example is invalid.\n" );
+ else
+ printf( "Saig_ManCexRemap(): The intial counter-example is correct.\n" );
// start the counter-example
pCex = Ssw_SmlAllocCounterExample( Aig_ManRegNum(p), Saig_ManPiNum(p), pCexAbs->iFrame+1 );
pCex->iFrame = pCexAbs->iFrame;
@@ -672,7 +122,7 @@ Ssw_Cex_t * Saig_ManCexShrink( Aig_Man_t * p, Aig_Man_t * pAbs, Ssw_Cex_t * pCex
// verify the counter example
if ( !Ssw_SmlRunCounterExample( p, pCex ) )
{
- printf( "Saig_ManCexShrink(): Counter-example is invalid.\n" );
+ printf( "Saig_ManCexRemap(): Counter-example is invalid.\n" );
Ssw_SmlFreeCounterExample( pCex );
pCex = NULL;
}
@@ -695,7 +145,7 @@ Ssw_Cex_t * Saig_ManCexShrink( Aig_Man_t * p, Aig_Man_t * pAbs, Ssw_Cex_t * pCex
SeeAlso []
***********************************************************************/
-int Saig_ManFirstFlopPi( Aig_Man_t * p, Aig_Man_t * pAbs )
+int Saig_ManCexFirstFlopPi( Aig_Man_t * p, Aig_Man_t * pAbs )
{
Aig_Obj_t * pObj;
int i;
@@ -710,7 +160,7 @@ int Saig_ManFirstFlopPi( Aig_Man_t * p, Aig_Man_t * pAbs )
/**Function*************************************************************
- Synopsis [Performs proof-based abstraction using BMC of the given depth.]
+ Synopsis [Refines abstraction using one step.]
Description []
@@ -719,15 +169,12 @@ int Saig_ManFirstFlopPi( Aig_Man_t * p, Aig_Man_t * pAbs )
SeeAlso []
***********************************************************************/
-Aig_Man_t * Saig_ManProofRefine( Aig_Man_t * p, Aig_Man_t * pAbs, Vec_Int_t * vFlops, int nFrames, int nConfMaxOne, int fUseBdds, int fUseDprove, int * pnUseStart, int fVerbose )
+Aig_Man_t * Saig_ManCexRefine( Aig_Man_t * p, Aig_Man_t * pAbs, Vec_Int_t * vFlops, int nFrames, int nConfMaxOne, int fUseBdds, int fUseDprove, int fVerbose, int * pnUseStart, int * piRetValue, int * pnFrames )
{
- extern void Saig_BmcPerform( Aig_Man_t * pAig, int nStart, int nFramesMax, int nNodesMax, int nTimeOut, int nConfMaxOne, int nConfMaxAll, int fVerbose, int fVerbOverwrite );
- extern Vec_Int_t * Saig_ManExtendCounterExampleTest( Aig_Man_t * p, int iFirstPi, void * pCex, int fVerbose );
- extern int Aig_ManVerifyUsingBdds( Aig_Man_t * p, int nBddMax, int nIterMax, int fPartition, int fReorder, int fReorderImage, int fVerbose, int fSilent );
-
- Vec_Int_t * vFlopsNew;//, * vPiToReg;
-// Aig_Obj_t * pObj;
- int i, Entry;//, iFlop;
+ extern int Saig_BmcPerform( Aig_Man_t * pAig, int nStart, int nFramesMax, int nNodesMax, int nTimeOut, int nConfMaxOne, int nConfMaxAll, int fVerbose, int fVerbOverwrite, int * piFrames );
+ Vec_Int_t * vFlopsNew;
+ int i, Entry;
+ *piRetValue = -1;
if ( fUseDprove && Aig_ManRegNum(pAbs) > 0 )
{
Fra_Sec_t SecPar, * pSecPar = &SecPar;
@@ -738,66 +185,92 @@ Aig_Man_t * Saig_ManProofRefine( Aig_Man_t * p, Aig_Man_t * pAbs, Vec_Int_t * vF
}
else if ( fUseBdds && (Aig_ManRegNum(pAbs) > 0 && Aig_ManRegNum(pAbs) <= 80) )
{
- int nBddMax = 1000000;
- int nIterMax = nFrames;
- int fPartition = 1;
- int fReorder = 1;
- int fReorderImage = 1;
- Aig_ManVerifyUsingBdds( pAbs, nBddMax, nIterMax, fPartition, fReorder, fReorderImage, fVerbose, 0 );
+ Saig_ParBbr_t Pars, * pPars = &Pars;
+ Bbr_ManSetDefaultParams( pPars );
+ pPars->TimeLimit = 0;
+ pPars->nBddMax = 1000000;
+ pPars->nIterMax = nFrames;
+ pPars->fPartition = 1;
+ pPars->fReorder = 1;
+ pPars->fReorderImage = 1;
+ pPars->fVerbose = fVerbose;
+ pPars->fSilent = 0;
+ Aig_ManVerifyUsingBdds( pAbs, pPars );
}
else
- Saig_BmcPerform( pAbs, pnUseStart? *pnUseStart: 0, nFrames, 2000, 20, nConfMaxOne, 1000000, fVerbose, 0 );
+ {
+ Saig_BmcPerform( pAbs, pnUseStart? *pnUseStart: 0, nFrames, 2000, 0, nConfMaxOne, 0, fVerbose, 0, pnFrames );
+ }
if ( pAbs->pSeqModel == NULL )
return NULL;
if ( pnUseStart )
- *pnUseStart = ((Fra_Cex_t *)pAbs->pSeqModel)->iFrame;
-// vFlopsNew = Saig_ManExtendCounterExampleTest( pAbs, Saig_ManPiNum(p), pAbs->pSeqModel, fVerbose );
- vFlopsNew = Saig_ManExtendCounterExampleTest( pAbs, Saig_ManFirstFlopPi(p, pAbs), pAbs->pSeqModel, fVerbose );
+ *pnUseStart = pAbs->pSeqModel->iFrame;
+ vFlopsNew = Saig_ManExtendCounterExampleTest( pAbs, Saig_ManCexFirstFlopPi(p, pAbs), pAbs->pSeqModel, fVerbose );
+ if ( vFlopsNew == NULL )
+ return NULL;
if ( Vec_IntSize(vFlopsNew) == 0 )
{
printf( "Discovered a true counter-example!\n" );
- p->pSeqModel = Saig_ManCexShrink( p, pAbs, pAbs->pSeqModel );
+ p->pSeqModel = Saig_ManCexRemap( p, pAbs, pAbs->pSeqModel );
Vec_IntFree( vFlopsNew );
+ *piRetValue = 0;
return NULL;
}
+ // vFlopsNew contains PI numbers that should be kept in pAbs
if ( fVerbose )
printf( "Adding %d registers to the abstraction.\n", Vec_IntSize(vFlopsNew) );
- // vFlopsNew contains PI number that should be kept in pAbs
-/*
- // for each additional PI, collect the number of a register it stands for
- Vec_IntForEachEntry( vFlops, Entry, i )
- {
- pObj = Saig_ManLo( p, Entry );
- pObj->fMarkA = 1;
- }
- vPiToReg = Vec_IntAlloc( 1000 );
- Aig_ManForEachPi( p, pObj, i )
- {
- if ( pObj->fMarkA )
- {
- pObj->fMarkA = 0;
- continue;
- }
- if ( i < Saig_ManPiNum(p) )
- Vec_IntPush( vPiToReg, -1 );
- else
- Vec_IntPush( vPiToReg, Aig_ObjPioNum(pObj)-Saig_ManPiNum(p) );
- }
- // collect registers
+ // add to the abstraction
Vec_IntForEachEntry( vFlopsNew, Entry, i )
{
- iFlop = Vec_IntEntry( vPiToReg, Entry );
- assert( iFlop >= 0 );
- assert( iFlop < Aig_ManRegNum(p) );
- Vec_IntPush( vFlops, iFlop );
+ Entry = Vec_IntEntry(pAbs->vCiNumsOrig, Entry);
+ assert( Entry >= Saig_ManPiNum(p) );
+ assert( Entry < Aig_ManPiNum(p) );
+ Vec_IntPush( vFlops, Entry-Saig_ManPiNum(p) );
}
- Vec_IntFree( vPiToReg );
Vec_IntFree( vFlopsNew );
Vec_IntSort( vFlops, 0 );
Vec_IntForEachEntryStart( vFlops, Entry, i, 1 )
assert( Vec_IntEntry(vFlops, i-1) != Entry );
-*/
+
+ return Saig_ManDeriveAbstraction( p, vFlops );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Refines abstraction using one step.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Saig_ManCexRefineStep( Aig_Man_t * p, Vec_Int_t * vFlops, Abc_Cex_t * pCex, int fVerbose )
+{
+ Aig_Man_t * pAbs;
+ Vec_Int_t * vFlopsNew;
+ int i, Entry;
+ pAbs = Saig_ManDeriveAbstraction( p, vFlops );
+ vFlopsNew = Saig_ManExtendCounterExampleTest( pAbs, Saig_ManCexFirstFlopPi(p, pAbs), pCex, fVerbose );
+ if ( vFlopsNew == NULL )
+ {
+ Aig_ManStop( pAbs );
+ return 0;
+ }
+ if ( Vec_IntSize(vFlopsNew) == 0 )
+ {
+ printf( "Refinement did not happen. Discovered a true counter-example.\n" );
+ printf( "Remapping counter-example from %d to %d primary inputs.\n", Aig_ManPiNum(pAbs), Aig_ManPiNum(p) );
+ p->pSeqModel = Saig_ManCexRemap( p, pAbs, pCex );
+ Vec_IntFree( vFlopsNew );
+ Aig_ManStop( pAbs );
+ return 0;
+ }
+ if ( fVerbose )
+ printf( "Adding %d registers to the abstraction.\n", Vec_IntSize(vFlopsNew) );
+ // vFlopsNew contains PI number that should be kept in pAbs
// add to the abstraction
Vec_IntForEachEntry( vFlopsNew, Entry, i )
{
@@ -807,17 +280,13 @@ Aig_Man_t * Saig_ManProofRefine( Aig_Man_t * p, Aig_Man_t * pAbs, Vec_Int_t * vF
Vec_IntPush( vFlops, Entry-Saig_ManPiNum(p) );
}
Vec_IntFree( vFlopsNew );
-
- Vec_IntSort( vFlops, 0 );
- Vec_IntForEachEntryStart( vFlops, Entry, i, 1 )
- assert( Vec_IntEntry(vFlops, i-1) != Entry );
-
- return Saig_ManAbstraction( p, vFlops );
+ Aig_ManStop( pAbs );
+ return 1;
}
/**Function*************************************************************
- Synopsis [Performs proof-based abstraction using BMC of the given depth.]
+ Synopsis [Computes the flops to remain after abstraction.]
Description []
@@ -826,138 +295,67 @@ Aig_Man_t * Saig_ManProofRefine( Aig_Man_t * p, Aig_Man_t * pAbs, Vec_Int_t * vF
SeeAlso []
***********************************************************************/
-Vec_Int_t * Saig_ManProofAbstraction_int( Aig_Man_t * p, Gia_ParAbs_t * pPars )
+Vec_Int_t * Saig_ManCexAbstractionFlops( Aig_Man_t * p, Gia_ParAbs_t * pPars )
{
- Aig_Man_t * pResult, * pTemp;
- Cnf_Dat_t * pCnf;
- Vec_Ptr_t * vFrames;
- sat_solver * pSat;
- Vec_Int_t * vCore;
+ int nUseStart = 0;
+ Aig_Man_t * pAbs, * pTemp;
Vec_Int_t * vFlops;
- int Iter, clk = clock(), clk2 = clock();
+ int Iter, clk = clock(), clk2 = clock();//, iFlop;
assert( Aig_ManRegNum(p) > 0 );
+ if ( pPars->fVerbose )
+ printf( "Performing counter-example-based refinement.\n" );
Aig_ManSetPioNumbers( p );
-
- if ( pPars->fSkipProof )
- {
-// assert( 0 );
- if ( pPars->fVerbose )
- printf( "Performing counter-example-based refinement.\n" );
-// vFlops = Vec_IntStartNatural( 100 );
-// Vec_IntPush( vFlops, 0 );
- vFlops = Vec_IntStartNatural( 1 );
- }
- else
- {
- if ( pPars->fVerbose )
- printf( "Performing proof-based abstraction with %d frames and %d max conflicts.\n", pPars->nFramesMax, pPars->nConfMax );
- if ( pPars->fDynamic )
- {
- // create CNF for the frames
- vFrames = Saig_AbsCreateFrames( p, pPars->nFramesMax, pPars->fVerbose );
- // create dynamic solver
- pSat = Saig_AbsCreateSolverDyn( p, vFrames );
- }
- else
- {
- // create CNF for the AIG
- pCnf = Cnf_DeriveSimple( p, Aig_ManPoNum(p) );
- // create SAT solver for the unrolled AIG
- pSat = Saig_AbsCreateSolver( pCnf, pPars->nFramesMax );
- }
- if ( pPars->fVerbose )
- {
- printf( "SAT solver: Vars = %7d. Clauses = %7d. ", pSat->size, pSat->stats.clauses );
- ABC_PRT( "Time", clock() - clk2 );
- }
- // compute UNSAT core
- vCore = Saig_AbsSolverUnsatCore( pSat, pPars->nConfMax, pPars->fVerbose );
- sat_solver_delete( pSat );
- if ( vCore == NULL )
- {
- Saig_AbsFreeCnfs( vFrames );
- return NULL;
- }
- // collect registers
- if ( pPars->fDynamic )
- {
- vFlops = Saig_AbsCollectRegistersDyn( p, vFrames, vCore );
- Saig_AbsFreeCnfs( vFrames );
- }
- else
- {
- vFlops = Saig_AbsCollectRegisters( pCnf, pPars->nFramesMax, vCore );
- Cnf_DataFree( pCnf );
- }
- Vec_IntFree( vCore );
- if ( pPars->fVerbose )
- {
- printf( "The number of relevant registers is %d (out of %d). ", Vec_IntSize(vFlops), Aig_ManRegNum(p) );
- ABC_PRT( "Time", clock() - clk );
- }
- }
+ vFlops = Vec_IntStartNatural( 1 );
/*
- // extend the abstraction
- if ( fExtend )
- {
- if ( fVerbose )
- printf( "Support extended from %d flops to", Vec_IntSize(vFlops) );
- Saig_AbsExtendOneStep( p, vFlops );
- if ( fVerbose )
- printf( " %d flops.\n", Vec_IntSize(vFlops) );
- }
+ iFlop = Saig_ManFindFirstFlop( p );
+ assert( iFlop >= 0 );
+ vFlops = Vec_IntAlloc( 1 );
+ Vec_IntPush( vFlops, iFlop );
*/
// create the resulting AIG
- pResult = Saig_ManAbstraction( p, vFlops );
-
- if ( pPars->fExtend )
+ pAbs = Saig_ManDeriveAbstraction( p, vFlops );
+ if ( !pPars->fVerbose )
{
- int nUseStart = 0;
- if ( !pPars->fVerbose )
+ printf( "Init : " );
+ Aig_ManPrintStats( pAbs );
+ }
+ printf( "Refining abstraction...\n" );
+ for ( Iter = 0; ; Iter++ )
+ {
+ pTemp = Saig_ManCexRefine( p, pAbs, vFlops, pPars->nFramesBmc, pPars->nConfMaxBmc, pPars->fUseBdds, pPars->fUseDprove, pPars->fVerbose, pPars->fUseStart?&nUseStart:NULL, &pPars->Status, &pPars->nFramesDone );
+ if ( pTemp == NULL )
{
- printf( "Init : " );
- Aig_ManPrintStats( pResult );
+ ABC_FREE( p->pSeqModel );
+ p->pSeqModel = pAbs->pSeqModel;
+ pAbs->pSeqModel = NULL;
+ Aig_ManStop( pAbs );
+ break;
}
- printf( "Refining abstraction...\n" );
- for ( Iter = 0; ; Iter++ )
- {
- pTemp = Saig_ManProofRefine( p, pResult, vFlops, pPars->nFramesBmc, pPars->nConfMaxBmc, pPars->fUseBdds, pPars->fUseDprove, pPars->fUseStart?&nUseStart:NULL, pPars->fVerbose );
- if ( pTemp == NULL )
- break;
- Aig_ManStop( pResult );
- pResult = pTemp;
- printf( "ITER %4d : ", Iter );
- if ( !pPars->fVerbose )
- Aig_ManPrintStats( pResult );
-// else
-// printf( " -----------------------------------------------------\n" );
- // output the intermediate result of abstraction
- Ioa_WriteAiger( pResult, "gabs.aig", 0, 0 );
+ Aig_ManStop( pAbs );
+ pAbs = pTemp;
+ printf( "ITER %4d : ", Iter );
+ if ( !pPars->fVerbose )
+ Aig_ManPrintStats( pAbs );
+ // output the intermediate result of abstraction
+ Ioa_WriteAiger( pAbs, "gabs.aig", 0, 0 );
// printf( "Intermediate abstracted model was written into file \"%s\".\n", "gabs.aig" );
- // check if the ratio is reached
- if ( 100.0*(Aig_ManRegNum(p)-Aig_ManRegNum(pTemp))/Aig_ManRegNum(p) < 1.0*pPars->nRatio )
- {
- printf( "Refinements is stopped because flop reduction is less than %d%%\n", pPars->nRatio );
- Aig_ManStop( pResult );
- pResult = NULL;
- break;
- }
+ // check if the ratio is reached
+ if ( 100.0*(Aig_ManRegNum(p)-Aig_ManRegNum(pAbs))/Aig_ManRegNum(p) < 1.0*pPars->nRatio )
+ {
+ printf( "Refinements is stopped because flop reduction is less than %d%%\n", pPars->nRatio );
+ Aig_ManStop( pAbs );
+ pAbs = NULL;
+ Vec_IntFree( vFlops );
+ vFlops = NULL;
+ break;
}
}
- // write the final result
- if ( pResult )
- Aig_ManStop( pResult );
- else
- {
- Vec_IntFree( vFlops );
- vFlops = NULL;
- }
return vFlops;
}
/**Function*************************************************************
- Synopsis [Performs proof-based abstraction using BMC of the given depth.]
+ Synopsis [Performs counter-example-based abstraction.]
Description []
@@ -966,15 +364,15 @@ Vec_Int_t * Saig_ManProofAbstraction_int( Aig_Man_t * p, Gia_ParAbs_t * pPars )
SeeAlso []
***********************************************************************/
-Aig_Man_t * Saig_ManProofAbstraction( Aig_Man_t * p, Gia_ParAbs_t * pPars )
+Aig_Man_t * Saig_ManCexAbstraction( Aig_Man_t * p, Gia_ParAbs_t * pPars )
{
Vec_Int_t * vFlops;
Aig_Man_t * pAbs = NULL;
- vFlops = Saig_ManProofAbstraction_int( p, pPars );
+ vFlops = Saig_ManCexAbstractionFlops( p, pPars );
// write the final result
if ( vFlops )
{
- pAbs = Saig_ManAbstraction( p, vFlops );
+ pAbs = Saig_ManDeriveAbstraction( p, vFlops );
Ioa_WriteAiger( pAbs, "gabs.aig", 0, 0 );
printf( "Final abstracted model was written into file \"%s\".\n", "gabs.aig" );
Vec_IntFree( vFlops );
@@ -987,3 +385,5 @@ Aig_Man_t * Saig_ManProofAbstraction( Aig_Man_t * p, Gia_ParAbs_t * pPars )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/saig/saigAbs2.c b/src/aig/saig/saigAbs2.c
new file mode 100644
index 00000000..a4d0f973
--- /dev/null
+++ b/src/aig/saig/saigAbs2.c
@@ -0,0 +1,237 @@
+/**CFile****************************************************************
+
+ FileName [saigAbs.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Sequential AIG package.]
+
+ Synopsis [Counter-example-based abstraction with constraints.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: saigAbs.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "saig.h"
+#include "ssw.h"
+#include "fra.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+extern int Saig_ManFindFirstFlop( Aig_Man_t * p );
+extern Aig_Man_t * Saig_ManCexRefine( Aig_Man_t * p, Aig_Man_t * pAbs, Vec_Int_t * vFlops,
+ int nFrames, int nConfMaxOne, int fUseBdds, int fUseDprove, int fVerbose, int * pnUseStart,
+ int * piRetValue, int * pnFrames );
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Returns the array of constraint numbers that are violated.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Saig_ManFindViolatedConstrs( Aig_Man_t * p, Abc_Cex_t * pCexAbs )
+{
+ Vec_Int_t * vFailed;
+ Aig_Obj_t * pObj, * pObjRi, * pObjRo;
+ int * pPoMap, i, k, iBit;
+ pPoMap = ABC_CALLOC( int, Saig_ManPoNum(p) );
+ Aig_ManCleanMarkA(p);
+ Saig_ManForEachLo( p, pObj, i )
+ pObj->fMarkA = 0;
+ assert( pCexAbs->nBits == pCexAbs->nRegs + (pCexAbs->iFrame + 1) * pCexAbs->nPis );
+ for ( i = 0; i <= pCexAbs->iFrame; i++ )
+ {
+ iBit = pCexAbs->nRegs + i * pCexAbs->nPis;
+ Saig_ManForEachPi( p, pObj, k )
+ pObj->fMarkA = Aig_InfoHasBit(pCexAbs->pData, iBit++);
+ Aig_ManForEachNode( p, pObj, k )
+ pObj->fMarkA = (Aig_ObjFanin0(pObj)->fMarkA ^ Aig_ObjFaninC0(pObj)) &
+ (Aig_ObjFanin1(pObj)->fMarkA ^ Aig_ObjFaninC1(pObj));
+ Aig_ManForEachPo( p, pObj, k )
+ pObj->fMarkA = Aig_ObjFanin0(pObj)->fMarkA ^ Aig_ObjFaninC0(pObj);
+ Saig_ManForEachPo( p, pObj, k )
+ pPoMap[k] |= pObj->fMarkA;
+ Saig_ManForEachLiLo( p, pObjRi, pObjRo, k )
+ pObjRo->fMarkA = pObjRi->fMarkA;
+ }
+ Aig_ManCleanMarkA(p);
+ // collect numbers of failed constraints
+ vFailed = Vec_IntAlloc( Saig_ManPoNum(p) );
+ Saig_ManForEachPo( p, pObj, k )
+ if ( pPoMap[k] )
+ Vec_IntPush( vFailed, k );
+ ABC_FREE( pPoMap );
+ return vFailed;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes the flops to remain after abstraction.]
+
+ Description [Updates the set of included constraints.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Saig_ManConCexAbstractionFlops( Aig_Man_t * pInit, Gia_ParAbs_t * pPars, Vec_Int_t * vConstrs )
+{
+ int nUseStart = 0;
+ Aig_Man_t * pCur, * pAbs, * pTemp;
+ Vec_Int_t * vFlops, * vFlopsCopy, * vConstrsToAdd;
+ int i, Entry, iFlop, Iter, clk = clock(), clk2 = clock();
+ assert( Aig_ManRegNum(pInit) > 0 );
+ if ( pPars->fVerbose )
+ printf( "Performing counter-example-based refinement with constraints.\n" );
+// Aig_ManSetPioNumbers( p );
+ // create constrained AIG
+ pCur = Saig_ManDupFoldConstrs( pInit, vConstrs );
+ assert( Saig_ManPoNum(pCur) == 1 );
+ printf( "cur>>> " ); Aig_ManPrintStats( pCur );
+ // start the flop map
+ iFlop = Saig_ManFindFirstFlop( pCur );
+ assert( iFlop >= 0 );
+// vFlops = Vec_IntStartNatural( 1 );
+ vFlops = Vec_IntAlloc( 1 );
+ Vec_IntPush( vFlops, iFlop );
+ // create the abstraction
+ pAbs = Saig_ManDeriveAbstraction( pCur, vFlops );
+ printf( "abs>>> " ); Aig_ManPrintStats( pAbs );
+ if ( !pPars->fVerbose )
+ {
+ printf( "Init : " );
+ Aig_ManPrintStats( pAbs );
+ }
+ printf( "Refining abstraction...\n" );
+ for ( Iter = 0; ; Iter++ )
+ {
+ while ( 1 )
+ {
+ vFlopsCopy = Vec_IntDup( vFlops );
+ pTemp = Saig_ManCexRefine( pCur, pAbs, vFlops, pPars->nFramesBmc, pPars->nConfMaxBmc, pPars->fUseBdds, pPars->fUseDprove, pPars->fVerbose, pPars->fUseStart?&nUseStart:NULL, &pPars->Status, &pPars->nFramesDone );
+ if ( pTemp == NULL )
+ {
+ Vec_IntFree( vFlopsCopy );
+ break;
+ }
+ vConstrsToAdd = Saig_ManFindViolatedConstrs( pInit, pAbs->pSeqModel );
+ if ( Vec_IntSize(vConstrsToAdd) == 0 )
+ {
+ Vec_IntFree( vConstrsToAdd );
+ Vec_IntFree( vFlopsCopy );
+ break;
+ }
+ // add the constraints to the base set
+ Vec_IntForEachEntry( vConstrsToAdd, Entry, i )
+ {
+// assert( Vec_IntFind(vConstrs, Entry) == -1 );
+ Vec_IntPushUnique( vConstrs, Entry );
+ }
+ printf( "Adding %3d constraints. The total is %3d (out of %3d).\n",
+ Vec_IntSize(vConstrsToAdd), Vec_IntSize(vConstrs), Saig_ManPoNum(pInit)-1 );
+ Vec_IntFree( vConstrsToAdd );
+ // update the current one
+ Aig_ManStop( pCur );
+ pCur = Saig_ManDupFoldConstrs( pInit, vConstrs );
+ printf( "cur>>> " ); Aig_ManPrintStats( pCur );
+ // update the flop map
+ Vec_IntFree( vFlops );
+ vFlops = vFlopsCopy;
+// Vec_IntFree( vFlopsCopy );
+// vFlops = vFlops;
+ // update abstraction
+ Aig_ManStop( pAbs );
+ pAbs = Saig_ManDeriveAbstraction( pCur, vFlops );
+ printf( "abs>>> " ); Aig_ManPrintStats( pAbs );
+ }
+ Aig_ManStop( pAbs );
+ if ( pTemp == NULL )
+ break;
+ pAbs = pTemp;
+ printf( "ITER %4d : ", Iter );
+ if ( !pPars->fVerbose )
+ Aig_ManPrintStats( pAbs );
+ // output the intermediate result of abstraction
+ Ioa_WriteAiger( pAbs, "gabs.aig", 0, 0 );
+// printf( "Intermediate abstracted model was written into file \"%s\".\n", "gabs.aig" );
+ // check if the ratio is reached
+ if ( 100.0*(Aig_ManRegNum(pCur)-Aig_ManRegNum(pAbs))/Aig_ManRegNum(pCur) < 1.0*pPars->nRatio )
+ {
+ printf( "Refinements is stopped because flop reduction is less than %d%%\n", pPars->nRatio );
+ Aig_ManStop( pAbs );
+ pAbs = NULL;
+ Vec_IntFree( vFlops );
+ vFlops = NULL;
+ break;
+ }
+ }
+ ABC_FREE( pInit->pSeqModel );
+ pInit->pSeqModel = pCur->pSeqModel;
+ pCur->pSeqModel = NULL;
+ Aig_ManStop( pCur );
+ return vFlops;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs counter-example-based abstraction.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Man_t * Saig_ManConCexAbstraction( Aig_Man_t * p, Gia_ParAbs_t * pPars )
+{
+ Vec_Int_t * vFlops, * vConstrs;
+ Aig_Man_t * pCur, * pAbs = NULL;
+ assert( Saig_ManPoNum(p) > 1 ); // should contain constraint outputs
+ // start included constraints
+ vConstrs = Vec_IntAlloc( 100 );
+ // perform refinement
+ vFlops = Saig_ManConCexAbstractionFlops( p, pPars, vConstrs );
+ // write the final result
+ if ( vFlops )
+ {
+ pCur = Saig_ManDupFoldConstrs( p, vConstrs );
+ pAbs = Saig_ManDeriveAbstraction( pCur, vFlops );
+ Aig_ManStop( pCur );
+
+ Ioa_WriteAiger( pAbs, "gabs.aig", 0, 0 );
+ printf( "Final abstracted model was written into file \"%s\".\n", "gabs.aig" );
+ Vec_IntFree( vFlops );
+ }
+ Vec_IntFree( vConstrs );
+ return pAbs;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/saig/saigBmc.c b/src/aig/saig/saigBmc.c
index ac1cbe5b..8aa3af80 100644
--- a/src/aig/saig/saigBmc.c
+++ b/src/aig/saig/saigBmc.c
@@ -19,375 +19,72 @@
***********************************************************************/
#include "saig.h"
+#include "fra.h"
#include "cnf.h"
#include "satStore.h"
-#include "ssw.h"
+
+ABC_NAMESPACE_IMPL_START
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
-#define AIG_VISITED ((Aig_Obj_t *)(ABC_PTRUINT_T)1)
-
-typedef struct Saig_Bmc_t_ Saig_Bmc_t;
-struct Saig_Bmc_t_
-{
- // parameters
- int nFramesMax; // the max number of timeframes to consider
- int nNodesMax; // the max number of nodes to add
- int nConfMaxOne; // the max number of conflicts at a target
- int nConfMaxAll; // the max number of conflicts for all targets
- int fVerbose; // enables verbose output
- // AIG managers
- Aig_Man_t * pAig; // the user's AIG manager
- Aig_Man_t * pFrm; // Frames manager
- Vec_Ptr_t * vVisited; // nodes visited in Frames
- // node mapping
- int nObjs; // the largest number of an AIG object
- Vec_Ptr_t * vAig2Frm; // mapping of AIG nodees into Frames nodes
-// Vec_Str_t * vAig2Frm2; // mapping of AIG nodees into Frames nodes
- // SAT solver
- sat_solver * pSat; // SAT solver
- int nSatVars; // the number of used SAT variables
- Vec_Int_t * vObj2Var; // mapping of frames objects in CNF variables
- // subproblems
- Vec_Ptr_t * vTargets; // targets to be solved in this interval
- int iFramePrev; // previous frame
- int iFrameLast; // last frame
- int iOutputLast; // last output
- int iFrameFail; // failed frame
- int iOutputFail; // failed output
-};
-
-static inline int Saig_BmcSatNum( Saig_Bmc_t * p, Aig_Obj_t * pObj ) { return Vec_IntGetEntry( p->vObj2Var, pObj->Id ); }
-static inline void Saig_BmcSetSatNum( Saig_Bmc_t * p, Aig_Obj_t * pObj, int Num ) { Vec_IntSetEntry(p->vObj2Var, pObj->Id, Num); }
-
-static inline Aig_Obj_t * Saig_BmcObjFrame( Saig_Bmc_t * p, Aig_Obj_t * pObj, int i ) { return Vec_PtrGetEntry( p->vAig2Frm, p->nObjs*i+pObj->Id ); }
-static inline void Saig_BmcObjSetFrame( Saig_Bmc_t * p, Aig_Obj_t * pObj, int i, Aig_Obj_t * pNode ) { Vec_PtrSetEntry( p->vAig2Frm, p->nObjs*i+pObj->Id, pNode ); }
-
-static inline Aig_Obj_t * Saig_BmcObjChild0( Saig_Bmc_t * p, Aig_Obj_t * pObj, int i ) { assert( !Aig_IsComplement(pObj) ); return Aig_NotCond(Saig_BmcObjFrame(p, Aig_ObjFanin0(pObj), i), Aig_ObjFaninC0(pObj)); }
-static inline Aig_Obj_t * Saig_BmcObjChild1( Saig_Bmc_t * p, Aig_Obj_t * pObj, int i ) { assert( !Aig_IsComplement(pObj) ); return Aig_NotCond(Saig_BmcObjFrame(p, Aig_ObjFanin1(pObj), i), Aig_ObjFaninC1(pObj)); }
-
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
-#define ABS_ZER 1
-#define ABS_ONE 2
-#define ABS_UND 3
-
-static inline int Abs_ManSimInfoNot( int Value )
-{
- if ( Value == ABS_ZER )
- return ABS_ONE;
- if ( Value == ABS_ONE )
- return ABS_ZER;
- return ABS_UND;
-}
-
-static inline int Abs_ManSimInfoAnd( int Value0, int Value1 )
-{
- if ( Value0 == ABS_ZER || Value1 == ABS_ZER )
- return ABS_ZER;
- if ( Value0 == ABS_ONE && Value1 == ABS_ONE )
- return ABS_ONE;
- return ABS_UND;
-}
-
-static inline int Abs_ManSimInfoGet( Vec_Ptr_t * vSimInfo, Aig_Obj_t * pObj, int iFrame )
-{
- unsigned * pInfo = Vec_PtrEntry( vSimInfo, iFrame );
- return 3 & (pInfo[Aig_ObjId(pObj) >> 4] >> ((Aig_ObjId(pObj) & 15) << 1));
-}
-
-static inline void Abs_ManSimInfoSet( Vec_Ptr_t * vSimInfo, Aig_Obj_t * pObj, int iFrame, int Value )
-{
- unsigned * pInfo = Vec_PtrEntry( vSimInfo, iFrame );
- assert( Value >= ABS_ZER && Value <= ABS_UND );
- Value ^= Abs_ManSimInfoGet( vSimInfo, pObj, iFrame );
- pInfo[Aig_ObjId(pObj) >> 4] ^= (Value << ((Aig_ObjId(pObj) & 15) << 1));
-}
-
/**Function*************************************************************
- Synopsis [Performs ternary simulation for one node.]
+ Synopsis [Create timeframes of the manager for BMC.]
- Description []
+ Description [The resulting manager is combinational. POs correspond to \
+ the property outputs in each time-frame.]
SideEffects []
SeeAlso []
***********************************************************************/
-int Abs_ManExtendOneEval_rec( Vec_Ptr_t * vSimInfo, Aig_Man_t * p, Aig_Obj_t * pObj, int iFrame )
+Aig_Man_t * Saig_ManFramesBmc( Aig_Man_t * pAig, int nFrames )
{
- int Value0, Value1, Value;
- Value = Abs_ManSimInfoGet( vSimInfo, pObj, iFrame );
- if ( Value )
- return Value;
- if ( Aig_ObjIsPi(pObj) )
- {
- assert( Saig_ObjIsLo(p, pObj) );
- Value = Abs_ManExtendOneEval_rec( vSimInfo, p, Saig_ObjLoToLi(p, pObj), iFrame-1 );
- Abs_ManSimInfoSet( vSimInfo, pObj, iFrame, Value );
- return Value;
- }
- Value0 = Abs_ManExtendOneEval_rec( vSimInfo, p, Aig_ObjFanin0(pObj), iFrame );
- if ( Aig_ObjFaninC0(pObj) )
- Value0 = Abs_ManSimInfoNot( Value0 );
- if ( Aig_ObjIsPo(pObj) )
- {
- Abs_ManSimInfoSet( vSimInfo, pObj, iFrame, Value0 );
- return Value0;
- }
- assert( Aig_ObjIsNode(pObj) );
- if ( Value0 == ABS_ZER )
- Value = ABS_ZER;
- else
- {
- Value1 = Abs_ManExtendOneEval_rec( vSimInfo, p, Aig_ObjFanin1(pObj), iFrame );
- if ( Aig_ObjFaninC1(pObj) )
- Value1 = Abs_ManSimInfoNot( Value1 );
- Value = Abs_ManSimInfoAnd( Value0, Value1 );
- }
- Abs_ManSimInfoSet( vSimInfo, pObj, iFrame, Value );
- assert( Value );
- return Value;
-}
-
-/**Function*************************************************************
-
- Synopsis [Performs ternary simulation for one design.]
-
- Description [The returned array contains the result of ternary
- simulation for all the frames where the output could be proved 0.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Vec_Ptr_t * Abs_ManTernarySimulate( Aig_Man_t * p, int nFramesMax, int fVerbose )
-{
- Vec_Ptr_t * vSimInfo;
- Aig_Obj_t * pObj;
- int i, f, nFramesLimit, nFrameWords;
- int clk = clock();
- assert( Aig_ManRegNum(p) > 0 );
- // the maximum number of frames will be determined to use at most 200Mb of RAM
- nFramesLimit = 1 + (200000000 * 4)/Aig_ManObjNum(p);
- nFramesLimit = ABC_MIN( nFramesLimit, nFramesMax );
- nFrameWords = Aig_BitWordNum( 2 * Aig_ManObjNum(p) );
- // allocate simulation info
- vSimInfo = Vec_PtrAlloc( nFramesLimit );
- for ( f = 0; f < nFramesLimit; f++ )
- {
- Vec_PtrPush( vSimInfo, ABC_CALLOC(unsigned, nFrameWords) );
- if ( f == 0 )
- {
- Saig_ManForEachLo( p, pObj, i )
- Abs_ManSimInfoSet( vSimInfo, pObj, 0, ABS_ZER );
- }
- Abs_ManSimInfoSet( vSimInfo, Aig_ManConst1(p), f, ABS_ONE );
- Saig_ManForEachPi( p, pObj, i )
- Abs_ManSimInfoSet( vSimInfo, pObj, f, ABS_UND );
- Saig_ManForEachPo( p, pObj, i )
- Abs_ManExtendOneEval_rec( vSimInfo, p, pObj, f );
- // check if simulation has derived at least one fail or unknown
- Saig_ManForEachPo( p, pObj, i )
- if ( Abs_ManSimInfoGet(vSimInfo, pObj, f) != ABS_ZER )
- {
- if ( fVerbose )
- {
- printf( "Ternary sim found non-zero output in frame %d. Used %5.2f Mb. ",
- f, 0.25 * (f+1) * Aig_ManObjNum(p) / (1<<20) );
- ABC_PRT( "Time", clock() - clk );
- }
- return vSimInfo;
- }
- }
- if ( fVerbose )
- {
- printf( "Ternary sim proved all outputs in the first %d frames. Used %5.2f Mb. ",
- nFramesLimit, 0.25 * nFramesLimit * Aig_ManObjNum(p) / (1<<20) );
- ABC_PRT( "Time", clock() - clk );
- }
- return vSimInfo;
-}
-
-/**Function*************************************************************
-
- Synopsis [Free the array of simulation info.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Abs_ManFreeAray( Vec_Ptr_t * p )
-{
- void * pTemp;
- int i;
- Vec_PtrForEachEntry( p, pTemp, i )
- ABC_FREE( pTemp );
- Vec_PtrFree( p );
-}
-
-
-/**Function*************************************************************
-
- Synopsis [Create manager.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Saig_Bmc_t * Saig_BmcManStart( Aig_Man_t * pAig, int nFramesMax, int nNodesMax, int nConfMaxOne, int nConfMaxAll, int fVerbose )
-{
- Saig_Bmc_t * p;
- Aig_Obj_t * pObj;
- int i, Lit;
-// assert( Aig_ManRegNum(pAig) > 0 );
- p = (Saig_Bmc_t *)ABC_ALLOC( char, sizeof(Saig_Bmc_t) );
- memset( p, 0, sizeof(Saig_Bmc_t) );
- // set parameters
- p->nFramesMax = nFramesMax;
- p->nNodesMax = nNodesMax;
- p->nConfMaxOne = nConfMaxOne;
- p->nConfMaxAll = nConfMaxAll;
- p->fVerbose = fVerbose;
- p->pAig = pAig;
- p->nObjs = Aig_ManObjNumMax(pAig);
- // create node and variable mappings
- p->vAig2Frm = Vec_PtrAlloc( 0 );
- Vec_PtrFill( p->vAig2Frm, 5 * p->nObjs, NULL );
- p->vObj2Var = Vec_IntAlloc( 0 );
- Vec_IntFill( p->vObj2Var, 5 * p->nObjs, 0 );
- // start the AIG manager and map primary inputs
- p->pFrm = Aig_ManStart( 5 * p->nObjs );
+ Aig_Man_t * pFrames;
+ Aig_Obj_t * pObj, * pObjLi, * pObjLo;
+ int i, f;
+ assert( Saig_ManRegNum(pAig) > 0 );
+ pFrames = Aig_ManStart( Aig_ManNodeNum(pAig) * nFrames );
+ // map the constant node
+ Aig_ManConst1(pAig)->pData = Aig_ManConst1( pFrames );
+ // create variables for register outputs
Saig_ManForEachLo( pAig, pObj, i )
- Saig_BmcObjSetFrame( p, pObj, 0, Aig_ManConst0(p->pFrm) );
- // create SAT solver
- p->nSatVars = 1;
- p->pSat = sat_solver_new();
- sat_solver_setnvars( p->pSat, 2000 );
- Lit = toLit( p->nSatVars );
- sat_solver_addclause( p->pSat, &Lit, &Lit + 1 );
- Saig_BmcSetSatNum( p, Aig_ManConst1(p->pFrm), p->nSatVars++ );
- // other data structures
- p->vTargets = Vec_PtrAlloc( 0 );
- p->vVisited = Vec_PtrAlloc( 0 );
- p->iOutputFail = -1;
- p->iFrameFail = -1;
- return p;
-}
-
-/**Function*************************************************************
-
- Synopsis [Delete manager.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Saig_BmcManStop( Saig_Bmc_t * p )
-{
-// Aig_Obj_t * pObj;
-// int i, f, Counter = 0;
-// int i, Counter = 0;
-// for ( i = 0; i < p->vAig2Frm2->nSize; i++ )
-// Counter += (p->vAig2Frm2->pArray[i] != 0);
-// for ( i = 0; i < p->vAig2Frm->nSize; i++ )
-// Counter += (p->vAig2Frm->pArray[i] != NULL);
-// printf( "Objs = %d. Nodes = %d. Frames = %d. Used = %d. Non-empty = %d.\n",
-// p->nObjs, Aig_ManNodeNum(p->pAig), p->iFrameLast, p->vAig2Frm->nSize, Counter );
-
-/*
- Aig_ManForEachObj( p->pAig, pObj, i )
- {
- int Last = -1;
- for ( f = 0; f <= p->iFrameLast; f++ )
- if ( Saig_BmcObjFrame( p, pObj, f ) )
- Last = f;
- if ( i % 50 == 0 )
- printf( "%d ", Last );
- }
- printf( "\n" );
-*/
-
- Aig_ManStop( p->pFrm );
- Vec_PtrFree( p->vAig2Frm );
-// Vec_StrFree( p->vAig2Frm2 );
- Vec_IntFree( p->vObj2Var );
- sat_solver_delete( p->pSat );
- Vec_PtrFree( p->vTargets );
- Vec_PtrFree( p->vVisited );
- ABC_FREE( p );
-}
-
-/**Function*************************************************************
-
- Synopsis [Explores the possibility of constructing the output.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Aig_Obj_t * Saig_BmcIntervalExplore_rec( Saig_Bmc_t * p, Aig_Obj_t * pObj, int i )
-{
- Aig_Obj_t * pRes, * p0, * p1, * pConst1 = Aig_ManConst1(p->pAig);
- pRes = Saig_BmcObjFrame( p, pObj, i );
- if ( pRes != NULL )
- return pRes;
- if ( Saig_ObjIsPi( p->pAig, pObj ) )
- pRes = AIG_VISITED;
- else if ( Saig_ObjIsLo( p->pAig, pObj ) )
- pRes = Saig_BmcIntervalExplore_rec( p, Saig_ObjLoToLi(p->pAig, pObj), i-1 );
- else if ( Aig_ObjIsPo( pObj ) )
- {
- pRes = Saig_BmcIntervalExplore_rec( p, Aig_ObjFanin0(pObj), i );
- if ( pRes != AIG_VISITED )
- pRes = Saig_BmcObjChild0( p, pObj, i );
- }
- else
+ pObj->pData = Aig_ManConst0( pFrames );
+ // add timeframes
+ for ( f = 0; f < nFrames; f++ )
{
- p0 = Saig_BmcIntervalExplore_rec( p, Aig_ObjFanin0(pObj), i );
- if ( p0 != AIG_VISITED )
- p0 = Saig_BmcObjChild0( p, pObj, i );
- p1 = Saig_BmcIntervalExplore_rec( p, Aig_ObjFanin1(pObj), i );
- if ( p1 != AIG_VISITED )
- p1 = Saig_BmcObjChild1( p, pObj, i );
-
- if ( p0 == Aig_Not(p1) )
- pRes = Aig_ManConst0(p->pFrm);
- else if ( Aig_Regular(p0) == pConst1 )
- pRes = (p0 == pConst1) ? p1 : Aig_ManConst0(p->pFrm);
- else if ( Aig_Regular(p1) == pConst1 )
- pRes = (p1 == pConst1) ? p0 : Aig_ManConst0(p->pFrm);
- else
- pRes = AIG_VISITED;
-
- if ( pRes != AIG_VISITED && !Aig_ObjIsConst1(Aig_Regular(pRes)) )
- pRes = AIG_VISITED;
+ // create PI nodes for this frame
+ Saig_ManForEachPi( pAig, pObj, i )
+ pObj->pData = Aig_ObjCreatePi( pFrames );
+ // add internal nodes of this frame
+ Aig_ManForEachNode( pAig, pObj, i )
+ pObj->pData = Aig_And( pFrames, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
+ // create POs for this frame
+ Saig_ManForEachPo( pAig, pObj, i )
+ Aig_ObjCreatePo( pFrames, Aig_ObjChild0Copy(pObj) );
+ if ( f == nFrames - 1 )
+ break;
+ // save register inputs
+ Saig_ManForEachLi( pAig, pObj, i )
+ pObj->pData = Aig_ObjChild0Copy(pObj);
+ // transfer to register outputs
+ Saig_ManForEachLiLo( pAig, pObjLi, pObjLo, i )
+ pObjLo->pData = pObjLi->pData;
}
- Saig_BmcObjSetFrame( p, pObj, i, pRes );
- return pRes;
+ Aig_ManCleanup( pFrames );
+ return pFrames;
}
/**Function*************************************************************
- Synopsis [Performs the actual construction of the output.]
+ Synopsis [Returns the number of internal nodes that are not counted yet.]
Description []
@@ -396,271 +93,88 @@ Aig_Obj_t * Saig_BmcIntervalExplore_rec( Saig_Bmc_t * p, Aig_Obj_t * pObj, int i
SeeAlso []
***********************************************************************/
-Aig_Obj_t * Saig_BmcIntervalConstruct_rec( Saig_Bmc_t * p, Aig_Obj_t * pObj, int i, Vec_Ptr_t * vVisited )
+int Saig_ManFramesCount_rec( Aig_Man_t * p, Aig_Obj_t * pObj )
{
- Aig_Obj_t * pRes;
- pRes = Saig_BmcObjFrame( p, pObj, i );
- if ( pRes != NULL )
- return pRes;
- if ( Saig_ObjIsPi( p->pAig, pObj ) )
- pRes = Aig_ObjCreatePi(p->pFrm);
- else if ( Saig_ObjIsLo( p->pAig, pObj ) )
- pRes = Saig_BmcIntervalConstruct_rec( p, Saig_ObjLoToLi(p->pAig, pObj), i-1, vVisited );
- else if ( Aig_ObjIsPo( pObj ) )
- {
- Saig_BmcIntervalConstruct_rec( p, Aig_ObjFanin0(pObj), i, vVisited );
- pRes = Saig_BmcObjChild0( p, pObj, i );
- }
- else
- {
- Saig_BmcIntervalConstruct_rec( p, Aig_ObjFanin0(pObj), i, vVisited );
- if ( Saig_BmcObjChild0(p, pObj, i) == Aig_ManConst0(p->pFrm) )
- pRes = Aig_ManConst0(p->pFrm);
- else
- {
- Saig_BmcIntervalConstruct_rec( p, Aig_ObjFanin1(pObj), i, vVisited );
- pRes = Aig_And( p->pFrm, Saig_BmcObjChild0(p, pObj, i), Saig_BmcObjChild1(p, pObj, i) );
- }
- }
- assert( pRes != NULL );
- Saig_BmcObjSetFrame( p, pObj, i, pRes );
- Vec_PtrPush( vVisited, pObj );
- Vec_PtrPush( vVisited, (void *)i );
- return pRes;
+ if ( !Aig_ObjIsNode(pObj) )
+ return 0;
+ if ( Aig_ObjIsTravIdCurrent(p, pObj) )
+ return 0;
+ Aig_ObjSetTravIdCurrent(p, pObj);
+ return 1 + Saig_ManFramesCount_rec( p, Aig_ObjFanin0(pObj) ) +
+ Saig_ManFramesCount_rec( p, Aig_ObjFanin1(pObj) );
}
/**Function*************************************************************
- Synopsis [Adds new AIG nodes to the frames.]
+ Synopsis [Create timeframes of the manager for BMC.]
- Description []
+ Description [The resulting manager is combinational. POs correspond to
+ the property outputs in each time-frame.
+ The unrolling is stopped as soon as the number of nodes in the frames
+ exceeds the given maximum size.]
SideEffects []
SeeAlso []
***********************************************************************/
-void Saig_BmcInterval( Saig_Bmc_t * p )
+Aig_Man_t * Saig_ManFramesBmcLimit( Aig_Man_t * pAig, int nFrames, int nSizeMax )
{
- Aig_Obj_t * pTarget;
- Aig_Obj_t * pObj, * pRes;
- int i, iFrame, Counter;
- int nNodes = Aig_ManObjNum( p->pFrm );
- Vec_PtrClear( p->vTargets );
- p->iFramePrev = p->iFrameLast;
- for ( ; p->iFrameLast < p->nFramesMax; p->iFrameLast++, p->iOutputLast = 0 )
+ Aig_Man_t * pFrames;
+ Aig_Obj_t * pObj, * pObjLi, * pObjLo, * pObjPo;
+ int i, f, Counter = 0;
+ assert( Saig_ManRegNum(pAig) > 0 );
+ pFrames = Aig_ManStart( nSizeMax );
+ Aig_ManIncrementTravId( pFrames );
+ // map the constant node
+ Aig_ManConst1(pAig)->pData = Aig_ManConst1( pFrames );
+ // create variables for register outputs
+ Saig_ManForEachLo( pAig, pObj, i )
+ pObj->pData = Aig_ManConst0( pFrames );
+ // add timeframes
+ Counter = 0;
+ for ( f = 0; f < nFrames; f++ )
{
- if ( p->iOutputLast == 0 )
+ // create PI nodes for this frame
+ Saig_ManForEachPi( pAig, pObj, i )
+ pObj->pData = Aig_ObjCreatePi( pFrames );
+ // add internal nodes of this frame
+ Aig_ManForEachNode( pAig, pObj, i )
+ pObj->pData = Aig_And( pFrames, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
+ // create POs for this frame
+ Saig_ManForEachPo( pAig, pObj, i )
{
- Saig_BmcObjSetFrame( p, Aig_ManConst1(p->pAig), p->iFrameLast, Aig_ManConst1(p->pFrm) );
+ pObjPo = Aig_ObjCreatePo( pFrames, Aig_ObjChild0Copy(pObj) );
+ Counter += Saig_ManFramesCount_rec( pFrames, Aig_ObjFanin0(pObjPo) );
}
- for ( ; p->iOutputLast < Saig_ManPoNum(p->pAig); p->iOutputLast++ )
- {
- if ( Aig_ManObjNum(p->pFrm) >= nNodes + p->nNodesMax )
- return;
-// Saig_BmcIntervalExplore_rec( p, Aig_ManPo(p->pAig, p->iOutputLast), p->iFrameLast );
- Vec_PtrClear( p->vVisited );
- pTarget = Saig_BmcIntervalConstruct_rec( p, Aig_ManPo(p->pAig, p->iOutputLast), p->iFrameLast, p->vVisited );
- Vec_PtrPush( p->vTargets, pTarget );
- Aig_ObjCreatePo( p->pFrm, pTarget );
- Aig_ManCleanup( p->pFrm );
- // check if the node is gone
- Counter = 0;
- Vec_PtrForEachEntry( p->vVisited, pObj, i )
- {
- iFrame = (int)(ABC_PTRINT_T)Vec_PtrEntry( p->vVisited, 1+i++ );
- pRes = Saig_BmcObjFrame( p, pObj, iFrame );
- if ( Aig_ObjIsNone( Aig_Regular(pRes) ) )
- {
- Saig_BmcObjSetFrame( p, pObj, iFrame, NULL );
- Counter++;
- }
- }
-// printf( "%d ", Counter );
- }
- }
-}
-
-/**Function*************************************************************
-
- Synopsis [Performs the actual construction of the output.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Aig_Obj_t * Saig_BmcIntervalToAig_rec( Saig_Bmc_t * p, Aig_Man_t * pNew, Aig_Obj_t * pObj )
-{
- if ( pObj->pData )
- return pObj->pData;
- Vec_PtrPush( p->vVisited, pObj );
- if ( Saig_BmcSatNum(p, pObj) || Aig_ObjIsPi(pObj) )
- return pObj->pData = Aig_ObjCreatePi(pNew);
- Saig_BmcIntervalToAig_rec( p, pNew, Aig_ObjFanin0(pObj) );
- Saig_BmcIntervalToAig_rec( p, pNew, Aig_ObjFanin1(pObj) );
- assert( pObj->pData == NULL );
- return pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
-}
-
-/**Function*************************************************************
-
- Synopsis [Creates AIG of the newly added nodes.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Aig_Man_t * Saig_BmcIntervalToAig( Saig_Bmc_t * p )
-{
- Aig_Man_t * pNew;
- Aig_Obj_t * pObj, * pObjNew;
- int i;
- Aig_ManForEachObj( p->pFrm, pObj, i )
- assert( pObj->pData == NULL );
-
- pNew = Aig_ManStart( p->nNodesMax );
- Aig_ManConst1(p->pFrm)->pData = Aig_ManConst1(pNew);
- Vec_PtrClear( p->vVisited );
- Vec_PtrPush( p->vVisited, Aig_ManConst1(p->pFrm) );
- Vec_PtrForEachEntry( p->vTargets, pObj, i )
- {
-// assert( !Aig_ObjIsConst1(Aig_Regular(pObj)) );
- pObjNew = Saig_BmcIntervalToAig_rec( p, pNew, Aig_Regular(pObj) );
- assert( !Aig_IsComplement(pObjNew) );
- Aig_ObjCreatePo( pNew, pObjNew );
- }
- return pNew;
-}
-
-/**Function*************************************************************
-
- Synopsis [Derives CNF for the newly added nodes.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Saig_BmcLoadCnf( Saig_Bmc_t * p, Cnf_Dat_t * pCnf )
-{
- Aig_Obj_t * pObj, * pObjNew;
- int i, Lits[2], VarNumOld, VarNumNew;
- Vec_PtrForEachEntry( p->vVisited, pObj, i )
- {
- // get the new variable of this node
- pObjNew = pObj->pData;
- pObj->pData = NULL;
- VarNumNew = pCnf->pVarNums[ pObjNew->Id ];
- if ( VarNumNew == -1 )
- continue;
- // get the old variable of this node
- VarNumOld = Saig_BmcSatNum( p, pObj );
- if ( VarNumOld == 0 )
+ if ( Counter >= nSizeMax )
{
- Saig_BmcSetSatNum( p, pObj, VarNumNew );
- continue;
+ Aig_ManCleanup( pFrames );
+ return pFrames;
}
- // add clauses connecting existing variables
- Lits[0] = toLitCond( VarNumOld, 0 );
- Lits[1] = toLitCond( VarNumNew, 1 );
- if ( !sat_solver_addclause( p->pSat, Lits, Lits+2 ) )
- assert( 0 );
- Lits[0] = toLitCond( VarNumOld, 1 );
- Lits[1] = toLitCond( VarNumNew, 0 );
- if ( !sat_solver_addclause( p->pSat, Lits, Lits+2 ) )
- assert( 0 );
- }
- // add CNF to the SAT solver
- for ( i = 0; i < pCnf->nClauses; i++ )
- if ( !sat_solver_addclause( p->pSat, pCnf->pClauses[i], pCnf->pClauses[i+1] ) )
+ if ( f == nFrames - 1 )
break;
- if ( i < pCnf->nClauses )
- printf( "SAT solver became UNSAT after adding clauses.\n" );
-}
-
-/**Function*************************************************************
-
- Synopsis [Solves targets with the given resource limit.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Saig_BmcDeriveFailed( Saig_Bmc_t * p, int iTargetFail )
-{
- int k;
- p->iOutputFail = p->iOutputLast;
- p->iFrameFail = p->iFrameLast;
- for ( k = Vec_PtrSize(p->vTargets); k > iTargetFail; k-- )
- {
- if ( p->iOutputFail == 0 )
- {
- p->iOutputFail = Saig_ManPoNum(p->pAig);
- p->iFrameFail--;
- }
- p->iOutputFail--;
+ // save register inputs
+ Saig_ManForEachLi( pAig, pObj, i )
+ pObj->pData = Aig_ObjChild0Copy(pObj);
+ // transfer to register outputs
+ Saig_ManForEachLiLo( pAig, pObjLi, pObjLo, i )
+ pObjLo->pData = pObjLi->pData;
}
+ Aig_ManCleanup( pFrames );
+ return pFrames;
}
-/**Function*************************************************************
+ABC_NAMESPACE_IMPL_END
- Synopsis [Solves targets with the given resource limit.]
+#include "utilMem.h"
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Ssw_Cex_t * Saig_BmcGenerateCounterExample( Saig_Bmc_t * p )
-{
- Ssw_Cex_t * pCex;
- Aig_Obj_t * pObj, * pObjFrm;
- int i, f, iVarNum;
- // start the counter-example
- pCex = Ssw_SmlAllocCounterExample( Aig_ManRegNum(p->pAig), Saig_ManPiNum(p->pAig), p->iFrameFail+1 );
- pCex->iFrame = p->iFrameFail;
- pCex->iPo = p->iOutputFail;
- // copy the bit data
- for ( f = 0; f <= p->iFrameFail; f++ )
- {
- Saig_ManForEachPi( p->pAig, pObj, i )
- {
- pObjFrm = Saig_BmcObjFrame( p, pObj, f );
- if ( pObjFrm == NULL )
- continue;
- iVarNum = Saig_BmcSatNum( p, pObjFrm );
- if ( iVarNum == 0 )
- continue;
- if ( sat_solver_var_value( p->pSat, iVarNum ) )
- Aig_InfoSetBit( pCex->pData, pCex->nRegs + Saig_ManPiNum(p->pAig) * f + i );
- }
- }
- // verify the counter example
- if ( !Ssw_SmlRunCounterExample( p->pAig, pCex ) )
- {
- printf( "Saig_BmcGenerateCounterExample(): Counter-example is invalid.\n" );
- Ssw_SmlFreeCounterExample( pCex );
- pCex = NULL;
- }
- return pCex;
-}
+ABC_NAMESPACE_IMPL_START
+
/**Function*************************************************************
- Synopsis [Solves targets with the given resource limit.]
+ Synopsis [Performs BMC for the given AIG.]
Description []
@@ -669,157 +183,156 @@ Ssw_Cex_t * Saig_BmcGenerateCounterExample( Saig_Bmc_t * p )
SeeAlso []
***********************************************************************/
-int Saig_BmcSolveTargets( Saig_Bmc_t * p, int nStart, int * pnOutsSolved )
+int Saig_ManBmcSimple( Aig_Man_t * pAig, int nFrames, int nSizeMax, int nConfLimit, int fRewrite, int fVerbose, int * piFrame, int nCofFanLit )
{
+ extern Aig_Man_t * Gia_ManCofactorAig( Aig_Man_t * p, int nFrames, int nCofFanLit );
+ sat_solver * pSat;
+ Cnf_Dat_t * pCnf;
+ Aig_Man_t * pFrames, * pAigTemp;
Aig_Obj_t * pObj;
- int i, VarNum, Lit, RetValue;
- assert( Vec_PtrSize(p->vTargets) > 0 );
- if ( p->pSat->qtail != p->pSat->qhead )
+ int status, clk, Lit, i, RetValue = -1;
+
+ // derive the timeframes
+ clk = clock();
+ if ( nCofFanLit )
{
- RetValue = sat_solver_simplify(p->pSat);
- assert( RetValue != 0 );
+ pFrames = Gia_ManCofactorAig( pAig, nFrames, nCofFanLit );
+ if ( pFrames == NULL )
+ return -1;
}
- Vec_PtrForEachEntry( p->vTargets, pObj, i )
+ else if ( nSizeMax > 0 )
{
- if ( ((*pnOutsSolved)++ / Saig_ManPoNum(p->pAig)) < nStart )
- continue;
- if ( p->pSat->stats.conflicts > p->nConfMaxAll )
- return l_Undef;
- VarNum = Saig_BmcSatNum( p, Aig_Regular(pObj) );
- Lit = toLitCond( VarNum, Aig_IsComplement(pObj) );
- RetValue = sat_solver_solve( p->pSat, &Lit, &Lit + 1, (ABC_INT64_T)p->nConfMaxOne, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
- if ( RetValue == l_False ) // unsat
- continue;
- if ( RetValue == l_Undef ) // undecided
- return l_Undef;
- // generate counter-example
- Saig_BmcDeriveFailed( p, i );
- p->pAig->pSeqModel = Saig_BmcGenerateCounterExample( p );
-
- {
-// extern Vec_Int_t * Saig_ManExtendCounterExampleTest( Aig_Man_t * p, int iFirstPi, void * pCex );
-// Saig_ManExtendCounterExampleTest( p->pAig, 0, p->pAig->pSeqModel );
- }
- return l_True;
+ pFrames = Saig_ManFramesBmcLimit( pAig, nFrames, nSizeMax );
+ nFrames = Aig_ManPoNum(pFrames) / Saig_ManPoNum(pAig) + ((Aig_ManPoNum(pFrames) % Saig_ManPoNum(pAig)) > 0);
}
- return l_False;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Saig_BmcAddTargetsAsPos( Saig_Bmc_t * p )
-{
- Aig_Obj_t * pObj;
- int i;
- Vec_PtrForEachEntry( p->vTargets, pObj, i )
- Aig_ObjCreatePo( p->pFrm, pObj );
- Aig_ManPrintStats( p->pFrm );
- Aig_ManCleanup( p->pFrm );
- Aig_ManPrintStats( p->pFrm );
-}
-
-/**Function*************************************************************
-
- Synopsis [Performs BMC with the given parameters.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Saig_BmcPerform( Aig_Man_t * pAig, int nStart, int nFramesMax, int nNodesMax, int nTimeOut, int nConfMaxOne, int nConfMaxAll, int fVerbose, int fVerbOverwrite )
-{
- Saig_Bmc_t * p;
- Aig_Man_t * pNew;
- Cnf_Dat_t * pCnf;
- int nOutsSolved = 0;
- int Iter, RetValue, clk = clock(), clk2;
-/*
- Vec_Ptr_t * vSimInfo;
- vSimInfo = Abs_ManTernarySimulate( pAig, nFramesMax, fVerbose );
- Abs_ManFreeAray( vSimInfo );
-*/
- p = Saig_BmcManStart( pAig, nFramesMax, nNodesMax, nConfMaxOne, nConfMaxAll, fVerbose );
+ else
+ pFrames = Saig_ManFramesBmc( pAig, nFrames );
+ if ( piFrame )
+ *piFrame = nFrames;
if ( fVerbose )
{
printf( "AIG: PI/PO/Reg = %d/%d/%d. Node = %6d. Lev = %5d.\n",
Saig_ManPiNum(pAig), Saig_ManPoNum(pAig), Saig_ManRegNum(pAig),
Aig_ManNodeNum(pAig), Aig_ManLevelNum(pAig) );
- printf( "Params: FramesMax = %d. NodesDelta = %d. ConfMaxOne = %d. ConfMaxAll = %d.\n",
- nFramesMax, nNodesMax, nConfMaxOne, nConfMaxAll );
- }
-
- for ( Iter = 0; ; Iter++ )
+ printf( "Time-frames (%d): PI/PO = %d/%d. Node = %6d. Lev = %5d. ",
+ nFrames, Aig_ManPiNum(pFrames), Aig_ManPoNum(pFrames),
+ Aig_ManNodeNum(pFrames), Aig_ManLevelNum(pFrames) );
+ ABC_PRT( "Time", clock() - clk );
+ fflush( stdout );
+ }
+ // rewrite the timeframes
+ if ( fRewrite )
{
- clk2 = clock();
- // add new logic interval to frames
- Saig_BmcInterval( p );
-// Saig_BmcAddTargetsAsPos( p );
- if ( Vec_PtrSize(p->vTargets) == 0 )
- break;
- // convert logic slice into new AIG
- pNew = Saig_BmcIntervalToAig( p );
- // derive CNF for the new AIG
- pCnf = Cnf_Derive( pNew, Aig_ManPoNum(pNew) );
- Cnf_DataLift( pCnf, p->nSatVars );
- p->nSatVars += pCnf->nVars;
- // add this CNF to the solver
- Saig_BmcLoadCnf( p, pCnf );
- Cnf_DataFree( pCnf );
- Aig_ManStop( pNew );
- // solve the targets
- RetValue = Saig_BmcSolveTargets( p, nStart, &nOutsSolved );
+ clk = clock();
+// pFrames = Dar_ManBalance( pAigTemp = pFrames, 0 );
+ pFrames = Dar_ManRwsat( pAigTemp = pFrames, 1, 0 );
+ Aig_ManStop( pAigTemp );
if ( fVerbose )
{
- printf( "%3d : F = %3d. O =%4d. And = %7d. Var = %7d. Conf = %7d. ",
- Iter, p->iFrameLast, p->iOutputLast, Aig_ManNodeNum(p->pFrm), p->nSatVars, (int)p->pSat->stats.conflicts );
- ABC_PRT( "Time", clock() - clk2 );
+ printf( "Time-frames after rewriting: Node = %6d. Lev = %5d. ",
+ Aig_ManNodeNum(pFrames), Aig_ManLevelNum(pFrames) );
+ ABC_PRT( "Time", clock() - clk );
+ fflush( stdout );
}
- if ( RetValue != l_False )
- break;
}
- if ( RetValue == l_True )
+ // create the SAT solver
+ clk = clock();
+ pCnf = Cnf_Derive( pFrames, Aig_ManPoNum(pFrames) );
+//if ( s_fInterrupt )
+//return -1;
+ pSat = sat_solver_new();
+ sat_solver_setnvars( pSat, pCnf->nVars );
+ for ( i = 0; i < pCnf->nClauses; i++ )
{
- assert( p->iFrameFail * Saig_ManPoNum(p->pAig) + p->iOutputFail + 1 == nOutsSolved );
- printf( "Output %d was asserted in frame %d (use \"write_counter\" to dump a witness). ",
- p->iOutputFail, p->iFrameFail );
+ if ( !sat_solver_addclause( pSat, pCnf->pClauses[i], pCnf->pClauses[i+1] ) )
+ assert( 0 );
}
- else // if ( RetValue == l_False || RetValue == l_Undef )
- printf( "No output was asserted in %d frames. ", p->iFramePrev-1 );
- if ( fVerbOverwrite )
+ if ( fVerbose )
{
- ABC_PRTr( "Time", clock() - clk );
+ printf( "CNF: Variables = %6d. Clauses = %7d. Literals = %8d. ", pCnf->nVars, pCnf->nClauses, pCnf->nLiterals );
+ ABC_PRT( "Time", clock() - clk );
+ fflush( stdout );
}
- else
+ status = sat_solver_simplify(pSat);
+ if ( status == 0 )
{
- ABC_PRT( "Time", clock() - clk );
+ if ( fVerbose )
+ {
+ printf( "The BMC problem is trivially UNSAT\n" );
+ fflush( stdout );
+ }
}
- if ( RetValue != l_True )
+ else
{
- if ( p->iFrameLast >= p->nFramesMax )
- printf( "Reached limit on the number of timeframes (%d).\n", p->nFramesMax );
- else if ( p->pSat->stats.conflicts > p->nConfMaxAll )
- printf( "Reached global conflict limit (%d).\n", p->nConfMaxAll );
- else
- printf( "Reached local conflict limit (%d).\n", p->nConfMaxOne );
+ int clkPart = clock();
+ Aig_ManForEachPo( pFrames, pObj, i )
+ {
+//if ( s_fInterrupt )
+//return -1;
+ Lit = toLitCond( pCnf->pVarNums[pObj->Id], 0 );
+ if ( fVerbose )
+ {
+ printf( "Solving output %2d of frame %3d ... \r",
+ i % Saig_ManPoNum(pAig), i / Saig_ManPoNum(pAig) );
+ }
+ clk = clock();
+ status = sat_solver_solve( pSat, &Lit, &Lit + 1, (ABC_INT64_T)nConfLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
+ if ( fVerbose && (i % Saig_ManPoNum(pAig) == Saig_ManPoNum(pAig) - 1) )
+ {
+ printf( "Solved %2d outputs of frame %3d. ",
+ Saig_ManPoNum(pAig), i / Saig_ManPoNum(pAig) );
+ printf( "Conf =%8.0f. Imp =%11.0f. ", (double)pSat->stats.conflicts, (double)pSat->stats.propagations );
+ ABC_PRT( "T", clock() - clkPart );
+ clkPart = clock();
+ fflush( stdout );
+ }
+ if ( status == l_False )
+ {
+/*
+ Lit = lit_neg( Lit );
+ RetValue = sat_solver_addclause( pSat, &Lit, &Lit + 1 );
+ assert( RetValue );
+ if ( pSat->qtail != pSat->qhead )
+ {
+ RetValue = sat_solver_simplify(pSat);
+ assert( RetValue );
+ }
+*/
+ }
+ else if ( status == l_True )
+ {
+// extern void * Fra_SmlCopyCounterExample( Aig_Man_t * pAig, Aig_Man_t * pFrames, int * pModel );
+ Vec_Int_t * vCiIds = Cnf_DataCollectPiSatNums( pCnf, pFrames );
+ int * pModel = Sat_SolverGetModel( pSat, vCiIds->pArray, vCiIds->nSize );
+ pModel[Aig_ManPiNum(pFrames)] = pObj->Id;
+ pAig->pSeqModel = (Abc_Cex_t *)Fra_SmlCopyCounterExample( pAig, pFrames, pModel );
+ ABC_FREE( pModel );
+ Vec_IntFree( vCiIds );
+
+ if ( piFrame )
+ *piFrame = i / Saig_ManPoNum(pAig);
+ RetValue = 0;
+ break;
+ }
+ else
+ {
+ if ( piFrame )
+ *piFrame = i / Saig_ManPoNum(pAig);
+ RetValue = -1;
+ break;
+ }
+ }
}
- Saig_BmcManStop( p );
+ sat_solver_delete( pSat );
+ Cnf_DataFree( pCnf );
+ Aig_ManStop( pFrames );
+ return RetValue;
}
-
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/saig/saigBmc2.c b/src/aig/saig/saigBmc2.c
index 240168e6..c7129c67 100644
--- a/src/aig/saig/saigBmc2.c
+++ b/src/aig/saig/saigBmc2.c
@@ -21,67 +21,207 @@
#include "saig.h"
#include "cnf.h"
#include "satStore.h"
+#include "ssw.h"
+
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
+#define AIG_VISITED ((Aig_Obj_t *)(ABC_PTRUINT_T)1)
+
+typedef struct Saig_Bmc_t_ Saig_Bmc_t;
+struct Saig_Bmc_t_
+{
+ // parameters
+ int nFramesMax; // the max number of timeframes to consider
+ int nNodesMax; // the max number of nodes to add
+ int nConfMaxOne; // the max number of conflicts at a target
+ int nConfMaxAll; // the max number of conflicts for all targets
+ int fVerbose; // enables verbose output
+ // AIG managers
+ Aig_Man_t * pAig; // the user's AIG manager
+ Aig_Man_t * pFrm; // Frames manager
+ Vec_Ptr_t * vVisited; // nodes visited in Frames
+ // node mapping
+ int nObjs; // the largest number of an AIG object
+ Vec_Ptr_t * vAig2Frm; // mapping of AIG nodees into Frames nodes
+// Vec_Str_t * vAig2Frm2; // mapping of AIG nodees into Frames nodes
+ // SAT solver
+ sat_solver * pSat; // SAT solver
+ int nSatVars; // the number of used SAT variables
+ Vec_Int_t * vObj2Var; // mapping of frames objects in CNF variables
+ int nStitchVars;
+ // subproblems
+ Vec_Ptr_t * vTargets; // targets to be solved in this interval
+ int iFramePrev; // previous frame
+ int iFrameLast; // last frame
+ int iOutputLast; // last output
+ int iFrameFail; // failed frame
+ int iOutputFail; // failed output
+};
+
+static inline int Saig_BmcSatNum( Saig_Bmc_t * p, Aig_Obj_t * pObj ) { return Vec_IntGetEntry( p->vObj2Var, pObj->Id ); }
+static inline void Saig_BmcSetSatNum( Saig_Bmc_t * p, Aig_Obj_t * pObj, int Num ) { Vec_IntSetEntry(p->vObj2Var, pObj->Id, Num); }
+
+static inline Aig_Obj_t * Saig_BmcObjFrame( Saig_Bmc_t * p, Aig_Obj_t * pObj, int i ) { return (Aig_Obj_t *)Vec_PtrGetEntry( p->vAig2Frm, p->nObjs*i+pObj->Id ); }
+static inline void Saig_BmcObjSetFrame( Saig_Bmc_t * p, Aig_Obj_t * pObj, int i, Aig_Obj_t * pNode ) { Vec_PtrSetEntry( p->vAig2Frm, p->nObjs*i+pObj->Id, pNode ); }
+
+static inline Aig_Obj_t * Saig_BmcObjChild0( Saig_Bmc_t * p, Aig_Obj_t * pObj, int i ) { assert( !Aig_IsComplement(pObj) ); return Aig_NotCond(Saig_BmcObjFrame(p, Aig_ObjFanin0(pObj), i), Aig_ObjFaninC0(pObj)); }
+static inline Aig_Obj_t * Saig_BmcObjChild1( Saig_Bmc_t * p, Aig_Obj_t * pObj, int i ) { assert( !Aig_IsComplement(pObj) ); return Aig_NotCond(Saig_BmcObjFrame(p, Aig_ObjFanin1(pObj), i), Aig_ObjFaninC1(pObj)); }
+
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
+#define ABS_ZER 1
+#define ABS_ONE 2
+#define ABS_UND 3
+
+static inline int Abs_ManSimInfoNot( int Value )
+{
+ if ( Value == ABS_ZER )
+ return ABS_ONE;
+ if ( Value == ABS_ONE )
+ return ABS_ZER;
+ return ABS_UND;
+}
+
+static inline int Abs_ManSimInfoAnd( int Value0, int Value1 )
+{
+ if ( Value0 == ABS_ZER || Value1 == ABS_ZER )
+ return ABS_ZER;
+ if ( Value0 == ABS_ONE && Value1 == ABS_ONE )
+ return ABS_ONE;
+ return ABS_UND;
+}
+
+static inline int Abs_ManSimInfoGet( Vec_Ptr_t * vSimInfo, Aig_Obj_t * pObj, int iFrame )
+{
+ unsigned * pInfo = (unsigned *)Vec_PtrEntry( vSimInfo, iFrame );
+ return 3 & (pInfo[Aig_ObjId(pObj) >> 4] >> ((Aig_ObjId(pObj) & 15) << 1));
+}
+
+static inline void Abs_ManSimInfoSet( Vec_Ptr_t * vSimInfo, Aig_Obj_t * pObj, int iFrame, int Value )
+{
+ unsigned * pInfo = (unsigned *)Vec_PtrEntry( vSimInfo, iFrame );
+ assert( Value >= ABS_ZER && Value <= ABS_UND );
+ Value ^= Abs_ManSimInfoGet( vSimInfo, pObj, iFrame );
+ pInfo[Aig_ObjId(pObj) >> 4] ^= (Value << ((Aig_ObjId(pObj) & 15) << 1));
+}
+
/**Function*************************************************************
- Synopsis [Create timeframes of the manager for BMC.]
+ Synopsis [Performs ternary simulation for one node.]
- Description [The resulting manager is combinational. POs correspond to \
- the property outputs in each time-frame.]
+ Description []
SideEffects []
SeeAlso []
***********************************************************************/
-Aig_Man_t * Saig_ManFramesBmc( Aig_Man_t * pAig, int nFrames )
+int Abs_ManExtendOneEval_rec( Vec_Ptr_t * vSimInfo, Aig_Man_t * p, Aig_Obj_t * pObj, int iFrame )
{
- Aig_Man_t * pFrames;
- Aig_Obj_t * pObj, * pObjLi, * pObjLo;
- int i, f;
- assert( Saig_ManRegNum(pAig) > 0 );
- pFrames = Aig_ManStart( Aig_ManNodeNum(pAig) * nFrames );
- // map the constant node
- Aig_ManConst1(pAig)->pData = Aig_ManConst1( pFrames );
- // create variables for register outputs
- Saig_ManForEachLo( pAig, pObj, i )
- pObj->pData = Aig_ManConst0( pFrames );
- // add timeframes
- for ( f = 0; f < nFrames; f++ )
+ int Value0, Value1, Value;
+ Value = Abs_ManSimInfoGet( vSimInfo, pObj, iFrame );
+ if ( Value )
+ return Value;
+ if ( Aig_ObjIsPi(pObj) )
{
- // create PI nodes for this frame
- Saig_ManForEachPi( pAig, pObj, i )
- pObj->pData = Aig_ObjCreatePi( pFrames );
- // add internal nodes of this frame
- Aig_ManForEachNode( pAig, pObj, i )
- pObj->pData = Aig_And( pFrames, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
- // create POs for this frame
- Saig_ManForEachPo( pAig, pObj, i )
- Aig_ObjCreatePo( pFrames, Aig_ObjChild0Copy(pObj) );
- if ( f == nFrames - 1 )
- break;
- // save register inputs
- Saig_ManForEachLi( pAig, pObj, i )
- pObj->pData = Aig_ObjChild0Copy(pObj);
- // transfer to register outputs
- Saig_ManForEachLiLo( pAig, pObjLi, pObjLo, i )
- pObjLo->pData = pObjLi->pData;
+ assert( Saig_ObjIsLo(p, pObj) );
+ Value = Abs_ManExtendOneEval_rec( vSimInfo, p, Saig_ObjLoToLi(p, pObj), iFrame-1 );
+ Abs_ManSimInfoSet( vSimInfo, pObj, iFrame, Value );
+ return Value;
+ }
+ Value0 = Abs_ManExtendOneEval_rec( vSimInfo, p, Aig_ObjFanin0(pObj), iFrame );
+ if ( Aig_ObjFaninC0(pObj) )
+ Value0 = Abs_ManSimInfoNot( Value0 );
+ if ( Aig_ObjIsPo(pObj) )
+ {
+ Abs_ManSimInfoSet( vSimInfo, pObj, iFrame, Value0 );
+ return Value0;
}
- Aig_ManCleanup( pFrames );
- return pFrames;
+ assert( Aig_ObjIsNode(pObj) );
+ if ( Value0 == ABS_ZER )
+ Value = ABS_ZER;
+ else
+ {
+ Value1 = Abs_ManExtendOneEval_rec( vSimInfo, p, Aig_ObjFanin1(pObj), iFrame );
+ if ( Aig_ObjFaninC1(pObj) )
+ Value1 = Abs_ManSimInfoNot( Value1 );
+ Value = Abs_ManSimInfoAnd( Value0, Value1 );
+ }
+ Abs_ManSimInfoSet( vSimInfo, pObj, iFrame, Value );
+ assert( Value );
+ return Value;
}
/**Function*************************************************************
- Synopsis [Returns the number of internal nodes that are not counted yet.]
+ Synopsis [Performs ternary simulation for one design.]
+
+ Description [The returned array contains the result of ternary
+ simulation for all the frames where the output could be proved 0.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Ptr_t * Abs_ManTernarySimulate( Aig_Man_t * p, int nFramesMax, int fVerbose )
+{
+ Vec_Ptr_t * vSimInfo;
+ Aig_Obj_t * pObj;
+ int i, f, nFramesLimit, nFrameWords;
+ int clk = clock();
+ assert( Aig_ManRegNum(p) > 0 );
+ // the maximum number of frames will be determined to use at most 200Mb of RAM
+ nFramesLimit = 1 + (200000000 * 4)/Aig_ManObjNum(p);
+ nFramesLimit = ABC_MIN( nFramesLimit, nFramesMax );
+ nFrameWords = Aig_BitWordNum( 2 * Aig_ManObjNum(p) );
+ // allocate simulation info
+ vSimInfo = Vec_PtrAlloc( nFramesLimit );
+ for ( f = 0; f < nFramesLimit; f++ )
+ {
+ Vec_PtrPush( vSimInfo, ABC_CALLOC(unsigned, nFrameWords) );
+ if ( f == 0 )
+ {
+ Saig_ManForEachLo( p, pObj, i )
+ Abs_ManSimInfoSet( vSimInfo, pObj, 0, ABS_ZER );
+ }
+ Abs_ManSimInfoSet( vSimInfo, Aig_ManConst1(p), f, ABS_ONE );
+ Saig_ManForEachPi( p, pObj, i )
+ Abs_ManSimInfoSet( vSimInfo, pObj, f, ABS_UND );
+ Saig_ManForEachPo( p, pObj, i )
+ Abs_ManExtendOneEval_rec( vSimInfo, p, pObj, f );
+ // check if simulation has derived at least one fail or unknown
+ Saig_ManForEachPo( p, pObj, i )
+ if ( Abs_ManSimInfoGet(vSimInfo, pObj, f) != ABS_ZER )
+ {
+ if ( fVerbose )
+ {
+ printf( "Ternary sim found non-zero output in frame %d. Used %5.2f Mb. ",
+ f, 0.25 * (f+1) * Aig_ManObjNum(p) / (1<<20) );
+ ABC_PRT( "Time", clock() - clk );
+ }
+ return vSimInfo;
+ }
+ }
+ if ( fVerbose )
+ {
+ printf( "Ternary sim proved all outputs in the first %d frames. Used %5.2f Mb. ",
+ nFramesLimit, 0.25 * nFramesLimit * Aig_ManObjNum(p) / (1<<20) );
+ ABC_PRT( "Time", clock() - clk );
+ }
+ return vSimInfo;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Free the array of simulation info.]
Description []
@@ -90,83 +230,444 @@ Aig_Man_t * Saig_ManFramesBmc( Aig_Man_t * pAig, int nFrames )
SeeAlso []
***********************************************************************/
-int Saig_ManFramesCount_rec( Aig_Man_t * p, Aig_Obj_t * pObj )
+void Abs_ManFreeAray( Vec_Ptr_t * p )
{
- if ( !Aig_ObjIsNode(pObj) )
- return 0;
- if ( Aig_ObjIsTravIdCurrent(p, pObj) )
- return 0;
- Aig_ObjSetTravIdCurrent(p, pObj);
- return 1 + Saig_ManFramesCount_rec( p, Aig_ObjFanin0(pObj) ) +
- Saig_ManFramesCount_rec( p, Aig_ObjFanin1(pObj) );
+ void * pTemp;
+ int i;
+ Vec_PtrForEachEntry( void *, p, pTemp, i )
+ ABC_FREE( pTemp );
+ Vec_PtrFree( p );
}
+
/**Function*************************************************************
- Synopsis [Create timeframes of the manager for BMC.]
+ Synopsis [Create manager.]
- Description [The resulting manager is combinational. POs correspond to
- the property outputs in each time-frame.
- The unrolling is stopped as soon as the number of nodes in the frames
- exceeds the given maximum size.]
+ Description []
SideEffects []
SeeAlso []
***********************************************************************/
-Aig_Man_t * Saig_ManFramesBmcLimit( Aig_Man_t * pAig, int nFrames, int nSizeMax )
+Saig_Bmc_t * Saig_BmcManStart( Aig_Man_t * pAig, int nFramesMax, int nNodesMax, int nConfMaxOne, int nConfMaxAll, int fVerbose )
{
- Aig_Man_t * pFrames;
- Aig_Obj_t * pObj, * pObjLi, * pObjLo, * pObjPo;
- int i, f, Counter = 0;
- assert( Saig_ManRegNum(pAig) > 0 );
- pFrames = Aig_ManStart( nSizeMax );
- Aig_ManIncrementTravId( pFrames );
- // map the constant node
- Aig_ManConst1(pAig)->pData = Aig_ManConst1( pFrames );
- // create variables for register outputs
+ Saig_Bmc_t * p;
+ Aig_Obj_t * pObj;
+ int i, Lit;
+// assert( Aig_ManRegNum(pAig) > 0 );
+ p = (Saig_Bmc_t *)ABC_ALLOC( char, sizeof(Saig_Bmc_t) );
+ memset( p, 0, sizeof(Saig_Bmc_t) );
+ // set parameters
+ p->nFramesMax = nFramesMax;
+ p->nNodesMax = nNodesMax;
+ p->nConfMaxOne = nConfMaxOne;
+ p->nConfMaxAll = nConfMaxAll;
+ p->fVerbose = fVerbose;
+ p->pAig = pAig;
+ p->nObjs = Aig_ManObjNumMax(pAig);
+ // create node and variable mappings
+ p->vAig2Frm = Vec_PtrAlloc( 0 );
+ Vec_PtrFill( p->vAig2Frm, 5 * p->nObjs, NULL );
+ p->vObj2Var = Vec_IntAlloc( 0 );
+ Vec_IntFill( p->vObj2Var, 5 * p->nObjs, 0 );
+ // start the AIG manager and map primary inputs
+ p->pFrm = Aig_ManStart( 5 * p->nObjs );
Saig_ManForEachLo( pAig, pObj, i )
- pObj->pData = Aig_ManConst0( pFrames );
- // add timeframes
- Counter = 0;
- for ( f = 0; f < nFrames; f++ )
+ Saig_BmcObjSetFrame( p, pObj, 0, Aig_ManConst0(p->pFrm) );
+ // create SAT solver
+ p->nSatVars = 1;
+ p->pSat = sat_solver_new();
+ sat_solver_setnvars( p->pSat, 2000 );
+ Lit = toLit( p->nSatVars );
+ sat_solver_addclause( p->pSat, &Lit, &Lit + 1 );
+ Saig_BmcSetSatNum( p, Aig_ManConst1(p->pFrm), p->nSatVars++ );
+ // other data structures
+ p->vTargets = Vec_PtrAlloc( 0 );
+ p->vVisited = Vec_PtrAlloc( 0 );
+ p->iOutputFail = -1;
+ p->iFrameFail = -1;
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Delete manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Saig_BmcManStop( Saig_Bmc_t * p )
+{
+// Aig_Obj_t * pObj;
+// int i, f, Counter = 0;
+// int i, Counter = 0;
+// for ( i = 0; i < p->vAig2Frm2->nSize; i++ )
+// Counter += (p->vAig2Frm2->pArray[i] != 0);
+// for ( i = 0; i < p->vAig2Frm->nSize; i++ )
+// Counter += (p->vAig2Frm->pArray[i] != NULL);
+// printf( "Objs = %d. Nodes = %d. Frames = %d. Used = %d. Non-empty = %d.\n",
+// p->nObjs, Aig_ManNodeNum(p->pAig), p->iFrameLast, p->vAig2Frm->nSize, Counter );
+
+/*
+ Aig_ManForEachObj( p->pAig, pObj, i )
{
- // create PI nodes for this frame
- Saig_ManForEachPi( pAig, pObj, i )
- pObj->pData = Aig_ObjCreatePi( pFrames );
- // add internal nodes of this frame
- Aig_ManForEachNode( pAig, pObj, i )
- pObj->pData = Aig_And( pFrames, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
- // create POs for this frame
- Saig_ManForEachPo( pAig, pObj, i )
+ int Last = -1;
+ for ( f = 0; f <= p->iFrameLast; f++ )
+ if ( Saig_BmcObjFrame( p, pObj, f ) )
+ Last = f;
+ if ( i % 50 == 0 )
+ printf( "%d ", Last );
+ }
+ printf( "\n" );
+*/
+
+ Aig_ManStop( p->pFrm );
+ Vec_PtrFree( p->vAig2Frm );
+// Vec_StrFree( p->vAig2Frm2 );
+ Vec_IntFree( p->vObj2Var );
+ sat_solver_delete( p->pSat );
+ Vec_PtrFree( p->vTargets );
+ Vec_PtrFree( p->vVisited );
+ ABC_FREE( p );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Explores the possibility of constructing the output.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Obj_t * Saig_BmcIntervalExplore_rec( Saig_Bmc_t * p, Aig_Obj_t * pObj, int i )
+{
+ Aig_Obj_t * pRes, * p0, * p1, * pConst1 = Aig_ManConst1(p->pAig);
+ pRes = Saig_BmcObjFrame( p, pObj, i );
+ if ( pRes != NULL )
+ return pRes;
+ if ( Saig_ObjIsPi( p->pAig, pObj ) )
+ pRes = AIG_VISITED;
+ else if ( Saig_ObjIsLo( p->pAig, pObj ) )
+ pRes = Saig_BmcIntervalExplore_rec( p, Saig_ObjLoToLi(p->pAig, pObj), i-1 );
+ else if ( Aig_ObjIsPo( pObj ) )
+ {
+ pRes = Saig_BmcIntervalExplore_rec( p, Aig_ObjFanin0(pObj), i );
+ if ( pRes != AIG_VISITED )
+ pRes = Saig_BmcObjChild0( p, pObj, i );
+ }
+ else
+ {
+ p0 = Saig_BmcIntervalExplore_rec( p, Aig_ObjFanin0(pObj), i );
+ if ( p0 != AIG_VISITED )
+ p0 = Saig_BmcObjChild0( p, pObj, i );
+ p1 = Saig_BmcIntervalExplore_rec( p, Aig_ObjFanin1(pObj), i );
+ if ( p1 != AIG_VISITED )
+ p1 = Saig_BmcObjChild1( p, pObj, i );
+
+ if ( p0 == Aig_Not(p1) )
+ pRes = Aig_ManConst0(p->pFrm);
+ else if ( Aig_Regular(p0) == pConst1 )
+ pRes = (p0 == pConst1) ? p1 : Aig_ManConst0(p->pFrm);
+ else if ( Aig_Regular(p1) == pConst1 )
+ pRes = (p1 == pConst1) ? p0 : Aig_ManConst0(p->pFrm);
+ else
+ pRes = AIG_VISITED;
+
+ if ( pRes != AIG_VISITED && !Aig_ObjIsConst1(Aig_Regular(pRes)) )
+ pRes = AIG_VISITED;
+ }
+ Saig_BmcObjSetFrame( p, pObj, i, pRes );
+ return pRes;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs the actual construction of the output.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Obj_t * Saig_BmcIntervalConstruct_rec( Saig_Bmc_t * p, Aig_Obj_t * pObj, int i, Vec_Ptr_t * vVisited )
+{
+ Aig_Obj_t * pRes;
+ pRes = Saig_BmcObjFrame( p, pObj, i );
+ if ( pRes != NULL )
+ return pRes;
+ if ( Saig_ObjIsPi( p->pAig, pObj ) )
+ pRes = Aig_ObjCreatePi(p->pFrm);
+ else if ( Saig_ObjIsLo( p->pAig, pObj ) )
+ pRes = Saig_BmcIntervalConstruct_rec( p, Saig_ObjLoToLi(p->pAig, pObj), i-1, vVisited );
+ else if ( Aig_ObjIsPo( pObj ) )
+ {
+ Saig_BmcIntervalConstruct_rec( p, Aig_ObjFanin0(pObj), i, vVisited );
+ pRes = Saig_BmcObjChild0( p, pObj, i );
+ }
+ else
+ {
+ Saig_BmcIntervalConstruct_rec( p, Aig_ObjFanin0(pObj), i, vVisited );
+ if ( Saig_BmcObjChild0(p, pObj, i) == Aig_ManConst0(p->pFrm) )
+ pRes = Aig_ManConst0(p->pFrm);
+ else
+ {
+ Saig_BmcIntervalConstruct_rec( p, Aig_ObjFanin1(pObj), i, vVisited );
+ pRes = Aig_And( p->pFrm, Saig_BmcObjChild0(p, pObj, i), Saig_BmcObjChild1(p, pObj, i) );
+ }
+ }
+ assert( pRes != NULL );
+ Saig_BmcObjSetFrame( p, pObj, i, pRes );
+ Vec_PtrPush( vVisited, pObj );
+ Vec_PtrPush( vVisited, (void *)(ABC_PTRINT_T)i );
+ return pRes;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Adds new AIG nodes to the frames.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Saig_BmcInterval( Saig_Bmc_t * p )
+{
+ Aig_Obj_t * pTarget;
+ Aig_Obj_t * pObj, * pRes;
+ int i, iFrame, Counter;
+ int nNodes = Aig_ManObjNum( p->pFrm );
+ Vec_PtrClear( p->vTargets );
+ p->iFramePrev = p->iFrameLast;
+ for ( ; p->iFrameLast < p->nFramesMax; p->iFrameLast++, p->iOutputLast = 0 )
+ {
+ if ( p->iOutputLast == 0 )
{
- pObjPo = Aig_ObjCreatePo( pFrames, Aig_ObjChild0Copy(pObj) );
- Counter += Saig_ManFramesCount_rec( pFrames, Aig_ObjFanin0(pObjPo) );
+ Saig_BmcObjSetFrame( p, Aig_ManConst1(p->pAig), p->iFrameLast, Aig_ManConst1(p->pFrm) );
}
- if ( Counter >= nSizeMax )
+ for ( ; p->iOutputLast < Saig_ManPoNum(p->pAig); p->iOutputLast++ )
{
- Aig_ManCleanup( pFrames );
- return pFrames;
+ if ( Aig_ManObjNum(p->pFrm) >= nNodes + p->nNodesMax )
+ return;
+// Saig_BmcIntervalExplore_rec( p, Aig_ManPo(p->pAig, p->iOutputLast), p->iFrameLast );
+ Vec_PtrClear( p->vVisited );
+ pTarget = Saig_BmcIntervalConstruct_rec( p, Aig_ManPo(p->pAig, p->iOutputLast), p->iFrameLast, p->vVisited );
+ Vec_PtrPush( p->vTargets, pTarget );
+ Aig_ObjCreatePo( p->pFrm, pTarget );
+ Aig_ManCleanup( p->pFrm );
+ // check if the node is gone
+ Counter = 0;
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vVisited, pObj, i )
+ {
+ iFrame = (int)(ABC_PTRINT_T)Vec_PtrEntry( p->vVisited, 1+i++ );
+ pRes = Saig_BmcObjFrame( p, pObj, iFrame );
+ if ( Aig_ObjIsNone( Aig_Regular(pRes) ) )
+ {
+ Saig_BmcObjSetFrame( p, pObj, iFrame, NULL );
+ Counter++;
+ }
+ }
+// printf( "%d ", Counter );
}
- if ( f == nFrames - 1 )
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs the actual construction of the output.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Obj_t * Saig_BmcIntervalToAig_rec( Saig_Bmc_t * p, Aig_Man_t * pNew, Aig_Obj_t * pObj )
+{
+ if ( pObj->pData )
+ return (Aig_Obj_t *)pObj->pData;
+ Vec_PtrPush( p->vVisited, pObj );
+ if ( Saig_BmcSatNum(p, pObj) || Aig_ObjIsPi(pObj) )
+ {
+ p->nStitchVars += !Aig_ObjIsPi(pObj);
+ return (Aig_Obj_t *)(pObj->pData = Aig_ObjCreatePi(pNew));
+ }
+ Saig_BmcIntervalToAig_rec( p, pNew, Aig_ObjFanin0(pObj) );
+ Saig_BmcIntervalToAig_rec( p, pNew, Aig_ObjFanin1(pObj) );
+ assert( pObj->pData == NULL );
+ return (Aig_Obj_t *)(pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) ));
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates AIG of the newly added nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Man_t * Saig_BmcIntervalToAig( Saig_Bmc_t * p )
+{
+ Aig_Man_t * pNew;
+ Aig_Obj_t * pObj, * pObjNew;
+ int i;
+ Aig_ManForEachObj( p->pFrm, pObj, i )
+ assert( pObj->pData == NULL );
+
+ pNew = Aig_ManStart( p->nNodesMax );
+ Aig_ManConst1(p->pFrm)->pData = Aig_ManConst1(pNew);
+ Vec_PtrClear( p->vVisited );
+ Vec_PtrPush( p->vVisited, Aig_ManConst1(p->pFrm) );
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vTargets, pObj, i )
+ {
+// assert( !Aig_ObjIsConst1(Aig_Regular(pObj)) );
+ pObjNew = Saig_BmcIntervalToAig_rec( p, pNew, Aig_Regular(pObj) );
+ assert( !Aig_IsComplement(pObjNew) );
+ Aig_ObjCreatePo( pNew, pObjNew );
+ }
+ return pNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Derives CNF for the newly added nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Saig_BmcLoadCnf( Saig_Bmc_t * p, Cnf_Dat_t * pCnf )
+{
+ Aig_Obj_t * pObj, * pObjNew;
+ int i, Lits[2], VarNumOld, VarNumNew;
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vVisited, pObj, i )
+ {
+ // get the new variable of this node
+ pObjNew = (Aig_Obj_t *)pObj->pData;
+ pObj->pData = NULL;
+ VarNumNew = pCnf->pVarNums[ pObjNew->Id ];
+ if ( VarNumNew == -1 )
+ continue;
+ // get the old variable of this node
+ VarNumOld = Saig_BmcSatNum( p, pObj );
+ if ( VarNumOld == 0 )
+ {
+ Saig_BmcSetSatNum( p, pObj, VarNumNew );
+ continue;
+ }
+ // add clauses connecting existing variables
+ Lits[0] = toLitCond( VarNumOld, 0 );
+ Lits[1] = toLitCond( VarNumNew, 1 );
+ if ( !sat_solver_addclause( p->pSat, Lits, Lits+2 ) )
+ assert( 0 );
+ Lits[0] = toLitCond( VarNumOld, 1 );
+ Lits[1] = toLitCond( VarNumNew, 0 );
+ if ( !sat_solver_addclause( p->pSat, Lits, Lits+2 ) )
+ assert( 0 );
+ }
+ // add CNF to the SAT solver
+ for ( i = 0; i < pCnf->nClauses; i++ )
+ if ( !sat_solver_addclause( p->pSat, pCnf->pClauses[i], pCnf->pClauses[i+1] ) )
break;
- // save register inputs
- Saig_ManForEachLi( pAig, pObj, i )
- pObj->pData = Aig_ObjChild0Copy(pObj);
- // transfer to register outputs
- Saig_ManForEachLiLo( pAig, pObjLi, pObjLo, i )
- pObjLo->pData = pObjLi->pData;
+ if ( i < pCnf->nClauses )
+ printf( "SAT solver became UNSAT after adding clauses.\n" );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Solves targets with the given resource limit.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Saig_BmcDeriveFailed( Saig_Bmc_t * p, int iTargetFail )
+{
+ int k;
+ p->iOutputFail = p->iOutputLast;
+ p->iFrameFail = p->iFrameLast;
+ for ( k = Vec_PtrSize(p->vTargets); k > iTargetFail; k-- )
+ {
+ if ( p->iOutputFail == 0 )
+ {
+ p->iOutputFail = Saig_ManPoNum(p->pAig);
+ p->iFrameFail--;
+ }
+ p->iOutputFail--;
}
- Aig_ManCleanup( pFrames );
- return pFrames;
}
-#include "utilMem.h"
+/**Function*************************************************************
+
+ Synopsis [Solves targets with the given resource limit.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Abc_Cex_t * Saig_BmcGenerateCounterExample( Saig_Bmc_t * p )
+{
+ Abc_Cex_t * pCex;
+ Aig_Obj_t * pObj, * pObjFrm;
+ int i, f, iVarNum;
+ // start the counter-example
+ pCex = Ssw_SmlAllocCounterExample( Aig_ManRegNum(p->pAig), Saig_ManPiNum(p->pAig), p->iFrameFail+1 );
+ pCex->iFrame = p->iFrameFail;
+ pCex->iPo = p->iOutputFail;
+ // copy the bit data
+ for ( f = 0; f <= p->iFrameFail; f++ )
+ {
+ Saig_ManForEachPi( p->pAig, pObj, i )
+ {
+ pObjFrm = Saig_BmcObjFrame( p, pObj, f );
+ if ( pObjFrm == NULL )
+ continue;
+ iVarNum = Saig_BmcSatNum( p, pObjFrm );
+ if ( iVarNum == 0 )
+ continue;
+ if ( sat_solver_var_value( p->pSat, iVarNum ) )
+ Aig_InfoSetBit( pCex->pData, pCex->nRegs + Saig_ManPiNum(p->pAig) * f + i );
+ }
+ }
+ // verify the counter example
+ if ( !Ssw_SmlRunCounterExample( p->pAig, pCex ) )
+ {
+ printf( "Saig_BmcGenerateCounterExample(): Counter-example is invalid.\n" );
+ Ssw_SmlFreeCounterExample( pCex );
+ pCex = NULL;
+ }
+ return pCex;
+}
/**Function*************************************************************
- Synopsis [Performs BMC for the given AIG.]
+ Synopsis [Solves targets with the given resource limit.]
Description []
@@ -175,154 +676,178 @@ Aig_Man_t * Saig_ManFramesBmcLimit( Aig_Man_t * pAig, int nFrames, int nSizeMax
SeeAlso []
***********************************************************************/
-int Saig_ManBmcSimple( Aig_Man_t * pAig, int nFrames, int nSizeMax, int nConfLimit, int fRewrite, int fVerbose, int * piFrame, int nCofFanLit )
+int Saig_BmcSolveTargets( Saig_Bmc_t * p, int nStart, int * pnOutsSolved )
{
- extern Aig_Man_t * Gia_ManCofactorAig( Aig_Man_t * p, int nFrames, int nCofFanLit );
- sat_solver * pSat;
- Cnf_Dat_t * pCnf;
- Aig_Man_t * pFrames, * pAigTemp;
Aig_Obj_t * pObj;
- int status, clk, Lit, i, RetValue = 1;
-
- // derive the timeframes
- clk = clock();
- if ( nCofFanLit )
+ int i, VarNum, Lit, RetValue;
+ assert( Vec_PtrSize(p->vTargets) > 0 );
+ if ( p->pSat->qtail != p->pSat->qhead )
{
- pFrames = Gia_ManCofactorAig( pAig, nFrames, nCofFanLit );
- if ( pFrames == NULL )
- return -1;
+ RetValue = sat_solver_simplify(p->pSat);
+ assert( RetValue != 0 );
}
- else if ( nSizeMax > 0 )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vTargets, pObj, i )
{
- pFrames = Saig_ManFramesBmcLimit( pAig, nFrames, nSizeMax );
- nFrames = Aig_ManPoNum(pFrames) / Saig_ManPoNum(pAig) + ((Aig_ManPoNum(pFrames) % Saig_ManPoNum(pAig)) > 0);
+ if ( ((*pnOutsSolved)++ / Saig_ManPoNum(p->pAig)) < nStart )
+ continue;
+ if ( p->nConfMaxAll && p->pSat->stats.conflicts > p->nConfMaxAll )
+ return l_Undef;
+ VarNum = Saig_BmcSatNum( p, Aig_Regular(pObj) );
+ Lit = toLitCond( VarNum, Aig_IsComplement(pObj) );
+ RetValue = sat_solver_solve( p->pSat, &Lit, &Lit + 1, (ABC_INT64_T)p->nConfMaxOne, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
+ if ( RetValue == l_False ) // unsat
+ continue;
+ if ( RetValue == l_Undef ) // undecided
+ return l_Undef;
+ // generate counter-example
+ Saig_BmcDeriveFailed( p, i );
+ p->pAig->pSeqModel = Saig_BmcGenerateCounterExample( p );
+
+ {
+// extern Vec_Int_t * Saig_ManExtendCounterExampleTest( Aig_Man_t * p, int iFirstPi, void * pCex );
+// Saig_ManExtendCounterExampleTest( p->pAig, 0, p->pAig->pSeqModel );
+ }
+ return l_True;
}
- else
- pFrames = Saig_ManFramesBmc( pAig, nFrames );
- if ( piFrame )
- *piFrame = nFrames;
+ return l_False;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Saig_BmcAddTargetsAsPos( Saig_Bmc_t * p )
+{
+ Aig_Obj_t * pObj;
+ int i;
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vTargets, pObj, i )
+ Aig_ObjCreatePo( p->pFrm, pObj );
+ Aig_ManPrintStats( p->pFrm );
+ Aig_ManCleanup( p->pFrm );
+ Aig_ManPrintStats( p->pFrm );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs BMC with the given parameters.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Saig_BmcPerform( Aig_Man_t * pAig, int nStart, int nFramesMax, int nNodesMax, int nTimeOut, int nConfMaxOne, int nConfMaxAll, int fVerbose, int fVerbOverwrite, int * piFrames )
+{
+ Saig_Bmc_t * p;
+ Aig_Man_t * pNew;
+ Cnf_Dat_t * pCnf;
+ int nOutsSolved = 0;
+ int Iter, RetValue, clk = clock(), clk2, clkTotal = clock();
+ int Status = -1;
+/*
+ Vec_Ptr_t * vSimInfo;
+ vSimInfo = Abs_ManTernarySimulate( pAig, nFramesMax, fVerbose );
+ Abs_ManFreeAray( vSimInfo );
+*/
+ p = Saig_BmcManStart( pAig, nFramesMax, nNodesMax, nConfMaxOne, nConfMaxAll, fVerbose );
if ( fVerbose )
{
printf( "AIG: PI/PO/Reg = %d/%d/%d. Node = %6d. Lev = %5d.\n",
Saig_ManPiNum(pAig), Saig_ManPoNum(pAig), Saig_ManRegNum(pAig),
Aig_ManNodeNum(pAig), Aig_ManLevelNum(pAig) );
- printf( "Time-frames (%d): PI/PO = %d/%d. Node = %6d. Lev = %5d. ",
- nFrames, Aig_ManPiNum(pFrames), Aig_ManPoNum(pFrames),
- Aig_ManNodeNum(pFrames), Aig_ManLevelNum(pFrames) );
- ABC_PRT( "Time", clock() - clk );
- fflush( stdout );
- }
- // rewrite the timeframes
- if ( fRewrite )
+ printf( "Params: FramesMax = %d. NodesDelta = %d. ConfMaxOne = %d. ConfMaxAll = %d.\n",
+ nFramesMax, nNodesMax, nConfMaxOne, nConfMaxAll );
+ }
+
+ for ( Iter = 0; ; Iter++ )
{
- clk = clock();
-// pFrames = Dar_ManBalance( pAigTemp = pFrames, 0 );
- pFrames = Dar_ManRwsat( pAigTemp = pFrames, 1, 0 );
- Aig_ManStop( pAigTemp );
+ clk2 = clock();
+ // add new logic interval to frames
+ Saig_BmcInterval( p );
+// Saig_BmcAddTargetsAsPos( p );
+ if ( Vec_PtrSize(p->vTargets) == 0 )
+ break;
+ // convert logic slice into new AIG
+ pNew = Saig_BmcIntervalToAig( p );
+//printf( "StitchVars = %d.\n", p->nStitchVars );
+ // derive CNF for the new AIG
+ pCnf = Cnf_Derive( pNew, Aig_ManPoNum(pNew) );
+ Cnf_DataLift( pCnf, p->nSatVars );
+ p->nSatVars += pCnf->nVars;
+ // add this CNF to the solver
+ Saig_BmcLoadCnf( p, pCnf );
+ Cnf_DataFree( pCnf );
+ Aig_ManStop( pNew );
+ // solve the targets
+ RetValue = Saig_BmcSolveTargets( p, nStart, &nOutsSolved );
if ( fVerbose )
{
- printf( "Time-frames after rewriting: Node = %6d. Lev = %5d. ",
- Aig_ManNodeNum(pFrames), Aig_ManLevelNum(pFrames) );
- ABC_PRT( "Time", clock() - clk );
- fflush( stdout );
+ printf( "%3d : F = %3d. O =%4d. And = %7d. Var = %7d. Conf = %7d. ",
+ Iter, p->iFrameLast, p->iOutputLast, Aig_ManNodeNum(p->pFrm), p->nSatVars, (int)p->pSat->stats.conflicts );
+ ABC_PRT( "Time", clock() - clk2 );
+ }
+ if ( RetValue != l_False )
+ break;
+ // check the timeout
+ if ( nTimeOut && ((float)nTimeOut <= (float)(clock()-clkTotal)/(float)(CLOCKS_PER_SEC)) )
+ {
+ printf( "Reached timeout (%d seconds).\n", nTimeOut );
+ Saig_BmcManStop( p );
+ if ( piFrames )
+ *piFrames = p->iFrameLast-1;
+ return Status;
}
}
- // create the SAT solver
- clk = clock();
- pCnf = Cnf_Derive( pFrames, Aig_ManPoNum(pFrames) );
-//if ( s_fInterrupt )
-//return -1;
- pSat = sat_solver_new();
- sat_solver_setnvars( pSat, pCnf->nVars );
- for ( i = 0; i < pCnf->nClauses; i++ )
+ if ( RetValue == l_True )
{
- if ( !sat_solver_addclause( pSat, pCnf->pClauses[i], pCnf->pClauses[i+1] ) )
- assert( 0 );
+ assert( p->iFrameFail * Saig_ManPoNum(p->pAig) + p->iOutputFail + 1 == nOutsSolved );
+ printf( "Output %d was asserted in frame %d (use \"write_counter\" to dump a witness). ",
+ p->iOutputFail, p->iFrameFail );
+ Status = 0;
+ if ( piFrames )
+ *piFrames = p->iFrameFail;
}
- if ( fVerbose )
+ else // if ( RetValue == l_False || RetValue == l_Undef )
{
- printf( "CNF: Variables = %6d. Clauses = %7d. Literals = %8d. ", pCnf->nVars, pCnf->nClauses, pCnf->nLiterals );
- ABC_PRT( "Time", clock() - clk );
- fflush( stdout );
+ printf( "No output was asserted in %d frames. ", p->iFramePrev-1 );
+ if ( piFrames )
+ *piFrames = p->iFramePrev-1;
}
- status = sat_solver_simplify(pSat);
- if ( status == 0 )
+ if ( fVerbOverwrite )
{
- if ( fVerbose )
- {
- printf( "The BMC problem is trivially UNSAT\n" );
- fflush( stdout );
- }
+ ABC_PRTr( "Time", clock() - clk );
}
else
{
- int clkPart = clock();
- Aig_ManForEachPo( pFrames, pObj, i )
- {
-//if ( s_fInterrupt )
-//return -1;
- Lit = toLitCond( pCnf->pVarNums[pObj->Id], 0 );
- if ( fVerbose )
- {
- printf( "Solving output %2d of frame %3d ... \r",
- i % Saig_ManPoNum(pAig), i / Saig_ManPoNum(pAig) );
- }
- clk = clock();
- status = sat_solver_solve( pSat, &Lit, &Lit + 1, (ABC_INT64_T)nConfLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
- if ( fVerbose && (i % Saig_ManPoNum(pAig) == Saig_ManPoNum(pAig) - 1) )
- {
- printf( "Solved %2d outputs of frame %3d. ",
- Saig_ManPoNum(pAig), i / Saig_ManPoNum(pAig) );
- printf( "Conf =%8.0f. Imp =%11.0f. ", (double)pSat->stats.conflicts, (double)pSat->stats.propagations );
- ABC_PRT( "T", clock() - clkPart );
- clkPart = clock();
- fflush( stdout );
- }
- if ( status == l_False )
- {
-/*
- Lit = lit_neg( Lit );
- RetValue = sat_solver_addclause( pSat, &Lit, &Lit + 1 );
- assert( RetValue );
- if ( pSat->qtail != pSat->qhead )
- {
- RetValue = sat_solver_simplify(pSat);
- assert( RetValue );
- }
-*/
- }
- else if ( status == l_True )
- {
- extern void * Fra_SmlCopyCounterExample( Aig_Man_t * pAig, Aig_Man_t * pFrames, int * pModel );
- Vec_Int_t * vCiIds = Cnf_DataCollectPiSatNums( pCnf, pFrames );
- int * pModel = Sat_SolverGetModel( pSat, vCiIds->pArray, vCiIds->nSize );
- pModel[Aig_ManPiNum(pFrames)] = pObj->Id;
- pAig->pSeqModel = Fra_SmlCopyCounterExample( pAig, pFrames, pModel );
- ABC_FREE( pModel );
- Vec_IntFree( vCiIds );
-
-// if ( piFrame )
-// *piFrame = i / Saig_ManPoNum(pAig);
- RetValue = 0;
- break;
- }
- else
- {
- if ( piFrame )
- *piFrame = i / Saig_ManPoNum(pAig);
- RetValue = -1;
- break;
- }
- }
+ ABC_PRT( "Time", clock() - clk );
}
- sat_solver_delete( pSat );
- Cnf_DataFree( pCnf );
- Aig_ManStop( pFrames );
- return RetValue;
+ if ( RetValue != l_True )
+ {
+ if ( p->iFrameLast >= p->nFramesMax )
+ printf( "Reached limit on the number of timeframes (%d).\n", p->nFramesMax );
+ else if ( p->pSat->stats.conflicts > p->nConfMaxAll )
+ printf( "Reached global conflict limit (%d).\n", p->nConfMaxAll );
+ else
+ printf( "Reached local conflict limit (%d).\n", p->nConfMaxOne );
+ }
+ Saig_BmcManStop( p );
+ return Status;
}
+
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/saig/saigBmc3.c b/src/aig/saig/saigBmc3.c
new file mode 100644
index 00000000..a75297f7
--- /dev/null
+++ b/src/aig/saig/saigBmc3.c
@@ -0,0 +1,1227 @@
+/**CFile****************************************************************
+
+ FileName [saigBmc3.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Sequential AIG package.]
+
+ Synopsis [Simple BMC package.]
+
+ Author [Alan Mishchenko in collaboration with Niklas Een.]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: saigBmc3.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "saig.h"
+#include "fra.h"
+#include "cnf.h"
+#include "satStore.h"
+
+ABC_NAMESPACE_IMPL_START
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+typedef struct Gia_ManBmc_t_ Gia_ManBmc_t;
+struct Gia_ManBmc_t_
+{
+ // input/output data
+ Saig_ParBmc_t * pPars; // parameters
+ Aig_Man_t * pAig; // user AIG
+ Vec_Ptr_t * vCexes; // counter-examples
+ // intermediate data
+ Vec_Int_t * vMapping; // mapping
+ Vec_Vec_t * vSects; // sections
+ Vec_Int_t * vId2Num; // number of each node
+ Vec_Int_t * vVisited; // visited nodes
+ // SAT variables
+ Vec_Int_t * vPiVars; // SAT vars for the PIs
+ Vec_Ptr_t * vId2Var; // SAT vars for each object
+ // SAT solver
+ sat_solver * pSat; // SAT solver
+ int nSatVars; // SAT variables
+ int nObjNums; // SAT objects
+ int nBufNum; // the number of simple nodes
+ int nDupNum; // the number of simple nodes
+ char * pSopSizes, ** pSops; // CNF representation
+};
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+#define SAIG_TER_ZER 1
+#define SAIG_TER_ONE 2
+#define SAIG_TER_UND 3
+
+static inline int Saig_ManBmcSimInfoNot( int Value )
+{
+ if ( Value == SAIG_TER_ZER )
+ return SAIG_TER_ONE;
+ if ( Value == SAIG_TER_ONE )
+ return SAIG_TER_ZER;
+ return SAIG_TER_UND;
+}
+
+static inline int Saig_ManBmcSimInfoAnd( int Value0, int Value1 )
+{
+ if ( Value0 == SAIG_TER_ZER || Value1 == SAIG_TER_ZER )
+ return SAIG_TER_ZER;
+ if ( Value0 == SAIG_TER_ONE && Value1 == SAIG_TER_ONE )
+ return SAIG_TER_ONE;
+ return SAIG_TER_UND;
+}
+
+static inline int Saig_ManBmcSimInfoGet( unsigned * pInfo, Aig_Obj_t * pObj )
+{
+ return 3 & (pInfo[Aig_ObjId(pObj) >> 4] >> ((Aig_ObjId(pObj) & 15) << 1));
+}
+
+static inline void Saig_ManBmcSimInfoSet( unsigned * pInfo, Aig_Obj_t * pObj, int Value )
+{
+ assert( Value >= SAIG_TER_ZER && Value <= SAIG_TER_UND );
+ Value ^= Saig_ManBmcSimInfoGet( pInfo, pObj );
+ pInfo[Aig_ObjId(pObj) >> 4] ^= (Value << ((Aig_ObjId(pObj) & 15) << 1));
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the number of LIs with binary ternary info.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Saig_ManBmcTerSimCount01( Aig_Man_t * p, unsigned * pInfo )
+{
+ Aig_Obj_t * pObj;
+ int i, Counter = 0;
+ if ( pInfo == NULL )
+ return Saig_ManRegNum(p);
+ Saig_ManForEachLi( p, pObj, i )
+ if ( !Aig_ObjIsConst1(Aig_ObjFanin0(pObj)) )
+ Counter += (Saig_ManBmcSimInfoGet(pInfo, pObj) != SAIG_TER_UND);
+ return Counter;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs ternary simulation of one frame.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+unsigned * Saig_ManBmcTerSimOne( Aig_Man_t * p, unsigned * pPrev )
+{
+ Aig_Obj_t * pObj, * pObjLi;
+ unsigned * pInfo;
+ int i, Val0, Val1;
+ pInfo = ABC_CALLOC( unsigned, Aig_BitWordNum(2 * Aig_ManObjNumMax(p)) );
+ Saig_ManBmcSimInfoSet( pInfo, Aig_ManConst1(p), SAIG_TER_ONE );
+ Saig_ManForEachPi( p, pObj, i )
+ Saig_ManBmcSimInfoSet( pInfo, pObj, SAIG_TER_UND );
+ if ( pPrev == NULL )
+ {
+ Saig_ManForEachLo( p, pObj, i )
+ Saig_ManBmcSimInfoSet( pInfo, pObj, SAIG_TER_ZER );
+ }
+ else
+ {
+ Saig_ManForEachLiLo( p, pObjLi, pObj, i )
+ Saig_ManBmcSimInfoSet( pInfo, pObj, Saig_ManBmcSimInfoGet(pPrev, pObjLi) );
+ }
+ Aig_ManForEachNode( p, pObj, i )
+ {
+ Val0 = Saig_ManBmcSimInfoGet( pInfo, Aig_ObjFanin0(pObj) );
+ Val1 = Saig_ManBmcSimInfoGet( pInfo, Aig_ObjFanin1(pObj) );
+ if ( Aig_ObjFaninC0(pObj) )
+ Val0 = Saig_ManBmcSimInfoNot( Val0 );
+ if ( Aig_ObjFaninC1(pObj) )
+ Val1 = Saig_ManBmcSimInfoNot( Val1 );
+ Saig_ManBmcSimInfoSet( pInfo, pObj, Saig_ManBmcSimInfoAnd(Val0, Val1) );
+ }
+ Aig_ManForEachPo( p, pObj, i )
+ {
+ Val0 = Saig_ManBmcSimInfoGet( pInfo, Aig_ObjFanin0(pObj) );
+ if ( Aig_ObjFaninC0(pObj) )
+ Val0 = Saig_ManBmcSimInfoNot( Val0 );
+ Saig_ManBmcSimInfoSet( pInfo, pObj, Val0 );
+ }
+ return pInfo;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Collects internal nodes and PIs in the DFS order.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Ptr_t * Saig_ManBmcTerSim( Aig_Man_t * p )
+{
+ Vec_Ptr_t * vInfos;
+ unsigned * pInfo = NULL;
+ int i, TerPrev = ABC_INFINITY, TerCur, CountIncrease = 0;
+ vInfos = Vec_PtrAlloc( 100 );
+ for ( i = 0; i < 1000 && CountIncrease < 5 && TerPrev > 0; i++ )
+ {
+ TerCur = Saig_ManBmcTerSimCount01( p, pInfo );
+ if ( TerCur >= TerPrev )
+ CountIncrease++;
+ TerPrev = TerCur;
+ pInfo = Saig_ManBmcTerSimOne( p, pInfo );
+ Vec_PtrPush( vInfos, pInfo );
+ }
+ return vInfos;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Saig_ManBmcTerSimTest( Aig_Man_t * p )
+{
+ Vec_Ptr_t * vInfos;
+ unsigned * pInfo;
+ int i;
+ vInfos = Saig_ManBmcTerSim( p );
+ Vec_PtrForEachEntry( unsigned *, vInfos, pInfo, i )
+ printf( "%d=%d ", i, Saig_ManBmcTerSimCount01(p, pInfo) );
+ printf( "\n" );
+ Vec_PtrFreeFree( vInfos );
+}
+
+
+
+/**Function*************************************************************
+
+ Synopsis [Collects internal nodes in the DFS order.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Saig_ManBmcDfs_rec( Aig_Man_t * p, Aig_Obj_t * pObj, Vec_Ptr_t * vNodes )
+{
+ assert( !Aig_IsComplement(pObj) );
+ if ( Aig_ObjIsTravIdCurrent(p, pObj) )
+ return;
+ Aig_ObjSetTravIdCurrent(p, pObj);
+ if ( Aig_ObjIsNode(pObj) )
+ {
+ Saig_ManBmcDfs_rec( p, Aig_ObjFanin0(pObj), vNodes );
+ Saig_ManBmcDfs_rec( p, Aig_ObjFanin1(pObj), vNodes );
+ }
+ Vec_PtrPush( vNodes, pObj );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Collects internal nodes and PIs in the DFS order.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Ptr_t * Saig_ManBmcDfsNodes( Aig_Man_t * p, Vec_Ptr_t * vRoots )
+{
+ Vec_Ptr_t * vNodes;
+ Aig_Obj_t * pObj;
+ int i;
+ vNodes = Vec_PtrAlloc( 100 );
+ Vec_PtrForEachEntry( Aig_Obj_t *, vRoots, pObj, i )
+ Saig_ManBmcDfs_rec( p, Aig_ObjFanin0(pObj), vNodes );
+ return vNodes;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Vec_t * Saig_ManBmcSections( Aig_Man_t * p )
+{
+ Vec_Ptr_t * vSects, * vRoots, * vCone;
+ Aig_Obj_t * pObj, * pObjPo;
+ int i;
+ Aig_ManIncrementTravId( p );
+ Aig_ObjSetTravIdCurrent( p, Aig_ManConst1(p) );
+ // start the roots
+ vRoots = Vec_PtrAlloc( 1000 );
+ Saig_ManForEachPo( p, pObjPo, i )
+ {
+ Aig_ObjSetTravIdCurrent( p, pObjPo );
+ Vec_PtrPush( vRoots, pObjPo );
+ }
+ // compute the cones
+ vSects = Vec_PtrAlloc( 20 );
+ while ( Vec_PtrSize(vRoots) > 0 )
+ {
+ vCone = Saig_ManBmcDfsNodes( p, vRoots );
+ Vec_PtrPush( vSects, vCone );
+ // get the next set of roots
+ Vec_PtrClear( vRoots );
+ Vec_PtrForEachEntry( Aig_Obj_t *, vCone, pObj, i )
+ {
+ if ( !Saig_ObjIsLo(p, pObj) )
+ continue;
+ pObjPo = Saig_ObjLoToLi( p, pObj );
+ if ( Aig_ObjIsTravIdCurrent(p, pObjPo) )
+ continue;
+ Aig_ObjSetTravIdCurrent( p, pObjPo );
+ Vec_PtrPush( vRoots, pObjPo );
+ }
+ }
+ Vec_PtrFree( vRoots );
+ return (Vec_Vec_t *)vSects;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Saig_ManBmcSectionsTest( Aig_Man_t * p )
+{
+ Vec_Vec_t * vSects;
+ Vec_Ptr_t * vOne;
+ int i;
+ vSects = Saig_ManBmcSections( p );
+ Vec_VecForEachLevel( vSects, vOne, i )
+ printf( "%d=%d ", i, Vec_PtrSize(vOne) );
+ printf( "\n" );
+ Vec_VecFree( vSects );
+}
+
+
+
+/**Function*************************************************************
+
+ Synopsis [Collects the supergate.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Saig_ManBmcSupergate_rec( Aig_Obj_t * pObj, Vec_Ptr_t * vSuper )
+{
+ // if the new node is complemented or a PI, another gate begins
+ if ( Aig_IsComplement(pObj) || Aig_ObjIsPi(pObj) ) // || (Aig_ObjRefs(pObj) > 1) )
+ {
+ Vec_PtrPushUnique( vSuper, Aig_Regular(pObj) );
+ return;
+ }
+ // go through the branches
+ Saig_ManBmcSupergate_rec( Aig_ObjChild0(pObj), vSuper );
+ Saig_ManBmcSupergate_rec( Aig_ObjChild1(pObj), vSuper );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Collect the topmost supergate.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Ptr_t * Saig_ManBmcSupergate( Aig_Man_t * p, int iPo )
+{
+ Vec_Ptr_t * vSuper;
+ Aig_Obj_t * pObj;
+ vSuper = Vec_PtrAlloc( 10 );
+ pObj = Aig_ManPo( p, iPo );
+ pObj = Aig_ObjChild0( pObj );
+ if ( !Aig_IsComplement(pObj) )
+ {
+ Vec_PtrPush( vSuper, pObj );
+ return vSuper;
+ }
+ pObj = Aig_Regular( pObj );
+ if ( !Aig_ObjIsNode(pObj) )
+ {
+ Vec_PtrPush( vSuper, pObj );
+ return vSuper;
+ }
+ Saig_ManBmcSupergate_rec( Aig_ObjChild0(pObj), vSuper );
+ Saig_ManBmcSupergate_rec( Aig_ObjChild1(pObj), vSuper );
+ return vSuper;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the number of nodes with ref counter more than 1.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Saig_ManBmcCountRefed( Aig_Man_t * p, Vec_Ptr_t * vSuper )
+{
+ Aig_Obj_t * pObj;
+ int i, Counter = 0;
+ Vec_PtrForEachEntry( Aig_Obj_t *, vSuper, pObj, i )
+ {
+ assert( !Aig_IsComplement(pObj) );
+ Counter += (Aig_ObjRefs(pObj) > 1);
+ }
+ return Counter;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Saig_ManBmcSupergateTest( Aig_Man_t * p )
+{
+ Vec_Ptr_t * vSuper;
+ Aig_Obj_t * pObj;
+ int i;
+ printf( "Supergates: " );
+ Saig_ManForEachPo( p, pObj, i )
+ {
+ vSuper = Saig_ManBmcSupergate( p, i );
+ printf( "%d=%d(%d) ", i, Vec_PtrSize(vSuper), Saig_ManBmcCountRefed(p, vSuper) );
+ Vec_PtrFree( vSuper );
+ }
+ printf( "\n" );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Saig_ManBmcWriteBlif( Aig_Man_t * p, Vec_Int_t * vMapping, char * pFileName )
+{
+ FILE * pFile;
+ char * pSopSizes, ** pSops;
+ Aig_Obj_t * pObj;
+ char Vals[4];
+ int i, k, b, iFan, iTruth, * pData;
+ pFile = fopen( pFileName, "w" );
+ if ( pFile == NULL )
+ {
+ printf( "Cannot open file %s\n", pFileName );
+ return;
+ }
+ fprintf( pFile, ".model test\n" );
+ fprintf( pFile, ".inputs" );
+ Aig_ManForEachPi( p, pObj, i )
+ fprintf( pFile, " n%d", Aig_ObjId(pObj) );
+ fprintf( pFile, "\n" );
+ fprintf( pFile, ".outputs" );
+ Aig_ManForEachPo( p, pObj, i )
+ fprintf( pFile, " n%d", Aig_ObjId(pObj) );
+ fprintf( pFile, "\n" );
+ fprintf( pFile, ".names" );
+ fprintf( pFile, " n%d\n", Aig_ObjId(Aig_ManConst1(p)) );
+ fprintf( pFile, " 1\n" );
+
+ Cnf_ReadMsops( &pSopSizes, &pSops );
+ Aig_ManForEachNode( p, pObj, i )
+ {
+ if ( Vec_IntEntry(vMapping, i) == 0 )
+ continue;
+ pData = Vec_IntEntryP( vMapping, Vec_IntEntry(vMapping, i) );
+ fprintf( pFile, ".names" );
+ for ( iFan = 0; iFan < 4; iFan++ )
+ if ( pData[iFan+1] >= 0 )
+ fprintf( pFile, " n%d", pData[iFan+1] );
+ else
+ break;
+ fprintf( pFile, " n%d\n", i );
+ // write SOP
+ iTruth = pData[0] & 0xffff;
+ for ( k = 0; k < pSopSizes[iTruth]; k++ )
+ {
+ int Lit = pSops[iTruth][k];
+ for ( b = 3; b >= 0; b-- )
+ {
+ if ( Lit % 3 == 0 )
+ Vals[b] = '0';
+ else if ( Lit % 3 == 1 )
+ Vals[b] = '1';
+ else
+ Vals[b] = '-';
+ Lit = Lit / 3;
+ }
+ for ( b = 0; b < iFan; b++ )
+ fprintf( pFile, "%c", Vals[b] );
+ fprintf( pFile, " 1\n" );
+ }
+ }
+ free( pSopSizes );
+ free( pSops[1] );
+ free( pSops );
+
+ Aig_ManForEachPo( p, pObj, i )
+ {
+ fprintf( pFile, ".names" );
+ fprintf( pFile, " n%d", Aig_ObjId(Aig_ObjFanin0(pObj)) );
+ fprintf( pFile, " n%d\n", Aig_ObjId(pObj) );
+ fprintf( pFile, "%d 1\n", !Aig_ObjFaninC0(pObj) );
+ }
+ fprintf( pFile, ".end\n" );
+ fclose( pFile );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Saig_ManBmcMappingTest( Aig_Man_t * p )
+{
+ Vec_Int_t * vMapping;
+ vMapping = Cnf_DeriveMappingArray( p );
+ Saig_ManBmcWriteBlif( p, vMapping, "test.blif" );
+ Vec_IntFree( vMapping );
+}
+
+
+
+
+
+
+
+/**Function*************************************************************
+
+ Synopsis [Create manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_ManBmc_t * Saig_Bmc3ManStart( Aig_Man_t * pAig )
+{
+ Gia_ManBmc_t * p;
+ Aig_Obj_t * pObj;
+ int i;
+ assert( Aig_ManRegNum(pAig) > 0 );
+ p = ABC_CALLOC( Gia_ManBmc_t, 1 );
+ p->pAig = pAig;
+ // create mapping
+ p->vMapping = Cnf_DeriveMappingArray( pAig );
+ // create sections
+ p->vSects = Saig_ManBmcSections( pAig );
+ // map object IDs into their numbers and section numbers
+ p->nObjNums = 0;
+ p->vId2Num = Vec_IntStartFull( Aig_ManObjNumMax(pAig) );
+ Vec_IntWriteEntry( p->vId2Num, Aig_ObjId(Aig_ManConst1(pAig)), p->nObjNums++ );
+ Aig_ManForEachPi( pAig, pObj, i )
+ Vec_IntWriteEntry( p->vId2Num, Aig_ObjId(pObj), p->nObjNums++ );
+ Aig_ManForEachNode( pAig, pObj, i )
+ if ( Vec_IntEntry(p->vMapping, Aig_ObjId(pObj)) > 0 )
+ Vec_IntWriteEntry( p->vId2Num, Aig_ObjId(pObj), p->nObjNums++ );
+ Aig_ManForEachPo( pAig, pObj, i )
+ Vec_IntWriteEntry( p->vId2Num, Aig_ObjId(pObj), p->nObjNums++ );
+ p->vPiVars = Vec_IntAlloc( 1000 );
+ p->vId2Var = Vec_PtrAlloc( 100 );
+ p->vVisited = Vec_IntAlloc( 1000 );
+ // create solver
+ p->nSatVars = 1;
+ p->pSat = sat_solver_new();
+ sat_solver_setnvars( p->pSat, 1000 );
+ Cnf_ReadMsops( &p->pSopSizes, &p->pSops );
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Delete manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Saig_Bmc3ManStop( Gia_ManBmc_t * p )
+{
+ if ( p->vCexes )
+ {
+ assert( p->pAig->pSeqModelVec == NULL );
+ p->pAig->pSeqModelVec = p->vCexes;
+ p->vCexes = NULL;
+ }
+// Vec_PtrFreeFree( p->vCexes );
+ Vec_IntFree( p->vMapping );
+ Vec_VecFree( p->vSects );
+ Vec_IntFree( p->vId2Num );
+ Vec_IntFree( p->vPiVars );
+ Vec_IntFree( p->vVisited );
+ Vec_VecFree( (Vec_Vec_t *)p->vId2Var );
+ sat_solver_delete( p->pSat );
+ free( p->pSopSizes );
+ free( p->pSops[1] );
+ free( p->pSops );
+ free( p );
+}
+
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int * Saig_ManBmcMapping( Gia_ManBmc_t * p, Aig_Obj_t * pObj )
+{
+ if ( Vec_IntEntry(p->vMapping, Aig_ObjId(pObj)) == 0 )
+ return NULL;
+ return Vec_IntEntryP( p->vMapping, Vec_IntEntry(p->vMapping, Aig_ObjId(pObj)) );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Saig_ManBmcLiteral( Gia_ManBmc_t * p, Aig_Obj_t * pObj, int iFrame )
+{
+ Vec_Int_t * vFrame;
+ int ObjNum;
+ assert( !Aig_ObjIsNode(pObj) || Saig_ManBmcMapping(p, pObj) );
+ ObjNum = Vec_IntEntry( p->vId2Num, Aig_ObjId(pObj) );
+ assert( ObjNum >= 0 );
+ vFrame = (Vec_Int_t *)Vec_PtrEntry( p->vId2Var, iFrame );
+ assert( vFrame != NULL );
+ return Vec_IntEntry( vFrame, ObjNum );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Saig_ManBmcSetLiteral( Gia_ManBmc_t * p, Aig_Obj_t * pObj, int iFrame, int iLit )
+{
+ Vec_Int_t * vFrame;
+ int ObjNum;
+ assert( !Aig_ObjIsNode(pObj) || Saig_ManBmcMapping(p, pObj) );
+ ObjNum = Vec_IntEntry( p->vId2Num, Aig_ObjId(pObj) );
+ vFrame = (Vec_Int_t *)Vec_PtrEntry( p->vId2Var, iFrame );
+ Vec_IntWriteEntry( vFrame, ObjNum, iLit );
+ if ( iLit == ABC_INFINITY || iLit == ABC_INFINITY+1 )
+ {
+ Vec_IntPush( p->vVisited, Aig_ObjId(pObj) );
+ Vec_IntPush( p->vVisited, iFrame );
+ }
+ else if ( iLit != ~0 && Saig_ObjIsPi(p->pAig, pObj) ) // save PI SAT var num
+ Vec_IntWriteEntry( p->vPiVars, iFrame*Saig_ManPiNum(p->pAig)+Aig_ObjPioNum(pObj), lit_var(iLit) );
+ return iLit;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Saig_ManBmcCof0( int t, int v )
+{
+ static int s_Truth[4] = { 0xAAAA, 0xCCCC, 0xF0F0, 0xFF00 };
+ return 0xffff & ((t & ~s_Truth[v]) | ((t & ~s_Truth[v]) << (1<<v)));
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Saig_ManBmcCof1( int t, int v )
+{
+ static int s_Truth[4] = { 0xAAAA, 0xCCCC, 0xF0F0, 0xFF00 };
+ return 0xffff & ((t & s_Truth[v]) | ((t & s_Truth[v]) >> (1<<v)));
+}
+
+/**Function*************************************************************
+
+ Synopsis [Derives CNF for one node.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Saig_ManBmcDeriveTruth( int uTruth, int Lits[] )
+{
+ int v;
+ for ( v = 0; v < 4; v++ )
+ if ( Lits[v] == 0 )
+ {
+ uTruth = Saig_ManBmcCof0(uTruth, v);
+ Lits[v] = -1;
+ }
+ else if ( Lits[v] == 1 )
+ {
+ uTruth = Saig_ManBmcCof1(uTruth, v);
+ Lits[v] = -1;
+ }
+ for ( v = 0; v < 4; v++ )
+ if ( Lits[v] == -1 )
+ assert( Saig_ManBmcCof0(uTruth, v) == Saig_ManBmcCof1(uTruth, v) );
+ return uTruth;
+}
+
+/*
+void Cnf_SopConvertToVector( char * pSop, int nCubes, Vec_Int_t * vCover )
+{
+ int Lits[4], Cube, iCube, i, b;
+ Vec_IntClear( vCover );
+ for ( i = 0; i < nCubes; i++ )
+ {
+ Cube = pSop[i];
+ for ( b = 0; b < 4; b++ )
+ {
+ if ( Cube % 3 == 0 )
+ Lits[b] = 1;
+ else if ( Cube % 3 == 1 )
+ Lits[b] = 2;
+ else
+ Lits[b] = 0;
+ Cube = Cube / 3;
+ }
+ iCube = 0;
+ for ( b = 0; b < 4; b++ )
+ iCube = (iCube << 2) | Lits[b];
+ Vec_IntPush( vCover, iCube );
+ }
+}
+
+ Vec_IntForEachEntry( vCover, Cube, k )
+ {
+ *pClas++ = pLits;
+ *pLits++ = 2 * OutVar;
+ pLits += Cnf_IsopWriteCube( Cube, pCut->nFanins, pVars, pLits );
+ }
+
+
+int Cnf_IsopWriteCube( int Cube, int nVars, int * pVars, int * pLiterals )
+{
+ int nLits = nVars, b;
+ for ( b = 0; b < nVars; b++ )
+ {
+ if ( (Cube & 3) == 1 ) // value 0 --> write positive literal
+ *pLiterals++ = 2 * pVars[b];
+ else if ( (Cube & 3) == 2 ) // value 1 --> write negative literal
+ *pLiterals++ = 2 * pVars[b] + 1;
+ else
+ nLits--;
+ Cube >>= 2;
+ }
+ return nLits;
+}
+
+ iTruth = pData[0] & 0xffff;
+ for ( k = 0; k < pSopSizes[iTruth]; k++ )
+ {
+ int Lit = pSops[iTruth][k];
+ for ( b = 3; b >= 0; b-- )
+ {
+ if ( Lit % 3 == 0 )
+ Vals[b] = '0';
+ else if ( Lit % 3 == 1 )
+ Vals[b] = '1';
+ else
+ Vals[b] = '-';
+ Lit = Lit / 3;
+ }
+ for ( b = 0; b < iFan; b++ )
+ fprintf( pFile, "%c", Vals[b] );
+ fprintf( pFile, " 1\n" );
+ }
+*/
+
+/**Function*************************************************************
+
+ Synopsis [Derives CNF for one node.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Saig_ManBmcAddClauses( Gia_ManBmc_t * p, int uTruth, int Lits[], int iLitOut )
+{
+ int i, k, b, CutLit, nClaLits, ClaLits[5];
+ assert( uTruth > 0 && uTruth < 0xffff );
+ // write positive/negative polarity
+ for ( i = 0; i < 2; i++ )
+ {
+ if ( i )
+ uTruth = 0xffff & ~uTruth;
+// Extra_PrintBinary( stdout, &uTruth, 16 ); printf( "\n" );
+ for ( k = 0; k < p->pSopSizes[uTruth]; k++ )
+ {
+ nClaLits = 0;
+ ClaLits[nClaLits++] = i ? lit_neg(iLitOut) : iLitOut;
+ CutLit = p->pSops[uTruth][k];
+ for ( b = 3; b >= 0; b-- )
+ {
+ if ( CutLit % 3 == 0 ) // value 0 --> write positive literal
+ {
+ assert( Lits[b] > 1 );
+ ClaLits[nClaLits++] = Lits[b];
+ }
+ else if ( CutLit % 3 == 1 ) // value 1 --> write negative literal
+ {
+ assert( Lits[b] > 1 );
+ ClaLits[nClaLits++] = lit_neg(Lits[b]);
+ }
+ CutLit = CutLit / 3;
+ }
+
+// for ( b = 0; b < nClaLits; b++ )
+// printf( "%d ", ClaLits[b] );
+// printf( "\n" );
+
+ if ( !sat_solver_addclause( p->pSat, ClaLits, ClaLits+nClaLits ) )
+ assert( 0 );
+ }
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Derives CNF for one node.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Saig_ManBmcCreateCnf_rec( Gia_ManBmc_t * p, Aig_Obj_t * pObj, int iFrame, int fAddClauses )
+{
+ int * pMapping, i, iLit, Lits[4], uTruth;
+ iLit = Saig_ManBmcLiteral( p, pObj, iFrame );
+ if ( iLit != ~0 )
+ return iLit;
+ assert( iFrame >= 0 );
+ if ( Aig_ObjIsPi(pObj) )
+ {
+ if ( Saig_ObjIsPi(p->pAig, pObj) )
+ iLit = fAddClauses ? toLit( p->nSatVars++ ) : ABC_INFINITY;
+ else
+ iLit = Saig_ManBmcCreateCnf_rec( p, Saig_ObjLoToLi(p->pAig, pObj), iFrame-1, fAddClauses );
+ return Saig_ManBmcSetLiteral( p, pObj, iFrame, iLit );
+ }
+ if ( Aig_ObjIsPo(pObj) )
+ {
+ iLit = Saig_ManBmcCreateCnf_rec( p, Aig_ObjFanin0(pObj), iFrame, fAddClauses );
+ if ( Aig_ObjFaninC0(pObj) )
+ iLit = lit_neg(iLit);
+ return Saig_ManBmcSetLiteral( p, pObj, iFrame, iLit );
+ }
+ assert( Aig_ObjIsNode(pObj) );
+ pMapping = Saig_ManBmcMapping( p, pObj );
+ for ( i = 0; i < 4; i++ )
+ if ( pMapping[i+1] == -1 )
+ Lits[i] = -1;
+ else
+ Lits[i] = Saig_ManBmcCreateCnf_rec( p, Aig_ManObj(p->pAig, pMapping[i+1]), iFrame, fAddClauses );
+ // derive new truth table
+//uTruth = 0xffff & (unsigned)pMapping[0];
+//printf( "Truth : " );
+//Extra_PrintBinary( stdout, &uTruth, 16 ); printf( "\n" );
+ uTruth = Saig_ManBmcDeriveTruth( 0xffff & (unsigned)pMapping[0], Lits );
+ if ( uTruth == 0 || uTruth == 0xffff )
+ {
+ iLit = (uTruth == 0xffff);
+ return Saig_ManBmcSetLiteral( p, pObj, iFrame, iLit );
+ }
+ // create CNF
+ if ( fAddClauses )
+ {
+ iLit = toLit( p->nSatVars++ );
+ Saig_ManBmcAddClauses( p, uTruth, Lits, iLit );
+
+ if ( uTruth == 0xAAAA || (0xffff & ~uTruth) == 0xAAAA ||
+ uTruth == 0xCCCC || (0xffff & ~uTruth) == 0xCCCC ||
+ uTruth == 0xF0F0 || (0xffff & ~uTruth) == 0xF0F0 ||
+ uTruth == 0xFF00 || (0xffff & ~uTruth) == 0xFF00 )
+ p->nBufNum++;
+
+ if ( (Lits[0] > 1 && (Lits[0] == Lits[1] || Lits[0] == Lits[2] || Lits[0] == Lits[3])) ||
+ (Lits[1] > 1 && (Lits[1] == Lits[2] || Lits[1] == Lits[2])) ||
+ (Lits[2] > 1 && (Lits[2] == Lits[3])) )
+ p->nDupNum++;
+
+ }
+ else
+ {
+ iLit = ABC_INFINITY;
+ }
+ return Saig_ManBmcSetLiteral( p, pObj, iFrame, iLit );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Derives CNF for one node.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Saig_ManBmcCreateCnf( Gia_ManBmc_t * p, Aig_Obj_t * pObj, int iFrame )
+{
+ int i, iLit, Entry, iFrameOld, Value;
+ Vec_IntClear( p->vVisited );
+ iLit = Saig_ManBmcCreateCnf_rec( p, pObj, iFrame, 0 );
+ Vec_IntForEachEntry( p->vVisited, Entry, i )
+ {
+ iFrameOld = Vec_IntEntry( p->vVisited, ++i );
+ Value = Saig_ManBmcLiteral( p, Aig_ManObj(p->pAig, Entry), iFrameOld );
+// assert( Value == 0 || Value == 1 || Value == ABC_INFINITY || Value == ABC_INFINITY+1 );
+ assert( Value == ABC_INFINITY || Value == ABC_INFINITY+1 );
+ if ( !(Value == ABC_INFINITY || Value == ABC_INFINITY+1) )
+ printf( "Internal error!\n" );
+// if ( Value == 0 || Value == 1 )
+// continue;
+ Saig_ManBmcSetLiteral( p, Aig_ManObj(p->pAig, Entry), iFrameOld, ~0 );
+ }
+ if ( iLit < 2 )
+ return iLit;
+ return Saig_ManBmcCreateCnf_rec( p, pObj, iFrame, 1 );
+}
+
+
+
+/**Function*************************************************************
+
+ Synopsis [This procedure sets default parameters.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Saig_ParBmcSetDefaultParams( Saig_ParBmc_t * p )
+{
+ memset( p, 0, sizeof(Saig_ParBmc_t) );
+ p->nStart = 0; // maximum number of timeframes
+ p->nFramesMax = 2000; // maximum number of timeframes
+ p->nConfLimit = 2000; // maximum number of conflicts at a node
+ p->nTimeOut = 0; // approximate timeout in seconds
+ p->fSolveAll = 0; // stops on the first SAT instance
+ p->fDropSatOuts = 0; // replace sat outputs by constant 0
+ p->fVerbose = 0; // verbose
+ p->iFrame = -1; // explored up to this frame
+ p->nFailOuts = 0; // the number of failed outputs
+}
+
+/**Function*************************************************************
+
+ Synopsis [Bounded model checking engine.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Saig_ManBmcScalable( Aig_Man_t * pAig, Saig_ParBmc_t * pPars )
+{
+ Gia_ManBmc_t * p;
+ Aig_Obj_t * pObj;
+ int RetValue = -1, fFirst = 1;
+ int i, f, Lit, status, clk, clk2, clkOther = 0, clkTotal = clock();
+ if ( pPars->fVerbose && Aig_ManConstrNum(pAig) > 0 )
+ printf( "Performing BMC with constraints...\n" );
+ p = Saig_Bmc3ManStart( pAig );
+ p->pPars = pPars;
+ if ( pPars->fVerbose )
+ {
+ printf( "AIG: PI/PO/Reg = %d/%d/%d. Node = %6d. Lev = %5d. Map = %6d. Sect =%3d.\n",
+ Saig_ManPiNum(pAig), Saig_ManPoNum(pAig), Saig_ManRegNum(pAig),
+ Aig_ManNodeNum(pAig), Aig_ManLevelNum(pAig), (Vec_IntSize(p->vMapping)-Aig_ManObjNumMax(pAig))/5, Vec_VecSize(p->vSects) );
+ printf( "Params: Start = %d. FramesMax = %d. ConfLimit = %d. TimeOut = %d. SolveAll = %d.\n",
+ pPars->nStart, pPars->nFramesMax, pPars->nConfLimit, pPars->nTimeOut, pPars->fSolveAll );
+ }
+ for ( f = 0; f < pPars->nFramesMax; f++ )
+ {
+ pPars->iFrame = f;
+ // resize the array
+ Vec_IntFillExtra( p->vPiVars, (f+1)*Saig_ManPiNum(p->pAig), 0 );
+ // map nodes of this section
+ Vec_PtrPush( p->vId2Var, Vec_IntStartFull(p->nObjNums) );
+/*
+ if ( f > 2*Vec_VecSize(p->vSects) )
+ {
+ int iFrameOld = f - 2*Vec_VecSize( p->vSects );
+ void * pMemory = Vec_IntReleaseArray( Vec_PtrEntry(p->vId2Var, iFrameOld) );
+ ABC_FREE( pMemory );
+ }
+*/
+ // prepare some nodes
+ Saig_ManBmcSetLiteral( p, Aig_ManConst1(pAig), f, 1 );
+ if ( f == 0 )
+ Saig_ManForEachLo( p->pAig, pObj, i )
+ Saig_ManBmcSetLiteral( p, pObj, 0, 0 );
+ // add the constraints for this frame
+ Saig_ManForEachPo( pAig, pObj, i )
+ {
+ if ( i < Saig_ManPoNum(pAig) - Saig_ManConstrNum(pAig) )
+ continue;
+clk2 = clock();
+ Lit = Saig_ManBmcCreateCnf( p, pObj, f );
+ Lit = lit_neg( Lit );
+clkOther += clock() - clk2;
+ status = sat_solver_addclause( p->pSat, &Lit, &Lit + 1 );
+ if ( status == 0 )
+ {
+ printf( "SAT problem became UNSAT after adding constraints in frame %d.\n", f );
+ Saig_Bmc3ManStop( p );
+ return 1;
+ }
+ }
+ // solve SAT
+ clk = clock();
+ Saig_ManForEachPo( pAig, pObj, i )
+ {
+ if ( i >= Saig_ManPoNum(pAig) - Saig_ManConstrNum(pAig) )
+ break;
+ // skip solved outputs
+ if ( p->vCexes && Vec_PtrEntry(p->vCexes, i) )
+ continue;
+ // add constraints for this output
+clk2 = clock();
+ Lit = Saig_ManBmcCreateCnf( p, pObj, f );
+clkOther += clock() - clk2;
+ if ( Lit == 0 )
+ continue;
+ if ( Lit == 1 )
+ {
+ extern Abc_Cex_t * Fra_SmlTrivCounterExample( Aig_Man_t * pAig, int iFrameOut );
+ Abc_Cex_t * pCex = Fra_SmlTrivCounterExample( pAig, f*Saig_ManPoNum(pAig)+i );
+ printf( "Output %d is trivially SAT in frame %d.\n", i, f );
+ if ( !pPars->fSolveAll )
+ {
+ ABC_FREE( pAig->pSeqModel );
+ pAig->pSeqModel = pCex;
+ Saig_Bmc3ManStop( p );
+ return 0;
+ }
+ pPars->nFailOuts++;
+ if ( p->vCexes == NULL )
+ p->vCexes = Vec_PtrStart( Saig_ManPoNum(pAig) );
+ Vec_PtrWriteEntry( p->vCexes, i, pCex );
+ continue;
+ }
+ // solve this output
+ sat_solver_compress( p->pSat );
+ status = sat_solver_solve( p->pSat, &Lit, &Lit + 1, (ABC_INT64_T)pPars->nConfLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
+ if ( status == l_False )
+ {/*
+ Lit = lit_neg( Lit );
+ status = sat_solver_addclause( p->pSat, &Lit, &Lit + 1 );
+ assert( status );
+ sat_solver_compress( p->pSat );
+ */
+ }
+ else if ( status == l_True )
+ {
+// extern void * Fra_SmlSimpleCounterExample( Aig_Man_t * p, int * pModel, int iFrame, int iPo );
+ int * pModel = Sat_SolverGetModel( p->pSat, Vec_IntArray(p->vPiVars), Vec_IntSize(p->vPiVars) );
+ Abc_Cex_t * pCex = Fra_SmlSimpleCounterExample( pAig, pModel, f, i );
+ ABC_FREE( pModel );
+ fFirst = 0;
+ if ( !pPars->fSolveAll )
+ {
+//ABC_PRT( "CNF generation runtime", clkOther );
+ if ( pPars->fVerbose )
+ {
+ printf( "%3d : ", f );
+ printf( "Var =%8.0f. ", (double)p->nSatVars );
+ printf( "Cla =%9.0f. ", (double)p->pSat->stats.clauses );
+ printf( "Conf =%7.0f. ",(double)p->pSat->stats.conflicts );
+ printf( "Imp =%10.0f. ", (double)p->pSat->stats.propagations );
+ ABC_PRT( "Time", clock() - clk );
+ ABC_PRM( "Id2Var", (f+1)*p->nObjNums*4 );
+ ABC_PRM( "SAT", 42 * p->pSat->size + 16 * (int)p->pSat->stats.clauses + 4 * (int)p->pSat->stats.clauses_literals );
+ printf( "Simples = %6d. ", p->nBufNum );
+// printf( "Dups = %6d. ", p->nDupNum );
+ printf( "\n" );
+ fflush( stdout );
+ }
+ ABC_FREE( pAig->pSeqModel );
+ pAig->pSeqModel = pCex;
+ Saig_Bmc3ManStop( p );
+ return 0;
+ }
+ pPars->nFailOuts++;
+ printf( "Output %d was asserted in frame %d (use \"write_counter\" to dump a witness).\n", i, f );
+ if ( p->vCexes == NULL )
+ p->vCexes = Vec_PtrStart( Saig_ManPoNum(pAig) );
+ Vec_PtrWriteEntry( p->vCexes, i, pCex );
+ }
+ else
+ {
+ assert( status == l_Undef );
+ Saig_Bmc3ManStop( p );
+ return RetValue;
+ }
+ if ( pPars->nTimeOut && ((float)pPars->nTimeOut <= (float)(clock()-clkTotal)/(float)(CLOCKS_PER_SEC)) )
+ {
+ printf( "Reached timeout (%d seconds).\n", pPars->nTimeOut );
+ Saig_Bmc3ManStop( p );
+ return RetValue;
+ }
+ }
+ if ( pPars->fVerbose )
+ {
+ if ( fFirst == 1 && f > 0 && p->pSat->stats.conflicts > 1 )
+ {
+ fFirst = 0;
+// printf( "Outputs of frames up to %d are trivially UNSAT.\n", f );
+ }
+ printf( "%3d : ", f );
+ printf( "Var =%8.0f. ", (double)p->nSatVars );
+ printf( "Cla =%9.0f. ", (double)p->pSat->stats.clauses );
+ printf( "Conf =%7.0f. ",(double)p->pSat->stats.conflicts );
+ printf( "Imp =%10.0f. ", (double)p->pSat->stats.propagations );
+ ABC_PRT( "Time", clock() - clk );
+// ABC_PRM( "Id2Var", (f+1)*p->nObjNums*4 );
+// ABC_PRM( "SAT", 42 * p->pSat->size + 16 * (int)p->pSat->stats.clauses + 4 * (int)p->pSat->stats.clauses_literals );
+// printf( "Simples = %6d. ", p->nBufNum );
+// printf( "Dups = %6d. ", p->nDupNum );
+// printf( "\n" );
+ fflush( stdout );
+ }
+ }
+//ABC_PRT( "CNF generation runtime", clkOther );
+ if ( pPars->fVerbose )
+ {
+ ABC_PRM( "Id2Var", (f+1)*p->nObjNums*4 );
+ ABC_PRM( "SAT", 48 * p->pSat->size + 16 * (int)p->pSat->stats.clauses + 4 * (int)p->pSat->stats.clauses_literals );
+ printf( "Simples = %6d. ", p->nBufNum );
+// printf( "Dups = %6d. ", p->nDupNum );
+ printf( "\n" );
+ }
+ Saig_Bmc3ManStop( p );
+ return RetValue;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/saig/saigCone.c b/src/aig/saig/saigCone.c
index 7ca077c8..2b0da5c9 100644
--- a/src/aig/saig/saigCone.c
+++ b/src/aig/saig/saigCone.c
@@ -20,6 +20,9 @@
#include "saig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -78,7 +81,7 @@ Vec_Ptr_t * Saig_ManSupport( Aig_Man_t * p, Vec_Ptr_t * vNodes )
int i;
vSupp = Vec_PtrAlloc( 100 );
Aig_ManIncrementTravId( p );
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
{
assert( Aig_ObjIsPo(pObj) );
Saig_ManSupport_rec( p, Aig_ObjFanin0(pObj), vSupp );
@@ -115,7 +118,7 @@ void Saig_ManPrintConeOne( Aig_Man_t * p, Aig_Obj_t * pObj )
{
// classify current into those new, prev, and older
nCurNew = nCurPrev = nCurOld = 0;
- Vec_PtrForEachEntry( vCur, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vCur, pObj, i )
{
if ( Vec_PtrFind(vTotal, pObj) == -1 )
{
@@ -174,3 +177,5 @@ void Saig_ManPrintCones( Aig_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/saig/saigConstr.c b/src/aig/saig/saigConstr.c
new file mode 100644
index 00000000..b4024634
--- /dev/null
+++ b/src/aig/saig/saigConstr.c
@@ -0,0 +1,384 @@
+/**CFile****************************************************************
+
+ FileName [saigConstr.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Sequential AIG package.]
+
+ Synopsis [Structural constraint detection.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: saigConstr.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "saig.h"
+#include "cnf.h"
+#include "satSolver.h"
+#include "kit.h"
+#include "ioa.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+static int Saig_ManDetectConstr( Aig_Man_t * p, Vec_Ptr_t ** pvOuts, Vec_Ptr_t ** pvCons );
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Duplicates the AIG while unfolding constraints.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Man_t * Saig_ManDupUnfoldConstrs( Aig_Man_t * pAig )
+{
+ Vec_Ptr_t * vOuts, * vCons;
+ Aig_Man_t * pAigNew;
+ Aig_Obj_t * pMiter, * pObj;
+ int i, RetValue;
+ RetValue = Saig_ManDetectConstr( pAig, &vOuts, &vCons );
+ if ( RetValue == 0 )
+ return Aig_ManDupDfs( pAig );
+ // start the new manager
+ pAigNew = Aig_ManStart( Aig_ManNodeNum(pAig) );
+ pAigNew->pName = Aig_UtilStrsav( pAig->pName );
+ // map the constant node
+ Aig_ManConst1(pAig)->pData = Aig_ManConst1( pAigNew );
+ // create variables for PIs
+ Aig_ManForEachPi( pAig, pObj, i )
+ pObj->pData = Aig_ObjCreatePi( pAigNew );
+ // add internal nodes of this frame
+ Aig_ManForEachNode( pAig, pObj, i )
+ pObj->pData = Aig_And( pAigNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
+ // AND the outputs
+ pMiter = Aig_ManConst1( pAigNew );
+ Vec_PtrForEachEntry( Aig_Obj_t *, vOuts, pObj, i )
+ pMiter = Aig_And( pAigNew, pMiter, Aig_Not(Aig_ObjRealCopy(pObj)) );
+ Aig_ObjCreatePo( pAigNew, pMiter );
+ // add constraints
+ pAigNew->nConstrs = Vec_PtrSize(vCons);
+ Vec_PtrForEachEntry( Aig_Obj_t *, vCons, pObj, i )
+ Aig_ObjCreatePo( pAigNew, Aig_ObjRealCopy(pObj) );
+ // transfer to register outputs
+ Saig_ManForEachLi( pAig, pObj, i )
+ Aig_ObjCreatePo( pAigNew, Aig_ObjChild0Copy(pObj) );
+ Vec_PtrFreeP( &vOuts );
+ Vec_PtrFreeP( &vCons );
+
+ Aig_ManSetRegNum( pAigNew, Aig_ManRegNum(pAig) );
+ Aig_ManCleanup( pAigNew );
+ Aig_ManSeqCleanup( pAigNew );
+ return pAigNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Duplicates the AIG while folding in the constraints.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Man_t * Saig_ManDupFoldConstrs( Aig_Man_t * pAig, Vec_Int_t * vConstrs )
+{
+ Aig_Man_t * pAigNew;
+ Aig_Obj_t * pMiter, * pFlopOut, * pFlopIn, * pObj;
+ int Entry, i;
+ assert( Saig_ManRegNum(pAig) > 0 );
+ // start the new manager
+ pAigNew = Aig_ManStart( Aig_ManNodeNum(pAig) );
+ pAigNew->pName = Aig_UtilStrsav( pAig->pName );
+ // map the constant node
+ Aig_ManConst1(pAig)->pData = Aig_ManConst1( pAigNew );
+ // create variables for PIs
+ Aig_ManForEachPi( pAig, pObj, i )
+ pObj->pData = Aig_ObjCreatePi( pAigNew );
+ // add internal nodes of this frame
+ Aig_ManForEachNode( pAig, pObj, i )
+ pObj->pData = Aig_And( pAigNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
+
+ // OR the constraint outputs
+ pMiter = Aig_ManConst0( pAigNew );
+ Vec_IntForEachEntry( vConstrs, Entry, i )
+ {
+ assert( Entry > 0 && Entry < Saig_ManPoNum(pAig) );
+ pObj = Aig_ManPo( pAig, Entry );
+ pMiter = Aig_Or( pAigNew, pMiter, Aig_ObjChild0Copy(pObj) );
+ }
+ // create additional flop
+ pFlopOut = Aig_ObjCreatePi( pAigNew );
+ pFlopIn = Aig_Or( pAigNew, pMiter, pFlopOut );
+
+ // create primary output
+ Saig_ManForEachPo( pAig, pObj, i )
+ {
+ pMiter = Aig_And( pAigNew, Aig_ObjChild0Copy(pObj), Aig_Not(pFlopIn) );
+ Aig_ObjCreatePo( pAigNew, pMiter );
+ }
+
+ // transfer to register outputs
+ Saig_ManForEachLi( pAig, pObj, i )
+ Aig_ObjCreatePo( pAigNew, Aig_ObjChild0Copy(pObj) );
+ // create additional flop
+ Aig_ObjCreatePo( pAigNew, pFlopIn );
+
+ Aig_ManSetRegNum( pAigNew, Aig_ManRegNum(pAig)+1 );
+ Aig_ManCleanup( pAigNew );
+ Aig_ManSeqCleanup( pAigNew );
+ return pAigNew;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Tests the above two procedures.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Saig_ManFoldConstrTest( Aig_Man_t * pAig )
+{
+ Aig_Man_t * pAig1, * pAig2;
+ Vec_Int_t * vConstrs;
+ // unfold constraints
+ pAig1 = Saig_ManDupUnfoldConstrs( pAig );
+ // create the constraint list
+ vConstrs = Vec_IntStartNatural( Saig_ManPoNum(pAig1) );
+ Vec_IntRemove( vConstrs, 0 );
+ // fold constraints back
+ pAig2 = Saig_ManDupFoldConstrs( pAig1, vConstrs );
+ Vec_IntFree( vConstrs );
+ // compare the two AIGs
+ Ioa_WriteAiger( pAig2, "test.aig", 0, 0 );
+ Aig_ManStop( pAig1 );
+ Aig_ManStop( pAig2 );
+}
+
+
+
+
+/**Function*************************************************************
+
+ Synopsis [Collects the supergate.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Saig_DetectConstrCollectSuper_rec( Aig_Obj_t * pObj, Vec_Ptr_t * vSuper )
+{
+ // if the new node is complemented or a PI, another gate begins
+ if ( Aig_IsComplement(pObj) || !Aig_ObjIsNode(pObj) )//|| (Aig_ObjRefs(pObj) > 1) )
+ {
+ Vec_PtrPushUnique( vSuper, Aig_Not(pObj) );
+ return;
+ }
+ // go through the branches
+ Saig_DetectConstrCollectSuper_rec( Aig_ObjChild0(pObj), vSuper );
+ Saig_DetectConstrCollectSuper_rec( Aig_ObjChild1(pObj), vSuper );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Collects the supergate.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Ptr_t * Saig_DetectConstrCollectSuper( Aig_Obj_t * pObj )
+{
+ Vec_Ptr_t * vSuper;
+ assert( !Aig_IsComplement(pObj) );
+ assert( Aig_ObjIsAnd(pObj) );
+ vSuper = Vec_PtrAlloc( 4 );
+ Saig_DetectConstrCollectSuper_rec( Aig_ObjChild0(pObj), vSuper );
+ Saig_DetectConstrCollectSuper_rec( Aig_ObjChild1(pObj), vSuper );
+ return vSuper;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns NULL if not contained, or array with unique entries.]
+
+ Description [Returns NULL if vSuper2 is not contained in vSuper. Otherwise
+ returns the array of entries in vSuper that are not found in vSuper2.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Ptr_t * Saig_ManDetectConstrCheckCont( Vec_Ptr_t * vSuper, Vec_Ptr_t * vSuper2 )
+{
+ Vec_Ptr_t * vUnique;
+ Aig_Obj_t * pObj, * pObj2;
+ int i;
+ Vec_PtrForEachEntry( Aig_Obj_t *, vSuper2, pObj2, i )
+ if ( Vec_PtrFind( vSuper, pObj2 ) == -1 )
+ return 0;
+ vUnique = Vec_PtrAlloc( 100 );
+ Vec_PtrForEachEntry( Aig_Obj_t *, vSuper, pObj, i )
+ if ( Vec_PtrFind( vSuper2, pObj ) == -1 )
+ Vec_PtrPush( vUnique, pObj );
+ return vUnique;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Detects constraints using structural methods.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Saig_ManDetectConstr( Aig_Man_t * p, Vec_Ptr_t ** pvOuts, Vec_Ptr_t ** pvCons )
+{
+ Vec_Ptr_t * vSuper, * vSuper2, * vUnique;
+ Aig_Obj_t * pObj, * pObj2, * pFlop;
+ int i, nFlops, RetValue;
+ *pvOuts = NULL;
+ *pvCons = NULL;
+ if ( Saig_ManPoNum(p) != 1 )
+ {
+ printf( "The number of POs is other than 1.\n" );
+ return 0;
+ }
+ pObj = Aig_ObjChild0( Aig_ManPo(p, 0) );
+ if ( Aig_IsComplement(pObj) || !Aig_ObjIsNode(pObj) )
+ {
+ printf( "The output is not an AND.\n" );
+ return 0;
+ }
+ vSuper = Saig_DetectConstrCollectSuper( pObj );
+ assert( Vec_PtrSize(vSuper) >= 2 );
+ nFlops = 0;
+ Vec_PtrForEachEntry( Aig_Obj_t *, vSuper, pObj, i )
+ nFlops += Saig_ObjIsLo( p, Aig_Regular(pObj) );
+ if ( nFlops == 0 )
+ {
+ printf( "There is no flop outputs.\n" );
+ Vec_PtrFree( vSuper );
+ return 0;
+ }
+ // try flops
+ vUnique = NULL;
+ Vec_PtrForEachEntry( Aig_Obj_t *, vSuper, pObj, i )
+ {
+ pFlop = Aig_Regular( pObj );
+ if ( !Saig_ObjIsLo(p, pFlop) )
+ continue;
+ pFlop = Saig_ObjLoToLi( p, pFlop );
+ pObj2 = Aig_ObjChild0( pFlop );
+ if ( !Aig_IsComplement(pObj2) || !Aig_ObjIsNode(Aig_Regular(pObj2)) )
+ continue;
+ vSuper2 = Saig_DetectConstrCollectSuper( Aig_Regular(pObj2) );
+ // every node in vSuper2 should appear in vSuper
+ vUnique = Saig_ManDetectConstrCheckCont( vSuper, vSuper2 );
+ if ( vUnique != NULL )
+ {
+/// assert( !Aig_IsComplement(pObj) );
+ // assert( Vec_PtrFind( vSuper2, pObj ) >= 0 );
+ if ( Aig_IsComplement(pObj) )
+ {
+ printf( "Special flop input is complemented.\n" );
+ Vec_PtrFreeP( &vUnique );
+ Vec_PtrFree( vSuper2 );
+ break;
+ }
+ if ( Vec_PtrFind( vSuper2, pObj ) == -1 )
+ {
+ printf( "Cannot find special flop about the inputs of OR gate.\n" );
+ Vec_PtrFreeP( &vUnique );
+ Vec_PtrFree( vSuper2 );
+ break;
+ }
+ // remove the flop output
+ Vec_PtrRemove( vSuper2, pObj );
+ break;
+ }
+ Vec_PtrFree( vSuper2 );
+ }
+ Vec_PtrFree( vSuper );
+ if ( vUnique == NULL )
+ {
+ printf( "There is no structural constraints.\n" );
+ return 0;
+ }
+ // vUnique contains unique entries
+ // vSuper2 contains the supergate
+ printf( "Structural analysis found %d original properties and %d constraints.\n",
+ Vec_PtrSize(vUnique), Vec_PtrSize(vSuper2) );
+ // remember the number of constraints
+ RetValue = Vec_PtrSize(vSuper2);
+ // make the AND of properties
+// Vec_PtrFree( vUnique );
+// Vec_PtrFree( vSuper2 );
+ *pvOuts = vUnique;
+ *pvCons = vSuper2;
+ return RetValue;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Experiment with the above procedure.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Saig_ManDetectConstrTest( Aig_Man_t * p )
+{
+ Vec_Ptr_t * vOuts, * vCons;
+ int RetValue = Saig_ManDetectConstr( p, &vOuts, &vCons );
+ Vec_PtrFreeP( &vOuts );
+ Vec_PtrFreeP( &vCons );
+ return RetValue;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/saig/saigConstr2.c b/src/aig/saig/saigConstr2.c
new file mode 100644
index 00000000..a5a575fd
--- /dev/null
+++ b/src/aig/saig/saigConstr2.c
@@ -0,0 +1,1001 @@
+/**CFile****************************************************************
+
+ FileName [saigConstr2.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Sequential AIG package.]
+
+ Synopsis [Functional constraint detection.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: saigConstr2.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "saig.h"
+#include "cnf.h"
+#include "satSolver.h"
+#include "kit.h"
+#include "bar.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+static inline Aig_Obj_t * Aig_ObjFrames( Aig_Obj_t ** pObjMap, int nFs, Aig_Obj_t * pObj, int i ) { return pObjMap[nFs*pObj->Id + i]; }
+static inline void Aig_ObjSetFrames( Aig_Obj_t ** pObjMap, int nFs, Aig_Obj_t * pObj, int i, Aig_Obj_t * pNode ) { pObjMap[nFs*pObj->Id + i] = pNode; }
+
+static inline Aig_Obj_t * Aig_ObjChild0Frames( Aig_Obj_t ** pObjMap, int nFs, Aig_Obj_t * pObj, int i ) { return Aig_ObjFanin0(pObj)? Aig_NotCond(Aig_ObjFrames(pObjMap,nFs,Aig_ObjFanin0(pObj),i), Aig_ObjFaninC0(pObj)) : NULL; }
+static inline Aig_Obj_t * Aig_ObjChild1Frames( Aig_Obj_t ** pObjMap, int nFs, Aig_Obj_t * pObj, int i ) { return Aig_ObjFanin1(pObj)? Aig_NotCond(Aig_ObjFrames(pObjMap,nFs,Aig_ObjFanin1(pObj),i), Aig_ObjFaninC1(pObj)) : NULL; }
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Returns the probability of POs being 1 under rand seq sim.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Ssw_ManProfileConstraints( Aig_Man_t * p, int nWords, int nFrames, int fVerbose )
+{
+ Vec_Ptr_t * vInfo;
+ Vec_Int_t * vProbs, * vProbs2;
+ Aig_Obj_t * pObj, * pObjLi;
+ unsigned * pInfo, * pInfo0, * pInfo1, * pInfoMask, * pInfoMask2;
+ int i, w, f, RetValue = 1, clk = clock();
+ if ( fVerbose )
+ printf( "Simulating %d nodes and %d flops for %d frames with %d words... ",
+ Aig_ManNodeNum(p), Aig_ManRegNum(p), nFrames, nWords );
+ Aig_ManRandom( 1 );
+ vInfo = Vec_PtrAllocSimInfo( Aig_ManObjNumMax(p)+2, nWords );
+ Vec_PtrCleanSimInfo( vInfo, 0, nWords );
+ vProbs = Vec_IntStart( Saig_ManPoNum(p) );
+ vProbs2 = Vec_IntStart( Saig_ManPoNum(p) );
+ // start the constant
+ pInfo = (unsigned *)Vec_PtrEntry( vInfo, Aig_ObjId(Aig_ManConst1(p)) );
+ for ( w = 0; w < nWords; w++ )
+ pInfo[w] = ~0;
+ // start the flop inputs
+ Saig_ManForEachLi( p, pObj, i )
+ {
+ pInfo = (unsigned *)Vec_PtrEntry( vInfo, Aig_ObjId(pObj) );
+ for ( w = 0; w < nWords; w++ )
+ pInfo[w] = 0;
+ }
+ // get the info mask
+ pInfoMask = (unsigned *)Vec_PtrEntry( vInfo, Aig_ManObjNumMax(p) ); // PO failed
+ pInfoMask2 = (unsigned *)Vec_PtrEntry( vInfo, Aig_ManObjNumMax(p)+1 ); // constr failed
+ for ( f = 0; f < nFrames; f++ )
+ {
+ // assign primary inputs
+ Saig_ManForEachPi( p, pObj, i )
+ {
+ pInfo = (unsigned *)Vec_PtrEntry( vInfo, Aig_ObjId(pObj) );
+ for ( w = 0; w < nWords; w++ )
+ pInfo[w] = Aig_ManRandom( 0 );
+ }
+ // move the flop values
+ Saig_ManForEachLiLo( p, pObjLi, pObj, i )
+ {
+ pInfo = (unsigned *)Vec_PtrEntry( vInfo, Aig_ObjId(pObj) );
+ pInfo0 = (unsigned *)Vec_PtrEntry( vInfo, Aig_ObjId(pObjLi) );
+ for ( w = 0; w < nWords; w++ )
+ pInfo[w] = pInfo0[w];
+ }
+ // simulate the nodes
+ Aig_ManForEachNode( p, pObj, i )
+ {
+ pInfo = (unsigned *)Vec_PtrEntry( vInfo, Aig_ObjId(pObj) );
+ pInfo0 = (unsigned *)Vec_PtrEntry( vInfo, Aig_ObjFaninId0(pObj) );
+ pInfo1 = (unsigned *)Vec_PtrEntry( vInfo, Aig_ObjFaninId1(pObj) );
+ if ( Aig_ObjFaninC0(pObj) )
+ {
+ if ( Aig_ObjFaninC1(pObj) )
+ for ( w = 0; w < nWords; w++ )
+ pInfo[w] = ~(pInfo0[w] | pInfo1[w]);
+ else
+ for ( w = 0; w < nWords; w++ )
+ pInfo[w] = ~pInfo0[w] & pInfo1[w];
+ }
+ else
+ {
+ if ( Aig_ObjFaninC1(pObj) )
+ for ( w = 0; w < nWords; w++ )
+ pInfo[w] = pInfo0[w] & ~pInfo1[w];
+ else
+ for ( w = 0; w < nWords; w++ )
+ pInfo[w] = pInfo0[w] & pInfo1[w];
+ }
+ }
+ // clean the mask
+ for ( w = 0; w < nWords; w++ )
+ pInfoMask[w] = pInfoMask2[w] = 0;
+ // simulate the primary outputs
+ Aig_ManForEachPo( p, pObj, i )
+ {
+ pInfo = (unsigned *)Vec_PtrEntry( vInfo, Aig_ObjId(pObj) );
+ pInfo0 = (unsigned *)Vec_PtrEntry( vInfo, Aig_ObjFaninId0(pObj) );
+ if ( i < Saig_ManPoNum(p)-Saig_ManConstrNum(p) || i >= Saig_ManPoNum(p) )
+ {
+ if ( Aig_ObjFaninC0(pObj) )
+ {
+ for ( w = 0; w < nWords; w++ )
+ pInfo[w] = ~pInfo0[w];
+ }
+ else
+ {
+ for ( w = 0; w < nWords; w++ )
+ pInfo[w] = pInfo0[w];
+ }
+ }
+ else
+ {
+ if ( Aig_ObjFaninC0(pObj) )
+ {
+ for ( w = 0; w < nWords; w++ )
+ pInfo[w] |= ~pInfo0[w];
+ }
+ else
+ {
+ for ( w = 0; w < nWords; w++ )
+ pInfo[w] |= pInfo0[w];
+ }
+ }
+ // collect patterns when one of the outputs fails
+ if ( i < Saig_ManPoNum(p)-Saig_ManConstrNum(p) )
+ {
+ for ( w = 0; w < nWords; w++ )
+ pInfoMask[w] |= pInfo[w];
+ }
+ else if ( i < Saig_ManPoNum(p) )
+ {
+ for ( w = 0; w < nWords; w++ )
+ pInfoMask2[w] |= pInfo[w];
+ }
+ }
+ // compare the PO values (mask=1 => out=0) or UNSAT(mask=1 & out=1)
+ Saig_ManForEachPo( p, pObj, i )
+ {
+ pInfo = (unsigned *)Vec_PtrEntry( vInfo, Aig_ObjId(pObj) );
+ for ( w = 0; w < nWords; w++ )
+ Vec_IntAddToEntry( vProbs, i, Aig_WordCountOnes(pInfo[w]) );
+ if ( i < Saig_ManPoNum(p)-Saig_ManConstrNum(p) )
+ {
+ // chek the output
+ for ( w = 0; w < nWords; w++ )
+ if ( pInfo[w] & ~pInfoMask2[w] )
+ break;
+ if ( w == nWords )
+ continue;
+ printf( "Primary output %d fails on some input patterns.\n", i );
+ }
+ else
+ {
+ // collect patterns that block the POs
+ for ( w = 0; w < nWords; w++ )
+ Vec_IntAddToEntry( vProbs2, i, Aig_WordCountOnes(pInfo[w] & pInfoMask[w]) );
+ }
+ }
+ }
+ if ( fVerbose )
+ Abc_PrintTime( 1, "T", clock() - clk );
+ // print the state
+ if ( fVerbose )
+ {
+ Saig_ManForEachPo( p, pObj, i )
+ {
+ if ( i < Saig_ManPoNum(p) - Saig_ManConstrNum(p) )
+ printf( "Primary output : ", i );
+ else
+ printf( "Constraint %3d : ", i-(Saig_ManPoNum(p) - Saig_ManConstrNum(p)) );
+ printf( "ProbOne = %f ", (float)Vec_IntEntry(vProbs, i)/(32*nWords*nFrames) );
+ printf( "ProbOneC = %f ", (float)Vec_IntEntry(vProbs2, i)/(32*nWords*nFrames) );
+ printf( "AllZeroValue = %d ", Aig_ObjPhase(pObj) );
+ printf( "\n" );
+ }
+ }
+
+ // print the states
+ Vec_PtrFree( vInfo );
+ Vec_IntFree( vProbs );
+ Vec_IntFree( vProbs2 );
+ return RetValue;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates COI of the property output.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Man_t * Saig_ManCreateIndMiter( Aig_Man_t * pAig, Vec_Vec_t * vCands )
+{
+ int nFrames = 2;
+ Vec_Ptr_t * vNodes;
+ Aig_Man_t * pFrames;
+ Aig_Obj_t * pObj, * pObjLi, * pObjLo, * pObjNew;
+ Aig_Obj_t ** pObjMap;
+ int i, f, k;
+
+ // create mapping for the frames nodes
+ pObjMap = ABC_CALLOC( Aig_Obj_t *, nFrames * Aig_ManObjNumMax(pAig) );
+
+ // start the fraig package
+ pFrames = Aig_ManStart( Aig_ManObjNumMax(pAig) * nFrames );
+ pFrames->pName = Aig_UtilStrsav( pAig->pName );
+ pFrames->pSpec = Aig_UtilStrsav( pAig->pSpec );
+ // map constant nodes
+ for ( f = 0; f < nFrames; f++ )
+ Aig_ObjSetFrames( pObjMap, nFrames, Aig_ManConst1(pAig), f, Aig_ManConst1(pFrames) );
+ // create PI nodes for the frames
+ for ( f = 0; f < nFrames; f++ )
+ Aig_ManForEachPiSeq( pAig, pObj, i )
+ Aig_ObjSetFrames( pObjMap, nFrames, pObj, f, Aig_ObjCreatePi(pFrames) );
+ // set initial state for the latches
+ Aig_ManForEachLoSeq( pAig, pObj, i )
+ Aig_ObjSetFrames( pObjMap, nFrames, pObj, 0, Aig_ObjCreatePi(pFrames) );
+
+ // add timeframes
+ for ( f = 0; f < nFrames; f++ )
+ {
+ // add internal nodes of this frame
+ Aig_ManForEachNode( pAig, pObj, i )
+ {
+ pObjNew = Aig_And( pFrames, Aig_ObjChild0Frames(pObjMap,nFrames,pObj,f), Aig_ObjChild1Frames(pObjMap,nFrames,pObj,f) );
+ Aig_ObjSetFrames( pObjMap, nFrames, pObj, f, pObjNew );
+ }
+ // set the latch inputs and copy them into the latch outputs of the next frame
+ Aig_ManForEachLiLoSeq( pAig, pObjLi, pObjLo, i )
+ {
+ pObjNew = Aig_ObjChild0Frames(pObjMap,nFrames,pObjLi,f);
+ if ( f < nFrames - 1 )
+ Aig_ObjSetFrames( pObjMap, nFrames, pObjLo, f+1, pObjNew );
+ }
+ }
+
+ // go through the candidates
+ Vec_VecForEachLevel( vCands, vNodes, i )
+ {
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, k )
+ {
+ Aig_Obj_t * pObjR = Aig_Regular(pObj);
+ Aig_Obj_t * pNode0 = pObjMap[nFrames*Aig_ObjId(pObjR)+0];
+ Aig_Obj_t * pNode1 = pObjMap[nFrames*Aig_ObjId(pObjR)+1];
+ Aig_Obj_t * pFan0 = Aig_NotCond( pNode0, Aig_IsComplement(pObj) );
+ Aig_Obj_t * pFan1 = Aig_NotCond( pNode1, !Aig_IsComplement(pObj) );
+ Aig_Obj_t * pMiter = Aig_And( pFrames, pFan0, pFan1 );
+ Aig_ObjCreatePo( pFrames, pMiter );
+ }
+ }
+ Aig_ManCleanup( pFrames );
+ ABC_FREE( pObjMap );
+
+//Aig_ManShow( pAig, 0, NULL );
+//Aig_ManShow( pFrames, 0, NULL );
+ return pFrames;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs inductive check for one of the constraints.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Saig_ManFilterUsingIndOne_new( Aig_Man_t * p, Aig_Man_t * pFrame, sat_solver * pSat, Cnf_Dat_t * pCnf, int nConfs, int nProps, int Counter )
+{
+ Aig_Obj_t * pObj;
+ int Lit, status;
+ pObj = Aig_ManPo( pFrame, Counter );
+ Lit = toLitCond( pCnf->pVarNums[Aig_ObjId(pObj)], 0 );
+ status = sat_solver_solve( pSat, &Lit, &Lit + 1, (ABC_INT64_T)nConfs, 0, 0, 0 );
+ if ( status == l_False )
+ return 1;
+ if ( status == l_Undef )
+ {
+// printf( "Solver returned undecided.\n" );
+ return 0;
+ }
+ assert( status == l_True );
+ return 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Detects constraints functionally.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Saig_ManFilterUsingInd( Aig_Man_t * p, Vec_Vec_t * vCands, int nConfs, int nProps, int fVerbose )
+{
+ Vec_Ptr_t * vNodes;
+ Aig_Man_t * pFrames;
+ sat_solver * pSat;
+ Cnf_Dat_t * pCnf;
+ Aig_Obj_t * pObj;
+ int i, k, k2, Counter;
+/*
+ Vec_VecForEachLevel( vCands, vNodes, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, k )
+ printf( "%d ", Aig_ObjId(Aig_Regular(pObj)) );
+ printf( "\n" );
+*/
+ // create timeframes
+// pFrames = Saig_ManUnrollInd( p );
+ pFrames = Saig_ManCreateIndMiter( p, vCands );
+ assert( Aig_ManPoNum(pFrames) == Vec_VecSizeSize(vCands) );
+ // start the SAT solver
+ pCnf = Cnf_DeriveSimple( pFrames, Aig_ManPoNum(pFrames) );
+ pSat = (sat_solver *)Cnf_DataWriteIntoSolver( pCnf, 1, 0 );
+ // check candidates
+ if ( fVerbose )
+ printf( "Filtered cands: " );
+ Counter = 0;
+ Vec_VecForEachLevel( vCands, vNodes, i )
+ {
+ k2 = 0;
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, k )
+ {
+ if ( Saig_ManFilterUsingIndOne_new( p, pFrames, pSat, pCnf, nConfs, nProps, Counter++ ) )
+// if ( Saig_ManFilterUsingIndOne_old( p, pSat, pCnf, nConfs, pObj ) )
+ {
+ Vec_PtrWriteEntry( vNodes, k2++, pObj );
+ if ( fVerbose )
+ printf( "%d:%s%d ", i, Aig_IsComplement(pObj)? "!":"", Aig_ObjId(Aig_Regular(pObj)) );
+ }
+ }
+ Vec_PtrShrink( vNodes, k2 );
+ }
+ if ( fVerbose )
+ printf( "\n" );
+ // clean up
+ Cnf_DataFree( pCnf );
+ sat_solver_delete( pSat );
+ if ( fVerbose )
+ Aig_ManPrintStats( pFrames );
+ Aig_ManStop( pFrames );
+}
+
+
+
+
+/**Function*************************************************************
+
+ Synopsis [Creates COI of the property output.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Man_t * Saig_ManUnrollCOI_( Aig_Man_t * p, int nFrames )
+{
+ Aig_Man_t * pFrames;
+ Aig_Obj_t ** pObjMap;
+ int i;
+//Aig_Man_t * Aig_ManFrames( Aig_Man_t * pAig, int nFrames, int fInit, int fOuts, int fRegs, int fEnlarge, Aig_Obj_t *** ppObjMap )
+ pFrames = Aig_ManFrames( p, nFrames, 0, 1, 1, 0, &pObjMap );
+ for ( i = 0; i < nFrames * Aig_ManObjNumMax(p); i++ )
+ if ( pObjMap[i] && Aig_ObjIsNone( Aig_Regular(pObjMap[i]) ) )
+ pObjMap[i] = NULL;
+ assert( p->pObjCopies == NULL );
+ p->pObjCopies = pObjMap;
+ return pFrames;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates COI of the property output.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Man_t * Saig_ManUnrollCOI( Aig_Man_t * pAig, int nFrames )
+{
+ Aig_Man_t * pFrames;
+ Aig_Obj_t * pObj, * pObjLi, * pObjLo, * pObjNew;
+ Aig_Obj_t ** pObjMap;
+ int i, f;
+ // create mapping for the frames nodes
+ pObjMap = ABC_CALLOC( Aig_Obj_t *, nFrames * Aig_ManObjNumMax(pAig) );
+ // start the fraig package
+ pFrames = Aig_ManStart( Aig_ManObjNumMax(pAig) * nFrames );
+ pFrames->pName = Aig_UtilStrsav( pAig->pName );
+ pFrames->pSpec = Aig_UtilStrsav( pAig->pSpec );
+ // map constant nodes
+ for ( f = 0; f < nFrames; f++ )
+ Aig_ObjSetFrames( pObjMap, nFrames, Aig_ManConst1(pAig), f, Aig_ManConst1(pFrames) );
+ // create PI nodes for the frames
+ for ( f = 0; f < nFrames; f++ )
+ Aig_ManForEachPiSeq( pAig, pObj, i )
+ Aig_ObjSetFrames( pObjMap, nFrames, pObj, f, Aig_ObjCreatePi(pFrames) );
+ // set initial state for the latches
+ Aig_ManForEachLoSeq( pAig, pObj, i )
+ Aig_ObjSetFrames( pObjMap, nFrames, pObj, 0, Aig_ObjCreatePi(pFrames) );
+ // add timeframes
+ for ( f = 0; f < nFrames; f++ )
+ {
+ Aig_ManForEachNode( pAig, pObj, i )
+ {
+ pObjNew = Aig_And( pFrames, Aig_ObjChild0Frames(pObjMap,nFrames,pObj,f), Aig_ObjChild1Frames(pObjMap,nFrames,pObj,f) );
+ Aig_ObjSetFrames( pObjMap, nFrames, pObj, f, pObjNew );
+ }
+ // set the latch inputs and copy them into the latch outputs of the next frame
+ Aig_ManForEachLiLoSeq( pAig, pObjLi, pObjLo, i )
+ {
+ pObjNew = Aig_ObjChild0Frames(pObjMap,nFrames,pObjLi,f);
+ if ( f < nFrames - 1 )
+ Aig_ObjSetFrames( pObjMap, nFrames, pObjLo, f+1, pObjNew );
+ }
+ }
+ // create the only output
+ for ( f = nFrames-1; f < nFrames; f++ )
+ {
+ Aig_ManForEachPoSeq( pAig, pObj, i )
+ {
+ pObjNew = Aig_ObjCreatePo( pFrames, Aig_ObjChild0Frames(pObjMap,nFrames,pObj,f) );
+ Aig_ObjSetFrames( pObjMap, nFrames, pObj, f, pObjNew );
+ }
+ }
+ // created lots of dangling nodes - no sweeping!
+ //Aig_ManCleanup( pFrames );
+ assert( pAig->pObjCopies == NULL );
+ pAig->pObjCopies = pObjMap;
+ return pFrames;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Collects and saves values of the SAT variables.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Saig_CollectSatValues( sat_solver * pSat, Cnf_Dat_t * pCnf, Vec_Ptr_t * vInfo, int * piPat )
+{
+ Aig_Obj_t * pObj;
+ unsigned * pInfo;
+ int i;
+ Aig_ManForEachObj( pCnf->pMan, pObj, i )
+ {
+ if ( !Aig_ObjIsNode(pObj) && !Aig_ObjIsPi(pObj) )
+ continue;
+ assert( pCnf->pVarNums[i] > 0 );
+ pInfo = (unsigned *)Vec_PtrEntry( vInfo, i );
+ if ( Aig_InfoHasBit(pInfo, *piPat) != sat_solver_var_value(pSat, pCnf->pVarNums[i]) )
+ Aig_InfoXorBit(pInfo, *piPat);
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Runs the SAT test for the node in one polarity.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Saig_DetectTryPolarity( sat_solver * pSat, int nConfs, int nProps, Cnf_Dat_t * pCnf, Aig_Obj_t * pObj, int iPol, Vec_Ptr_t * vInfo, int * piPat, int fVerbose )
+{
+ Aig_Obj_t * pOut = Aig_ManPo( pCnf->pMan, 0 );
+ int status, Lits[2];
+// ABC_INT64_T nOldConfs = pSat->stats.conflicts;
+// ABC_INT64_T nOldImps = pSat->stats.propagations;
+ Lits[0] = toLitCond( pCnf->pVarNums[Aig_ObjId(pOut)], 0 );
+ Lits[1] = toLitCond( pCnf->pVarNums[Aig_ObjId(pObj)], !iPol );
+ status = sat_solver_solve( pSat, Lits, Lits + 2, (ABC_INT64_T)nConfs, (ABC_INT64_T)nProps, 0, 0 );
+ if ( status == l_False )
+ {
+// printf( "u%d(%d) ", (int)(pSat->stats.conflicts-nOldConfs), (int)(pSat->stats.propagations-nOldImps) );
+ return 1;
+ }
+ if ( status == l_Undef )
+ {
+// printf( "Solver returned undecided.\n" );
+ return 0;
+ }
+// printf( "s%d(%d) ", (int)(pSat->stats.conflicts-nOldConfs), (int)(pSat->stats.propagations-nOldImps) );
+ assert( status == l_True );
+ Saig_CollectSatValues( pSat, pCnf, vInfo, piPat );
+ (*piPat)++;
+ if ( *piPat == Vec_PtrReadWordsSimInfo(vInfo) * 32 )
+ {
+ if ( fVerbose )
+ printf( "Warning: Reached the limit on the number of patterns.\n" );
+ *piPat = 0;
+ }
+ return 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the number of variables implied by the output.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Vec_t * Ssw_ManFindDirectImplications( Aig_Man_t * p, int nFrames, int nConfs, int nProps, int fVerbose )
+{
+ Vec_Vec_t * vCands = NULL;
+ Vec_Ptr_t * vNodes;
+ Cnf_Dat_t * pCnf;
+ sat_solver * pSat;
+ Aig_Man_t * pFrames;
+ Aig_Obj_t * pObj, * pRepr, * pReprR;
+ int i, f, k, value;
+ vCands = Vec_VecAlloc( nFrames );
+
+ // perform unrolling
+ pFrames = Saig_ManUnrollCOI( p, nFrames );
+ assert( Aig_ManPoNum(pFrames) == 1 );
+ // start the SAT solver
+ pCnf = Cnf_DeriveSimple( pFrames, 0 );
+ pSat = (sat_solver *)Cnf_DataWriteIntoSolver( pCnf, 1, 0 );
+ if ( pSat != NULL )
+ {
+ Aig_ManIncrementTravId( p );
+ for ( f = 0; f < nFrames; f++ )
+ {
+ Aig_ManForEachObj( p, pObj, i )
+ {
+ if ( !Aig_ObjIsCand(pObj) )
+ continue;
+ if ( Aig_ObjIsTravIdCurrent(p, pObj) )
+ continue;
+ // get the node from timeframes
+ pRepr = p->pObjCopies[nFrames*i + nFrames-1-f];
+ pReprR = Aig_Regular(pRepr);
+ if ( pCnf->pVarNums[Aig_ObjId(pReprR)] < 0 )
+ continue;
+ value = pSat->assigns[ pCnf->pVarNums[Aig_ObjId(pReprR)] ];
+ if ( value == l_Undef )
+ continue;
+ // label this node as taken
+ Aig_ObjSetTravIdCurrent(p, pObj);
+ if ( Saig_ObjIsLo(p, pObj) )
+ Aig_ObjSetTravIdCurrent( p, Aig_ObjFanin0(Saig_ObjLoToLi(p, pObj)) );
+ // remember the node
+ Vec_VecPush( vCands, f, Aig_NotCond( pObj, (value == l_True) ^ Aig_IsComplement(pRepr) ) );
+ // printf( "%s%d ", (value == l_False)? "":"!", i );
+ }
+ }
+ // printf( "\n" );
+ sat_solver_delete( pSat );
+ }
+ Aig_ManStop( pFrames );
+ Cnf_DataFree( pCnf );
+
+ if ( fVerbose )
+ {
+ printf( "Found %3d candidates.\n", Vec_VecSizeSize(vCands) );
+ Vec_VecForEachLevel( vCands, vNodes, k )
+ {
+ printf( "Level %d. Cands =%d ", k, Vec_PtrSize(vNodes) );
+// Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
+// printf( "%d:%s%d ", k, Aig_IsComplement(pObj)? "!":"", Aig_ObjId(Aig_Regular(pObj)) );
+ printf( "\n" );
+ }
+ }
+
+ ABC_FREE( p->pObjCopies );
+ Saig_ManFilterUsingInd( p, vCands, nConfs, nProps, fVerbose );
+ if ( Vec_VecSizeSize(vCands) )
+ printf( "Found %3d constraints after filtering.\n", Vec_VecSizeSize(vCands) );
+ if ( fVerbose )
+ {
+ Vec_VecForEachLevel( vCands, vNodes, k )
+ {
+ printf( "Level %d. Constr =%d ", k, Vec_PtrSize(vNodes) );
+// Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
+// printf( "%d:%s%d ", k, Aig_IsComplement(pObj)? "!":"", Aig_ObjId(Aig_Regular(pObj)) );
+ printf( "\n" );
+ }
+ }
+
+ return vCands;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Detects constraints functionally.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Vec_t * Saig_ManDetectConstrFunc( Aig_Man_t * p, int nFrames, int nConfs, int nProps, int fVerbose )
+{
+ int iPat = 0, nWordsAlloc = 16;
+ Bar_Progress_t * pProgress = NULL;
+ Vec_Vec_t * vCands = NULL;
+ Vec_Ptr_t * vInfo, * vNodes;
+ Aig_Obj_t * pObj, * pRepr, * pObjNew;
+ Aig_Man_t * pFrames;
+ sat_solver * pSat;
+ Cnf_Dat_t * pCnf;
+ unsigned * pInfo;
+ int i, j, k, Lit, status, nCands = 0;
+ assert( Saig_ManPoNum(p) == 1 );
+ if ( Saig_ManPoNum(p) != 1 )
+ {
+ printf( "The number of outputs is different from 1.\n" );
+ return NULL;
+ }
+//printf( "Implications = %d.\n", Ssw_ManCountImplications(p, nFrames) );
+
+ // perform unrolling
+ pFrames = Saig_ManUnrollCOI( p, nFrames );
+ assert( Aig_ManPoNum(pFrames) == 1 );
+ if ( fVerbose )
+ {
+ printf( "Detecting constraints with %d frames, %d conflicts, and %d propagations.\n", nFrames, nConfs, nProps );
+ printf( "Frames: " );
+ Aig_ManPrintStats( pFrames );
+ }
+// Aig_ManShow( pFrames, 0, NULL );
+
+ // start the SAT solver
+ pCnf = Cnf_DeriveSimple( pFrames, Aig_ManPoNum(pFrames) );
+ pSat = (sat_solver *)Cnf_DataWriteIntoSolver( pCnf, 1, 0 );
+//printf( "Implications = %d.\n", pSat->qhead );
+
+ // solve the original problem
+ Lit = toLitCond( pCnf->pVarNums[Aig_ObjId(Aig_ManPo(pFrames,0))], 0 );
+ status = sat_solver_solve( pSat, &Lit, &Lit + 1, (ABC_INT64_T)nConfs, 0, 0, 0 );
+ if ( status == l_False )
+ {
+ printf( "The problem is trivially UNSAT (inductive with k=%d).\n", nFrames-1 );
+ Cnf_DataFree( pCnf );
+ sat_solver_delete( pSat );
+ Aig_ManStop( pFrames );
+ return NULL;
+ }
+ if ( status == l_Undef )
+ {
+ printf( "Solver could not solve the original problem.\n" );
+ Cnf_DataFree( pCnf );
+ sat_solver_delete( pSat );
+ Aig_ManStop( pFrames );
+ return NULL;
+ }
+ assert( status == l_True );
+
+ // create simulation info
+ vInfo = Vec_PtrAllocSimInfo( Aig_ManObjNumMax(pFrames), nWordsAlloc );
+ Vec_PtrCleanSimInfo( vInfo, 0, nWordsAlloc );
+ Saig_CollectSatValues( pSat, pCnf, vInfo, &iPat );
+ Aig_ManForEachObj( pFrames, pObj, i )
+ {
+ pInfo = (unsigned *)Vec_PtrEntry( vInfo, i );
+ if ( pInfo[0] & 1 )
+ memset( (char*)pInfo, 0xff, 4*nWordsAlloc );
+ }
+// Aig_ManShow( pFrames, 0, NULL );
+// Aig_ManShow( p, 0, NULL );
+
+ // consider the nodes for ci=>!Out and label when it holds
+ pProgress = Bar_ProgressStart( stdout, Aig_ManObjNumMax(pFrames) );
+ Aig_ManCleanMarkAB( pFrames );
+ Aig_ManForEachObj( pFrames, pObj, i )
+ {
+ if ( !Aig_ObjIsNode(pObj) && !Aig_ObjIsPi(pObj) )
+ continue;
+ Bar_ProgressUpdate( pProgress, i, NULL );
+ // check if the node is available in both polarities
+ pInfo = (unsigned *)Vec_PtrEntry( vInfo, i );
+ for ( k = 0; k < nWordsAlloc; k++ )
+ if ( pInfo[k] != ~0 )
+ break;
+ if ( k == nWordsAlloc )
+ {
+ if ( Saig_DetectTryPolarity(pSat, nConfs, nProps, pCnf, pObj, 0, vInfo, &iPat, fVerbose) ) // !pObj is a constr
+ {
+ pObj->fMarkA = 1, nCands++;
+// printf( "!%d ", Aig_ObjId(pObj) );
+ }
+ continue;
+ }
+ for ( k = 0; k < nWordsAlloc; k++ )
+ if ( pInfo[k] != 0 )
+ break;
+ if ( k == nWordsAlloc )
+ {
+ if ( Saig_DetectTryPolarity(pSat, nConfs, nProps, pCnf, pObj, 1, vInfo, &iPat, fVerbose) ) // pObj is a constr
+ {
+ pObj->fMarkB = 1, nCands++;
+// printf( "%d ", Aig_ObjId(pObj) );
+ }
+ continue;
+ }
+ }
+ Bar_ProgressStop( pProgress );
+ if ( nCands )
+ {
+
+// printf( "\n" );
+ if ( fVerbose )
+ printf( "Found %3d classes of candidates.\n", nCands );
+ vCands = Vec_VecAlloc( nFrames );
+ for ( k = 0; k < nFrames; k++ )
+ {
+ Aig_ManForEachObj( p, pObj, i )
+ {
+ if ( !Aig_ObjIsNode(pObj) && !Aig_ObjIsPi(pObj) )
+ continue;
+ pRepr = p->pObjCopies[nFrames*i + nFrames-1-k];
+// pRepr = p->pObjCopies[nFrames*i + k];
+ if ( pRepr == NULL )
+ continue;
+ if ( Aig_Regular(pRepr)->fMarkA ) // !pObj is a constr
+ {
+ pObjNew = Aig_NotCond(pObj, !Aig_IsComplement(pRepr));
+
+ for ( j = 0; j < k; j++ )
+ if ( Vec_PtrFind( (Vec_Ptr_t *)Vec_VecEntry(vCands, j), pObjNew ) >= 0 )
+ break;
+ if ( j == k )
+ Vec_VecPush( vCands, k, pObjNew );
+// printf( "%d->!%d ", Aig_ObjId(Aig_Regular(pRepr)), Aig_ObjId(pObj) );
+ }
+ else if ( Aig_Regular(pRepr)->fMarkB ) // pObj is a constr
+ {
+ pObjNew = Aig_NotCond(pObj, Aig_IsComplement(pRepr));
+
+ for ( j = 0; j < k; j++ )
+ if ( Vec_PtrFind( (Vec_Ptr_t *)Vec_VecEntry(vCands, j), pObjNew ) >= 0 )
+ break;
+ if ( j == k )
+ Vec_VecPush( vCands, k, pObjNew );
+// printf( "%d->%d ", Aig_ObjId(Aig_Regular(pRepr)), Aig_ObjId(pObj) );
+ }
+ }
+ }
+
+// printf( "\n" );
+ if ( fVerbose )
+ {
+ printf( "Found %3d candidates.\n", Vec_VecSizeSize(vCands) );
+ Vec_VecForEachLevel( vCands, vNodes, k )
+ {
+ printf( "Level %d. Cands =%d ", k, Vec_PtrSize(vNodes) );
+// Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
+// printf( "%d:%s%d ", k, Aig_IsComplement(pObj)? "!":"", Aig_ObjId(Aig_Regular(pObj)) );
+ printf( "\n" );
+ }
+ }
+
+ ABC_FREE( p->pObjCopies );
+ Saig_ManFilterUsingInd( p, vCands, nConfs, nProps, fVerbose );
+ if ( Vec_VecSizeSize(vCands) )
+ printf( "Found %3d constraints after filtering.\n", Vec_VecSizeSize(vCands) );
+ if ( fVerbose )
+ {
+ Vec_VecForEachLevel( vCands, vNodes, k )
+ {
+ printf( "Level %d. Constr =%d ", k, Vec_PtrSize(vNodes) );
+// Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
+// printf( "%d:%s%d ", k, Aig_IsComplement(pObj)? "!":"", Aig_ObjId(Aig_Regular(pObj)) );
+ printf( "\n" );
+ }
+ }
+ }
+ Vec_PtrFree( vInfo );
+ Cnf_DataFree( pCnf );
+ sat_solver_delete( pSat );
+ Aig_ManCleanMarkAB( pFrames );
+ Aig_ManStop( pFrames );
+ return vCands;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Experimental procedure.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Saig_ManDetectConstrFuncTest( Aig_Man_t * p, int nFrames, int nConfs, int nProps, int fOldAlgo, int fVerbose )
+{
+ Vec_Vec_t * vCands;
+ if ( fOldAlgo )
+ vCands = Saig_ManDetectConstrFunc( p, nFrames, nConfs, nProps, fVerbose );
+ else
+ vCands = Ssw_ManFindDirectImplications( p, nFrames, nConfs, nProps, fVerbose );
+ Vec_VecFreeP( &vCands );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Duplicates the AIG while unfolding constraints.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Man_t * Saig_ManDupUnfoldConstrsFunc( Aig_Man_t * pAig, int nFrames, int nConfs, int nProps, int fOldAlgo, int fVerbose )
+{
+ Aig_Man_t * pNew;
+ Vec_Vec_t * vCands;
+ Vec_Ptr_t * vNodes, * vNewFlops;
+ Aig_Obj_t * pObj;
+ int i, j, k, nNewFlops;
+ if ( fOldAlgo )
+ vCands = Saig_ManDetectConstrFunc( pAig, nFrames, nConfs, nProps, fVerbose );
+ else
+ vCands = Ssw_ManFindDirectImplications( pAig, nFrames, nConfs, nProps, fVerbose );
+ if ( vCands == NULL || Vec_VecSizeSize(vCands) == 0 )
+ {
+ Vec_VecFreeP( &vCands );
+ return Aig_ManDupDfs( pAig );
+ }
+ // create new manager
+ pNew = Aig_ManDupWithoutPos( pAig );
+ pNew->nConstrs = pAig->nConstrs + Vec_VecSizeSize(vCands);
+ // add normal POs
+ Saig_ManForEachPo( pAig, pObj, i )
+ Aig_ObjCreatePo( pNew, Aig_ObjChild0Copy(pObj) );
+ // create constraint outputs
+ vNewFlops = Vec_PtrAlloc( 100 );
+ Vec_VecForEachLevel( vCands, vNodes, i )
+ {
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, k )
+ {
+ Vec_PtrPush( vNewFlops, Aig_ObjRealCopy(pObj) );
+ for ( j = 0; j < i; j++ )
+ Vec_PtrPush( vNewFlops, Aig_ObjCreatePi(pNew) );
+ Aig_ObjCreatePo( pNew, (Aig_Obj_t *)Vec_PtrPop(vNewFlops) );
+ }
+ }
+ // add latch outputs
+ Saig_ManForEachLi( pAig, pObj, i )
+ Aig_ObjCreatePo( pNew, Aig_ObjChild0Copy(pObj) );
+ // add new latch outputs
+ nNewFlops = 0;
+ Vec_VecForEachLevel( vCands, vNodes, i )
+ {
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, k )
+ {
+ for ( j = 0; j < i; j++ )
+ Aig_ObjCreatePo( pNew, (Aig_Obj_t *)Vec_PtrEntry(vNewFlops, nNewFlops++) );
+ }
+ }
+ assert( nNewFlops == Vec_PtrSize(vNewFlops) );
+ Aig_ManSetRegNum( pNew, Aig_ManRegNum(pAig) + nNewFlops );
+ Vec_VecFreeP( &vCands );
+ Vec_PtrFree( vNewFlops );
+ return pNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Duplicates the AIG while unfolding constraints.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Man_t * Saig_ManDupFoldConstrsFunc( Aig_Man_t * pAig, int fCompl, int fVerbose )
+{
+ Aig_Man_t * pAigNew;
+ Aig_Obj_t * pMiter, * pFlopOut, * pFlopIn, * pObj;
+ int i;
+ assert( Saig_ManRegNum(pAig) > 0 );
+ if ( Aig_ManConstrNum(pAig) == 0 )
+ return Aig_ManDupDfs( pAig );
+ assert( Aig_ManConstrNum(pAig) < Saig_ManPoNum(pAig) );
+ // start the new manager
+ pAigNew = Aig_ManStart( Aig_ManNodeNum(pAig) );
+ pAigNew->pName = Aig_UtilStrsav( pAig->pName );
+ pAigNew->pSpec = Aig_UtilStrsav( pAig->pSpec );
+ // map the constant node
+ Aig_ManConst1(pAig)->pData = Aig_ManConst1( pAigNew );
+ // create variables for PIs
+ Aig_ManForEachPi( pAig, pObj, i )
+ pObj->pData = Aig_ObjCreatePi( pAigNew );
+ // add internal nodes of this frame
+ Aig_ManForEachNode( pAig, pObj, i )
+ pObj->pData = Aig_And( pAigNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
+
+ // OR the constraint outputs
+ pMiter = Aig_ManConst0( pAigNew );
+ Saig_ManForEachPo( pAig, pObj, i )
+ {
+ if ( i < Saig_ManPoNum(pAig)-Aig_ManConstrNum(pAig) )
+ continue;
+ pMiter = Aig_Or( pAigNew, pMiter, Aig_NotCond( Aig_ObjChild0Copy(pObj), fCompl ) );
+ }
+ // create additional flop
+ pFlopOut = Aig_ObjCreatePi( pAigNew );
+ pFlopIn = Aig_Or( pAigNew, pMiter, pFlopOut );
+
+ // create primary output
+ Saig_ManForEachPo( pAig, pObj, i )
+ {
+ if ( i >= Saig_ManPoNum(pAig)-Aig_ManConstrNum(pAig) )
+ continue;
+ pMiter = Aig_And( pAigNew, Aig_ObjChild0Copy(pObj), Aig_Not(pFlopIn) );
+ Aig_ObjCreatePo( pAigNew, pMiter );
+ }
+
+ // transfer to register outputs
+ Saig_ManForEachLi( pAig, pObj, i )
+ Aig_ObjCreatePo( pAigNew, Aig_ObjChild0Copy(pObj) );
+ // create additional flop
+ Aig_ObjCreatePo( pAigNew, pFlopIn );
+
+ Aig_ManSetRegNum( pAigNew, Aig_ManRegNum(pAig)+1 );
+ Aig_ManCleanup( pAigNew );
+ Aig_ManSeqCleanup( pAigNew );
+ return pAigNew;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/saig/saigDup.c b/src/aig/saig/saigDup.c
index e261fca1..268540da 100644
--- a/src/aig/saig/saigDup.c
+++ b/src/aig/saig/saigDup.c
@@ -20,6 +20,9 @@
#include "saig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -44,9 +47,15 @@ Aig_Man_t * Said_ManDupOrpos( Aig_Man_t * pAig )
Aig_Man_t * pAigNew;
Aig_Obj_t * pObj, * pMiter;
int i;
+ if ( pAig->nConstrs > 0 )
+ {
+ printf( "The AIG manager should have no constraints.\n" );
+ return NULL;
+ }
// start the new manager
pAigNew = Aig_ManStart( Aig_ManNodeNum(pAig) );
pAigNew->pName = Aig_UtilStrsav( pAig->pName );
+ pAigNew->nConstrs = pAig->nConstrs;
// map the constant node
Aig_ManConst1(pAig)->pData = Aig_ManConst1( pAigNew );
// create variables for PIs
@@ -82,10 +91,10 @@ Aig_Man_t * Said_ManDupOrpos( Aig_Man_t * pAig )
Aig_Obj_t * Saig_ManAbstractionDfs_rec( Aig_Man_t * pNew, Aig_Obj_t * pObj )
{
if ( pObj->pData )
- return pObj->pData;
+ return (Aig_Obj_t *)pObj->pData;
Saig_ManAbstractionDfs_rec( pNew, Aig_ObjFanin0(pObj) );
Saig_ManAbstractionDfs_rec( pNew, Aig_ObjFanin1(pObj) );
- return pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
+ return (Aig_Obj_t *)(pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) ));
}
/**Function*************************************************************
@@ -112,6 +121,7 @@ Aig_Man_t * Saig_ManTrimPis( Aig_Man_t * p )
// start the new manager
pNew = Aig_ManStart( Aig_ManObjNum(p) );
pNew->pName = Aig_UtilStrsav( p->pName );
+ pNew->nConstrs = p->nConstrs;
// start mapping of the CI numbers
pNew->vCiNumsOrig = Vec_IntAlloc( Aig_ManPiNum(p) );
// map const and primary inputs
@@ -142,9 +152,9 @@ Aig_Man_t * Saig_ManTrimPis( Aig_Man_t * p )
SeeAlso []
***********************************************************************/
-Aig_Man_t * Saig_ManAbstraction( Aig_Man_t * p, Vec_Int_t * vFlops )
+Aig_Man_t * Saig_ManDeriveAbstraction( Aig_Man_t * p, Vec_Int_t * vFlops )
{
- Aig_Man_t * pNew, * pTemp;
+ Aig_Man_t * pNew;//, * pTemp;
Aig_Obj_t * pObj, * pObjLi, * pObjLo;
int i, Entry;
Aig_ManCleanData( p );
@@ -200,8 +210,8 @@ Aig_Man_t * Saig_ManAbstraction( Aig_Man_t * p, Vec_Int_t * vFlops )
Aig_ManSetRegNum( pNew, Vec_IntSize(vFlops) );
Aig_ManSeqCleanup( pNew );
// remove PIs without fanout
- pNew = Saig_ManTrimPis( pTemp = pNew );
- Aig_ManStop( pTemp );
+// pNew = Saig_ManTrimPis( pTemp = pNew );
+// Aig_ManStop( pTemp );
return pNew;
}
@@ -210,3 +220,5 @@ Aig_Man_t * Saig_ManAbstraction( Aig_Man_t * p, Vec_Int_t * vFlops )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/saig/saigHaig.c b/src/aig/saig/saigHaig.c
index 1c7aa025..3ea0a2c6 100644
--- a/src/aig/saig/saigHaig.c
+++ b/src/aig/saig/saigHaig.c
@@ -22,6 +22,9 @@
#include "satSolver.h"
#include "cnf.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -51,9 +54,9 @@ void Aig_ManHaigSpeculate( Aig_Man_t * pFrames, Aig_Obj_t * pObj )
return;
// assert( pObjRepr->Id < pObj->Id );
// get the new node
- pObjNew = pObj->pData;
+ pObjNew = (Aig_Obj_t *)pObj->pData;
// get the new node of the representative
- pObjReprNew = pObjRepr->pData;
+ pObjReprNew = (Aig_Obj_t *)pObjRepr->pData;
// if this is the same node, no need to add constraints
assert( pObjNew != NULL && pObjReprNew != NULL );
if ( Aig_Regular(pObjNew) == Aig_Regular(pObjReprNew) )
@@ -233,7 +236,7 @@ clk = clock();
// Saig_ManDumpBlif( pHaig, "haig_temp.blif" );
// Saig_ManDumpBlif( pFrames, "haig_temp_frames.blif" );
// create the SAT solver to be used for this problem
- pSat = Cnf_DataWriteIntoSolver( pCnf, 1, 0 );
+ pSat = (sat_solver *)Cnf_DataWriteIntoSolver( pCnf, 1, 0 );
if ( pSat == NULL )
{
printf( "Aig_ManHaigVerify(): Computed CNF is not valid.\n" );
@@ -422,7 +425,7 @@ clk = clock();
// printf( "\n" );
// create the SAT solver to be used for this problem
- pSat = Cnf_DataWriteIntoSolver( pCnf, nFrames, 0 );
+ pSat = (sat_solver *)Cnf_DataWriteIntoSolver( pCnf, nFrames, 0 );
//Sat_SolverWriteDimacs( pSat, "1.cnf", NULL, NULL, 0 );
if ( pSat == NULL )
{
@@ -586,7 +589,7 @@ Aig_Man_t * Saig_ManHaigDump( Aig_Man_t * pHaig )
}
printf( "Added %d property outputs.\n", Vec_IntSize(pHaig->vEquPairs)/2 );
// add the registers
- Vec_PtrForEachEntry( vTemp, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vTemp, pObj, i )
Vec_PtrPush( pHaig->vPos, pObj );
Vec_PtrFree( vTemp );
assert( pHaig->nObjs[AIG_OBJ_PO] == Vec_PtrSize(pHaig->vPos) );
@@ -630,7 +633,7 @@ clk = clock();
// create its history AIG
pNew->pManHaig = Aig_ManDupSimple( pNew );
Aig_ManForEachObj( pNew, pObj, i )
- pObj->pHaig = pObj->pData;
+ pObj->pHaig = (Aig_Obj_t *)pObj->pData;
// remove structural hashing table
Aig_TableClear( pNew->pManHaig );
pNew->pManHaig->vEquPairs = Vec_IntAlloc( 10000 );
@@ -725,3 +728,5 @@ clkSynth = clock() - clk;
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/saig/saigInd.c b/src/aig/saig/saigInd.c
index 1c26e5df..e22adba2 100644
--- a/src/aig/saig/saigInd.c
+++ b/src/aig/saig/saigInd.c
@@ -22,6 +22,9 @@
#include "cnf.h"
#include "satSolver.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -32,7 +35,51 @@
/**Function*************************************************************
- Synopsis [Performs localization by unrolling timeframes backward.]
+ Synopsis [Returns 1 if two state are equal.]
+
+ Description [Array vState contains indexes of CNF variables for each
+ flop in the first N time frames (0 < i < k, i < N, k < N).]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Saig_ManStatesAreEqual( sat_solver * pSat, Vec_Int_t * vState, int nRegs, int i, int k )
+{
+ int * pStateI = (int *)Vec_IntArray(vState) + nRegs * i;
+ int * pStateK = (int *)Vec_IntArray(vState) + nRegs * k;
+ int v;
+ assert( i && k && i < k );
+ assert( nRegs * k <= Vec_IntSize(vState) );
+ // check if the states are available
+ for ( v = 0; v < nRegs; v++ )
+ if ( pStateI[v] >= 0 && pStateK[v] == -1 )
+ return 0;
+/*
+ printf( "\nchecking uniqueness\n" );
+ printf( "%3d : ", i );
+ for ( v = 0; v < nRegs; v++ )
+ printf( "%d", sat_solver_var_value(pSat, pStateI[v]) );
+ printf( "\n" );
+
+ printf( "%3d : ", k );
+ for ( v = 0; v < nRegs; v++ )
+ printf( "%d", sat_solver_var_value(pSat, pStateK[v]) );
+ printf( "\n" );
+*/
+ for ( v = 0; v < nRegs; v++ )
+ if ( pStateI[v] >= 0 )
+ {
+ if ( sat_solver_var_value(pSat, pStateI[v]) != sat_solver_var_value(pSat, pStateK[v]) )
+ return 0;
+ }
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Add uniqueness constraint.]
Description []
@@ -41,21 +88,78 @@
SeeAlso []
***********************************************************************/
-int Saig_ManInduction( Aig_Man_t * p, int nFramesMax, int nConfMax, int fVerbose )
+void Saig_ManAddUniqueness( sat_solver * pSat, Vec_Int_t * vState, int nRegs, int i, int k, int * pnSatVarNum, int * pnClauses )
+{
+ int * pStateI = (int *)Vec_IntArray(vState) + nRegs * i;
+ int * pStateK = (int *)Vec_IntArray(vState) + nRegs * k;
+ int v, iVars, nSatVarsOld, RetValue, * pClause;
+ assert( i && k && i < k );
+ assert( nRegs * k <= Vec_IntSize(vState) );
+ // check if the states are available
+ for ( v = 0; v < nRegs; v++ )
+ if ( pStateI[v] >= 0 && pStateK[v] == -1 )
+ {
+// printf( "Cannot constrain an incomplete state.\n" );
+ return;
+ }
+ // add XORs
+ nSatVarsOld = *pnSatVarNum;
+ for ( v = 0; v < nRegs; v++ )
+ if ( pStateI[v] >= 0 )
+ {
+ *pnClauses += 4;
+ RetValue = Cnf_DataAddXorClause( pSat, pStateI[v], pStateK[v], (*pnSatVarNum)++ );
+ if ( RetValue == 0 )
+ {
+ printf( "SAT solver became UNSAT.\n" );
+ return;
+ }
+ }
+ // add OR clause
+ (*pnClauses)++;
+ iVars = 0;
+ pClause = ABC_ALLOC( int, nRegs );
+ for ( v = nSatVarsOld; v < *pnSatVarNum; v++ )
+ pClause[iVars++] = toLitCond( v, 0 );
+ assert( iVars <= nRegs );
+ RetValue = sat_solver_addclause( pSat, pClause, pClause + iVars );
+ ABC_FREE( pClause );
+ if ( RetValue == 0 )
+ {
+ printf( "SAT solver became UNSAT.\n" );
+ return;
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs induction by unrolling timeframes backward.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Saig_ManInduction( Aig_Man_t * p, int nFramesMax, int nConfMax, int fUnique, int fUniqueAll, int fVerbose, int fVeryVerbose )
{
sat_solver * pSat;
Aig_Man_t * pAigPart;
Cnf_Dat_t * pCnfPart;
- Vec_Int_t * vTopVarNums;
+ Vec_Int_t * vTopVarNums, * vState;
Vec_Ptr_t * vTop, * vBot;
Aig_Obj_t * pObjPi, * pObjPiCopy, * pObjPo;
- int i, f, clk, Lits[2], status, RetValue, nSatVarNum, nConfPrev;
+ int i, k, f, clk, Lits[2], status, RetValue, nSatVarNum, nConfPrev;
+ int nOldSize, iReg, iLast, fAdded, nConstrs = 0, nClauses = 0;
+ assert( fUnique == 0 || fUniqueAll == 0 );
assert( Saig_ManPoNum(p) == 1 );
Aig_ManSetPioNumbers( p );
// start the top by including the PO
vBot = Vec_PtrAlloc( 100 );
vTop = Vec_PtrAlloc( 100 );
+ vState = Vec_IntAlloc( 1000 );
Vec_PtrPush( vTop, Aig_ManPo(p, 0) );
// start the array of CNF variables
vTopVarNums = Vec_IntAlloc( 100 );
@@ -67,7 +171,7 @@ int Saig_ManInduction( Aig_Man_t * p, int nFramesMax, int nConfMax, int fVerbose
RetValue = -1;
nSatVarNum = 0;
if ( fVerbose )
- printf( "Localization parameters: FramesMax = %5d. ConflictMax = %6d.\n", nFramesMax, nConfMax );
+ printf( "Induction parameters: FramesMax = %5d. ConflictMax = %6d.\n", nFramesMax, nConfMax );
for ( f = 0; ; f++ )
{
if ( f > 0 )
@@ -84,6 +188,7 @@ int Saig_ManInduction( Aig_Man_t * p, int nFramesMax, int nConfMax, int fVerbose
pCnfPart = Cnf_Derive( pAigPart, Aig_ManPoNum(pAigPart) );
Cnf_DataLift( pCnfPart, nSatVarNum );
nSatVarNum += pCnfPart->nVars;
+ nClauses += pCnfPart->nClauses;
// stitch variables of top and bot
assert( Aig_ManPoNum(pAigPart)-1 == Vec_IntSize(vTopVarNums) );
@@ -98,6 +203,7 @@ int Saig_ManInduction( Aig_Man_t * p, int nFramesMax, int nConfMax, int fVerbose
Lits[0] = toLitCond( pCnfPart->pVarNums[pObjPo->Id], f>0 );
if ( !sat_solver_addclause( pSat, Lits, Lits+1 ) )
assert( 0 );
+ nClauses++;
continue;
}
Lits[0] = toLitCond( Vec_IntEntry(vTopVarNums, i-1), 0 );
@@ -108,6 +214,7 @@ int Saig_ManInduction( Aig_Man_t * p, int nFramesMax, int nConfMax, int fVerbose
Lits[1] = toLitCond( pCnfPart->pVarNums[pObjPo->Id], 0 );
if ( !sat_solver_addclause( pSat, Lits, Lits+2 ) )
assert( 0 );
+ nClauses += 2;
}
// add CNF to the SAT solver
for ( i = 0; i < pCnfPart->nClauses; i++ )
@@ -119,14 +226,50 @@ int Saig_ManInduction( Aig_Man_t * p, int nFramesMax, int nConfMax, int fVerbose
RetValue = 1;
break;
}
+
+ // create new set of POs to derive new top
+ Vec_PtrClear( vTop );
+ Vec_PtrPush( vTop, Aig_ManPo(p, 0) );
+ Vec_IntClear( vTopVarNums );
+ nOldSize = Vec_IntSize(vState);
+ Vec_IntFillExtra( vState, nOldSize + Aig_ManRegNum(p), -1 );
+ Vec_PtrForEachEntry( Aig_Obj_t *, vBot, pObjPi, i )
+ {
+ assert( Aig_ObjIsPi(pObjPi) );
+ if ( Saig_ObjIsLo(p, pObjPi) )
+ {
+ pObjPiCopy = (Aig_Obj_t *)pObjPi->pData;
+ assert( pObjPiCopy != NULL );
+ Vec_PtrPush( vTop, Saig_ObjLoToLi(p, pObjPi) );
+ Vec_IntPush( vTopVarNums, pCnfPart->pVarNums[pObjPiCopy->Id] );
+
+ iReg = pObjPi->PioNum - Saig_ManPiNum(p);
+ assert( iReg >= 0 && iReg < Aig_ManRegNum(p) );
+ Vec_IntWriteEntry( vState, nOldSize+iReg, pCnfPart->pVarNums[pObjPiCopy->Id] );
+ }
+ }
+ iLast = Vec_IntSize(vState)/Aig_ManRegNum(p);
+ if ( fUniqueAll )
+ {
+ for ( i = 1; i < iLast-1; i++ )
+ {
+ nConstrs++;
+ Saig_ManAddUniqueness( pSat, vState, Aig_ManRegNum(p), i, iLast-1, &nSatVarNum, &nClauses );
+ if ( fVeryVerbose )
+ printf( "added constaint for %3d and %3d\n", i, iLast-1 );
+ }
+ }
+
+nextrun:
+ fAdded = 0;
// run the SAT solver
nConfPrev = pSat->stats.conflicts;
status = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)nConfMax, 0, 0, 0 );
if ( fVerbose )
{
- printf( "%3d : PI = %5d. PO = %5d. AIG = %5d. Var = %6d. Conf = %6d. ",
- f+1, Aig_ManPiNum(pAigPart), Aig_ManPoNum(pAigPart), Aig_ManNodeNum(pAigPart),
- nSatVarNum, pSat->stats.conflicts-nConfPrev );
+ printf( "%4d : PI =%5d. PO =%5d. AIG =%5d. Var =%7d. Clau =%7d. Conf =%7d. ",
+ f, Aig_ManPiNum(pAigPart), Aig_ManPoNum(pAigPart), Aig_ManNodeNum(pAigPart),
+ nSatVarNum, nClauses, pSat->stats.conflicts-nConfPrev );
ABC_PRT( "Time", clock() - clk );
}
if ( status == l_Undef )
@@ -137,26 +280,49 @@ int Saig_ManInduction( Aig_Man_t * p, int nFramesMax, int nConfMax, int fVerbose
break;
}
assert( status == l_True );
+ // the problem is SAT - add more clauses
+ if ( fVeryVerbose )
+ {
+ Vec_IntForEachEntry( vState, iReg, i )
+ {
+ if ( i && (i % Aig_ManRegNum(p)) == 0 )
+ printf( "\n" );
+ if ( (i % Aig_ManRegNum(p)) == 0 )
+ printf( "%3d : ", i/Aig_ManRegNum(p) );
+ printf( "%c", (iReg >= 0) ? ('0' + sat_solver_var_value(pSat, iReg)) : 'x' );
+ }
+ printf( "\n" );
+ }
if ( f == nFramesMax - 1 )
break;
- // the problem is SAT - add more clauses
- // create new set of POs to derive new top
- Vec_PtrClear( vTop );
- Vec_PtrPush( vTop, Aig_ManPo(p, 0) );
- Vec_IntClear( vTopVarNums );
- Vec_PtrForEachEntry( vBot, pObjPi, i )
+ if ( fUnique )
{
- assert( Aig_ObjIsPi(pObjPi) );
- if ( Saig_ObjIsLo(p, pObjPi) )
+ for ( i = 1; i < iLast; i++ )
+ for ( k = i+1; k < iLast; k++ )
{
- pObjPiCopy = pObjPi->pData;
- assert( pObjPiCopy != NULL );
- Vec_PtrPush( vTop, Saig_ObjLoToLi(p, pObjPi) );
- Vec_IntPush( vTopVarNums, pCnfPart->pVarNums[pObjPiCopy->Id] );
+ if ( !Saig_ManStatesAreEqual( pSat, vState, Aig_ManRegNum(p), i, k ) )
+ continue;
+ nConstrs++;
+ fAdded = 1;
+ Saig_ManAddUniqueness( pSat, vState, Aig_ManRegNum(p), i, k, &nSatVarNum, &nClauses );
+ if ( fVeryVerbose )
+ printf( "added constaint for %3d and %3d\n", i, k );
}
}
+ if ( fAdded )
+ {
+// if ( fVeryVerbose )
+// printf( "Trying a new run.\n" );
+ goto nextrun;
+ }
+ }
+ if ( fVerbose )
+ {
+ if ( fUnique || fUniqueAll )
+ printf( "Completed %d interations and added %d uniqueness constraints.\n", f+1, nConstrs );
+ else
+ printf( "Completed %d interations.\n", f+1 );
}
-// printf( "Completed %d interations.\n", f+1 );
// cleanup
sat_solver_delete( pSat );
Aig_ManStop( pAigPart );
@@ -164,11 +330,15 @@ int Saig_ManInduction( Aig_Man_t * p, int nFramesMax, int nConfMax, int fVerbose
Vec_IntFree( vTopVarNums );
Vec_PtrFree( vTop );
Vec_PtrFree( vBot );
+ Vec_IntFree( vState );
return RetValue;
}
+
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/saig/saigIoa.c b/src/aig/saig/saigIoa.c
index d049489e..c84c37f3 100644
--- a/src/aig/saig/saigIoa.c
+++ b/src/aig/saig/saigIoa.c
@@ -18,8 +18,12 @@
***********************************************************************/
+#include <math.h>
#include "saig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -346,7 +350,7 @@ Aig_Man_t * Saig_ManReadBlif( char * pFileName )
// allocate mapping
if ( pNum2Id == NULL )
{
- extern double pow( double x, double y );
+// extern double pow( double x, double y );
int Size = (int)pow(10.0, (double)(strlen(pToken) - 1));
pNum2Id = ABC_CALLOC( int, Size );
}
@@ -397,3 +401,5 @@ Aig_Man_t * Saig_ManReadBlif( char * pFileName )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/saig/saigMiter.c b/src/aig/saig/saigMiter.c
index 0a9f230b..b470333d 100644
--- a/src/aig/saig/saigMiter.c
+++ b/src/aig/saig/saigMiter.c
@@ -19,6 +19,10 @@
***********************************************************************/
#include "saig.h"
+#include "fra.h"
+
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -210,10 +214,10 @@ void Saig_AndDualRail( Aig_Man_t * pNew, Aig_Obj_t * pObj, Aig_Obj_t ** ppData,
{
Aig_Obj_t * pFanin0 = Aig_ObjFanin0(pObj);
Aig_Obj_t * pFanin1 = Aig_ObjFanin1(pObj);
- Aig_Obj_t * p0Data = Aig_ObjFaninC0(pObj)? pFanin0->pNext : pFanin0->pData;
- Aig_Obj_t * p0Next = Aig_ObjFaninC0(pObj)? pFanin0->pData : pFanin0->pNext;
- Aig_Obj_t * p1Data = Aig_ObjFaninC1(pObj)? pFanin1->pNext : pFanin1->pData;
- Aig_Obj_t * p1Next = Aig_ObjFaninC1(pObj)? pFanin1->pData : pFanin1->pNext;
+ Aig_Obj_t * p0Data = Aig_ObjFaninC0(pObj)? pFanin0->pNext : (Aig_Obj_t *)pFanin0->pData;
+ Aig_Obj_t * p0Next = Aig_ObjFaninC0(pObj)? (Aig_Obj_t *)pFanin0->pData : pFanin0->pNext;
+ Aig_Obj_t * p1Data = Aig_ObjFaninC1(pObj)? pFanin1->pNext : (Aig_Obj_t *)pFanin1->pData;
+ Aig_Obj_t * p1Next = Aig_ObjFaninC1(pObj)? (Aig_Obj_t *)pFanin1->pData : pFanin1->pNext;
*ppData = Aig_Or( pNew,
Aig_And(pNew, p0Data, Aig_Not(p0Next)),
Aig_And(pNew, p1Data, Aig_Not(p1Next)) );
@@ -262,20 +266,20 @@ Aig_Man_t * Saig_ManDualRail( Aig_Man_t * p, int fMiter )
Saig_ManForEachLo( p, pObj, i )
{
pMiter = Aig_And( pNew, pMiter,
- Aig_Or(pNew, pObj->pData, pObj->pNext) );
+ Aig_Or(pNew, (Aig_Obj_t *)pObj->pData, pObj->pNext) );
}
Aig_ObjCreatePo( pNew, pMiter );
Saig_ManForEachLi( p, pObj, i )
{
if ( !Aig_ObjFaninC0(pObj) )
{
- Aig_ObjCreatePo( pNew, Aig_ObjFanin0(pObj)->pData );
+ Aig_ObjCreatePo( pNew, (Aig_Obj_t *)Aig_ObjFanin0(pObj)->pData );
Aig_ObjCreatePo( pNew, Aig_ObjFanin0(pObj)->pNext );
}
else
{
Aig_ObjCreatePo( pNew, Aig_ObjFanin0(pObj)->pNext );
- Aig_ObjCreatePo( pNew, Aig_ObjFanin0(pObj)->pData );
+ Aig_ObjCreatePo( pNew, (Aig_Obj_t *)Aig_ObjFanin0(pObj)->pData );
}
}
}
@@ -285,13 +289,13 @@ Aig_Man_t * Saig_ManDualRail( Aig_Man_t * p, int fMiter )
{
if ( !Aig_ObjFaninC0(pObj) )
{
- Aig_ObjCreatePo( pNew, Aig_ObjFanin0(pObj)->pData );
+ Aig_ObjCreatePo( pNew, (Aig_Obj_t *)Aig_ObjFanin0(pObj)->pData );
Aig_ObjCreatePo( pNew, Aig_ObjFanin0(pObj)->pNext );
}
else
{
Aig_ObjCreatePo( pNew, Aig_ObjFanin0(pObj)->pNext );
- Aig_ObjCreatePo( pNew, Aig_ObjFanin0(pObj)->pData );
+ Aig_ObjCreatePo( pNew, (Aig_Obj_t *)Aig_ObjFanin0(pObj)->pData );
}
}
}
@@ -396,7 +400,7 @@ Aig_Man_t * Aig_ManDupNodesAll( Aig_Man_t * p, Vec_Ptr_t * vSet )
pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
// Saig_ManForEachPo( p, pObj, i )
// pObj->pData = Aig_ObjCreatePo( pNew, Aig_ObjChild0Copy(pObj) );
- Vec_PtrForEachEntry( vSet, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vSet, pObj, i )
Aig_ObjCreatePo( pNew, Aig_NotCond((Aig_Obj_t *)Aig_Regular(pObj)->pData, Aig_IsComplement(pObj)) );
Saig_ManForEachLi( p, pObj, i )
pObj->pData = Aig_ObjCreatePo( pNew, Aig_ObjChild0Copy(pObj) );
@@ -447,7 +451,7 @@ Aig_Man_t * Aig_ManDupNodesHalf( Aig_Man_t * p, Vec_Ptr_t * vSet, int iPart )
pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
// Saig_ManForEachPo( p, pObj, i )
// pObj->pData = Aig_ObjCreatePo( pNew, Aig_ObjChild0Copy(pObj) );
- Vec_PtrForEachEntry( vSet, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vSet, pObj, i )
Aig_ObjCreatePo( pNew, Aig_NotCond((Aig_Obj_t *)Aig_Regular(pObj)->pData, Aig_IsComplement(pObj)) );
if ( iPart == 0 )
{
@@ -712,8 +716,8 @@ int Saig_ManDemiter( Aig_Man_t * p, Aig_Man_t ** ppAig0, Aig_Man_t ** ppAig1 )
vSet0 = Vec_PtrAlloc( Saig_ManPoNum(p) );
vSet1 = Vec_PtrAlloc( Saig_ManPoNum(p) );
// get the first pair of outputs
- pObj0 = Vec_PtrEntry( vPairs, 0 );
- pObj1 = Vec_PtrEntry( vPairs, 1 );
+ pObj0 = (Aig_Obj_t *)Vec_PtrEntry( vPairs, 0 );
+ pObj1 = (Aig_Obj_t *)Vec_PtrEntry( vPairs, 1 );
// label registers reachable from the outputs
Aig_ManIncrementTravId( p );
Saig_ManDemiterLabel_rec( p, Aig_Regular(pObj0), 0 );
@@ -724,8 +728,8 @@ int Saig_ManDemiter( Aig_Man_t * p, Aig_Man_t ** ppAig0, Aig_Man_t ** ppAig1 )
// find where each output belongs
for ( i = 2; i < Vec_PtrSize(vPairs); i += 2 )
{
- pObj0 = Vec_PtrEntry( vPairs, i );
- pObj1 = Vec_PtrEntry( vPairs, i+1 );
+ pObj0 = (Aig_Obj_t *)Vec_PtrEntry( vPairs, i );
+ pObj1 = (Aig_Obj_t *)Vec_PtrEntry( vPairs, i+1 );
Aig_ManIncrementTravId( p );
pFlop0 = Saig_ManGetLabeledRegister_rec( p, Aig_Regular(pObj0) );
@@ -862,7 +866,7 @@ int Ssw_SecCexResimulate( Aig_Man_t * p, int * pModel, int * pnOutputs )
***********************************************************************/
int Ssw_SecSpecial( Aig_Man_t * pPart0, Aig_Man_t * pPart1, int nFrames, int fVerbose )
{
- extern int Fra_FraigCec( Aig_Man_t ** ppAig, int nConfLimit, int fVerbose );
+// extern int Fra_FraigCec( Aig_Man_t ** ppAig, int nConfLimit, int fVerbose );
int iOut, nOuts;
Aig_Man_t * pMiterCec;
int RetValue, clkTotal = clock();
@@ -905,7 +909,7 @@ ABC_PRT( "Time", clock() - clkTotal );
printf( "Counter-example is not available.\n" );
else
{
- iOut = Ssw_SecCexResimulate( pMiterCec, pMiterCec->pData, &nOuts );
+ iOut = Ssw_SecCexResimulate( pMiterCec, (int *)pMiterCec->pData, &nOuts );
if ( iOut == -1 )
printf( "Counter-example verification has failed.\n" );
else
@@ -993,3 +997,5 @@ int Ssw_SecSpecialMiter( Aig_Man_t * p0, Aig_Man_t * p1, int nFrames, int fVerbo
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/saig/saigPba.c b/src/aig/saig/saigPba.c
new file mode 100644
index 00000000..65b39fc0
--- /dev/null
+++ b/src/aig/saig/saigPba.c
@@ -0,0 +1,752 @@
+/**CFile****************************************************************
+
+ FileName [saigPba.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Sequential AIG package.]
+
+ Synopsis [Proof-based abstraction.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: saigPba.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "saig.h"
+
+#include "cnf.h"
+#include "satSolver.h"
+#include "satStore.h"
+#include "ssw.h"
+#include "ioa.h"
+#include "fra.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+static inline char Saig_AbsVisited( Vec_Str_t * p, int nObjs, Aig_Obj_t * pObj, int i ) { return Vec_StrGetEntry( p, nObjs*i+pObj->Id ); }
+static inline void Saig_AbsSetVisited( Vec_Str_t * p, int nObjs, Aig_Obj_t * pObj, int i ) { Vec_StrSetEntry( p, nObjs*i+pObj->Id, (char)1 ); }
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Finds the set of clauses involved in the UNSAT core.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Saig_AbsSolverUnsatCore( sat_solver * pSat, int nConfMax, int fVerbose, int * piRetValue )
+{
+ Vec_Int_t * vCore;
+ void * pSatCnf;
+ Intp_Man_t * pManProof;
+ int RetValue, clk = clock();
+ *piRetValue = -1;
+ // solve the problem
+ RetValue = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)nConfMax, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
+ if ( RetValue == l_Undef )
+ {
+ printf( "Conflict limit is reached.\n" );
+ return NULL;
+ }
+ if ( RetValue == l_True )
+ {
+ printf( "The BMC problem is SAT.\n" );
+ *piRetValue = 0;
+ return NULL;
+ }
+ if ( fVerbose )
+ {
+ printf( "SAT solver returned UNSAT after %d conflicts. ", pSat->stats.conflicts );
+ ABC_PRT( "Time", clock() - clk );
+ }
+ assert( RetValue == l_False );
+ pSatCnf = sat_solver_store_release( pSat );
+ // derive the UNSAT core
+ clk = clock();
+ pManProof = Intp_ManAlloc();
+ vCore = (Vec_Int_t *)Intp_ManUnsatCore( pManProof, (Sto_Man_t *)pSatCnf, 0 );
+ Intp_ManFree( pManProof );
+ Sto_ManFree( (Sto_Man_t *)pSatCnf );
+ if ( fVerbose )
+ {
+ printf( "SAT core contains %d clauses (out of %d). ", Vec_IntSize(vCore), pSat->stats.clauses );
+ ABC_PRT( "Time", clock() - clk );
+ }
+ return vCore;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Mark visited nodes recursively.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Saig_AbsMarkVisited_rec( Aig_Man_t * p, Vec_Str_t * vObj2Visit, Aig_Obj_t * pObj, int i )
+{
+ if ( Saig_AbsVisited( vObj2Visit, Aig_ManObjNumMax(p), pObj, i ) )
+ return 1;
+ Saig_AbsSetVisited( vObj2Visit, Aig_ManObjNumMax(p), pObj, i );
+ if ( Saig_ObjIsPi( p, pObj ) )
+ return 1;
+ if ( Saig_ObjIsLo( p, pObj ) )
+ {
+ if ( i == 0 )
+ return 1;
+ return Saig_AbsMarkVisited_rec( p, vObj2Visit, Saig_ObjLoToLi(p, pObj), i-1 );
+ }
+ if ( Aig_ObjIsPo( pObj ) )
+ return Saig_AbsMarkVisited_rec( p, vObj2Visit, Aig_ObjFanin0(pObj), i );
+ Saig_AbsMarkVisited_rec( p, vObj2Visit, Aig_ObjFanin0(pObj), i );
+ Saig_AbsMarkVisited_rec( p, vObj2Visit, Aig_ObjFanin1(pObj), i );
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Mark visited nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Str_t * Saig_AbsMarkVisited( Aig_Man_t * p, int nFramesMax )
+{
+ Vec_Str_t * vObj2Visit;
+ Aig_Obj_t * pObj;
+ int i, f;
+ vObj2Visit = Vec_StrStart( Aig_ManObjNumMax(p) * nFramesMax );
+// Saig_ManForEachLo( p, pObj, i )
+// Saig_AbsSetVisited( vObj2Visit, Aig_ManObjNumMax(p), pObj, 0 );
+ for ( f = 0; f < nFramesMax; f++ )
+ {
+ Saig_AbsSetVisited( vObj2Visit, Aig_ManObjNumMax(p), Aig_ManConst1(p), f );
+ Saig_ManForEachPo( p, pObj, i )
+ Saig_AbsMarkVisited_rec( p, vObj2Visit, pObj, f );
+ }
+ return vObj2Visit;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs the actual construction of the output.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Obj_t * Saig_AbsCreateFrames_rec( Aig_Man_t * pFrame, Aig_Obj_t * pObj )
+{
+ if ( pObj->pData )
+ return (Aig_Obj_t *)pObj->pData;
+ assert( Aig_ObjIsNode(pObj) );
+ Saig_AbsCreateFrames_rec( pFrame, Aig_ObjFanin0(pObj) );
+ Saig_AbsCreateFrames_rec( pFrame, Aig_ObjFanin1(pObj) );
+ return (Aig_Obj_t *)(pObj->pData = Aig_And( pFrame, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) ));
+}
+
+/**Function*************************************************************
+
+ Synopsis [Derives a vector of AIG managers, one for each frame.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Ptr_t * Saig_AbsCreateFrames( Aig_Man_t * p, int nFramesMax, int fVerbose )
+{
+ Vec_Ptr_t * vFrames, * vLoObjs, * vLiObjs;
+ Vec_Str_t * vObj2Visit;
+ Aig_Man_t * pFrame;
+ Aig_Obj_t * pObj;
+ int f, i;
+ vObj2Visit = Saig_AbsMarkVisited( p, nFramesMax );
+ vFrames = Vec_PtrAlloc( nFramesMax );
+ vLoObjs = Vec_PtrAlloc( 100 );
+ vLiObjs = Vec_PtrAlloc( 100 );
+ for ( f = 0; f < nFramesMax; f++ )
+ {
+ Aig_ManCleanData( p );
+ pFrame = Aig_ManStart( 1000 );
+ Aig_ManConst1(p)->pData = Aig_ManConst1(pFrame);
+ // create PIs
+ Vec_PtrClear( vLoObjs );
+ Vec_PtrClear( vLiObjs );
+ Aig_ManForEachPi( p, pObj, i )
+ {
+ if ( Saig_AbsVisited( vObj2Visit, Aig_ManObjNumMax(p), pObj, f ) )
+ {
+ pObj->pData = Aig_ObjCreatePi(pFrame);
+ if ( i >= Saig_ManPiNum(p) )
+ Vec_PtrPush( vLoObjs, pObj );
+ }
+ }
+ // remember the number of (implicit) registers in this frame
+ pFrame->nAsserts = Vec_PtrSize(vLoObjs);
+ // create POs
+ Aig_ManForEachPo( p, pObj, i )
+ {
+ if ( Saig_AbsVisited( vObj2Visit, Aig_ManObjNumMax(p), pObj, f ) )
+ {
+ Saig_AbsCreateFrames_rec( pFrame, Aig_ObjFanin0(pObj) );
+ pObj->pData = Aig_ObjCreatePo( pFrame, Aig_ObjChild0Copy(pObj) );
+ if ( i >= Saig_ManPoNum(p) )
+ Vec_PtrPush( vLiObjs, pObj );
+ }
+ }
+// Vec_PtrPush( vFrames, Cnf_Derive(pFrame, Aig_ManPoNum(pFrame)) );
+ Vec_PtrPush( vFrames, Cnf_DeriveSimple(pFrame, Aig_ManPoNum(pFrame)) );
+ // set the new PIs to point to the corresponding registers
+ Aig_ManCleanData( pFrame );
+ Vec_PtrForEachEntry( Aig_Obj_t *, vLoObjs, pObj, i )
+ ((Aig_Obj_t *)pObj->pData)->pData = pObj;
+ Vec_PtrForEachEntry( Aig_Obj_t *, vLiObjs, pObj, i )
+ ((Aig_Obj_t *)pObj->pData)->pData = pObj;
+ if ( fVerbose )
+ printf( "%3d : PI =%8d. PO =%8d. Flop =%8d. Node =%8d.\n",
+ f, Aig_ManPiNum(pFrame), Aig_ManPoNum(pFrame), pFrame->nAsserts, Aig_ManNodeNum(pFrame) );
+ }
+ Vec_PtrFree( vLoObjs );
+ Vec_PtrFree( vLiObjs );
+ Vec_StrFree( vObj2Visit );
+ return vFrames;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Derives a vector of AIG managers, one for each frame.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+sat_solver * Saig_AbsCreateSolverDyn( Aig_Man_t * p, Vec_Ptr_t * vFrames )
+{
+ sat_solver * pSat;
+ Cnf_Dat_t * pCnf, * pCnfPrev;
+ Vec_Int_t * vPoLits;
+ Aig_Obj_t * pObjPo, * pObjLi, * pObjLo;
+ int f, i, Lit, Lits[2], iVarOld, iVarNew, nSatVars, nRegisters;
+ // start array of output literals
+ vPoLits = Vec_IntAlloc( 100 );
+ // count the number of CNF variables
+ nSatVars = 0;
+ Vec_PtrForEachEntry( Cnf_Dat_t *, vFrames, pCnf, f )
+ nSatVars += pCnf->nVars;
+
+ // create the SAT solver
+ pSat = sat_solver_new();
+ sat_solver_store_alloc( pSat );
+ sat_solver_setnvars( pSat, nSatVars );
+
+ // add clauses for the timeframes
+ nSatVars = 0;
+// Vec_PtrForEachEntryReverse( Cnf_Dat_t *, vFrames, pCnf, f )
+ Vec_PtrForEachEntry( Cnf_Dat_t *, vFrames, pCnf, f )
+ {
+ // lift clauses of this CNF
+ Cnf_DataLift( pCnf, nSatVars );
+ nSatVars += pCnf->nVars;
+ // copy clauses into the manager
+ for ( i = 0; i < pCnf->nClauses; i++ )
+ {
+ if ( !sat_solver_addclause( pSat, pCnf->pClauses[i], pCnf->pClauses[i+1] ) )
+ {
+ printf( "The BMC problem is trivially UNSAT.\n" );
+ sat_solver_delete( pSat );
+ Vec_IntFree( vPoLits );
+ return NULL;
+ }
+ }
+ // remember output literal
+ Aig_ManForEachPo( pCnf->pMan, pObjPo, i )
+ {
+ if ( i == Saig_ManPoNum(p) )
+ break;
+ Vec_IntPush( vPoLits, toLit(pCnf->pVarNums[pObjPo->Id]) );
+ }
+ }
+
+ // add auxiliary clauses (output, connectors, initial)
+ // add output clause
+ if ( !sat_solver_addclause( pSat, Vec_IntArray(vPoLits), Vec_IntArray(vPoLits) + Vec_IntSize(vPoLits) ) )
+ {
+ printf( "SAT solver is not created correctly.\n" );
+ assert( 0 );
+ }
+ Vec_IntFree( vPoLits );
+
+ // add connecting clauses
+ pCnfPrev = (Cnf_Dat_t *)Vec_PtrEntry( vFrames, 0 );
+ Vec_PtrForEachEntryStart( Cnf_Dat_t *, vFrames, pCnf, f, 1 )
+ {
+ nRegisters = pCnf->pMan->nAsserts;
+ assert( nRegisters <= Aig_ManPoNum(pCnfPrev->pMan) );
+ assert( nRegisters <= Aig_ManPiNum(pCnf->pMan) );
+ for ( i = 0; i < nRegisters; i++ )
+ {
+ pObjLi = Aig_ManPo( pCnfPrev->pMan, Aig_ManPoNum(pCnfPrev->pMan) - nRegisters + i );
+ pObjLo = Aig_ManPi( pCnf->pMan, Aig_ManPiNum(pCnf->pMan) - nRegisters + i );
+ // get variable numbers
+ iVarOld = pCnfPrev->pVarNums[pObjLi->Id];
+ iVarNew = pCnf->pVarNums[pObjLo->Id];
+ // add clauses connecting existing variables
+ Lits[0] = toLitCond( iVarOld, 0 );
+ Lits[1] = toLitCond( iVarNew, 1 );
+ if ( !sat_solver_addclause( pSat, Lits, Lits+2 ) )
+ assert( 0 );
+ Lits[0] = toLitCond( iVarOld, 1 );
+ Lits[1] = toLitCond( iVarNew, 0 );
+ if ( !sat_solver_addclause( pSat, Lits, Lits+2 ) )
+ assert( 0 );
+ }
+ pCnfPrev = pCnf;
+ }
+ // add unit clauses
+ pCnf = (Cnf_Dat_t *)Vec_PtrEntry( vFrames, 0 );
+ nRegisters = pCnf->pMan->nAsserts;
+ for ( i = 0; i < nRegisters; i++ )
+ {
+ pObjLo = Aig_ManPi( pCnf->pMan, Aig_ManPiNum(pCnf->pMan) - nRegisters + i );
+ assert( pCnf->pVarNums[pObjLo->Id] >= 0 );
+ Lit = toLitCond( pCnf->pVarNums[pObjLo->Id], 1 );
+ if ( !sat_solver_addclause( pSat, &Lit, &Lit+1 ) )
+ assert( 0 );
+ }
+ sat_solver_store_mark_roots( pSat );
+ return pSat;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Creates SAT solver for BMC.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+sat_solver * Saig_AbsCreateSolver( Cnf_Dat_t * pCnf, int nFrames )
+{
+ sat_solver * pSat;
+ Vec_Int_t * vPoLits;
+ Aig_Obj_t * pObjPo, * pObjLi, * pObjLo;
+ int f, i, Lit, Lits[2], iVarOld, iVarNew;
+ // start array of output literals
+ vPoLits = Vec_IntAlloc( nFrames * Saig_ManPoNum(pCnf->pMan) );
+ // create the SAT solver
+ pSat = sat_solver_new();
+ sat_solver_store_alloc( pSat );
+ sat_solver_setnvars( pSat, pCnf->nVars * nFrames );
+
+ // add clauses for the timeframes
+ for ( f = 0; f < nFrames; f++ )
+ {
+ for ( i = 0; i < pCnf->nClauses; i++ )
+ {
+ if ( !sat_solver_addclause( pSat, pCnf->pClauses[i], pCnf->pClauses[i+1] ) )
+ {
+ printf( "The BMC problem is trivially UNSAT.\n" );
+ sat_solver_delete( pSat );
+ Vec_IntFree( vPoLits );
+ return NULL;
+ }
+ }
+ // remember output literal
+ Saig_ManForEachPo( pCnf->pMan, pObjPo, i )
+ Vec_IntPush( vPoLits, toLit(pCnf->pVarNums[pObjPo->Id]) );
+ // lift CNF to the next frame
+ Cnf_DataLift( pCnf, pCnf->nVars );
+ }
+ // put CNF back to the original level
+ Cnf_DataLift( pCnf, - pCnf->nVars * nFrames );
+
+ // add auxiliary clauses (output, connectors, initial)
+ // add output clause
+ if ( !sat_solver_addclause( pSat, Vec_IntArray(vPoLits), Vec_IntArray(vPoLits) + Vec_IntSize(vPoLits) ) )
+ assert( 0 );
+ Vec_IntFree( vPoLits );
+ // add connecting clauses
+ for ( f = 0; f < nFrames; f++ )
+ {
+ // connect to the previous timeframe
+ if ( f > 0 )
+ {
+ Saig_ManForEachLiLo( pCnf->pMan, pObjLi, pObjLo, i )
+ {
+ iVarOld = pCnf->pVarNums[pObjLi->Id] - pCnf->nVars;
+ iVarNew = pCnf->pVarNums[pObjLo->Id];
+ // add clauses connecting existing variables
+ Lits[0] = toLitCond( iVarOld, 0 );
+ Lits[1] = toLitCond( iVarNew, 1 );
+ if ( !sat_solver_addclause( pSat, Lits, Lits+2 ) )
+ assert( 0 );
+ Lits[0] = toLitCond( iVarOld, 1 );
+ Lits[1] = toLitCond( iVarNew, 0 );
+ if ( !sat_solver_addclause( pSat, Lits, Lits+2 ) )
+ assert( 0 );
+ }
+ }
+ // lift CNF to the next frame
+ Cnf_DataLift( pCnf, pCnf->nVars );
+ }
+ // put CNF back to the original level
+ Cnf_DataLift( pCnf, - pCnf->nVars * nFrames );
+ // add unit clauses
+ Saig_ManForEachLo( pCnf->pMan, pObjLo, i )
+ {
+ assert( pCnf->pVarNums[pObjLo->Id] >= 0 );
+ Lit = toLitCond( pCnf->pVarNums[pObjLo->Id], 1 );
+ if ( !sat_solver_addclause( pSat, &Lit, &Lit+1 ) )
+ assert( 0 );
+ }
+ sat_solver_store_mark_roots( pSat );
+ return pSat;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs proof-based abstraction using BMC of the given depth.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Saig_AbsCollectRegistersDyn( Aig_Man_t * p, Vec_Ptr_t * vFrames, Vec_Int_t * vCore )
+{
+ Aig_Obj_t * pObj;
+ Cnf_Dat_t * pCnf;
+ Vec_Int_t * vFlops;
+ int * pVars, * pFlops;
+ int i, f, iClause, iReg, * piLit, nSatVars, nSatClauses;
+ // count the number of CNF variables
+ nSatVars = 0;
+ Vec_PtrForEachEntry( Cnf_Dat_t *, vFrames, pCnf, f )
+ nSatVars += pCnf->nVars;
+ // mark register variables
+ pVars = ABC_ALLOC( int, nSatVars );
+ for ( i = 0; i < nSatVars; i++ )
+ pVars[i] = -1;
+ Vec_PtrForEachEntry( Cnf_Dat_t *, vFrames, pCnf, f )
+ {
+ Aig_ManForEachPi( pCnf->pMan, pObj, i )
+ {
+ assert( pCnf->pVarNums[pObj->Id] >= 0 );
+ assert( pCnf->pVarNums[pObj->Id] < nSatVars );
+ if ( pObj->pData == NULL )
+ continue;
+ iReg = Aig_ObjPioNum((Aig_Obj_t *)pObj->pData) - Saig_ManPiNum(p);
+ assert( iReg >= 0 && iReg < Aig_ManRegNum(p) );
+ pVars[ pCnf->pVarNums[pObj->Id] ] = iReg;
+ }
+ Aig_ManForEachPo( pCnf->pMan, pObj, i )
+ {
+ assert( pCnf->pVarNums[pObj->Id] >= 0 );
+ assert( pCnf->pVarNums[pObj->Id] < nSatVars );
+ if ( pObj->pData == NULL )
+ continue;
+ iReg = Aig_ObjPioNum((Aig_Obj_t *)pObj->pData) - Saig_ManPoNum(p);
+ assert( iReg >= 0 && iReg < Aig_ManRegNum(p) );
+ pVars[ pCnf->pVarNums[pObj->Id] ] = iReg;
+ }
+ }
+ // mark used registers
+ pFlops = ABC_CALLOC( int, Aig_ManRegNum(p) );
+ Vec_IntForEachEntry( vCore, iClause, i )
+ {
+ nSatClauses = 0;
+ Vec_PtrForEachEntry( Cnf_Dat_t *, vFrames, pCnf, f )
+ {
+ if ( iClause < nSatClauses + pCnf->nClauses )
+ break;
+ nSatClauses += pCnf->nClauses;
+ }
+ if ( f == Vec_PtrSize(vFrames) )
+ continue;
+ iClause = iClause - nSatClauses;
+ assert( iClause >= 0 );
+ assert( iClause < pCnf->nClauses );
+ // consider the clause
+ for ( piLit = pCnf->pClauses[iClause]; piLit < pCnf->pClauses[iClause+1]; piLit++ )
+ {
+ iReg = pVars[ lit_var(*piLit) ];
+ if ( iReg >= 0 )
+ pFlops[iReg] = 1;
+ }
+ }
+ // collect registers
+ vFlops = Vec_IntAlloc( Aig_ManRegNum(p) );
+ for ( i = 0; i < Aig_ManRegNum(p); i++ )
+ if ( pFlops[i] )
+ Vec_IntPush( vFlops, i );
+ ABC_FREE( pFlops );
+ ABC_FREE( pVars );
+ return vFlops;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs proof-based abstraction using BMC of the given depth.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Saig_AbsCollectRegisters( Cnf_Dat_t * pCnf, int nFrames, Vec_Int_t * vCore )
+{
+ Aig_Obj_t * pObj;
+ Vec_Int_t * vFlops;
+ int * pVars, * pFlops;
+ int i, iClause, iReg, * piLit;
+ // mark register variables
+ pVars = ABC_ALLOC( int, pCnf->nVars );
+ for ( i = 0; i < pCnf->nVars; i++ )
+ pVars[i] = -1;
+ Saig_ManForEachLi( pCnf->pMan, pObj, i )
+ pVars[ pCnf->pVarNums[pObj->Id] ] = i;
+ Saig_ManForEachLo( pCnf->pMan, pObj, i )
+ pVars[ pCnf->pVarNums[pObj->Id] ] = i;
+ // mark used registers
+ pFlops = ABC_CALLOC( int, Aig_ManRegNum(pCnf->pMan) );
+ Vec_IntForEachEntry( vCore, iClause, i )
+ {
+ // skip auxiliary clauses
+ if ( iClause >= pCnf->nClauses * nFrames )
+ continue;
+ // consider the clause
+ iClause = iClause % pCnf->nClauses;
+ for ( piLit = pCnf->pClauses[iClause]; piLit < pCnf->pClauses[iClause+1]; piLit++ )
+ {
+ iReg = pVars[ lit_var(*piLit) ];
+ if ( iReg >= 0 )
+ pFlops[iReg] = 1;
+ }
+ }
+ // collect registers
+ vFlops = Vec_IntAlloc( Aig_ManRegNum(pCnf->pMan) );
+ for ( i = 0; i < Aig_ManRegNum(pCnf->pMan); i++ )
+ if ( pFlops[i] )
+ Vec_IntPush( vFlops, i );
+ ABC_FREE( pFlops );
+ ABC_FREE( pVars );
+ return vFlops;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs proof-based abstraction using BMC of the given depth.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Saig_AbsFreeCnfs( Vec_Ptr_t * vFrames )
+{
+ Cnf_Dat_t * pCnf;
+ int i;
+ Vec_PtrForEachEntry( Cnf_Dat_t *, vFrames, pCnf, i )
+ {
+ Aig_ManStop( pCnf->pMan );
+ Cnf_DataFree( pCnf );
+ }
+ Vec_PtrFree( vFrames );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs proof-based abstraction using BMC of the given depth.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Saig_AbsExtendOneStep( Aig_Man_t * p, Vec_Int_t * vFlops )
+{
+ Vec_Ptr_t * vFlopPtrs, * vSupp;
+ Aig_Obj_t * pObj;
+ int i, Entry;
+ // collect latch inputs
+ vFlopPtrs = Vec_PtrAlloc( 1000 );
+ Vec_IntForEachEntry( vFlops, Entry, i )
+ {
+ Vec_PtrPush( vFlopPtrs, Saig_ManLi(p, Entry) );
+ pObj = Saig_ManLo(p, Entry);
+ pObj->fMarkA = 1;
+ }
+ // collect latch outputs
+ vSupp = Vec_PtrAlloc( 1000 );
+ Aig_SupportNodes( p, (Aig_Obj_t **)Vec_PtrArray(vFlopPtrs), Vec_PtrSize(vFlopPtrs), vSupp );
+ Vec_PtrFree( vFlopPtrs );
+ // mark influencing flops
+ Vec_PtrForEachEntry( Aig_Obj_t *, vSupp, pObj, i )
+ pObj->fMarkA = 1;
+ Vec_PtrFree( vSupp );
+ // reload flops
+ Vec_IntClear( vFlops );
+ Aig_ManForEachPi( p, pObj, i )
+ {
+ if ( pObj->fMarkA == 0 )
+ continue;
+ pObj->fMarkA = 0;
+ if ( Aig_ObjPioNum(pObj)-Saig_ManPiNum(p) >= 0 )
+ Vec_IntPush( vFlops, Aig_ObjPioNum(pObj)-Saig_ManPiNum(p) );
+ }
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Performs proof-based abstraction using BMC of the given depth.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Saig_ManProofAbstractionFlops( Aig_Man_t * p, Gia_ParAbs_t * pPars )
+{
+ Vec_Int_t * vFlops;
+ sat_solver * pSat;
+ Vec_Ptr_t * vFrames = NULL;
+ Vec_Int_t * vCore;
+ Cnf_Dat_t * pCnf = NULL;
+ int clk = clock(), clk2 = clock();
+ if ( pPars->fVerbose )
+ printf( "Performing proof-based abstraction with %d frames and %d max conflicts.\n", pPars->nFramesMax, pPars->nConfMax );
+ assert( Aig_ManRegNum(p) > 0 );
+ Aig_ManSetPioNumbers( p );
+ if ( pPars->fDynamic )
+ {
+ // create CNF for the frames
+ vFrames = Saig_AbsCreateFrames( p, pPars->nFramesMax, pPars->fVerbose );
+ // create dynamic solver
+ pSat = Saig_AbsCreateSolverDyn( p, vFrames );
+ }
+ else
+ {
+ // create CNF for the AIG
+ pCnf = Cnf_DeriveSimple( p, Aig_ManPoNum(p) );
+ // create SAT solver for the unrolled AIG
+ pSat = Saig_AbsCreateSolver( pCnf, pPars->nFramesMax );
+ }
+ if ( pPars->fVerbose )
+ {
+ printf( "SAT solver: Vars = %7d. Clauses = %7d. ", pSat->size, pSat->stats.clauses );
+ ABC_PRT( "Time", clock() - clk2 );
+ }
+ // compute UNSAT core
+ vCore = Saig_AbsSolverUnsatCore( pSat, pPars->nConfMax, pPars->fVerbose, &pPars->Status );
+ sat_solver_delete( pSat );
+ if ( vCore == NULL )
+ {
+ if ( vFrames )
+ Saig_AbsFreeCnfs( vFrames );
+ return NULL;
+ }
+ pPars->nFramesDone = pPars->nFramesMax;
+ // collect registers
+ if ( pPars->fDynamic )
+ {
+ vFlops = Saig_AbsCollectRegistersDyn( p, vFrames, vCore );
+ Saig_AbsFreeCnfs( vFrames );
+ }
+ else
+ {
+ vFlops = Saig_AbsCollectRegisters( pCnf, pPars->nFramesMax, vCore );
+ Cnf_DataFree( pCnf );
+ }
+ Vec_IntFree( vCore );
+ if ( pPars->fVerbose )
+ {
+ printf( "The number of relevant registers is %d (out of %d). ", Vec_IntSize(vFlops), Aig_ManRegNum(p) );
+ ABC_PRT( "Time", clock() - clk );
+ }
+ return vFlops;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs proof-based abstraction using BMC of the given depth.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Man_t * Saig_ManProofAbstraction( Aig_Man_t * p, Gia_ParAbs_t * pPars )
+{
+ Vec_Int_t * vFlops;
+ Aig_Man_t * pAbs = NULL;
+ vFlops = Saig_ManProofAbstractionFlops( p, pPars );
+ // write the final result
+ if ( vFlops )
+ {
+ pAbs = Saig_ManDeriveAbstraction( p, vFlops );
+ Ioa_WriteAiger( pAbs, "gabs.aig", 0, 0 );
+ printf( "Final abstracted model was written into file \"%s\".\n", "gabs.aig" );
+ Vec_IntFree( vFlops );
+ }
+ return pAbs;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/saig/saigPhase.c b/src/aig/saig/saigPhase.c
index c67949b5..340910d0 100644
--- a/src/aig/saig/saigPhase.c
+++ b/src/aig/saig/saigPhase.c
@@ -20,6 +20,9 @@
#include "saig.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*
The algorithm is described in the paper: Per Bjesse and Jim Kukula,
"Automatic Phase Abstraction for Formal Verification", ICCAD 2005
@@ -228,7 +231,7 @@ int Saig_TsiCountNonXValuedRegisters( Saig_Tsim_t * p, int nWords, int nPref )
p->vNonXRegs = Vec_IntAlloc( 10 );
for ( i = 0; i < nRegs; i++ )
{
- Vec_PtrForEachEntryStart( p->vStates, pState, k, nPref )
+ Vec_PtrForEachEntryStart( unsigned *, p->vStates, pState, k, nPref )
{
Value = (Aig_InfoHasBit( pState, 2 * i + 1 ) << 1) | Aig_InfoHasBit( pState, 2 * i );
assert( Value != 0 );
@@ -261,7 +264,7 @@ void Saig_TsiPrintTraces( Saig_Tsim_t * p, int nWords, int nPrefix )
return;
for ( i = 0; i < nRegs; i++ )
{
- Vec_PtrForEachEntry( p->vStates, pState, k )
+ Vec_PtrForEachEntry( unsigned *, p->vStates, pState, k )
{
Value = (Aig_InfoHasBit( pState, 2 * i + 1 ) << 1) | Aig_InfoHasBit( pState, 2 * i );
if ( Value == SAIG_XVSX )
@@ -273,7 +276,7 @@ void Saig_TsiPrintTraces( Saig_Tsim_t * p, int nWords, int nPrefix )
continue;
// print trace
printf( "%5d : %5d %5d ", Counter, i, Saig_ManLo(p->pAig, i)->Id );
- Vec_PtrForEachEntryStop( p->vStates, pState, k, Vec_PtrSize(p->vStates)-1 )
+ Vec_PtrForEachEntryStop( unsigned *, p->vStates, pState, k, Vec_PtrSize(p->vStates)-1 )
{
Value = (Aig_InfoHasBit( pState, 2 * i + 1 ) << 1) | Aig_InfoHasBit( pState, 2 * i );
if ( Value == SAIG_XVS0 )
@@ -310,7 +313,7 @@ int Saig_TsiComputePrefix( Saig_Tsim_t * p, unsigned * pState, int nWords )
for ( pEntry = p->pBins[Hash]; pEntry; pEntry = Saig_TsiNext(pEntry, nWords) )
if ( !memcmp( pEntry, pState, sizeof(unsigned) * nWords ) )
{
- Vec_PtrForEachEntry( p->vStates, pPrev, i )
+ Vec_PtrForEachEntry( unsigned *, p->vStates, pPrev, i )
{
if ( pPrev == pEntry )
return i;
@@ -449,7 +452,7 @@ void Saig_TsiStateOrAll( Saig_Tsim_t * pTsi, unsigned * pState )
{
unsigned * pPrev;
int i, k;
- Vec_PtrForEachEntry( pTsi->vStates, pPrev, i )
+ Vec_PtrForEachEntry( unsigned *, pTsi->vStates, pPrev, i )
{
for ( k = 0; k < pTsi->nWords; k++ )
pState[k] |= pPrev[k];
@@ -616,9 +619,9 @@ int Saig_ManFindRegisters( Saig_Tsim_t * pTsi, int nFrames, int fIgnore, int fVe
for ( k = 0; k < nTests; k++ )
{
if ( k < pTsi->nPrefix + pTsi->nCycle )
- pState = Vec_PtrEntry( pTsi->vStates, k );
+ pState = (unsigned *)Vec_PtrEntry( pTsi->vStates, k );
else
- pState = Vec_PtrEntry( pTsi->vStates, k - pTsi->nCycle );
+ pState = (unsigned *)Vec_PtrEntry( pTsi->vStates, k - pTsi->nCycle );
Value = (Aig_InfoHasBit( pState, 2 * Reg + 1 ) << 1) | Aig_InfoHasBit( pState, 2 * Reg );
assert( Value == SAIG_XVS0 || Value == SAIG_XVS1 );
if ( k < nFrames || (fIgnore && k == nFrames) )
@@ -721,7 +724,7 @@ Aig_Man_t * Saig_ManPerformAbstraction( Saig_Tsim_t * pTsi, int nFrames, int fVe
Vec_IntForEachEntry( pTsi->vNonXRegs, Reg, i )
{
pObj = Saig_ManLo( pAig, Reg );
- pState = Vec_PtrEntry( pTsi->vStates, f );
+ pState = (unsigned *)Vec_PtrEntry( pTsi->vStates, f );
Value = (Aig_InfoHasBit( pState, 2 * Reg + 1 ) << 1) | Aig_InfoHasBit( pState, 2 * Reg );
assert( Value == SAIG_XVS0 || Value == SAIG_XVS1 );
pObjNew = (Value == SAIG_XVS1)? Aig_ManConst1(pFrames) : Aig_ManConst0(pFrames);
@@ -766,6 +769,37 @@ Aig_Man_t * Saig_ManPerformAbstraction( Saig_Tsim_t * pTsi, int nFrames, int fVe
return pFrames;
}
+
+/**Function*************************************************************
+
+ Synopsis [Performs automated phase abstraction.]
+
+ Description [Takes the AIG manager and the array of initial states.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Saig_ManPhaseFrameNum( Aig_Man_t * p, Vec_Int_t * vInits )
+{
+ Saig_Tsim_t * pTsi;
+ int nFrames, nPrefix;
+ assert( Saig_ManRegNum(p) );
+ assert( Saig_ManPiNum(p) );
+ assert( Saig_ManPoNum(p) );
+ // perform terminary simulation
+ pTsi = Saig_ManReachableTernary( p, vInits, 0 );
+ if ( pTsi == NULL )
+ return 1;
+ // derive information
+ nPrefix = Saig_TsiComputePrefix( pTsi, (unsigned *)Vec_PtrEntryLast(pTsi->vStates), pTsi->nWords );
+ nFrames = Vec_PtrSize(pTsi->vStates) - 1 - nPrefix;
+ Saig_TsiStop( pTsi );
+ // potentially, may need to reduce nFrames if nPrefix is less than nFrames
+ return nFrames;
+}
+
/**Function*************************************************************
Synopsis [Performs automated phase abstraction.]
@@ -789,7 +823,7 @@ Aig_Man_t * Saig_ManPhaseAbstract( Aig_Man_t * p, Vec_Int_t * vInits, int nFrame
if ( pTsi == NULL )
return NULL;
// derive information
- pTsi->nPrefix = Saig_TsiComputePrefix( pTsi, Vec_PtrEntryLast(pTsi->vStates), pTsi->nWords );
+ pTsi->nPrefix = Saig_TsiComputePrefix( pTsi, (unsigned *)Vec_PtrEntryLast(pTsi->vStates), pTsi->nWords );
pTsi->nCycle = Vec_PtrSize(pTsi->vStates) - 1 - pTsi->nPrefix;
pTsi->nNonXRegs = Saig_TsiCountNonXValuedRegisters(pTsi, pTsi->nWords, ABC_MIN(pTsi->nPrefix,nPref));
// print statistics
@@ -845,7 +879,7 @@ Aig_Man_t * Saig_ManPhaseAbstractAuto( Aig_Man_t * p, int fVerbose )
if ( pTsi == NULL )
return NULL;
// derive information
- pTsi->nPrefix = Saig_TsiComputePrefix( pTsi, Vec_PtrEntryLast(pTsi->vStates), pTsi->nWords );
+ pTsi->nPrefix = Saig_TsiComputePrefix( pTsi, (unsigned *)Vec_PtrEntryLast(pTsi->vStates), pTsi->nWords );
pTsi->nCycle = Vec_PtrSize(pTsi->vStates) - 1 - pTsi->nPrefix;
pTsi->nNonXRegs = Saig_TsiCountNonXValuedRegisters(pTsi, pTsi->nWords, 0);
// print statistics
@@ -903,3 +937,5 @@ Aig_Man_t * Saig_ManPhaseAbstractAuto( Aig_Man_t * p, int fVerbose )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/saig/saigRetFwd.c b/src/aig/saig/saigRetFwd.c
index 8178d26e..94d08aaf 100644
--- a/src/aig/saig/saigRetFwd.c
+++ b/src/aig/saig/saigRetFwd.c
@@ -20,6 +20,9 @@
#include "saig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -240,3 +243,5 @@ Aig_Man_t * Saig_ManRetimeForward( Aig_Man_t * p, int nMaxIters, int fVerbose )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/saig/saigRetMin.c b/src/aig/saig/saigRetMin.c
index b9204f44..cce7dcc6 100644
--- a/src/aig/saig/saigRetMin.c
+++ b/src/aig/saig/saigRetMin.c
@@ -20,16 +20,18 @@
#include "saig.h"
+#include "nwk.h"
#include "cnf.h"
#include "satSolver.h"
#include "satStore.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
-extern Vec_Ptr_t * Nwk_ManDeriveRetimingCut( Aig_Man_t * p, int fForward, int fVerbose );
-
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
@@ -55,7 +57,7 @@ Vec_Int_t * Saig_ManRetimeInitState( Aig_Man_t * p )
int i, RetValue, * pModel;
// solve the SAT problem
pCnf = Cnf_DeriveSimpleForRetiming( p );
- pSat = Cnf_DataWriteIntoSolver( pCnf, 1, 0 );
+ pSat = (sat_solver *)Cnf_DataWriteIntoSolver( pCnf, 1, 0 );
if ( pSat == NULL )
{
Cnf_DataFree( pCnf );
@@ -126,9 +128,9 @@ int Saig_ManRetimeUnsatCore( Aig_Man_t * p, int fVerbose )
sat_solver_delete( pSat );
// derive the UNSAT core
pManProof = Intp_ManAlloc();
- vCore = Intp_ManUnsatCore( pManProof, pSatCnf, fVeryVerbose );
+ vCore = (Vec_Int_t *)Intp_ManUnsatCore( pManProof, (Sto_Man_t *)pSatCnf, fVeryVerbose );
Intp_ManFree( pManProof );
- Sto_ManFree( pSatCnf );
+ Sto_ManFree( (Sto_Man_t *)pSatCnf );
// derive the set of variables on which the core depends
// collect the variable numbers
nVars = 0;
@@ -216,7 +218,7 @@ int Saig_ManRetimeCountCut( Aig_Man_t * p, Vec_Ptr_t * vCut )
int i, RetValue;
// mark the cones
Aig_ManIncrementTravId( p );
- Vec_PtrForEachEntry( vCut, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vCut, pObj, i )
Saig_ManMarkCone_rec( p, pObj );
// collect the new cut
vNodes = Vec_PtrAlloc( 1000 );
@@ -237,7 +239,7 @@ int Saig_ManRetimeCountCut( Aig_Man_t * p, Vec_Ptr_t * vCut )
pFanin->fMarkA = 1;
}
}
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
pObj->fMarkA = 0;
RetValue = Vec_PtrSize( vNodes );
Vec_PtrFree( vNodes );
@@ -296,7 +298,7 @@ Aig_Man_t * Saig_ManRetimeDupForward( Aig_Man_t * p, Vec_Ptr_t * vCut )
Saig_ManForEachPi( p, pObj, i )
pObj->pData = Aig_ObjCreatePi( pNew );
// create the registers
- Vec_PtrForEachEntry( vCut, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vCut, pObj, i )
pObj->pData = Aig_NotCond( Aig_ObjCreatePi(pNew), pObj->fPhase );
// duplicate logic above the cut
Aig_ManForEachPo( p, pObj, i )
@@ -311,14 +313,14 @@ Aig_Man_t * Saig_ManRetimeDupForward( Aig_Man_t * p, Vec_Ptr_t * vCut )
Saig_ManForEachLiLo( p, pObjLi, pObjLo, i )
pObjLo->pData = pObjLi->pData;
// erase the data values on the internal nodes of the cut
- Vec_PtrForEachEntry( vCut, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vCut, pObj, i )
if ( Aig_ObjIsNode(pObj) )
pObj->pData = NULL;
// duplicate logic below the cut
- Vec_PtrForEachEntry( vCut, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vCut, pObj, i )
{
Saig_ManRetimeDup_rec( pNew, pObj );
- Aig_ObjCreatePo( pNew, Aig_NotCond(pObj->pData, pObj->fPhase) );
+ Aig_ObjCreatePo( pNew, Aig_NotCond((Aig_Obj_t *)pObj->pData, pObj->fPhase) );
}
Aig_ManCleanup( pNew );
return pNew;
@@ -355,7 +357,7 @@ Aig_Man_t * Saig_ManRetimeDupBackward( Aig_Man_t * p, Vec_Ptr_t * vCut, Vec_Int_
Saig_ManForEachPi( p, pObj, i )
pObj->pData = Aig_ObjCreatePi( pNew );
// create the registers
- Vec_PtrForEachEntry( vCut, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vCut, pObj, i )
pObj->pData = Aig_NotCond( Aig_ObjCreatePi(pNew), vInit?Vec_IntEntry(vInit,i):0 );
// duplicate logic above the cut and remember values
Saig_ManForEachLi( p, pObj, i )
@@ -367,7 +369,7 @@ Aig_Man_t * Saig_ManRetimeDupBackward( Aig_Man_t * p, Vec_Ptr_t * vCut, Vec_Int_
Saig_ManForEachLiLo( p, pObjLi, pObjLo, i )
pObjLo->pData = pObjLi->pData;
// erase the data values on the internal nodes of the cut
- Vec_PtrForEachEntry( vCut, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vCut, pObj, i )
if ( Aig_ObjIsNode(pObj) )
pObj->pData = NULL;
// replicate the data on the constant node and the PIs
@@ -381,10 +383,10 @@ Aig_Man_t * Saig_ManRetimeDupBackward( Aig_Man_t * p, Vec_Ptr_t * vCut, Vec_Int_
Saig_ManRetimeDup_rec( pNew, Aig_ObjFanin0(pObj) );
Aig_ObjCreatePo( pNew, Aig_ObjChild0Copy(pObj) );
}
- Vec_PtrForEachEntry( vCut, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vCut, pObj, i )
{
Saig_ManRetimeDup_rec( pNew, pObj );
- Aig_ObjCreatePo( pNew, Aig_NotCond(pObj->pData, vInit?Vec_IntEntry(vInit,i):0) );
+ Aig_ObjCreatePo( pNew, Aig_NotCond((Aig_Obj_t *)pObj->pData, vInit?Vec_IntEntry(vInit,i):0) );
}
Aig_ManCleanup( pNew );
return pNew;
@@ -414,7 +416,7 @@ Aig_Man_t * Saig_ManRetimeDupInitState( Aig_Man_t * p, Vec_Ptr_t * vCut )
Aig_ManCleanData( p );
Aig_ManConst1(p)->pData = Aig_ManConst1(pNew);
// create the registers
- Vec_PtrForEachEntry( vCut, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vCut, pObj, i )
pObj->pData = Aig_ObjCreatePi(pNew);
// duplicate logic above the cut and create POs
Saig_ManForEachLi( p, pObj, i )
@@ -503,7 +505,7 @@ int Saig_ManHideBadRegs( Aig_Man_t * p, Vec_Ptr_t * vBadRegs )
nTruePo = Aig_ManPoNum(p) - Aig_ManRegNum(p);
assert( nTruePi == p->nTruePis );
assert( nTruePo == p->nTruePos );
- Vec_PtrForEachEntry( vBadRegs, pObjLi, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vBadRegs, pObjLi, i )
{
Vec_PtrWriteEntry( vPisNew, nTruePi++, pObjLi->pData );
Vec_PtrWriteEntry( vPosNew, nTruePo++, pObjLi );
@@ -699,3 +701,5 @@ Aig_Man_t * Saig_ManRetimeMinArea( Aig_Man_t * p, int nMaxIters, int fForwardOnl
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/saig/saigRetStep.c b/src/aig/saig/saigRetStep.c
index e2502761..aa1ae8a4 100644
--- a/src/aig/saig/saigRetStep.c
+++ b/src/aig/saig/saigRetStep.c
@@ -20,6 +20,9 @@
#include "saig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -229,3 +232,5 @@ int Saig_ManRetimeSteps( Aig_Man_t * p, int nSteps, int fForward, int fAddBugs )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/saig/saigScl.c b/src/aig/saig/saigScl.c
index 6d55943a..4b0a3102 100644
--- a/src/aig/saig/saigScl.c
+++ b/src/aig/saig/saigScl.c
@@ -20,6 +20,9 @@
#include "saig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -108,3 +111,5 @@ int Saig_ManReportComplements( Aig_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/saig/saigSimExt.c b/src/aig/saig/saigSimExt.c
index 22d5d6b8..9828d17e 100644
--- a/src/aig/saig/saigSimExt.c
+++ b/src/aig/saig/saigSimExt.c
@@ -21,6 +21,9 @@
#include "saig.h"
#include "ssw.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -49,13 +52,13 @@ static inline int Saig_ManSimInfoAnd( int Value0, int Value1 )
static inline int Saig_ManSimInfoGet( Vec_Ptr_t * vSimInfo, Aig_Obj_t * pObj, int iFrame )
{
- unsigned * pInfo = Vec_PtrEntry( vSimInfo, Aig_ObjId(pObj) );
+ unsigned * pInfo = (unsigned *)Vec_PtrEntry( vSimInfo, Aig_ObjId(pObj) );
return 3 & (pInfo[iFrame >> 4] >> ((iFrame & 15) << 1));
}
static inline void Saig_ManSimInfoSet( Vec_Ptr_t * vSimInfo, Aig_Obj_t * pObj, int iFrame, int Value )
{
- unsigned * pInfo = Vec_PtrEntry( vSimInfo, Aig_ObjId(pObj) );
+ unsigned * pInfo = (unsigned *)Vec_PtrEntry( vSimInfo, Aig_ObjId(pObj) );
assert( Value >= SAIG_ZER && Value <= SAIG_UND );
Value ^= Saig_ManSimInfoGet( vSimInfo, pObj, iFrame );
pInfo[iFrame >> 4] ^= (Value << ((iFrame & 15) << 1));
@@ -107,7 +110,7 @@ int Saig_ManExtendOneEval( Vec_Ptr_t * vSimInfo, Aig_Obj_t * pObj, int iFrame )
SeeAlso []
***********************************************************************/
-int Saig_ManSimDataInit( Aig_Man_t * p, Ssw_Cex_t * pCex, Vec_Ptr_t * vSimInfo, Vec_Int_t * vRes )
+int Saig_ManSimDataInit( Aig_Man_t * p, Abc_Cex_t * pCex, Vec_Ptr_t * vSimInfo, Vec_Int_t * vRes )
{
Aig_Obj_t * pObj, * pObjLi, * pObjLo;
int i, f, Entry, iBit = 0;
@@ -146,7 +149,7 @@ int Saig_ManSimDataInit( Aig_Man_t * p, Ssw_Cex_t * pCex, Vec_Ptr_t * vSimInfo,
SeeAlso []
***********************************************************************/
-int Saig_ManExtendOne( Aig_Man_t * p, Ssw_Cex_t * pCex, Vec_Ptr_t * vSimInfo,
+int Saig_ManExtendOne( Aig_Man_t * p, Abc_Cex_t * pCex, Vec_Ptr_t * vSimInfo,
int iPi, int iFrame, Vec_Int_t * vUndo, Vec_Int_t * vVis, Vec_Int_t * vVis2 )
{
Aig_Obj_t * pFanout, * pObj = Aig_ManPi(p, iPi);
@@ -247,7 +250,7 @@ void Saig_ManExtendUndo( Aig_Man_t * p, Vec_Ptr_t * vSimInfo, Vec_Int_t * vUndo
SeeAlso []
***********************************************************************/
-Vec_Int_t * Saig_ManExtendCounterExample( Aig_Man_t * p, int iFirstFlopPi, Ssw_Cex_t * pCex, Vec_Ptr_t * vSimInfo, int fVerbose )
+Vec_Int_t * Saig_ManExtendCounterExample0( Aig_Man_t * p, int iFirstFlopPi, Abc_Cex_t * pCex, Vec_Ptr_t * vSimInfo, int fVerbose )
{
Vec_Int_t * vRes, * vResInv, * vUndo, * vVis, * vVis2;
int i, f, Value;
@@ -297,14 +300,244 @@ Vec_Int_t * Saig_ManExtendCounterExample( Aig_Man_t * p, int iFirstFlopPi, Ssw_C
SeeAlso []
***********************************************************************/
-Vec_Int_t * Saig_ManExtendCounterExampleTest( Aig_Man_t * p, int iFirstFlopPi, Ssw_Cex_t * pCex, int fVerbose )
+Vec_Int_t * Saig_ManExtendCounterExample1( Aig_Man_t * p, int iFirstFlopPi, Abc_Cex_t * pCex, Vec_Ptr_t * vSimInfo, int fVerbose )
+{
+ Vec_Int_t * vRes, * vResInv, * vUndo, * vVis, * vVis2;
+ int i, f, Value;
+// assert( Aig_ManRegNum(p) > 0 );
+ assert( (unsigned *)Vec_PtrEntry(vSimInfo,1) - (unsigned *)Vec_PtrEntry(vSimInfo,0) >= Aig_BitWordNum(2*(pCex->iFrame+1)) );
+ // start simulation data
+ Value = Saig_ManSimDataInit( p, pCex, vSimInfo, NULL );
+ assert( Value == SAIG_ONE );
+ // select the result
+ vRes = Vec_IntAlloc( 1000 );
+ vResInv = Vec_IntAlloc( 1000 );
+ vVis = Vec_IntAlloc( 1000 );
+ vVis2 = Vec_IntAlloc( 1000 );
+ vUndo = Vec_IntAlloc( 1000 );
+ for ( i = Saig_ManPiNum(p) - 1; i >= iFirstFlopPi; i-- )
+ {
+ Vec_IntClear( vUndo );
+ for ( f = pCex->iFrame; f >= 0; f-- )
+ if ( !Saig_ManExtendOne( p, pCex, vSimInfo, i, f, vUndo, vVis, vVis2 ) )
+ {
+ Saig_ManExtendUndo( p, vSimInfo, vUndo );
+ break;
+ }
+ if ( f >= 0 )
+ Vec_IntPush( vRes, i );
+ else
+ Vec_IntPush( vResInv, i );
+ }
+ Vec_IntFree( vVis );
+ Vec_IntFree( vVis2 );
+ Vec_IntFree( vUndo );
+ // resimulate to make sure it is valid
+ Value = Saig_ManSimDataInit( p, pCex, vSimInfo, vResInv );
+ assert( Value == SAIG_ONE );
+ Vec_IntFree( vResInv );
+ return vRes;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the array of PIs for flops that should not be absracted.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Saig_ManExtendCounterExample2( Aig_Man_t * p, int iFirstFlopPi, Abc_Cex_t * pCex, Vec_Ptr_t * vSimInfo, int fVerbose )
+{
+ Vec_Int_t * vRes, * vResInv, * vUndo, * vVis, * vVis2;
+ int i, f, Value;
+// assert( Aig_ManRegNum(p) > 0 );
+ assert( (unsigned *)Vec_PtrEntry(vSimInfo,1) - (unsigned *)Vec_PtrEntry(vSimInfo,0) >= Aig_BitWordNum(2*(pCex->iFrame+1)) );
+ // start simulation data
+ Value = Saig_ManSimDataInit( p, pCex, vSimInfo, NULL );
+ assert( Value == SAIG_ONE );
+ // select the result
+ vRes = Vec_IntAlloc( 1000 );
+ vResInv = Vec_IntAlloc( 1000 );
+ vVis = Vec_IntAlloc( 1000 );
+ vVis2 = Vec_IntAlloc( 1000 );
+ vUndo = Vec_IntAlloc( 1000 );
+ for ( i = iFirstFlopPi; i < Saig_ManPiNum(p); i++ )
+ {
+ if ( i % 2 == 0 )
+ continue;
+ Vec_IntClear( vUndo );
+ for ( f = pCex->iFrame; f >= 0; f-- )
+ if ( !Saig_ManExtendOne( p, pCex, vSimInfo, i, f, vUndo, vVis, vVis2 ) )
+ {
+ Saig_ManExtendUndo( p, vSimInfo, vUndo );
+ break;
+ }
+ if ( f >= 0 )
+ Vec_IntPush( vRes, i );
+ else
+ Vec_IntPush( vResInv, i );
+ }
+ for ( i = iFirstFlopPi; i < Saig_ManPiNum(p); i++ )
+ {
+ if ( i % 2 == 1 )
+ continue;
+ Vec_IntClear( vUndo );
+ for ( f = pCex->iFrame; f >= 0; f-- )
+ if ( !Saig_ManExtendOne( p, pCex, vSimInfo, i, f, vUndo, vVis, vVis2 ) )
+ {
+ Saig_ManExtendUndo( p, vSimInfo, vUndo );
+ break;
+ }
+ if ( f >= 0 )
+ Vec_IntPush( vRes, i );
+ else
+ Vec_IntPush( vResInv, i );
+ }
+ Vec_IntFree( vVis );
+ Vec_IntFree( vVis2 );
+ Vec_IntFree( vUndo );
+ // resimulate to make sure it is valid
+ Value = Saig_ManSimDataInit( p, pCex, vSimInfo, vResInv );
+ assert( Value == SAIG_ONE );
+ Vec_IntFree( vResInv );
+ return vRes;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the array of PIs for flops that should not be absracted.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Saig_ManExtendCounterExample3( Aig_Man_t * p, int iFirstFlopPi, Abc_Cex_t * pCex, Vec_Ptr_t * vSimInfo, int fVerbose )
+{
+ Vec_Int_t * vRes, * vResInv, * vUndo, * vVis, * vVis2;
+ int i, f, Value;
+// assert( Aig_ManRegNum(p) > 0 );
+ assert( (unsigned *)Vec_PtrEntry(vSimInfo,1) - (unsigned *)Vec_PtrEntry(vSimInfo,0) >= Aig_BitWordNum(2*(pCex->iFrame+1)) );
+ // start simulation data
+ Value = Saig_ManSimDataInit( p, pCex, vSimInfo, NULL );
+ assert( Value == SAIG_ONE );
+ // select the result
+ vRes = Vec_IntAlloc( 1000 );
+ vResInv = Vec_IntAlloc( 1000 );
+ vVis = Vec_IntAlloc( 1000 );
+ vVis2 = Vec_IntAlloc( 1000 );
+ vUndo = Vec_IntAlloc( 1000 );
+ for ( i = Saig_ManPiNum(p) - 1; i >= iFirstFlopPi; i-- )
+ {
+ if ( i % 2 == 0 )
+ continue;
+ Vec_IntClear( vUndo );
+ for ( f = pCex->iFrame; f >= 0; f-- )
+ if ( !Saig_ManExtendOne( p, pCex, vSimInfo, i, f, vUndo, vVis, vVis2 ) )
+ {
+ Saig_ManExtendUndo( p, vSimInfo, vUndo );
+ break;
+ }
+ if ( f >= 0 )
+ Vec_IntPush( vRes, i );
+ else
+ Vec_IntPush( vResInv, i );
+ }
+ for ( i = Saig_ManPiNum(p) - 1; i >= iFirstFlopPi; i-- )
+ {
+ if ( i % 2 == 1 )
+ continue;
+ Vec_IntClear( vUndo );
+ for ( f = pCex->iFrame; f >= 0; f-- )
+ if ( !Saig_ManExtendOne( p, pCex, vSimInfo, i, f, vUndo, vVis, vVis2 ) )
+ {
+ Saig_ManExtendUndo( p, vSimInfo, vUndo );
+ break;
+ }
+ if ( f >= 0 )
+ Vec_IntPush( vRes, i );
+ else
+ Vec_IntPush( vResInv, i );
+ }
+ Vec_IntFree( vVis );
+ Vec_IntFree( vVis2 );
+ Vec_IntFree( vUndo );
+ // resimulate to make sure it is valid
+ Value = Saig_ManSimDataInit( p, pCex, vSimInfo, vResInv );
+ assert( Value == SAIG_ONE );
+ Vec_IntFree( vResInv );
+ return vRes;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the array of PIs for flops that should not be absracted.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Saig_ManExtendCounterExample( Aig_Man_t * p, int iFirstFlopPi, Abc_Cex_t * pCex, Vec_Ptr_t * vSimInfo, int fVerbose )
+{
+ Vec_Int_t * vRes0 = Saig_ManExtendCounterExample0( p, iFirstFlopPi, pCex, vSimInfo, fVerbose );
+ Vec_Int_t * vRes1 = Saig_ManExtendCounterExample1( p, iFirstFlopPi, pCex, vSimInfo, fVerbose );
+ Vec_Int_t * vRes2 = Saig_ManExtendCounterExample2( p, iFirstFlopPi, pCex, vSimInfo, fVerbose );
+ Vec_Int_t * vRes3 = Saig_ManExtendCounterExample3( p, iFirstFlopPi, pCex, vSimInfo, fVerbose );
+ Vec_Int_t * vRes = vRes0;
+// if ( fVerbose )
+ printf( "Removable flops: Order0 =%3d. Order1 =%3d. Order2 =%3d. Order3 =%3d.\n",
+ Vec_IntSize(vRes0), Vec_IntSize(vRes1), Vec_IntSize(vRes2), Vec_IntSize(vRes3) );
+ if ( Vec_IntSize(vRes1) < Vec_IntSize(vRes) )
+ vRes = vRes1;
+ if ( Vec_IntSize(vRes2) < Vec_IntSize(vRes) )
+ vRes = vRes2;
+ if ( Vec_IntSize(vRes3) < Vec_IntSize(vRes) )
+ vRes = vRes3;
+ vRes = Vec_IntDup( vRes );
+ Vec_IntFree( vRes0 );
+ Vec_IntFree( vRes1 );
+ Vec_IntFree( vRes2 );
+ Vec_IntFree( vRes3 );
+ return vRes;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the array of PIs for flops that should not be absracted.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Saig_ManExtendCounterExampleTest( Aig_Man_t * p, int iFirstFlopPi, Abc_Cex_t * pCex, int fVerbose )
{
Vec_Int_t * vRes;
Vec_Ptr_t * vSimInfo;
int clk;
+ if ( Saig_ManPiNum(p) != pCex->nPis )
+ {
+ printf( "Saig_ManExtendCounterExampleTest(): The PI count of AIG (%d) does not match that of cex (%d).\n",
+ Aig_ManPiNum(p), pCex->nPis );
+ return NULL;
+ }
Aig_ManFanoutStart( p );
vSimInfo = Vec_PtrAllocSimInfo( Aig_ManObjNumMax(p), Aig_BitWordNum(2*(pCex->iFrame+1)) );
+ Vec_PtrCleanSimInfo( vSimInfo, 0, Aig_BitWordNum(2*(pCex->iFrame+1)) );
+
clk = clock();
+// vRes = Saig_ManExtendCounterExample0( p, iFirstFlopPi, pCex, vSimInfo, fVerbose );
vRes = Saig_ManExtendCounterExample( p, iFirstFlopPi, pCex, vSimInfo, fVerbose );
if ( fVerbose )
{
@@ -314,8 +547,6 @@ ABC_PRT( "Time", clock() - clk );
Vec_PtrFree( vSimInfo );
Aig_ManFanoutStop( p );
return vRes;
-// Vec_IntFree( vRes );
-// return NULL;
}
////////////////////////////////////////////////////////////////////////
@@ -323,3 +554,5 @@ ABC_PRT( "Time", clock() - clk );
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/saig/saigSimFast.c b/src/aig/saig/saigSimFast.c
index 05f77f8a..1840eaa7 100644
--- a/src/aig/saig/saigSimFast.c
+++ b/src/aig/saig/saigSimFast.c
@@ -20,6 +20,11 @@
#include "saig.h"
+#include "main.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -247,7 +252,7 @@ static inline unsigned Faig_SimulateTransferShift( unsigned uOld, unsigned uNew
***********************************************************************/
int * Faig_ManSimulateFrames( Faig_Man_t * p, int nFrames, int nPref, int fTrans )
{
- int * pNumOnes = ABC_CALLOC( unsigned, p->nObjs );
+ int * pNumOnes = ABC_CALLOC( int, p->nObjs );
unsigned * pSimInfo = ABC_ALLOC( unsigned, p->nObjs );
int f, i;
//printf( "Allocating %7.2f Mb.\n", 1.0 * 4 * p->nObjs/(1<<20) );
@@ -338,7 +343,6 @@ float Faig_ManComputeProbOne( int nOnes, int nSimWords )
***********************************************************************/
Vec_Int_t * Faig_ManComputeSwitchProbs4( Aig_Man_t * p, int nFrames, int nPref, int fProbOne )
{
- extern char * Abc_FrameReadFlag( char * pFlag );
int fTrans = 1;
Faig_Man_t * pAig;
Vec_Int_t * vSwitching;
@@ -442,3 +446,5 @@ Vec_Int_t * Saig_ManComputeSwitchProb3s( Aig_Man_t * p, int nFrames, int nPref,
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/saig/saigSimMv.c b/src/aig/saig/saigSimMv.c
index a3fdaf93..90c6cb33 100644
--- a/src/aig/saig/saigSimMv.c
+++ b/src/aig/saig/saigSimMv.c
@@ -20,6 +20,9 @@
#include "saig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -61,7 +64,7 @@ struct Saig_MvMan_t_
Saig_MvObj_t * pAigOld; // AIG objects
Vec_Ptr_t * vFlops; // collected flops
Vec_Ptr_t * vTired; // collected flops
- int * pTStates; // hash table for states
+ unsigned * pTStates; // hash table for states
int nTStatesSize; // hash table size
Aig_MmFixed_t * pMemStates; // memory for states
Vec_Ptr_t * vStates; // reached states
@@ -213,7 +216,7 @@ Saig_MvMan_t * Saig_MvManStart( Aig_Man_t * pAig )
// compacted AIG
p->pAigOld = Saig_ManCreateReducedAig( pAig, &p->vFlops );
p->nTStatesSize = Aig_PrimeCudd( p->nStatesMax );
- p->pTStates = ABC_CALLOC( int, p->nTStatesSize );
+ p->pTStates = ABC_CALLOC( unsigned, p->nTStatesSize );
p->pMemStates = Aig_MmFixedStart( sizeof(int) * (p->nFlops+1), p->nStatesMax );
p->vStates = Vec_PtrAlloc( p->nStatesMax );
Vec_PtrPush( p->vStates, NULL );
@@ -422,7 +425,7 @@ printf( "%d = %d%s * %d%s --> %d\n", pEntry - p->pAigOld,
assert( 0 );
}
Vec_PtrClear( p->vTired );
- Vec_PtrForEachEntry( p->vFlops, pEntry, i )
+ Vec_PtrForEachEntry( Saig_MvObj_t *, p->vFlops, pEntry, i )
{
NewValue = Saig_MvSimulateValue0(p->pAigOld, pEntry);
if ( NewValue != (int)pEntry->Value )
@@ -451,7 +454,7 @@ printf( "\n" );
SeeAlso []
***********************************************************************/
-int Saig_MvSimHash( int * pState, int nFlops, int TableSize )
+int Saig_MvSimHash( unsigned * pState, int nFlops, int TableSize )
{
static int s_SPrimes[128] = {
1009, 1049, 1093, 1151, 1201, 1249, 1297, 1361, 1427, 1459,
@@ -486,12 +489,12 @@ int Saig_MvSimHash( int * pState, int nFlops, int TableSize )
SeeAlso []
***********************************************************************/
-static inline int * Saig_MvSimTableFind( Saig_MvMan_t * p, int * pState )
+static inline unsigned * Saig_MvSimTableFind( Saig_MvMan_t * p, unsigned * pState )
{
- int * pEntry;
- int * pPlace = p->pTStates + Saig_MvSimHash( pState+1, p->nFlops, p->nTStatesSize );
- for ( pEntry = (*pPlace)? Vec_PtrEntry(p->vStates, *pPlace) : NULL; pEntry;
- pPlace = pEntry, pEntry = (*pPlace)? Vec_PtrEntry(p->vStates, *pPlace) : NULL )
+ unsigned * pEntry;
+ unsigned * pPlace = p->pTStates + Saig_MvSimHash( pState+1, p->nFlops, p->nTStatesSize );
+ for ( pEntry = (*pPlace)? (unsigned *)Vec_PtrEntry(p->vStates, *pPlace) : NULL; pEntry;
+ pPlace = pEntry, pEntry = (*pPlace)? (unsigned *)Vec_PtrEntry(p->vStates, *pPlace) : NULL )
if ( memcmp( pEntry+1, pState+1, sizeof(int)*p->nFlops ) == 0 )
break;
return pPlace;
@@ -511,12 +514,13 @@ static inline int * Saig_MvSimTableFind( Saig_MvMan_t * p, int * pState )
int Saig_MvSaveState( Saig_MvMan_t * p, int * piReg )
{
Saig_MvObj_t * pEntry;
- int i, k, * pState, * pPlace, nMaxUndefs = 0;
+ unsigned * pState, * pPlace;
+ int i, k, nMaxUndefs = 0;
int iTimesOld, iTimesNew;
*piReg = -1;
- pState = (int *)Aig_MmFixedEntryFetch( p->pMemStates );
+ pState = (unsigned *)Aig_MmFixedEntryFetch( p->pMemStates );
pState[0] = 0;
- Vec_PtrForEachEntry( p->vFlops, pEntry, i )
+ Vec_PtrForEachEntry( Saig_MvObj_t *, p->vFlops, pEntry, i )
{
iTimesOld = p->nRegsValues[i];
// count the number of different def values
@@ -585,21 +589,22 @@ int Saig_MvSaveState( Saig_MvMan_t * p, int * piReg )
void Saig_MvManPostProcess( Saig_MvMan_t * p, int iState )
{
Saig_MvObj_t * pEntry;
- int i, k, j, nTotal = 0, * pState, Counter = 0, iFlop;
+ unsigned * pState;
+ int i, k, j, nTotal = 0, Counter = 0, iFlop;
Vec_Int_t * vUniques = Vec_IntAlloc( 100 );
Vec_Int_t * vCounter = Vec_IntAlloc( 100 );
// count registers that never became undef
- Vec_PtrForEachEntry( p->vFlops, pEntry, i )
+ Vec_PtrForEachEntry( Saig_MvObj_t *, p->vFlops, pEntry, i )
if ( p->pRegsUndef[i] == 0 )
nTotal++;
printf( "The number of registers that never became undef = %d. (Total = %d.)\n", nTotal, p->nFlops );
- Vec_PtrForEachEntry( p->vFlops, pEntry, i )
+ Vec_PtrForEachEntry( Saig_MvObj_t *, p->vFlops, pEntry, i )
{
if ( p->pRegsUndef[i] )
continue;
Vec_IntForEachEntry( vUniques, iFlop, k )
{
- Vec_PtrForEachEntryStart( p->vStates, pState, j, 1 )
+ Vec_PtrForEachEntryStart( unsigned *, p->vStates, pState, j, 1 )
if ( pState[iFlop+1] != pState[i+1] )
break;
if ( j == Vec_PtrSize(p->vStates) )
@@ -625,7 +630,7 @@ void Saig_MvManPostProcess( Saig_MvMan_t * p, int iState )
printf( "%d ", p->pRegsValues[iFlop][k] );
printf( "\n" );
*/
- Vec_PtrForEachEntryStart( p->vStates, pState, k, 1 )
+ Vec_PtrForEachEntryStart( unsigned *, p->vStates, pState, k, 1 )
{
if ( k == iState+1 )
printf( " # " );
@@ -664,7 +669,7 @@ int Saig_MvManSimulate( Aig_Man_t * pAig, int fVerbose )
ABC_PRT( "Constructing the problem", clock() - clk );
clk = clock();
// initiliaze registers
- Vec_PtrForEachEntry( p->vFlops, pEntry, i )
+ Vec_PtrForEachEntry( Saig_MvObj_t *, p->vFlops, pEntry, i )
{
pEntry->Value = Saig_MvConst0();
if ( pEntry->iFan0 == 1 )
@@ -706,7 +711,7 @@ ABC_PRT( "Constructing the problem", clock() - clk );
printf( "Retiring flop %d.\n", iRegMax );
*/
// printf( "Retiring %d flops.\n", Vec_PtrSize(p->vTired) );
- Vec_PtrForEachEntry( p->vTired, pEntry, k )
+ Vec_PtrForEachEntry( Saig_MvObj_t *, p->vTired, pEntry, k )
pEntry->Value = Saig_MvUndef();
}
}
@@ -724,3 +729,5 @@ ABC_PRT( "Multi-value simulation", clock() - clk );
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/saig/saigSimSeq.c b/src/aig/saig/saigSimSeq.c
index c527b152..37bb12b5 100644
--- a/src/aig/saig/saigSimSeq.c
+++ b/src/aig/saig/saigSimSeq.c
@@ -21,6 +21,9 @@
#include "saig.h"
#include "ssw.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -52,7 +55,7 @@ struct Raig_Man_t_
int nWordsAlloc; // the number of allocated entries
int nMems; // the number of used entries
int nMemsMax; // the max number of used entries
- int MemFree; // next ABC_FREE entry
+ int MemFree; // next free entry
};
static inline int Raig_Var2Lit( int Var, int fCompl ) { return Var + Var + fCompl; }
@@ -228,7 +231,7 @@ unsigned * Raig_ManSimRef( Raig_Man_t * p, int i )
assert( p->pSims[i] == 0 );
if ( p->MemFree == 0 )
{
- int * pPlace, Ent;
+ unsigned * pPlace, Ent;
if ( p->nWordsAlloc == 0 )
{
assert( p->pMems == NULL );
@@ -238,9 +241,9 @@ unsigned * Raig_ManSimRef( Raig_Man_t * p, int i )
p->nWordsAlloc *= 2;
p->pMems = ABC_REALLOC( unsigned, p->pMems, p->nWordsAlloc );
memset( p->pMems, 0xff, sizeof(unsigned) * (p->nWords + 1) );
- pPlace = &p->MemFree;
+ pPlace = (unsigned *)&p->MemFree;
for ( Ent = p->nMems * (p->nWords + 1);
- Ent + p->nWords + 1 < p->nWordsAlloc;
+ Ent + p->nWords + 1 < (unsigned)p->nWordsAlloc;
Ent += p->nWords + 1 )
{
*pPlace = Ent;
@@ -410,9 +413,9 @@ int Raig_ManSimulateRound( Raig_Man_t * p, int fMiter, int fFirst, int * piPat )
SeeAlso []
***********************************************************************/
-Ssw_Cex_t * Raig_ManGenerateCounter( Aig_Man_t * pAig, int iFrame, int iOut, int nWords, int iPat, Vec_Int_t * vCis2Ids )
+Abc_Cex_t * Raig_ManGenerateCounter( Aig_Man_t * pAig, int iFrame, int iOut, int nWords, int iPat, Vec_Int_t * vCis2Ids )
{
- Ssw_Cex_t * p;
+ Abc_Cex_t * p;
unsigned * pData;
int f, i, w, iPioId, Counter;
p = Ssw_SmlAllocCounterExample( Aig_ManRegNum(pAig), Saig_ManPiNum(pAig), iFrame+1 );
@@ -511,3 +514,5 @@ int Raig_ManSimulate( Aig_Man_t * pAig, int nWords, int nIters, int TimeLimit, i
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/saig/saigStrSim.c b/src/aig/saig/saigStrSim.c
index 9e50c9b6..1d69630f 100644
--- a/src/aig/saig/saigStrSim.c
+++ b/src/aig/saig/saigStrSim.c
@@ -21,6 +21,9 @@
#include "saig.h"
#include "ssw.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -66,7 +69,7 @@ unsigned Saig_StrSimHash( Aig_Obj_t * pObj )
unsigned uHash = 0;
int i;
assert( SAIG_WORDS <= 128 );
- pSims = pObj->pData;
+ pSims = (unsigned *)pObj->pData;
for ( i = 0; i < SAIG_WORDS; i++ )
uHash ^= pSims[i] * s_SPrimes[i & 0x7F];
return uHash;
@@ -85,8 +88,8 @@ unsigned Saig_StrSimHash( Aig_Obj_t * pObj )
***********************************************************************/
int Saig_StrSimIsEqual( Aig_Obj_t * pObj0, Aig_Obj_t * pObj1 )
{
- unsigned * pSims0 = pObj0->pData;
- unsigned * pSims1 = pObj1->pData;
+ unsigned * pSims0 = (unsigned *)pObj0->pData;
+ unsigned * pSims1 = (unsigned *)pObj1->pData;
int i;
for ( i = 0; i < SAIG_WORDS; i++ )
if ( pSims0[i] != pSims1[i] )
@@ -107,7 +110,7 @@ int Saig_StrSimIsEqual( Aig_Obj_t * pObj0, Aig_Obj_t * pObj1 )
***********************************************************************/
int Saig_StrSimIsZero( Aig_Obj_t * pObj )
{
- unsigned * pSims = pObj->pData;
+ unsigned * pSims = (unsigned *)pObj->pData;
int i;
for ( i = 0; i < SAIG_WORDS; i++ )
if ( pSims[i] != 0 )
@@ -128,7 +131,7 @@ int Saig_StrSimIsZero( Aig_Obj_t * pObj )
***********************************************************************/
int Saig_StrSimIsOne( Aig_Obj_t * pObj )
{
- unsigned * pSims = pObj->pData;
+ unsigned * pSims = (unsigned *)pObj->pData;
int i;
for ( i = 0; i < SAIG_WORDS; i++ )
if ( pSims[i] != ~0 )
@@ -149,7 +152,7 @@ int Saig_StrSimIsOne( Aig_Obj_t * pObj )
***********************************************************************/
void Saig_StrSimAssignRandom( Aig_Obj_t * pObj )
{
- unsigned * pSims = pObj->pData;
+ unsigned * pSims = (unsigned *)pObj->pData;
int i;
for ( i = 0; i < SAIG_WORDS; i++ )
pSims[i] = Aig_ManRandom(0);
@@ -168,7 +171,7 @@ void Saig_StrSimAssignRandom( Aig_Obj_t * pObj )
***********************************************************************/
void Saig_StrSimAssignOne( Aig_Obj_t * pObj )
{
- unsigned * pSims = pObj->pData;
+ unsigned * pSims = (unsigned *)pObj->pData;
int i;
for ( i = 0; i < SAIG_WORDS; i++ )
pSims[i] = ~0;
@@ -187,7 +190,7 @@ void Saig_StrSimAssignOne( Aig_Obj_t * pObj )
***********************************************************************/
void Saig_StrSimAssignZeroInit( Aig_Obj_t * pObj )
{
- unsigned * pSims = pObj->pData;
+ unsigned * pSims = (unsigned *)pObj->pData;
pSims[0] = 0;
}
@@ -204,9 +207,9 @@ void Saig_StrSimAssignZeroInit( Aig_Obj_t * pObj )
***********************************************************************/
void Saig_StrSimulateNode( Aig_Obj_t * pObj, int i )
{
- unsigned * pSims = pObj->pData;
- unsigned * pSims0 = Aig_ObjFanin0(pObj)->pData;
- unsigned * pSims1 = Aig_ObjFanin1(pObj)->pData;
+ unsigned * pSims = (unsigned *)pObj->pData;
+ unsigned * pSims0 = (unsigned *)Aig_ObjFanin0(pObj)->pData;
+ unsigned * pSims1 = (unsigned *)Aig_ObjFanin1(pObj)->pData;
if ( Aig_ObjFaninC0(pObj) && Aig_ObjFaninC1(pObj) )
pSims[i] = ~(pSims0[i] | pSims1[i]);
else if ( Aig_ObjFaninC0(pObj) && !Aig_ObjFaninC1(pObj) )
@@ -230,8 +233,8 @@ void Saig_StrSimulateNode( Aig_Obj_t * pObj, int i )
***********************************************************************/
void Saig_StrSimSaveOutput( Aig_Obj_t * pObj, int i )
{
- unsigned * pSims = pObj->pData;
- unsigned * pSims0 = Aig_ObjFanin0(pObj)->pData;
+ unsigned * pSims = (unsigned *)pObj->pData;
+ unsigned * pSims0 = (unsigned *)Aig_ObjFanin0(pObj)->pData;
if ( Aig_ObjFaninC0(pObj) )
pSims[i] = ~pSims0[i];
else
@@ -251,8 +254,8 @@ void Saig_StrSimSaveOutput( Aig_Obj_t * pObj, int i )
***********************************************************************/
void Saig_StrSimTransfer( Aig_Obj_t * pObj0, Aig_Obj_t * pObj1 )
{
- unsigned * pSims0 = pObj0->pData;
- unsigned * pSims1 = pObj1->pData;
+ unsigned * pSims0 = (unsigned *)pObj0->pData;
+ unsigned * pSims1 = (unsigned *)pObj1->pData;
int i;
for ( i = 0; i < SAIG_WORDS; i++ )
pSims1[i] = pSims0[i];
@@ -271,8 +274,8 @@ void Saig_StrSimTransfer( Aig_Obj_t * pObj0, Aig_Obj_t * pObj1 )
***********************************************************************/
void Saig_StrSimTransferNext( Aig_Obj_t * pObj0, Aig_Obj_t * pObj1, int i )
{
- unsigned * pSims0 = pObj0->pData;
- unsigned * pSims1 = pObj1->pData;
+ unsigned * pSims0 = (unsigned *)pObj0->pData;
+ unsigned * pSims1 = (unsigned *)pObj1->pData;
assert( i < SAIG_WORDS - 1 );
pSims1[i+1] = pSims0[i];
}
@@ -520,7 +523,7 @@ void Saig_StrSimPrepareAig( Aig_Man_t * p )
// allocate simulation info
p->pData2 = Vec_PtrAllocSimInfo( Aig_ManObjNumMax(p), SAIG_WORDS );
Aig_ManForEachObj( p, pObj, i )
- pObj->pData = Vec_PtrEntry( p->pData2, i );
+ pObj->pData = Vec_PtrEntry( (Vec_Ptr_t *)p->pData2, i );
// set simulation info for constant1 and register outputs
Saig_StrSimAssignOne( Aig_ManConst1(p) );
Saig_ManForEachLo( p, pObj, i )
@@ -821,7 +824,7 @@ void Ssw_StrSimMatchingExtend( Aig_Man_t * p0, Aig_Man_t * p1, int nDist, int fV
{
Ssw_StrSimMatchingExtendOne( p0, vNodes0 );
Ssw_StrSimMatchingExtendOne( p1, vNodes1 );
- Vec_PtrForEachEntry( vNodes0, pNext0, k )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes0, pNext0, k )
{
pNext1 = Aig_ObjRepr( p0, pNext0 );
if ( pNext1 == NULL )
@@ -832,7 +835,7 @@ void Ssw_StrSimMatchingExtend( Aig_Man_t * p0, Aig_Man_t * p1, int nDist, int fV
Aig_ObjSetRepr( p0, pNext0, NULL );
Aig_ObjSetRepr( p1, pNext1, NULL );
}
- Vec_PtrForEachEntry( vNodes1, pNext1, k )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes1, pNext1, k )
{
pNext0 = Aig_ObjRepr( p1, pNext1 );
if ( pNext0 == NULL )
@@ -932,8 +935,8 @@ Vec_Int_t * Saig_StrSimPerformMatching( Aig_Man_t * p0, Aig_Man_t * p1, int nDis
break;
}
// cleanup
- Vec_PtrFree( pPart0->pData2 ); pPart0->pData2 = NULL;
- Vec_PtrFree( pPart1->pData2 ); pPart1->pData2 = NULL;
+ Vec_PtrFree( (Vec_Ptr_t *)pPart0->pData2 ); pPart0->pData2 = NULL;
+ Vec_PtrFree( (Vec_Ptr_t *)pPart1->pData2 ); pPart1->pData2 = NULL;
// extend the islands
Aig_ManFanoutStart( pPart0 );
Aig_ManFanoutStart( pPart1 );
@@ -969,3 +972,5 @@ Vec_Int_t * Saig_StrSimPerformMatching( Aig_Man_t * p0, Aig_Man_t * p1, int nDis
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/saig/saigSwitch.c b/src/aig/saig/saigSwitch.c
index 122483d2..bbad9be4 100644
--- a/src/aig/saig/saigSwitch.c
+++ b/src/aig/saig/saigSwitch.c
@@ -20,6 +20,11 @@
#include "saig.h"
+#include "main.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -260,7 +265,6 @@ float Saig_ManComputeProbOnePlus( int nOnes, int nSimWords, int fCompl )
***********************************************************************/
Vec_Int_t * Saig_ManComputeSwitchProb4s( Aig_Man_t * p, int nFrames, int nPref, int fProbOne )
{
- extern char * Abc_FrameReadFlag( char * pFlag );
Saig_SimObj_t * pAig, * pEntry;
Vec_Int_t * vSwitching;
float * pSwitching;
@@ -564,3 +568,5 @@ Aig_CMan_t * Aig_CManCreate( Aig_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/saig/saigSynch.c b/src/aig/saig/saigSynch.c
index b29fcb9b..00f7517e 100644
--- a/src/aig/saig/saigSynch.c
+++ b/src/aig/saig/saigSynch.c
@@ -20,6 +20,9 @@
#include "saig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -75,7 +78,7 @@ void Saig_SynchSetConstant1( Aig_Man_t * pAig, Vec_Ptr_t * vSimInfo, int nWords
unsigned * pSim;
int w;
pObj = Aig_ManConst1( pAig );
- pSim = Vec_PtrEntry( vSimInfo, pObj->Id );
+ pSim = (unsigned *)Vec_PtrEntry( vSimInfo, pObj->Id );
for ( w = 0; w < nWords; w++ )
pSim[w] = 0x55555555;
}
@@ -98,7 +101,7 @@ void Saig_SynchInitRegsTernary( Aig_Man_t * pAig, Vec_Ptr_t * vSimInfo, int nWor
int i, w;
Saig_ManForEachLo( pAig, pObj, i )
{
- pSim = Vec_PtrEntry( vSimInfo, pObj->Id );
+ pSim = (unsigned *)Vec_PtrEntry( vSimInfo, pObj->Id );
for ( w = 0; w < nWords; w++ )
pSim[w] = 0xffffffff;
}
@@ -122,7 +125,7 @@ void Saig_SynchInitRegsBinary( Aig_Man_t * pAig, Vec_Ptr_t * vSimInfo, int nWord
int i, w;
Saig_ManForEachLo( pAig, pObj, i )
{
- pSim = Vec_PtrEntry( vSimInfo, pObj->Id );
+ pSim = (unsigned *)Vec_PtrEntry( vSimInfo, pObj->Id );
for ( w = 0; w < nWords; w++ )
pSim[w] = Saig_SynchTernary( pObj->fMarkA );
}
@@ -146,7 +149,7 @@ void Saig_SynchInitPisRandom( Aig_Man_t * pAig, Vec_Ptr_t * vSimInfo, int nWords
int i, w;
Saig_ManForEachPi( pAig, pObj, i )
{
- pSim = Vec_PtrEntry( vSimInfo, pObj->Id );
+ pSim = (unsigned *)Vec_PtrEntry( vSimInfo, pObj->Id );
for ( w = 0; w < nWords; w++ )
pSim[w] = Saig_SynchRandomBinary();
}
@@ -170,7 +173,7 @@ void Saig_SynchInitPisGiven( Aig_Man_t * pAig, Vec_Ptr_t * vSimInfo, int nWords,
int i, w;
Saig_ManForEachPi( pAig, pObj, i )
{
- pSim = Vec_PtrEntry( vSimInfo, pObj->Id );
+ pSim = (unsigned *)Vec_PtrEntry( vSimInfo, pObj->Id );
for ( w = 0; w < nWords; w++ )
pSim[w] = Saig_SynchTernary( pValues[i] );
}
@@ -195,9 +198,9 @@ void Saig_SynchTernarySimulate( Aig_Man_t * pAig, Vec_Ptr_t * vSimInfo, int nWor
// simulate nodes
Aig_ManForEachNode( pAig, pObj, i )
{
- pSim = Vec_PtrEntry( vSimInfo, pObj->Id );
- pSim0 = Vec_PtrEntry( vSimInfo, Aig_ObjFaninId0(pObj) );
- pSim1 = Vec_PtrEntry( vSimInfo, Aig_ObjFaninId1(pObj) );
+ pSim = (unsigned *)Vec_PtrEntry( vSimInfo, pObj->Id );
+ pSim0 = (unsigned *)Vec_PtrEntry( vSimInfo, Aig_ObjFaninId0(pObj) );
+ pSim1 = (unsigned *)Vec_PtrEntry( vSimInfo, Aig_ObjFaninId1(pObj) );
if ( Aig_ObjFaninC0(pObj) && Aig_ObjFaninC1(pObj) )
{
for ( w = 0; w < nWords; w++ )
@@ -222,8 +225,8 @@ void Saig_SynchTernarySimulate( Aig_Man_t * pAig, Vec_Ptr_t * vSimInfo, int nWor
// transfer values to register inputs
Saig_ManForEachLi( pAig, pObj, i )
{
- pSim = Vec_PtrEntry( vSimInfo, pObj->Id );
- pSim0 = Vec_PtrEntry( vSimInfo, Aig_ObjFaninId0(pObj) );
+ pSim = (unsigned *)Vec_PtrEntry( vSimInfo, pObj->Id );
+ pSim0 = (unsigned *)Vec_PtrEntry( vSimInfo, Aig_ObjFaninId0(pObj) );
if ( Aig_ObjFaninC0(pObj) )
{
for ( w = 0; w < nWords; w++ )
@@ -255,8 +258,8 @@ void Saig_SynchTernaryTransferState( Aig_Man_t * pAig, Vec_Ptr_t * vSimInfo, int
int i, w;
Saig_ManForEachLiLo( pAig, pObjLi, pObjLo, i )
{
- pSim0 = Vec_PtrEntry( vSimInfo, pObjLi->Id );
- pSim1 = Vec_PtrEntry( vSimInfo, pObjLo->Id );
+ pSim0 = (unsigned *)Vec_PtrEntry( vSimInfo, pObjLi->Id );
+ pSim1 = (unsigned *)Vec_PtrEntry( vSimInfo, pObjLo->Id );
for ( w = 0; w < nWords; w++ )
pSim1[w] = pSim0[w];
}
@@ -283,7 +286,7 @@ int Saig_SynchCountX( Aig_Man_t * pAig, Vec_Ptr_t * vSimInfo, int nWords, int *
pCounters = ABC_CALLOC( int, nWords * 16 );
Saig_ManForEachLi( pAig, pObj, i )
{
- pSim = Vec_PtrEntry( vSimInfo, pObj->Id );
+ pSim = (unsigned *)Vec_PtrEntry( vSimInfo, pObj->Id );
for ( w = 0; w < nWords; w++ )
for ( b = 0; b < 16; b++ )
if ( ((pSim[w] >> (b << 1)) & 3) == 3 )
@@ -324,7 +327,7 @@ int Saig_SynchSavePattern( Aig_Man_t * pAig, Vec_Ptr_t * vSimInfo, int nWords, i
assert( iPat < 16 * nWords );
Saig_ManForEachPi( pAig, pObj, i )
{
- pSim = Vec_PtrEntry( vSimInfo, pObj->Id );
+ pSim = (unsigned *)Vec_PtrEntry( vSimInfo, pObj->Id );
Value = (pSim[iPat>>4] >> ((iPat&0xf) << 1)) & 3;
Vec_StrPush( vSequence, (char)Value );
// printf( "%d ", Value );
@@ -333,11 +336,11 @@ int Saig_SynchSavePattern( Aig_Man_t * pAig, Vec_Ptr_t * vSimInfo, int nWords, i
Counter = 0;
Saig_ManForEachLiLo( pAig, pObjLi, pObjLo, i )
{
- pSim = Vec_PtrEntry( vSimInfo, pObjLi->Id );
+ pSim = (unsigned *)Vec_PtrEntry( vSimInfo, pObjLi->Id );
Value = (pSim[iPat>>4] >> ((iPat&0xf) << 1)) & 3;
Counter += (Value == 3);
// save patern in the same register
- pSim = Vec_PtrEntry( vSimInfo, pObjLo->Id );
+ pSim = (unsigned *)Vec_PtrEntry( vSimInfo, pObjLo->Id );
for ( w = 0; w < nWords; w++ )
pSim[w] = Saig_SynchTernary( Value );
}
@@ -377,7 +380,7 @@ int Saig_SynchSequenceRun( Aig_Man_t * pAig, Vec_Ptr_t * vSimInfo, Vec_Str_t * v
Counter = 0;
Saig_ManForEachLo( pAig, pObj, i )
{
- pSim = Vec_PtrEntry( vSimInfo, pObj->Id );
+ pSim = (unsigned *)Vec_PtrEntry( vSimInfo, pObj->Id );
Value = pSim[0] & 3;
assert( Value != 2 );
Counter += (Value == 3);
@@ -656,3 +659,5 @@ Aig_Man_t * Saig_Synchronize( Aig_Man_t * pAig1, Aig_Man_t * pAig2, int nWords,
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/saig/saigTrans.c b/src/aig/saig/saigTrans.c
index a92d9369..09639e27 100644
--- a/src/aig/saig/saigTrans.c
+++ b/src/aig/saig/saigTrans.c
@@ -19,6 +19,10 @@
***********************************************************************/
#include "saig.h"
+#include "fra.h"
+
+ABC_NAMESPACE_IMPL_START
+
/*
A similar approach is presented in the his paper:
@@ -59,7 +63,7 @@ static inline void Saig_ManStartMap1( Aig_Man_t * p, int nFrames )
static inline void Saig_ManStopMap1( Aig_Man_t * p )
{
assert( p->pData != NULL );
- Vec_IntFree( p->pData );
+ Vec_IntFree( (Vec_Int_t *)p->pData );
p->pData = NULL;
}
static inline int Saig_ManHasMap1( Aig_Man_t * p )
@@ -68,7 +72,7 @@ static inline int Saig_ManHasMap1( Aig_Man_t * p )
}
static inline void Saig_ManSetMap1( Aig_Man_t * p, Aig_Obj_t * pOld, int f1, Aig_Obj_t * pNew )
{
- Vec_Int_t * vMap = p->pData;
+ Vec_Int_t * vMap = (Vec_Int_t *)p->pData;
int nOffset = f1 * Aig_ManObjNumMax(p) + pOld->Id;
assert( !Aig_IsComplement(pOld) );
assert( !Aig_IsComplement(pNew) );
@@ -76,7 +80,7 @@ static inline void Saig_ManSetMap1( Aig_Man_t * p, Aig_Obj_t * pOld, int f1, Aig
}
static inline int Saig_ManGetMap1( Aig_Man_t * p, Aig_Obj_t * pOld, int f1 )
{
- Vec_Int_t * vMap = p->pData;
+ Vec_Int_t * vMap = (Vec_Int_t *)p->pData;
int nOffset = f1 * Aig_ManObjNumMax(p) + pOld->Id;
return Vec_IntEntry( vMap, nOffset );
}
@@ -106,7 +110,7 @@ static inline void Saig_ManStartMap2( Aig_Man_t * p, int nFrames )
static inline void Saig_ManStopMap2( Aig_Man_t * p )
{
assert( p->pData2 != NULL );
- Vec_IntFree( p->pData2 );
+ Vec_IntFree( (Vec_Int_t *)p->pData2 );
p->pData2 = NULL;
}
static inline int Saig_ManHasMap2( Aig_Man_t * p )
@@ -115,7 +119,7 @@ static inline int Saig_ManHasMap2( Aig_Man_t * p )
}
static inline void Saig_ManSetMap2( Aig_Man_t * p, Aig_Obj_t * pOld, int f1, Aig_Obj_t * pNew, int f2 )
{
- Vec_Int_t * vMap = p->pData2;
+ Vec_Int_t * vMap = (Vec_Int_t *)p->pData2;
int nOffset = f1 * Aig_ManObjNumMax(p) + pOld->Id;
assert( !Aig_IsComplement(pOld) );
assert( !Aig_IsComplement(pNew) );
@@ -124,7 +128,7 @@ static inline void Saig_ManSetMap2( Aig_Man_t * p, Aig_Obj_t * pOld, int f1, Aig
}
static inline int Saig_ManGetMap2( Aig_Man_t * p, Aig_Obj_t * pOld, int f1, int * pf2 )
{
- Vec_Int_t * vMap = p->pData2;
+ Vec_Int_t * vMap = (Vec_Int_t *)p->pData2;
int nOffset = f1 * Aig_ManObjNumMax(p) + pOld->Id;
*pf2 = Vec_IntEntry( vMap, 2*nOffset + 1 );
return Vec_IntEntry( vMap, 2*nOffset );
@@ -222,7 +226,7 @@ Aig_Man_t * Saig_ManFramesNonInitial( Aig_Man_t * pAig, int nFrames )
Aig_ManForEachObj( pAig, pObj, i )
{
assert( pObj->pData != NULL );
- Saig_ManSetMap1( pAig, pObj, f, Aig_Regular(pObj->pData) );
+ Saig_ManSetMap1( pAig, pObj, f, Aig_Regular((Aig_Obj_t *)pObj->pData) );
}
// quit if the last frame
if ( f == nFrames - 1 )
@@ -233,7 +237,7 @@ Aig_Man_t * Saig_ManFramesNonInitial( Aig_Man_t * pAig, int nFrames )
}
// remember register outputs
Saig_ManForEachLiLo( pAig, pObjLi, pObjLo, i )
- Aig_ObjCreatePo( pFrames, pObjLi->pData );
+ Aig_ObjCreatePo( pFrames, (Aig_Obj_t *)pObjLi->pData );
Aig_ManCleanup( pFrames );
return pFrames;
}
@@ -266,7 +270,7 @@ Aig_Man_t * Saig_ManFramesInitialMapped( Aig_Man_t * pAig, int nFrames, int nFra
Saig_ManForEachLo( pAig, pObj, i )
{
pObj->pData = Aig_ManConst0( pFrames );
- Saig_ManSetMap1( pAig, pObj, 0, Aig_Regular(pObj->pData) );
+ Saig_ManSetMap1( pAig, pObj, 0, Aig_Regular((Aig_Obj_t *)pObj->pData) );
}
}
else
@@ -279,7 +283,7 @@ Aig_Man_t * Saig_ManFramesInitialMapped( Aig_Man_t * pAig, int nFrames, int nFra
Saig_ManForEachLo( pAig, pObj, i )
{
pObj->pData = Aig_ObjCreatePi( pFrames );
- Saig_ManSetMap1( pAig, pObj, 0, Aig_Regular(pObj->pData) );
+ Saig_ManSetMap1( pAig, pObj, 0, Aig_Regular((Aig_Obj_t *)pObj->pData) );
}
}
// add timeframes
@@ -288,7 +292,7 @@ Aig_Man_t * Saig_ManFramesInitialMapped( Aig_Man_t * pAig, int nFrames, int nFra
// map the constant node
pObj = Aig_ManConst1(pAig);
pObj->pData = Aig_ManConst1( pFrames );
- Saig_ManSetMap1( pAig, pObj, f, Aig_Regular(pObj->pData) );
+ Saig_ManSetMap1( pAig, pObj, f, Aig_Regular((Aig_Obj_t *)pObj->pData) );
// create PI nodes for this frame
Saig_ManForEachPi( pAig, pObj, i )
{
@@ -296,13 +300,13 @@ Aig_Man_t * Saig_ManFramesInitialMapped( Aig_Man_t * pAig, int nFrames, int nFra
pObj->pData = Aig_ObjCreatePi( pFrames );
else
pObj->pData = Aig_ManPi( pFrames, f * Saig_ManPiNum(pAig) + i );
- Saig_ManSetMap1( pAig, pObj, f, Aig_Regular(pObj->pData) );
+ Saig_ManSetMap1( pAig, pObj, f, Aig_Regular((Aig_Obj_t *)pObj->pData) );
}
// add internal nodes of this frame
Aig_ManForEachNode( pAig, pObj, i )
{
pObj->pData = Aig_And( pFrames, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
- Saig_ManSetMap1( pAig, pObj, f, Aig_Regular(pObj->pData) );
+ Saig_ManSetMap1( pAig, pObj, f, Aig_Regular((Aig_Obj_t *)pObj->pData) );
if ( !Saig_ManHasMap2(pAig) )
continue;
if ( f < nFrames )
@@ -322,19 +326,19 @@ Aig_Man_t * Saig_ManFramesInitialMapped( Aig_Man_t * pAig, int nFrames, int nFra
iNum1 = Saig_ManGetMap1( pAig, Aig_ManObj(pAig, iNum2), iFrame2 );
pRepr = Aig_ManObj( pFrames, iNum1 );
// compare the phases of these nodes
- pObj->pData = Aig_NotCond( pRepr, pRepr->fPhase ^ Aig_ObjPhaseReal(pObj->pData) );
+ pObj->pData = Aig_NotCond( pRepr, pRepr->fPhase ^ Aig_ObjPhaseReal((Aig_Obj_t *)pObj->pData) );
}
// create POs for this frame
Saig_ManForEachPo( pAig, pObj, i )
{
pObj->pData = Aig_ObjCreatePo( pFrames, Aig_ObjChild0Copy(pObj) );
- Saig_ManSetMap1( pAig, pObj, f, Aig_Regular(pObj->pData) );
+ Saig_ManSetMap1( pAig, pObj, f, Aig_Regular((Aig_Obj_t *)pObj->pData) );
}
// save register inputs
Saig_ManForEachLi( pAig, pObj, i )
{
pObj->pData = Aig_ObjChild0Copy(pObj);
- Saig_ManSetMap1( pAig, pObj, f, Aig_Regular(pObj->pData) );
+ Saig_ManSetMap1( pAig, pObj, f, Aig_Regular((Aig_Obj_t *)pObj->pData) );
}
// quit if the last frame
if ( f == nFramesMax - 1 )
@@ -344,14 +348,14 @@ Aig_Man_t * Saig_ManFramesInitialMapped( Aig_Man_t * pAig, int nFrames, int nFra
{
pObjLo->pData = pObjLi->pData;
if ( !fInit )
- Saig_ManSetMap1( pAig, pObjLo, f+1, Aig_Regular(pObjLo->pData) );
+ Saig_ManSetMap1( pAig, pObjLo, f+1, Aig_Regular((Aig_Obj_t *)pObjLo->pData) );
}
}
if ( !fInit )
{
// create registers
Saig_ManForEachLiLo( pAig, pObjLi, pObjLo, i )
- Aig_ObjCreatePo( pFrames, pObjLi->pData );
+ Aig_ObjCreatePo( pFrames, (Aig_Obj_t *)pObjLi->pData );
// set register number
Aig_ManSetRegNum( pFrames, pAig->nRegs );
}
@@ -373,7 +377,7 @@ Aig_Man_t * Saig_ManFramesInitialMapped( Aig_Man_t * pAig, int nFrames, int nFra
***********************************************************************/
Aig_Man_t * Saig_ManTimeframeSimplify( Aig_Man_t * pAig, int nFrames, int nFramesMax, int fInit, int fVerbose )
{
- extern Aig_Man_t * Fra_FraigEquivence( Aig_Man_t * pManAig, int nConfMax, int fProve );
+// extern Aig_Man_t * Fra_FraigEquivence( Aig_Man_t * pManAig, int nConfMax, int fProve );
Aig_Man_t * pFrames, * pFraig, * pRes1, * pRes2;
int clk;
// create uninitialized timeframes with map1
@@ -420,3 +424,5 @@ ABC_PRT( "Normal", clock() - clk );
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/saig/saigWnd.c b/src/aig/saig/saigWnd.c
index 10202f1b..eeacb44e 100644
--- a/src/aig/saig/saigWnd.c
+++ b/src/aig/saig/saigWnd.c
@@ -20,6 +20,9 @@
#include "saig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -103,7 +106,7 @@ Vec_Ptr_t * Saig_ManWindowOutline( Aig_Man_t * p, Aig_Obj_t * pObj, int nDist )
vNodes = Vec_PtrAlloc( 1000 );
Aig_ManIncrementTravId( p );
Saig_ManWindowOutline_rec( p, pObj, nDist, vNodes, pDists );
- Vec_PtrSort( vNodes, Aig_ObjCompareIdIncrease );
+ Vec_PtrSort( vNodes, (int (*)(void))Aig_ObjCompareIdIncrease );
// make sure LI/LO are labeled/unlabeled mutually
Saig_ManForEachLiLo( p, pObjLi, pObjLo, i )
assert( Aig_ObjIsTravIdCurrent(p, pObjLi) ==
@@ -150,7 +153,7 @@ Vec_Ptr_t * Saig_ManWindowCollectPis( Aig_Man_t * p, Vec_Ptr_t * vNodes )
Aig_Obj_t * pObj, * pMatch, * pFanin;
int i;
vNodesPi = Vec_PtrAlloc( 1000 );
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
{
if ( Saig_ObjIsPi(p, pObj) )
{
@@ -197,7 +200,7 @@ Vec_Ptr_t * Saig_ManWindowCollectPos( Aig_Man_t * p, Vec_Ptr_t * vNodes, Vec_Ptr
vNodesPo = Vec_PtrAlloc( 1000 );
if ( pvPointers )
*pvPointers = Vec_PtrAlloc( 1000 );
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
{
if ( (pPointer = Saig_ObjHasUnlabeledFanout(p, pObj)) )
{
@@ -236,29 +239,29 @@ Aig_Man_t * Saig_ManWindowExtractNodes( Aig_Man_t * p, Vec_Ptr_t * vNodes )
pObj->pData = Aig_ManConst1( pNew );
// create real PIs
vNodesPi = Saig_ManWindowCollectPis( p, vNodes );
- Vec_PtrForEachEntry( vNodesPi, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodesPi, pObj, i )
pObj->pData = Aig_ObjCreatePi(pNew);
Vec_PtrFree( vNodesPi );
// create register outputs
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
{
if ( Saig_ObjIsLo(p, pObj) )
pObj->pData = Aig_ObjCreatePi(pNew);
}
// create internal nodes
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
{
if ( Aig_ObjIsNode(pObj) )
pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
}
// create POs
vNodesPo = Saig_ManWindowCollectPos( p, vNodes, NULL );
- Vec_PtrForEachEntry( vNodesPo, pObj, i )
- Aig_ObjCreatePo( pNew, pObj->pData );
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodesPo, pObj, i )
+ Aig_ObjCreatePo( pNew, (Aig_Obj_t *)pObj->pData );
Vec_PtrFree( vNodesPo );
// create register inputs
nRegCount = 0;
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
{
if ( Saig_ObjIsLo(p, pObj) )
{
@@ -292,7 +295,7 @@ void Saig_ManWindowInsertBig_rec( Aig_Man_t * pNew, Aig_Obj_t * pObjBig,
Aig_Obj_t * pMatch;
if ( pObjBig->pData )
return;
- if ( (pMatch = Vec_PtrEntry( vBigNode2SmallPo, pObjBig->Id )) )
+ if ( (pMatch = (Aig_Obj_t *)Vec_PtrEntry( vBigNode2SmallPo, pObjBig->Id )) )
{
Saig_ManWindowInsertSmall_rec( pNew, Aig_ObjFanin0(pMatch), vBigNode2SmallPo, vSmallPi2BigNode );
pObjBig->pData = Aig_ObjChild0Copy(pMatch);
@@ -321,7 +324,7 @@ void Saig_ManWindowInsertSmall_rec( Aig_Man_t * pNew, Aig_Obj_t * pObjSmall,
Aig_Obj_t * pMatch;
if ( pObjSmall->pData )
return;
- if ( (pMatch = Vec_PtrEntry( vSmallPi2BigNode, pObjSmall->Id )) )
+ if ( (pMatch = (Aig_Obj_t *)Vec_PtrEntry( vSmallPi2BigNode, pObjSmall->Id )) )
{
Saig_ManWindowInsertBig_rec( pNew, pMatch, vBigNode2SmallPo, vSmallPi2BigNode );
pObjSmall->pData = pMatch->pData;
@@ -355,7 +358,7 @@ Aig_Man_t * Saig_ManWindowInsertNodes( Aig_Man_t * p, Vec_Ptr_t * vNodes, Aig_Ma
// set mapping of small PIs into big nodes
vSmallPi2BigNode = Vec_PtrStart( Aig_ManObjNumMax(pWnd) );
vNodesPi = Saig_ManWindowCollectPis( p, vNodes );
- Vec_PtrForEachEntry( vNodesPi, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodesPi, pObj, i )
Vec_PtrWriteEntry( vSmallPi2BigNode, Aig_ManPi(pWnd, i)->Id, pObj );
assert( i == Saig_ManPiNum(pWnd) );
Vec_PtrFree( vNodesPi );
@@ -363,7 +366,7 @@ Aig_Man_t * Saig_ManWindowInsertNodes( Aig_Man_t * p, Vec_Ptr_t * vNodes, Aig_Ma
// set mapping of big nodes into small POs
vBigNode2SmallPo = Vec_PtrStart( Aig_ManObjNumMax(p) );
vNodesPo = Saig_ManWindowCollectPos( p, vNodes, NULL );
- Vec_PtrForEachEntry( vNodesPo, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodesPo, pObj, i )
Vec_PtrWriteEntry( vBigNode2SmallPo, pObj->Id, Aig_ManPo(pWnd, i) );
assert( i == Saig_ManPoNum(pWnd) );
Vec_PtrFree( vNodesPo );
@@ -589,7 +592,7 @@ void Saig_ManWindowCreatePis( Aig_Man_t * pNew, Aig_Man_t * p0, Aig_Man_t * p1,
{
Aig_Obj_t * pObj, * pMatch, * pFanin;
int i, Counter = 0;
- Vec_PtrForEachEntry( vNodes0, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes0, pObj, i )
{
if ( Saig_ObjIsLo(p0, pObj) )
{
@@ -667,7 +670,7 @@ void Saig_ManWindowCreatePos( Aig_Man_t * pNew, Aig_Man_t * p0, Aig_Man_t * p1 )
Aig_ObjIsTravIdCurrent(p1, pFanin1) );
if ( Aig_ObjIsTravIdCurrent(p0, pFanin0) )
{
- pMiter = Aig_Exor( pNew, pFanin0->pData, pFanin1->pData );
+ pMiter = Aig_Exor( pNew, (Aig_Obj_t *)pFanin0->pData, (Aig_Obj_t *)pFanin1->pData );
Aig_ObjCreatePo( pNew, pMiter );
}
}
@@ -681,7 +684,7 @@ void Saig_ManWindowCreatePos( Aig_Man_t * pNew, Aig_Man_t * p0, Aig_Man_t * p1 )
Aig_ObjIsTravIdCurrent(p1, pFanin1) );
if ( Aig_ObjIsTravIdCurrent(p0, pFanin0) )
{
- pMiter = Aig_Exor( pNew, pFanin0->pData, pFanin1->pData );
+ pMiter = Aig_Exor( pNew, (Aig_Obj_t *)pFanin0->pData, (Aig_Obj_t *)pFanin1->pData );
Aig_ObjCreatePo( pNew, pMiter );
}
@@ -691,7 +694,7 @@ void Saig_ManWindowCreatePos( Aig_Man_t * pNew, Aig_Man_t * p0, Aig_Man_t * p1 )
Aig_ObjIsTravIdCurrent(p1, pFanin1) );
if ( Aig_ObjIsTravIdCurrent(p0, pFanin0) )
{
- pMiter = Aig_Exor( pNew, pFanin0->pData, pFanin1->pData );
+ pMiter = Aig_Exor( pNew, (Aig_Obj_t *)pFanin0->pData, (Aig_Obj_t *)pFanin1->pData );
Aig_ObjCreatePo( pNew, pMiter );
}
}
@@ -753,23 +756,23 @@ Aig_Man_t * Saig_ManWindowExtractMiter( Aig_Man_t * p0, Aig_Man_t * p1 )
Saig_ManWindowCreatePis( pNew, p0, p1, vNodes0 );
Saig_ManWindowCreatePis( pNew, p1, p0, vNodes1 );
// create register outputs
- Vec_PtrForEachEntry( vNodes0, pObj0, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes0, pObj0, i )
{
if ( Saig_ObjIsLo(p0, pObj0) )
pObj0->pData = Aig_ObjCreatePi(pNew);
}
- Vec_PtrForEachEntry( vNodes1, pObj1, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes1, pObj1, i )
{
if ( Saig_ObjIsLo(p1, pObj1) )
pObj1->pData = Aig_ObjCreatePi(pNew);
}
// create internal nodes
- Vec_PtrForEachEntry( vNodes0, pObj0, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes0, pObj0, i )
{
if ( Aig_ObjIsNode(pObj0) )
pObj0->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj0), Aig_ObjChild1Copy(pObj0) );
}
- Vec_PtrForEachEntry( vNodes1, pObj1, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes1, pObj1, i )
{
if ( Aig_ObjIsNode(pObj1) )
pObj1->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj1), Aig_ObjChild1Copy(pObj1) );
@@ -779,7 +782,7 @@ Aig_Man_t * Saig_ManWindowExtractMiter( Aig_Man_t * p0, Aig_Man_t * p1 )
// Saig_ManWindowCreatePos( pNew, p1, p0 );
// create register inputs
nRegCount = 0;
- Vec_PtrForEachEntry( vNodes0, pObj0, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes0, pObj0, i )
{
if ( Saig_ObjIsLo(p0, pObj0) )
{
@@ -788,7 +791,7 @@ Aig_Man_t * Saig_ManWindowExtractMiter( Aig_Man_t * p0, Aig_Man_t * p1 )
nRegCount++;
}
}
- Vec_PtrForEachEntry( vNodes1, pObj1, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes1, pObj1, i )
{
if ( Saig_ObjIsLo(p1, pObj1) )
{
@@ -807,3 +810,5 @@ Aig_Man_t * Saig_ManWindowExtractMiter( Aig_Man_t * p0, Aig_Man_t * p1 )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/saig/saig_.c b/src/aig/saig/saig_.c
index 255639e6..f0f293fd 100644
--- a/src/aig/saig/saig_.c
+++ b/src/aig/saig/saig_.c
@@ -20,6 +20,9 @@
#include "saig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -45,3 +48,5 @@
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ssw/module.make b/src/aig/ssw/module.make
index 1e79c955..9d93fb93 100644
--- a/src/aig/ssw/module.make
+++ b/src/aig/ssw/module.make
@@ -2,8 +2,10 @@ SRC += src/aig/ssw/sswAig.c \
src/aig/ssw/sswBmc.c \
src/aig/ssw/sswClass.c \
src/aig/ssw/sswCnf.c \
+ src/aig/ssw/sswConstr.c \
src/aig/ssw/sswCore.c \
src/aig/ssw/sswDyn.c \
+ src/aig/ssw/sswFilter.c \
src/aig/ssw/sswIslands.c \
src/aig/ssw/sswLcorr.c \
src/aig/ssw/sswMan.c \
diff --git a/src/aig/ssw/ssw.h b/src/aig/ssw/ssw.h
index c2a33ee4..207ebea9 100644
--- a/src/aig/ssw/ssw.h
+++ b/src/aig/ssw/ssw.h
@@ -21,6 +21,7 @@
#ifndef __SSW_H__
#define __SSW_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -29,9 +30,7 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+ABC_NAMESPACE_HEADER_START
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -45,7 +44,8 @@ struct Ssw_Pars_t_
int nOverSize; // size of the overlap between partitions
int nFramesK; // the induction depth
int nFramesAddSim; // the number of additional frames to simulate
- int nConstrs; // treat the last nConstrs POs as seq constraints
+ int fConstrs; // treat the last nConstrs POs as seq constraints
+ int fMergeFull; // enables full merge when constraints are used
int nMaxLevs; // the max number of levels of nodes to consider
int nBTLimit; // conflict limit at a node
int nBTLimitGlobal;// conflict limit for multiple runs
@@ -53,10 +53,13 @@ struct Ssw_Pars_t_
int nItersStop; // stop after the given number of iterations
int fDumpSRInit; // dumps speculative reduction
int nResimDelta; // the number of nodes to resimulate
+ int nStepsMax; // (scorr only) the max number of induction steps
+ int TimeLimit; // time out in seconds
int fPolarFlip; // uses polarity adjustment
int fLatchCorr; // perform register correspondence
+ int fOutputCorr; // perform 'PO correspondence'
int fSemiFormal; // enable semiformal filtering
- int fUniqueness; // enable uniqueness constraints
+// int fUniqueness; // enable uniqueness constraints
int fDynamic; // enable dynamic addition of constraints
int fLocalSim; // enable local simulation simulation
int fPartSigCorr; // uses partial signal correspondence
@@ -75,18 +78,9 @@ struct Ssw_Pars_t_
// internal parameters
int nIters; // the number of iterations performed
int nConflicts; // the total number of conflicts performed
-};
-
-// sequential counter-example
-typedef struct Ssw_Cex_t_ Ssw_Cex_t;
-struct Ssw_Cex_t_
-{
- int iPo; // the zero-based number of PO, for which verification failed
- int iFrame; // the zero-based number of the time-frame, for which verificaiton failed
- int nRegs; // the number of registers in the miter
- int nPis; // the number of primary inputs in the miter
- int nBits; // the number of words of bit data used
- unsigned pData[0]; // the cex bit data (the number of bits: nRegs + (iFrame+1) * nPis)
+ // callback
+ void * pData;
+ void * pFunc;
};
typedef struct Ssw_Sml_t_ Ssw_Sml_t; // sequential simulation manager
@@ -101,6 +95,8 @@ typedef struct Ssw_Sml_t_ Ssw_Sml_t; // sequential simulation manager
/*=== sswBmc.c ==========================================================*/
extern int Ssw_BmcDynamic( Aig_Man_t * pAig, int nFramesMax, int nConfLimit, int fVerbose, int * piFrame );
+/*=== sswConstr.c ==========================================================*/
+extern int Ssw_ManSetConstrPhases( Aig_Man_t * p, int nFrames, Vec_Int_t ** pvInits );
/*=== sswCore.c ==========================================================*/
extern void Ssw_ManSetDefaultParams( Ssw_Pars_t * p );
extern void Ssw_ManSetDefaultParamsLcorr( Ssw_Pars_t * p );
@@ -110,7 +106,6 @@ extern Aig_Man_t * Ssw_LatchCorrespondence( Aig_Man_t * pAig, Ssw_Pars_t * pPa
extern int Ssw_SecWithSimilarityPairs( Aig_Man_t * p0, Aig_Man_t * p1, Vec_Int_t * vPairs, Ssw_Pars_t * pPars );
extern int Ssw_SecWithSimilarity( Aig_Man_t * p0, Aig_Man_t * p1, Ssw_Pars_t * pPars );
/*=== sswMiter.c ===================================================*/
-extern int Ssw_SecSpecialMiter( Aig_Man_t * p0, Aig_Man_t * p1, int nFrames, int fVerbose );
/*=== sswPart.c ==========================================================*/
extern Aig_Man_t * Ssw_SignalCorrespondencePart( Aig_Man_t * pAig, Ssw_Pars_t * pPars );
/*=== sswPairs.c ===================================================*/
@@ -127,15 +122,17 @@ extern int Ssw_SmlNumFrames( Ssw_Sml_t * p );
extern int Ssw_SmlNumWordsTotal( Ssw_Sml_t * p );
extern unsigned * Ssw_SmlSimInfo( Ssw_Sml_t * p, Aig_Obj_t * pObj );
extern int Ssw_SmlObjsAreEqualWord( Ssw_Sml_t * p, Aig_Obj_t * pObj0, Aig_Obj_t * pObj1 );
-extern Ssw_Cex_t * Ssw_SmlAllocCounterExample( int nRegs, int nRealPis, int nFrames );
-extern void Ssw_SmlFreeCounterExample( Ssw_Cex_t * pCex );
-extern int Ssw_SmlRunCounterExample( Aig_Man_t * pAig, Ssw_Cex_t * p );
-extern int Ssw_SmlFindOutputCounterExample( Aig_Man_t * pAig, Ssw_Cex_t * p );
-extern Ssw_Cex_t * Ssw_SmlDupCounterExample( Ssw_Cex_t * p, int nRegsNew );
-
-#ifdef __cplusplus
-}
-#endif
+extern Abc_Cex_t * Ssw_SmlAllocCounterExample( int nRegs, int nRealPis, int nFrames );
+extern void Ssw_SmlFreeCounterExample( Abc_Cex_t * pCex );
+extern int Ssw_SmlRunCounterExample( Aig_Man_t * pAig, Abc_Cex_t * p );
+extern int Ssw_SmlFindOutputCounterExample( Aig_Man_t * pAig, Abc_Cex_t * p );
+extern Abc_Cex_t * Ssw_SmlDupCounterExample( Abc_Cex_t * p, int nRegsNew );
+
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/aig/ssw/sswAig.c b/src/aig/ssw/sswAig.c
index 62e93d2d..f3174470 100644
--- a/src/aig/ssw/sswAig.c
+++ b/src/aig/ssw/sswAig.c
@@ -20,6 +20,9 @@
#include "sswInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -142,7 +145,7 @@ Aig_Man_t * Ssw_FramesWithClasses( Ssw_Man_t * p )
{
Aig_Man_t * pFrames;
Aig_Obj_t * pObj, * pObjLi, * pObjLo, * pObjNew;
- int i, f;
+ int i, f, iLits;
assert( p->pFrames == NULL );
assert( Aig_ManRegNum(p->pAig) > 0 );
assert( Aig_ManRegNum(p->pAig) < Aig_ManPiNum(p->pAig) );
@@ -154,12 +157,17 @@ Aig_Man_t * Ssw_FramesWithClasses( Ssw_Man_t * p )
Saig_ManForEachLo( p->pAig, pObj, i )
Ssw_ObjSetFrame( p, pObj, 0, Aig_ObjCreatePi(pFrames) );
// add timeframes
+ iLits = 0;
for ( f = 0; f < p->pPars->nFramesK; f++ )
{
// map constants and PIs
Ssw_ObjSetFrame( p, Aig_ManConst1(p->pAig), f, Aig_ManConst1(pFrames) );
Saig_ManForEachPi( p->pAig, pObj, i )
- Ssw_ObjSetFrame( p, pObj, f, Aig_ObjCreatePi(pFrames) );
+ {
+ pObjNew = Aig_ObjCreatePi(pFrames);
+ pObjNew->fPhase = (p->vInits != NULL) && Vec_IntEntry(p->vInits, iLits++);
+ Ssw_ObjSetFrame( p, pObj, f, pObjNew );
+ }
// set the constraints on the latch outputs
Saig_ManForEachLo( p->pAig, pObj, i )
Ssw_FramesConstrainNode( p, pFrames, p->pAig, pObj, f, 1 );
@@ -170,10 +178,14 @@ Aig_Man_t * Ssw_FramesWithClasses( Ssw_Man_t * p )
Ssw_ObjSetFrame( p, pObj, f, pObjNew );
Ssw_FramesConstrainNode( p, pFrames, p->pAig, pObj, f, 1 );
}
+ // transfer to the primary outputs
+ Aig_ManForEachPo( p->pAig, pObj, i )
+ Ssw_ObjSetFrame( p, pObj, f, Ssw_ObjChild0Fra(p, pObj,f) );
// transfer latch input to the latch outputs
Saig_ManForEachLiLo( p->pAig, pObjLi, pObjLo, i )
- Ssw_ObjSetFrame( p, pObjLo, f+1, Ssw_ObjChild0Fra(p, pObjLi,f) );
+ Ssw_ObjSetFrame( p, pObjLo, f+1, Ssw_ObjFrame(p, pObjLi,f) );
}
+ assert( p->vInits == NULL || Vec_IntSize(p->vInits) == iLits + Saig_ManPiNum(p->pAig) );
// add the POs for the latch outputs of the last frame
Saig_ManForEachLo( p->pAig, pObj, i )
Aig_ObjCreatePo( pFrames, Ssw_ObjFrame( p, pObj, p->pPars->nFramesK ) );
@@ -186,8 +198,6 @@ Aig_Man_t * Ssw_FramesWithClasses( Ssw_Man_t * p )
return pFrames;
}
-
-
/**Function*************************************************************
Synopsis [Prepares the inductive case with speculative reduction.]
@@ -245,3 +255,5 @@ Aig_Man_t * Ssw_SpeculativeReduction( Ssw_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ssw/sswBmc.c b/src/aig/ssw/sswBmc.c
index 86d04424..aba32304 100644
--- a/src/aig/ssw/sswBmc.c
+++ b/src/aig/ssw/sswBmc.c
@@ -20,6 +20,9 @@
#include "sswInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -84,9 +87,9 @@ Aig_Obj_t * Ssw_BmcUnroll_rec( Ssw_Frm_t * pFrm, Aig_Obj_t * pObj, int f )
SeeAlso []
***********************************************************************/
-Ssw_Cex_t * Ssw_BmcGetCounterExample( Ssw_Frm_t * pFrm, Ssw_Sat_t * pSat, int iPo, int iFrame )
+Abc_Cex_t * Ssw_BmcGetCounterExample( Ssw_Frm_t * pFrm, Ssw_Sat_t * pSat, int iPo, int iFrame )
{
- Ssw_Cex_t * pCex;
+ Abc_Cex_t * pCex;
Aig_Obj_t * pObj, * pObjFrames;
int f, i, nShift;
assert( Saig_ManRegNum(pFrm->pAig) > 0 );
@@ -217,3 +220,5 @@ int Ssw_BmcDynamic( Aig_Man_t * pAig, int nFramesMax, int nConfLimit, int fVerbo
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ssw/sswClass.c b/src/aig/ssw/sswClass.c
index ce6ebf85..7fd2a21b 100644
--- a/src/aig/ssw/sswClass.c
+++ b/src/aig/ssw/sswClass.c
@@ -20,6 +20,9 @@
#include "sswInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*
The candidate equivalence classes are stored as a vector of pointers
to the array of pointers to the nodes in each class.
@@ -144,8 +147,8 @@ Ssw_Cla_t * Ssw_ClassesStart( Aig_Man_t * pAig )
p->vClassOld = Vec_PtrAlloc( 100 );
p->vClassNew = Vec_PtrAlloc( 100 );
p->vRefined = Vec_PtrAlloc( 1000 );
- assert( pAig->pReprs == NULL );
- Aig_ManReprStart( pAig, Aig_ManObjNumMax(pAig) );
+ if ( pAig->pReprs == NULL )
+ Aig_ManReprStart( pAig, Aig_ManObjNumMax(pAig) );
return p;
}
@@ -412,7 +415,7 @@ void Ssw_ClassesPrint( Ssw_Cla_t * p, int fVeryVerbose )
Aig_Obj_t ** ppClass;
Aig_Obj_t * pObj;
int i;
- printf( "Equivalence classes: Const1 = %5d. Class = %5d. Lit = %5d.\n",
+ printf( "Equiv classes: Const1 = %5d. Class = %5d. Lit = %5d.\n",
p->nCands1, p->nClasses, p->nCands1+p->nLits );
if ( !fVeryVerbose )
return;
@@ -508,7 +511,7 @@ int Ssw_ClassesPrepareRehash( Ssw_Cla_t * p, Vec_Ptr_t * vCands )
// sort through the candidates
nEntries = 0;
p->nCands1 = 0;
- Vec_PtrForEachEntry( vCands, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vCands, pObj, i )
{
assert( p->pClassSizes[pObj->Id] == 0 );
Aig_ObjSetRepr( p->pAig, pObj, NULL );
@@ -547,7 +550,7 @@ int Ssw_ClassesPrepareRehash( Ssw_Cla_t * p, Vec_Ptr_t * vCands )
// copy the entries into storage in the topological order
nEntries2 = 0;
- Vec_PtrForEachEntry( vCands, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vCands, pObj, i )
{
nNodes = p->pClassSizes[pObj->Id];
// skip the nodes that are not representatives of non-trivial classes
@@ -587,7 +590,7 @@ int Ssw_ClassesPrepareRehash( Ssw_Cla_t * p, Vec_Ptr_t * vCands )
SeeAlso []
***********************************************************************/
-Ssw_Cla_t * Ssw_ClassesPrepare( Aig_Man_t * pAig, int nFramesK, int fLatchCorr, int nMaxLevs, int fVerbose )
+Ssw_Cla_t * Ssw_ClassesPrepare( Aig_Man_t * pAig, int nFramesK, int fLatchCorr, int fOutputCorr, int nMaxLevs, int fVerbose )
{
// int nFrames = 4;
// int nWords = 1;
@@ -622,7 +625,7 @@ if ( fVerbose )
// set comparison procedures
clk = clock();
- Ssw_ClassesSetData( p, pSml, Ssw_SmlObjHashWord, Ssw_SmlObjIsConstWord, Ssw_SmlObjsAreEqualWord );
+ Ssw_ClassesSetData( p, pSml, (unsigned(*)(void *,Aig_Obj_t *))Ssw_SmlObjHashWord, (int(*)(void *,Aig_Obj_t *))Ssw_SmlObjIsConstWord, (int(*)(void *,Aig_Obj_t *,Aig_Obj_t *))Ssw_SmlObjsAreEqualWord );
// collect nodes to be considered as candidates
vCands = Vec_PtrAlloc( 1000 );
@@ -643,6 +646,22 @@ clk = clock();
}
Vec_PtrPush( vCands, pObj );
}
+
+ // this change will consider all PO drivers
+ if ( fOutputCorr )
+ {
+ Vec_PtrClear( vCands );
+ Aig_ManForEachObj( p->pAig, pObj, i )
+ pObj->fMarkB = 0;
+ Saig_ManForEachPo( p->pAig, pObj, i )
+ if ( Aig_ObjIsCand(Aig_ObjFanin0(pObj)) )
+ Aig_ObjFanin0(pObj)->fMarkB = 1;
+ Aig_ManForEachObj( p->pAig, pObj, i )
+ if ( pObj->fMarkB )
+ Vec_PtrPush( vCands, pObj );
+ Aig_ManForEachObj( p->pAig, pObj, i )
+ pObj->fMarkB = 0;
+ }
// allocate room for classes
p->pMemClasses = ABC_ALLOC( Aig_Obj_t *, Vec_PtrSize(vCands) );
@@ -741,6 +760,69 @@ Ssw_Cla_t * Ssw_ClassesPrepareSimple( Aig_Man_t * pAig, int fLatchCorr, int nMax
SeeAlso []
***********************************************************************/
+Ssw_Cla_t * Ssw_ClassesPrepareFromReprs( Aig_Man_t * pAig )
+{
+ Ssw_Cla_t * p;
+ Aig_Obj_t * pObj, * pRepr;
+ int * pClassSizes, nEntries, i;
+ // start the classes
+ p = Ssw_ClassesStart( pAig );
+ // allocate memory for classes
+ p->pMemClasses = ABC_CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(pAig) );
+ // count classes
+ p->nCands1 = 0;
+ Aig_ManForEachObj( pAig, pObj, i )
+ {
+ if ( Ssw_ObjIsConst1Cand(pAig, pObj) )
+ {
+ p->nCands1++;
+ continue;
+ }
+ if ( (pRepr = Aig_ObjRepr(pAig, pObj)) )
+ {
+ if ( p->pClassSizes[pRepr->Id]++ == 0 )
+ p->pClassSizes[pRepr->Id]++;
+ }
+ }
+ // add nodes
+ nEntries = 0;
+ p->nClasses = 0;
+ pClassSizes = ABC_CALLOC( int, Aig_ManObjNumMax(pAig) );
+ Aig_ManForEachObj( pAig, pObj, i )
+ {
+ if ( p->pClassSizes[i] )
+ {
+ p->pId2Class[i] = p->pMemClasses + nEntries;
+ nEntries += p->pClassSizes[i];
+ p->pId2Class[i][pClassSizes[i]++] = pObj;
+ p->nClasses++;
+ continue;
+ }
+ if ( Ssw_ObjIsConst1Cand(pAig, pObj) )
+ continue;
+ if ( (pRepr = Aig_ObjRepr(pAig, pObj)) )
+ p->pId2Class[pRepr->Id][pClassSizes[pRepr->Id]++] = pObj;
+ }
+ p->pMemClassesFree = p->pMemClasses + nEntries;
+ p->nLits = nEntries - p->nClasses;
+ assert( memcmp(pClassSizes, p->pClassSizes, sizeof(int)*Aig_ManObjNumMax(pAig)) == 0 );
+ ABC_FREE( pClassSizes );
+// printf( "After converting:\n" );
+// Ssw_ClassesPrint( p, 0 );
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates initial simulation classes.]
+
+ Description [Assumes that simulation info is assigned.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
Ssw_Cla_t * Ssw_ClassesPrepareTargets( Aig_Man_t * pAig )
{
Ssw_Cla_t * p;
@@ -902,20 +984,20 @@ int Ssw_ClassesRefineOneClass( Ssw_Cla_t * p, Aig_Obj_t * pReprOld, int fRecursi
// Vec_PtrPush( p->vRefined, pObj );
// get the new representative
- pReprNew = Vec_PtrEntry( p->vClassNew, 0 );
+ pReprNew = (Aig_Obj_t *)Vec_PtrEntry( p->vClassNew, 0 );
assert( Vec_PtrSize(p->vClassOld) > 0 );
assert( Vec_PtrSize(p->vClassNew) > 0 );
// create old class
pClassOld = Ssw_ObjRemoveClass( p, pReprOld );
- Vec_PtrForEachEntry( p->vClassOld, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vClassOld, pObj, i )
{
pClassOld[i] = pObj;
Aig_ObjSetRepr( p->pAig, pObj, i? pReprOld : NULL );
}
// create new class
pClassNew = pClassOld + i;
- Vec_PtrForEachEntry( p->vClassNew, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vClassNew, pObj, i )
{
pClassNew[i] = pObj;
Aig_ObjSetRepr( p->pAig, pObj, i? pReprNew : NULL );
@@ -972,21 +1054,21 @@ int Ssw_ClassesRefineConst1Group( Ssw_Cla_t * p, Vec_Ptr_t * vRoots, int fRecurs
return 0;
// collect the nodes to be refined
Vec_PtrClear( p->vClassNew );
- Vec_PtrForEachEntry( vRoots, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vRoots, pObj, i )
if ( !p->pFuncNodeIsConst( p->pManData, pObj ) )
Vec_PtrPush( p->vClassNew, pObj );
// check if there is a new class
if ( Vec_PtrSize(p->vClassNew) == 0 )
return 0;
p->nCands1 -= Vec_PtrSize(p->vClassNew);
- pReprNew = Vec_PtrEntry( p->vClassNew, 0 );
+ pReprNew = (Aig_Obj_t *)Vec_PtrEntry( p->vClassNew, 0 );
Aig_ObjSetRepr( p->pAig, pReprNew, NULL );
if ( Vec_PtrSize(p->vClassNew) == 1 )
return 1;
// create a new class composed of these nodes
ppClassNew = p->pMemClassesFree;
p->pMemClassesFree += Vec_PtrSize(p->vClassNew);
- Vec_PtrForEachEntry( p->vClassNew, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vClassNew, pObj, i )
{
ppClassNew[i] = pObj;
Aig_ObjSetRepr( p->pAig, pObj, i? pReprNew : NULL );
@@ -1029,14 +1111,14 @@ int Ssw_ClassesRefineConst1( Ssw_Cla_t * p, int fRecursive )
if ( Vec_PtrSize(p->vClassNew) == 0 )
return 0;
p->nCands1 -= Vec_PtrSize(p->vClassNew);
- pReprNew = Vec_PtrEntry( p->vClassNew, 0 );
+ pReprNew = (Aig_Obj_t *)Vec_PtrEntry( p->vClassNew, 0 );
Aig_ObjSetRepr( p->pAig, pReprNew, NULL );
if ( Vec_PtrSize(p->vClassNew) == 1 )
return 1;
// create a new class composed of these nodes
ppClassNew = p->pMemClassesFree;
p->pMemClassesFree += Vec_PtrSize(p->vClassNew);
- Vec_PtrForEachEntry( p->vClassNew, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vClassNew, pObj, i )
{
ppClassNew[i] = pObj;
Aig_ObjSetRepr( p->pAig, pObj, i? pReprNew : NULL );
@@ -1054,3 +1136,5 @@ int Ssw_ClassesRefineConst1( Ssw_Cla_t * p, int fRecursive )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ssw/sswCnf.c b/src/aig/ssw/sswCnf.c
index 73fa0b02..1970c62f 100644
--- a/src/aig/ssw/sswCnf.c
+++ b/src/aig/ssw/sswCnf.c
@@ -20,6 +20,9 @@
#include "sswInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -228,7 +231,7 @@ void Ssw_AddClausesSuper( Ssw_Sat_t * p, Aig_Obj_t * pNode, Vec_Ptr_t * vSuper )
pLits = ABC_ALLOC( int, nLits );
// suppose AND-gate is A & B = C
// add !A => !C or A + !C
- Vec_PtrForEachEntry( vSuper, pFanin, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vSuper, pFanin, i )
{
pLits[0] = toLitCond(Ssw_ObjSatNum(p,Aig_Regular(pFanin)), Aig_IsComplement(pFanin));
pLits[1] = toLitCond(Ssw_ObjSatNum(p,pNode), 1);
@@ -241,7 +244,7 @@ void Ssw_AddClausesSuper( Ssw_Sat_t * p, Aig_Obj_t * pNode, Vec_Ptr_t * vSuper )
assert( RetValue );
}
// add A & B => C or !A + !B + C
- Vec_PtrForEachEntry( vSuper, pFanin, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vSuper, pFanin, i )
{
pLits[i] = toLitCond(Ssw_ObjSatNum(p,Aig_Regular(pFanin)), !Aig_IsComplement(pFanin));
if ( p->fPolarFlip )
@@ -357,7 +360,7 @@ void Ssw_CnfNodeAddToSolver( Ssw_Sat_t * p, Aig_Obj_t * pObj )
vFrontier = Vec_PtrAlloc( 100 );
Ssw_ObjAddToFrontier( p, pObj, vFrontier );
// explore nodes in the frontier
- Vec_PtrForEachEntry( vFrontier, pNode, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vFrontier, pNode, i )
{
// create the supergate
assert( Ssw_ObjSatNum(p,pNode) );
@@ -368,14 +371,14 @@ void Ssw_CnfNodeAddToSolver( Ssw_Sat_t * p, Aig_Obj_t * pObj )
Vec_PtrPushUnique( p->vFanins, Aig_ObjFanin0( Aig_ObjFanin1(pNode) ) );
Vec_PtrPushUnique( p->vFanins, Aig_ObjFanin1( Aig_ObjFanin0(pNode) ) );
Vec_PtrPushUnique( p->vFanins, Aig_ObjFanin1( Aig_ObjFanin1(pNode) ) );
- Vec_PtrForEachEntry( p->vFanins, pFanin, k )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vFanins, pFanin, k )
Ssw_ObjAddToFrontier( p, Aig_Regular(pFanin), vFrontier );
Ssw_AddClausesMux( p, pNode );
}
else
{
Ssw_CollectSuper( pNode, fUseMuxes, p->vFanins );
- Vec_PtrForEachEntry( p->vFanins, pFanin, k )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vFanins, pFanin, k )
Ssw_ObjAddToFrontier( p, Aig_Regular(pFanin), vFrontier );
Ssw_AddClausesSuper( p, pNode, p->vFanins );
}
@@ -421,3 +424,5 @@ int Ssw_CnfGetNodeValue( Ssw_Sat_t * p, Aig_Obj_t * pObj )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ssw/sswConstr.c b/src/aig/ssw/sswConstr.c
new file mode 100644
index 00000000..e233f133
--- /dev/null
+++ b/src/aig/ssw/sswConstr.c
@@ -0,0 +1,635 @@
+/**CFile****************************************************************
+
+ FileName [sswConstr.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Inductive prover with constraints.]
+
+ Synopsis [One round of SAT sweeping.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - September 1, 2008.]
+
+ Revision [$Id: sswConstr.c,v 1.00 2008/09/01 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "sswInt.h"
+#include "cnf.h"
+#include "bar.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Constructs initialized timeframes with constraints as POs.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Man_t * Ssw_FramesWithConstraints( Aig_Man_t * p, int nFrames )
+{
+ Aig_Man_t * pFrames;
+ Aig_Obj_t * pObj, * pObjLi, * pObjLo;
+ int i, f;
+ assert( Saig_ManConstrNum(p) > 0 );
+ assert( Aig_ManRegNum(p) > 0 );
+ assert( Aig_ManRegNum(p) < Aig_ManPiNum(p) );
+ // start the fraig package
+ pFrames = Aig_ManStart( Aig_ManObjNumMax(p) * nFrames );
+ // create latches for the first frame
+ Saig_ManForEachLo( p, pObj, i )
+ Aig_ObjSetCopy( pObj, Aig_ManConst0(pFrames) );
+ // add timeframes
+ for ( f = 0; f < nFrames; f++ )
+ {
+ // map constants and PIs
+ Aig_ObjSetCopy( Aig_ManConst1(p), Aig_ManConst1(pFrames) );
+ Saig_ManForEachPi( p, pObj, i )
+ Aig_ObjSetCopy( pObj, Aig_ObjCreatePi(pFrames) );
+ // add internal nodes of this frame
+ Aig_ManForEachNode( p, pObj, i )
+ Aig_ObjSetCopy( pObj, Aig_And( pFrames, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) ) );
+ // transfer to the primary output
+ Aig_ManForEachPo( p, pObj, i )
+ Aig_ObjSetCopy( pObj, Aig_ObjChild0Copy(pObj) );
+ // create constraint outputs
+ Saig_ManForEachPo( p, pObj, i )
+ {
+ if ( i < Saig_ManPoNum(p) - Saig_ManConstrNum(p) )
+ continue;
+ Aig_ObjCreatePo( pFrames, Aig_Not( Aig_ObjCopy(pObj) ) );
+ }
+ // transfer latch inputs to the latch outputs
+ Saig_ManForEachLiLo( p, pObjLi, pObjLo, i )
+ Aig_ObjSetCopy( pObjLo, Aig_ObjCopy(pObjLi) );
+ }
+ // remove dangling nodes
+ Aig_ManCleanup( pFrames );
+ return pFrames;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Finds one satisfiable assignment of the timeframes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Ssw_ManSetConstrPhases( Aig_Man_t * p, int nFrames, Vec_Int_t ** pvInits )
+{
+ Aig_Man_t * pFrames;
+ sat_solver * pSat;
+ Cnf_Dat_t * pCnf;
+ Aig_Obj_t * pObj;
+ int i, RetValue;
+ if ( pvInits )
+ *pvInits = NULL;
+ assert( p->nConstrs > 0 );
+ // derive the timeframes
+ pFrames = Ssw_FramesWithConstraints( p, nFrames );
+ // create CNF
+ pCnf = Cnf_Derive( pFrames, 0 );
+ // create SAT solver
+ pSat = (sat_solver *)Cnf_DataWriteIntoSolver( pCnf, 1, 0 );
+ if ( pSat == NULL )
+ {
+ Cnf_DataFree( pCnf );
+ Aig_ManStop( pFrames );
+ return 1;
+ }
+ // solve
+ RetValue = sat_solver_solve( pSat, NULL, NULL,
+ (ABC_INT64_T)1000000, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
+ if ( RetValue == l_True && pvInits )
+ {
+ *pvInits = Vec_IntAlloc( 1000 );
+ Aig_ManForEachPi( pFrames, pObj, i )
+ Vec_IntPush( *pvInits, sat_solver_var_value(pSat, pCnf->pVarNums[Aig_ObjId(pObj)]) );
+
+// Aig_ManForEachPi( pFrames, pObj, i )
+// printf( "%d", Vec_IntEntry(*pvInits, i) );
+// printf( "\n" );
+ }
+ sat_solver_delete( pSat );
+ Cnf_DataFree( pCnf );
+ Aig_ManStop( pFrames );
+ if ( RetValue == l_False )
+ return 1;
+ if ( RetValue == l_True )
+ return 0;
+ return -1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs fraiging for one node.]
+
+ Description [Returns the fraiged node.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Ssw_ManSetConstrPhases_( Aig_Man_t * p, int nFrames, Vec_Int_t ** pvInits )
+{
+ Vec_Int_t * vLits;
+ sat_solver * pSat;
+ Cnf_Dat_t * pCnf;
+ Aig_Obj_t * pObj;
+ int i, f, iVar, RetValue, nRegs;
+ if ( pvInits )
+ *pvInits = NULL;
+ assert( p->nConstrs > 0 );
+ // create CNF
+ nRegs = p->nRegs; p->nRegs = 0;
+ pCnf = Cnf_Derive( p, Aig_ManPoNum(p) );
+ p->nRegs = nRegs;
+ // create SAT solver
+ pSat = (sat_solver *)Cnf_DataWriteIntoSolver( pCnf, nFrames, 0 );
+ assert( pSat->size == nFrames * pCnf->nVars );
+ // collect constraint literals
+ vLits = Vec_IntAlloc( 100 );
+ Saig_ManForEachLo( p, pObj, i )
+ {
+ assert( pCnf->pVarNums[Aig_ObjId(pObj)] >= 0 );
+ Vec_IntPush( vLits, toLitCond(pCnf->pVarNums[Aig_ObjId(pObj)], 1) );
+ }
+ for ( f = 0; f < nFrames; f++ )
+ {
+ Saig_ManForEachPo( p, pObj, i )
+ {
+ if ( i < Saig_ManPoNum(p) - Saig_ManConstrNum(p) )
+ continue;
+ assert( pCnf->pVarNums[Aig_ObjId(pObj)] >= 0 );
+ iVar = pCnf->pVarNums[Aig_ObjId(pObj)] + pCnf->nVars*f;
+ Vec_IntPush( vLits, toLitCond(iVar, 1) );
+ }
+ }
+ RetValue = sat_solver_solve( pSat, (int *)Vec_IntArray(vLits),
+ (int *)Vec_IntArray(vLits) + Vec_IntSize(vLits),
+ (ABC_INT64_T)1000000, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
+ if ( RetValue == l_True && pvInits )
+ {
+ *pvInits = Vec_IntAlloc( 1000 );
+ for ( f = 0; f < nFrames; f++ )
+ {
+ Saig_ManForEachPi( p, pObj, i )
+ {
+ iVar = pCnf->pVarNums[Aig_ObjId(pObj)] + pCnf->nVars*f;
+ Vec_IntPush( *pvInits, sat_solver_var_value(pSat, iVar) );
+ }
+ }
+ }
+ sat_solver_delete( pSat );
+ Vec_IntFree( vLits );
+ Cnf_DataFree( pCnf );
+ if ( RetValue == l_False )
+ return 1;
+ if ( RetValue == l_True )
+ return 0;
+ return -1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs fraiging for one node.]
+
+ Description [Returns the fraiged node.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Ssw_ManPrintPolarity( Aig_Man_t * p )
+{
+ Aig_Obj_t * pObj;
+ int i;
+ Aig_ManForEachObj( p, pObj, i )
+ printf( "%d", pObj->fPhase );
+ printf( "\n" );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs fraiging for one node.]
+
+ Description [Returns the fraiged node.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Ssw_ManRefineByConstrSim( Ssw_Man_t * p )
+{
+ Aig_Obj_t * pObj, * pObjLi;
+ int f, i, iLits, RetValue1, RetValue2;
+ int nFrames = Vec_IntSize(p->vInits) / Saig_ManPiNum(p->pAig);
+ assert( Vec_IntSize(p->vInits) % Saig_ManPiNum(p->pAig) == 0 );
+ // assign register outputs
+ Saig_ManForEachLi( p->pAig, pObj, i )
+ pObj->fMarkB = 0;
+ // simulate the timeframes
+ iLits = 0;
+ for ( f = 0; f < nFrames; f++ )
+ {
+ // set the PI simulation information
+ Aig_ManConst1(p->pAig)->fMarkB = 1;
+ Saig_ManForEachPi( p->pAig, pObj, i )
+ pObj->fMarkB = Vec_IntEntry( p->vInits, iLits++ );
+ Saig_ManForEachLiLo( p->pAig, pObjLi, pObj, i )
+ pObj->fMarkB = pObjLi->fMarkB;
+ // simulate internal nodes
+ Aig_ManForEachNode( p->pAig, pObj, i )
+ pObj->fMarkB = ( Aig_ObjFanin0(pObj)->fMarkB ^ Aig_ObjFaninC0(pObj) )
+ & ( Aig_ObjFanin1(pObj)->fMarkB ^ Aig_ObjFaninC1(pObj) );
+ // assign the COs
+ Aig_ManForEachPo( p->pAig, pObj, i )
+ pObj->fMarkB = ( Aig_ObjFanin0(pObj)->fMarkB ^ Aig_ObjFaninC0(pObj) );
+ // check the outputs
+ Saig_ManForEachPo( p->pAig, pObj, i )
+ {
+ if ( i < Saig_ManPoNum(p->pAig) - Saig_ManConstrNum(p->pAig) )
+ {
+ if ( pObj->fMarkB )
+ printf( "output %d failed in frame %d.\n", i, f );
+ }
+ else
+ {
+ if ( pObj->fMarkB )
+ printf( "constraint %d failed in frame %d.\n", i, f );
+ }
+ }
+ // transfer
+ if ( f == 0 )
+ { // copy markB into phase
+ Aig_ManForEachObj( p->pAig, pObj, i )
+ pObj->fPhase = pObj->fMarkB;
+ }
+ else
+ { // refine classes
+ RetValue1 = Ssw_ClassesRefineConst1( p->ppClasses, 0 );
+ RetValue2 = Ssw_ClassesRefine( p->ppClasses, 0 );
+ }
+ }
+ assert( iLits == Vec_IntSize(p->vInits) );
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Performs fraiging for one node.]
+
+ Description [Returns the fraiged node.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Ssw_ManSweepNodeConstr( Ssw_Man_t * p, Aig_Obj_t * pObj, int f, int fBmc )
+{
+ Aig_Obj_t * pObjRepr, * pObjFraig, * pObjFraig2, * pObjReprFraig;
+ int RetValue;
+ // get representative of this class
+ pObjRepr = Aig_ObjRepr( p->pAig, pObj );
+ if ( pObjRepr == NULL )
+ return 0;
+ // get the fraiged node
+ pObjFraig = Ssw_ObjFrame( p, pObj, f );
+ // get the fraiged representative
+ pObjReprFraig = Ssw_ObjFrame( p, pObjRepr, f );
+ // check if constant 0 pattern distinquishes these nodes
+ assert( pObjFraig != NULL && pObjReprFraig != NULL );
+ assert( (pObj->fPhase == pObjRepr->fPhase) == (Aig_ObjPhaseReal(pObjFraig) == Aig_ObjPhaseReal(pObjReprFraig)) );
+ // if the fraiged nodes are the same, return
+ if ( Aig_Regular(pObjFraig) == Aig_Regular(pObjReprFraig) )
+ return 0;
+ // call equivalence checking
+ if ( Aig_Regular(pObjFraig) != Aig_ManConst1(p->pFrames) )
+ RetValue = Ssw_NodesAreEquiv( p, Aig_Regular(pObjReprFraig), Aig_Regular(pObjFraig) );
+ else
+ RetValue = Ssw_NodesAreEquiv( p, Aig_Regular(pObjFraig), Aig_Regular(pObjReprFraig) );
+ if ( RetValue == 1 ) // proved equivalent
+ {
+ pObjFraig2 = Aig_NotCond( pObjReprFraig, pObj->fPhase ^ pObjRepr->fPhase );
+ Ssw_ObjSetFrame( p, pObj, f, pObjFraig2 );
+ return 0;
+ }
+ if ( RetValue == -1 ) // timed out
+ {
+ Ssw_ClassesRemoveNode( p->ppClasses, pObj );
+ return 1;
+ }
+ // disproved equivalence
+ Ssw_SmlSavePatternAig( p, f );
+ Ssw_ManResimulateBit( p, pObj, pObjRepr );
+ assert( Aig_ObjRepr( p->pAig, pObj ) != pObjRepr );
+ if ( Aig_ObjRepr( p->pAig, pObj ) == pObjRepr )
+ {
+ printf( "Ssw_ManSweepNodeConstr(): Failed to refine representative.\n" );
+ }
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs fraiging for the internal nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Obj_t * Ssw_ManSweepBmcConstr_rec( Ssw_Man_t * p, Aig_Obj_t * pObj, int f )
+{
+ Aig_Obj_t * pObjNew, * pObjLi;
+ pObjNew = Ssw_ObjFrame( p, pObj, f );
+ if ( pObjNew )
+ return pObjNew;
+ assert( !Saig_ObjIsPi(p->pAig, pObj) );
+ if ( Saig_ObjIsLo(p->pAig, pObj) )
+ {
+ assert( f > 0 );
+ pObjLi = Saig_ObjLoToLi( p->pAig, pObj );
+ pObjNew = Ssw_ManSweepBmcConstr_rec( p, Aig_ObjFanin0(pObjLi), f-1 );
+ pObjNew = Aig_NotCond( pObjNew, Aig_ObjFaninC0(pObjLi) );
+ }
+ else
+ {
+ assert( Aig_ObjIsNode(pObj) );
+ Ssw_ManSweepBmcConstr_rec( p, Aig_ObjFanin0(pObj), f );
+ Ssw_ManSweepBmcConstr_rec( p, Aig_ObjFanin1(pObj), f );
+ pObjNew = Aig_And( p->pFrames, Ssw_ObjChild0Fra(p, pObj, f), Ssw_ObjChild1Fra(p, pObj, f) );
+ }
+ Ssw_ObjSetFrame( p, pObj, f, pObjNew );
+ assert( pObjNew != NULL );
+ return pObjNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs fraiging for the internal nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Ssw_ManSweepBmcConstr( Ssw_Man_t * p )
+{
+ Bar_Progress_t * pProgress = NULL;
+ Aig_Obj_t * pObj, * pObjNew, * pObjLi, * pObjLo;
+ int i, f, iLits, clk;
+clk = clock();
+
+ // start initialized timeframes
+ p->pFrames = Aig_ManStart( Aig_ManObjNumMax(p->pAig) * p->pPars->nFramesK );
+ Saig_ManForEachLo( p->pAig, pObj, i )
+ Ssw_ObjSetFrame( p, pObj, 0, Aig_ManConst0(p->pFrames) );
+
+ // build the constraint outputs
+ iLits = 0;
+ for ( f = 0; f < p->pPars->nFramesK; f++ )
+ {
+ // map constants and PIs
+ Ssw_ObjSetFrame( p, Aig_ManConst1(p->pAig), f, Aig_ManConst1(p->pFrames) );
+ Saig_ManForEachPi( p->pAig, pObj, i )
+ {
+ pObjNew = Aig_ObjCreatePi(p->pFrames);
+ pObjNew->fPhase = Vec_IntEntry( p->vInits, iLits++ );
+ Ssw_ObjSetFrame( p, pObj, f, pObjNew );
+ }
+ // build the constraint cones
+ Saig_ManForEachPo( p->pAig, pObj, i )
+ {
+ if ( i < Saig_ManPoNum(p->pAig) - Saig_ManConstrNum(p->pAig) )
+ continue;
+ pObjNew = Ssw_ManSweepBmcConstr_rec( p, Aig_ObjFanin0(pObj), f );
+ pObjNew = Aig_NotCond( pObjNew, Aig_ObjFaninC0(pObj) );
+ if ( Aig_Regular(pObjNew) == Aig_ManConst1(p->pFrames) )
+ {
+ assert( Aig_IsComplement(pObjNew) );
+ continue;
+ }
+ Ssw_NodesAreConstrained( p, pObjNew, Aig_ManConst0(p->pFrames) );
+ }
+ }
+ assert( Vec_IntSize(p->vInits) == iLits + Saig_ManPiNum(p->pAig) );
+
+ // sweep internal nodes
+ p->fRefined = 0;
+ if ( p->pPars->fVerbose )
+ pProgress = Bar_ProgressStart( stdout, Aig_ManObjNumMax(p->pAig) * p->pPars->nFramesK );
+ for ( f = 0; f < p->pPars->nFramesK; f++ )
+ {
+ // sweep internal nodes
+ Aig_ManForEachNode( p->pAig, pObj, i )
+ {
+ if ( p->pPars->fVerbose )
+ Bar_ProgressUpdate( pProgress, Aig_ManObjNumMax(p->pAig) * f + i, NULL );
+ pObjNew = Aig_And( p->pFrames, Ssw_ObjChild0Fra(p, pObj, f), Ssw_ObjChild1Fra(p, pObj, f) );
+ Ssw_ObjSetFrame( p, pObj, f, pObjNew );
+ p->fRefined |= Ssw_ManSweepNodeConstr( p, pObj, f, 1 );
+ }
+ // quit if this is the last timeframe
+ if ( f == p->pPars->nFramesK - 1 )
+ break;
+ // transfer latch input to the latch outputs
+ Aig_ManForEachPo( p->pAig, pObj, i )
+ Ssw_ObjSetFrame( p, pObj, f, Ssw_ObjChild0Fra(p, pObj, f) );
+ // build logic cones for register outputs
+ Saig_ManForEachLiLo( p->pAig, pObjLi, pObjLo, i )
+ {
+ pObjNew = Ssw_ObjFrame( p, pObjLi, f );
+ Ssw_ObjSetFrame( p, pObjLo, f+1, pObjNew );
+ Ssw_CnfNodeAddToSolver( p->pMSat, Aig_Regular(pObjNew) );//
+ }
+ }
+ if ( p->pPars->fVerbose )
+ Bar_ProgressStop( pProgress );
+
+ // cleanup
+// Ssw_ClassesCheck( p->ppClasses );
+p->timeBmc += clock() - clk;
+ return p->fRefined;
+}
+
+
+
+
+/**Function*************************************************************
+
+ Synopsis [Performs fraiging for the internal nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Obj_t * Ssw_FramesWithClasses_rec( Ssw_Man_t * p, Aig_Obj_t * pObj, int f )
+{
+ Aig_Obj_t * pObjNew, * pObjLi;
+ pObjNew = Ssw_ObjFrame( p, pObj, f );
+ if ( pObjNew )
+ return pObjNew;
+ assert( !Saig_ObjIsPi(p->pAig, pObj) );
+ if ( Saig_ObjIsLo(p->pAig, pObj) )
+ {
+ assert( f > 0 );
+ pObjLi = Saig_ObjLoToLi( p->pAig, pObj );
+ pObjNew = Ssw_FramesWithClasses_rec( p, Aig_ObjFanin0(pObjLi), f-1 );
+ pObjNew = Aig_NotCond( pObjNew, Aig_ObjFaninC0(pObjLi) );
+ }
+ else
+ {
+ assert( Aig_ObjIsNode(pObj) );
+ Ssw_FramesWithClasses_rec( p, Aig_ObjFanin0(pObj), f );
+ Ssw_FramesWithClasses_rec( p, Aig_ObjFanin1(pObj), f );
+ pObjNew = Aig_And( p->pFrames, Ssw_ObjChild0Fra(p, pObj, f), Ssw_ObjChild1Fra(p, pObj, f) );
+ }
+ Ssw_ObjSetFrame( p, pObj, f, pObjNew );
+ assert( pObjNew != NULL );
+ return pObjNew;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Performs fraiging for the internal nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Ssw_ManSweepConstr( Ssw_Man_t * p )
+{
+ Bar_Progress_t * pProgress = NULL;
+ Aig_Obj_t * pObj, * pObj2, * pObjNew;
+ int nConstrPairs, clk, i, f, iLits;
+//Ssw_ManPrintPolarity( p->pAig );
+
+ // perform speculative reduction
+clk = clock();
+ // create timeframes
+ p->pFrames = Ssw_FramesWithClasses( p );
+ // add constants
+ nConstrPairs = Aig_ManPoNum(p->pFrames)-Aig_ManRegNum(p->pAig);
+ assert( (nConstrPairs & 1) == 0 );
+ for ( i = 0; i < nConstrPairs; i += 2 )
+ {
+ pObj = Aig_ManPo( p->pFrames, i );
+ pObj2 = Aig_ManPo( p->pFrames, i+1 );
+ Ssw_NodesAreConstrained( p, Aig_ObjChild0(pObj), Aig_ObjChild0(pObj2) );
+ }
+ // build logic cones for register inputs
+ for ( i = 0; i < Aig_ManRegNum(p->pAig); i++ )
+ {
+ pObj = Aig_ManPo( p->pFrames, nConstrPairs + i );
+ Ssw_CnfNodeAddToSolver( p->pMSat, Aig_ObjFanin0(pObj) );//
+ }
+
+ // map constants and PIs of the last frame
+ f = p->pPars->nFramesK;
+// iLits = 0;
+ iLits = f * Saig_ManPiNum(p->pAig);
+ Ssw_ObjSetFrame( p, Aig_ManConst1(p->pAig), f, Aig_ManConst1(p->pFrames) );
+ Saig_ManForEachPi( p->pAig, pObj, i )
+ {
+ pObjNew = Aig_ObjCreatePi(p->pFrames);
+ pObjNew->fPhase = (p->vInits != NULL) && Vec_IntEntry(p->vInits, iLits++);
+ Ssw_ObjSetFrame( p, pObj, f, pObjNew );
+ }
+ assert( Vec_IntSize(p->vInits) == iLits );
+p->timeReduce += clock() - clk;
+
+ // add constraints to all timeframes
+ for ( f = 0; f <= p->pPars->nFramesK; f++ )
+ {
+ Saig_ManForEachPo( p->pAig, pObj, i )
+ {
+ if ( i < Saig_ManPoNum(p->pAig) - Saig_ManConstrNum(p->pAig) )
+ continue;
+ Ssw_FramesWithClasses_rec( p, Aig_ObjFanin0(pObj), f );
+// if ( Aig_Regular(Ssw_ObjChild0Fra(p,pObj,f)) == Aig_ManConst1(p->pFrames) )
+ if ( Ssw_ObjChild0Fra(p,pObj,f) == Aig_ManConst0(p->pFrames) )
+ continue;
+ assert( Ssw_ObjChild0Fra(p,pObj,f) != Aig_ManConst1(p->pFrames) );
+ if ( Ssw_ObjChild0Fra(p,pObj,f) == Aig_ManConst1(p->pFrames) )
+ {
+ printf( "Polarity violation.\n" );
+ continue;
+ }
+ Ssw_NodesAreConstrained( p, Ssw_ObjChild0Fra(p,pObj,f), Aig_ManConst0(p->pFrames) );
+ }
+ }
+ f = p->pPars->nFramesK;
+ // clean the solver
+ sat_solver_simplify( p->pMSat->pSat );
+
+
+ // sweep internal nodes
+ p->fRefined = 0;
+ Ssw_ClassesClearRefined( p->ppClasses );
+ if ( p->pPars->fVerbose )
+ pProgress = Bar_ProgressStart( stdout, Aig_ManObjNumMax(p->pAig) );
+ Aig_ManForEachObj( p->pAig, pObj, i )
+ {
+ if ( p->pPars->fVerbose )
+ Bar_ProgressUpdate( pProgress, i, NULL );
+ if ( Saig_ObjIsLo(p->pAig, pObj) )
+ p->fRefined |= Ssw_ManSweepNodeConstr( p, pObj, f, 0 );
+ else if ( Aig_ObjIsNode(pObj) )
+ {
+ pObjNew = Aig_And( p->pFrames, Ssw_ObjChild0Fra(p, pObj, f), Ssw_ObjChild1Fra(p, pObj, f) );
+ Ssw_ObjSetFrame( p, pObj, f, pObjNew );
+ p->fRefined |= Ssw_ManSweepNodeConstr( p, pObj, f, 0 );
+ }
+ }
+ if ( p->pPars->fVerbose )
+ Bar_ProgressStop( pProgress );
+ // cleanup
+// Ssw_ClassesCheck( p->ppClasses );
+ return p->fRefined;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ssw/sswCore.c b/src/aig/ssw/sswCore.c
index 6cb84800..c277d76e 100644
--- a/src/aig/ssw/sswCore.c
+++ b/src/aig/ssw/sswCore.c
@@ -20,6 +20,9 @@
#include "sswInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -46,16 +49,18 @@ void Ssw_ManSetDefaultParams( Ssw_Pars_t * p )
p->nOverSize = 0; // size of the overlap between partitions
p->nFramesK = 1; // the induction depth
p->nFramesAddSim = 2; // additional frames to simulate
- p->nConstrs = 0; // treat the last nConstrs POs as seq constraints
+ p->fConstrs = 0; // treat the last nConstrs POs as seq constraints
+ p->fMergeFull = 0; // enables full merge when constraints are used
p->nBTLimit = 1000; // conflict limit at a node
p->nBTLimitGlobal = 5000000; // conflict limit for all runs
p->nMinDomSize = 100; // min clock domain considered for optimization
p->nItersStop = -1; // stop after the given number of iterations
p->nResimDelta = 1000; // the internal of nodes to resimulate
+ p->nStepsMax = -1; // (scorr only) the max number of induction steps
p->fPolarFlip = 0; // uses polarity adjustment
p->fLatchCorr = 0; // performs register correspondence
+ p->fOutputCorr = 0; // perform 'PO correspondence'
p->fSemiFormal = 0; // enable semiformal filtering
- p->fUniqueness = 0; // enable uniqueness constraints
p->fDynamic = 0; // dynamic partitioning
p->fLocalSim = 0; // local simulation
p->fVerbose = 0; // verbose stats
@@ -90,6 +95,130 @@ void Ssw_ManSetDefaultParamsLcorr( Ssw_Pars_t * p )
/**Function*************************************************************
+ Synopsis [Reports improvements for property cones.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Ssw_ReportConeReductions( Ssw_Man_t * p, Aig_Man_t * pAigInit, Aig_Man_t * pAigStop )
+{
+ Aig_Man_t * pAig1, * pAig2, * pAux;
+ pAig1 = Aig_ManDupOneOutput( pAigInit, 0, 1 );
+ pAig1 = Aig_ManScl( pAux = pAig1, 1, 1, 0 );
+ Aig_ManStop( pAux );
+ pAig2 = Aig_ManDupOneOutput( pAigStop, 0, 1 );
+ pAig2 = Aig_ManScl( pAux = pAig2, 1, 1, 0 );
+ Aig_ManStop( pAux );
+
+ p->nNodesBegC = Aig_ManNodeNum(pAig1);
+ p->nNodesEndC = Aig_ManNodeNum(pAig2);
+ p->nRegsBegC = Aig_ManRegNum(pAig1);
+ p->nRegsEndC = Aig_ManRegNum(pAig2);
+
+ Aig_ManStop( pAig1 );
+ Aig_ManStop( pAig2 );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Reports one node.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Ssw_ReportOneOutput( Aig_Man_t * p, Aig_Obj_t * pObj )
+{
+ if ( pObj == Aig_ManConst1(p) )
+ printf( "1" );
+ else if ( pObj == Aig_ManConst0(p) )
+ printf( "0" );
+ else
+ printf( "X" );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Reports improvements for property cones.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Ssw_ReportOutputs( Aig_Man_t * pAig )
+{
+ Aig_Obj_t * pObj;
+ int i;
+ Saig_ManForEachPo( pAig, pObj, i )
+ {
+ if ( i < Saig_ManPoNum(pAig)-Saig_ManConstrNum(pAig) )
+ printf( "o" );
+ else
+ printf( "c" );
+ Ssw_ReportOneOutput( pAig, Aig_ObjChild0(pObj) );
+ }
+ printf( "\n" );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Remove from-equivs that are in the cone of constraints.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Ssw_ManUpdateEquivs( Ssw_Man_t * p, Aig_Man_t * pAig, int fVerbose )
+{
+ Vec_Ptr_t * vCones;
+ Aig_Obj_t ** pArray;
+ Aig_Obj_t * pObj;
+ int i, nTotal = 0, nRemoved = 0;
+ // collect the nodes in the cone of constraints
+ pArray = (Aig_Obj_t **)Vec_PtrArray(pAig->vPos);
+ pArray += Saig_ManPoNum(pAig) - Saig_ManConstrNum(pAig);
+ vCones = Aig_ManDfsNodes( pAig, pArray, Saig_ManConstrNum(pAig) );
+ // remove all the node that are equiv to something and are in the cones
+ Aig_ManForEachObj( pAig, pObj, i )
+ {
+ if ( !Aig_ObjIsPi(pObj) && !Aig_ObjIsNode(pObj) )
+ continue;
+ if ( pAig->pReprs[i] != NULL )
+ nTotal++;
+ if ( !Aig_ObjIsTravIdCurrent(pAig, pObj) )
+ continue;
+ if ( pAig->pReprs[i] )
+ {
+ if ( p->pPars->fConstrs && !p->pPars->fMergeFull )
+ {
+ pAig->pReprs[i] = NULL;
+ nRemoved++;
+ }
+ }
+ }
+ // collect statistics
+ p->nConesTotal = Aig_ManPiNum(pAig) + Aig_ManNodeNum(pAig);
+ p->nConesConstr = Vec_PtrSize(vCones);
+ p->nEquivsTotal = nTotal;
+ p->nEquivsConstr = nRemoved;
+ Vec_PtrFree( vCones );
+}
+
+/**Function*************************************************************
+
Synopsis [Performs computation of signal correspondence with constraints.]
Description []
@@ -118,9 +247,10 @@ Aig_Man_t * Ssw_SignalCorrespondenceRefine( Ssw_Man_t * p )
if ( !p->pPars->fLatchCorr )
{
p->pMSat = Ssw_SatStart( 0 );
- Ssw_ManSweepBmc( p );
- if ( p->pPars->nFramesK > 1 && p->pPars->fUniqueness )
- Ssw_UniqueRegisterPairInfo( p );
+ if ( p->pPars->fConstrs )
+ Ssw_ManSweepBmcConstr( p );
+ else
+ Ssw_ManSweepBmc( p );
Ssw_SatStop( p->pMSat );
p->pMSat = NULL;
Ssw_ManCleanup( p );
@@ -142,10 +272,25 @@ Aig_Man_t * Ssw_SignalCorrespondenceRefine( Ssw_Man_t * p )
Aig_ManStop( pSRed );
}
*/
+ if ( p->pPars->pFunc )
+ {
+ ((int (*)(void *))p->pPars->pFunc)( p->pPars->pData );
+ ((int (*)(void *))p->pPars->pFunc)( p->pPars->pData );
+ }
+ if ( p->pPars->nStepsMax == 0 )
+ {
+ printf( "Stopped signal correspondence after BMC.\n" );
+ goto finalize;
+ }
// refine classes using induction
nSatProof = nSatCallsSat = nRecycles = nSatFailsReal = nUniques = 0;
for ( nIter = 0; ; nIter++ )
{
+ if ( p->pPars->nStepsMax == nIter )
+ {
+ printf( "Stopped signal correspondence after %d refiment iterations.\n", nIter );
+ goto finalize;
+ }
if ( p->pPars->nItersStop >= 0 && p->pPars->nItersStop == nIter )
{
Aig_Man_t * pSRed = Ssw_SpeculativeReduction( p );
@@ -174,19 +319,20 @@ clk = clock();
}
else
{
- if ( p->pPars->fDynamic )
+ if ( p->pPars->fConstrs )
+ RetValue = Ssw_ManSweepConstr( p );
+ else if ( p->pPars->fDynamic )
RetValue = Ssw_ManSweepDyn( p );
else
RetValue = Ssw_ManSweep( p );
+
p->pPars->nConflicts += p->pMSat->pSat->stats.conflicts;
if ( p->pPars->fVerbose )
{
printf( "%3d : C =%7d. Cl =%7d. LR =%6d. NR =%6d. ",
nIter, Ssw_ClassesCand1Num(p->ppClasses), Ssw_ClassesClassNum(p->ppClasses),
p->nConstrReduced, Aig_ManNodeNum(p->pFrames) );
- if ( p->pPars->fUniqueness )
- printf( "U =%4d. ", p->nUniques-nUniques );
- else if ( p->pPars->fDynamic )
+ if ( p->pPars->fDynamic )
{
printf( "Cex =%5d. ", p->nSatCallsSat-nSatCallsSat );
printf( "R =%4d. ", p->nRecycles-nRecycles );
@@ -211,9 +357,15 @@ clk = clock();
Ssw_ManCleanup( p );
if ( !RetValue )
break;
+ if ( p->pPars->pFunc )
+ ((int (*)(void *))p->pPars->pFunc)( p->pPars->pData );
}
+
+finalize:
p->pPars->nIters = nIter + 1;
p->timeTotal = clock() - clkTotal;
+
+ Ssw_ManUpdateEquivs( p, p->pAig, p->pPars->fVerbose );
pAigNew = Aig_ManDupRepr( p->pAig, 0 );
Aig_ManSeqCleanup( pAigNew );
//Ssw_ClassesPrint( p->ppClasses, 1 );
@@ -221,6 +373,9 @@ p->timeTotal = clock() - clkTotal;
p->nLitsEnd = Ssw_ClassesLitNum( p->ppClasses );
p->nNodesEnd = Aig_ManNodeNum(pAigNew);
p->nRegsEnd = Aig_ManRegNum(pAigNew);
+ // cleanup
+ Aig_ManSetPhase( p->pAig );
+ Aig_ManCleanMarkB( p->pAig );
return pAigNew;
}
@@ -255,13 +410,6 @@ Aig_Man_t * Ssw_SignalCorrespondence( Aig_Man_t * pAig, Ssw_Pars_t * pPars )
return Aig_ManDupOrdered(pAig);
}
// check and update parameters
- if ( pPars->fUniqueness )
- {
- pPars->nFramesAddSim = 0;
- if ( pPars->nFramesK != 2 )
- printf( "Setting K = 2 for uniqueness constraints to work.\n" );
- pPars->nFramesK = 2;
- }
if ( pPars->fLatchCorrOpt )
{
pPars->fLatchCorr = 1;
@@ -291,15 +439,31 @@ Aig_Man_t * Ssw_SignalCorrespondence( Aig_Man_t * pAig, Ssw_Pars_t * pPars )
return Cec_SignalCorrespondence( pAig, pPars->nBTLimit, pPars->fUseCSat );
}
}
-
+
// start the induction manager
p = Ssw_ManCreate( pAig, pPars );
// compute candidate equivalence classes
// p->pPars->nConstrs = 1;
- if ( p->pPars->nConstrs == 0 )
+ if ( p->pPars->fConstrs )
+ {
+ // create trivial equivalence classes with all nodes being candidates for constant 1
+ p->ppClasses = Ssw_ClassesPrepareSimple( pAig, pPars->fLatchCorr, pPars->nMaxLevs );
+ Ssw_ClassesSetData( p->ppClasses, NULL, NULL, Ssw_SmlObjIsConstBit, Ssw_SmlObjsAreEqualBit );
+ // derive phase bits to satisfy the constraints
+ if ( Ssw_ManSetConstrPhases( pAig, p->pPars->nFramesK + 1, &p->vInits ) != 0 )
+ {
+ printf( "Ssw_SignalCorrespondence(): The init state does not satisfy the constraints!\n" );
+ p->pPars->fVerbose = 0;
+ Ssw_ManStop( p );
+ return NULL;
+ }
+ // perform simulation of the first timeframes
+ Ssw_ManRefineByConstrSim( p );
+ }
+ else
{
// perform one round of seq simulation and generate candidate equivalence classes
- p->ppClasses = Ssw_ClassesPrepare( pAig, pPars->nFramesK, pPars->fLatchCorr, pPars->nMaxLevs, pPars->fVerbose );
+ p->ppClasses = Ssw_ClassesPrepare( pAig, pPars->nFramesK, pPars->fLatchCorr, pPars->fOutputCorr, pPars->nMaxLevs, pPars->fVerbose );
// p->ppClasses = Ssw_ClassesPrepareTargets( pAig );
if ( pPars->fLatchCorrOpt )
p->pSml = Ssw_SmlStart( pAig, 0, 2, 1 );
@@ -307,21 +471,16 @@ Aig_Man_t * Ssw_SignalCorrespondence( Aig_Man_t * pAig, Ssw_Pars_t * pPars )
p->pSml = Ssw_SmlStart( pAig, 0, p->nFrames + p->pPars->nFramesAddSim, 1 );
else
p->pSml = Ssw_SmlStart( pAig, 0, 1 + p->pPars->nFramesAddSim, 1 );
- Ssw_ClassesSetData( p->ppClasses, p->pSml, Ssw_SmlObjHashWord, Ssw_SmlObjIsConstWord, Ssw_SmlObjsAreEqualWord );
- }
- else
- {
- // create trivial equivalence classes with all nodes being candidates for constant 1
- p->ppClasses = Ssw_ClassesPrepareSimple( pAig, pPars->fLatchCorr, pPars->nMaxLevs );
- Ssw_ClassesSetData( p->ppClasses, NULL, NULL, Ssw_SmlObjIsConstBit, Ssw_SmlObjsAreEqualBit );
+ Ssw_ClassesSetData( p->ppClasses, p->pSml, (unsigned(*)(void *,Aig_Obj_t *))Ssw_SmlObjHashWord, (int(*)(void *,Aig_Obj_t *))Ssw_SmlObjIsConstWord, (int(*)(void *,Aig_Obj_t *,Aig_Obj_t *))Ssw_SmlObjsAreEqualWord );
}
+ // allocate storage
if ( p->pPars->fLocalSim )
p->pVisited = ABC_CALLOC( int, Ssw_SmlNumFrames( p->pSml ) * Aig_ManObjNumMax(p->pAig) );
// perform refinement of classes
pAigNew = Ssw_SignalCorrespondenceRefine( p );
- if ( pPars->fUniqueness )
- printf( "Uniqueness constraints = %3d. Prevented counter-examples = %3d.\n",
- p->nUniquesAdded, p->nUniquesUseful );
+// Ssw_ReportOutputs( pAigNew );
+ if ( pPars->fConstrs && pPars->fVerbose )
+ Ssw_ReportConeReductions( p, pAig, pAigNew );
// cleanup
Ssw_ManStop( p );
return pAigNew;
@@ -340,10 +499,14 @@ Aig_Man_t * Ssw_SignalCorrespondence( Aig_Man_t * pAig, Ssw_Pars_t * pPars )
***********************************************************************/
Aig_Man_t * Ssw_LatchCorrespondence( Aig_Man_t * pAig, Ssw_Pars_t * pPars )
{
+ Aig_Man_t * pRes;
Ssw_Pars_t Pars;
if ( pPars == NULL )
Ssw_ManSetDefaultParamsLcorr( pPars = &Pars );
- return Ssw_SignalCorrespondence( pAig, pPars );
+ pRes = Ssw_SignalCorrespondence( pAig, pPars );
+// if ( pPars->fConstrs && pPars->fVerbose )
+// Ssw_ReportConeReductions( pAig, pRes );
+ return pRes;
}
@@ -352,3 +515,5 @@ Aig_Man_t * Ssw_LatchCorrespondence( Aig_Man_t * pAig, Ssw_Pars_t * pPars )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ssw/sswDyn.c b/src/aig/ssw/sswDyn.c
index 04e66f09..7e8edc66 100644
--- a/src/aig/ssw/sswDyn.c
+++ b/src/aig/ssw/sswDyn.c
@@ -21,6 +21,9 @@
#include "sswInt.h"
#include "bar.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -153,7 +156,7 @@ void Ssw_ManLoadSolver( Ssw_Man_t * p, Aig_Obj_t * pRepr, Aig_Obj_t * pObj )
Ssw_ManCollectPis_rec( pRepr, p->vNewLos );
Ssw_ManCollectPis_rec( pObj, p->vNewLos );
// add logic cones for register outputs
- Vec_PtrForEachEntry( p->vNewLos, pTemp, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vNewLos, pTemp, i )
{
pObj0 = Aig_Regular( Ssw_ObjFrame( p, pTemp, p->pPars->nFramesK ) );
Ssw_CnfNodeAddToSolver( p->pMSat, pObj0 );
@@ -172,7 +175,7 @@ void Ssw_ManLoadSolver( Ssw_Man_t * p, Aig_Obj_t * pRepr, Aig_Obj_t * pObj )
// collect the related constraint POs
Vec_IntClear( p->vNewPos );
- Vec_PtrForEachEntry( p->vNewLos, pTemp, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vNewLos, pTemp, i )
Ssw_ManCollectPos_rec( p, pTemp, p->vNewPos );
// check if the corresponding pairs are added
Vec_IntForEachEntry( p->vNewPos, iConstr, i )
@@ -222,7 +225,7 @@ void Ssw_ManSweepTransferDyn( Ssw_Man_t * p )
}
assert( !Aig_IsComplement(pObjFraig) );
assert( Aig_ObjIsPi(pObjFraig) );
- pInfo = Vec_PtrEntry( p->vSimInfo, Aig_ObjPioNum(pObjFraig) );
+ pInfo = (unsigned *)Vec_PtrEntry( p->vSimInfo, Aig_ObjPioNum(pObjFraig) );
Ssw_SmlObjSetWord( p->pSml, pObj, pInfo[0], 0, 0 );
}
// set random simulation info for the second frame
@@ -233,7 +236,7 @@ void Ssw_ManSweepTransferDyn( Ssw_Man_t * p )
pObjFraig = Ssw_ObjFrame( p, pObj, f );
assert( !Aig_IsComplement(pObjFraig) );
assert( Aig_ObjIsPi(pObjFraig) );
- pInfo = Vec_PtrEntry( p->vSimInfo, Aig_ObjPioNum(pObjFraig) );
+ pInfo = (unsigned *)Vec_PtrEntry( p->vSimInfo, Aig_ObjPioNum(pObjFraig) );
Ssw_SmlObjSetWord( p->pSml, pObj, pInfo[0], 0, f );
}
}
@@ -327,10 +330,10 @@ int Ssw_ManSweepResimulateDynLocal( Ssw_Man_t * p, int f )
// Aig_ManIncrementTravId( p->pAig );
// Aig_ObjIsTravIdCurrent( p->pAig, Aig_ManConst1(p->pAig) );
p->nVisCounter++;
- Vec_PtrForEachEntry( p->vResimConsts, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vResimConsts, pObj, i )
Ssw_SmlSimulateOneDyn_rec( p->pSml, pObj, p->nFrames-1, p->pVisited, p->nVisCounter );
// resimulate the cone of influence of the cand classes
- Vec_PtrForEachEntry( p->vResimClasses, pRepr, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vResimClasses, pRepr, i )
{
ppClass = Ssw_ClassesReadClass( p->ppClasses, pRepr, &nSize );
for ( k = 0; k < nSize; k++ )
@@ -343,7 +346,7 @@ int Ssw_ManSweepResimulateDynLocal( Ssw_Man_t * p, int f )
// refine these nodes
RetValue1 = Ssw_ClassesRefineConst1Group( p->ppClasses, p->vResimConsts, 1 );
RetValue2 = 0;
- Vec_PtrForEachEntry( p->vResimClasses, pRepr, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vResimClasses, pRepr, i )
RetValue2 += Ssw_ClassesRefineOneClass( p->ppClasses, pRepr, 1 );
// prepare simulation info for the next round
@@ -482,3 +485,5 @@ p->timeReduce += clock() - clk;
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ssw/sswFilter.c b/src/aig/ssw/sswFilter.c
new file mode 100644
index 00000000..a0c0934a
--- /dev/null
+++ b/src/aig/ssw/sswFilter.c
@@ -0,0 +1,492 @@
+/**CFile****************************************************************
+
+ FileName [sswConstr.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Inductive prover with constraints.]
+
+ Synopsis [One round of SAT sweeping.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - September 1, 2008.]
+
+ Revision [$Id: sswConstr.c,v 1.00 2008/09/01 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "sswInt.h"
+#include "giaAig.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Performs fraiging for one node.]
+
+ Description [Returns the fraiged node.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Ssw_ManRefineByFilterSim( Ssw_Man_t * p, int nFrames )
+{
+ Aig_Obj_t * pObj, * pObjLi;
+ int f, i, RetValue1, RetValue2;
+ assert( nFrames > 0 );
+ // assign register outputs
+ Saig_ManForEachLi( p->pAig, pObj, i )
+ pObj->fMarkB = Aig_InfoHasBit( p->pPatWords, Saig_ManPiNum(p->pAig) + i );
+ // simulate the timeframes
+ for ( f = 0; f < nFrames; f++ )
+ {
+ // set the PI simulation information
+ Aig_ManConst1(p->pAig)->fMarkB = 1;
+ Saig_ManForEachPi( p->pAig, pObj, i )
+ pObj->fMarkB = 0;
+ Saig_ManForEachLiLo( p->pAig, pObjLi, pObj, i )
+ pObj->fMarkB = pObjLi->fMarkB;
+ // simulate internal nodes
+ Aig_ManForEachNode( p->pAig, pObj, i )
+ pObj->fMarkB = ( Aig_ObjFanin0(pObj)->fMarkB ^ Aig_ObjFaninC0(pObj) )
+ & ( Aig_ObjFanin1(pObj)->fMarkB ^ Aig_ObjFaninC1(pObj) );
+ // assign the COs
+ Aig_ManForEachPo( p->pAig, pObj, i )
+ pObj->fMarkB = ( Aig_ObjFanin0(pObj)->fMarkB ^ Aig_ObjFaninC0(pObj) );
+ // transfer
+ if ( f == 0 )
+ { // copy markB into phase
+ Aig_ManForEachObj( p->pAig, pObj, i )
+ pObj->fPhase = pObj->fMarkB;
+ }
+ else
+ { // refine classes
+ RetValue1 = Ssw_ClassesRefineConst1( p->ppClasses, 0 );
+ RetValue2 = Ssw_ClassesRefine( p->ppClasses, 0 );
+ }
+ }
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Performs fraiging for one node.]
+
+ Description [Returns the fraiged node.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Ssw_ManRollForward( Ssw_Man_t * p, int nFrames )
+{
+ Aig_Obj_t * pObj, * pObjLi;
+ int f, i;
+ assert( nFrames > 0 );
+ // assign register outputs
+ Saig_ManForEachLi( p->pAig, pObj, i )
+ pObj->fMarkB = Aig_InfoHasBit( p->pPatWords, Saig_ManPiNum(p->pAig) + i );
+ // simulate the timeframes
+ for ( f = 0; f < nFrames; f++ )
+ {
+ // set the PI simulation information
+ Aig_ManConst1(p->pAig)->fMarkB = 1;
+ Saig_ManForEachPi( p->pAig, pObj, i )
+ pObj->fMarkB = Aig_ManRandom(0) & 1;
+ Saig_ManForEachLiLo( p->pAig, pObjLi, pObj, i )
+ pObj->fMarkB = pObjLi->fMarkB;
+ // simulate internal nodes
+ Aig_ManForEachNode( p->pAig, pObj, i )
+ pObj->fMarkB = ( Aig_ObjFanin0(pObj)->fMarkB ^ Aig_ObjFaninC0(pObj) )
+ & ( Aig_ObjFanin1(pObj)->fMarkB ^ Aig_ObjFaninC1(pObj) );
+ // assign the COs
+ Aig_ManForEachPo( p->pAig, pObj, i )
+ pObj->fMarkB = ( Aig_ObjFanin0(pObj)->fMarkB ^ Aig_ObjFaninC0(pObj) );
+ }
+ // record the new pattern
+ Saig_ManForEachLi( p->pAig, pObj, i )
+ if ( pObj->fMarkB ^ Aig_InfoHasBit(p->pPatWords, Saig_ManPiNum(p->pAig) + i) )
+ Aig_InfoXorBit( p->pPatWords, Saig_ManPiNum(p->pAig) + i );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs fraiging for one node.]
+
+ Description [Returns the fraiged node.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Ssw_ManFindStartingState( Ssw_Man_t * p, Abc_Cex_t * pCex )
+{
+ Aig_Obj_t * pObj, * pObjLi;
+ int f, i, iBit;
+ // assign register outputs
+ Saig_ManForEachLi( p->pAig, pObj, i )
+ pObj->fMarkB = 0;
+ // simulate the timeframes
+ iBit = pCex->nRegs;
+ for ( f = 0; f <= pCex->iFrame; f++ )
+ {
+ // set the PI simulation information
+ Aig_ManConst1(p->pAig)->fMarkB = 1;
+ Saig_ManForEachPi( p->pAig, pObj, i )
+ pObj->fMarkB = Aig_InfoHasBit( pCex->pData, iBit++ );
+ Saig_ManForEachLiLo( p->pAig, pObjLi, pObj, i )
+ pObj->fMarkB = pObjLi->fMarkB;
+ // simulate internal nodes
+ Aig_ManForEachNode( p->pAig, pObj, i )
+ pObj->fMarkB = ( Aig_ObjFanin0(pObj)->fMarkB ^ Aig_ObjFaninC0(pObj) )
+ & ( Aig_ObjFanin1(pObj)->fMarkB ^ Aig_ObjFaninC1(pObj) );
+ // assign the COs
+ Aig_ManForEachPo( p->pAig, pObj, i )
+ pObj->fMarkB = ( Aig_ObjFanin0(pObj)->fMarkB ^ Aig_ObjFaninC0(pObj) );
+ }
+ assert( iBit == pCex->nBits );
+ // check that the output failed as expected -- cannot check because it is not an SRM!
+// pObj = Aig_ManPo( p->pAig, pCex->iPo );
+// if ( pObj->fMarkB != 1 )
+// printf( "The counter-example does not refine the output.\n" );
+ // record the new pattern
+ Saig_ManForEachLo( p->pAig, pObj, i )
+ if ( pObj->fMarkB ^ Aig_InfoHasBit(p->pPatWords, Saig_ManPiNum(p->pAig) + i) )
+ Aig_InfoXorBit( p->pPatWords, Saig_ManPiNum(p->pAig) + i );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs fraiging for one node.]
+
+ Description [Returns the fraiged node.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Ssw_ManSweepNodeFilter( Ssw_Man_t * p, Aig_Obj_t * pObj, int f )
+{
+ Aig_Obj_t * pObjRepr, * pObjFraig, * pObjFraig2, * pObjReprFraig;
+ int RetValue;
+ // get representative of this class
+ pObjRepr = Aig_ObjRepr( p->pAig, pObj );
+ if ( pObjRepr == NULL )
+ return 0;
+ // get the fraiged node
+ pObjFraig = Ssw_ObjFrame( p, pObj, f );
+ // get the fraiged representative
+ pObjReprFraig = Ssw_ObjFrame( p, pObjRepr, f );
+ // check if constant 0 pattern distinquishes these nodes
+ assert( pObjFraig != NULL && pObjReprFraig != NULL );
+ assert( (pObj->fPhase == pObjRepr->fPhase) == (Aig_ObjPhaseReal(pObjFraig) == Aig_ObjPhaseReal(pObjReprFraig)) );
+ // if the fraiged nodes are the same, return
+ if ( Aig_Regular(pObjFraig) == Aig_Regular(pObjReprFraig) )
+ return 0;
+ // call equivalence checking
+ if ( Aig_Regular(pObjFraig) != Aig_ManConst1(p->pFrames) )
+ RetValue = Ssw_NodesAreEquiv( p, Aig_Regular(pObjReprFraig), Aig_Regular(pObjFraig) );
+ else
+ RetValue = Ssw_NodesAreEquiv( p, Aig_Regular(pObjFraig), Aig_Regular(pObjReprFraig) );
+ if ( RetValue == 1 ) // proved equivalent
+ {
+ pObjFraig2 = Aig_NotCond( pObjReprFraig, pObj->fPhase ^ pObjRepr->fPhase );
+ Ssw_ObjSetFrame( p, pObj, f, pObjFraig2 );
+ return 0;
+ }
+ if ( RetValue == -1 ) // timed out
+ {
+// Ssw_ClassesRemoveNode( p->ppClasses, pObj );
+ return 1;
+ }
+ // disproved equivalence
+ Ssw_SmlSavePatternAig( p, f );
+ Ssw_ManResimulateBit( p, pObj, pObjRepr );
+ assert( Aig_ObjRepr( p->pAig, pObj ) != pObjRepr );
+ if ( Aig_ObjRepr( p->pAig, pObj ) == pObjRepr )
+ {
+ printf( "Ssw_ManSweepNodeFilter(): Failed to refine representative.\n" );
+ }
+ return 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs fraiging for the internal nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Obj_t * Ssw_ManSweepBmcFilter_rec( Ssw_Man_t * p, Aig_Obj_t * pObj, int f )
+{
+ Aig_Obj_t * pObjNew, * pObjLi;
+ pObjNew = Ssw_ObjFrame( p, pObj, f );
+ if ( pObjNew )
+ return pObjNew;
+ assert( !Saig_ObjIsPi(p->pAig, pObj) );
+ if ( Saig_ObjIsLo(p->pAig, pObj) )
+ {
+ assert( f > 0 );
+ pObjLi = Saig_ObjLoToLi( p->pAig, pObj );
+ pObjNew = Ssw_ManSweepBmcFilter_rec( p, Aig_ObjFanin0(pObjLi), f-1 );
+ pObjNew = Aig_NotCond( pObjNew, Aig_ObjFaninC0(pObjLi) );
+ }
+ else
+ {
+ assert( Aig_ObjIsNode(pObj) );
+ Ssw_ManSweepBmcFilter_rec( p, Aig_ObjFanin0(pObj), f );
+ Ssw_ManSweepBmcFilter_rec( p, Aig_ObjFanin1(pObj), f );
+ pObjNew = Aig_And( p->pFrames, Ssw_ObjChild0Fra(p, pObj, f), Ssw_ObjChild1Fra(p, pObj, f) );
+ }
+ Ssw_ObjSetFrame( p, pObj, f, pObjNew );
+ assert( pObjNew != NULL );
+ return pObjNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Filter equivalence classes of nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Ssw_ManSweepBmcFilter( Ssw_Man_t * p, int TimeLimit )
+{
+ Aig_Obj_t * pObj, * pObjNew, * pObjLi, * pObjLo;
+ int f, f1, i, clkTotal = clock();
+ // start initialized timeframes
+ p->pFrames = Aig_ManStart( Aig_ManObjNumMax(p->pAig) * p->pPars->nFramesK );
+ Saig_ManForEachLo( p->pAig, pObj, i )
+ {
+ if ( Aig_InfoHasBit( p->pPatWords, Saig_ManPiNum(p->pAig) + i ) )
+ {
+ Ssw_ObjSetFrame( p, pObj, 0, Aig_ManConst1(p->pFrames) );
+//printf( "1" );
+ }
+ else
+ {
+ Ssw_ObjSetFrame( p, pObj, 0, Aig_ManConst0(p->pFrames) );
+//printf( "0" );
+ }
+ }
+//printf( "\n" );
+
+ // sweep internal nodes
+ for ( f = 0; f < p->pPars->nFramesK; f++ )
+ {
+ // realloc mapping of timeframes
+ if ( f == p->nFrames-1 )
+ {
+ Aig_Obj_t ** pNodeToFrames;
+ pNodeToFrames = ABC_CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p->pAig) * 2 * p->nFrames );
+ for ( f1 = 0; f1 < p->nFrames; f1++ )
+ {
+ Aig_ManForEachObj( p->pAig, pObj, i )
+ pNodeToFrames[2*p->nFrames*pObj->Id + f1] = Ssw_ObjFrame( p, pObj, f1 );
+ }
+ ABC_FREE( p->pNodeToFrames );
+ p->pNodeToFrames = pNodeToFrames;
+ p->nFrames *= 2;
+ }
+ // map constants and PIs
+ Ssw_ObjSetFrame( p, Aig_ManConst1(p->pAig), f, Aig_ManConst1(p->pFrames) );
+ Saig_ManForEachPi( p->pAig, pObj, i )
+ {
+ pObjNew = Aig_ObjCreatePi(p->pFrames);
+ Ssw_ObjSetFrame( p, pObj, f, pObjNew );
+ }
+ // sweep internal nodes
+ Aig_ManForEachNode( p->pAig, pObj, i )
+ {
+ pObjNew = Aig_And( p->pFrames, Ssw_ObjChild0Fra(p, pObj, f), Ssw_ObjChild1Fra(p, pObj, f) );
+ Ssw_ObjSetFrame( p, pObj, f, pObjNew );
+ if ( Ssw_ManSweepNodeFilter( p, pObj, f ) )
+ break;
+ }
+ // printout
+ if ( p->pPars->fVerbose )
+ {
+ printf( "Frame %4d : ", f );
+ Ssw_ClassesPrint( p->ppClasses, 0 );
+ }
+ if ( i < Vec_PtrSize(p->pAig->vObjs) )
+ {
+ if ( p->pPars->fVerbose )
+ printf( "Exceeded the resource limits (%d conflicts). Quitting...\n", p->pPars->nBTLimit );
+ break;
+ }
+ // quit if this is the last timeframe
+ if ( f == p->pPars->nFramesK - 1 )
+ {
+ if ( p->pPars->fVerbose )
+ printf( "Exceeded the time frame limit (%d time frames). Quitting...\n", p->pPars->nFramesK );
+ break;
+ }
+ // check timeout
+ if ( TimeLimit && ((float)TimeLimit <= (float)(clock()-clkTotal)/(float)(CLOCKS_PER_SEC)) )
+ break;
+ // transfer latch input to the latch outputs
+ Aig_ManForEachPo( p->pAig, pObj, i )
+ Ssw_ObjSetFrame( p, pObj, f, Ssw_ObjChild0Fra(p, pObj, f) );
+ // build logic cones for register outputs
+ Saig_ManForEachLiLo( p->pAig, pObjLi, pObjLo, i )
+ {
+ pObjNew = Ssw_ObjFrame( p, pObjLi, f );
+ Ssw_ObjSetFrame( p, pObjLo, f+1, pObjNew );
+ Ssw_CnfNodeAddToSolver( p->pMSat, Aig_Regular(pObjNew) );//
+ }
+ }
+ // verify
+// Ssw_ClassesCheck( p->ppClasses );
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Filter equivalence classes of nodes.]
+
+ Description [Unrolls at most nFramesMax frames. Works with nConfMax
+ conflicts until the first undefined SAT call. Verbose prints the message.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Ssw_SignalFilter( Aig_Man_t * pAig, int nFramesMax, int nConfMax, int nRounds, int TimeLimit, int TimeLimit2, Abc_Cex_t * pCex, int fVerbose )
+{
+ Ssw_Pars_t Pars, * pPars = &Pars;
+ Ssw_Man_t * p;
+ int r, TimeLimitPart, clkTotal = clock();
+ assert( Aig_ManRegNum(pAig) > 0 );
+ assert( Aig_ManConstrNum(pAig) == 0 );
+ // consider the case of empty AIG
+ if ( Aig_ManNodeNum(pAig) == 0 )
+ return;
+ // reset random numbers
+ Aig_ManRandom( 1 );
+ // if parameters are not given, create them
+ Ssw_ManSetDefaultParams( pPars = &Pars );
+ pPars->nFramesK = 3; //nFramesMax;
+ pPars->nBTLimit = nConfMax;
+ pPars->TimeLimit = TimeLimit;
+ pPars->fVerbose = fVerbose;
+ // start the induction manager
+ p = Ssw_ManCreate( pAig, pPars );
+ pPars->nFramesK = nFramesMax;
+ // create trivial equivalence classes with all nodes being candidates for constant 1
+ if ( pAig->pReprs == NULL )
+ p->ppClasses = Ssw_ClassesPrepareSimple( pAig, 0, 0 );
+ else
+ p->ppClasses = Ssw_ClassesPrepareFromReprs( pAig );
+ Ssw_ClassesSetData( p->ppClasses, NULL, NULL, Ssw_SmlObjIsConstBit, Ssw_SmlObjsAreEqualBit );
+ assert( p->vInits == NULL );
+ // compute starting state if needed
+ if ( pCex )
+ Ssw_ManFindStartingState( p, pCex );
+ // refine classes using BMC
+ for ( r = 0; r < nRounds; r++ )
+ {
+ if ( p->pPars->fVerbose )
+ printf( "Round %3d:\n", r );
+ // start filtering equivalence classes
+ Ssw_ManRefineByFilterSim( p, p->pPars->nFramesK );
+ if ( Ssw_ClassesCand1Num(p->ppClasses) == 0 && Ssw_ClassesClassNum(p->ppClasses) == 0 )
+ {
+ printf( "All equivalences are refined away.\n" );
+ break;
+ }
+ // printout
+ if ( p->pPars->fVerbose )
+ {
+ printf( "Initial : " );
+ Ssw_ClassesPrint( p->ppClasses, 0 );
+ }
+ p->pMSat = Ssw_SatStart( 0 );
+ TimeLimitPart = TimeLimit ? TimeLimit - (int)((float)(clock()-clkTotal)/(float)(CLOCKS_PER_SEC)) : 0;
+ if ( TimeLimit2 )
+ {
+ if ( TimeLimitPart )
+ TimeLimitPart = ABC_MIN( TimeLimitPart, TimeLimit2 );
+ else
+ TimeLimitPart = TimeLimit2;
+ }
+ Ssw_ManSweepBmcFilter( p, TimeLimitPart );
+ Ssw_SatStop( p->pMSat );
+ p->pMSat = NULL;
+ Ssw_ManCleanup( p );
+ // simulate pattern forward
+ Ssw_ManRollForward( p, p->pPars->nFramesK );
+ // check timeout
+ if ( TimeLimit && ((float)TimeLimit <= (float)(clock()-clkTotal)/(float)(CLOCKS_PER_SEC)) )
+ {
+ printf( "Reached timeout (%d seconds).\n", TimeLimit );
+ break;
+ }
+ }
+ // cleanup
+ Aig_ManSetPhase( p->pAig );
+ Aig_ManCleanMarkB( p->pAig );
+ // cleanup
+ pPars->fVerbose = 0;
+ Ssw_ManStop( p );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Filter equivalence classes of nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Ssw_SignalFilterGia( Gia_Man_t * p, int nFramesMax, int nConfMax, int nRounds, int TimeLimit, int TimeLimit2, Abc_Cex_t * pCex, int fVerbose )
+{
+ Aig_Man_t * pAig;
+ pAig = Gia_ManToAigSimple( p );
+ if ( p->pReprs != NULL )
+ {
+ Gia_ManReprToAigRepr2( pAig, p );
+ ABC_FREE( p->pReprs );
+ ABC_FREE( p->pNexts );
+ }
+ Ssw_SignalFilter( pAig, nFramesMax, nConfMax, nRounds, TimeLimit, TimeLimit2, pCex, fVerbose );
+ Gia_ManReprFromAigRepr( pAig, p );
+ Aig_ManStop( pAig );
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ssw/sswInt.h b/src/aig/ssw/sswInt.h
index 269bdad7..e3a9a341 100644
--- a/src/aig/ssw/sswInt.h
+++ b/src/aig/ssw/sswInt.h
@@ -21,6 +21,7 @@
#ifndef __SSW_INT_H__
#define __SSW_INT_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -33,9 +34,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -93,6 +95,7 @@ struct Ssw_Man_t_
int iNodeLast; // the last node considered
Vec_Ptr_t * vResimConsts; // resimulation constants
Vec_Ptr_t * vResimClasses; // resimulation classes
+ Vec_Int_t * vInits; // the init values of primary inputs under constraints
// counter example storage
int nPatWords; // the number of words in the counter example
unsigned * pPatWords; // the counter example
@@ -113,6 +116,15 @@ struct Ssw_Man_t_
int nNodesEnd;
int nRegsBeg;
int nRegsEnd;
+ // equiv statistis
+ int nConesTotal;
+ int nConesConstr;
+ int nEquivsTotal;
+ int nEquivsConstr;
+ int nNodesBegC;
+ int nNodesEndC;
+ int nRegsBegC;
+ int nRegsEndC;
// runtime stats
int timeBmc; // bounded model checking
int timeReduce; // speculative reduction
@@ -172,7 +184,7 @@ static inline void Ssw_ObjSetFrame( Ssw_Man_t * p, Aig_Obj_t * pObj, int
static inline Aig_Obj_t * Ssw_ObjChild0Fra( Ssw_Man_t * p, Aig_Obj_t * pObj, int i ) { assert( !Aig_IsComplement(pObj) ); return Aig_ObjFanin0(pObj)? Aig_NotCond(Ssw_ObjFrame(p, Aig_ObjFanin0(pObj), i), Aig_ObjFaninC0(pObj)) : NULL; }
static inline Aig_Obj_t * Ssw_ObjChild1Fra( Ssw_Man_t * p, Aig_Obj_t * pObj, int i ) { assert( !Aig_IsComplement(pObj) ); return Aig_ObjFanin1(pObj)? Aig_NotCond(Ssw_ObjFrame(p, Aig_ObjFanin1(pObj), i), Aig_ObjFaninC1(pObj)) : NULL; }
-static inline Aig_Obj_t * Ssw_ObjFrame_( Ssw_Frm_t * p, Aig_Obj_t * pObj, int i ) { return Vec_PtrGetEntry( p->vAig2Frm, p->nObjs*i+pObj->Id ); }
+static inline Aig_Obj_t * Ssw_ObjFrame_( Ssw_Frm_t * p, Aig_Obj_t * pObj, int i ) { return (Aig_Obj_t *)Vec_PtrGetEntry( p->vAig2Frm, p->nObjs*i+pObj->Id ); }
static inline void Ssw_ObjSetFrame_( Ssw_Frm_t * p, Aig_Obj_t * pObj, int i, Aig_Obj_t * pNode ) { Vec_PtrSetEntry( p->vAig2Frm, p->nObjs*i+pObj->Id, pNode ); }
static inline Aig_Obj_t * Ssw_ObjChild0Fra_( Ssw_Frm_t * p, Aig_Obj_t * pObj, int i ) { assert( !Aig_IsComplement(pObj) ); return Aig_ObjFanin0(pObj)? Aig_NotCond(Ssw_ObjFrame_(p, Aig_ObjFanin0(pObj), i), Aig_ObjFaninC0(pObj)) : NULL; }
@@ -206,8 +218,9 @@ extern void Ssw_ClassesCollectClass( Ssw_Cla_t * p, Aig_Obj_t * pRepr,
extern void Ssw_ClassesCheck( Ssw_Cla_t * p );
extern void Ssw_ClassesPrint( Ssw_Cla_t * p, int fVeryVerbose );
extern void Ssw_ClassesRemoveNode( Ssw_Cla_t * p, Aig_Obj_t * pObj );
-extern Ssw_Cla_t * Ssw_ClassesPrepare( Aig_Man_t * pAig, int nFramesK, int fLatchCorr, int nMaxLevs, int fVerbose );
+extern Ssw_Cla_t * Ssw_ClassesPrepare( Aig_Man_t * pAig, int nFramesK, int fLatchCorr, int fOutputCorr, int nMaxLevs, int fVerbose );
extern Ssw_Cla_t * Ssw_ClassesPrepareSimple( Aig_Man_t * pAig, int fLatchCorr, int nMaxLevs );
+extern Ssw_Cla_t * Ssw_ClassesPrepareFromReprs( Aig_Man_t * pAig );
extern Ssw_Cla_t * Ssw_ClassesPrepareTargets( Aig_Man_t * pAig );
extern Ssw_Cla_t * Ssw_ClassesPreparePairs( Aig_Man_t * pAig, Vec_Int_t ** pvClasses );
extern Ssw_Cla_t * Ssw_ClassesPreparePairsSimple( Aig_Man_t * pMiter, Vec_Int_t * vPairs );
@@ -220,6 +233,10 @@ extern Ssw_Sat_t * Ssw_SatStart( int fPolarFlip );
extern void Ssw_SatStop( Ssw_Sat_t * p );
extern void Ssw_CnfNodeAddToSolver( Ssw_Sat_t * p, Aig_Obj_t * pObj );
extern int Ssw_CnfGetNodeValue( Ssw_Sat_t * p, Aig_Obj_t * pObjFraig );
+/*=== sswConstr.c ===================================================*/
+extern int Ssw_ManSweepBmcConstr( Ssw_Man_t * p );
+extern int Ssw_ManSweepConstr( Ssw_Man_t * p );
+extern void Ssw_ManRefineByConstrSim( Ssw_Man_t * p );
/*=== sswCore.c ===================================================*/
extern Aig_Man_t * Ssw_SignalCorrespondenceRefine( Ssw_Man_t * p );
/*=== sswDyn.c ===================================================*/
@@ -231,10 +248,10 @@ extern int Ssw_ManSweepLatch( Ssw_Man_t * p );
extern Ssw_Man_t * Ssw_ManCreate( Aig_Man_t * pAig, Ssw_Pars_t * pPars );
extern void Ssw_ManCleanup( Ssw_Man_t * p );
extern void Ssw_ManStop( Ssw_Man_t * p );
-extern void Ssw_ManStartSolver( Ssw_Man_t * p );
/*=== sswSat.c ===================================================*/
extern int Ssw_NodesAreEquiv( Ssw_Man_t * p, Aig_Obj_t * pOld, Aig_Obj_t * pNew );
extern int Ssw_NodesAreConstrained( Ssw_Man_t * p, Aig_Obj_t * pOld, Aig_Obj_t * pNew );
+extern int Ssw_NodeIsConstrained( Ssw_Man_t * p, Aig_Obj_t * pPoObj );
/*=== sswSemi.c ===================================================*/
extern int Ssw_FilterUsingSemi( Ssw_Man_t * pMan, int fCheckTargets, int nConfMax, int fVerbose );
/*=== sswSim.c ===================================================*/
@@ -259,6 +276,7 @@ extern void Ssw_ManResimulateBit( Ssw_Man_t * p, Aig_Obj_t * pObj, Aig_
extern void Ssw_ManResimulateWord( Ssw_Man_t * p, Aig_Obj_t * pCand, Aig_Obj_t * pRepr, int f );
/*=== sswSweep.c ===================================================*/
extern int Ssw_ManGetSatVarValue( Ssw_Man_t * p, Aig_Obj_t * pObj, int f );
+extern void Ssw_SmlSavePatternAig( Ssw_Man_t * p, int f );
extern int Ssw_ManSweepNode( Ssw_Man_t * p, Aig_Obj_t * pObj, int f, int fBmc );
extern int Ssw_ManSweepBmc( Ssw_Man_t * p );
extern int Ssw_ManSweep( Ssw_Man_t * p );
@@ -267,9 +285,11 @@ extern void Ssw_UniqueRegisterPairInfo( Ssw_Man_t * p );
extern int Ssw_ManUniqueOne( Ssw_Man_t * p, Aig_Obj_t * pRepr, Aig_Obj_t * pObj, int fVerbose );
extern int Ssw_ManUniqueAddConstraint( Ssw_Man_t * p, Vec_Ptr_t * vCommon, int f1, int f2 );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/aig/ssw/sswIslands.c b/src/aig/ssw/sswIslands.c
index 8913116c..d1ebe4bc 100644
--- a/src/aig/ssw/sswIslands.c
+++ b/src/aig/ssw/sswIslands.c
@@ -20,6 +20,9 @@
#include "sswInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -99,7 +102,7 @@ void Ssw_MatchingStart( Aig_Man_t * p0, Aig_Man_t * p1, Vec_Int_t * vPairs )
{
if ( pObj0->pData == NULL )
continue;
- pObj1 = pObj0->pData;
+ pObj1 = (Aig_Obj_t *)pObj0->pData;
if ( !Saig_ObjIsLo(p1, pObj1) )
printf( "Mismatch between LO pairs.\n" );
}
@@ -107,7 +110,7 @@ void Ssw_MatchingStart( Aig_Man_t * p0, Aig_Man_t * p1, Vec_Int_t * vPairs )
{
if ( pObj1->pData == NULL )
continue;
- pObj0 = pObj1->pData;
+ pObj0 = (Aig_Obj_t *)pObj1->pData;
if ( !Saig_ObjIsLo(p0, pObj0) )
printf( "Mismatch between LO pairs.\n" );
}
@@ -234,9 +237,9 @@ void Ssw_MatchingExtend( Aig_Man_t * p0, Aig_Man_t * p1, int nDist, int fVerbose
{
Ssw_MatchingExtendOne( p0, vNodes0 );
Ssw_MatchingExtendOne( p1, vNodes1 );
- Vec_PtrForEachEntry( vNodes0, pNext0, k )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes0, pNext0, k )
{
- pNext1 = pNext0->pData;
+ pNext1 = (Aig_Obj_t *)pNext0->pData;
if ( pNext1 == NULL )
continue;
assert( pNext1->pData == pNext0 );
@@ -245,9 +248,9 @@ void Ssw_MatchingExtend( Aig_Man_t * p0, Aig_Man_t * p1, int nDist, int fVerbose
pNext0->pData = NULL;
pNext1->pData = NULL;
}
- Vec_PtrForEachEntry( vNodes1, pNext0, k )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes1, pNext0, k )
{
- pNext1 = pNext0->pData;
+ pNext1 = (Aig_Obj_t *)pNext0->pData;
if ( pNext1 == NULL )
continue;
assert( pNext1->pData == pNext0 );
@@ -307,7 +310,7 @@ void Ssw_MatchingComplete( Aig_Man_t * p0, Aig_Man_t * p1 )
pObj1->pData = pObj0;
}
// create register outputs in p0 that are absent in p1
- Vec_PtrForEachEntry( vNewLis, pObj0Li, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNewLis, pObj0Li, i )
Aig_ObjCreatePo( p1, Aig_ObjChild0Copy(pObj0Li) );
// increment the number of registers
Aig_ManSetRegNum( p1, Aig_ManRegNum(p1) + Vec_PtrSize(vNewLis) );
@@ -342,7 +345,7 @@ Vec_Int_t * Ssw_MatchingPairs( Aig_Man_t * p0, Aig_Man_t * p1 )
{
if ( Aig_ObjIsPo(pObj0) )
continue;
- pObj1 = pObj0->pData;
+ pObj1 = (Aig_Obj_t *)pObj0->pData;
Vec_IntPush( vPairsNew, pObj0->Id );
Vec_IntPush( vPairsNew, pObj1->Id );
}
@@ -379,11 +382,11 @@ Vec_Int_t * Ssw_MatchingMiter( Aig_Man_t * pMiter, Aig_Man_t * p0, Aig_Man_t * p
assert( pObj1->pData != NULL );
if ( pObj0->pData == pObj1->pData )
continue;
- if ( Aig_ObjIsNone(pObj0->pData) || Aig_ObjIsNone(pObj1->pData) )
+ if ( Aig_ObjIsNone((Aig_Obj_t *)pObj0->pData) || Aig_ObjIsNone((Aig_Obj_t *)pObj1->pData) )
continue;
// get the miter nodes
- pObj0 = pObj0->pData;
- pObj1 = pObj1->pData;
+ pObj0 = (Aig_Obj_t *)pObj0->pData;
+ pObj1 = (Aig_Obj_t *)pObj1->pData;
assert( !Aig_IsComplement(pObj0) );
assert( !Aig_IsComplement(pObj1) );
assert( Aig_ObjType(pObj0) == Aig_ObjType(pObj1) );
@@ -435,7 +438,7 @@ Aig_Man_t * Ssw_SecWithSimilaritySweep( Aig_Man_t * p0, Aig_Man_t * p1, Vec_Int_
if ( p->pPars->fPartSigCorr )
p->ppClasses = Ssw_ClassesPreparePairsSimple( pMiter, vPairsMiter );
else
- p->ppClasses = Ssw_ClassesPrepare( pMiter, pPars->nFramesK, pPars->fLatchCorr, pPars->nMaxLevs, pPars->fVerbose );
+ p->ppClasses = Ssw_ClassesPrepare( pMiter, pPars->nFramesK, pPars->fLatchCorr, pPars->fOutputCorr, pPars->nMaxLevs, pPars->fVerbose );
if ( p->pPars->fDumpSRInit )
{
if ( p->pPars->fPartSigCorr )
@@ -449,7 +452,7 @@ Aig_Man_t * Ssw_SecWithSimilaritySweep( Aig_Man_t * p0, Aig_Man_t * p1, Vec_Int_
printf( "Dumping speculative miter is possible only for partial signal correspondence (switch \"-c\").\n" );
}
p->pSml = Ssw_SmlStart( pMiter, 0, 1 + p->pPars->nFramesAddSim, 1 );
- Ssw_ClassesSetData( p->ppClasses, p->pSml, Ssw_SmlObjHashWord, Ssw_SmlObjIsConstWord, Ssw_SmlObjsAreEqualWord );
+ Ssw_ClassesSetData( p->ppClasses, p->pSml, (unsigned(*)(void *,Aig_Obj_t *))Ssw_SmlObjHashWord, (int(*)(void *,Aig_Obj_t *))Ssw_SmlObjIsConstWord, (int(*)(void *,Aig_Obj_t *,Aig_Obj_t *))Ssw_SmlObjsAreEqualWord );
// perform refinement of classes
pAigNew = Ssw_SignalCorrespondenceRefine( p );
// cleanup
@@ -591,3 +594,5 @@ int Ssw_SecWithSimilarity( Aig_Man_t * p0, Aig_Man_t * p1, Ssw_Pars_t * pPars )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ssw/sswLcorr.c b/src/aig/ssw/sswLcorr.c
index fb36c31d..7cd94727 100644
--- a/src/aig/ssw/sswLcorr.c
+++ b/src/aig/ssw/sswLcorr.c
@@ -21,6 +21,9 @@
#include "sswInt.h"
//#include "bar.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -56,7 +59,7 @@ void Ssw_ManSweepTransfer( Ssw_Man_t * p )
}
assert( !Aig_IsComplement(pObjFraig) );
assert( Aig_ObjIsPi(pObjFraig) );
- pInfo = Vec_PtrEntry( p->vSimInfo, Aig_ObjPioNum(pObjFraig) );
+ pInfo = (unsigned *)Vec_PtrEntry( p->vSimInfo, Aig_ObjPioNum(pObjFraig) );
Ssw_SmlObjSetWord( p->pSml, pObj, pInfo[0], 0, 0 );
}
}
@@ -106,14 +109,14 @@ void Ssw_SmlAddPattern( Ssw_Man_t * p, Aig_Obj_t * pRepr, Aig_Obj_t * pCand )
Aig_Obj_t * pObj;
unsigned * pInfo;
int i, nVarNum, Value;
- Vec_PtrForEachEntry( p->pMSat->vUsedPis, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->pMSat->vUsedPis, pObj, i )
{
nVarNum = Ssw_ObjSatNum( p->pMSat, pObj );
assert( nVarNum > 0 );
Value = sat_solver_var_value( p->pMSat->pSat, nVarNum );
if ( Value == 0 )
continue;
- pInfo = Vec_PtrEntry( p->vSimInfo, Aig_ObjPioNum(pObj) );
+ pInfo = (unsigned *)Vec_PtrEntry( p->vSimInfo, Aig_ObjPioNum(pObj) );
Aig_InfoSetBit( pInfo, p->nPatterns );
}
}
@@ -284,7 +287,7 @@ int Ssw_ManSweepLatch( Ssw_Man_t * p )
if ( Vec_PtrSize(vClass) == 0 )
continue;
// try to prove equivalences in this class
- Vec_PtrForEachEntry( vClass, pTemp, k )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vClass, pTemp, k )
if ( Aig_ObjRepr(p->pAig, pTemp) == pObj )
{
Ssw_ManSweepLatchOne( p, pObj, pTemp );
@@ -329,3 +332,5 @@ int Ssw_ManSweepLatch( Ssw_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ssw/sswMan.c b/src/aig/ssw/sswMan.c
index 90cc9028..0f1317e1 100644
--- a/src/aig/ssw/sswMan.c
+++ b/src/aig/ssw/sswMan.c
@@ -20,6 +20,9 @@
#include "sswInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -57,13 +60,12 @@ Ssw_Man_t * Ssw_ManCreate( Aig_Man_t * pAig, Ssw_Pars_t * pPars )
p->iOutputLit = -1;
// allocate storage for sim pattern
p->nPatWords = Aig_BitWordNum( Saig_ManPiNum(pAig) * p->nFrames + Saig_ManRegNum(pAig) );
- p->pPatWords = ABC_ALLOC( unsigned, p->nPatWords );
+ p->pPatWords = ABC_CALLOC( unsigned, p->nPatWords );
// other
p->vNewLos = Vec_PtrAlloc( 100 );
p->vNewPos = Vec_IntAlloc( 100 );
p->vResimConsts = Vec_PtrAlloc( 100 );
p->vResimClasses = Vec_PtrAlloc( 100 );
-
// p->pPars->fVerbose = 1;
return p;
}
@@ -104,10 +106,10 @@ void Ssw_ManPrintStats( Ssw_Man_t * p )
double nMemory = 1.0*Aig_ManObjNumMax(p->pAig)*p->nFrames*(2*sizeof(int)+2*sizeof(void*))/(1<<20);
printf( "Parameters: F = %d. AddF = %d. C-lim = %d. Constr = %d. MaxLev = %d. Mem = %0.2f Mb.\n",
- p->pPars->nFramesK, p->pPars->nFramesAddSim, p->pPars->nBTLimit, p->pPars->nConstrs, p->pPars->nMaxLevs, nMemory );
+ p->pPars->nFramesK, p->pPars->nFramesAddSim, p->pPars->nBTLimit, Saig_ManConstrNum(p->pAig), p->pPars->nMaxLevs, nMemory );
printf( "AIG : PI = %d. PO = %d. Latch = %d. Node = %d. Ave SAT vars = %d.\n",
Saig_ManPiNum(p->pAig), Saig_ManPoNum(p->pAig), Saig_ManRegNum(p->pAig), Aig_ManNodeNum(p->pAig),
- 0/p->pPars->nIters );
+ 0/(p->pPars->nIters+1) );
printf( "SAT calls : Proof = %d. Cex = %d. Fail = %d. Lits proved = %d.\n",
p->nSatProof, p->nSatCallsSat, p->nSatFailsReal, Ssw_ManCountEquivs(p) );
printf( "SAT solver: Vars max = %d. Calls max = %d. Recycles = %d. Sim rounds = %d.\n",
@@ -127,6 +129,19 @@ void Ssw_ManPrintStats( Ssw_Man_t * p )
ABC_PRTP( " undecided", p->timeSatUndec, p->timeTotal );
ABC_PRTP( "Other ", p->timeOther, p->timeTotal );
ABC_PRTP( "TOTAL ", p->timeTotal, p->timeTotal );
+
+ // report the reductions
+ if ( p->pAig->nConstrs )
+ {
+ printf( "Statistics reflecting the use of constraints:\n" );
+ printf( "Total cones = %6d. Constraint cones = %6d. (%6.2f %%)\n",
+ p->nConesTotal, p->nConesConstr, 100.0*p->nConesConstr/p->nConesTotal );
+ printf( "Total equivs = %6d. Removed equivs = %6d. (%6.2f %%)\n",
+ p->nEquivsTotal, p->nEquivsConstr, 100.0*p->nEquivsConstr/p->nEquivsTotal );
+ printf( "NBeg = %d. NEnd = %d. (Gain = %6.2f %%). RBeg = %d. REnd = %d. (Gain = %6.2f %%).\n",
+ p->nNodesBegC, p->nNodesEndC, 100.0*(p->nNodesBegC-p->nNodesEndC)/(p->nNodesBegC?p->nNodesBegC:1),
+ p->nRegsBegC, p->nRegsEndC, 100.0*(p->nRegsBegC-p->nRegsEndC)/(p->nRegsBegC?p->nRegsBegC:1) );
+ }
}
/**Function*************************************************************
@@ -174,7 +189,7 @@ void Ssw_ManCleanup( Ssw_Man_t * p )
void Ssw_ManStop( Ssw_Man_t * p )
{
ABC_FREE( p->pVisited );
- if ( p->pPars->fVerbose )
+ if ( p->pPars->fVerbose )//&& p->pPars->nStepsMax == -1 )
Ssw_ManPrintStats( p );
if ( p->ppClasses )
Ssw_ClassesStop( p->ppClasses );
@@ -182,6 +197,8 @@ void Ssw_ManStop( Ssw_Man_t * p )
Ssw_SmlStop( p->pSml );
if ( p->vDiffPairs )
Vec_IntFree( p->vDiffPairs );
+ if ( p->vInits )
+ Vec_IntFree( p->vInits );
Vec_PtrFree( p->vResimConsts );
Vec_PtrFree( p->vResimClasses );
Vec_PtrFree( p->vNewLos );
@@ -197,3 +214,5 @@ void Ssw_ManStop( Ssw_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ssw/sswPairs.c b/src/aig/ssw/sswPairs.c
index 3c079922..0aba942f 100644
--- a/src/aig/ssw/sswPairs.c
+++ b/src/aig/ssw/sswPairs.c
@@ -20,6 +20,9 @@
#include "sswInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -113,8 +116,8 @@ Vec_Int_t * Ssw_TransferSignalPairs( Aig_Man_t * pMiter, Aig_Man_t * pAig1, Aig_
{
pObj1 = Aig_ManObj( pAig1, Vec_IntEntry(vIds1, i) );
pObj2 = Aig_ManObj( pAig2, Vec_IntEntry(vIds2, i) );
- pObj1m = Aig_Regular(pObj1->pData);
- pObj2m = Aig_Regular(pObj2->pData);
+ pObj1m = Aig_Regular((Aig_Obj_t *)pObj1->pData);
+ pObj2m = Aig_Regular((Aig_Obj_t *)pObj2->pData);
assert( pObj1m && pObj2m );
if ( pObj1m == pObj2m )
continue;
@@ -290,7 +293,7 @@ Aig_Man_t * Ssw_SignalCorrespondenceWithPairs( Aig_Man_t * pAig1, Aig_Man_t * pA
// create equivalence classes using these IDs
p->ppClasses = Ssw_ClassesPreparePairs( pMiter, pvClasses );
p->pSml = Ssw_SmlStart( pMiter, 0, p->nFrames + p->pPars->nFramesAddSim, 1 );
- Ssw_ClassesSetData( p->ppClasses, p->pSml, Ssw_SmlObjHashWord, Ssw_SmlObjIsConstWord, Ssw_SmlObjsAreEqualWord );
+ Ssw_ClassesSetData( p->ppClasses, p->pSml, (unsigned(*)(void *,Aig_Obj_t *))Ssw_SmlObjHashWord, (int(*)(void *,Aig_Obj_t *))Ssw_SmlObjIsConstWord, (int(*)(void *,Aig_Obj_t *,Aig_Obj_t *))Ssw_SmlObjsAreEqualWord );
// perform refinement of classes
pAigNew = Ssw_SignalCorrespondenceRefine( p );
// cleanup
@@ -326,7 +329,7 @@ Aig_Man_t * Ssw_SignalCorrespondeceTestPairs( Aig_Man_t * pAig )
vIds2 = Vec_IntAlloc( Aig_ManObjNumMax(pAig) );
Aig_ManForEachObj( pAig, pObj, i )
{
- pRepr = Aig_Regular(pObj->pData);
+ pRepr = Aig_Regular((Aig_Obj_t *)pObj->pData);
if ( pRepr == NULL )
continue;
if ( Aig_ManObj(pAigNew, pRepr->Id) == NULL )
@@ -470,3 +473,5 @@ int Ssw_SecGeneralMiter( Aig_Man_t * pMiter, Ssw_Pars_t * pPars )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ssw/sswPart.c b/src/aig/ssw/sswPart.c
index f481b457..8a0e69da 100644
--- a/src/aig/ssw/sswPart.c
+++ b/src/aig/ssw/sswPart.c
@@ -19,6 +19,10 @@
***********************************************************************/
#include "sswInt.h"
+#include "ioa.h"
+
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -50,16 +54,20 @@ Aig_Man_t * Ssw_SignalCorrespondencePart( Aig_Man_t * pAig, Ssw_Pars_t * pPars )
int i, nCountPis, nCountRegs;
int nClasses, nPartSize, fVerbose;
int clk = clock();
-
+ if ( pPars->fConstrs )
+ {
+ printf( "Cannot use partitioned computation with constraints.\n" );
+ return NULL;
+ }
// save parameters
nPartSize = pPars->nPartSize; pPars->nPartSize = 0;
- fVerbose = pPars->fVerbose; pPars->fVerbose = 0;
+ fVerbose = pPars->fVerbose; pPars->fVerbose = 0;
// generate partitions
if ( pAig->vClockDoms )
{
// divide large clock domains into separate partitions
vResult = Vec_PtrAlloc( 100 );
- Vec_PtrForEachEntry( (Vec_Ptr_t *)pAig->vClockDoms, vPart, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, (Vec_Ptr_t *)pAig->vClockDoms, vPart, i )
{
if ( nPartSize && Vec_IntSize(vPart) > nPartSize )
Aig_ManPartDivide( vResult, vPart, nPartSize, pPars->nOverSize );
@@ -75,9 +83,9 @@ Aig_Man_t * Ssw_SignalCorrespondencePart( Aig_Man_t * pAig, Ssw_Pars_t * pPars )
{
// print partitions
printf( "Simple partitioning. %d partitions are saved:\n", Vec_PtrSize(vResult) );
- Vec_PtrForEachEntry( vResult, vPart, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vResult, vPart, i )
{
- extern void Ioa_WriteAiger( Aig_Man_t * pMan, char * pFileName, int fWriteSymbols, int fCompact );
+// extern void Ioa_WriteAiger( Aig_Man_t * pMan, char * pFileName, int fWriteSymbols, int fCompact );
sprintf( Buffer, "part%03d.aig", i );
pTemp = Aig_ManRegCreatePart( pAig, vPart, &nCountPis, &nCountRegs, NULL );
Ioa_WriteAiger( pTemp, Buffer, 0, 0 );
@@ -89,7 +97,7 @@ Aig_Man_t * Ssw_SignalCorrespondencePart( Aig_Man_t * pAig, Ssw_Pars_t * pPars )
// perform SSW with partitions
Aig_ManReprStart( pAig, Aig_ManObjNumMax(pAig) );
- Vec_PtrForEachEntry( vResult, vPart, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vResult, vPart, i )
{
pTemp = Aig_ManRegCreatePart( pAig, vPart, &nCountPis, &nCountRegs, &pMapBack );
Aig_ManSetRegNum( pTemp, pTemp->nRegs );
@@ -129,3 +137,5 @@ Aig_Man_t * Ssw_SignalCorrespondencePart( Aig_Man_t * pAig, Ssw_Pars_t * pPars )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ssw/sswSat.c b/src/aig/ssw/sswSat.c
index 21c5c1f1..7d371cac 100644
--- a/src/aig/ssw/sswSat.c
+++ b/src/aig/ssw/sswSat.c
@@ -20,6 +20,9 @@
#include "sswInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -50,9 +53,6 @@ int Ssw_NodesAreEquiv( Ssw_Man_t * p, Aig_Obj_t * pOld, Aig_Obj_t * pNew )
assert( !Aig_IsComplement(pOld) );
assert( !Aig_IsComplement(pNew) );
assert( pOld != pNew );
-
-// if ( p->pSat == NULL )
-// Ssw_ManStartSolver( p );
assert( p->pMSat != NULL );
// if the nodes do not have SAT variables, allocate them
@@ -199,7 +199,7 @@ int Ssw_NodesAreConstrained( Ssw_Man_t * p, Aig_Obj_t * pOld, Aig_Obj_t * pNew )
// sanity checks
assert( Aig_Regular(pOld) != Aig_Regular(pNew) );
- assert( Aig_ObjPhaseReal(pOld) == Aig_ObjPhaseReal(pNew) );
+ assert( p->pPars->fConstrs || Aig_ObjPhaseReal(pOld) == Aig_ObjPhaseReal(pNew) );
// move constant to the old node
if ( Aig_Regular(pNew) == Aig_ManConst1(p->pFrames) )
@@ -216,9 +216,6 @@ int Ssw_NodesAreConstrained( Ssw_Man_t * p, Aig_Obj_t * pOld, Aig_Obj_t * pNew )
pOld = Aig_Regular(pOld);
pNew = Aig_Not(pNew);
}
-
-// if ( p->pSat == NULL )
-// Ssw_ManStartSolver( p );
assert( p->pMSat != NULL );
// if the nodes do not have SAT variables, allocate them
@@ -274,8 +271,36 @@ int Ssw_NodesAreConstrained( Ssw_Man_t * p, Aig_Obj_t * pOld, Aig_Obj_t * pNew )
return 1;
}
+/**Function*************************************************************
+
+ Synopsis [Constrains one node in the SAT solver.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Ssw_NodeIsConstrained( Ssw_Man_t * p, Aig_Obj_t * pPoObj )
+{
+ int RetValue, Lit;
+ Ssw_CnfNodeAddToSolver( p->pMSat, Aig_ObjFanin0(pPoObj) );
+ // add constraint A = 1 ----> A
+ Lit = toLitCond( Ssw_ObjSatNum(p->pMSat,Aig_ObjFanin0(pPoObj)), !Aig_ObjFaninC0(pPoObj) );
+ if ( p->pPars->fPolarFlip )
+ {
+ if ( Aig_ObjFanin0(pPoObj)->fPhase ) Lit = lit_neg( Lit );
+ }
+ RetValue = sat_solver_addclause( p->pMSat->pSat, &Lit, &Lit + 1 );
+ assert( RetValue );
+ return 1;
+}
+
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ssw/sswSemi.c b/src/aig/ssw/sswSemi.c
index 1d578291..dfb2fb0f 100644
--- a/src/aig/ssw/sswSemi.c
+++ b/src/aig/ssw/sswSemi.c
@@ -20,6 +20,9 @@
#include "sswInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -127,7 +130,7 @@ int Ssw_SemCheckTargets( Ssw_Sem_t * p )
{
Aig_Obj_t * pObj;
int i;
- Vec_PtrForEachEntry( p->vTargets, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vTargets, pObj, i )
if ( !Ssw_ObjIsConst1Cand(p->pMan->pAig, pObj) )
return 1;
return 0;
@@ -153,7 +156,7 @@ void Ssw_ManFilterBmcSavePattern( Ssw_Sem_t * p )
return;
Saig_ManForEachLo( p->pMan->pAig, pObj, i )
{
- pInfo = Vec_PtrEntry( p->vPatterns, i );
+ pInfo = (unsigned *)Vec_PtrEntry( p->vPatterns, i );
if ( Aig_InfoHasBit( p->pMan->pPatWords, Saig_ManPiNum(p->pMan->pAig) + i ) )
Aig_InfoSetBit( pInfo, p->nPatterns );
}
@@ -183,7 +186,7 @@ clk = clock();
p->pFrames = Aig_ManStart( Aig_ManObjNumMax(p->pAig) * 3 );
Saig_ManForEachLo( p->pAig, pObj, i )
{
- pInfo = Vec_PtrEntry( pBmc->vPatterns, i );
+ pInfo = (unsigned *)Vec_PtrEntry( pBmc->vPatterns, i );
pObjNew = Aig_NotCond( Aig_ManConst1(p->pFrames), !Aig_InfoHasBit(pInfo, iPat) );
Ssw_ObjSetFrame( p, pObj, 0, pObjNew );
}
@@ -315,3 +318,5 @@ clk = clock();
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ssw/sswSim.c b/src/aig/ssw/sswSim.c
index cf5270dd..37bf5717 100644
--- a/src/aig/ssw/sswSim.c
+++ b/src/aig/ssw/sswSim.c
@@ -20,6 +20,9 @@
#include "sswInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -349,7 +352,7 @@ int Ssw_SmlNodeCountOnesRealVec( Ssw_Sml_t * p, Vec_Ptr_t * vObjs )
for ( i = 0; i < p->nWordsTotal; i++ )
{
uWord = 0;
- Vec_PtrForEachEntry( vObjs, pObj, k )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vObjs, pObj, k )
{
pSims = Ssw_ObjSim(p, Aig_Regular(pObj)->Id);
if ( Aig_Regular(pObj)->fPhase ^ Aig_IsComplement(pObj) )
@@ -858,7 +861,7 @@ void Ssw_SmlInitialize( Ssw_Sml_t * p, int fInit )
if ( fInit )
{
assert( Aig_ManRegNum(p->pAig) > 0 );
- assert( Aig_ManRegNum(p->pAig) < Aig_ManPiNum(p->pAig) );
+ assert( Aig_ManRegNum(p->pAig) <= Aig_ManPiNum(p->pAig) );
// assign random info for primary inputs
Saig_ManForEachPi( p->pAig, pObj, i )
Ssw_SmlAssignRandom( p, pObj );
@@ -1240,12 +1243,12 @@ unsigned * Ssw_SmlSimInfo( Ssw_Sml_t * p, Aig_Obj_t * pObj )
SeeAlso []
***********************************************************************/
-Ssw_Cex_t * Ssw_SmlAllocCounterExample( int nRegs, int nRealPis, int nFrames )
+Abc_Cex_t * Ssw_SmlAllocCounterExample( int nRegs, int nRealPis, int nFrames )
{
- Ssw_Cex_t * pCex;
+ Abc_Cex_t * pCex;
int nWords = Aig_BitWordNum( nRegs + nRealPis * nFrames );
- pCex = (Ssw_Cex_t *)ABC_ALLOC( char, sizeof(Ssw_Cex_t) + sizeof(unsigned) * nWords );
- memset( pCex, 0, sizeof(Ssw_Cex_t) + sizeof(unsigned) * nWords );
+ pCex = (Abc_Cex_t *)ABC_ALLOC( char, sizeof(Abc_Cex_t) + sizeof(unsigned) * nWords );
+ memset( pCex, 0, sizeof(Abc_Cex_t) + sizeof(unsigned) * nWords );
pCex->nRegs = nRegs;
pCex->nPis = nRealPis;
pCex->nBits = nRegs + nRealPis * nFrames;
@@ -1263,7 +1266,7 @@ Ssw_Cex_t * Ssw_SmlAllocCounterExample( int nRegs, int nRealPis, int nFrames )
SeeAlso []
***********************************************************************/
-void Ssw_SmlFreeCounterExample( Ssw_Cex_t * pCex )
+void Ssw_SmlFreeCounterExample( Abc_Cex_t * pCex )
{
ABC_FREE( pCex );
}
@@ -1279,11 +1282,15 @@ void Ssw_SmlFreeCounterExample( Ssw_Cex_t * pCex )
SeeAlso []
***********************************************************************/
-int Ssw_SmlRunCounterExample( Aig_Man_t * pAig, Ssw_Cex_t * p )
+int Ssw_SmlRunCounterExample( Aig_Man_t * pAig, Abc_Cex_t * p )
{
Ssw_Sml_t * pSml;
Aig_Obj_t * pObj;
int RetValue, i, k, iBit;
+ if ( Saig_ManPiNum(pAig) != p->nPis )
+ return 0;
+// if ( Saig_ManRegNum(pAig) != p->nRegs )
+// return 0;
// assert( Aig_ManRegNum(pAig) > 0 );
// assert( Aig_ManRegNum(pAig) < Aig_ManPiNum(pAig) );
// start a new sequential simulator
@@ -1293,10 +1300,11 @@ int Ssw_SmlRunCounterExample( Aig_Man_t * pAig, Ssw_Cex_t * p )
Saig_ManForEachLo( pAig, pObj, i )
Ssw_SmlObjAssignConst( pSml, pObj, Aig_InfoHasBit(p->pData, iBit++), 0 );
// assign simulation info for the primary inputs
+ iBit = Saig_ManRegNum(pAig);
for ( i = 0; i <= p->iFrame; i++ )
Saig_ManForEachPi( pAig, pObj, k )
Ssw_SmlObjAssignConst( pSml, pObj, Aig_InfoHasBit(p->pData, iBit++), i );
- assert( iBit == p->nBits );
+// assert( iBit == p->nBits );
// run random simulation
Ssw_SmlSimulateOne( pSml );
// check if the given output has failed
@@ -1316,7 +1324,7 @@ int Ssw_SmlRunCounterExample( Aig_Man_t * pAig, Ssw_Cex_t * p )
SeeAlso []
***********************************************************************/
-int Ssw_SmlFindOutputCounterExample( Aig_Man_t * pAig, Ssw_Cex_t * p )
+int Ssw_SmlFindOutputCounterExample( Aig_Man_t * pAig, Abc_Cex_t * p )
{
Ssw_Sml_t * pSml;
Aig_Obj_t * pObj;
@@ -1359,9 +1367,9 @@ int Ssw_SmlFindOutputCounterExample( Aig_Man_t * pAig, Ssw_Cex_t * p )
SeeAlso []
***********************************************************************/
-Ssw_Cex_t * Ssw_SmlGetCounterExample( Ssw_Sml_t * p )
+Abc_Cex_t * Ssw_SmlGetCounterExample( Ssw_Sml_t * p )
{
- Ssw_Cex_t * pCex;
+ Abc_Cex_t * pCex;
Aig_Obj_t * pObj;
unsigned * pSims;
int iPo, iFrame, iBit, i, k;
@@ -1433,9 +1441,9 @@ Ssw_Cex_t * Ssw_SmlGetCounterExample( Ssw_Sml_t * p )
SeeAlso []
***********************************************************************/
-Ssw_Cex_t * Ssw_SmlCopyCounterExample( Aig_Man_t * pAig, Aig_Man_t * pFrames, int * pModel )
+Abc_Cex_t * Ssw_SmlCopyCounterExample( Aig_Man_t * pAig, Aig_Man_t * pFrames, int * pModel )
{
- Ssw_Cex_t * pCex;
+ Abc_Cex_t * pCex;
Aig_Obj_t * pObj;
int i, nFrames, nTruePis, nTruePos, iPo, iFrame;
// get the number of frames
@@ -1493,9 +1501,9 @@ Ssw_Cex_t * Ssw_SmlCopyCounterExample( Aig_Man_t * pAig, Aig_Man_t * pFrames, in
SeeAlso []
***********************************************************************/
-Ssw_Cex_t * Ssw_SmlTrivCounterExample( Aig_Man_t * pAig, int iFrameOut )
+Abc_Cex_t * Ssw_SmlTrivCounterExample( Aig_Man_t * pAig, int iFrameOut )
{
- Ssw_Cex_t * pCex;
+ Abc_Cex_t * pCex;
int nTruePis, nTruePos, iPo, iFrame;
assert( Aig_ManRegNum(pAig) > 0 );
nTruePis = Aig_ManPiNum(pAig)-Aig_ManRegNum(pAig);
@@ -1520,9 +1528,9 @@ Ssw_Cex_t * Ssw_SmlTrivCounterExample( Aig_Man_t * pAig, int iFrameOut )
SeeAlso []
***********************************************************************/
-Ssw_Cex_t * Ssw_SmlDupCounterExample( Ssw_Cex_t * p, int nRegsNew )
+Abc_Cex_t * Ssw_SmlDupCounterExample( Abc_Cex_t * p, int nRegsNew )
{
- Ssw_Cex_t * pCex;
+ Abc_Cex_t * pCex;
int i;
pCex = Ssw_SmlAllocCounterExample( nRegsNew, p->nPis, p->iFrame+1 );
pCex->iPo = p->iPo;
@@ -1544,7 +1552,7 @@ Ssw_Cex_t * Ssw_SmlDupCounterExample( Ssw_Cex_t * p, int nRegsNew )
SeeAlso []
***********************************************************************/
-int Ssw_SmlWriteCounterExample( FILE * pFile, Aig_Man_t * pAig, Ssw_Cex_t * p )
+int Ssw_SmlWriteCounterExample( FILE * pFile, Aig_Man_t * pAig, Abc_Cex_t * p )
{
Ssw_Sml_t * pSml;
Aig_Obj_t * pObj;
@@ -1614,3 +1622,5 @@ int Ssw_SmlWriteCounterExample( FILE * pFile, Aig_Man_t * pAig, Ssw_Cex_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ssw/sswSimSat.c b/src/aig/ssw/sswSimSat.c
index c85b8bcf..6b18a3a6 100644
--- a/src/aig/ssw/sswSimSat.c
+++ b/src/aig/ssw/sswSimSat.c
@@ -20,6 +20,9 @@
#include "sswInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -51,21 +54,25 @@ void Ssw_ManResimulateBit( Ssw_Man_t * p, Aig_Obj_t * pCand, Aig_Obj_t * pRepr )
Aig_ManForEachNode( p->pAig, pObj, i )
pObj->fMarkB = ( Aig_ObjFanin0(pObj)->fMarkB ^ Aig_ObjFaninC0(pObj) )
& ( Aig_ObjFanin1(pObj)->fMarkB ^ Aig_ObjFaninC1(pObj) );
- // check equivalence classes
- RetValue1 = Ssw_ClassesRefineConst1( p->ppClasses, 0 );
- RetValue2 = Ssw_ClassesRefine( p->ppClasses, 0 );
- // make sure refinement happened
- if ( Aig_ObjIsConst1(pRepr) )
- {
- assert( RetValue1 );
- if ( RetValue1 == 0 )
- printf( "\nSsw_ManResimulateBit() Error: RetValue1 does not hold.\n" );
- }
- else
+ // if repr is given, perform refinement
+ if ( pRepr )
{
- assert( RetValue2 );
- if ( RetValue2 == 0 )
- printf( "\nSsw_ManResimulateBit() Error: RetValue2 does not hold.\n" );
+ // check equivalence classes
+ RetValue1 = Ssw_ClassesRefineConst1( p->ppClasses, 0 );
+ RetValue2 = Ssw_ClassesRefine( p->ppClasses, 0 );
+ // make sure refinement happened
+ if ( Aig_ObjIsConst1(pRepr) )
+ {
+ assert( RetValue1 );
+ if ( RetValue1 == 0 )
+ printf( "\nSsw_ManResimulateBit() Error: RetValue1 does not hold.\n" );
+ }
+ else
+ {
+ assert( RetValue2 );
+ if ( RetValue2 == 0 )
+ printf( "\nSsw_ManResimulateBit() Error: RetValue2 does not hold.\n" );
+ }
}
p->timeSimSat += clock() - clk;
}
@@ -112,3 +119,5 @@ p->timeSimSat += clock() - clk;
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ssw/sswSweep.c b/src/aig/ssw/sswSweep.c
index a2f3c175..39fcd48e 100644
--- a/src/aig/ssw/sswSweep.c
+++ b/src/aig/ssw/sswSweep.c
@@ -21,6 +21,9 @@
#include "sswInt.h"
#include "bar.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -157,14 +160,14 @@ void Ssw_SmlAddPatternDyn( Ssw_Man_t * p )
unsigned * pInfo;
int i, nVarNum;
// iterate through the PIs of the frames
- Vec_PtrForEachEntry( p->pMSat->vUsedPis, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->pMSat->vUsedPis, pObj, i )
{
assert( Aig_ObjIsPi(pObj) );
nVarNum = Ssw_ObjSatNum( p->pMSat, pObj );
assert( nVarNum > 0 );
if ( sat_solver_var_value( p->pMSat->pSat, nVarNum ) )
{
- pInfo = Vec_PtrEntry( p->vSimInfo, Aig_ObjPioNum(pObj) );
+ pInfo = (unsigned *)Vec_PtrEntry( p->vSimInfo, Aig_ObjPioNum(pObj) );
Aig_InfoSetBit( pInfo, p->nPatterns );
}
}
@@ -232,34 +235,7 @@ p->timeMarkCones += clock() - clk;
}
else
Ssw_SmlSavePatternAig( p, f );
- // consider uniqueness
- if ( !fBmc && !p->pPars->fDynamic && p->pPars->fUniqueness && p->pPars->nFramesK > 1 &&
- Ssw_ManUniqueOne( p, pObjRepr, pObj, p->pPars->fVerbose ) && p->iOutputLit == -1 )
- {
- if ( Ssw_ManUniqueAddConstraint( p, p->vCommon, 0, 1 ) )
- {
- int RetValue2 = Ssw_NodesAreEquiv( p, Aig_Regular(pObjReprFraig), Aig_Regular(pObjFraig) );
- p->iOutputLit = -1;
- p->nUniques++;
- p->nUniquesAdded++;
- if ( RetValue2 == 0 )
- {
- int x;
-// printf( "Second time:\n" );
- x = Ssw_ManUniqueOne( p, pObjRepr, pObj, p->pPars->fVerbose );
- Ssw_SmlSavePatternAig( p, f );
- Ssw_ManResimulateWord( p, pObj, pObjRepr, f );
- if ( Aig_ObjRepr( p->pAig, pObj ) == pObjRepr )
- printf( "Ssw_ManSweepNode(): Refinement did not happen!!!.\n" );
- return 1;
- }
- else
- p->nUniquesUseful++;
-// printf( "Counter-example prevented!!!\n" );
- return 0;
- }
- }
- if ( p->pPars->nConstrs == 0 )
+ if ( !p->pPars->fConstrs )
Ssw_ManResimulateWord( p, pObj, pObjRepr, f );
else
Ssw_ManResimulateBit( p, pObj, pObjRepr );
@@ -298,7 +274,6 @@ clk = clock();
p->fRefined = 0;
if ( p->pPars->fVerbose )
pProgress = Bar_ProgressStart( stdout, Aig_ManObjNumMax(p->pAig) * p->pPars->nFramesK );
-// Ssw_ManStartSolver( p );
for ( f = 0; f < p->pPars->nFramesK; f++ )
{
// map constants and PIs
@@ -318,10 +293,12 @@ clk = clock();
if ( f == p->pPars->nFramesK - 1 )
break;
// transfer latch input to the latch outputs
+ Aig_ManForEachPo( p->pAig, pObj, i )
+ Ssw_ObjSetFrame( p, pObj, f, Ssw_ObjChild0Fra(p, pObj, f) );
// build logic cones for register outputs
Saig_ManForEachLiLo( p->pAig, pObjLi, pObjLo, i )
{
- pObjNew = Ssw_ObjChild0Fra(p, pObjLi,f);
+ pObjNew = Ssw_ObjFrame( p, pObjLi, f );
Ssw_ObjSetFrame( p, pObjLo, f+1, pObjNew );
Ssw_CnfNodeAddToSolver( p->pMSat, Aig_Regular(pObjNew) );//
}
@@ -350,7 +327,7 @@ int Ssw_ManSweep( Ssw_Man_t * p )
{
Bar_Progress_t * pProgress = NULL;
Aig_Obj_t * pObj, * pObj2, * pObjNew;
- int nConstrPairs, clk, i, f, v;
+ int nConstrPairs, clk, i, f;
// perform speculative reduction
clk = clock();
@@ -380,12 +357,6 @@ clk = clock();
Ssw_ObjSetFrame( p, pObj, f, Aig_ObjCreatePi(p->pFrames) );
p->timeReduce += clock() - clk;
- // bring up the previous frames
- if ( p->pPars->fUniqueness )
- for ( v = 0; v < f; v++ )
- Saig_ManForEachLo( p->pAig, pObj, i )
- Ssw_CnfNodeAddToSolver( p->pMSat, Aig_Regular(Ssw_ObjFrame(p, pObj, v)) );
-
// sweep internal nodes
p->fRefined = 0;
Ssw_ClassesClearRefined( p->ppClasses );
@@ -417,3 +388,5 @@ p->timeReduce += clock() - clk;
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/ssw/sswUnique.c b/src/aig/ssw/sswUnique.c
index d6590716..b5f6a853 100644
--- a/src/aig/ssw/sswUnique.c
+++ b/src/aig/ssw/sswUnique.c
@@ -20,6 +20,9 @@
#include "sswInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -100,7 +103,7 @@ int Ssw_ManUniqueOne( Ssw_Man_t * p, Aig_Obj_t * pRepr, Aig_Obj_t * pObj, int fV
RetValue = Vec_PtrSize( p->vCommon );
fFeasible = 0;
k = 0;
- Vec_PtrForEachEntry( p->vCommon, pTemp, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vCommon, pTemp, i )
{
assert( Aig_ObjIsPi(pTemp) );
if ( !Saig_ObjIsLo(p->pAig, pTemp) )
@@ -119,7 +122,7 @@ int Ssw_ManUniqueOne( Ssw_Man_t * p, Aig_Obj_t * pRepr, Aig_Obj_t * pObj, int fV
// check the current values
RetValue = 1;
- Vec_PtrForEachEntry( p->vCommon, pTemp, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, p->vCommon, pTemp, i )
{
Value0 = Ssw_ManGetSatVarValue( p, pTemp, 0 );
Value1 = Ssw_ManGetSatVarValue( p, pTemp, 1 );
@@ -153,7 +156,7 @@ int Ssw_ManUniqueAddConstraint( Ssw_Man_t * p, Vec_Ptr_t * vCommon, int f1, int
assert( Vec_PtrSize(vCommon) > 0 );
// generate the constraint
pTotal = Aig_ManConst0(p->pFrames);
- Vec_PtrForEachEntry( vCommon, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vCommon, pObj, i )
{
assert( Saig_ObjIsLo(p->pAig, pObj) );
pObj1New = Ssw_ObjFrame( p, pObj, f1 );
@@ -190,3 +193,5 @@ int Ssw_ManUniqueAddConstraint( Ssw_Man_t * p, Vec_Ptr_t * vCommon, int f1, int
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/tim/tim.c b/src/aig/tim/tim.c
index e565b01f..6b7e310c 100644
--- a/src/aig/tim/tim.c
+++ b/src/aig/tim/tim.c
@@ -28,6 +28,9 @@
#include "mem.h"
#include "tim.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -71,12 +74,12 @@ struct Tim_Obj_t_
float timeReq; // required time of the object
};
-static inline Tim_Obj_t * Tim_ManCi( Tim_Man_t * p, int i ) { assert( i < p->nCis ); return p->pCis + i; }
-static inline Tim_Obj_t * Tim_ManCo( Tim_Man_t * p, int i ) { assert( i < p->nCos ); return p->pCos + i; }
-static inline Tim_Box_t * Tim_ManBox( Tim_Man_t * p, int i ) { return Vec_PtrEntry(p->vBoxes, i); }
+static inline Tim_Obj_t * Tim_ManCi( Tim_Man_t * p, int i ) { assert( i < p->nCis ); return p->pCis + i; }
+static inline Tim_Obj_t * Tim_ManCo( Tim_Man_t * p, int i ) { assert( i < p->nCos ); return p->pCos + i; }
+static inline Tim_Box_t * Tim_ManBox( Tim_Man_t * p, int i ) { return (Tim_Box_t *)Vec_PtrEntry(p->vBoxes, i); }
-static inline Tim_Box_t * Tim_ManCiBox( Tim_Man_t * p, int i ) { return Tim_ManCi(p,i)->iObj2Box < 0 ? NULL : Vec_PtrEntry( p->vBoxes, Tim_ManCi(p,i)->iObj2Box ); }
-static inline Tim_Box_t * Tim_ManCoBox( Tim_Man_t * p, int i ) { return Tim_ManCo(p,i)->iObj2Box < 0 ? NULL : Vec_PtrEntry( p->vBoxes, Tim_ManCo(p,i)->iObj2Box ); }
+static inline Tim_Box_t * Tim_ManCiBox( Tim_Man_t * p, int i ) { return Tim_ManCi(p,i)->iObj2Box < 0 ? NULL : (Tim_Box_t *)Vec_PtrEntry( p->vBoxes, Tim_ManCi(p,i)->iObj2Box ); }
+static inline Tim_Box_t * Tim_ManCoBox( Tim_Man_t * p, int i ) { return Tim_ManCo(p,i)->iObj2Box < 0 ? NULL : (Tim_Box_t *)Vec_PtrEntry( p->vBoxes, Tim_ManCo(p,i)->iObj2Box ); }
static inline Tim_Obj_t * Tim_ManBoxInput( Tim_Man_t * p, Tim_Box_t * pBox, int i ) { assert( i < pBox->nInputs ); return p->pCos + pBox->Inouts[i]; }
static inline Tim_Obj_t * Tim_ManBoxOutput( Tim_Man_t * p, Tim_Box_t * pBox, int i ) { assert( i < pBox->nOutputs ); return p->pCis + pBox->Inouts[pBox->nInputs+i]; }
@@ -93,7 +96,7 @@ static inline Tim_Obj_t * Tim_ManBoxOutput( Tim_Man_t * p, Tim_Box_t * pBox, int
for ( i = 0; (i < (p)->nCos) && ((pObj) = (p)->pCos + i); i++ ) \
if ( pObj->iObj2Box >= 0 ) {} else
#define Tim_ManForEachBox( p, pBox, i ) \
- Vec_PtrForEachEntry( p->vBoxes, pBox, i )
+ Vec_PtrForEachEntry( Tim_Box_t *, p->vBoxes, pBox, i )
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
@@ -178,12 +181,25 @@ Tim_Man_t * Tim_ManDup( Tim_Man_t * p, int fDiscrete )
pNew->vDelayTables = Vec_PtrAlloc( 100 );
Tim_ManForEachBox( p, pBox, i )
{
+//printf( "%d %d\n", pBox->nInputs, pBox->nOutputs );
pDelayTableNew = ABC_ALLOC( float, pBox->nInputs * pBox->nOutputs );
Vec_PtrPush( pNew->vDelayTables, pDelayTableNew );
if ( fDiscrete )
{
for ( k = 0; k < pBox->nInputs * pBox->nOutputs; k++ )
pDelayTableNew[k] = 1.0; // modify here
+
+///// begin part of improved CIN/COUT propagation
+ for ( k = 0; k < pBox->nInputs; k++ ) // fill in the first row
+ pDelayTableNew[k] = 0.5;
+ for ( k = 0; k < pBox->nOutputs; k++ ) // fill in the first column
+ pDelayTableNew[k*pBox->nInputs] = 0.5;
+ pDelayTableNew[0] = 0.0; // fill in the first entry
+///// end part of improved CIN/COUT propagation
+
+ /// change
+// pDelayTableNew[0] = 0.0;
+ /// change
}
else
memcpy( pDelayTableNew, pBox->pDelayTable, sizeof(float) * pBox->nInputs * pBox->nOutputs );
@@ -278,7 +294,7 @@ void Tim_ManStop( Tim_Man_t * p )
int i;
if ( p->vDelayTables )
{
- Vec_PtrForEachEntry( p->vDelayTables, pTable, i )
+ Vec_PtrForEachEntry( float *, p->vDelayTables, pTable, i )
ABC_FREE( pTable );
Vec_PtrFree( p->vDelayTables );
}
@@ -300,6 +316,25 @@ void Tim_ManStop( Tim_Man_t * p )
SeeAlso []
***********************************************************************/
+void Tim_ManStopP( Tim_Man_t ** p )
+{
+ if ( *p == NULL )
+ return;
+ Tim_ManStop( *p );
+ *p = NULL;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Stops the timing manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
void Tim_ManPrint( Tim_Man_t * p )
{
Tim_Box_t * pBox;
@@ -547,11 +582,10 @@ void Tim_ManCreateBoxFirst( Tim_Man_t * p, int firstIn, int nIns, int firstOut,
{
Tim_Box_t * pBox;
int i;
+
pBox = (Tim_Box_t *)Mem_FlexEntryFetch( p->pMemObj, sizeof(Tim_Box_t) + sizeof(int) * (nIns+nOuts) );
memset( pBox, 0, sizeof(Tim_Box_t) );
pBox->iBox = Vec_PtrSize( p->vBoxes );
-//printf( "Creating box %d: First in = %d. (%d) First out = %d. (%d)\n", pBox->iBox,
-// firstIn, nIns, firstOut, nOuts );
Vec_PtrPush( p->vBoxes, pBox );
pBox->pDelayTable = pDelayTable;
pBox->nInputs = nIns;
@@ -570,6 +604,8 @@ void Tim_ManCreateBoxFirst( Tim_Man_t * p, int firstIn, int nIns, int firstOut,
p->pCis[firstOut+i].iObj2Box = pBox->iBox;
p->pCis[firstOut+i].iObj2Num = i;
}
+// if ( pBox->iBox < 50 )
+// printf( "%4d %4d %4d %4d \n", firstIn, nIns, firstOut, nOuts );
}
@@ -726,7 +762,10 @@ void Tim_ManSetCoRequiredAll( Tim_Man_t * p, float Delay )
Tim_Obj_t * pObj;
int i;
Tim_ManForEachCo( p, pObj, i )
+ {
Tim_ManSetCoRequired( p, i, Delay );
+//printf( "%d ", i );
+ }
}
@@ -873,7 +912,7 @@ int Tim_ManBoxForCo( Tim_Man_t * p, int iCo )
***********************************************************************/
int Tim_ManBoxInputFirst( Tim_Man_t * p, int iBox )
{
- Tim_Box_t * pBox = Vec_PtrEntry( p->vBoxes, iBox );
+ Tim_Box_t * pBox = (Tim_Box_t *)Vec_PtrEntry( p->vBoxes, iBox );
return pBox->Inouts[0];
}
@@ -890,7 +929,7 @@ int Tim_ManBoxInputFirst( Tim_Man_t * p, int iBox )
***********************************************************************/
int Tim_ManBoxOutputFirst( Tim_Man_t * p, int iBox )
{
- Tim_Box_t * pBox = Vec_PtrEntry( p->vBoxes, iBox );
+ Tim_Box_t * pBox = (Tim_Box_t *)Vec_PtrEntry( p->vBoxes, iBox );
return pBox->Inouts[pBox->nInputs];
}
@@ -907,7 +946,7 @@ int Tim_ManBoxOutputFirst( Tim_Man_t * p, int iBox )
***********************************************************************/
int Tim_ManBoxInputNum( Tim_Man_t * p, int iBox )
{
- Tim_Box_t * pBox = Vec_PtrEntry( p->vBoxes, iBox );
+ Tim_Box_t * pBox = (Tim_Box_t *)Vec_PtrEntry( p->vBoxes, iBox );
return pBox->nInputs;
}
@@ -924,13 +963,34 @@ int Tim_ManBoxInputNum( Tim_Man_t * p, int iBox )
***********************************************************************/
int Tim_ManBoxOutputNum( Tim_Man_t * p, int iBox )
{
- Tim_Box_t * pBox = Vec_PtrEntry( p->vBoxes, iBox );
+ Tim_Box_t * pBox = (Tim_Box_t *)Vec_PtrEntry( p->vBoxes, iBox );
return pBox->nOutputs;
}
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Tim_ManChangeForAdders( Tim_Man_t * p )
+{
+ Tim_Box_t * pBox;
+ int i;
+ Tim_ManForEachBox( p, pBox, i )
+ pBox->pDelayTable[0] = 0.0;
+}
+
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/aig/tim/tim.h b/src/aig/tim/tim.h
index bdb8e61e..2d52b7b1 100644
--- a/src/aig/tim/tim.h
+++ b/src/aig/tim/tim.h
@@ -21,6 +21,7 @@
#ifndef __TIM_H__
#define __TIM_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -29,9 +30,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -63,6 +65,7 @@ extern Tim_Man_t * Tim_ManDup( Tim_Man_t * p, int fDiscrete );
extern Tim_Man_t * Tim_ManDupUnit( Tim_Man_t * p );
extern Tim_Man_t * Tim_ManDupApprox( Tim_Man_t * p );
extern void Tim_ManStop( Tim_Man_t * p );
+extern void Tim_ManStopP( Tim_Man_t ** p );
extern void Tim_ManPrint( Tim_Man_t * p );
extern void Tim_ManTravIdDisable( Tim_Man_t * p );
extern void Tim_ManTravIdEnable( Tim_Man_t * p );
@@ -91,10 +94,13 @@ extern int Tim_ManBoxInputFirst( Tim_Man_t * p, int iBox );
extern int Tim_ManBoxOutputFirst( Tim_Man_t * p, int iBox );
extern int Tim_ManBoxInputNum( Tim_Man_t * p, int iBox );
extern int Tim_ManBoxOutputNum( Tim_Man_t * p, int iBox );
+extern void Tim_ManChangeForAdders( Tim_Man_t * p );
+
+
+
+ABC_NAMESPACE_HEADER_END
+
-#ifdef __cplusplus
-}
-#endif
#endif
diff --git a/src/base/abc/abc.h b/src/base/abc/abc.h
index 73a487e9..6dcb3881 100644
--- a/src/base/abc/abc.h
+++ b/src/base/abc/abc.h
@@ -21,6 +21,7 @@
#ifndef __ABC_H__
#define __ABC_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -31,10 +32,10 @@
#include <assert.h>
#include <time.h>
+#include "vec.h"
#include "cuddInt.h"
#include "hop.h"
#include "extra.h"
-#include "vec.h"
#include "stmm.h"
#include "nm.h"
@@ -42,9 +43,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
// network types
typedef enum {
@@ -109,15 +111,9 @@ typedef enum {
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
-//typedef int bool;
-#ifndef __cplusplus
-#ifndef bool
-#define bool int
-#endif
-#endif
-
typedef struct Abc_Lib_t_ Abc_Lib_t;
typedef struct Abc_Ntk_t_ Abc_Ntk_t;
+struct Abc_Obj_t_;
typedef struct Abc_Obj_t_ Abc_Obj_t;
typedef struct Abc_Aig_t_ Abc_Aig_t;
typedef struct Abc_ManTime_t_ Abc_ManTime_t;
@@ -152,7 +148,10 @@ struct Abc_Obj_t_ // 12 words
Vec_Int_t vFanins; // the array of fanins
Vec_Int_t vFanouts; // the array of fanouts
// miscellaneous
+ union {
void * pData; // the network specific data (SOP, BDD, gate, equiv class, etc)
+ int iData;
+ };
Abc_Obj_t * pNext; // the next pointer in the hash table
union { // temporary store for user's data
Abc_Obj_t * pCopy; // the copy of this object
@@ -178,9 +177,10 @@ struct Abc_Ntk_t_
Vec_Ptr_t * vCis; // the array of combinational inputs (PIs, latches)
Vec_Ptr_t * vCos; // the array of combinational outputs (POs, asserts, latches)
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 * vLtlProperties;
// the number of living objects
+ int nConstrs; // the number of constraints (model checking only)
int nObjs; // the number of live objs
int nObjCounts[ABC_OBJ_NUMBER]; // the number of objects by type
// the backup network and the step number
@@ -202,7 +202,8 @@ struct Abc_Ntk_t_
Vec_Int_t * vLevelsR; // level in the reverse topological order (for AIGs)
Vec_Ptr_t * vSupps; // CO support information
int * pModel; // counter-example (for miters)
- void * pSeqModel; // counter-example (for sequential miters)
+ Abc_Cex_t * pSeqModel; // counter-example (for sequential miters)
+ Vec_Ptr_t * pSeqModelVec; // vector of counter-examples (for sequential miters)
Abc_Ntk_t * pExdc; // the EXDC network (if given)
void * pExcare; // the EXDC network (if given)
void * pData; // misc
@@ -230,8 +231,10 @@ struct Abc_Lib_t_
////////////////////////////////////////////////////////////////////////
// transforming floats into ints and back
-static inline int Abc_Float2Int( float Val ) { return *((int *)&Val); }
-static inline float Abc_Int2Float( int Num ) { return *((float *)&Num); }
+//static inline int Abc_Float2Int( float Val ) { return *((int *)&Val); }
+//static inline float Abc_Int2Float( int Num ) { return *((float *)&Num); }
+static inline int Abc_Float2Int( float Val ) { union { int x; float y; } v; v.y = Val; return v.x; }
+static inline float Abc_Int2Float( int Num ) { union { int x; float y; } v; v.x = Num; return v.y; }
static inline int Abc_BitWordNum( int nBits ) { return (nBits>>5) + ((nBits&31) > 0); }
static inline int Abc_TruthWordNum( int nVars ) { return nVars <= 5 ? 1 : (1 << (nVars - 5)); }
static inline int Abc_InfoHasBit( unsigned * p, int i ) { return (p[(i)>>5] & (1<<((i) & 31))) > 0; }
@@ -252,25 +255,25 @@ static inline int Abc_InfoIsOrOne( unsigned * p, unsigned * q, int nWord
static inline int Abc_InfoIsOrOne3( unsigned * p, unsigned * q, unsigned * r, int nWords ){ int i; for ( i = nWords - 1; i >= 0; i-- ) if ( ~(p[i] | q[i] | r[i]) ) return 0; return 1; }
// checking the network type
-static inline bool Abc_NtkIsNetlist( Abc_Ntk_t * pNtk ) { return pNtk->ntkType == ABC_NTK_NETLIST; }
-static inline bool Abc_NtkIsLogic( Abc_Ntk_t * pNtk ) { return pNtk->ntkType == ABC_NTK_LOGIC; }
-static inline bool Abc_NtkIsStrash( Abc_Ntk_t * pNtk ) { return pNtk->ntkType == ABC_NTK_STRASH; }
-
-static inline bool Abc_NtkHasSop( Abc_Ntk_t * pNtk ) { return pNtk->ntkFunc == ABC_FUNC_SOP; }
-static inline bool Abc_NtkHasBdd( Abc_Ntk_t * pNtk ) { return pNtk->ntkFunc == ABC_FUNC_BDD; }
-static inline bool Abc_NtkHasAig( Abc_Ntk_t * pNtk ) { return pNtk->ntkFunc == ABC_FUNC_AIG; }
-static inline bool Abc_NtkHasMapping( Abc_Ntk_t * pNtk ) { return pNtk->ntkFunc == ABC_FUNC_MAP; }
-static inline bool Abc_NtkHasBlifMv( Abc_Ntk_t * pNtk ) { return pNtk->ntkFunc == ABC_FUNC_BLIFMV; }
-static inline bool Abc_NtkHasBlackbox( Abc_Ntk_t * pNtk ) { return pNtk->ntkFunc == ABC_FUNC_BLACKBOX; }
-
-static inline bool Abc_NtkIsSopNetlist( Abc_Ntk_t * pNtk ) { return pNtk->ntkFunc == ABC_FUNC_SOP && pNtk->ntkType == ABC_NTK_NETLIST; }
-static inline bool Abc_NtkIsAigNetlist( Abc_Ntk_t * pNtk ) { return pNtk->ntkFunc == ABC_FUNC_AIG && pNtk->ntkType == ABC_NTK_NETLIST; }
-static inline bool Abc_NtkIsMappedNetlist( Abc_Ntk_t * pNtk ) { return pNtk->ntkFunc == ABC_FUNC_MAP && pNtk->ntkType == ABC_NTK_NETLIST; }
-static inline bool Abc_NtkIsBlifMvNetlist( Abc_Ntk_t * pNtk ) { return pNtk->ntkFunc == ABC_FUNC_BLIFMV && pNtk->ntkType == ABC_NTK_NETLIST; }
-static inline bool Abc_NtkIsSopLogic( Abc_Ntk_t * pNtk ) { return pNtk->ntkFunc == ABC_FUNC_SOP && pNtk->ntkType == ABC_NTK_LOGIC ; }
-static inline bool Abc_NtkIsBddLogic( Abc_Ntk_t * pNtk ) { return pNtk->ntkFunc == ABC_FUNC_BDD && pNtk->ntkType == ABC_NTK_LOGIC ; }
-static inline bool Abc_NtkIsAigLogic( Abc_Ntk_t * pNtk ) { return pNtk->ntkFunc == ABC_FUNC_AIG && pNtk->ntkType == ABC_NTK_LOGIC ; }
-static inline bool Abc_NtkIsMappedLogic( Abc_Ntk_t * pNtk ) { return pNtk->ntkFunc == ABC_FUNC_MAP && pNtk->ntkType == ABC_NTK_LOGIC ; }
+static inline int Abc_NtkIsNetlist( Abc_Ntk_t * pNtk ) { return pNtk->ntkType == ABC_NTK_NETLIST; }
+static inline int Abc_NtkIsLogic( Abc_Ntk_t * pNtk ) { return pNtk->ntkType == ABC_NTK_LOGIC; }
+static inline int Abc_NtkIsStrash( Abc_Ntk_t * pNtk ) { return pNtk->ntkType == ABC_NTK_STRASH; }
+
+static inline int Abc_NtkHasSop( Abc_Ntk_t * pNtk ) { return pNtk->ntkFunc == ABC_FUNC_SOP; }
+static inline int Abc_NtkHasBdd( Abc_Ntk_t * pNtk ) { return pNtk->ntkFunc == ABC_FUNC_BDD; }
+static inline int Abc_NtkHasAig( Abc_Ntk_t * pNtk ) { return pNtk->ntkFunc == ABC_FUNC_AIG; }
+static inline int Abc_NtkHasMapping( Abc_Ntk_t * pNtk ) { return pNtk->ntkFunc == ABC_FUNC_MAP; }
+static inline int Abc_NtkHasBlifMv( Abc_Ntk_t * pNtk ) { return pNtk->ntkFunc == ABC_FUNC_BLIFMV; }
+static inline int Abc_NtkHasBlackbox( Abc_Ntk_t * pNtk ) { return pNtk->ntkFunc == ABC_FUNC_BLACKBOX; }
+
+static inline int Abc_NtkIsSopNetlist( Abc_Ntk_t * pNtk ) { return pNtk->ntkFunc == ABC_FUNC_SOP && pNtk->ntkType == ABC_NTK_NETLIST; }
+static inline int Abc_NtkIsAigNetlist( Abc_Ntk_t * pNtk ) { return pNtk->ntkFunc == ABC_FUNC_AIG && pNtk->ntkType == ABC_NTK_NETLIST; }
+static inline int Abc_NtkIsMappedNetlist( Abc_Ntk_t * pNtk ) { return pNtk->ntkFunc == ABC_FUNC_MAP && pNtk->ntkType == ABC_NTK_NETLIST; }
+static inline int Abc_NtkIsBlifMvNetlist( Abc_Ntk_t * pNtk ) { return pNtk->ntkFunc == ABC_FUNC_BLIFMV && pNtk->ntkType == ABC_NTK_NETLIST; }
+static inline int Abc_NtkIsSopLogic( Abc_Ntk_t * pNtk ) { return pNtk->ntkFunc == ABC_FUNC_SOP && pNtk->ntkType == ABC_NTK_LOGIC ; }
+static inline int Abc_NtkIsBddLogic( Abc_Ntk_t * pNtk ) { return pNtk->ntkFunc == ABC_FUNC_BDD && pNtk->ntkType == ABC_NTK_LOGIC ; }
+static inline int Abc_NtkIsAigLogic( Abc_Ntk_t * pNtk ) { return pNtk->ntkFunc == ABC_FUNC_AIG && pNtk->ntkType == ABC_NTK_LOGIC ; }
+static inline int Abc_NtkIsMappedLogic( Abc_Ntk_t * pNtk ) { return pNtk->ntkFunc == ABC_FUNC_MAP && pNtk->ntkType == ABC_NTK_LOGIC ; }
// reading data members of the network
static inline char * Abc_NtkName( Abc_Ntk_t * pNtk ) { return pNtk->pName; }
@@ -293,7 +296,6 @@ static inline int Abc_NtkPiNum( Abc_Ntk_t * pNtk ) { return Ve
static inline int Abc_NtkPoNum( Abc_Ntk_t * pNtk ) { return Vec_PtrSize(pNtk->vPos); }
static inline int Abc_NtkCiNum( Abc_Ntk_t * pNtk ) { return Vec_PtrSize(pNtk->vCis); }
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_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]; }
@@ -302,8 +304,9 @@ static inline int Abc_NtkNodeNum( Abc_Ntk_t * pNtk ) { return pN
static inline int Abc_NtkLatchNum( Abc_Ntk_t * pNtk ) { return pNtk->nObjCounts[ABC_OBJ_LATCH]; }
static inline int Abc_NtkWhiteboxNum( Abc_Ntk_t * pNtk ) { return pNtk->nObjCounts[ABC_OBJ_WHITEBOX]; }
static inline int Abc_NtkBlackboxNum( Abc_Ntk_t * pNtk ) { return pNtk->nObjCounts[ABC_OBJ_BLACKBOX]; }
-static inline bool Abc_NtkIsComb( Abc_Ntk_t * pNtk ) { return Abc_NtkLatchNum(pNtk) == 0; }
-static inline bool Abc_NtkHasOnlyLatchBoxes(Abc_Ntk_t * pNtk ){ return Abc_NtkLatchNum(pNtk) == Abc_NtkBoxNum(pNtk); }
+static inline int Abc_NtkIsComb( Abc_Ntk_t * pNtk ) { return Abc_NtkLatchNum(pNtk) == 0; }
+static inline int Abc_NtkHasOnlyLatchBoxes(Abc_Ntk_t * pNtk ){ return Abc_NtkLatchNum(pNtk) == Abc_NtkBoxNum(pNtk); }
+static inline int Abc_NtkConstrNum( Abc_Ntk_t * pNtk ) { return pNtk->nConstrs; }
// creating simple objects
extern ABC_DLL Abc_Obj_t * Abc_NtkCreateObj( Abc_Ntk_t * pNtk, Abc_ObjType_t Type );
@@ -324,11 +327,10 @@ static inline Abc_Obj_t * Abc_NtkPi( Abc_Ntk_t * pNtk, int i ) { return (A
static inline Abc_Obj_t * Abc_NtkPo( Abc_Ntk_t * pNtk, int i ) { return (Abc_Obj_t *)Vec_PtrEntry( pNtk->vPos, i ); }
static inline Abc_Obj_t * Abc_NtkCi( Abc_Ntk_t * pNtk, int i ) { return (Abc_Obj_t *)Vec_PtrEntry( pNtk->vCis, i ); }
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 ); }
// working with complemented attributes of objects
-static inline bool Abc_ObjIsComplement( Abc_Obj_t * p ) { return (bool)((ABC_PTRUINT_T)p & (ABC_PTRUINT_T)01); }
+static inline int Abc_ObjIsComplement( Abc_Obj_t * p ) { return (int )((ABC_PTRUINT_T)p & (ABC_PTRUINT_T)01); }
static inline Abc_Obj_t * Abc_ObjRegular( Abc_Obj_t * p ) { return (Abc_Obj_t *)((ABC_PTRUINT_T)p & ~(ABC_PTRUINT_T)01); }
static inline Abc_Obj_t * Abc_ObjNot( Abc_Obj_t * p ) { return (Abc_Obj_t *)((ABC_PTRUINT_T)p ^ (ABC_PTRUINT_T)01); }
static inline Abc_Obj_t * Abc_ObjNotCond( Abc_Obj_t * p, int c ) { return (Abc_Obj_t *)((ABC_PTRUINT_T)p ^ (ABC_PTRUINT_T)(c!=0)); }
@@ -352,21 +354,21 @@ static inline void Abc_ObjSetCopy( Abc_Obj_t * pObj, Abc_Obj_t * pCopy )
static inline void Abc_ObjSetData( Abc_Obj_t * pObj, void * pData ) { pObj->pData = pData; }
// checking the object type
-static inline bool Abc_ObjIsPio( Abc_Obj_t * pObj ) { return pObj->Type == ABC_OBJ_PIO; }
-static inline bool Abc_ObjIsPi( Abc_Obj_t * pObj ) { return pObj->Type == ABC_OBJ_PI; }
-static inline bool Abc_ObjIsPo( Abc_Obj_t * pObj ) { return pObj->Type == ABC_OBJ_PO; }
-static inline bool Abc_ObjIsBi( Abc_Obj_t * pObj ) { return pObj->Type == ABC_OBJ_BI; }
-static inline bool Abc_ObjIsBo( Abc_Obj_t * pObj ) { return pObj->Type == ABC_OBJ_BO; }
-static inline bool Abc_ObjIsAssert( Abc_Obj_t * pObj ) { return pObj->Type == ABC_OBJ_ASSERT; }
-static inline bool Abc_ObjIsCi( Abc_Obj_t * pObj ) { return pObj->Type == ABC_OBJ_PI || pObj->Type == ABC_OBJ_BO; }
-static inline bool Abc_ObjIsCo( Abc_Obj_t * pObj ) { return pObj->Type == ABC_OBJ_PO || pObj->Type == ABC_OBJ_BI || pObj->Type == ABC_OBJ_ASSERT; }
-static inline bool Abc_ObjIsTerm( Abc_Obj_t * pObj ) { return Abc_ObjIsCi(pObj) || Abc_ObjIsCo(pObj); }
-static inline bool Abc_ObjIsNet( Abc_Obj_t * pObj ) { return pObj->Type == ABC_OBJ_NET; }
-static inline bool Abc_ObjIsNode( Abc_Obj_t * pObj ) { return pObj->Type == ABC_OBJ_NODE; }
-static inline bool Abc_ObjIsLatch( Abc_Obj_t * pObj ) { return pObj->Type == ABC_OBJ_LATCH; }
-static inline bool Abc_ObjIsBox( Abc_Obj_t * pObj ) { return pObj->Type == ABC_OBJ_LATCH || pObj->Type == ABC_OBJ_WHITEBOX || pObj->Type == ABC_OBJ_BLACKBOX; }
-static inline bool Abc_ObjIsWhitebox( Abc_Obj_t * pObj ) { return pObj->Type == ABC_OBJ_WHITEBOX;}
-static inline bool Abc_ObjIsBlackbox( Abc_Obj_t * pObj ) { return pObj->Type == ABC_OBJ_BLACKBOX;}
+static inline int Abc_ObjIsPio( Abc_Obj_t * pObj ) { return pObj->Type == ABC_OBJ_PIO; }
+static inline int Abc_ObjIsPi( Abc_Obj_t * pObj ) { return pObj->Type == ABC_OBJ_PI; }
+static inline int Abc_ObjIsPo( Abc_Obj_t * pObj ) { return pObj->Type == ABC_OBJ_PO; }
+static inline int Abc_ObjIsBi( Abc_Obj_t * pObj ) { return pObj->Type == ABC_OBJ_BI; }
+static inline int Abc_ObjIsBo( Abc_Obj_t * pObj ) { return pObj->Type == ABC_OBJ_BO; }
+static inline int Abc_ObjIsAssert( Abc_Obj_t * pObj ) { return pObj->Type == ABC_OBJ_ASSERT; }
+static inline int Abc_ObjIsCi( Abc_Obj_t * pObj ) { return pObj->Type == ABC_OBJ_PI || pObj->Type == ABC_OBJ_BO; }
+static inline int Abc_ObjIsCo( Abc_Obj_t * pObj ) { return pObj->Type == ABC_OBJ_PO || pObj->Type == ABC_OBJ_BI || pObj->Type == ABC_OBJ_ASSERT; }
+static inline int Abc_ObjIsTerm( Abc_Obj_t * pObj ) { return Abc_ObjIsCi(pObj) || Abc_ObjIsCo(pObj); }
+static inline int Abc_ObjIsNet( Abc_Obj_t * pObj ) { return pObj->Type == ABC_OBJ_NET; }
+static inline int Abc_ObjIsNode( Abc_Obj_t * pObj ) { return pObj->Type == ABC_OBJ_NODE; }
+static inline int Abc_ObjIsLatch( Abc_Obj_t * pObj ) { return pObj->Type == ABC_OBJ_LATCH; }
+static inline int Abc_ObjIsBox( Abc_Obj_t * pObj ) { return pObj->Type == ABC_OBJ_LATCH || pObj->Type == ABC_OBJ_WHITEBOX || pObj->Type == ABC_OBJ_BLACKBOX; }
+static inline int Abc_ObjIsWhitebox( Abc_Obj_t * pObj ) { return pObj->Type == ABC_OBJ_WHITEBOX;}
+static inline int Abc_ObjIsBlackbox( Abc_Obj_t * pObj ) { return pObj->Type == ABC_OBJ_BLACKBOX;}
static inline void Abc_ObjBlackboxToWhitebox( Abc_Obj_t * pObj ) { assert( Abc_ObjIsBlackbox(pObj) ); pObj->Type = ABC_OBJ_WHITEBOX; pObj->pNtk->nObjCounts[ABC_OBJ_BLACKBOX]--; pObj->pNtk->nObjCounts[ABC_OBJ_WHITEBOX]++; }
// working with fanin/fanout edges
@@ -383,9 +385,9 @@ static inline Abc_Obj_t * Abc_ObjFanin0( Abc_Obj_t * pObj ) { return (A
static inline Abc_Obj_t * Abc_ObjFanin1( Abc_Obj_t * pObj ) { return (Abc_Obj_t *)pObj->pNtk->vObjs->pArray[ pObj->vFanins.pArray[1] ]; }
static inline Abc_Obj_t * Abc_ObjFanin0Ntk( Abc_Obj_t * pObj ) { return (Abc_NtkIsNetlist(pObj->pNtk)? Abc_ObjFanin0(pObj) : pObj); }
static inline Abc_Obj_t * Abc_ObjFanout0Ntk( Abc_Obj_t * pObj ) { return (Abc_NtkIsNetlist(pObj->pNtk)? Abc_ObjFanout0(pObj) : pObj); }
-static inline bool Abc_ObjFaninC0( Abc_Obj_t * pObj ) { return pObj->fCompl0; }
-static inline bool Abc_ObjFaninC1( Abc_Obj_t * pObj ) { return pObj->fCompl1; }
-static inline bool Abc_ObjFaninC( Abc_Obj_t * pObj, int i ) { assert( i >=0 && i < 2 ); return i? pObj->fCompl1 : pObj->fCompl0; }
+static inline int Abc_ObjFaninC0( Abc_Obj_t * pObj ) { return pObj->fCompl0; }
+static inline int Abc_ObjFaninC1( Abc_Obj_t * pObj ) { return pObj->fCompl1; }
+static inline int Abc_ObjFaninC( Abc_Obj_t * pObj, int i ) { assert( i >=0 && i < 2 ); return i? pObj->fCompl1 : pObj->fCompl0; }
static inline void Abc_ObjSetFaninC( Abc_Obj_t * pObj, int i ){ assert( i >=0 && i < 2 ); if ( i ) pObj->fCompl1 = 1; else pObj->fCompl0 = 1; }
static inline void Abc_ObjXorFaninC( Abc_Obj_t * pObj, int i ){ assert( i >=0 && i < 2 ); if ( i ) pObj->fCompl1^= 1; else pObj->fCompl0^= 1; }
static inline Abc_Obj_t * Abc_ObjChild( Abc_Obj_t * pObj, int i ) { return Abc_ObjNotCond( Abc_ObjFanin(pObj,i), Abc_ObjFaninC(pObj,i) );}
@@ -400,9 +402,9 @@ static inline Abc_Obj_t * Abc_ObjChild1Data( Abc_Obj_t * pObj ) { return Ab
//static inline Hop_Obj_t * Abc_ObjChild1Equiv( Abc_Obj_t * pObj ) { return Hop_NotCond( Abc_ObjFanin1(pObj)->pEquiv, Abc_ObjFaninC1(pObj) ); }
// checking the AIG node types
-static inline bool Abc_AigNodeIsConst( Abc_Obj_t * pNode ) { assert(Abc_NtkIsStrash(Abc_ObjRegular(pNode)->pNtk)); return Abc_ObjRegular(pNode)->Type == ABC_OBJ_CONST1; }
-static inline bool Abc_AigNodeIsAnd( Abc_Obj_t * pNode ) { assert(!Abc_ObjIsComplement(pNode)); assert(Abc_NtkIsStrash(pNode->pNtk)); return Abc_ObjFaninNum(pNode) == 2; }
-static inline bool Abc_AigNodeIsChoice( Abc_Obj_t * pNode ) { assert(!Abc_ObjIsComplement(pNode)); assert(Abc_NtkIsStrash(pNode->pNtk)); return pNode->pData != NULL && Abc_ObjFanoutNum(pNode) > 0; }
+static inline int Abc_AigNodeIsConst( Abc_Obj_t * pNode ) { assert(Abc_NtkIsStrash(Abc_ObjRegular(pNode)->pNtk)); return Abc_ObjRegular(pNode)->Type == ABC_OBJ_CONST1; }
+static inline int Abc_AigNodeIsAnd( Abc_Obj_t * pNode ) { assert(!Abc_ObjIsComplement(pNode)); assert(Abc_NtkIsStrash(pNode->pNtk)); return Abc_ObjFaninNum(pNode) == 2; }
+static inline int Abc_AigNodeIsChoice( Abc_Obj_t * pNode ) { assert(!Abc_ObjIsComplement(pNode)); assert(Abc_NtkIsStrash(pNode->pNtk)); return pNode->pData != NULL && Abc_ObjFanoutNum(pNode) > 0; }
// handling persistent nodes
static inline int Abc_NodeIsPersistant( Abc_Obj_t * pNode ) { assert( Abc_AigNodeIsAnd(pNode) ); return pNode->fPersist; }
@@ -413,18 +415,18 @@ static inline void Abc_NodeClearPersistant( Abc_Obj_t * pNode ) { assert(
static inline void Abc_NodeSetTravId( Abc_Obj_t * pNode, int TravId ) { pNode->TravId = TravId; }
static inline void Abc_NodeSetTravIdCurrent( Abc_Obj_t * pNode ) { pNode->TravId = pNode->pNtk->nTravIds; }
static inline void Abc_NodeSetTravIdPrevious( Abc_Obj_t * pNode ) { pNode->TravId = pNode->pNtk->nTravIds - 1; }
-static inline bool Abc_NodeIsTravIdCurrent( Abc_Obj_t * pNode ) { return (bool)(pNode->TravId == pNode->pNtk->nTravIds); }
-static inline bool Abc_NodeIsTravIdPrevious( Abc_Obj_t * pNode ) { return (bool)(pNode->TravId == pNode->pNtk->nTravIds - 1); }
+static inline int Abc_NodeIsTravIdCurrent( Abc_Obj_t * pNode ) { return (int )(pNode->TravId == pNode->pNtk->nTravIds); }
+static inline int Abc_NodeIsTravIdPrevious( Abc_Obj_t * pNode ) { return (int )(pNode->TravId == pNode->pNtk->nTravIds - 1); }
// checking initial state of the latches
static inline void Abc_LatchSetInitNone( Abc_Obj_t * pLatch ) { assert(Abc_ObjIsLatch(pLatch)); pLatch->pData = (void *)ABC_INIT_NONE; }
static inline void Abc_LatchSetInit0( Abc_Obj_t * pLatch ) { assert(Abc_ObjIsLatch(pLatch)); pLatch->pData = (void *)ABC_INIT_ZERO; }
static inline void Abc_LatchSetInit1( Abc_Obj_t * pLatch ) { assert(Abc_ObjIsLatch(pLatch)); pLatch->pData = (void *)ABC_INIT_ONE; }
static inline void Abc_LatchSetInitDc( Abc_Obj_t * pLatch ) { assert(Abc_ObjIsLatch(pLatch)); pLatch->pData = (void *)ABC_INIT_DC; }
-static inline bool Abc_LatchIsInitNone( Abc_Obj_t * pLatch ) { assert(Abc_ObjIsLatch(pLatch)); return pLatch->pData == (void *)ABC_INIT_NONE; }
-static inline bool Abc_LatchIsInit0( Abc_Obj_t * pLatch ) { assert(Abc_ObjIsLatch(pLatch)); return pLatch->pData == (void *)ABC_INIT_ZERO; }
-static inline bool Abc_LatchIsInit1( Abc_Obj_t * pLatch ) { assert(Abc_ObjIsLatch(pLatch)); return pLatch->pData == (void *)ABC_INIT_ONE; }
-static inline bool Abc_LatchIsInitDc( Abc_Obj_t * pLatch ) { assert(Abc_ObjIsLatch(pLatch)); return pLatch->pData == (void *)ABC_INIT_DC; }
+static inline int Abc_LatchIsInitNone( Abc_Obj_t * pLatch ) { assert(Abc_ObjIsLatch(pLatch)); return pLatch->pData == (void *)ABC_INIT_NONE; }
+static inline int Abc_LatchIsInit0( Abc_Obj_t * pLatch ) { assert(Abc_ObjIsLatch(pLatch)); return pLatch->pData == (void *)ABC_INIT_ZERO; }
+static inline int Abc_LatchIsInit1( Abc_Obj_t * pLatch ) { assert(Abc_ObjIsLatch(pLatch)); return pLatch->pData == (void *)ABC_INIT_ONE; }
+static inline int 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)(ABC_PTRINT_T)pLatch->pData; }
// global BDDs of the nodes
@@ -488,8 +490,6 @@ static inline void Abc_ObjSetMvVar( Abc_Obj_t * pObj, void * pV) { Vec_At
for ( i = 0; (i < Abc_NtkPoNum(pNtk)) && (((pPo) = Abc_NtkPo(pNtk, i)), 1); i++ )
#define Abc_NtkForEachCo( pNtk, pCo, i ) \
for ( i = 0; (i < Abc_NtkCoNum(pNtk)) && (((pCo) = Abc_NtkCo(pNtk, i)), 1); i++ )
-#define Abc_NtkForEachAssert( pNtk, pObj, i ) \
- for ( i = 0; (i < Vec_PtrSize((pNtk)->vAsserts)) && (((pObj) = Abc_NtkAssert(pNtk, i)), 1); i++ )
// fanin and fanouts
#define Abc_ObjForEachFanin( pObj, pFanin, i ) \
for ( i = 0; (i < Abc_ObjFaninNum(pObj)) && (((pFanin) = Abc_ObjFanin(pObj, i)), 1); i++ )
@@ -510,7 +510,7 @@ static inline void Abc_ObjSetMvVar( Abc_Obj_t * pObj, void * pV) { Vec_At
extern ABC_DLL Abc_Aig_t * Abc_AigAlloc( Abc_Ntk_t * pNtk );
extern ABC_DLL void Abc_AigFree( Abc_Aig_t * pMan );
extern ABC_DLL int Abc_AigCleanup( Abc_Aig_t * pMan );
-extern ABC_DLL bool Abc_AigCheck( Abc_Aig_t * pMan );
+extern ABC_DLL int Abc_AigCheck( Abc_Aig_t * pMan );
extern ABC_DLL int Abc_AigLevel( Abc_Ntk_t * pNtk );
extern ABC_DLL Abc_Obj_t * Abc_AigConst1( Abc_Ntk_t * pNtk );
extern ABC_DLL Abc_Obj_t * Abc_AigAnd( Abc_Aig_t * pMan, Abc_Obj_t * p0, Abc_Obj_t * p1 );
@@ -521,13 +521,13 @@ extern ABC_DLL Abc_Obj_t * Abc_AigOr( Abc_Aig_t * pMan, Abc_Obj_t * p0, A
extern ABC_DLL Abc_Obj_t * Abc_AigXor( Abc_Aig_t * pMan, Abc_Obj_t * p0, Abc_Obj_t * p1 );
extern ABC_DLL Abc_Obj_t * Abc_AigMux( Abc_Aig_t * pMan, Abc_Obj_t * pC, Abc_Obj_t * p1, Abc_Obj_t * p0 );
extern ABC_DLL Abc_Obj_t * Abc_AigMiter( Abc_Aig_t * pMan, Vec_Ptr_t * vPairs, int fImplic );
-extern ABC_DLL void Abc_AigReplace( Abc_Aig_t * pMan, Abc_Obj_t * pOld, Abc_Obj_t * pNew, bool fUpdateLevel );
+extern ABC_DLL void Abc_AigReplace( Abc_Aig_t * pMan, Abc_Obj_t * pOld, Abc_Obj_t * pNew, int fUpdateLevel );
extern ABC_DLL void Abc_AigDeleteNode( Abc_Aig_t * pMan, Abc_Obj_t * pOld );
extern ABC_DLL void Abc_AigRehash( Abc_Aig_t * pMan );
-extern ABC_DLL bool Abc_AigNodeHasComplFanoutEdge( Abc_Obj_t * pNode );
-extern ABC_DLL bool Abc_AigNodeHasComplFanoutEdgeTrav( Abc_Obj_t * pNode );
+extern ABC_DLL int Abc_AigNodeHasComplFanoutEdge( Abc_Obj_t * pNode );
+extern ABC_DLL int Abc_AigNodeHasComplFanoutEdgeTrav( Abc_Obj_t * pNode );
extern ABC_DLL void Abc_AigPrintNode( Abc_Obj_t * pNode );
-extern ABC_DLL bool Abc_AigNodeIsAcyclic( Abc_Obj_t * pNode, Abc_Obj_t * pRoot );
+extern ABC_DLL int Abc_AigNodeIsAcyclic( Abc_Obj_t * pNode, Abc_Obj_t * pRoot );
extern ABC_DLL void Abc_AigCheckFaninOrder( Abc_Aig_t * pMan );
extern ABC_DLL void Abc_AigSetNodePhases( Abc_Ntk_t * pNtk );
extern ABC_DLL Vec_Ptr_t * Abc_AigUpdateStart( Abc_Aig_t * pMan, Vec_Ptr_t ** pvUpdatedNets );
@@ -545,13 +545,13 @@ extern ABC_DLL int Abc_NtkConvertToBlifMv( Abc_Ntk_t * pNtk );
extern ABC_DLL char * Abc_NodeConvertSopToMvSop( int nVars, Vec_Int_t * vSop0, Vec_Int_t * vSop1 );
extern ABC_DLL int Abc_NodeEvalMvCost( int nVars, Vec_Int_t * vSop0, Vec_Int_t * vSop1 );
/*=== abcBalance.c ==========================================================*/
-extern ABC_DLL Abc_Ntk_t * Abc_NtkBalance( Abc_Ntk_t * pNtk, bool fDuplicate, bool fSelective, bool fUpdateLevel );
+extern ABC_DLL Abc_Ntk_t * Abc_NtkBalance( Abc_Ntk_t * pNtk, int fDuplicate, int fSelective, int fUpdateLevel );
/*=== abcCheck.c ==========================================================*/
-extern ABC_DLL bool Abc_NtkCheck( Abc_Ntk_t * pNtk );
-extern ABC_DLL bool Abc_NtkCheckRead( Abc_Ntk_t * pNtk );
-extern ABC_DLL bool Abc_NtkDoCheck( Abc_Ntk_t * pNtk );
-extern ABC_DLL bool Abc_NtkCheckObj( Abc_Ntk_t * pNtk, Abc_Obj_t * pObj );
-extern ABC_DLL bool Abc_NtkCompareSignals( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fOnlyPis, int fComb );
+extern ABC_DLL int Abc_NtkCheck( Abc_Ntk_t * pNtk );
+extern ABC_DLL int Abc_NtkCheckRead( Abc_Ntk_t * pNtk );
+extern ABC_DLL int Abc_NtkDoCheck( Abc_Ntk_t * pNtk );
+extern ABC_DLL int Abc_NtkCheckObj( Abc_Ntk_t * pNtk, Abc_Obj_t * pObj );
+extern ABC_DLL int Abc_NtkCompareSignals( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fOnlyPis, int fComb );
extern ABC_DLL int Abc_NtkIsAcyclicHierarchy( Abc_Ntk_t * pNtk );
extern ABC_DLL int Abc_NtkCheckUniqueCiNames( Abc_Ntk_t * pNtk );
extern ABC_DLL int Abc_NtkCheckUniqueCoNames( Abc_Ntk_t * pNtk );
@@ -564,6 +564,9 @@ extern ABC_DLL void * Abc_NodeGetCuts( void * p, Abc_Obj_t * pObj, i
extern ABC_DLL void Abc_NodeGetCutsSeq( void * p, Abc_Obj_t * pObj, int fFirst );
extern ABC_DLL void * Abc_NodeReadCuts( void * p, Abc_Obj_t * pObj );
extern ABC_DLL void Abc_NodeFreeCuts( void * p, Abc_Obj_t * pObj );
+/*=== abcDar.c ============================================================*/
+extern ABC_DLL int Abc_NtkPhaseFrameNum( Abc_Ntk_t * pNtk );
+extern ABC_DLL int Abc_NtkDarPrintCone( Abc_Ntk_t * pNtk );
/*=== abcDelay.c ==========================================================*/
extern ABC_DLL float Abc_NtkDelayTraceLut( Abc_Ntk_t * pNtk, int fUseLutLib );
/*=== abcDfs.c ==========================================================*/
@@ -577,15 +580,15 @@ extern ABC_DLL Vec_Ptr_t * Abc_NtkDfsSeqReverse( Abc_Ntk_t * pNtk );
extern ABC_DLL Vec_Ptr_t * Abc_NtkDfsIter( Abc_Ntk_t * pNtk, int fCollectAll );
extern ABC_DLL Vec_Ptr_t * Abc_NtkDfsIterNodes( Abc_Ntk_t * pNtk, Vec_Ptr_t * vRoots );
extern ABC_DLL Vec_Ptr_t * Abc_NtkDfsHie( Abc_Ntk_t * pNtk, int fCollectAll );
-extern ABC_DLL bool Abc_NtkIsDfsOrdered( Abc_Ntk_t * pNtk );
+extern ABC_DLL int Abc_NtkIsDfsOrdered( Abc_Ntk_t * pNtk );
extern ABC_DLL Vec_Ptr_t * Abc_NtkSupport( Abc_Ntk_t * pNtk );
extern ABC_DLL Vec_Ptr_t * Abc_NtkNodeSupport( Abc_Ntk_t * pNtk, Abc_Obj_t ** ppNodes, int nNodes );
extern ABC_DLL Vec_Ptr_t * Abc_AigDfs( Abc_Ntk_t * pNtk, int fCollectAll, int fCollectCos );
-extern ABC_DLL Vec_Vec_t * Abc_DfsLevelized( Abc_Obj_t * pNode, bool fTfi );
+extern ABC_DLL Vec_Vec_t * Abc_DfsLevelized( Abc_Obj_t * pNode, int fTfi );
extern ABC_DLL Vec_Vec_t * Abc_NtkLevelize( Abc_Ntk_t * pNtk );
extern ABC_DLL int Abc_NtkLevel( Abc_Ntk_t * pNtk );
extern ABC_DLL int Abc_NtkLevelReverse( Abc_Ntk_t * pNtk );
-extern ABC_DLL bool Abc_NtkIsAcyclic( Abc_Ntk_t * pNtk );
+extern ABC_DLL int Abc_NtkIsAcyclic( Abc_Ntk_t * pNtk );
extern ABC_DLL Vec_Ptr_t * Abc_AigGetLevelizedOrder( Abc_Ntk_t * pNtk, int fCollectCis );
/*=== abcFanio.c ==========================================================*/
extern ABC_DLL void Abc_ObjAddFanin( Abc_Obj_t * pObj, Abc_Obj_t * pFanin );
@@ -626,7 +629,7 @@ extern ABC_DLL Abc_Ntk_t * Abc_NtkFlattenLogicHierarchy( Abc_Ntk_t * pNtk
extern ABC_DLL Abc_Ntk_t * Abc_NtkConvertBlackboxes( Abc_Ntk_t * pNtk );
extern ABC_DLL Abc_Ntk_t * Abc_NtkInsertNewLogic( Abc_Ntk_t * pNtkH, Abc_Ntk_t * pNtkL );
/*=== abcLatch.c ==========================================================*/
-extern ABC_DLL bool Abc_NtkLatchIsSelfFeed( Abc_Obj_t * pLatch );
+extern ABC_DLL int Abc_NtkLatchIsSelfFeed( Abc_Obj_t * pLatch );
extern ABC_DLL int Abc_NtkCountSelfFeedLatches( Abc_Ntk_t * pNtk );
extern ABC_DLL int Abc_NtkRemoveSelfFeedLatches( Abc_Ntk_t * pNtk );
extern ABC_DLL Vec_Int_t * Abc_NtkCollectLatchValues( Abc_Ntk_t * pNtk );
@@ -642,6 +645,8 @@ extern ABC_DLL int Abc_LibAddModel( Abc_Lib_t * pLib, Abc_Ntk_t *
extern ABC_DLL Abc_Ntk_t * Abc_LibFindModelByName( Abc_Lib_t * pLib, char * pName );
extern ABC_DLL int Abc_LibFindTopLevelModels( Abc_Lib_t * pLib );
extern ABC_DLL Abc_Ntk_t * Abc_LibDeriveRoot( Abc_Lib_t * pLib );
+/*=== abcLog.c ==========================================================*/
+extern ABC_DLL void Abc_NtkWriteLogFile( char * pFileName, Abc_Cex_t * pSeqCex, int Status, char * pCommand );
/*=== abcMiter.c ==========================================================*/
extern ABC_DLL int Abc_NtkMinimumBase( Abc_Ntk_t * pNtk );
extern ABC_DLL int Abc_NodeMinimumBase( Abc_Obj_t * pNode );
@@ -658,6 +663,7 @@ extern ABC_DLL Abc_Ntk_t * Abc_NtkMiterQuantifyPis( Abc_Ntk_t * pNtk );
extern ABC_DLL int Abc_NtkMiterIsConstant( Abc_Ntk_t * pMiter );
extern ABC_DLL void Abc_NtkMiterReport( Abc_Ntk_t * pMiter );
extern ABC_DLL Abc_Ntk_t * Abc_NtkFrames( Abc_Ntk_t * pNtk, int nFrames, int fInitial, int fVerbose );
+extern ABC_DLL int Abc_NtkCombinePos( Abc_Ntk_t * pNtk, int fAnd );
/*=== abcNames.c ====================================================*/
extern ABC_DLL char * Abc_ObjName( Abc_Obj_t * pNode );
extern ABC_DLL char * Abc_ObjAssignName( Abc_Obj_t * pObj, char * pName, char * pSuffix );
@@ -674,7 +680,6 @@ extern ABC_DLL int Abc_NodeCompareNames( Abc_Obj_t ** pp1, Abc_Ob
extern ABC_DLL void Abc_NtkOrderObjsByName( Abc_Ntk_t * pNtk, int fComb );
extern ABC_DLL void Abc_NtkAddDummyPiNames( Abc_Ntk_t * pNtk );
extern ABC_DLL void Abc_NtkAddDummyPoNames( Abc_Ntk_t * pNtk );
-extern ABC_DLL void Abc_NtkAddDummyAssertNames( Abc_Ntk_t * pNtk );
extern ABC_DLL void Abc_NtkAddDummyBoxNames( Abc_Ntk_t * pNtk );
extern ABC_DLL void Abc_NtkShortNames( Abc_Ntk_t * pNtk );
/*=== abcNetlist.c ==========================================================*/
@@ -728,15 +733,21 @@ extern ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeAnd( Abc_Ntk_t * pNtk, Vec_Pt
extern ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeOr( Abc_Ntk_t * pNtk, Vec_Ptr_t * vFanins );
extern ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeExor( Abc_Ntk_t * pNtk, Vec_Ptr_t * vFanins );
extern ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeMux( Abc_Ntk_t * pNtk, Abc_Obj_t * pNodeC, Abc_Obj_t * pNode1, Abc_Obj_t * pNode0 );
-extern ABC_DLL bool Abc_NodeIsConst( Abc_Obj_t * pNode );
-extern ABC_DLL bool Abc_NodeIsConst0( Abc_Obj_t * pNode );
-extern ABC_DLL bool Abc_NodeIsConst1( Abc_Obj_t * pNode );
-extern ABC_DLL bool Abc_NodeIsBuf( Abc_Obj_t * pNode );
-extern ABC_DLL bool Abc_NodeIsInv( Abc_Obj_t * pNode );
+extern ABC_DLL int Abc_NodeIsConst( Abc_Obj_t * pNode );
+extern ABC_DLL int Abc_NodeIsConst0( Abc_Obj_t * pNode );
+extern ABC_DLL int Abc_NodeIsConst1( Abc_Obj_t * pNode );
+extern ABC_DLL int Abc_NodeIsBuf( Abc_Obj_t * pNode );
+extern ABC_DLL int Abc_NodeIsInv( Abc_Obj_t * pNode );
extern ABC_DLL void Abc_NodeComplement( Abc_Obj_t * pNode );
+/*=== abcOdc.c ==========================================================*/
+typedef struct Odc_Man_t_ Odc_Man_t;
+extern ABC_DLL Odc_Man_t * Abc_NtkDontCareAlloc( int nVarsMax, int nLevels, int fVerbose, int fVeryVerbose );
+extern ABC_DLL void Abc_NtkDontCareClear( Odc_Man_t * p );
+extern ABC_DLL void Abc_NtkDontCareFree( Odc_Man_t * p );
+extern ABC_DLL int Abc_NtkDontCareCompute( Odc_Man_t * p, Abc_Obj_t * pNode, Vec_Ptr_t * vLeaves, unsigned * puTruth );
/*=== abcPrint.c ==========================================================*/
extern ABC_DLL float Abc_NtkMfsTotalSwitching( Abc_Ntk_t * pNtk );
-extern ABC_DLL void Abc_NtkPrintStats( FILE * pFile, Abc_Ntk_t * pNtk, int fFactored, int fSaveBest, int fDumpResult, int fUseLutLib, int fPrintMuxes, int fPower, int fGlitch );
+extern ABC_DLL void Abc_NtkPrintStats( Abc_Ntk_t * pNtk, int fFactored, int fSaveBest, int fDumpResult, int fUseLutLib, int fPrintMuxes, int fPower, int fGlitch );
extern ABC_DLL void Abc_NtkPrintIo( FILE * pFile, Abc_Ntk_t * pNtk );
extern ABC_DLL void Abc_NtkPrintLatch( FILE * pFile, Abc_Ntk_t * pNtk );
extern ABC_DLL void Abc_NtkPrintFanio( FILE * pFile, Abc_Ntk_t * pNtk );
@@ -768,7 +779,7 @@ extern ABC_DLL void Abc_NtkManCutStop( Abc_ManCut_t * p );
extern ABC_DLL Vec_Ptr_t * Abc_NtkManCutReadCutLarge( Abc_ManCut_t * p );
extern ABC_DLL Vec_Ptr_t * Abc_NtkManCutReadCutSmall( Abc_ManCut_t * p );
extern ABC_DLL Vec_Ptr_t * Abc_NtkManCutReadVisited( Abc_ManCut_t * p );
-extern ABC_DLL Vec_Ptr_t * Abc_NodeFindCut( Abc_ManCut_t * p, Abc_Obj_t * pRoot, bool fContain );
+extern ABC_DLL Vec_Ptr_t * Abc_NodeFindCut( Abc_ManCut_t * p, Abc_Obj_t * pRoot, int fContain );
extern ABC_DLL void Abc_NodeConeCollect( Abc_Obj_t ** ppRoots, int nRoots, Vec_Ptr_t * vFanins, Vec_Ptr_t * vVisited, int fIncludeFanins );
extern ABC_DLL DdNode * Abc_NodeConeBdd( DdManager * dd, DdNode ** pbVars, Abc_Obj_t * pNode, Vec_Ptr_t * vFanins, Vec_Ptr_t * vVisited );
extern ABC_DLL DdNode * Abc_NodeConeDcs( DdManager * dd, DdNode ** pbVarsX, DdNode ** pbVarsY, Vec_Ptr_t * vLeaves, Vec_Ptr_t * vRoots, Vec_Ptr_t * vVisited );
@@ -783,7 +794,7 @@ extern ABC_DLL void Abc_NodeMffcConeSupp( Abc_Obj_t * pNode, Vec_P
extern ABC_DLL int Abc_NodeDeref_rec( Abc_Obj_t * pNode );
extern ABC_DLL int Abc_NodeRef_rec( Abc_Obj_t * pNode );
/*=== abcRefactor.c ==========================================================*/
-extern ABC_DLL int Abc_NtkRefactor( Abc_Ntk_t * pNtk, int nNodeSizeMax, int nConeSizeMax, bool fUpdateLevel, bool fUseZeros, bool fUseDcs, bool fVerbose );
+extern ABC_DLL int Abc_NtkRefactor( Abc_Ntk_t * pNtk, int nNodeSizeMax, int nConeSizeMax, int fUpdateLevel, int fUseZeros, int fUseDcs, int fVerbose );
/*=== abcRewrite.c ==========================================================*/
extern ABC_DLL int Abc_NtkRewrite( Abc_Ntk_t * pNtk, int fUpdateLevel, int fUseZeros, int fVerbose, int fVeryVerbose, int fPlaceEnable );
/*=== abcSat.c ==========================================================*/
@@ -814,15 +825,15 @@ extern ABC_DLL int Abc_SopGetVarNum( char * pSop );
extern ABC_DLL int Abc_SopGetPhase( char * pSop );
extern ABC_DLL int Abc_SopGetIthCareLit( char * pSop, int i );
extern ABC_DLL void Abc_SopComplement( char * pSop );
-extern ABC_DLL bool Abc_SopIsComplement( char * pSop );
-extern ABC_DLL bool Abc_SopIsConst0( char * pSop );
-extern ABC_DLL bool Abc_SopIsConst1( char * pSop );
-extern ABC_DLL bool Abc_SopIsBuf( char * pSop );
-extern ABC_DLL bool Abc_SopIsInv( char * pSop );
-extern ABC_DLL bool Abc_SopIsAndType( char * pSop );
-extern ABC_DLL bool Abc_SopIsOrType( char * pSop );
+extern ABC_DLL int Abc_SopIsComplement( char * pSop );
+extern ABC_DLL int Abc_SopIsConst0( char * pSop );
+extern ABC_DLL int Abc_SopIsConst1( char * pSop );
+extern ABC_DLL int Abc_SopIsBuf( char * pSop );
+extern ABC_DLL int Abc_SopIsInv( char * pSop );
+extern ABC_DLL int Abc_SopIsAndType( char * pSop );
+extern ABC_DLL int Abc_SopIsOrType( char * pSop );
extern ABC_DLL int Abc_SopIsExorType( char * pSop );
-extern ABC_DLL bool Abc_SopCheck( char * pSop, int nFanins );
+extern ABC_DLL int Abc_SopCheck( char * pSop, int nFanins );
extern ABC_DLL char * Abc_SopFromTruthBin( char * pTruth );
extern ABC_DLL char * Abc_SopFromTruthHex( char * pTruth );
extern ABC_DLL char * Abc_SopEncoderPos( Extra_MmFlex_t * pMan, int iValue, int nValues );
@@ -892,12 +903,12 @@ extern ABC_DLL void Abc_NtkCleanMarkA( Abc_Ntk_t * pNtk );
extern ABC_DLL Abc_Obj_t * Abc_NodeFindCoFanout( Abc_Obj_t * pNode );
extern ABC_DLL Abc_Obj_t * Abc_NodeFindNonCoFanout( Abc_Obj_t * pNode );
extern ABC_DLL Abc_Obj_t * Abc_NodeHasUniqueCoFanout( Abc_Obj_t * pNode );
-extern ABC_DLL bool Abc_NtkLogicHasSimpleCos( Abc_Ntk_t * pNtk );
-extern ABC_DLL int Abc_NtkLogicMakeSimpleCos( Abc_Ntk_t * pNtk, bool fDuplicate );
+extern ABC_DLL int Abc_NtkLogicHasSimpleCos( Abc_Ntk_t * pNtk );
+extern ABC_DLL int Abc_NtkLogicMakeSimpleCos( Abc_Ntk_t * pNtk, int fDuplicate );
extern ABC_DLL void Abc_VecObjPushUniqueOrderByLevel( Vec_Ptr_t * p, Abc_Obj_t * pNode );
-extern ABC_DLL bool Abc_NodeIsExorType( Abc_Obj_t * pNode );
-extern ABC_DLL bool Abc_NodeIsMuxType( Abc_Obj_t * pNode );
-extern ABC_DLL bool Abc_NodeIsMuxControlType( Abc_Obj_t * pNode );
+extern ABC_DLL int Abc_NodeIsExorType( Abc_Obj_t * pNode );
+extern ABC_DLL int Abc_NodeIsMuxType( Abc_Obj_t * pNode );
+extern ABC_DLL int Abc_NodeIsMuxControlType( Abc_Obj_t * pNode );
extern ABC_DLL Abc_Obj_t * Abc_NodeRecognizeMux( Abc_Obj_t * pNode, Abc_Obj_t ** ppNodeT, Abc_Obj_t ** ppNodeE );
extern ABC_DLL int Abc_NtkPrepareTwoNtks( FILE * pErr, Abc_Ntk_t * pNtk, char ** argv, int argc, Abc_Ntk_t ** ppNtk1, Abc_Ntk_t ** ppNtk2, int * pfDelete1, int * pfDelete2 );
extern ABC_DLL void Abc_NodeCollectFanins( Abc_Obj_t * pNode, Vec_Ptr_t * vNodes );
@@ -911,13 +922,18 @@ extern ABC_DLL Vec_Int_t * Abc_NtkGetCiIds( Abc_Ntk_t * pNtk );
extern ABC_DLL void Abc_NtkReassignIds( Abc_Ntk_t * pNtk );
extern ABC_DLL int Abc_ObjPointerCompare( void ** pp1, void ** pp2 );
extern ABC_DLL void Abc_NtkTransferCopy( Abc_Ntk_t * pNtk );
+
/*=== abcVerify.c ==========================================================*/
extern ABC_DLL int * Abc_NtkVerifyGetCleanModel( Abc_Ntk_t * pNtk, int nFrames );
extern ABC_DLL int * Abc_NtkVerifySimulatePattern( Abc_Ntk_t * pNtk, int * pModel );
+extern ABC_DLL int Abc_NtkIsTrueCex( Abc_Ntk_t * pNtk, Abc_Cex_t * pCex );
+extern ABC_DLL int Abc_NtkIsValidCex( Abc_Ntk_t * pNtk, Abc_Cex_t * pCex );
+
+
+
+ABC_NAMESPACE_HEADER_END
+
-#ifdef __cplusplus
-}
-#endif
#endif
diff --git a/src/base/abc/abcAig.c b/src/base/abc/abcAig.c
index a3188901..956a26b9 100644
--- a/src/base/abc/abcAig.c
+++ b/src/base/abc/abcAig.c
@@ -20,6 +20,8 @@
#include "abc.h"
+ABC_NAMESPACE_IMPL_START
+
/*
AIG is an And-Inv Graph with structural hashing.
It is always structurally hashed. It means that at any time:
@@ -203,7 +205,7 @@ int Abc_AigCleanup( Abc_Aig_t * pMan )
if ( Abc_ObjFanoutNum(pAnd) == 0 )
Vec_PtrPush( vDangles, pAnd );
// process the dangling nodes and their MFFCs
- Vec_PtrForEachEntry( vDangles, pAnd, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vDangles, pAnd, i )
Abc_AigDeleteNode( pMan, pAnd );
Vec_PtrFree( vDangles );
return nNodesOld - pMan->nEntries;
@@ -220,7 +222,7 @@ int Abc_AigCleanup( Abc_Aig_t * pMan )
SeeAlso []
***********************************************************************/
-bool Abc_AigCheck( Abc_Aig_t * pMan )
+int Abc_AigCheck( Abc_Aig_t * pMan )
{
Abc_Obj_t * pObj, * pAnd;
int i, nFanins, Counter;
@@ -265,7 +267,7 @@ bool Abc_AigCheck( Abc_Aig_t * pMan )
// if the node is a choice node, nodes in its class should not have fanouts
Abc_NtkForEachNode( pMan->pNtkAig, pObj, i )
if ( Abc_AigNodeIsChoice(pObj) )
- for ( pAnd = pObj->pData; pAnd; pAnd = pAnd->pData )
+ for ( pAnd = (Abc_Obj_t *)pObj->pData; pAnd; pAnd = (Abc_Obj_t *)pAnd->pData )
if ( Abc_ObjFanoutNum(pAnd) > 0 )
{
printf( "Abc_AigCheck: Representative %s", Abc_ObjName(pAnd) );
@@ -796,12 +798,12 @@ Abc_Obj_t * Abc_AigMiter( Abc_Aig_t * pMan, Vec_Ptr_t * vPairs, int fImplic )
if ( fImplic )
{
for ( i = 0; i < vPairs->nSize; i += 2 )
- vPairs->pArray[i/2] = Abc_AigAnd( pMan, vPairs->pArray[i], Abc_ObjNot(vPairs->pArray[i+1]) );
+ vPairs->pArray[i/2] = Abc_AigAnd( pMan, (Abc_Obj_t *)vPairs->pArray[i], Abc_ObjNot((Abc_Obj_t *)vPairs->pArray[i+1]) );
}
else
{
for ( i = 0; i < vPairs->nSize; i += 2 )
- vPairs->pArray[i/2] = Abc_AigXor( pMan, vPairs->pArray[i], vPairs->pArray[i+1] );
+ vPairs->pArray[i/2] = Abc_AigXor( pMan, (Abc_Obj_t *)vPairs->pArray[i], (Abc_Obj_t *)vPairs->pArray[i+1] );
}
vPairs->nSize = vPairs->nSize/2;
return Abc_AigMiter_rec( pMan, (Abc_Obj_t **)vPairs->pArray, vPairs->nSize );
@@ -827,7 +829,7 @@ Abc_Obj_t * Abc_AigMiter2( Abc_Aig_t * pMan, Vec_Ptr_t * vPairs )
pMiter = Abc_ObjNot( Abc_AigConst1(pMan->pNtkAig) );
for ( i = 0; i < vPairs->nSize; i += 2 )
{
- pXor = Abc_AigXor( pMan, vPairs->pArray[i], vPairs->pArray[i+1] );
+ pXor = Abc_AigXor( pMan, (Abc_Obj_t *)vPairs->pArray[i], (Abc_Obj_t *)vPairs->pArray[i+1] );
pMiter = Abc_AigOr( pMan, pMiter, pXor );
}
return pMiter;
@@ -847,7 +849,7 @@ Abc_Obj_t * Abc_AigMiter2( Abc_Aig_t * pMan, Vec_Ptr_t * vPairs )
SeeAlso []
***********************************************************************/
-void Abc_AigReplace( Abc_Aig_t * pMan, Abc_Obj_t * pOld, Abc_Obj_t * pNew, bool fUpdateLevel )
+void Abc_AigReplace( Abc_Aig_t * pMan, Abc_Obj_t * pOld, Abc_Obj_t * pNew, int fUpdateLevel )
{
assert( Vec_PtrSize(pMan->vStackReplaceOld) == 0 );
assert( Vec_PtrSize(pMan->vStackReplaceNew) == 0 );
@@ -860,8 +862,8 @@ void Abc_AigReplace( Abc_Aig_t * pMan, Abc_Obj_t * pOld, Abc_Obj_t * pNew, bool
// process the replacements
while ( Vec_PtrSize(pMan->vStackReplaceOld) )
{
- pOld = Vec_PtrPop( pMan->vStackReplaceOld );
- pNew = Vec_PtrPop( pMan->vStackReplaceNew );
+ pOld = (Abc_Obj_t *)Vec_PtrPop( pMan->vStackReplaceOld );
+ pNew = (Abc_Obj_t *)Vec_PtrPop( pMan->vStackReplaceNew );
Abc_AigReplace_int( pMan, pOld, pNew, fUpdateLevel );
}
if ( fUpdateLevel )
@@ -893,7 +895,7 @@ void Abc_AigReplace_int( Abc_Aig_t * pMan, Abc_Obj_t * pOld, Abc_Obj_t * pNew, i
assert( Abc_ObjFanoutNum(pOld) > 0 );
// look at the fanouts of old node
Abc_NodeCollectFanouts( pOld, pMan->vNodes );
- Vec_PtrForEachEntry( pMan->vNodes, pFanout, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, pMan->vNodes, pFanout, k )
{
if ( Abc_ObjIsCo(pFanout) )
{
@@ -984,7 +986,7 @@ void Abc_AigDeleteNode( Abc_Aig_t * pMan, Abc_Obj_t * pNode )
assert( Abc_ObjFanoutNum(pNode) == 0 );
// when deleting an old node that is scheduled for replacement, remove it from the replacement queue
- Vec_PtrForEachEntry( pMan->vStackReplaceOld, pTemp, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, pMan->vStackReplaceOld, pTemp, i )
if ( pNode == pTemp )
{
// remove the entry from the replacement array
@@ -998,7 +1000,7 @@ void Abc_AigDeleteNode( Abc_Aig_t * pMan, Abc_Obj_t * pNode )
}
// when deleting a new node that should replace another node, do not delete
- Vec_PtrForEachEntry( pMan->vStackReplaceNew, pTemp, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, pMan->vStackReplaceNew, pTemp, i )
if ( pNode == Abc_ObjRegular(pTemp) )
return;
@@ -1057,7 +1059,7 @@ void Abc_AigUpdateLevel_int( Abc_Aig_t * pMan )
{
if ( Vec_PtrSize(vVec) == 0 )
continue;
- Vec_PtrForEachEntry( vVec, pNode, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vVec, pNode, k )
{
if ( pNode == NULL )
continue;
@@ -1113,7 +1115,7 @@ void Abc_AigUpdateLevelR_int( Abc_Aig_t * pMan )
{
if ( Vec_PtrSize(vVec) == 0 )
continue;
- Vec_PtrForEachEntry( vVec, pNode, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vVec, pNode, k )
{
if ( pNode == NULL )
continue;
@@ -1168,8 +1170,8 @@ void Abc_AigRemoveFromLevelStructure( Vec_Vec_t * vStruct, Abc_Obj_t * pNode )
Abc_Obj_t * pTemp;
int m;
assert( pNode->fMarkA );
- vVecTemp = Vec_VecEntry( vStruct, pNode->Level );
- Vec_PtrForEachEntry( vVecTemp, pTemp, m )
+ vVecTemp = (Vec_Ptr_t *)Vec_VecEntry( vStruct, pNode->Level );
+ Vec_PtrForEachEntry( Abc_Obj_t *, vVecTemp, pTemp, m )
{
if ( pTemp != pNode )
continue;
@@ -1197,8 +1199,8 @@ void Abc_AigRemoveFromLevelStructureR( Vec_Vec_t * vStruct, Abc_Obj_t * pNode )
Abc_Obj_t * pTemp;
int m;
assert( pNode->fMarkB );
- vVecTemp = Vec_VecEntry( vStruct, Abc_ObjReverseLevel(pNode) );
- Vec_PtrForEachEntry( vVecTemp, pTemp, m )
+ vVecTemp = (Vec_Ptr_t *)Vec_VecEntry( vStruct, Abc_ObjReverseLevel(pNode) );
+ Vec_PtrForEachEntry( Abc_Obj_t *, vVecTemp, pTemp, m )
{
if ( pTemp != pNode )
continue;
@@ -1224,7 +1226,7 @@ void Abc_AigRemoveFromLevelStructureR( Vec_Vec_t * vStruct, Abc_Obj_t * pNode )
SeeAlso []
***********************************************************************/
-bool Abc_AigNodeHasComplFanoutEdge( Abc_Obj_t * pNode )
+int Abc_AigNodeHasComplFanoutEdge( Abc_Obj_t * pNode )
{
Abc_Obj_t * pFanout;
int i, iFanin;
@@ -1251,7 +1253,7 @@ bool Abc_AigNodeHasComplFanoutEdge( Abc_Obj_t * pNode )
SeeAlso []
***********************************************************************/
-bool Abc_AigNodeHasComplFanoutEdgeTrav( Abc_Obj_t * pNode )
+int Abc_AigNodeHasComplFanoutEdgeTrav( Abc_Obj_t * pNode )
{
Abc_Obj_t * pFanout;
int i, iFanin;
@@ -1313,7 +1315,7 @@ void Abc_AigPrintNode( Abc_Obj_t * pNode )
SeeAlso []
***********************************************************************/
-bool Abc_AigNodeIsAcyclic( Abc_Obj_t * pNode, Abc_Obj_t * pRoot )
+int Abc_AigNodeIsAcyclic( Abc_Obj_t * pNode, Abc_Obj_t * pRoot )
{
Abc_Obj_t * pFanin0, * pFanin1;
Abc_Obj_t * pChild00, * pChild01;
@@ -1498,3 +1500,11 @@ int Abc_AigCountNext( Abc_Aig_t * pMan )
////////////////////////////////////////////////////////////////////////
+void Abc_NtkHelloWorld( Abc_Ntk_t * pNtk )
+{
+ printf( "Hello, World!\n" );
+}
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abc/abcBlifMv.c b/src/base/abc/abcBlifMv.c
index d4bbebf0..946e3f75 100644
--- a/src/base/abc/abcBlifMv.c
+++ b/src/base/abc/abcBlifMv.c
@@ -20,6 +20,9 @@
#include "abc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -61,8 +64,8 @@ void Abc_NtkStartMvVars( Abc_Ntk_t * pNtk )
***********************************************************************/
void Abc_NtkFreeMvVars( Abc_Ntk_t * pNtk )
{
- void * pUserMan;
- pUserMan = Abc_NtkAttrFree( pNtk, VEC_ATTR_GLOBAL_BDD, 0 );
+ Extra_MmFlex_t * pUserMan;
+ pUserMan = (Extra_MmFlex_t *)Abc_NtkAttrFree( pNtk, VEC_ATTR_GLOBAL_BDD, 0 );
Extra_MmFlexStop( pUserMan );
}
@@ -93,8 +96,8 @@ void Abc_NtkSetMvVarValues( Abc_Obj_t * pObj, int nValues )
if ( Abc_ObjMvVar(pObj) != NULL )
return;
// create the structure
- pFlex = Abc_NtkMvVarMan( pObj->pNtk );
- pVarStruct = (void *)Extra_MmFlexEntryFetch( pFlex, sizeof(struct temp) );
+ pFlex = (Extra_MmFlex_t *)Abc_NtkMvVarMan( pObj->pNtk );
+ pVarStruct = (struct temp *)Extra_MmFlexEntryFetch( pFlex, sizeof(struct temp) );
pVarStruct->nValues = nValues;
pVarStruct->pNames = NULL;
Abc_ObjSetMvVar( pObj, pVarStruct );
@@ -150,7 +153,7 @@ int Abc_NodeStrashBlifMv( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pObj )
pValues[k] = Abc_ObjNot( Abc_AigConst1(pNtkNew) );
// get the BLIF-MV formula
- pSop = pObj->pData;
+ pSop = (char *)pObj->pData;
// skip the value line
// while ( *pSop++ != '\n' );
@@ -170,7 +173,7 @@ int Abc_NodeStrashBlifMv( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pObj )
Index = Abc_StringGetNumber( &pSop );
assert( Index < nValues );
////////////////////////////////////////////
- // adding ABC_FREE variables for binary ND-constants
+ // adding free variables for binary ND-constants
if ( fAddFreeVars && nValues == 2 && *pSop == '-' )
{
pValues[1] = Abc_NtkCreatePi(pNtkNew);
@@ -243,7 +246,7 @@ int Abc_NodeStrashBlifMv( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pObj )
{
Index = Abc_StringGetNumber( &pSop );
assert( Index < nValuesF );
- pTemp2 = Abc_AigOr( pNtkNew->pManFunc, pTemp2, pValuesF[Index] );
+ pTemp2 = Abc_AigOr( (Abc_Aig_t *)pNtkNew->pManFunc, pTemp2, pValuesF[Index] );
assert( *pSop == ')' || *pSop == ',' );
if ( *pSop == ',' )
pSop++;
@@ -266,7 +269,7 @@ int Abc_NodeStrashBlifMv( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pObj )
assert( nValuesF == nValuesF2 );
pTemp2 = Abc_ObjNot( Abc_AigConst1(pNtkNew) );
for ( v = 0; v < nValues; v++ )
- pTemp2 = Abc_AigOr( pNtkNew->pManFunc, pTemp2, Abc_AigAnd(pNtkNew->pManFunc, pValuesF[v], pValuesF2[v]) );
+ pTemp2 = Abc_AigOr( (Abc_Aig_t *)pNtkNew->pManFunc, pTemp2, Abc_AigAnd((Abc_Aig_t *)pNtkNew->pManFunc, pValuesF[v], pValuesF2[v]) );
}
else
{
@@ -275,7 +278,7 @@ int Abc_NodeStrashBlifMv( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pObj )
pTemp2 = pValuesF[Index];
}
// compute the compute
- pTemp = Abc_AigAnd( pNtkNew->pManFunc, pTemp, pTemp2 );
+ pTemp = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, pTemp, pTemp2 );
// advance the reading point
assert( *pSop == ' ' );
pSop++;
@@ -293,14 +296,14 @@ int Abc_NodeStrashBlifMv( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pObj )
pValuesF = (Abc_Obj_t **)pFanin->pCopy;
assert( nValuesF == nValues ); // should be guaranteed by the parser
for ( k = 0; k < nValuesF; k++ )
- pValues[k] = Abc_AigOr( pNtkNew->pManFunc, pValues[k], Abc_AigAnd(pNtkNew->pManFunc, pTemp, pValuesF[k]) );
+ pValues[k] = Abc_AigOr( (Abc_Aig_t *)pNtkNew->pManFunc, pValues[k], Abc_AigAnd((Abc_Aig_t *)pNtkNew->pManFunc, pTemp, pValuesF[k]) );
}
else
{
// get the output value
Index = Abc_StringGetNumber( &pSop );
assert( Index < nValues );
- pValues[Index] = Abc_AigOr( pNtkNew->pManFunc, pValues[Index], pTemp );
+ pValues[Index] = Abc_AigOr( (Abc_Aig_t *)pNtkNew->pManFunc, pValues[Index], pTemp );
}
// advance the reading point
assert( *pSop == '\n' );
@@ -315,7 +318,7 @@ int Abc_NodeStrashBlifMv( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pObj )
{
if ( k == Def )
continue;
- pTemp = Abc_AigAnd( pNtkNew->pManFunc, pTemp, Abc_ObjNot(pValues[k]) );
+ pTemp = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, pTemp, Abc_ObjNot(pValues[k]) );
}
// assign the default value
@@ -330,7 +333,7 @@ int Abc_NodeStrashBlifMv( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pObj )
pValuesF = (Abc_Obj_t **)pFanin->pCopy;
assert( nValuesF == nValues ); // should be guaranteed by the parser
for ( k = 0; k < nValuesF; k++ )
- pValues[k] = Abc_AigOr( pNtkNew->pManFunc, pValues[k], Abc_AigAnd(pNtkNew->pManFunc, pTemp, pValuesF[k]) );
+ pValues[k] = Abc_AigOr( (Abc_Aig_t *)pNtkNew->pManFunc, pValues[k], Abc_AigAnd((Abc_Aig_t *)pNtkNew->pManFunc, pTemp, pValuesF[k]) );
}
}
@@ -484,7 +487,7 @@ Abc_Ntk_t * Abc_NtkStrashBlifMv( Abc_Ntk_t * pNtk )
for ( k = 0; k < nBits; k++ )
{
pBit = Abc_ObjNotCond( pBits[k], (v&(1<<k)) == 0 );
- pValues[v] = Abc_AigAnd( pNtkNew->pManFunc, pValues[v], pBit );
+ pValues[v] = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, pValues[v], pBit );
}
}
// save the values in the fanout net
@@ -517,7 +520,7 @@ Abc_Ntk_t * Abc_NtkStrashBlifMv( Abc_Ntk_t * pNtk )
for ( k = 0; k < nBits; k++ )
{
pBit = Abc_ObjNotCond( pBits[k], (v&(1<<k)) == 0 );
- pValues[v] = Abc_AigAnd( pNtkNew->pManFunc, pValues[v], pBit );
+ pValues[v] = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, pValues[v], pBit );
}
}
// save the values in the fanout net
@@ -528,7 +531,7 @@ Abc_Ntk_t * Abc_NtkStrashBlifMv( Abc_Ntk_t * pNtk )
}
// process nodes in the topological order
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
if ( !Abc_NodeStrashBlifMv( pNtkNew, pObj ) )
{
Abc_NtkDelete( pNtkNew );
@@ -602,7 +605,7 @@ Abc_Ntk_t * Abc_NtkStrashBlifMv( Abc_Ntk_t * pNtk )
pBit = Abc_ObjNot( Abc_AigConst1(pNtkNew) );
for ( v = 0; v < nValues; v++ )
if ( v & (1<<k) )
- pBit = Abc_AigOr( pNtkNew->pManFunc, pBit, pValues[v] );
+ pBit = Abc_AigOr( (Abc_Aig_t *)pNtkNew->pManFunc, pBit, pValues[v] );
pTemp = Abc_NtkCreatePo( pNtkNew );
Abc_ObjAddFanin( pTemp, pBit );
if ( nValuesMax == 2 )
@@ -628,7 +631,7 @@ Abc_Ntk_t * Abc_NtkStrashBlifMv( Abc_Ntk_t * pNtk )
pBit = Abc_ObjNot( Abc_AigConst1(pNtkNew) );
for ( v = 0; v < nValues; v++ )
if ( v & (1<<k) )
- pBit = Abc_AigOr( pNtkNew->pManFunc, pBit, pValues[v] );
+ pBit = Abc_AigOr( (Abc_Aig_t *)pNtkNew->pManFunc, pBit, pValues[v] );
pTemp = Abc_NtkCreateBi( pNtkNew );
Abc_ObjAddFanin( pTemp, pBit );
if ( nValuesMax == 2 )
@@ -645,7 +648,7 @@ Abc_Ntk_t * Abc_NtkStrashBlifMv( Abc_Ntk_t * pNtk )
Vec_Ptr_t * vTemp;
Abc_Obj_t * pLatch, * pObjLi, * pObjLo;
int i;
- // move ABC_FREE vars to the front among the PIs
+ // move free vars to the front among the PIs
vTemp = Vec_PtrAlloc( Vec_PtrSize(pNtkNew->vPis) );
Abc_NtkForEachPi( pNtkNew, pObj, i )
if ( strncmp( Abc_ObjName(pObj), "free_var_", 9 ) == 0 )
@@ -656,7 +659,7 @@ Abc_Ntk_t * Abc_NtkStrashBlifMv( Abc_Ntk_t * pNtk )
assert( Vec_PtrSize(vTemp) == Vec_PtrSize(pNtkNew->vPis) );
Vec_PtrFree( pNtkNew->vPis );
pNtkNew->vPis = vTemp;
- // move ABC_FREE vars to the front among the CIs
+ // move free vars to the front among the CIs
vTemp = Vec_PtrAlloc( Vec_PtrSize(pNtkNew->vCis) );
Abc_NtkForEachCi( pNtkNew, pObj, i )
if ( strncmp( Abc_ObjName(pObj), "free_var_", 9 ) == 0 )
@@ -690,7 +693,7 @@ Abc_Ntk_t * Abc_NtkStrashBlifMv( Abc_Ntk_t * pNtk )
ABC_FREE( pObj->pCopy );
// remove dangling nodes
- i = Abc_AigCleanup(pNtkNew->pManFunc);
+ i = Abc_AigCleanup((Abc_Aig_t *)pNtkNew->pManFunc);
// printf( "Cleanup removed %d nodes.\n", i );
// Abc_NtkReassignIds( pNtkNew );
@@ -781,7 +784,7 @@ Abc_Ntk_t * Abc_NtkSkeletonBlifMv( Abc_Ntk_t * pNtk )
for ( v = 0; v < nValues; v++ )
{
pNodeNew = Abc_NtkCreateNode( pNtkNew );
- pNodeNew->pData = Abc_SopEncoderPos( pNtkNew->pManFunc, v, nValues );
+ pNodeNew->pData = Abc_SopEncoderPos( (Extra_MmFlex_t *)pNtkNew->pManFunc, v, nValues );
pNetNew = Abc_NtkCreateNet( pNtkNew );
pTermNew = Abc_NtkCreateBi( pNtkNew );
Abc_ObjAddFanin( pNodeNew, pNet->pCopy );
@@ -803,7 +806,7 @@ Abc_Ntk_t * Abc_NtkSkeletonBlifMv( Abc_Ntk_t * pNtk )
for ( k = 0; k < nBits; k++ )
{
pNodeNew = Abc_NtkCreateNode( pNtkNew );
- pNodeNew->pData = Abc_SopEncoderLog( pNtkNew->pManFunc, k, nValues );
+ pNodeNew->pData = Abc_SopEncoderLog( (Extra_MmFlex_t *)pNtkNew->pManFunc, k, nValues );
pNetNew = Abc_NtkCreateNet( pNtkNew );
pTermNew = Abc_NtkCreateBi( pNtkNew );
Abc_ObjAddFanin( pNodeNew, pNet->pCopy );
@@ -828,7 +831,7 @@ Abc_Ntk_t * Abc_NtkSkeletonBlifMv( Abc_Ntk_t * pNtk )
Abc_NodeSetTravIdCurrent( pNet );
nValues = Abc_ObjMvVarNum(pNet);
pNodeNew = Abc_NtkCreateNode( pNtkNew );
- pNodeNew->pData = Abc_SopDecoderPos( pNtkNew->pManFunc, nValues );
+ pNodeNew->pData = Abc_SopDecoderPos( (Extra_MmFlex_t *)pNtkNew->pManFunc, nValues );
for ( v = 0; v < nValues; v++ )
{
pTermNew = Abc_NtkCreateBo( pNtkNew );
@@ -852,7 +855,7 @@ Abc_Ntk_t * Abc_NtkSkeletonBlifMv( Abc_Ntk_t * pNtk )
nValues = Abc_ObjMvVarNum(pNet);
nBits = Extra_Base2Log( nValues );
pNodeNew = Abc_NtkCreateNode( pNtkNew );
- pNodeNew->pData = Abc_SopDecoderLog( pNtkNew->pManFunc, nValues );
+ pNodeNew->pData = Abc_SopDecoderLog( (Extra_MmFlex_t *)pNtkNew->pManFunc, nValues );
for ( k = 0; k < nBits; k++ )
{
pTermNew = Abc_NtkCreateBo( pNtkNew );
@@ -995,13 +998,13 @@ int Abc_NtkConvertToBlifMv( Abc_Ntk_t * pNtk )
*pCur++ = 0;
assert( pCur - pBlifMv == nSize );
// update the node representation
- Cudd_RecursiveDeref( pNtk->pManFunc, pNode->pData );
+ Cudd_RecursiveDeref( (DdManager *)pNtk->pManFunc, (DdNode *)pNode->pData );
pNode->pData = pBlifMv;
}
// update the functionality type
pNtk->ntkFunc = ABC_FUNC_BLIFMV;
- Cudd_Quit( pNtk->pManFunc );
+ Cudd_Quit( (DdManager *)pNtk->pManFunc );
pNtk->pManFunc = pMmFlex;
Vec_StrFree( vCube );
@@ -1152,3 +1155,5 @@ int Abc_NodeEvalMvCost( int nVars, Vec_Int_t * vSop0, Vec_Int_t * vSop1 )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abc/abcCheck.c b/src/base/abc/abcCheck.c
index a43cc9eb..aa264314 100644
--- a/src/base/abc/abcCheck.c
+++ b/src/base/abc/abcCheck.c
@@ -22,21 +22,24 @@
#include "main.h"
//#include "seq.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
-static bool Abc_NtkCheckNames( Abc_Ntk_t * pNtk );
-static bool Abc_NtkCheckPis( Abc_Ntk_t * pNtk );
-static bool Abc_NtkCheckPos( Abc_Ntk_t * pNtk );
-//static bool Abc_NtkCheckObj( Abc_Ntk_t * pNtk, Abc_Obj_t * pObj );
-static bool Abc_NtkCheckNet( Abc_Ntk_t * pNtk, Abc_Obj_t * pNet );
-static bool Abc_NtkCheckNode( Abc_Ntk_t * pNtk, Abc_Obj_t * pNode );
-static bool Abc_NtkCheckLatch( Abc_Ntk_t * pNtk, Abc_Obj_t * pLatch );
+static int Abc_NtkCheckNames( Abc_Ntk_t * pNtk );
+static int Abc_NtkCheckPis( Abc_Ntk_t * pNtk );
+static int Abc_NtkCheckPos( Abc_Ntk_t * pNtk );
+//static int Abc_NtkCheckObj( Abc_Ntk_t * pNtk, Abc_Obj_t * pObj );
+static int Abc_NtkCheckNet( Abc_Ntk_t * pNtk, Abc_Obj_t * pNet );
+static int Abc_NtkCheckNode( Abc_Ntk_t * pNtk, Abc_Obj_t * pNode );
+static int Abc_NtkCheckLatch( Abc_Ntk_t * pNtk, Abc_Obj_t * pLatch );
-static bool Abc_NtkComparePis( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb );
-static bool Abc_NtkComparePos( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb );
-static bool Abc_NtkCompareLatches( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb );
+static int Abc_NtkComparePis( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb );
+static int Abc_NtkComparePos( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb );
+static int Abc_NtkCompareLatches( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb );
static inline char * Abc_ObjNameNet( Abc_Obj_t * pObj ) { return (Abc_ObjIsNode(pObj) && Abc_NtkIsNetlist(pObj->pNtk)) ? Abc_ObjName(Abc_ObjFanout0(pObj)) : Abc_ObjName(pObj); }
@@ -55,7 +58,7 @@ static inline char * Abc_ObjNameNet( Abc_Obj_t * pObj ) { return (Abc_ObjIsNode(
SeeAlso []
***********************************************************************/
-bool Abc_NtkCheck( Abc_Ntk_t * pNtk )
+int Abc_NtkCheck( Abc_Ntk_t * pNtk )
{
return !Abc_FrameIsFlagEnabled( "check" ) || Abc_NtkDoCheck( pNtk );
}
@@ -71,7 +74,7 @@ bool Abc_NtkCheck( Abc_Ntk_t * pNtk )
SeeAlso []
***********************************************************************/
-bool Abc_NtkCheckRead( Abc_Ntk_t * pNtk )
+int Abc_NtkCheckRead( Abc_Ntk_t * pNtk )
{
return !Abc_FrameIsFlagEnabled( "checkread" ) || Abc_NtkDoCheck( pNtk );
}
@@ -87,7 +90,7 @@ bool Abc_NtkCheckRead( Abc_Ntk_t * pNtk )
SeeAlso []
***********************************************************************/
-bool Abc_NtkDoCheck( Abc_Ntk_t * pNtk )
+int Abc_NtkDoCheck( Abc_Ntk_t * pNtk )
{
Abc_Obj_t * pObj, * pNet, * pNode;
int i;
@@ -122,7 +125,7 @@ bool Abc_NtkDoCheck( Abc_Ntk_t * pNtk )
fprintf( stdout, "in procedure Abc_NtkCreateObj() and in the user's code.\n" );
return 0;
}
- if ( Abc_NtkPoNum(pNtk) + Abc_NtkAssertNum(pNtk) + Abc_NtkLatchNum(pNtk) != Abc_NtkCoNum(pNtk) )
+ if ( Abc_NtkPoNum(pNtk) + Abc_NtkLatchNum(pNtk) != Abc_NtkCoNum(pNtk) )
{
fprintf( stdout, "NetworkCheck: Number of COs does not match number of POs, asserts, and latches.\n" );
fprintf( stdout, "One possible reason is that latches are added twice:\n" );
@@ -171,7 +174,7 @@ bool Abc_NtkDoCheck( Abc_Ntk_t * pNtk )
// check the nodes
if ( Abc_NtkIsStrash(pNtk) )
- Abc_AigCheck( pNtk->pManFunc );
+ Abc_AigCheck( (Abc_Aig_t *)pNtk->pManFunc );
else
{
Abc_NtkForEachNode( pNtk, pNode, i )
@@ -232,7 +235,7 @@ bool Abc_NtkDoCheck( Abc_Ntk_t * pNtk )
SeeAlso []
***********************************************************************/
-bool Abc_NtkCheckNames( Abc_Ntk_t * pNtk )
+int Abc_NtkCheckNames( Abc_Ntk_t * pNtk )
{
Abc_Obj_t * pObj = NULL; // Ensure pObj isn't used uninitialized.
Vec_Int_t * vNameIds;
@@ -306,7 +309,7 @@ bool Abc_NtkCheckNames( Abc_Ntk_t * pNtk )
SeeAlso []
***********************************************************************/
-bool Abc_NtkCheckPis( Abc_Ntk_t * pNtk )
+int Abc_NtkCheckPis( Abc_Ntk_t * pNtk )
{
Abc_Obj_t * pObj;
int i;
@@ -354,7 +357,7 @@ bool Abc_NtkCheckPis( Abc_Ntk_t * pNtk )
SeeAlso []
***********************************************************************/
-bool Abc_NtkCheckPos( Abc_Ntk_t * pNtk )
+int Abc_NtkCheckPos( Abc_Ntk_t * pNtk )
{
Abc_Obj_t * pObj;
int i;
@@ -408,11 +411,11 @@ bool Abc_NtkCheckPos( Abc_Ntk_t * pNtk )
SeeAlso []
***********************************************************************/
-bool Abc_NtkCheckObj( Abc_Ntk_t * pNtk, Abc_Obj_t * pObj )
+int Abc_NtkCheckObj( Abc_Ntk_t * pNtk, Abc_Obj_t * pObj )
{
Abc_Obj_t * pFanin, * pFanout;
- int i, Value = 1;
- int k;
+ int Value = 1;
+ int i, k;
// check the network
if ( pObj->pNtk != pNtk )
@@ -487,7 +490,7 @@ bool Abc_NtkCheckObj( Abc_Ntk_t * pNtk, Abc_Obj_t * pObj )
SeeAlso []
***********************************************************************/
-bool Abc_NtkCheckNet( Abc_Ntk_t * pNtk, Abc_Obj_t * pNet )
+int Abc_NtkCheckNet( Abc_Ntk_t * pNtk, Abc_Obj_t * pNet )
{
if ( Abc_ObjFaninNum(pNet) == 0 )
{
@@ -513,7 +516,7 @@ bool Abc_NtkCheckNet( Abc_Ntk_t * pNtk, Abc_Obj_t * pNet )
SeeAlso []
***********************************************************************/
-bool Abc_NtkCheckNode( Abc_Ntk_t * pNtk, Abc_Obj_t * pNode )
+int Abc_NtkCheckNode( Abc_Ntk_t * pNtk, Abc_Obj_t * pNode )
{
// detect internal nodes that do not have nets
if ( Abc_NtkIsNetlist(pNtk) && Abc_ObjFanoutNum(pNode) == 0 )
@@ -530,7 +533,7 @@ bool Abc_NtkCheckNode( Abc_Ntk_t * pNtk, Abc_Obj_t * pNode )
// the netlist and SOP logic network should have SOPs
if ( Abc_NtkHasSop(pNtk) )
{
- if ( !Abc_SopCheck( pNode->pData, Abc_ObjFaninNum(pNode) ) )
+ if ( !Abc_SopCheck( (char *)pNode->pData, Abc_ObjFaninNum(pNode) ) )
{
fprintf( stdout, "NodeCheck: SOP check for node \"%s\" has failed.\n", Abc_ObjNameNet(pNode) );
return 0;
@@ -538,7 +541,7 @@ bool Abc_NtkCheckNode( Abc_Ntk_t * pNtk, Abc_Obj_t * pNode )
}
else if ( Abc_NtkHasBdd(pNtk) )
{
- int nSuppSize = Cudd_SupportSize(pNtk->pManFunc, pNode->pData);
+ int nSuppSize = Cudd_SupportSize((DdManager *)pNtk->pManFunc, (DdNode *)pNode->pData);
if ( nSuppSize > Abc_ObjFaninNum(pNode) )
{
fprintf( stdout, "NodeCheck: BDD of the node \"%s\" has incorrect support size.\n", Abc_ObjNameNet(pNode) );
@@ -563,7 +566,7 @@ bool Abc_NtkCheckNode( Abc_Ntk_t * pNtk, Abc_Obj_t * pNode )
SeeAlso []
***********************************************************************/
-bool Abc_NtkCheckLatch( Abc_Ntk_t * pNtk, Abc_Obj_t * pLatch )
+int Abc_NtkCheckLatch( Abc_Ntk_t * pNtk, Abc_Obj_t * pLatch )
{
int Value = 1;
// check whether the object is a latch
@@ -629,7 +632,7 @@ bool Abc_NtkCheckLatch( Abc_Ntk_t * pNtk, Abc_Obj_t * pLatch )
SeeAlso []
***********************************************************************/
-bool Abc_NtkComparePis( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb )
+int Abc_NtkComparePis( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb )
{
Abc_Obj_t * pObj1;
int i;
@@ -662,7 +665,7 @@ bool Abc_NtkComparePis( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb )
SeeAlso []
***********************************************************************/
-bool Abc_NtkComparePos( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb )
+int Abc_NtkComparePos( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb )
{
Abc_Obj_t * pObj1;
int i;
@@ -695,7 +698,7 @@ bool Abc_NtkComparePos( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb )
SeeAlso []
***********************************************************************/
-bool Abc_NtkCompareBoxes( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb )
+int Abc_NtkCompareBoxes( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb )
{
Abc_Obj_t * pObj1;
int i;
@@ -733,7 +736,7 @@ bool Abc_NtkCompareBoxes( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb )
SeeAlso []
***********************************************************************/
-bool Abc_NtkCompareSignals( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fOnlyPis, int fComb )
+int Abc_NtkCompareSignals( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fOnlyPis, int fComb )
{
Abc_NtkOrderObjsByName( pNtk1, fComb );
Abc_NtkOrderObjsByName( pNtk2, fComb );
@@ -778,7 +781,7 @@ int Abc_NtkIsAcyclicHierarchy_rec( Abc_Ntk_t * pNtk )
{
if ( Abc_ObjIsLatch(pObj) )
continue;
- pNtkNext = pObj->pData;
+ pNtkNext = (Abc_Ntk_t *)pObj->pData;
assert( pNtkNext != NULL );
if ( pNtkNext->fHiePath )
return 0;
@@ -807,14 +810,14 @@ int Abc_NtkIsAcyclicHierarchy( Abc_Ntk_t * pNtk )
int i, RetValue;
assert( Abc_NtkIsNetlist(pNtk) && pNtk->pDesign );
// clear the modules
- Vec_PtrForEachEntry( pNtk->pDesign->vModules, pTemp, i )
+ Vec_PtrForEachEntry( Abc_Ntk_t *, pNtk->pDesign->vModules, pTemp, i )
pTemp->fHieVisited = pTemp->fHiePath = 0;
// traverse
pNtk->fHiePath = 1;
RetValue = Abc_NtkIsAcyclicHierarchy_rec( pNtk );
pNtk->fHiePath = 0;
// clear the modules
- Vec_PtrForEachEntry( pNtk->pDesign->vModules, pTemp, i )
+ Vec_PtrForEachEntry( Abc_Ntk_t *, pNtk->pDesign->vModules, pTemp, i )
pTemp->fHieVisited = pTemp->fHiePath = 0;
return RetValue;
}
@@ -855,9 +858,9 @@ int Abc_NtkCheckUniqueCiNames( Abc_Ntk_t * pNtk )
vNames = Vec_PtrAlloc( Abc_NtkCiNum(pNtk) );
Abc_NtkForEachCi( pNtk, pObj, i )
Vec_PtrPush( vNames, Abc_ObjName(pObj) );
- Vec_PtrSort( vNames, Abc_NtkNamesCompare );
+ Vec_PtrSort( vNames, (int (*)())Abc_NtkNamesCompare );
for ( i = 1; i < Abc_NtkCiNum(pNtk); i++ )
- if ( !strcmp( Vec_PtrEntry(vNames,i-1), Vec_PtrEntry(vNames,i) ) )
+ if ( !strcmp( (const char *)Vec_PtrEntry(vNames,i-1), (const char *)Vec_PtrEntry(vNames,i) ) )
{
printf( "Abc_NtkCheck: Repeated CI names: %s and %s.\n", (char*)Vec_PtrEntry(vNames,i-1), (char*)Vec_PtrEntry(vNames,i) );
fRetValue = 0;
@@ -886,11 +889,11 @@ int Abc_NtkCheckUniqueCoNames( Abc_Ntk_t * pNtk )
vNames = Vec_PtrAlloc( Abc_NtkCoNum(pNtk) );
Abc_NtkForEachCo( pNtk, pObj, i )
Vec_PtrPush( vNames, Abc_ObjName(pObj) );
- Vec_PtrSort( vNames, Abc_NtkNamesCompare );
+ Vec_PtrSort( vNames, (int (*)())Abc_NtkNamesCompare );
for ( i = 1; i < Abc_NtkCoNum(pNtk); i++ )
{
// printf( "%s\n", Vec_PtrEntry(vNames,i) );
- if ( !strcmp( Vec_PtrEntry(vNames,i-1), Vec_PtrEntry(vNames,i) ) )
+ if ( !strcmp( (const char *)Vec_PtrEntry(vNames,i-1), (const char *)Vec_PtrEntry(vNames,i) ) )
{
printf( "Abc_NtkCheck: Repeated CO names: %s and %s.\n", (char*)Vec_PtrEntry(vNames,i-1), (char*)Vec_PtrEntry(vNames,i) );
fRetValue = 0;
@@ -939,3 +942,5 @@ int Abc_NtkCheckUniqueCioNames( Abc_Ntk_t * pNtk )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abc/abcDfs.c b/src/base/abc/abcDfs.c
index 50ebef6d..20b361fb 100644
--- a/src/base/abc/abcDfs.c
+++ b/src/base/abc/abcDfs.c
@@ -20,6 +20,9 @@
#include "abc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -128,7 +131,7 @@ Vec_Ptr_t * Abc_NtkDfsNodes( Abc_Ntk_t * pNtk, Abc_Obj_t ** ppNodes, int nNodes
Abc_NodeSetTravIdCurrent(ppNodes[i]);
Abc_NtkDfs_rec( Abc_ObjFanin0Ntk(Abc_ObjFanin0(ppNodes[i])), vNodes );
}
- else if ( Abc_ObjIsNode(ppNodes[i]) )
+ else if ( Abc_ObjIsNode(ppNodes[i]) || Abc_ObjIsCi(ppNodes[i]) )
Abc_NtkDfs_rec( ppNodes[i], vNodes );
}
return vNodes;
@@ -237,7 +240,7 @@ void Abc_NtkDfsReverseNodes_rec( Abc_Obj_t * pNode, Vec_Ptr_t * vNodes )
// add the node after the fanins have been added
// Vec_PtrPush( vNodes, pNode );
Vec_PtrFillExtra( vNodes, pNode->Level + 1, NULL );
- pNode->pCopy = Vec_PtrEntry( vNodes, pNode->Level );
+ pNode->pCopy = (Abc_Obj_t *)Vec_PtrEntry( vNodes, pNode->Level );
Vec_PtrWriteEntry( vNodes, pNode->Level, pNode );
}
@@ -306,14 +309,14 @@ Vec_Ptr_t * Abc_NtkDfsReverseNodesContained( Abc_Ntk_t * pNtk, Abc_Obj_t ** ppNo
Abc_NodeSetTravIdCurrent( pObj );
// add to the array
assert( pObj->Level == 0 );
- pObj->pCopy = Vec_PtrEntry( vNodes, pObj->Level );
+ pObj->pCopy = (Abc_Obj_t *)Vec_PtrEntry( vNodes, pObj->Level );
Vec_PtrWriteEntry( vNodes, pObj->Level, pObj );
}
// iterate through the levels
for ( i = 0; i <= nLevels; i++ )
{
// iterate through the nodes on each level
- for ( pObj = Vec_PtrEntry(vNodes, i); pObj; pObj = pObj->pCopy )
+ for ( pObj = (Abc_Obj_t *)Vec_PtrEntry(vNodes, i); pObj; pObj = pObj->pCopy )
{
// iterate through the fanouts of each node
Abc_ObjForEachFanout( pObj, pFanout, k )
@@ -337,7 +340,7 @@ Vec_Ptr_t * Abc_NtkDfsReverseNodesContained( Abc_Ntk_t * pNtk, Abc_Obj_t ** ppNo
if ( Abc_ObjIsCo(pFanout) )
pFanout->Level = nLevels + 1;
// add to the array
- pFanout->pCopy = Vec_PtrEntry( vNodes, pFanout->Level );
+ pFanout->pCopy = (Abc_Obj_t *)Vec_PtrEntry( vNodes, pFanout->Level );
Vec_PtrWriteEntry( vNodes, pFanout->Level, pFanout );
// handle the COs
if ( Abc_ObjIsCo(pFanout) )
@@ -494,7 +497,7 @@ void Abc_NtkDfs_iter( Vec_Ptr_t * vStack, Abc_Obj_t * pRoot, Vec_Ptr_t * vNodes
{
// get the node and its fanin
iFanin = (int)(ABC_PTRINT_T)Vec_PtrPop(vStack);
- pNode = Vec_PtrPop(vStack);
+ pNode = (Abc_Obj_t *)Vec_PtrPop(vStack);
assert( !Abc_ObjIsNet(pNode) );
// add it to the array of nodes if we finished
if ( iFanin == Abc_ObjFaninNum(pNode) )
@@ -578,7 +581,7 @@ Vec_Ptr_t * Abc_NtkDfsIterNodes( Abc_Ntk_t * pNtk, Vec_Ptr_t * vRoots )
Abc_NtkIncrementTravId( pNtk );
vNodes = Vec_PtrAlloc( 1000 );
vStack = Vec_PtrAlloc( 1000 );
- Vec_PtrForEachEntry( vRoots, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vRoots, pObj, i )
if ( !Abc_NodeIsTravIdCurrent(Abc_ObjRegular(pObj)) )
Abc_NtkDfs_iter( vStack, Abc_ObjRegular(pObj), vNodes );
Vec_PtrFree( vStack );
@@ -657,7 +660,7 @@ Vec_Ptr_t * Abc_NtkDfsHie( Abc_Ntk_t * pNtk, int fCollectAll )
SeeAlso []
***********************************************************************/
-bool Abc_NtkIsDfsOrdered( Abc_Ntk_t * pNtk )
+int Abc_NtkIsDfsOrdered( Abc_Ntk_t * pNtk )
{
Abc_Obj_t * pNode, * pFanin;
int i, k;
@@ -675,7 +678,7 @@ bool Abc_NtkIsDfsOrdered( Abc_Ntk_t * pNtk )
return 0;
// check the choices of the node
if ( Abc_NtkIsStrash(pNtk) && Abc_AigNodeIsChoice(pNode) )
- for ( pFanin = pNode->pData; pFanin; pFanin = pFanin->pData )
+ for ( pFanin = (Abc_Obj_t *)pNode->pData; pFanin; pFanin = (Abc_Obj_t *)pFanin->pData )
if ( !Abc_NodeIsTravIdCurrent(pFanin) )
return 0;
// mark the node as visited
@@ -832,7 +835,7 @@ void Abc_AigDfs_rec( Abc_Obj_t * pNode, Vec_Ptr_t * vNodes )
Abc_AigDfs_rec( pFanin, vNodes );
// visit the equivalent nodes
if ( Abc_AigNodeIsChoice( pNode ) )
- for ( pFanin = pNode->pData; pFanin; pFanin = pFanin->pData )
+ for ( pFanin = (Abc_Obj_t *)pNode->pData; pFanin; pFanin = (Abc_Obj_t *)pFanin->pData )
Abc_AigDfs_rec( pFanin, vNodes );
// add the node after the fanins have been added
Vec_PtrPush( vNodes, pNode );
@@ -921,7 +924,7 @@ void Abc_DfsLevelizedTfo_rec( Abc_Obj_t * pNode, Vec_Vec_t * vLevels )
SeeAlso []
***********************************************************************/
-Vec_Vec_t * Abc_DfsLevelized( Abc_Obj_t * pNode, bool fTfi )
+Vec_Vec_t * Abc_DfsLevelized( Abc_Obj_t * pNode, int fTfi )
{
Vec_Vec_t * vLevels;
Abc_Obj_t * pFanout;
@@ -1118,7 +1121,7 @@ int Abc_NtkLevelReverse( Abc_Ntk_t * pNtk )
SeeAlso []
***********************************************************************/
-bool Abc_NtkIsAcyclic_rec( Abc_Obj_t * pNode )
+int Abc_NtkIsAcyclic_rec( Abc_Obj_t * pNode )
{
Abc_Ntk_t * pNtk = pNode->pNtk;
Abc_Obj_t * pFanin;
@@ -1157,7 +1160,7 @@ bool Abc_NtkIsAcyclic_rec( Abc_Obj_t * pNode )
// visit choices
if ( Abc_NtkIsStrash(pNode->pNtk) && Abc_AigNodeIsChoice(pNode) )
{
- for ( pFanin = pNode->pData; pFanin; pFanin = pFanin->pData )
+ for ( pFanin = (Abc_Obj_t *)pNode->pData; pFanin; pFanin = (Abc_Obj_t *)pFanin->pData )
{
// check if the fanin is visited
if ( Abc_NodeIsTravIdPrevious(pFanin) )
@@ -1194,10 +1197,11 @@ bool Abc_NtkIsAcyclic_rec( Abc_Obj_t * pNode )
SeeAlso []
***********************************************************************/
-bool Abc_NtkIsAcyclic( Abc_Ntk_t * pNtk )
+int Abc_NtkIsAcyclic( Abc_Ntk_t * pNtk )
{
Abc_Obj_t * pNode;
- int fAcyclic, i;
+ int fAcyclic;
+ int i;
// set the traversal ID for this DFS ordering
Abc_NtkIncrementTravId( pNtk );
Abc_NtkIncrementTravId( pNtk );
@@ -1247,16 +1251,16 @@ int Abc_NodeSetChoiceLevel_rec( Abc_Obj_t * pNode, int fMaximum )
Level = 1 + ABC_MAX( Level1, Level2 );
if ( pNode->pData )
{
- LevelE = Abc_NodeSetChoiceLevel_rec( pNode->pData, fMaximum );
+ LevelE = Abc_NodeSetChoiceLevel_rec( (Abc_Obj_t *)pNode->pData, fMaximum );
if ( fMaximum )
Level = ABC_MAX( Level, LevelE );
else
Level = ABC_MIN( Level, LevelE );
// set the level of all equivalent nodes to be the same minimum
- for ( pTemp = pNode->pData; pTemp; pTemp = pTemp->pData )
- pTemp->pCopy = (void *)(ABC_PTRINT_T)Level;
+ for ( pTemp = (Abc_Obj_t *)pNode->pData; pTemp; pTemp = (Abc_Obj_t *)pTemp->pData )
+ pTemp->pCopy = (Abc_Obj_t *)(ABC_PTRINT_T)Level;
}
- pNode->pCopy = (void *)(ABC_PTRINT_T)Level;
+ pNode->pCopy = (Abc_Obj_t *)(ABC_PTRINT_T)Level;
return Level;
}
@@ -1331,7 +1335,7 @@ Vec_Ptr_t * Abc_AigGetLevelizedOrder( Abc_Ntk_t * pNtk, int fCollectCis )
}
// recollect nodes
vNodes = Vec_PtrStart( Abc_NtkNodeNum(pNtk) );
- Vec_PtrForEachEntryStart( vLevels, pNode, i, !fCollectCis )
+ Vec_PtrForEachEntryStart( Abc_Obj_t *, vLevels, pNode, i, !fCollectCis )
for ( ; pNode; pNode = pNode->pCopy )
Vec_PtrPush( vNodes, pNode );
Vec_PtrFree( vLevels );
@@ -1388,3 +1392,5 @@ int Abc_NtkPrintSubraphSizes( Abc_Ntk_t * pNtk )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abc/abcFanio.c b/src/base/abc/abcFanio.c
index 6c75cf3f..ee6f4173 100644
--- a/src/base/abc/abcFanio.c
+++ b/src/base/abc/abcFanio.c
@@ -20,6 +20,9 @@
#include "abc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -274,14 +277,14 @@ void Abc_ObjTransferFanout( Abc_Obj_t * pNodeFrom, Abc_Obj_t * pNodeTo )
assert( !Abc_ObjIsPo(pNodeFrom) && !Abc_ObjIsPo(pNodeTo) );
assert( pNodeFrom->pNtk == pNodeTo->pNtk );
assert( pNodeFrom != pNodeTo );
- assert( Abc_ObjFanoutNum(pNodeFrom) > 0 );
+ assert( !Abc_ObjIsNode(pNodeFrom) || Abc_ObjFanoutNum(pNodeFrom) > 0 );
// get the fanouts of the old node
nFanoutsOld = Abc_ObjFanoutNum(pNodeTo);
vFanouts = Vec_PtrAlloc( nFanoutsOld );
Abc_NodeCollectFanouts( pNodeFrom, vFanouts );
// patch the fanin of each of them
for ( i = 0; i < vFanouts->nSize; i++ )
- Abc_ObjPatchFanin( vFanouts->pArray[i], pNodeFrom, pNodeTo );
+ Abc_ObjPatchFanin( (Abc_Obj_t *)vFanouts->pArray[i], pNodeFrom, pNodeTo );
assert( Abc_ObjFanoutNum(pNodeFrom) == 0 );
assert( Abc_ObjFanoutNum(pNodeTo) == nFanoutsOld + vFanouts->nSize );
Vec_PtrFree( vFanouts );
@@ -338,3 +341,5 @@ int Abc_ObjFanoutFaninNum( Abc_Obj_t * pFanout, Abc_Obj_t * pFanin )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abc/abcFunc.c b/src/base/abc/abcFunc.c
index df46fc06..35ea8332 100644
--- a/src/base/abc/abcFunc.c
+++ b/src/base/abc/abcFunc.c
@@ -22,6 +22,9 @@
#include "main.h"
#include "mio.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -66,16 +69,16 @@ int Abc_NtkSopToBdd( Abc_Ntk_t * pNtk )
Abc_NtkForEachNode( pNtk, pNode, i )
{
assert( pNode->pData );
- pNode->pData = Abc_ConvertSopToBdd( dd, pNode->pData );
+ pNode->pData = Abc_ConvertSopToBdd( dd, (char *)pNode->pData );
if ( pNode->pData == NULL )
{
printf( "Abc_NtkSopToBdd: Error while converting SOP into BDD.\n" );
return 0;
}
- Cudd_Ref( pNode->pData );
+ Cudd_Ref( (DdNode *)pNode->pData );
}
- Extra_MmFlexStop( pNtk->pManFunc );
+ Extra_MmFlexStop( (Extra_MmFlex_t *)pNtk->pManFunc );
pNtk->pManFunc = dd;
// update the network type
@@ -164,7 +167,7 @@ void Abc_NtkLogicMakeDirectSops( Abc_Ntk_t * pNtk )
// check if there are nodes with complemented SOPs
fFound = 0;
Abc_NtkForEachNode( pNtk, pNode, i )
- if ( Abc_SopIsComplement(pNode->pData) )
+ if ( Abc_SopIsComplement((char *)pNode->pData) )
{
fFound = 1;
break;
@@ -181,12 +184,12 @@ void Abc_NtkLogicMakeDirectSops( Abc_Ntk_t * pNtk )
// change the cover of negated nodes
vCube = Vec_StrAlloc( 100 );
Abc_NtkForEachNode( pNtk, pNode, i )
- if ( Abc_SopIsComplement(pNode->pData) )
+ if ( Abc_SopIsComplement((char *)pNode->pData) )
{
- bFunc = Abc_ConvertSopToBdd( dd, pNode->pData ); Cudd_Ref( bFunc );
- pNode->pData = Abc_ConvertBddToSop( pNtk->pManFunc, dd, bFunc, bFunc, Abc_ObjFaninNum(pNode), 0, vCube, 1 );
+ bFunc = Abc_ConvertSopToBdd( dd, (char *)pNode->pData ); Cudd_Ref( bFunc );
+ pNode->pData = Abc_ConvertBddToSop( (Extra_MmFlex_t *)pNtk->pManFunc, dd, bFunc, bFunc, Abc_ObjFaninNum(pNode), 0, vCube, 1 );
Cudd_RecursiveDeref( dd, bFunc );
- assert( !Abc_SopIsComplement(pNode->pData) );
+ assert( !Abc_SopIsComplement((char *)pNode->pData) );
}
Vec_StrFree( vCube );
Extra_StopManager( dd );
@@ -211,7 +214,7 @@ int Abc_NtkBddToSop( Abc_Ntk_t * pNtk, int fDirect )
{
Abc_Obj_t * pNode;
Extra_MmFlex_t * pManNew;
- DdManager * dd = pNtk->pManFunc;
+ DdManager * dd = (DdManager *)pNtk->pManFunc;
DdNode * bFunc;
Vec_Str_t * vCube;
int i, fMode;
@@ -232,7 +235,7 @@ int Abc_NtkBddToSop( Abc_Ntk_t * pNtk, int fDirect )
Abc_NtkForEachNode( pNtk, pNode, i )
{
assert( pNode->pData );
- bFunc = pNode->pData;
+ bFunc = (DdNode *)pNode->pData;
pNode->pNext = (Abc_Obj_t *)Abc_ConvertBddToSop( pManNew, dd, bFunc, bFunc, Abc_ObjFaninNum(pNode), 0, vCube, fMode );
if ( pNode->pNext == NULL )
{
@@ -252,7 +255,7 @@ int Abc_NtkBddToSop( Abc_Ntk_t * pNtk, int fDirect )
// transfer from next to data
Abc_NtkForEachNode( pNtk, pNode, i )
{
- Cudd_RecursiveDeref( dd, pNode->pData );
+ Cudd_RecursiveDeref( dd, (DdNode *)pNode->pData );
pNode->pData = pNode->pNext;
pNode->pNext = NULL;
}
@@ -482,8 +485,8 @@ int Abc_ConvertZddToSop( DdManager * dd, DdNode * zCover, char * pSop, int nFani
void Abc_NodeBddToCnf( Abc_Obj_t * pNode, Extra_MmFlex_t * pMmMan, Vec_Str_t * vCube, int fAllPrimes, char ** ppSop0, char ** ppSop1 )
{
assert( Abc_NtkHasBdd(pNode->pNtk) );
- *ppSop0 = Abc_ConvertBddToSop( pMmMan, pNode->pNtk->pManFunc, pNode->pData, pNode->pData, Abc_ObjFaninNum(pNode), fAllPrimes, vCube, 0 );
- *ppSop1 = Abc_ConvertBddToSop( pMmMan, pNode->pNtk->pManFunc, pNode->pData, pNode->pData, Abc_ObjFaninNum(pNode), fAllPrimes, vCube, 1 );
+ *ppSop0 = Abc_ConvertBddToSop( pMmMan, (DdManager *)pNode->pNtk->pManFunc, (DdNode *)pNode->pData, (DdNode *)pNode->pData, Abc_ObjFaninNum(pNode), fAllPrimes, vCube, 0 );
+ *ppSop1 = Abc_ConvertBddToSop( pMmMan, (DdManager *)pNode->pNtk->pManFunc, (DdNode *)pNode->pData, (DdNode *)pNode->pData, Abc_ObjFaninNum(pNode), fAllPrimes, vCube, 1 );
}
@@ -563,14 +566,14 @@ int Abc_NtkSopToAig( Abc_Ntk_t * pNtk )
Abc_NtkForEachNode( pNtk, pNode, i )
{
assert( pNode->pData );
- pNode->pData = Abc_ConvertSopToAig( pMan, pNode->pData );
+ pNode->pData = Abc_ConvertSopToAig( pMan, (char *)pNode->pData );
if ( pNode->pData == NULL )
{
printf( "Abc_NtkSopToAig: Error while converting SOP into AIG.\n" );
return 0;
}
}
- Extra_MmFlexStop( pNtk->pManFunc );
+ Extra_MmFlexStop( (Extra_MmFlex_t *)pNtk->pManFunc );
pNtk->pManFunc = pMan;
// update the network type
@@ -595,27 +598,32 @@ Hop_Obj_t * Abc_ConvertSopToAigInternal( Hop_Man_t * pMan, char * pSop )
Hop_Obj_t * pAnd, * pSum;
int i, Value, nFanins;
char * pCube;
- int fExor = Abc_SopIsExorType(pSop);
// get the number of variables
nFanins = Abc_SopGetVarNum(pSop);
- // go through the cubes of the node's SOP
- pSum = Hop_ManConst0(pMan);
- Abc_SopForEachCube( pSop, nFanins, pCube )
+ if ( Abc_SopIsExorType(pSop) )
+ {
+ pSum = Hop_ManConst0(pMan);
+ for ( i = 0; i < nFanins; i++ )
+ pSum = Hop_Exor( pMan, pSum, Hop_IthVar(pMan,i) );
+ }
+ else
{
- // create the AND of literals
- pAnd = Hop_ManConst1(pMan);
- Abc_CubeForEachVar( pCube, Value, i )
+ // go through the cubes of the node's SOP
+ pSum = Hop_ManConst0(pMan);
+ Abc_SopForEachCube( pSop, nFanins, pCube )
{
- if ( Value == '1' )
- pAnd = Hop_And( pMan, pAnd, Hop_IthVar(pMan,i) );
- else if ( Value == '0' )
- pAnd = Hop_And( pMan, pAnd, Hop_Not(Hop_IthVar(pMan,i)) );
- }
- // add to the sum of cubes
- if ( fExor )
- pSum = Hop_Exor( pMan, pSum, pAnd );
- else
+ // create the AND of literals
+ pAnd = Hop_ManConst1(pMan);
+ Abc_CubeForEachVar( pCube, Value, i )
+ {
+ if ( Value == '1' )
+ pAnd = Hop_And( pMan, pAnd, Hop_IthVar(pMan,i) );
+ else if ( Value == '0' )
+ pAnd = Hop_And( pMan, pAnd, Hop_Not(Hop_IthVar(pMan,i)) );
+ }
+ // add to the sum of cubes
pSum = Hop_Or( pMan, pSum, pAnd );
+ }
}
// decide whether to complement the result
if ( Abc_SopIsComplement(pSop) )
@@ -675,32 +683,32 @@ int Abc_NtkAigToBdd( Abc_Ntk_t * pNtk )
dd = Cudd_Init( nFaninsMax, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 );
// set the mapping of elementary AIG nodes into the elementary BDD nodes
- pMan = pNtk->pManFunc;
+ pMan = (Hop_Man_t *)pNtk->pManFunc;
assert( Hop_ManPiNum(pMan) >= nFaninsMax );
for ( i = 0; i < nFaninsMax; i++ )
{
Hop_ManPi(pMan, i)->pData = Cudd_bddIthVar(dd, i);
- Cudd_Ref( Hop_ManPi(pMan, i)->pData );
+ Cudd_Ref( (DdNode *)Hop_ManPi(pMan, i)->pData );
}
// convert each node from SOP to BDD
Abc_NtkForEachNode( pNtk, pNode, i )
{
assert( pNode->pData );
- pNode->pData = Abc_ConvertAigToBdd( dd, pNode->pData );
+ pNode->pData = Abc_ConvertAigToBdd( dd, (Hop_Obj_t *)pNode->pData );
if ( pNode->pData == NULL )
{
printf( "Abc_NtkSopToBdd: Error while converting SOP into BDD.\n" );
return 0;
}
- Cudd_Ref( pNode->pData );
+ Cudd_Ref( (DdNode *)pNode->pData );
}
// dereference intermediate BDD nodes
for ( i = 0; i < nFaninsMax; i++ )
- Cudd_RecursiveDeref( dd, Hop_ManPi(pMan, i)->pData );
+ Cudd_RecursiveDeref( dd, (DdNode *) Hop_ManPi(pMan, i)->pData );
- Hop_ManStop( pNtk->pManFunc );
+ Hop_ManStop( (Hop_Man_t *)pNtk->pManFunc );
pNtk->pManFunc = dd;
// update the network type
@@ -727,7 +735,7 @@ void Abc_ConvertAigToBdd_rec1( DdManager * dd, Hop_Obj_t * 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 );
+ Cudd_Ref( (DdNode *)pObj->pData );
assert( !Hop_ObjIsMarkA(pObj) ); // loop detection
Hop_ObjSetMarkA( pObj );
}
@@ -750,7 +758,7 @@ void Abc_ConvertAigToBdd_rec2( DdManager * dd, Hop_Obj_t * pObj )
return;
Abc_ConvertAigToBdd_rec2( dd, Hop_ObjFanin0(pObj) );
Abc_ConvertAigToBdd_rec2( dd, Hop_ObjFanin1(pObj) );
- Cudd_RecursiveDeref( dd, pObj->pData );
+ Cudd_RecursiveDeref( dd, (DdNode *)pObj->pData );
pObj->pData = NULL;
assert( Hop_ObjIsMarkA(pObj) ); // loop detection
Hop_ObjClearMarkA( pObj );
@@ -805,7 +813,7 @@ void Abc_ConvertAigToAig_rec( Abc_Ntk_t * pNtkAig, Hop_Obj_t * pObj )
return;
Abc_ConvertAigToAig_rec( pNtkAig, Hop_ObjFanin0(pObj) );
Abc_ConvertAigToAig_rec( pNtkAig, Hop_ObjFanin1(pObj) );
- pObj->pData = Abc_AigAnd( pNtkAig->pManFunc, (Abc_Obj_t *)Hop_ObjChild0Copy(pObj), (Abc_Obj_t *)Hop_ObjChild1Copy(pObj) );
+ pObj->pData = Abc_AigAnd( (Abc_Aig_t *)pNtkAig->pManFunc, (Abc_Obj_t *)Hop_ObjChild0Copy(pObj), (Abc_Obj_t *)Hop_ObjChild1Copy(pObj) );
assert( !Hop_ObjIsMarkA(pObj) ); // loop detection
Hop_ObjSetMarkA( pObj );
}
@@ -828,8 +836,8 @@ Abc_Obj_t * Abc_ConvertAigToAig( Abc_Ntk_t * pNtkAig, Abc_Obj_t * pObjOld )
Abc_Obj_t * pFanin;
int i;
// get the local AIG
- pHopMan = pObjOld->pNtk->pManFunc;
- pRoot = pObjOld->pData;
+ pHopMan = (Hop_Man_t *)pObjOld->pNtk->pManFunc;
+ pRoot = (Hop_Obj_t *)pObjOld->pData;
// check the case of a constant
if ( Hop_ObjIsConst1( Hop_Regular(pRoot) ) )
return Abc_ObjNotCond( Abc_AigConst1(pNtkAig), Hop_IsComplement(pRoot) );
@@ -843,7 +851,7 @@ Abc_Obj_t * Abc_ConvertAigToAig( Abc_Ntk_t * pNtkAig, Abc_Obj_t * pObjOld )
Abc_ConvertAigToAig_rec( pNtkAig, Hop_Regular(pRoot) );
Hop_ConeUnmark_rec( Hop_Regular(pRoot) );
// return the result
- return Abc_ObjNotCond( Hop_Regular(pRoot)->pData, Hop_IsComplement(pRoot) );
+ return Abc_ObjNotCond( (Abc_Obj_t *)Hop_Regular(pRoot)->pData, Hop_IsComplement(pRoot) );
}
@@ -873,9 +881,9 @@ int Abc_NtkMapToSop( Abc_Ntk_t * pNtk )
// update the nodes
Abc_NtkForEachNode( pNtk, pNode, i )
{
- pSop = Mio_GateReadSop(pNode->pData);
+ pSop = Mio_GateReadSop((Mio_Gate_t *)pNode->pData);
assert( Abc_SopGetVarNum(pSop) == Abc_ObjFaninNum(pNode) );
- pNode->pData = Abc_SopRegister( pNtk->pManFunc, pSop );
+ pNode->pData = Abc_SopRegister( (Extra_MmFlex_t *)pNtk->pManFunc, pSop );
}
return 1;
}
@@ -1000,3 +1008,5 @@ int Abc_NtkToAig( Abc_Ntk_t * pNtk )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abc/abcHie.c b/src/base/abc/abcHie.c
index 2addf289..1155731e 100644
--- a/src/base/abc/abcHie.c
+++ b/src/base/abc/abcHie.c
@@ -20,6 +20,9 @@
#include "abc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -143,7 +146,7 @@ void Abc_NtkFlattenLogicHierarchy2_rec( Abc_Ntk_t * pNtkNew, Abc_Ntk_t * pNtk, i
{
if ( Abc_ObjIsLatch(pObj) )
continue;
- pNtkModel = pObj->pData;
+ pNtkModel = (Abc_Ntk_t *)pObj->pData;
// check the match between the number of actual and formal parameters
assert( Abc_ObjFaninNum(pObj) == Abc_NtkPiNum(pNtkModel) );
assert( Abc_ObjFanoutNum(pObj) == Abc_NtkPoNum(pNtkModel) );
@@ -293,7 +296,7 @@ void Abc_NtkFlattenLogicHierarchy_rec( Abc_Ntk_t * pNtkNew, Abc_Ntk_t * pNtk, in
{
char Buffer[20];
sprintf( Buffer, "(%d)", *pCounter );
- Vec_StrAppend( vPref, Buffer );
+ Vec_StrPrintStr( vPref, Buffer );
}
Vec_StrPush( vPref, '|' );
Vec_StrPush( vPref, 0 );
@@ -369,7 +372,7 @@ void Abc_NtkFlattenLogicHierarchy_rec( Abc_Ntk_t * pNtkNew, Abc_Ntk_t * pNtk, in
{
if ( Abc_ObjIsLatch(pObj) )
continue;
- pNtkModel = pObj->pData;
+ pNtkModel = (Abc_Ntk_t *)pObj->pData;
// check the match between the number of actual and formal parameters
assert( Abc_ObjFaninNum(pObj) == Abc_NtkPiNum(pNtkModel) );
assert( Abc_ObjFanoutNum(pObj) == Abc_NtkPoNum(pNtkModel) );
@@ -382,7 +385,7 @@ void Abc_NtkFlattenLogicHierarchy_rec( Abc_Ntk_t * pNtkNew, Abc_Ntk_t * pNtk, in
Abc_ObjFanin0( Abc_NtkPo(pNtkModel, k) )->pCopy = Abc_ObjFanout0(pTerm)->pCopy;
// create name
Vec_StrShrink( vPref, Length );
- Vec_StrAppend( vPref, Abc_NtkName(pNtkModel) );
+ Vec_StrPrintStr( vPref, Abc_NtkName(pNtkModel) );
// call recursively
Abc_NtkFlattenLogicHierarchy_rec( pNtkNew, pNtkModel, pCounter, vPref );
}
@@ -444,7 +447,7 @@ Abc_Ntk_t * Abc_NtkFlattenLogicHierarchy( Abc_Ntk_t * pNtk )
// recursively flatten hierarchy, create internal logic, add new PI/PO names if there are black boxes
vPref = Vec_StrAlloc( 1000 );
- Vec_StrAppend( vPref, Abc_NtkName(pNtk) );
+ Vec_StrPrintStr( vPref, Abc_NtkName(pNtk) );
Abc_NtkFlattenLogicHierarchy_rec( pNtkNew, pNtk, &Counter, vPref );
printf( "Hierarchy reader flattened %d instances of logic boxes and left %d black boxes.\n",
Counter, Abc_NtkBlackboxNum(pNtkNew) );
@@ -734,3 +737,5 @@ Abc_Ntk_t * Abc_NtkInsertNewLogic( Abc_Ntk_t * pNtkH, Abc_Ntk_t * pNtkL )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abc/abcInt.h b/src/base/abc/abcInt.h
index 0e35e774..326ff5a2 100644
--- a/src/base/abc/abcInt.h
+++ b/src/base/abc/abcInt.h
@@ -21,6 +21,10 @@
#ifndef __ABC_INT_H__
#define __ABC_INT_H__
+
+ABC_NAMESPACE_HEADER_START
+
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -43,6 +47,10 @@
/// FUNCTION DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif
////////////////////////////////////////////////////////////////////////
diff --git a/src/base/abc/abcLatch.c b/src/base/abc/abcLatch.c
index baf4e64b..7528f470 100644
--- a/src/base/abc/abcLatch.c
+++ b/src/base/abc/abcLatch.c
@@ -20,6 +20,8 @@
#include "abc.h"
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -39,7 +41,7 @@
SeeAlso []
***********************************************************************/
-bool Abc_NtkLatchIsSelfFeed_rec( Abc_Obj_t * pLatch, Abc_Obj_t * pLatchRoot )
+int Abc_NtkLatchIsSelfFeed_rec( Abc_Obj_t * pLatch, Abc_Obj_t * pLatchRoot )
{
Abc_Obj_t * pFanin;
assert( Abc_ObjIsLatch(pLatch) );
@@ -62,7 +64,7 @@ bool Abc_NtkLatchIsSelfFeed_rec( Abc_Obj_t * pLatch, Abc_Obj_t * pLatchRoot )
SeeAlso []
***********************************************************************/
-bool Abc_NtkLatchIsSelfFeed( Abc_Obj_t * pLatch )
+int Abc_NtkLatchIsSelfFeed( Abc_Obj_t * pLatch )
{
Abc_Obj_t * pFanin;
assert( Abc_ObjIsLatch(pLatch) );
@@ -163,7 +165,7 @@ void Abc_NtkLatchPipe( Abc_Ntk_t * pNtk, int nLatches )
Abc_ObjAssignName( pLatch, Abc_ObjNameDummy("LL", i*nLatches + k, nDigits), NULL );
}
// patch the PI fanouts
- Vec_PtrForEachEntry( vNodes, pFanout, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pFanout, k )
Abc_ObjPatchFanin( pFanout, pObj, pFanin );
}
Vec_PtrFree( vNodes );
@@ -255,11 +257,11 @@ void Abc_NtkNodeConvertToMux( Abc_Ntk_t * pNtk, Abc_Obj_t * pNodeC, Abc_Obj_t *
Abc_ObjAddFanin( pMux, pNode1 );
Abc_ObjAddFanin( pMux, pNode0 );
if ( Abc_NtkHasSop(pNtk) )
- pMux->pData = Abc_SopRegister( pNtk->pManFunc, "11- 1\n0-1 1\n" );
+ pMux->pData = Abc_SopRegister( (Extra_MmFlex_t *)pNtk->pManFunc, "11- 1\n0-1 1\n" );
else if ( Abc_NtkHasBdd(pNtk) )
- pMux->pData = Cudd_bddIte(pNtk->pManFunc,Cudd_bddIthVar(pNtk->pManFunc,0),Cudd_bddIthVar(pNtk->pManFunc,1),Cudd_bddIthVar(pNtk->pManFunc,2)), Cudd_Ref( pMux->pData );
+ pMux->pData = Cudd_bddIte((DdManager *)pNtk->pManFunc,Cudd_bddIthVar((DdManager *)pNtk->pManFunc,0),Cudd_bddIthVar((DdManager *)pNtk->pManFunc,1),Cudd_bddIthVar((DdManager *)pNtk->pManFunc,2)), Cudd_Ref( (DdNode *)pMux->pData );
else if ( Abc_NtkHasAig(pNtk) )
- pMux->pData = Hop_Mux(pNtk->pManFunc,Hop_IthVar(pNtk->pManFunc,0),Hop_IthVar(pNtk->pManFunc,1),Hop_IthVar(pNtk->pManFunc,2));
+ pMux->pData = Hop_Mux((Hop_Man_t *)pNtk->pManFunc,Hop_IthVar((Hop_Man_t *)pNtk->pManFunc,0),Hop_IthVar((Hop_Man_t *)pNtk->pManFunc,1),Hop_IthVar((Hop_Man_t *)pNtk->pManFunc,2));
else
assert( 0 );
}
@@ -343,10 +345,10 @@ Vec_Ptr_t * Abc_NtkConverLatchNamesIntoNumbers( Abc_Ntk_t * pNtk )
pObj->pNext = (Abc_Obj_t *)(ABC_PTRINT_T)i;
// add the numbers
vResult = Vec_PtrAlloc( Vec_PtrSize(pNtk->vOnehots) );
- Vec_PtrForEachEntry( pNtk->vOnehots, vNames, i )
+ Vec_PtrForEachEntry( Vec_Ptr_t *, pNtk->vOnehots, vNames, i )
{
vNumbers = Vec_IntAlloc( Vec_PtrSize(vNames) );
- Vec_PtrForEachEntry( vNames, pName, k )
+ Vec_PtrForEachEntry( char *, vNames, pName, k )
{
Num = Nm_ManFindIdByName( pNtk->pManName, pName, ABC_OBJ_BO );
if ( Num < 0 )
@@ -442,14 +444,14 @@ Abc_Ntk_t * Abc_NtkConvertOnehot( Abc_Ntk_t * pNtk )
if ( (k >> i) & 1 )
Abc_ObjAddFanin( pObjNew, Abc_NtkCi(pNtkNew, Abc_NtkPiNum(pNtkNew)+k) );
assert( Abc_ObjFaninNum(pObjNew) == nStates/2 );
- pObjNew->pData = Abc_SopCreateOr( pNtkNew->pManFunc, nStates/2, NULL );
+ pObjNew->pData = Abc_SopCreateOr( (Extra_MmFlex_t *)pNtkNew->pManFunc, nStates/2, NULL );
// save the new flop
pObj = Abc_NtkCi( pNtk, Abc_NtkPiNum(pNtk) + i );
pObj->pCopy = pObjNew;
}
// duplicate the nodes
vNodes = Abc_NtkDfs( pNtk, 0 );
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
{
pObj->pCopy = Abc_NtkDupObj( pNtkNew, pObj, 1 );
Abc_ObjForEachFanin( pObj, pFanin, k )
@@ -472,7 +474,7 @@ Abc_Ntk_t * Abc_NtkConvertOnehot( Abc_Ntk_t * pNtk )
Abc_ObjAddFanin( pObjNew, Abc_ObjRegular(pObj->pCopy) );
pfCompl[i] = Abc_ObjIsComplement(pObj->pCopy) ^ !((k >> i) & 1);
}
- pObjNew->pData = Abc_SopCreateAnd( pNtkNew->pManFunc, nFlops, pfCompl );
+ pObjNew->pData = Abc_SopCreateAnd( (Extra_MmFlex_t *)pNtkNew->pManFunc, nFlops, pfCompl );
// connect it to the flop input
Abc_ObjAddFanin( Abc_NtkCo(pNtkNew, Abc_NtkPoNum(pNtkNew)+k), pObjNew );
}
@@ -481,8 +483,13 @@ Abc_Ntk_t * Abc_NtkConvertOnehot( Abc_Ntk_t * pNtk )
return pNtkNew;
}
+ABC_NAMESPACE_IMPL_END
+
#include "giaAig.h"
+ABC_NAMESPACE_IMPL_START
+
+
/**Function*************************************************************
Synopsis [Performs retiming with classes.]
@@ -559,7 +566,7 @@ void Abc_NtkTransformBack( Abc_Ntk_t * pNtkOld, Abc_Ntk_t * pNtkNew, Vec_Ptr_t *
Abc_NtkForEachPo( pNtkOld, pObj, i )
pObj->pCopy = Abc_NtkPo( pNtkNew, i );
// remap the flops
- Vec_PtrForEachEntry( vControls, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vControls, pObj, i )
{
assert( Abc_ObjIsPo(pObj) && pObj->pNtk == pNtkOld );
Vec_PtrWriteEntry( vControls, i, pObj->pCopy );
@@ -572,17 +579,17 @@ void Abc_NtkTransformBack( Abc_Ntk_t * pNtkOld, Abc_Ntk_t * pNtkNew, Vec_Ptr_t *
if ( Class == -1 )
continue;
pDriver = Abc_ObjFanin0(Abc_ObjFanin0(pObj));
- pCtrl = Vec_PtrEntry( vControls, Class );
+ pCtrl = (Abc_Obj_t *)Vec_PtrEntry( vControls, Class );
pCtrl = Abc_ObjFanin0( pCtrl );
pNodeNew = Abc_NtkCreateNode( pNtkNew );
Abc_ObjAddFanin( pNodeNew, pCtrl );
Abc_ObjAddFanin( pNodeNew, pDriver );
Abc_ObjAddFanin( pNodeNew, Abc_ObjFanout0(pObj) );
- Abc_ObjSetData( pNodeNew, Abc_SopRegister(pNtkNew->pManFunc, "0-1 1\n11- 1\n") );
+ Abc_ObjSetData( pNodeNew, Abc_SopRegister((Extra_MmFlex_t *)pNtkNew->pManFunc, "0-1 1\n11- 1\n") );
Abc_ObjPatchFanin( Abc_ObjFanin0(pObj), pDriver, pNodeNew );
}
// remove the useless POs
- Vec_PtrForEachEntry( vControls, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vControls, pObj, i )
Abc_NtkDeleteObj( pObj );
}
@@ -649,7 +656,7 @@ Abc_Ntk_t * Abc_NtkCRetime( Abc_Ntk_t * pNtk, int fVerbose )
CountN, Count2, Count1, Count0, Vec_PtrSize(vControls) );
// add the controls to the list of POs
- Vec_PtrForEachEntry( vControls, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vControls, pObj, i )
{
pObjPo = Abc_NtkCreatePo( pNtk );
Abc_ObjAddFanin( pObjPo, pObj );
@@ -676,3 +683,5 @@ Abc_Ntk_t * Abc_NtkCRetime( Abc_Ntk_t * pNtk, int fVerbose )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abc/abcLib.c b/src/base/abc/abcLib.c
index 4540462d..d3e4d735 100644
--- a/src/base/abc/abcLib.c
+++ b/src/base/abc/abcLib.c
@@ -20,6 +20,9 @@
#include "abc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -71,12 +74,12 @@ void Abc_LibFree( Abc_Lib_t * pLib, Abc_Ntk_t * pNtkSave )
if ( pLib->pName )
ABC_FREE( pLib->pName );
if ( pLib->pManFunc )
- Hop_ManStop( pLib->pManFunc );
+ Hop_ManStop( (Hop_Man_t *)pLib->pManFunc );
if ( pLib->tModules )
st_free_table( pLib->tModules );
if ( pLib->vModules )
{
- Vec_PtrForEachEntry( pLib->vModules, pNtk, i )
+ Vec_PtrForEachEntry( Abc_Ntk_t *, pLib->vModules, pNtk, i )
{
if ( pNtk == pNtkSave )
continue;
@@ -115,7 +118,7 @@ Abc_Lib_t * Abc_LibDupBlackboxes( Abc_Lib_t * pLib, Abc_Ntk_t * pNtkSave )
// pLibNew->pManFunc = pNtkSave->pManFunc;
Vec_PtrPush( pLibNew->vTops, pNtkSave );
Vec_PtrPush( pLibNew->vModules, pNtkSave );
- Vec_PtrForEachEntry( pLib->vModules, pNtkTemp, i )
+ Vec_PtrForEachEntry( Abc_Ntk_t *, pLib->vModules, pNtkTemp, i )
if ( Abc_NtkHasBlackbox( pNtkTemp ) )
Vec_PtrPush( pLibNew->vModules, Abc_NtkDup(pNtkTemp) );
return pLibNew;
@@ -139,7 +142,7 @@ void Abc_LibPrint( Abc_Lib_t * pLib )
Abc_Obj_t * pObj;
int i, k;
printf( "Models of design %s:\n", pLib->pName );
- Vec_PtrForEachEntry( pLib->vModules, pNtk, i )
+ Vec_PtrForEachEntry( Abc_Ntk_t *, pLib->vModules, pNtk, i )
{
printf( "%2d : %20s ", i+1, pNtk->pName );
printf( "nd = %6d lat = %6d whitebox = %3d blackbox = %3d\n",
@@ -148,9 +151,9 @@ void Abc_LibPrint( Abc_Lib_t * pLib )
if ( Abc_NtkBlackboxNum(pNtk) == 0 )
continue;
Abc_NtkForEachWhitebox( pNtk, pObj, k )
- printf( " %20s (whitebox)\n", Abc_NtkName(pObj->pData) );
+ printf( " %20s (whitebox)\n", Abc_NtkName((Abc_Ntk_t *)pObj->pData) );
Abc_NtkForEachBlackbox( pNtk, pObj, k )
- printf( " %20s (blackbox)\n", Abc_NtkName(pObj->pData) );
+ printf( " %20s (blackbox)\n", Abc_NtkName((Abc_Ntk_t *)pObj->pData) );
}
}
@@ -214,7 +217,7 @@ Abc_Ntk_t * Abc_LibDeriveRoot( Abc_Lib_t * pLib )
printf( "The design includes more than one module and is currently not used.\n" );
return NULL;
}
- pNtk = Vec_PtrEntry( pLib->vModules, 0 ); Vec_PtrClear( pLib->vModules );
+ pNtk = (Abc_Ntk_t *)Vec_PtrEntry( pLib->vModules, 0 ); Vec_PtrClear( pLib->vModules );
pNtk->pManFunc = pLib->pManFunc; pLib->pManFunc = NULL;
return pNtk;
}
@@ -237,10 +240,10 @@ int Abc_LibFindTopLevelModels( Abc_Lib_t * pLib )
int i, k;
assert( Vec_PtrSize( pLib->vModules ) > 0 );
// clear the models
- Vec_PtrForEachEntry( pLib->vModules, pNtk, i )
+ Vec_PtrForEachEntry( Abc_Ntk_t *, pLib->vModules, pNtk, i )
pNtk->fHieVisited = 0;
// mark all the models reachable from other models
- Vec_PtrForEachEntry( pLib->vModules, pNtk, i )
+ Vec_PtrForEachEntry( Abc_Ntk_t *, pLib->vModules, pNtk, i )
{
Abc_NtkForEachBox( pNtk, pObj, k )
{
@@ -248,13 +251,13 @@ int Abc_LibFindTopLevelModels( Abc_Lib_t * pLib )
continue;
if ( pObj->pData == NULL )
continue;
- pNtkBox = pObj->pData;
+ pNtkBox = (Abc_Ntk_t *)pObj->pData;
pNtkBox->fHieVisited = 1;
}
}
// collect the models that are not marked
Vec_PtrClear( pLib->vTops );
- Vec_PtrForEachEntry( pLib->vModules, pNtk, i )
+ Vec_PtrForEachEntry( Abc_Ntk_t *, pLib->vModules, pNtk, i )
{
if ( pNtk->fHieVisited == 0 )
Vec_PtrPush( pLib->vTops, pNtk );
@@ -364,7 +367,7 @@ void Abc_NodeStrashUsingNetwork( Abc_Ntk_t * pNtkAig, Abc_Obj_t * pBox )
unsigned * pPolarity;
int i, fCompl;
assert( Abc_ObjIsBox(pBox) );
- pNtkGate = pBox->pData;
+ pNtkGate = (Abc_Ntk_t *)pBox->pData;
pPolarity = (unsigned *)pBox->pNext;
assert( Abc_NtkIsNetlist(pNtkGate) );
assert( Abc_NtkLatchNum(pNtkGate) == 0 );
@@ -416,7 +419,7 @@ Abc_Ntk_t * Abc_LibDeriveAig( Abc_Ntk_t * pNtk, Abc_Lib_t * pLib )
// build the AIG for the remaining logic in the netlist
vNodes = Abc_NtkDfs( pNtk, 0 );
pProgress = Extra_ProgressBarStart( stdout, Vec_PtrSize(vNodes) );
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
{
Extra_ProgressBarUpdate( pProgress, i, NULL );
if ( Abc_ObjIsNode(pObj) )
@@ -432,14 +435,14 @@ Abc_Ntk_t * Abc_LibDeriveAig( Abc_Ntk_t * pNtk, Abc_Lib_t * pLib )
// deallocate memory manager, which remembers the phase
if ( pNtk->pData )
{
- Extra_MmFlexStop( pNtk->pData );
+ Extra_MmFlexStop( (Extra_MmFlex_t *)pNtk->pData );
pNtk->pData = NULL;
}
// set the COs
// Abc_NtkFinalize( pNtk, pNtkAig );
Abc_NtkForEachCo( pNtk, pObj, i )
Abc_ObjAddFanin( pObj->pCopy, Abc_ObjFanin0(pObj)->pCopy );
- Abc_AigCleanup( pNtkAig->pManFunc );
+ Abc_AigCleanup( (Abc_Aig_t *)pNtkAig->pManFunc );
// make sure that everything is okay
if ( !Abc_NtkCheck( pNtkAig ) )
{
@@ -454,3 +457,5 @@ Abc_Ntk_t * Abc_LibDeriveAig( Abc_Ntk_t * pNtk, Abc_Lib_t * pLib )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abc/abcMinBase.c b/src/base/abc/abcMinBase.c
index 5186c920..ee0085a2 100644
--- a/src/base/abc/abcMinBase.c
+++ b/src/base/abc/abcMinBase.c
@@ -20,6 +20,9 @@
#include "abc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -87,12 +90,12 @@ int Abc_NodeMinimumBase( Abc_Obj_t * pNode )
Abc_NodeCollectFanins( pNode, vFanins );
for ( i = 0; i < vFanins->nSize; i++ )
if ( vSupport->pArray[i] == 0 )
- Abc_ObjDeleteFanin( pNode, vFanins->pArray[i] );
+ Abc_ObjDeleteFanin( pNode, (Abc_Obj_t *)vFanins->pArray[i] );
assert( nVars == Abc_ObjFaninNum(pNode) );
// update the function of the node
- pNode->pData = Extra_bddRemapUp( pNode->pNtk->pManFunc, bTemp = pNode->pData ); Cudd_Ref( pNode->pData );
- Cudd_RecursiveDeref( pNode->pNtk->pManFunc, bTemp );
+ pNode->pData = Extra_bddRemapUp( (DdManager *)pNode->pNtk->pManFunc, bTemp = (DdNode *)pNode->pData ); Cudd_Ref( (DdNode *)pNode->pData );
+ Cudd_RecursiveDeref( (DdManager *)pNode->pNtk->pManFunc, bTemp );
Vec_PtrFree( vFanins );
Vec_StrFree( vSupport );
return 1;
@@ -146,12 +149,12 @@ int Abc_NodeRemoveDupFanins_int( Abc_Obj_t * pNode )
break;
if ( pFanin1 == pFanin2 )
{
- DdManager * dd = pNode->pNtk->pManFunc;
+ DdManager * dd = (DdManager *)pNode->pNtk->pManFunc;
DdNode * bVar1 = Cudd_bddIthVar( dd, i );
DdNode * bVar2 = Cudd_bddIthVar( dd, k );
DdNode * bTrans, * bTemp;
bTrans = Cudd_bddXnor( dd, bVar1, bVar2 ); Cudd_Ref( bTrans );
- pNode->pData = Cudd_bddAndAbstract( dd, bTemp = pNode->pData, bTrans, bVar2 ); Cudd_Ref( pNode->pData );
+ pNode->pData = Cudd_bddAndAbstract( dd, bTemp = (DdNode *)pNode->pData, bTrans, bVar2 ); Cudd_Ref( (DdNode *)pNode->pData );
Cudd_RecursiveDeref( dd, bTemp );
Cudd_RecursiveDeref( dd, bTrans );
Abc_NodeMinimumBase( pNode );
@@ -315,7 +318,7 @@ int Abc_ObjFaninNumberNew( Vec_Ptr_t * vFanins, Abc_Obj_t * pFanin )
{
Abc_Obj_t * pObj;
int i;
- Vec_PtrForEachEntry( vFanins, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vFanins, pObj, i )
if ( pObj == pFanin )
return i;
return -1;
@@ -363,7 +366,7 @@ int Abc_NodeCollapsePermMap( Abc_Obj_t * pNode, Abc_Obj_t * pSkip, Vec_Ptr_t * v
***********************************************************************/
DdNode * Abc_NodeCollapseFunc( Abc_Obj_t * pFanin, Abc_Obj_t * pFanout, Vec_Ptr_t * vFanins, int * pPermFanin, int * pPermFanout )
{
- DdManager * dd = pFanin->pNtk->pManFunc;
+ DdManager * dd = (DdManager *)pFanin->pNtk->pManFunc;
DdNode * bVar, * bFunc0, * bFunc1, * bTemp, * bFanin, * bFanout;
int RetValue, nSize, iFanin;
// can only eliminate if fanin occurs in the fanin list of the fanout exactly once
@@ -380,14 +383,14 @@ DdNode * Abc_NodeCollapseFunc( Abc_Obj_t * pFanin, Abc_Obj_t * pFanout, Vec_Ptr_
assert( RetValue );
// cofactor the local function of the node
bVar = Cudd_bddIthVar( dd, iFanin );
- bFunc0 = Cudd_Cofactor( dd, pFanout->pData, Cudd_Not(bVar) ); Cudd_Ref( bFunc0 );
- bFunc1 = Cudd_Cofactor( dd, pFanout->pData, bVar ); Cudd_Ref( bFunc1 );
+ bFunc0 = Cudd_Cofactor( dd, (DdNode *)pFanout->pData, Cudd_Not(bVar) ); Cudd_Ref( bFunc0 );
+ bFunc1 = Cudd_Cofactor( dd, (DdNode *)pFanout->pData, bVar ); Cudd_Ref( bFunc1 );
// find the permutation after collapsing
bFunc0 = Cudd_bddPermute( dd, bTemp = bFunc0, pPermFanout ); Cudd_Ref( bFunc0 );
Cudd_RecursiveDeref( dd, bTemp );
bFunc1 = Cudd_bddPermute( dd, bTemp = bFunc1, pPermFanout ); Cudd_Ref( bFunc1 );
Cudd_RecursiveDeref( dd, bTemp );
- bFanin = Cudd_bddPermute( dd, pFanin->pData, pPermFanin ); Cudd_Ref( bFanin );
+ bFanin = Cudd_bddPermute( dd, (DdNode *)pFanin->pData, pPermFanin ); Cudd_Ref( bFanin );
// create the new function
bFanout = Cudd_bddIte( dd, bFanin, bFunc1, bFunc0 ); Cudd_Ref( bFanout );
Cudd_RecursiveDeref( dd, bFanin );
@@ -422,7 +425,7 @@ int Abc_NodeCollapse( Abc_Obj_t * pFanin, Abc_Obj_t * pFanout, Vec_Ptr_t * vFani
Cudd_Ref( bFanoutNew );
// create the new node
pFanoutNew = Abc_NtkCreateNode( pFanin->pNtk );
- Vec_PtrForEachEntry( vFanins, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vFanins, pObj, i )
Abc_ObjAddFanin( pFanoutNew, pObj );
pFanoutNew->pData = bFanoutNew;
// minimize the node
@@ -471,7 +474,7 @@ int Abc_NtkEliminate( Abc_Ntk_t * pNtk, int nMaxSize, int fReverse, int fVerbose
pPermFanout = ABC_ALLOC( int, nMaxSize + 100 );
vFanins = Vec_PtrAlloc( 100 );
vFanouts = Vec_PtrAlloc( 100 );
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
{
if ( Abc_NodeFindCoFanout(pNode) != NULL )
continue;
@@ -484,7 +487,7 @@ int Abc_NtkEliminate( Abc_Ntk_t * pNtk, int nMaxSize, int fReverse, int fVerbose
continue;
// perform elimination
Abc_NodeCollectFanouts( pNode, vFanouts );
- Vec_PtrForEachEntry( vFanouts, pFanout, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vFanouts, pFanout, k )
{
RetValue = Abc_NodeCollapse( pNode, pFanout, vFanins, pPermFanin, pPermFanout );
assert( RetValue );
@@ -504,3 +507,5 @@ int Abc_NtkEliminate( Abc_Ntk_t * pNtk, int nMaxSize, int fReverse, int fVerbose
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abc/abcNames.c b/src/base/abc/abcNames.c
index e07b47c1..f8041ec7 100644
--- a/src/base/abc/abcNames.c
+++ b/src/base/abc/abcNames.c
@@ -20,6 +20,9 @@
#include "abc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -140,7 +143,6 @@ void Abc_NtkTrasferNames( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew )
assert( Abc_NtkPiNum(pNtk) == Abc_NtkPiNum(pNtkNew) );
assert( Abc_NtkPoNum(pNtk) == Abc_NtkPoNum(pNtkNew) );
assert( Abc_NtkBoxNum(pNtk) == Abc_NtkBoxNum(pNtkNew) );
- assert( Abc_NtkAssertNum(pNtk) == Abc_NtkAssertNum(pNtkNew) );
assert( Nm_ManNumEntries(pNtk->pManName) > 0 );
assert( Nm_ManNumEntries(pNtkNew->pManName) == 0 );
// copy the CI/CO/box names
@@ -169,7 +171,6 @@ void Abc_NtkTrasferNamesNoLatches( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew )
int i;
assert( Abc_NtkPiNum(pNtk) == Abc_NtkPiNum(pNtkNew) );
assert( Abc_NtkPoNum(pNtk) == Abc_NtkPoNum(pNtkNew) );
- assert( Abc_NtkAssertNum(pNtk) == Abc_NtkAssertNum(pNtkNew) );
assert( Nm_ManNumEntries(pNtk->pManName) > 0 );
assert( Nm_ManNumEntries(pNtkNew->pManName) == 0 );
// copy the CI/CO/box name and skip latches and theirs inputs/outputs
@@ -330,7 +331,6 @@ void Abc_NtkOrderObjsByName( Abc_Ntk_t * pNtk, int fComb )
{
Abc_Obj_t * pObj;
int i;
- assert( Abc_NtkAssertNum(pNtk) == 0 );
assert( Abc_NtkHasOnlyLatchBoxes(pNtk) );
// temporarily store the names in the copy field
Abc_NtkForEachPi( pNtk, pObj, i )
@@ -410,37 +410,51 @@ void Abc_NtkAddDummyPoNames( Abc_Ntk_t * pNtk )
SeeAlso []
***********************************************************************/
-void Abc_NtkAddDummyAssertNames( Abc_Ntk_t * pNtk )
-{
- Abc_Obj_t * pObj;
- int nDigits, i;
- nDigits = Extra_Base10Log( Abc_NtkAssertNum(pNtk) );
- Abc_NtkForEachAssert( pNtk, pObj, i )
- Abc_ObjAssignName( pObj, Abc_ObjNameDummy("a", i, nDigits), NULL );
-}
-
-/**Function*************************************************************
-
- Synopsis [Adds dummy names.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
void Abc_NtkAddDummyBoxNames( Abc_Ntk_t * pNtk )
{
+ char * pName, PrefLi[100], PrefLo[100];
Abc_Obj_t * pObj;
- int nDigits, i;
+ int nDigits, i, k, CountCur, CountMax = 0;
+ // if PIs/POs already have nodes with what looks like latch names
+ // we need to add different prefix for the new latches
+ Abc_NtkForEachPi( pNtk, pObj, i )
+ {
+ CountCur = 0;
+ pName = Abc_ObjName(pObj);
+ for ( k = 0; pName[k]; k++ )
+ if ( pName[k] == 'l' )
+ CountCur++;
+ else
+ break;
+ CountMax = ABC_MAX( CountMax, CountCur );
+ }
+ Abc_NtkForEachPo( pNtk, pObj, i )
+ {
+ CountCur = 0;
+ pName = Abc_ObjName(pObj);
+ for ( k = 0; pName[k]; k++ )
+ if ( pName[k] == 'l' )
+ CountCur++;
+ else
+ break;
+ CountMax = ABC_MAX( CountMax, CountCur );
+ }
+//printf( "CountMax = %d\n", CountMax );
+ assert( CountMax < 100-2 );
+ for ( i = 0; i <= CountMax; i++ )
+ PrefLi[i] = PrefLo[i] = 'l';
+ PrefLi[i] = 'i';
+ PrefLo[i] = 'o';
+ PrefLi[i+1] = 0;
+ PrefLo[i+1] = 0;
+ // create latch names
assert( !Abc_NtkIsNetlist(pNtk) );
nDigits = Extra_Base10Log( Abc_NtkLatchNum(pNtk) );
Abc_NtkForEachLatch( pNtk, pObj, i )
{
Abc_ObjAssignName( pObj, Abc_ObjNameDummy("l", i, nDigits), NULL );
- Abc_ObjAssignName( Abc_ObjFanin0(pObj), Abc_ObjNameDummy("li", i, nDigits), NULL );
- Abc_ObjAssignName( Abc_ObjFanout0(pObj), Abc_ObjNameDummy("lo", i, nDigits), NULL );
+ Abc_ObjAssignName( Abc_ObjFanin0(pObj), Abc_ObjNameDummy(PrefLi, i, nDigits), NULL );
+ Abc_ObjAssignName( Abc_ObjFanout0(pObj), Abc_ObjNameDummy(PrefLo, i, nDigits), NULL );
}
/*
nDigits = Extra_Base10Log( Abc_NtkBlackboxNum(pNtk) );
@@ -474,7 +488,6 @@ void Abc_NtkShortNames( Abc_Ntk_t * pNtk )
pNtk->pManName = Nm_ManCreate( Abc_NtkCiNum(pNtk) + Abc_NtkCoNum(pNtk) + Abc_NtkBoxNum(pNtk) );
Abc_NtkAddDummyPiNames( pNtk );
Abc_NtkAddDummyPoNames( pNtk );
- Abc_NtkAddDummyAssertNames( pNtk );
Abc_NtkAddDummyBoxNames( pNtk );
}
@@ -483,3 +496,5 @@ void Abc_NtkShortNames( Abc_Ntk_t * pNtk )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abc/abcNetlist.c b/src/base/abc/abcNetlist.c
index 26b88c68..9077e621 100644
--- a/src/base/abc/abcNetlist.c
+++ b/src/base/abc/abcNetlist.c
@@ -21,6 +21,9 @@
#include "abc.h"
//#include "seq.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -252,7 +255,7 @@ Abc_Ntk_t * Abc_NtkAigToLogicSop( Abc_Ntk_t * pNtk )
Abc_NtkForEachNode( pNtk, pObj, i )
{
Abc_NtkDupObj(pNtkNew, pObj, 0);
- pObj->pCopy->pData = Abc_SopCreateAnd2( pNtkNew->pManFunc, Abc_ObjFaninC0(pObj), Abc_ObjFaninC1(pObj) );
+ pObj->pCopy->pData = Abc_SopCreateAnd2( (Extra_MmFlex_t *)pNtkNew->pManFunc, Abc_ObjFaninC0(pObj), Abc_ObjFaninC1(pObj) );
}
// create the choice nodes
Abc_NtkForEachNode( pNtk, pObj, i )
@@ -263,13 +266,13 @@ Abc_Ntk_t * Abc_NtkAigToLogicSop( Abc_Ntk_t * pNtk )
pNodeNew = Abc_NtkCreateNode(pNtkNew);
// add fanins
vInts = Vec_IntAlloc( 10 );
- for ( pFanin = pObj; pFanin; pFanin = pFanin->pData )
+ for ( pFanin = pObj; pFanin; pFanin = (Abc_Obj_t *)pFanin->pData )
{
Vec_IntPush( vInts, (int)(pObj->fPhase != pFanin->fPhase) );
Abc_ObjAddFanin( pNodeNew, pFanin->pCopy );
}
// create the logic function
- pNodeNew->pData = Abc_SopCreateOrMultiCube( pNtkNew->pManFunc, Vec_IntSize(vInts), Vec_IntArray(vInts) );
+ pNodeNew->pData = Abc_SopCreateOrMultiCube( (Extra_MmFlex_t *)pNtkNew->pManFunc, Vec_IntSize(vInts), Vec_IntArray(vInts) );
// set the new node
pObj->pCopy->pCopy = pNodeNew;
Vec_IntFree( vInts );
@@ -332,26 +335,26 @@ Abc_Ntk_t * Abc_NtkAigToLogicSopBench( Abc_Ntk_t * pNtk )
pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_SOP );
// collect the nodes to be used (marks all nodes with current TravId)
vNodes = Abc_NtkDfs( pNtk, 0 );
- // create inverters for the CI and remember them
+ // create inverters for the constant node
pObj = Abc_AigConst1(pNtk);
- if ( Abc_AigNodeHasComplFanoutEdgeTrav(pObj) )
- {
+ if ( Abc_ObjFanoutNum(pObj) > 0 )
pObj->pCopy = Abc_NtkCreateNodeConst1(pNtkNew);
+ if ( Abc_AigNodeHasComplFanoutEdgeTrav(pObj) )
pObj->pCopy->pCopy = Abc_NtkCreateNodeInv( pNtkNew, pObj->pCopy );
- }
+ // create inverters for the CIs
Abc_NtkForEachCi( pNtk, pObj, i )
if ( Abc_AigNodeHasComplFanoutEdgeTrav(pObj) )
pObj->pCopy->pCopy = Abc_NtkCreateNodeInv( pNtkNew, pObj->pCopy );
// duplicate the nodes, create node functions, and inverters
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
{
Abc_NtkDupObj( pNtkNew, pObj, 0 );
- pObj->pCopy->pData = Abc_SopCreateAnd( pNtkNew->pManFunc, 2, NULL );
+ pObj->pCopy->pData = Abc_SopCreateAnd( (Extra_MmFlex_t *)pNtkNew->pManFunc, 2, NULL );
if ( Abc_AigNodeHasComplFanoutEdgeTrav(pObj) )
pObj->pCopy->pCopy = Abc_NtkCreateNodeInv( pNtkNew, pObj->pCopy );
}
// connect the objects
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
Abc_ObjForEachFanin( pObj, pFanin, k )
{
if ( Abc_ObjFaninC( pObj, k ) )
@@ -409,3 +412,5 @@ void Abc_NtkAddPoBuffers( Abc_Ntk_t * pNtk )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abc/abcNtk.c b/src/base/abc/abcNtk.c
index ae345467..602ad548 100644
--- a/src/base/abc/abcNtk.c
+++ b/src/base/abc/abcNtk.c
@@ -22,6 +22,10 @@
#include "abcInt.h"
#include "main.h"
#include "mio.h"
+#include "gia.h"
+
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -51,13 +55,13 @@ Abc_Ntk_t * Abc_NtkAlloc( Abc_NtkType_t Type, Abc_NtkFunc_t Func, int fUseMemMan
pNtk->ntkFunc = Func;
// start the object storage
pNtk->vObjs = Vec_PtrAlloc( 100 );
- pNtk->vAsserts = Vec_PtrAlloc( 100 );
pNtk->vPios = Vec_PtrAlloc( 100 );
pNtk->vPis = Vec_PtrAlloc( 100 );
pNtk->vPos = Vec_PtrAlloc( 100 );
pNtk->vCis = Vec_PtrAlloc( 100 );
pNtk->vCos = Vec_PtrAlloc( 100 );
pNtk->vBoxes = Vec_PtrAlloc( 100 );
+ pNtk->vLtlProperties = Vec_PtrAlloc( 100 );
// start the memory managers
pNtk->pMmObj = fUseMemMan? Extra_MmFixedStart( sizeof(Abc_Obj_t) ) : NULL;
pNtk->pMmStep = fUseMemMan? Extra_MmStepStart( ABC_NUM_STEPS ) : NULL;
@@ -105,6 +109,7 @@ Abc_Ntk_t * Abc_NtkStartFrom( Abc_Ntk_t * pNtk, Abc_NtkType_t Type, Abc_NtkFunc_
fCopyNames = ( Type != ABC_NTK_NETLIST );
// start the network
pNtkNew = Abc_NtkAlloc( Type, Func, 1 );
+ pNtkNew->nConstrs = pNtk->nConstrs;
// duplicate the name and the spec
pNtkNew->pName = Extra_UtilStrsav(pNtk->pName);
pNtkNew->pSpec = Extra_UtilStrsav(pNtk->pSpec);
@@ -118,8 +123,6 @@ Abc_Ntk_t * Abc_NtkStartFrom( Abc_Ntk_t * pNtk, Abc_NtkType_t Type, Abc_NtkFunc_
Abc_NtkDupObj( pNtkNew, pObj, fCopyNames );
Abc_NtkForEachPo( pNtk, pObj, i )
Abc_NtkDupObj( pNtkNew, pObj, fCopyNames );
- Abc_NtkForEachAssert( pNtk, pObj, i )
- Abc_NtkDupObj( pNtkNew, pObj, fCopyNames );
Abc_NtkForEachBox( pNtk, pObj, i )
Abc_NtkDupBox( pNtkNew, pObj, fCopyNames );
// transfer the names
@@ -127,6 +130,10 @@ Abc_Ntk_t * Abc_NtkStartFrom( Abc_Ntk_t * pNtk, Abc_NtkType_t Type, Abc_NtkFunc_
Abc_ManTimeDup( pNtk, pNtkNew );
if ( pNtk->vOnehots )
pNtkNew->vOnehots = (Vec_Ptr_t *)Vec_VecDupInt( (Vec_Vec_t *)pNtk->vOnehots );
+ if ( pNtk->pSeqModel )
+ {
+ pNtkNew->pSeqModel = Gia_ManDupCounterExample( pNtk->pSeqModel, Abc_NtkLatchNum(pNtk) );
+ }
// check that the CI/CO/latches are copied correctly
assert( Abc_NtkCiNum(pNtk) == Abc_NtkCiNum(pNtkNew) );
assert( Abc_NtkCoNum(pNtk) == Abc_NtkCoNum(pNtkNew) );
@@ -155,6 +162,7 @@ Abc_Ntk_t * Abc_NtkStartFromNoLatches( Abc_Ntk_t * pNtk, Abc_NtkType_t Type, Abc
assert( Type != ABC_NTK_NETLIST );
// start the network
pNtkNew = Abc_NtkAlloc( Type, Func, 1 );
+ pNtkNew->nConstrs = pNtk->nConstrs;
// duplicate the name and the spec
pNtkNew->pName = Extra_UtilStrsav(pNtk->pName);
pNtkNew->pSpec = Extra_UtilStrsav(pNtk->pSpec);
@@ -168,8 +176,6 @@ Abc_Ntk_t * Abc_NtkStartFromNoLatches( Abc_Ntk_t * pNtk, Abc_NtkType_t Type, Abc
Abc_NtkDupObj( pNtkNew, pObj, 1 );
Abc_NtkForEachPo( pNtk, pObj, i )
Abc_NtkDupObj( pNtkNew, pObj, 1 );
- Abc_NtkForEachAssert( pNtk, pObj, i )
- Abc_NtkDupObj( pNtkNew, pObj, 1 );
Abc_NtkForEachBox( pNtk, pObj, i )
{
if ( Abc_ObjIsLatch(pObj) )
@@ -320,7 +326,7 @@ Abc_Ntk_t * Abc_NtkDup( Abc_Ntk_t * pNtk )
{
// copy the AND gates
Abc_AigForEachAnd( pNtk, pObj, i )
- pObj->pCopy = Abc_AigAnd( pNtkNew->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
+ pObj->pCopy = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
// relink the choice nodes
Abc_AigForEachAnd( pNtk, pObj, i )
if ( pObj->pData )
@@ -349,7 +355,7 @@ Abc_Ntk_t * Abc_NtkDup( Abc_Ntk_t * pNtk )
if ( pNtk->pExdc )
pNtkNew->pExdc = Abc_NtkDup( pNtk->pExdc );
if ( pNtk->pExcare )
- pNtkNew->pExcare = Abc_NtkDup( pNtk->pExcare );
+ pNtkNew->pExcare = Abc_NtkDup( (Abc_Ntk_t *)pNtk->pExcare );
if ( !Abc_NtkCheck( pNtkNew ) )
fprintf( stdout, "Abc_NtkDup(): Network check has failed.\n" );
pNtk->pCopy = pNtkNew;
@@ -387,8 +393,6 @@ Abc_Ntk_t * Abc_NtkDouble( Abc_Ntk_t * pNtk )
Abc_NtkDupObj( pNtkNew, pObj, 0 );
Abc_NtkForEachPo( pNtk, pObj, i )
Abc_NtkDupObj( pNtkNew, pObj, 0 );
- Abc_NtkForEachAssert( pNtk, pObj, i )
- Abc_NtkDupObj( pNtkNew, pObj, 0 );
Abc_NtkForEachBox( pNtk, pObj, i )
Abc_NtkDupBox( pNtkNew, pObj, 0 );
// copy the internal nodes
@@ -409,8 +413,6 @@ Abc_Ntk_t * Abc_NtkDouble( Abc_Ntk_t * pNtk )
Abc_NtkDupObj( pNtkNew, pObj, 0 );
Abc_NtkForEachPo( pNtk, pObj, i )
Abc_NtkDupObj( pNtkNew, pObj, 0 );
- Abc_NtkForEachAssert( pNtk, pObj, i )
- Abc_NtkDupObj( pNtkNew, pObj, 0 );
Abc_NtkForEachBox( pNtk, pObj, i )
Abc_NtkDupBox( pNtkNew, pObj, 0 );
// copy the internal nodes
@@ -484,7 +486,7 @@ Abc_Ntk_t * Abc_NtkAttachBottom( Abc_Ntk_t * pNtkTop, Abc_Ntk_t * pNtkBottom )
Abc_NtkPi(pNtkBottom, i)->pCopy = Abc_NtkPi(pNtkTop, i);
// construct all nodes
vNodes = Abc_NtkDfs( pNtkBottom, 0 );
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
{
Abc_NtkDupObj(pNtkTop, pObj, 0);
Abc_ObjForEachFanin( pObj, pFanin, k )
@@ -549,12 +551,12 @@ Abc_Ntk_t * Abc_NtkCreateCone( Abc_Ntk_t * pNtk, Abc_Obj_t * pNode, char * pNode
pNodeCoNew = Abc_NtkCreatePo( pNtkNew );
Abc_ObjAssignName( pNodeCoNew, pNodeName, NULL );
// copy the nodes
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
{
// if it is an AIG, add to the hash table
if ( Abc_NtkIsStrash(pNtk) )
{
- pObj->pCopy = Abc_AigAnd( pNtkNew->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
+ pObj->pCopy = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
}
else
{
@@ -617,12 +619,12 @@ Abc_Ntk_t * Abc_NtkCreateConeArray( Abc_Ntk_t * pNtk, Vec_Ptr_t * vRoots, int fU
}
// copy the nodes
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
{
// if it is an AIG, add to the hash table
if ( Abc_NtkIsStrash(pNtk) )
{
- pObj->pCopy = Abc_AigAnd( pNtkNew->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
+ pObj->pCopy = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
}
else
{
@@ -634,7 +636,7 @@ Abc_Ntk_t * Abc_NtkCreateConeArray( Abc_Ntk_t * pNtk, Vec_Ptr_t * vRoots, int fU
Vec_PtrFree( vNodes );
// add the POs corresponding to the root nodes
- Vec_PtrForEachEntry( vRoots, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vRoots, pObj, i )
{
// create the PO node
pNodeCoNew = Abc_NtkCreatePo( pNtkNew );
@@ -696,8 +698,8 @@ void Abc_NtkAppendToCone( Abc_Ntk_t * pNtkNew, Abc_Ntk_t * pNtk, Vec_Ptr_t * vRo
}
// copy the nodes
- Vec_PtrForEachEntry( vNodes, pObj, i )
- pObj->pCopy = Abc_AigAnd( pNtkNew->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
+ pObj->pCopy = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
Vec_PtrFree( vNodes );
// do not add the COs
@@ -744,7 +746,7 @@ Abc_Ntk_t * Abc_NtkCreateMffc( Abc_Ntk_t * pNtk, Abc_Obj_t * pNode, char * pNode
Abc_NodeMffcConeSupp( pNode, vCone, vSupp );
Abc_NodeRef_rec( pNode );
// create the PIs
- Vec_PtrForEachEntry( vSupp, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vSupp, pObj, i )
{
pObj->pCopy = Abc_NtkCreatePi(pNtkNew);
Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(pObj), NULL );
@@ -753,12 +755,12 @@ Abc_Ntk_t * Abc_NtkCreateMffc( Abc_Ntk_t * pNtk, Abc_Obj_t * pNode, char * pNode
pNodeCoNew = Abc_NtkCreatePo( pNtkNew );
Abc_ObjAssignName( pNodeCoNew, pNodeName, NULL );
// copy the nodes
- Vec_PtrForEachEntry( vCone, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vCone, pObj, i )
{
// if it is an AIG, add to the hash table
if ( Abc_NtkIsStrash(pNtk) )
{
- pObj->pCopy = Abc_AigAnd( pNtkNew->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
+ pObj->pCopy = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
}
else
{
@@ -811,13 +813,13 @@ Abc_Ntk_t * Abc_NtkCreateTarget( Abc_Ntk_t * pNtk, Vec_Ptr_t * vRoots, Vec_Int_t
Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(pObj), NULL );
}
// copy the nodes
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
pObj->pCopy = Abc_NodeStrash( pNtkNew, pObj, 0 );
Vec_PtrFree( vNodes );
// add the PO
pFinal = Abc_AigConst1( pNtkNew );
- Vec_PtrForEachEntry( vRoots, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vRoots, pObj, i )
{
if ( Abc_ObjIsCo(pObj) )
pOther = Abc_ObjFanin0(pObj)->pCopy;
@@ -825,7 +827,7 @@ Abc_Ntk_t * Abc_NtkCreateTarget( Abc_Ntk_t * pNtk, Vec_Ptr_t * vRoots, Vec_Int_t
pOther = pObj->pCopy;
if ( Vec_IntEntry(vValues, i) == 0 )
pOther = Abc_ObjNot(pOther);
- pFinal = Abc_AigAnd( pNtkNew->pManFunc, pFinal, pOther );
+ pFinal = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, pFinal, pOther );
}
// add the PO corresponding to this output
@@ -900,13 +902,13 @@ Abc_Ntk_t * Abc_NtkCreateWithNode( char * pSop )
nVars = Abc_SopGetVarNum( pSop );
vNames = Abc_NodeGetFakeNames( nVars );
for ( i = 0; i < nVars; i++ )
- Abc_ObjAssignName( Abc_NtkCreatePi(pNtkNew), Vec_PtrEntry(vNames, i), NULL );
+ Abc_ObjAssignName( Abc_NtkCreatePi(pNtkNew), (char *)Vec_PtrEntry(vNames, i), NULL );
Abc_NodeFreeNames( vNames );
// create the node, add PIs as fanins, set the function
pNode = Abc_NtkCreateNode( pNtkNew );
Abc_NtkForEachPi( pNtkNew, pFanin, i )
Abc_ObjAddFanin( pNode, pFanin );
- pNode->pData = Abc_SopRegister( pNtkNew->pManFunc, pSop );
+ pNode->pData = Abc_SopRegister( (Extra_MmFlex_t *)pNtkNew->pManFunc, pSop );
// create the only PO
pNodePo = Abc_NtkCreatePo(pNtkNew);
Abc_ObjAddFanin( pNodePo, pNode );
@@ -942,12 +944,12 @@ void Abc_NtkDelete( Abc_Ntk_t * pNtk )
if ( pNtk->pExdc )
Abc_NtkDelete( pNtk->pExdc );
if ( pNtk->pExcare )
- Abc_NtkDelete( pNtk->pExcare );
+ Abc_NtkDelete( (Abc_Ntk_t *)pNtk->pExcare );
// dereference the BDDs
if ( Abc_NtkHasBdd(pNtk) )
{
Abc_NtkForEachNode( pNtk, pObj, i )
- Cudd_RecursiveDeref( pNtk->pManFunc, pObj->pData );
+ Cudd_RecursiveDeref( (DdManager *)pNtk->pManFunc, (DdNode *)pObj->pData );
}
// make sure all the marks are clean
Abc_NtkForEachObj( pNtk, pObj, i )
@@ -982,12 +984,13 @@ void Abc_NtkDelete( Abc_Ntk_t * pNtk )
Vec_PtrFree( pNtk->vPos );
Vec_PtrFree( pNtk->vCis );
Vec_PtrFree( pNtk->vCos );
- Vec_PtrFree( pNtk->vAsserts );
Vec_PtrFree( pNtk->vObjs );
Vec_PtrFree( pNtk->vBoxes );
if ( pNtk->vLevelsR ) Vec_IntFree( pNtk->vLevelsR );
ABC_FREE( pNtk->pModel );
ABC_FREE( pNtk->pSeqModel );
+ if ( pNtk->pSeqModelVec )
+ Vec_PtrFreeFree( pNtk->pSeqModelVec );
TotalMemory = 0;
TotalMemory += pNtk->pMmObj? Extra_MmFixedReadMemUsage(pNtk->pMmObj) : 0;
TotalMemory += pNtk->pMmStep? Extra_MmStepReadMemUsage(pNtk->pMmStep) : 0;
@@ -1004,13 +1007,13 @@ void Abc_NtkDelete( Abc_Ntk_t * pNtk )
Abc_ManTimeStop( pNtk->pManTime );
// start the functionality manager
if ( Abc_NtkIsStrash(pNtk) )
- Abc_AigFree( pNtk->pManFunc );
+ Abc_AigFree( (Abc_Aig_t *)pNtk->pManFunc );
else if ( Abc_NtkHasSop(pNtk) || Abc_NtkHasBlifMv(pNtk) )
- Extra_MmFlexStop( pNtk->pManFunc );
+ Extra_MmFlexStop( (Extra_MmFlex_t *)pNtk->pManFunc );
else if ( Abc_NtkHasBdd(pNtk) )
- Extra_StopManager( pNtk->pManFunc );
+ Extra_StopManager( (DdManager *)pNtk->pManFunc );
else if ( Abc_NtkHasAig(pNtk) )
- { if ( pNtk->pManFunc ) Hop_ManStop( pNtk->pManFunc ); }
+ { if ( pNtk->pManFunc ) Hop_ManStop( (Hop_Man_t *)pNtk->pManFunc ); }
else if ( Abc_NtkHasMapping(pNtk) )
pNtk->pManFunc = NULL;
else if ( !Abc_NtkHasBlackbox(pNtk) )
@@ -1024,11 +1027,11 @@ void Abc_NtkDelete( Abc_Ntk_t * pNtk )
// if ( pNtk->pBlackBoxes )
// Vec_IntFree( pNtk->pBlackBoxes );
// free node attributes
- Vec_PtrForEachEntry( pNtk->vAttrs, pAttrMan, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, pNtk->vAttrs, pAttrMan, i )
if ( pAttrMan )
{
//printf( "deleting attr\n" );
- Vec_AttFree( pAttrMan, 1 );
+ Vec_AttFree( (Vec_Att_t *)pAttrMan, 1 );
}
Vec_PtrFree( pNtk->vAttrs );
ABC_FREE( pNtk->pName );
@@ -1059,6 +1062,14 @@ void Abc_NtkFixNonDrivenNets( Abc_Ntk_t * pNtk )
if ( Abc_NtkNodeNum(pNtk) == 0 && Abc_NtkBoxNum(pNtk) == 0 )
return;
+ // special case
+ pNet = Abc_NtkFindNet( pNtk, "[_c1_]" );
+ if ( pNet != NULL )
+ {
+ pNode = Abc_NtkCreateNodeConst1( pNtk );
+ Abc_ObjAddFanin( pNet, pNode );
+ }
+
// check for non-driven nets
vNets = Vec_PtrAlloc( 100 );
Abc_NtkForEachNet( pNtk, pNet, i )
@@ -1077,7 +1088,7 @@ void Abc_NtkFixNonDrivenNets( Abc_Ntk_t * pNtk )
if ( vNets->nSize > 0 )
{
printf( "Warning: Constant-0 drivers added to %d non-driven nets in network \"%s\":\n", Vec_PtrSize(vNets), pNtk->pName );
- Vec_PtrForEachEntry( vNets, pNet, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNets, pNet, i )
{
printf( "%s%s", (i? ", ": ""), Abc_ObjName(pNet) );
if ( i == 3 )
@@ -1117,7 +1128,7 @@ void Abc_NtkMakeComb( Abc_Ntk_t * pNtk, int fRemoveLatches )
// detach the latches
// Abc_NtkForEachLatch( pNtk, pObj, i )
- Vec_PtrForEachEntryReverse( pNtk->vBoxes, pObj, i )
+ Vec_PtrForEachEntryReverse( Abc_Obj_t *, pNtk->vBoxes, pObj, i )
Abc_NtkDeleteObj( pObj );
assert( Abc_NtkLatchNum(pNtk) == 0 );
assert( Abc_NtkBoxNum(pNtk) == 0 );
@@ -1151,7 +1162,7 @@ void Abc_NtkMakeComb( Abc_Ntk_t * pNtk, int fRemoveLatches )
Vec_PtrFree( pNtk->vCos );
pNtk->vCos = NULL;
// remove the BOs
- Vec_PtrForEachEntry( vBos, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vBos, pObj, i )
Abc_NtkDeleteObj( pObj );
Vec_PtrFree( vBos );
// create COs
@@ -1160,7 +1171,7 @@ void Abc_NtkMakeComb( Abc_Ntk_t * pNtk, int fRemoveLatches )
if ( Abc_NtkIsLogic(pNtk) )
Abc_NtkCleanup( pNtk, 0 );
else if ( Abc_NtkIsStrash(pNtk) )
- Abc_AigCleanup( pNtk->pManFunc );
+ Abc_AigCleanup( (Abc_Aig_t *)pNtk->pManFunc );
else
assert( 0 );
}
@@ -1272,38 +1283,41 @@ void Abc_NtkMakeSeq( Abc_Ntk_t * pNtk, int nLatchesToAdd )
SeeAlso []
***********************************************************************/
-void Abc_NtkMakeOnePo( Abc_Ntk_t * pNtk, Abc_Obj_t * pNodePo )
+Abc_Ntk_t * Abc_NtkMakeOnePo( Abc_Ntk_t * pNtkInit, int Output, int nRange )
{
+ Abc_Ntk_t * pNtk;
Vec_Ptr_t * vPosToRemove;
- Abc_Obj_t * pObj;
+ Abc_Obj_t * pNodePo;
int i;
+ assert( !Abc_NtkIsNetlist(pNtkInit) );
+ assert( Abc_NtkHasOnlyLatchBoxes(pNtkInit) );
+ if ( Output < 0 || Output >= Abc_NtkPoNum(pNtkInit) )
+ {
+ printf( "PO index is incorrect.\n" );
+ return NULL;
+ }
- assert( !Abc_NtkIsNetlist(pNtk) );
- assert( Abc_NtkHasOnlyLatchBoxes(pNtk) );
-
+ pNtk = Abc_NtkDup( pNtkInit );
if ( Abc_NtkPoNum(pNtk) == 1 )
- return;
+ return pNtk;
- // make sure the node exists
- Abc_NtkForEachPo( pNtk, pObj, i )
- if ( pObj == pNodePo )
- break;
- assert( i < Abc_NtkPoNum(pNtk) );
+ if ( nRange < 1 )
+ nRange = 1;
// collect POs to remove
vPosToRemove = Vec_PtrAlloc( 100 );
- Abc_NtkForEachPo( pNtk, pObj, i )
- if ( pObj != pNodePo )
- Vec_PtrPush( vPosToRemove, pObj );
+ Abc_NtkForEachPo( pNtk, pNodePo, i )
+ if ( i < Output || i >= Output + nRange )
+ Vec_PtrPush( vPosToRemove, pNodePo );
// remove the POs
- Vec_PtrForEachEntry( vPosToRemove, pObj, i )
- Abc_NtkDeleteObj( pObj );
+ Vec_PtrForEachEntry( Abc_Obj_t *, vPosToRemove, pNodePo, i )
+ Abc_NtkDeleteObj( pNodePo );
Vec_PtrFree( vPosToRemove );
if ( Abc_NtkIsStrash(pNtk) )
{
- Abc_AigCleanup( pNtk->pManFunc );
+ Abc_AigCleanup( (Abc_Aig_t *)pNtk->pManFunc );
printf( "Run sequential cleanup (\"scl\") to get rid of dangling logic.\n" );
}
else
@@ -1313,6 +1327,7 @@ void Abc_NtkMakeOnePo( Abc_Ntk_t * pNtk, Abc_Obj_t * pNodePo )
if ( !Abc_NtkCheck( pNtk ) )
fprintf( stdout, "Abc_NtkMakeComb(): Network check has failed.\n" );
+ return pNtk;
}
/**Function*************************************************************
@@ -1398,9 +1413,68 @@ Abc_Ntk_t * Abc_NtkTrim( Abc_Ntk_t * pNtk )
return Abc_NtkDup( pNtk );
}
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Abc_NtkDropSatOutputs( Abc_Ntk_t * pNtk, Vec_Ptr_t * vCexes, int fVerbose )
+{
+ Abc_Obj_t * pObj, * pConst0, * pFaninNew;
+ int i, Counter = 0;
+ assert( Vec_PtrSize(vCexes) == Abc_NtkPoNum(pNtk) );
+ pConst0 = Abc_ObjNot( Abc_AigConst1(pNtk) );
+ Abc_NtkForEachPo( pNtk, pObj, i )
+ {
+ if ( Vec_PtrEntry( vCexes, i ) == NULL )
+ continue;
+ Counter++;
+ pFaninNew = Abc_ObjNotCond( pConst0, Abc_ObjFaninC0(pObj) );
+ Abc_ObjPatchFanin( pObj, Abc_ObjFanin0(pObj), pFaninNew );
+ assert( Abc_ObjChild0(pObj) == pConst0 );
+ // if a PO is driven by a latch, they have the same name...
+// if ( Abc_ObjIsBo(pObj) )
+// Nm_ManDeleteIdName( pNtk->pManName, Abc_ObjId(pObj) );
+ }
+ if ( fVerbose )
+ printf( "Logic cones of %d POs have been replaced by constant 0.\n", Counter );
+ Counter = Abc_AigCleanup( (Abc_Aig_t *)pNtk->pManFunc );
+// printf( "Cleanup removed %d nodes.\n", Counter );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Abc_NtkDropOneOutput( Abc_Ntk_t * pNtk, int iOutput )
+{
+ Abc_Obj_t * pObj, * pConst0, * pFaninNew;
+ pObj = Abc_NtkPo( pNtk, iOutput );
+ pConst0 = Abc_ObjNot( Abc_AigConst1(pNtk) );
+ pFaninNew = Abc_ObjNotCond( pConst0, Abc_ObjFaninC0(pObj) );
+ Abc_ObjPatchFanin( pObj, Abc_ObjFanin0(pObj), pFaninNew );
+ assert( Abc_ObjChild0(pObj) == pConst0 );
+ Abc_AigCleanup( (Abc_Aig_t *)pNtk->pManFunc );
+}
+
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abc/abcObj.c b/src/base/abc/abcObj.c
index e4484ec5..40bbc18b 100644
--- a/src/base/abc/abcObj.c
+++ b/src/base/abc/abcObj.c
@@ -23,6 +23,9 @@
#include "main.h"
#include "mio.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -134,10 +137,6 @@ Abc_Obj_t * Abc_NtkCreateObj( Abc_Ntk_t * pNtk, Abc_ObjType_t Type )
case ABC_OBJ_BO:
if ( pNtk->vCis ) Vec_PtrPush( pNtk->vCis, pObj );
break;
- case ABC_OBJ_ASSERT:
- Vec_PtrPush( pNtk->vAsserts, pObj );
- Vec_PtrPush( pNtk->vCos, pObj );
- break;
case ABC_OBJ_NET:
case ABC_OBJ_NODE:
break;
@@ -178,10 +177,10 @@ void Abc_NtkDeleteObj( Abc_Obj_t * pObj )
vNodes = Vec_PtrAlloc( 100 );
Abc_NodeCollectFanouts( pObj, vNodes );
for ( i = 0; i < vNodes->nSize; i++ )
- Abc_ObjDeleteFanin( vNodes->pArray[i], pObj );
+ Abc_ObjDeleteFanin( (Abc_Obj_t *)vNodes->pArray[i], pObj );
Abc_NodeCollectFanins( pObj, vNodes );
for ( i = 0; i < vNodes->nSize; i++ )
- Abc_ObjDeleteFanin( pObj, vNodes->pArray[i] );
+ Abc_ObjDeleteFanin( pObj, (Abc_Obj_t *)vNodes->pArray[i] );
Vec_PtrFree( vNodes );
// remove from the list of objects
Vec_PtrWriteEntry( pNtk->vObjs, pObj->Id, NULL );
@@ -214,15 +213,11 @@ void Abc_NtkDeleteObj( Abc_Obj_t * pObj )
case ABC_OBJ_BO:
if ( pNtk->vCis ) Vec_PtrRemove( pNtk->vCis, pObj );
break;
- case ABC_OBJ_ASSERT:
- Vec_PtrRemove( pNtk->vAsserts, pObj );
- Vec_PtrRemove( pNtk->vCos, pObj );
- break;
case ABC_OBJ_NET:
break;
case ABC_OBJ_NODE:
if ( Abc_NtkHasBdd(pNtk) )
- Cudd_RecursiveDeref( pNtk->pManFunc, pObj->pData );
+ Cudd_RecursiveDeref( (DdManager *)pNtk->pManFunc, (DdNode *)pObj->pData );
pObj->pData = NULL;
break;
case ABC_OBJ_LATCH:
@@ -262,13 +257,13 @@ void Abc_NtkDeleteObj_rec( Abc_Obj_t * pObj, int fOnlyNodes )
Abc_NtkDeleteObj( pObj );
if ( fOnlyNodes )
{
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
if ( Abc_ObjIsNode(pObj) && Abc_ObjFanoutNum(pObj) == 0 )
Abc_NtkDeleteObj_rec( pObj, fOnlyNodes );
}
else
{
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
if ( !Abc_ObjIsPi(pObj) && Abc_ObjFanoutNum(pObj) == 0 )
Abc_NtkDeleteObj_rec( pObj, fOnlyNodes );
}
@@ -296,7 +291,7 @@ void Abc_NtkDeleteAll_rec( Abc_Obj_t * pObj )
vNodes = Vec_PtrAlloc( 100 );
Abc_NodeCollectFanins( pObj, vNodes );
Abc_NtkDeleteObj( pObj );
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
if ( !Abc_ObjIsNode(pObj) && Abc_ObjFanoutNum(pObj) == 0 )
Abc_NtkDeleteAll_rec( pObj );
Vec_PtrFree( vNodes );
@@ -317,7 +312,7 @@ Abc_Obj_t * Abc_NtkDupObj( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pObj, int fCopyName
{
Abc_Obj_t * pObjNew;
// create the new object
- pObjNew = Abc_NtkCreateObj( pNtkNew, pObj->Type );
+ pObjNew = Abc_NtkCreateObj( pNtkNew, (Abc_ObjType_t)pObj->Type );
// transfer names of the terminal objects
if ( fCopyName )
{
@@ -350,11 +345,11 @@ Abc_Obj_t * Abc_NtkDupObj( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pObj, int fCopyName
if ( Abc_NtkIsStrash(pNtkNew) )
{}
else if ( Abc_NtkHasSop(pNtkNew) || Abc_NtkHasBlifMv(pNtkNew) )
- pObjNew->pData = Abc_SopRegister( pNtkNew->pManFunc, pObj->pData );
+ pObjNew->pData = Abc_SopRegister( (Extra_MmFlex_t *)pNtkNew->pManFunc, (char *)pObj->pData );
else if ( Abc_NtkHasBdd(pNtkNew) )
- pObjNew->pData = Cudd_bddTransfer(pObj->pNtk->pManFunc, pNtkNew->pManFunc, pObj->pData), Cudd_Ref(pObjNew->pData);
+ pObjNew->pData = Cudd_bddTransfer((DdManager *)pObj->pNtk->pManFunc, (DdManager *)pNtkNew->pManFunc, (DdNode *)pObj->pData), Cudd_Ref((DdNode *)pObjNew->pData);
else if ( Abc_NtkHasAig(pNtkNew) )
- pObjNew->pData = Hop_Transfer(pObj->pNtk->pManFunc, pNtkNew->pManFunc, pObj->pData, Abc_ObjFaninNum(pObj));
+ pObjNew->pData = Hop_Transfer((Hop_Man_t *)pObj->pNtk->pManFunc, (Hop_Man_t *)pNtkNew->pManFunc, (Hop_Obj_t *)pObj->pData, Abc_ObjFaninNum(pObj));
else if ( Abc_NtkHasMapping(pNtkNew) )
pObjNew->pData = pObj->pData;
else assert( 0 );
@@ -414,7 +409,7 @@ Abc_Obj_t * Abc_NtkCloneObj( Abc_Obj_t * pObj )
{
Abc_Obj_t * pClone, * pFanin;
int i;
- pClone = Abc_NtkCreateObj( pObj->pNtk, pObj->Type );
+ pClone = Abc_NtkCreateObj( pObj->pNtk, (Abc_ObjType_t)pObj->Type );
Abc_ObjForEachFanin( pObj, pFanin, i )
Abc_ObjAddFanin( pClone, pFanin );
return pClone;
@@ -586,13 +581,13 @@ Abc_Obj_t * Abc_NtkCreateNodeConst0( Abc_Ntk_t * pNtk )
assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
pNode = Abc_NtkCreateNode( pNtk );
if ( Abc_NtkHasSop(pNtk) || Abc_NtkHasBlifMv(pNtk) )
- pNode->pData = Abc_SopRegister( pNtk->pManFunc, " 0\n" );
+ pNode->pData = Abc_SopRegister( (Extra_MmFlex_t *)pNtk->pManFunc, " 0\n" );
else if ( Abc_NtkHasBdd(pNtk) )
- pNode->pData = Cudd_ReadLogicZero(pNtk->pManFunc), Cudd_Ref( pNode->pData );
+ pNode->pData = Cudd_ReadLogicZero((DdManager *)pNtk->pManFunc), Cudd_Ref( (DdNode *)pNode->pData );
else if ( Abc_NtkHasAig(pNtk) )
- pNode->pData = Hop_ManConst0(pNtk->pManFunc);
+ pNode->pData = Hop_ManConst0((Hop_Man_t *)pNtk->pManFunc);
else if ( Abc_NtkHasMapping(pNtk) )
- pNode->pData = Mio_LibraryReadConst0(Abc_FrameReadLibGen());
+ pNode->pData = Mio_LibraryReadConst0((Mio_Library_t *)Abc_FrameReadLibGen());
else if ( !Abc_NtkHasBlackbox(pNtk) )
assert( 0 );
return pNode;
@@ -615,13 +610,13 @@ Abc_Obj_t * Abc_NtkCreateNodeConst1( Abc_Ntk_t * pNtk )
assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
pNode = Abc_NtkCreateNode( pNtk );
if ( Abc_NtkHasSop(pNtk) || Abc_NtkHasBlifMv(pNtk) )
- pNode->pData = Abc_SopRegister( pNtk->pManFunc, " 1\n" );
+ pNode->pData = Abc_SopRegister( (Extra_MmFlex_t *)pNtk->pManFunc, " 1\n" );
else if ( Abc_NtkHasBdd(pNtk) )
- pNode->pData = Cudd_ReadOne(pNtk->pManFunc), Cudd_Ref( pNode->pData );
+ pNode->pData = Cudd_ReadOne((DdManager *)pNtk->pManFunc), Cudd_Ref( (DdNode *)pNode->pData );
else if ( Abc_NtkHasAig(pNtk) )
- pNode->pData = Hop_ManConst1(pNtk->pManFunc);
+ pNode->pData = Hop_ManConst1((Hop_Man_t *)pNtk->pManFunc);
else if ( Abc_NtkHasMapping(pNtk) )
- pNode->pData = Mio_LibraryReadConst1(Abc_FrameReadLibGen());
+ pNode->pData = Mio_LibraryReadConst1((Mio_Library_t *)Abc_FrameReadLibGen());
else if ( !Abc_NtkHasBlackbox(pNtk) )
assert( 0 );
return pNode;
@@ -645,13 +640,13 @@ Abc_Obj_t * Abc_NtkCreateNodeInv( Abc_Ntk_t * pNtk, Abc_Obj_t * pFanin )
pNode = Abc_NtkCreateNode( pNtk );
if ( pFanin ) Abc_ObjAddFanin( pNode, pFanin );
if ( Abc_NtkHasSop(pNtk) )
- pNode->pData = Abc_SopRegister( pNtk->pManFunc, "0 1\n" );
+ pNode->pData = Abc_SopRegister( (Extra_MmFlex_t *)pNtk->pManFunc, "0 1\n" );
else if ( Abc_NtkHasBdd(pNtk) )
- pNode->pData = Cudd_Not(Cudd_bddIthVar(pNtk->pManFunc,0)), Cudd_Ref( pNode->pData );
+ pNode->pData = Cudd_Not(Cudd_bddIthVar((DdManager *)pNtk->pManFunc,0)), Cudd_Ref( (DdNode *)pNode->pData );
else if ( Abc_NtkHasAig(pNtk) )
- pNode->pData = Hop_Not(Hop_IthVar(pNtk->pManFunc,0));
+ pNode->pData = Hop_Not(Hop_IthVar((Hop_Man_t *)pNtk->pManFunc,0));
else if ( Abc_NtkHasMapping(pNtk) )
- pNode->pData = Mio_LibraryReadInv(Abc_FrameReadLibGen());
+ pNode->pData = Mio_LibraryReadInv((Mio_Library_t *)Abc_FrameReadLibGen());
else
assert( 0 );
return pNode;
@@ -675,13 +670,13 @@ Abc_Obj_t * Abc_NtkCreateNodeBuf( Abc_Ntk_t * pNtk, Abc_Obj_t * pFanin )
pNode = Abc_NtkCreateNode( pNtk );
if ( pFanin ) Abc_ObjAddFanin( pNode, pFanin );
if ( Abc_NtkHasSop(pNtk) )
- pNode->pData = Abc_SopRegister( pNtk->pManFunc, "1 1\n" );
+ pNode->pData = Abc_SopRegister( (Extra_MmFlex_t *)pNtk->pManFunc, "1 1\n" );
else if ( Abc_NtkHasBdd(pNtk) )
- pNode->pData = Cudd_bddIthVar(pNtk->pManFunc,0), Cudd_Ref( pNode->pData );
+ pNode->pData = Cudd_bddIthVar((DdManager *)pNtk->pManFunc,0), Cudd_Ref( (DdNode *)pNode->pData );
else if ( Abc_NtkHasAig(pNtk) )
- pNode->pData = Hop_IthVar(pNtk->pManFunc,0);
+ pNode->pData = Hop_IthVar((Hop_Man_t *)pNtk->pManFunc,0);
else if ( Abc_NtkHasMapping(pNtk) )
- pNode->pData = Mio_LibraryReadBuf(Abc_FrameReadLibGen());
+ pNode->pData = Mio_LibraryReadBuf((Mio_Library_t *)Abc_FrameReadLibGen());
else
assert( 0 );
return pNode;
@@ -705,13 +700,13 @@ Abc_Obj_t * Abc_NtkCreateNodeAnd( Abc_Ntk_t * pNtk, Vec_Ptr_t * vFanins )
assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
pNode = Abc_NtkCreateNode( pNtk );
for ( i = 0; i < vFanins->nSize; i++ )
- Abc_ObjAddFanin( pNode, vFanins->pArray[i] );
+ Abc_ObjAddFanin( pNode, (Abc_Obj_t *)vFanins->pArray[i] );
if ( Abc_NtkHasSop(pNtk) )
- pNode->pData = Abc_SopCreateAnd( pNtk->pManFunc, Vec_PtrSize(vFanins), NULL );
+ pNode->pData = Abc_SopCreateAnd( (Extra_MmFlex_t *)pNtk->pManFunc, Vec_PtrSize(vFanins), NULL );
else if ( Abc_NtkHasBdd(pNtk) )
- pNode->pData = Extra_bddCreateAnd( pNtk->pManFunc, Vec_PtrSize(vFanins) ), Cudd_Ref(pNode->pData);
+ pNode->pData = Extra_bddCreateAnd( (DdManager *)pNtk->pManFunc, Vec_PtrSize(vFanins) ), Cudd_Ref((DdNode *)pNode->pData);
else if ( Abc_NtkHasAig(pNtk) )
- pNode->pData = Hop_CreateAnd( pNtk->pManFunc, Vec_PtrSize(vFanins) );
+ pNode->pData = Hop_CreateAnd( (Hop_Man_t *)pNtk->pManFunc, Vec_PtrSize(vFanins) );
else
assert( 0 );
return pNode;
@@ -735,13 +730,13 @@ Abc_Obj_t * Abc_NtkCreateNodeOr( Abc_Ntk_t * pNtk, Vec_Ptr_t * vFanins )
assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
pNode = Abc_NtkCreateNode( pNtk );
for ( i = 0; i < vFanins->nSize; i++ )
- Abc_ObjAddFanin( pNode, vFanins->pArray[i] );
+ Abc_ObjAddFanin( pNode, (Abc_Obj_t *)vFanins->pArray[i] );
if ( Abc_NtkHasSop(pNtk) )
- pNode->pData = Abc_SopCreateOr( pNtk->pManFunc, Vec_PtrSize(vFanins), NULL );
+ pNode->pData = Abc_SopCreateOr( (Extra_MmFlex_t *)pNtk->pManFunc, Vec_PtrSize(vFanins), NULL );
else if ( Abc_NtkHasBdd(pNtk) )
- pNode->pData = Extra_bddCreateOr( pNtk->pManFunc, Vec_PtrSize(vFanins) ), Cudd_Ref(pNode->pData);
+ pNode->pData = Extra_bddCreateOr( (DdManager *)pNtk->pManFunc, Vec_PtrSize(vFanins) ), Cudd_Ref((DdNode *)pNode->pData);
else if ( Abc_NtkHasAig(pNtk) )
- pNode->pData = Hop_CreateOr( pNtk->pManFunc, Vec_PtrSize(vFanins) );
+ pNode->pData = Hop_CreateOr( (Hop_Man_t *)pNtk->pManFunc, Vec_PtrSize(vFanins) );
else
assert( 0 );
return pNode;
@@ -765,13 +760,13 @@ Abc_Obj_t * Abc_NtkCreateNodeExor( Abc_Ntk_t * pNtk, Vec_Ptr_t * vFanins )
assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
pNode = Abc_NtkCreateNode( pNtk );
for ( i = 0; i < vFanins->nSize; i++ )
- Abc_ObjAddFanin( pNode, vFanins->pArray[i] );
+ Abc_ObjAddFanin( pNode, (Abc_Obj_t *)vFanins->pArray[i] );
if ( Abc_NtkHasSop(pNtk) )
- pNode->pData = Abc_SopCreateXorSpecial( pNtk->pManFunc, Vec_PtrSize(vFanins) );
+ pNode->pData = Abc_SopCreateXorSpecial( (Extra_MmFlex_t *)pNtk->pManFunc, Vec_PtrSize(vFanins) );
else if ( Abc_NtkHasBdd(pNtk) )
- pNode->pData = Extra_bddCreateExor( pNtk->pManFunc, Vec_PtrSize(vFanins) ), Cudd_Ref(pNode->pData);
+ pNode->pData = Extra_bddCreateExor( (DdManager *)pNtk->pManFunc, Vec_PtrSize(vFanins) ), Cudd_Ref((DdNode *)pNode->pData);
else if ( Abc_NtkHasAig(pNtk) )
- pNode->pData = Hop_CreateExor( pNtk->pManFunc, Vec_PtrSize(vFanins) );
+ pNode->pData = Hop_CreateExor( (Hop_Man_t *)pNtk->pManFunc, Vec_PtrSize(vFanins) );
else
assert( 0 );
return pNode;
@@ -797,11 +792,11 @@ Abc_Obj_t * Abc_NtkCreateNodeMux( Abc_Ntk_t * pNtk, Abc_Obj_t * pNodeC, Abc_Obj_
Abc_ObjAddFanin( pNode, pNode1 );
Abc_ObjAddFanin( pNode, pNode0 );
if ( Abc_NtkHasSop(pNtk) )
- pNode->pData = Abc_SopRegister( pNtk->pManFunc, "11- 1\n0-1 1\n" );
+ pNode->pData = Abc_SopRegister( (Extra_MmFlex_t *)pNtk->pManFunc, "11- 1\n0-1 1\n" );
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 );
+ pNode->pData = Cudd_bddIte((DdManager *)pNtk->pManFunc,Cudd_bddIthVar((DdManager *)pNtk->pManFunc,0),Cudd_bddIthVar((DdManager *)pNtk->pManFunc,1),Cudd_bddIthVar((DdManager *)pNtk->pManFunc,2)), Cudd_Ref( (DdNode *)pNode->pData );
else if ( Abc_NtkHasAig(pNtk) )
- pNode->pData = Hop_Mux(pNtk->pManFunc,Hop_IthVar(pNtk->pManFunc,0),Hop_IthVar(pNtk->pManFunc,1),Hop_IthVar(pNtk->pManFunc,2));
+ pNode->pData = Hop_Mux((Hop_Man_t *)pNtk->pManFunc,Hop_IthVar((Hop_Man_t *)pNtk->pManFunc,0),Hop_IthVar((Hop_Man_t *)pNtk->pManFunc,1),Hop_IthVar((Hop_Man_t *)pNtk->pManFunc,2));
else
assert( 0 );
return pNode;
@@ -819,7 +814,7 @@ Abc_Obj_t * Abc_NtkCreateNodeMux( Abc_Ntk_t * pNtk, Abc_Obj_t * pNodeC, Abc_Obj_
SeeAlso []
***********************************************************************/
-bool Abc_NodeIsConst( Abc_Obj_t * pNode )
+int Abc_NodeIsConst( Abc_Obj_t * pNode )
{
assert( Abc_NtkIsLogic(pNode->pNtk) || Abc_NtkIsNetlist(pNode->pNtk) );
return Abc_ObjIsNode(pNode) && Abc_ObjFaninNum(pNode) == 0;
@@ -836,7 +831,7 @@ bool Abc_NodeIsConst( Abc_Obj_t * pNode )
SeeAlso []
***********************************************************************/
-bool Abc_NodeIsConst0( Abc_Obj_t * pNode )
+int Abc_NodeIsConst0( Abc_Obj_t * pNode )
{
Abc_Ntk_t * pNtk = pNode->pNtk;
assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
@@ -844,13 +839,13 @@ bool Abc_NodeIsConst0( Abc_Obj_t * pNode )
if ( !Abc_NodeIsConst(pNode) )
return 0;
if ( Abc_NtkHasSop(pNtk) )
- return Abc_SopIsConst0(pNode->pData);
+ return Abc_SopIsConst0((char *)pNode->pData);
if ( Abc_NtkHasBdd(pNtk) )
return Cudd_IsComplement(pNode->pData);
if ( Abc_NtkHasAig(pNtk) )
- return Hop_IsComplement(pNode->pData);
+ return Hop_IsComplement((Hop_Obj_t *)pNode->pData)? 1:0;
if ( Abc_NtkHasMapping(pNtk) )
- return pNode->pData == Mio_LibraryReadConst0(Abc_FrameReadLibGen());
+ return pNode->pData == Mio_LibraryReadConst0((Mio_Library_t *)Abc_FrameReadLibGen());
assert( 0 );
return 0;
}
@@ -866,7 +861,7 @@ bool Abc_NodeIsConst0( Abc_Obj_t * pNode )
SeeAlso []
***********************************************************************/
-bool Abc_NodeIsConst1( Abc_Obj_t * pNode )
+int Abc_NodeIsConst1( Abc_Obj_t * pNode )
{
Abc_Ntk_t * pNtk = pNode->pNtk;
assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
@@ -874,13 +869,13 @@ bool Abc_NodeIsConst1( Abc_Obj_t * pNode )
if ( !Abc_NodeIsConst(pNode) )
return 0;
if ( Abc_NtkHasSop(pNtk) )
- return Abc_SopIsConst1(pNode->pData);
+ return Abc_SopIsConst1((char *)pNode->pData);
if ( Abc_NtkHasBdd(pNtk) )
return !Cudd_IsComplement(pNode->pData);
if ( Abc_NtkHasAig(pNtk) )
- return !Hop_IsComplement(pNode->pData);
+ return !Hop_IsComplement((Hop_Obj_t *)pNode->pData);
if ( Abc_NtkHasMapping(pNtk) )
- return pNode->pData == Mio_LibraryReadConst1(Abc_FrameReadLibGen());
+ return pNode->pData == Mio_LibraryReadConst1((Mio_Library_t *)Abc_FrameReadLibGen());
assert( 0 );
return 0;
}
@@ -896,7 +891,7 @@ bool Abc_NodeIsConst1( Abc_Obj_t * pNode )
SeeAlso []
***********************************************************************/
-bool Abc_NodeIsBuf( Abc_Obj_t * pNode )
+int Abc_NodeIsBuf( Abc_Obj_t * pNode )
{
Abc_Ntk_t * pNtk = pNode->pNtk;
assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
@@ -904,13 +899,13 @@ bool Abc_NodeIsBuf( Abc_Obj_t * pNode )
if ( Abc_ObjFaninNum(pNode) != 1 )
return 0;
if ( Abc_NtkHasSop(pNtk) )
- return Abc_SopIsBuf(pNode->pData);
+ return Abc_SopIsBuf((char *)pNode->pData);
if ( Abc_NtkHasBdd(pNtk) )
return !Cudd_IsComplement(pNode->pData);
if ( Abc_NtkHasAig(pNtk) )
- return !Hop_IsComplement(pNode->pData);
+ return !Hop_IsComplement((Hop_Obj_t *)pNode->pData);
if ( Abc_NtkHasMapping(pNtk) )
- return pNode->pData == Mio_LibraryReadBuf(Abc_FrameReadLibGen());
+ return pNode->pData == Mio_LibraryReadBuf((Mio_Library_t *)Abc_FrameReadLibGen());
assert( 0 );
return 0;
}
@@ -926,7 +921,7 @@ bool Abc_NodeIsBuf( Abc_Obj_t * pNode )
SeeAlso []
***********************************************************************/
-bool Abc_NodeIsInv( Abc_Obj_t * pNode )
+int Abc_NodeIsInv( Abc_Obj_t * pNode )
{
Abc_Ntk_t * pNtk = pNode->pNtk;
assert( Abc_NtkIsLogic(pNtk) || Abc_NtkIsNetlist(pNtk) );
@@ -934,13 +929,13 @@ bool Abc_NodeIsInv( Abc_Obj_t * pNode )
if ( Abc_ObjFaninNum(pNode) != 1 )
return 0;
if ( Abc_NtkHasSop(pNtk) )
- return Abc_SopIsInv(pNode->pData);
+ return Abc_SopIsInv((char *)pNode->pData);
if ( Abc_NtkHasBdd(pNtk) )
return Cudd_IsComplement(pNode->pData);
if ( Abc_NtkHasAig(pNtk) )
- return Hop_IsComplement(pNode->pData);
+ return Hop_IsComplement((Hop_Obj_t *)pNode->pData)? 1:0;
if ( Abc_NtkHasMapping(pNtk) )
- return pNode->pData == Mio_LibraryReadInv(Abc_FrameReadLibGen());
+ return pNode->pData == Mio_LibraryReadInv((Mio_Library_t *)Abc_FrameReadLibGen());
assert( 0 );
return 0;
}
@@ -961,11 +956,11 @@ void Abc_NodeComplement( Abc_Obj_t * pNode )
assert( Abc_NtkIsLogic(pNode->pNtk) || Abc_NtkIsNetlist(pNode->pNtk) );
assert( Abc_ObjIsNode(pNode) );
if ( Abc_NtkHasSop(pNode->pNtk) )
- Abc_SopComplement( pNode->pData );
+ Abc_SopComplement( (char *)pNode->pData );
else if ( Abc_NtkHasBdd(pNode->pNtk) )
pNode->pData = Cudd_Not( pNode->pData );
else if ( Abc_NtkHasAig(pNode->pNtk) )
- pNode->pData = Hop_Not( pNode->pData );
+ pNode->pData = Hop_Not( (Hop_Obj_t *)pNode->pData );
else
assert( 0 );
}
@@ -974,3 +969,5 @@ void Abc_NodeComplement( Abc_Obj_t * pNode )
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abc/abcRefs.c b/src/base/abc/abcRefs.c
index ec89eaed..26ae55ab 100644
--- a/src/base/abc/abcRefs.c
+++ b/src/base/abc/abcRefs.c
@@ -20,12 +20,15 @@
#include "abc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
-static int Abc_NodeRefDeref( Abc_Obj_t * pNode, bool fReference, bool fLabel );
-static int Abc_NodeRefDerefStop( Abc_Obj_t * pNode, bool fReference );
+static int Abc_NodeRefDeref( Abc_Obj_t * pNode, int fReference, int fLabel );
+static int Abc_NodeRefDerefStop( Abc_Obj_t * pNode, int fReference );
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
@@ -120,7 +123,7 @@ int Abc_NodeMffcLabelAig( Abc_Obj_t * pNode )
SeeAlso []
***********************************************************************/
-int Abc_NodeRefDeref( Abc_Obj_t * pNode, bool fReference, bool fLabel )
+int Abc_NodeRefDeref( Abc_Obj_t * pNode, int fReference, int fLabel )
{
Abc_Obj_t * pNode0, * pNode1;
int Counter;
@@ -165,7 +168,7 @@ int Abc_NodeRefDeref( Abc_Obj_t * pNode, bool fReference, bool fLabel )
SeeAlso []
***********************************************************************/
-int Abc_NodeRefDerefStop( Abc_Obj_t * pNode, bool fReference )
+int Abc_NodeRefDerefStop( Abc_Obj_t * pNode, int fReference )
{
Abc_Obj_t * pNode0, * pNode1;
int Counter;
@@ -327,7 +330,7 @@ void Abc_NodeMffcConeSuppPrint( Abc_Obj_t * pNode )
Abc_NodeRef_rec( pNode );
printf( "Node = %6s : Supp = %3d Cone = %3d (",
Abc_ObjName(pNode), Vec_PtrSize(vSupp), Vec_PtrSize(vCone) );
- Vec_PtrForEachEntry( vCone, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vCone, pObj, i )
printf( " %s", Abc_ObjName(pObj) );
printf( " )\n" );
Vec_PtrFree( vCone );
@@ -350,7 +353,7 @@ int Abc_NodeMffcInside( Abc_Obj_t * pNode, Vec_Ptr_t * vLeaves, Vec_Ptr_t * vIns
Abc_Obj_t * pObj;
int i, Count1, Count2;
// increment the fanout counters for the leaves
- Vec_PtrForEachEntry( vLeaves, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pObj, i )
pObj->vFanouts.nSize++;
// dereference the node
Count1 = Abc_NodeDeref_rec( pNode );
@@ -360,7 +363,7 @@ int Abc_NodeMffcInside( Abc_Obj_t * pNode, Vec_Ptr_t * vLeaves, Vec_Ptr_t * vIns
Count2 = Abc_NodeRef_rec( pNode );
assert( Count1 == Count2 );
// remove the extra counters
- Vec_PtrForEachEntry( vLeaves, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pObj, i )
pObj->vFanouts.nSize--;
return Count1;
}
@@ -450,3 +453,5 @@ int Abc_NodeMffcLabel( Abc_Obj_t * pNode )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abc/abcShow.c b/src/base/abc/abcShow.c
index 359f737e..4295726e 100644
--- a/src/base/abc/abcShow.c
+++ b/src/base/abc/abcShow.c
@@ -29,6 +29,9 @@
#include "main.h"
#include "ioAbc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -71,7 +74,7 @@ void Abc_NodeShowBdd( Abc_Obj_t * pNode )
// set the node names
vNamesIn = Abc_NodeGetFaninNames( pNode );
pNameOut = Abc_ObjName(pNode);
- Cudd_DumpDot( pNode->pNtk->pManFunc, 1, (DdNode **)&pNode->pData, (char **)vNamesIn->pArray, &pNameOut, pFile );
+ Cudd_DumpDot( (DdManager *)pNode->pNtk->pManFunc, 1, (DdNode **)&pNode->pData, (char **)vNamesIn->pArray, &pNameOut, pFile );
Abc_NodeFreeNames( vNamesIn );
Abc_NtkCleanCopy( pNode->pNtk );
fclose( pFile );
@@ -82,6 +85,30 @@ void Abc_NodeShowBdd( Abc_Obj_t * pNode )
/**Function*************************************************************
+ Synopsis [Visualizes BDD of the node.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Abc_NodeShowBddOne( DdManager * dd, DdNode * bFunc )
+{
+ char * FileNameDot = "temp.dot";
+ FILE * pFile;
+ if ( (pFile = fopen( FileNameDot, "w" )) == NULL )
+ {
+ fprintf( stdout, "Cannot open the intermediate file \"%s\".\n", FileNameDot );
+ return;
+ }
+ Cudd_DumpDot( dd, 1, (DdNode **)&bFunc, NULL, NULL, pFile );
+ fclose( pFile );
+ Abc_ShowFile( FileNameDot );
+}
+/**Function*************************************************************
+
Synopsis [Visualizes a reconvergence driven cut at the node.]
Description []
@@ -118,7 +145,7 @@ void Abc_NodeShowCut( Abc_Obj_t * pNode, int nNodeSizeMax, int nConeSizeMax )
// add the nodes in the TFO
vNodesTfo = Abc_NodeCollectTfoCands( p, pNode, vCutSmall, ABC_INFINITY );
- Vec_PtrForEachEntry( vNodesTfo, pTemp, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodesTfo, pTemp, i )
Vec_PtrPushUnique( vInside, pTemp );
// create the file name
@@ -314,8 +341,96 @@ void Abc_ShowGetFileName( char * pName, char * pBuffer )
}
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Abc_NtkWriteFlopDependency( Abc_Ntk_t * pNtk, char * pFileName )
+{
+ FILE * pFile;
+ Vec_Ptr_t * vSupp;
+ Abc_Obj_t * pObj, * pTemp;
+ int i, k, Count;
+ pFile = fopen( pFileName, "w" );
+ if ( pFile == NULL )
+ {
+ printf( "Cannot open input file %s.\n", pFileName );
+ return;
+ }
+ fprintf( pFile, "# Flop dependency for \"%s\" generated by ABC on %s\n", Abc_NtkName(pNtk), Extra_TimeStamp() );
+ fprintf( pFile, "digraph G {\n" );
+ fprintf( pFile, " graph [splines=true overlap=false];\n" );
+ fprintf( pFile, " size = \"7.5,10\";\n" );
+ fprintf( pFile, " center = true;\n" );
+// fprintf( pFile, " edge [len=3,dir=forward];\n" );
+ fprintf( pFile, " edge [dir=forward];\n" );
+ Abc_NtkForEachLatchInput( pNtk, pObj, i )
+ {
+ Abc_ObjFanout0( Abc_ObjFanout0(pObj) )->iTemp = i;
+ vSupp = Abc_NtkNodeSupport( pNtk, &pObj, 1 );
+ Count = 0;
+ Vec_PtrForEachEntry( Abc_Obj_t *, vSupp, pTemp, k )
+ Count += Abc_ObjIsPi(pTemp);
+ Vec_PtrFree( vSupp );
+ fprintf( pFile, " { rank = same; %d [label=\"%d(%d)\"]; }\n", i, i, Count );
+ }
+ Abc_NtkForEachLatchInput( pNtk, pObj, i )
+ {
+ vSupp = Abc_NtkNodeSupport( pNtk, &pObj, 1 );
+ Count = 0;
+ Vec_PtrForEachEntry( Abc_Obj_t *, vSupp, pTemp, k )
+ if ( !Abc_ObjIsPi(pTemp) )
+ fprintf( pFile, " %4d -> %4d\n", pTemp->iTemp, i );
+ Vec_PtrFree( vSupp );
+ }
+ fprintf( pFile, "}\n" );
+ fclose( pFile );
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Visualizes AIG with choices.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Abc_NtkShowFlopDependency( Abc_Ntk_t * pNtk )
+{
+ FILE * pFile;
+ char FileNameDot[200];
+ assert( Abc_NtkIsStrash(pNtk) || Abc_NtkIsLogic(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 );
+ // write the DOT file
+ Abc_NtkWriteFlopDependency( pNtk, FileNameDot );
+ // visualize the file
+ Abc_ShowFile( FileNameDot );
+}
+
+
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abc/abcSop.c b/src/base/abc/abcSop.c
index c0ace492..5be2f8ef 100644
--- a/src/base/abc/abcSop.c
+++ b/src/base/abc/abcSop.c
@@ -20,6 +20,9 @@
#include "abc.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*
The SOPs in this package are represented using char * strings.
For example, the SOP of the node:
@@ -533,7 +536,9 @@ int Abc_SopGetLitNum( char * pSop )
int Abc_SopGetVarNum( char * pSop )
{
char * pCur;
- for ( pCur = pSop; *pCur != '\n'; pCur++ );
+ for ( pCur = pSop; *pCur != '\n'; pCur++ )
+ if ( *pCur == 0 )
+ return -1;
return pCur - pSop - 2;
}
@@ -622,7 +627,7 @@ void Abc_SopComplement( char * pSop )
SeeAlso []
***********************************************************************/
-bool Abc_SopIsComplement( char * pSop )
+int Abc_SopIsComplement( char * pSop )
{
char * pCur;
for ( pCur = pSop; *pCur; pCur++ )
@@ -643,7 +648,7 @@ bool Abc_SopIsComplement( char * pSop )
SeeAlso []
***********************************************************************/
-bool Abc_SopIsConst0( char * pSop )
+int Abc_SopIsConst0( char * pSop )
{
return pSop[0] == ' ' && pSop[1] == '0';
}
@@ -659,7 +664,7 @@ bool Abc_SopIsConst0( char * pSop )
SeeAlso []
***********************************************************************/
-bool Abc_SopIsConst1( char * pSop )
+int Abc_SopIsConst1( char * pSop )
{
return pSop[0] == ' ' && pSop[1] == '1';
}
@@ -675,7 +680,7 @@ bool Abc_SopIsConst1( char * pSop )
SeeAlso []
***********************************************************************/
-bool Abc_SopIsBuf( char * pSop )
+int Abc_SopIsBuf( char * pSop )
{
if ( pSop[4] != 0 )
return 0;
@@ -695,7 +700,7 @@ bool Abc_SopIsBuf( char * pSop )
SeeAlso []
***********************************************************************/
-bool Abc_SopIsInv( char * pSop )
+int Abc_SopIsInv( char * pSop )
{
if ( pSop[4] != 0 )
return 0;
@@ -715,7 +720,7 @@ bool Abc_SopIsInv( char * pSop )
SeeAlso []
***********************************************************************/
-bool Abc_SopIsAndType( char * pSop )
+int Abc_SopIsAndType( char * pSop )
{
char * pCur;
if ( Abc_SopGetCubeNum(pSop) != 1 )
@@ -739,7 +744,7 @@ bool Abc_SopIsAndType( char * pSop )
SeeAlso []
***********************************************************************/
-bool Abc_SopIsOrType( char * pSop )
+int Abc_SopIsOrType( char * pSop )
{
char * pCube, * pCur;
int nVars, nLits;
@@ -790,7 +795,7 @@ int Abc_SopIsExorType( char * pSop )
SeeAlso []
***********************************************************************/
-bool Abc_SopCheck( char * pSop, int nFanins )
+int Abc_SopCheck( char * pSop, int nFanins )
{
char * pCubes, * pCubesOld;
int fFound0 = 0, fFound1 = 0;
@@ -1123,3 +1128,5 @@ char * Abc_SopDecoderLog( Extra_MmFlex_t * pMan, int nValues )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abc/abcUtil.c b/src/base/abc/abcUtil.c
index 8ebb00a3..43c53004 100644
--- a/src/base/abc/abcUtil.c
+++ b/src/base/abc/abcUtil.c
@@ -24,6 +24,9 @@
#include "dec.h"
//#include "seq.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -47,7 +50,7 @@ void * Abc_NtkAttrFree( Abc_Ntk_t * pNtk, int Attr, int fFreeMan )
{
void * pUserMan;
Vec_Att_t * pAttrMan;
- pAttrMan = Vec_PtrEntry( pNtk->vAttrs, Attr );
+ pAttrMan = (Vec_Att_t *)Vec_PtrEntry( pNtk->vAttrs, Attr );
Vec_PtrWriteEntry( pNtk->vAttrs, Attr, NULL );
pUserMan = Vec_AttFree( pAttrMan, fFreeMan );
return pUserMan;
@@ -98,8 +101,6 @@ void Abc_NtkOrderCisCos( Abc_Ntk_t * pNtk )
Vec_PtrPush( pNtk->vCis, pObj );
Abc_NtkForEachPo( pNtk, pObj, i )
Vec_PtrPush( pNtk->vCos, pObj );
- Abc_NtkForEachAssert( pNtk, pObj, i )
- Vec_PtrPush( pNtk->vCos, pObj );
Abc_NtkForEachBox( pNtk, pObj, i )
{
if ( Abc_ObjIsLatch(pObj) )
@@ -141,7 +142,7 @@ int Abc_NtkGetCubeNum( Abc_Ntk_t * pNtk )
if ( Abc_NodeIsConst(pNode) )
continue;
assert( pNode->pData );
- nCubes += Abc_SopGetCubeNum( pNode->pData );
+ nCubes += Abc_SopGetCubeNum( (char *)pNode->pData );
}
return nCubes;
}
@@ -167,7 +168,7 @@ int Abc_NtkGetCubePairNum( Abc_Ntk_t * pNtk )
if ( Abc_NodeIsConst(pNode) )
continue;
assert( pNode->pData );
- nCubes = Abc_SopGetCubeNum( pNode->pData );
+ nCubes = Abc_SopGetCubeNum( (char *)pNode->pData );
nCubePairs += nCubes * (nCubes - 1) / 2;
}
return nCubePairs;
@@ -192,7 +193,7 @@ int Abc_NtkGetLitNum( Abc_Ntk_t * pNtk )
Abc_NtkForEachNode( pNtk, pNode, i )
{
assert( pNode->pData );
- nLits += Abc_SopGetLitNum( pNode->pData );
+ nLits += Abc_SopGetLitNum( (char *)pNode->pData );
}
return nLits;
}
@@ -219,7 +220,7 @@ int Abc_NtkGetLitFactNum( Abc_Ntk_t * pNtk )
{
if ( Abc_NodeIsConst(pNode) )
continue;
- pFactor = Dec_Factor( pNode->pData );
+ pFactor = Dec_Factor( (char *)pNode->pData );
nNodes += 1 + Dec_GraphNodeNum(pFactor);
Dec_GraphFree( pFactor );
}
@@ -269,7 +270,7 @@ int Abc_NtkGetBddNodeNum( Abc_Ntk_t * pNtk )
assert( pNode->pData );
if ( Abc_ObjFaninNum(pNode) < 2 )
continue;
- nNodes += pNode->pData? -1 + Cudd_DagSize( pNode->pData ) : 0;
+ nNodes += pNode->pData? -1 + Cudd_DagSize( (DdNode *)pNode->pData ) : 0;
}
return nNodes;
}
@@ -296,7 +297,7 @@ int Abc_NtkGetAigNodeNum( Abc_Ntk_t * pNtk )
if ( Abc_ObjFaninNum(pNode) < 2 )
continue;
//printf( "%d ", Hop_DagSize( pNode->pData ) );
- nNodes += pNode->pData? Hop_DagSize( pNode->pData ) : 0;
+ nNodes += pNode->pData? Hop_DagSize( (Hop_Obj_t *)pNode->pData ) : 0;
}
return nNodes;
}
@@ -316,13 +317,13 @@ int Abc_NtkGetClauseNum( Abc_Ntk_t * pNtk )
{
Abc_Obj_t * pNode;
DdNode * bCover, * zCover, * bFunc;
- DdManager * dd = pNtk->pManFunc;
+ DdManager * dd = (DdManager *)pNtk->pManFunc;
int i, nClauses = 0;
assert( Abc_NtkIsBddLogic(pNtk) );
Abc_NtkForEachNode( pNtk, pNode, i )
{
assert( pNode->pData );
- bFunc = pNode->pData;
+ bFunc = (DdNode *)pNode->pData;
bCover = Cudd_zddIsop( dd, bFunc, bFunc, &zCover );
Cudd_Ref( bCover );
@@ -367,7 +368,7 @@ double Abc_NtkGetMappedArea( Abc_Ntk_t * pNtk )
printf( "Node without mapping is encountered.\n" );
continue;
}
- TotalArea += Mio_GateReadArea( pNode->pData );
+ TotalArea += Mio_GateReadArea( (Mio_Gate_t *)pNode->pData );
}
return TotalArea;
}
@@ -598,7 +599,7 @@ void Abc_NtkLoadCopy( Abc_Ntk_t * pNtk, Vec_Ptr_t * vCopies )
Abc_Obj_t * pObj;
int i;
Abc_NtkForEachObj( pNtk, pObj, i )
- pObj->pCopy = Vec_PtrEntry( vCopies, i );
+ pObj->pCopy = (Abc_Obj_t *)Vec_PtrEntry( vCopies, i );
}
/**Function*************************************************************
@@ -780,7 +781,7 @@ void Abc_NtkFixCoDriverProblem( Abc_Obj_t * pDriver, Abc_Obj_t * pNodeCo, int fD
SeeAlso []
***********************************************************************/
-bool Abc_NtkLogicHasSimpleCos( Abc_Ntk_t * pNtk )
+int Abc_NtkLogicHasSimpleCos( Abc_Ntk_t * pNtk )
{
Abc_Obj_t * pNode, * pDriver;
int i;
@@ -825,7 +826,7 @@ bool Abc_NtkLogicHasSimpleCos( Abc_Ntk_t * pNtk )
SeeAlso []
***********************************************************************/
-int Abc_NtkLogicMakeSimpleCos( Abc_Ntk_t * pNtk, bool fDuplicate )
+int Abc_NtkLogicMakeSimpleCos( Abc_Ntk_t * pNtk, int fDuplicate )
{
Abc_Obj_t * pNode, * pDriver;
int i, nDupGates = 0;
@@ -887,8 +888,8 @@ void Abc_VecObjPushUniqueOrderByLevel( Vec_Ptr_t * p, Abc_Obj_t * pNode )
// find the p of the node
for ( i = p->nSize-1; i > 0; i-- )
{
- pNode1 = p->pArray[i ];
- pNode2 = p->pArray[i-1];
+ pNode1 = (Abc_Obj_t *)p->pArray[i ];
+ pNode2 = (Abc_Obj_t *)p->pArray[i-1];
if ( Abc_ObjRegular(pNode1)->Level <= Abc_ObjRegular(pNode2)->Level )
break;
p->pArray[i ] = pNode2;
@@ -909,7 +910,7 @@ void Abc_VecObjPushUniqueOrderByLevel( Vec_Ptr_t * p, Abc_Obj_t * pNode )
SeeAlso []
***********************************************************************/
-bool Abc_NodeIsExorType( Abc_Obj_t * pNode )
+int Abc_NodeIsExorType( Abc_Obj_t * pNode )
{
Abc_Obj_t * pNode0, * pNode1;
// check that the node is regular
@@ -942,7 +943,7 @@ bool Abc_NodeIsExorType( Abc_Obj_t * pNode )
SeeAlso []
***********************************************************************/
-bool Abc_NodeIsMuxType( Abc_Obj_t * pNode )
+int Abc_NodeIsMuxType( Abc_Obj_t * pNode )
{
Abc_Obj_t * pNode0, * pNode1;
// check that the node is regular
@@ -998,7 +999,7 @@ int Abc_NtkCountMuxes( Abc_Ntk_t * pNtk )
SeeAlso []
***********************************************************************/
-bool Abc_NodeIsMuxControlType( Abc_Obj_t * pNode )
+int Abc_NodeIsMuxControlType( Abc_Obj_t * pNode )
{
Abc_Obj_t * pNode0, * pNode1;
// check that the node is regular
@@ -1424,12 +1425,6 @@ void Abc_NtkReassignIds( Abc_Ntk_t * pNtk )
pNode->Id = Vec_PtrSize( vObjsNew );
Vec_PtrPush( vObjsNew, pNode );
}
- // put assert nodes next
- Abc_NtkForEachAssert( pNtk, pNode, i )
- {
- pNode->Id = Vec_PtrSize( vObjsNew );
- Vec_PtrPush( vObjsNew, pNode );
- }
// put latches and their inputs/outputs next
Abc_NtkForEachBox( pNtk, pNode, i )
{
@@ -1448,7 +1443,7 @@ void Abc_NtkReassignIds( Abc_Ntk_t * pNtk )
}
// finally, internal nodes in the DFS order
vNodes = Abc_AigDfs( pNtk, 1, 0 );
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
{
if ( pNode == pConst1 )
continue;
@@ -1472,7 +1467,7 @@ void Abc_NtkReassignIds( Abc_Ntk_t * pNtk )
pNtk->vObjs = vObjsNew;
// rehash the AIG
- Abc_AigRehash( pNtk->pManFunc );
+ Abc_AigRehash( (Abc_Aig_t *)pNtk->pManFunc );
// update the name manager!!!
}
@@ -1582,7 +1577,7 @@ static inline int Abc_ObjCrossCutInc( Abc_Obj_t * pObj )
{
// pObj->pCopy = (void *)(((int)pObj->pCopy)++);
int Value = (int)(ABC_PTRINT_T)pObj->pCopy;
- pObj->pCopy = (void *)(ABC_PTRINT_T)(Value + 1);
+ pObj->pCopy = (Abc_Obj_t *)(ABC_PTRINT_T)(Value + 1);
return (int)(ABC_PTRINT_T)pObj->pCopy == Abc_ObjFanoutNum(pObj);
}
@@ -1755,10 +1750,10 @@ void Abc_NtkCompareCones( Abc_Ntk_t * pNtk )
// count the number of nodes in the reverse cone
Counter = 0;
for ( k = 1; k < Vec_PtrSize(vReverse) - 1; k++ )
- for ( pTemp = Vec_PtrEntry(vReverse, k); pTemp; pTemp = pTemp->pCopy )
+ for ( pTemp = (Abc_Obj_t *)Vec_PtrEntry(vReverse, k); pTemp; pTemp = (Abc_Obj_t *)pTemp->pCopy )
Counter++;
CounterCos = CounterCosNew = 0;
- for ( pTemp = Vec_PtrEntryLast(vReverse); pTemp; pTemp = pTemp->pCopy )
+ for ( pTemp = (Abc_Obj_t *)Vec_PtrEntryLast(vReverse); pTemp; pTemp = (Abc_Obj_t *)pTemp->pCopy )
{
assert( Abc_ObjIsCo(pTemp) );
CounterCos++;
@@ -1811,7 +1806,7 @@ void Abc_NtkCompareSupports( Abc_Ntk_t * pNtk )
nNodesOld = Vec_PtrSize(vSupp);
Vec_PtrFree( vSupp );
- for ( pTemp = pObj->pData; pTemp; pTemp = pTemp->pData )
+ for ( pTemp = (Abc_Obj_t *)pObj->pData; pTemp; pTemp = (Abc_Obj_t *)pTemp->pData )
{
vSupp = Abc_NtkNodeSupport( pNtk, &pTemp, 1 );
if ( nNodesOld != Vec_PtrSize(vSupp) )
@@ -1826,3 +1821,5 @@ void Abc_NtkCompareSupports( Abc_Ntk_t * pNtk )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abc/abc_.c b/src/base/abc/abc_.c
index 50558bdb..d9302303 100644
--- a/src/base/abc/abc_.c
+++ b/src/base/abc/abc_.c
@@ -20,6 +20,9 @@
#include "abc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -45,3 +48,5 @@
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c
index f7caad5d..c9623cf6 100644
--- a/src/base/abci/abc.c
+++ b/src/base/abci/abc.c
@@ -1,6 +1,6 @@
/**CFile****************************************************************
- FileName [abc.c]
+ FileName [abc.c]
SystemName [ABC: Logic synthesis and verification system.]
@@ -9,7 +9,7 @@
Synopsis [Command file.]
Author [Alan Mishchenko]
-
+
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
@@ -17,14 +17,16 @@
Revision [$Id: abc.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
-
+
#include "abc.h"
+#include "main.h"
#include "mainInt.h"
#include "fraig.h"
#include "fxu.h"
#include "cut.h"
#include "fpga.h"
#include "if.h"
+#include "sim.h"
#include "res.h"
#include "lpk.h"
#include "giaAig.h"
@@ -38,10 +40,32 @@
#include "dch.h"
#include "ssw.h"
#include "cgt.h"
+#include "kit.h"
#include "amap.h"
+#include "retInt.h"
+#include "cnf.h"
#include "cec.h"
#include "giaAbs.h"
+#include "tim.h"
+#include "llb.h"
+#include "ntlnwk.h"
+#include "mfx.h"
+#include "bbr.h"
+#include "cov.h"
+
+#include "cmd.h"
+#include "extra.h"
+//#include "magic.h"
+
+#ifdef _WIN32
+//#include <io.h>
+#else
+#include <unistd.h>
+#endif
+
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -65,6 +89,7 @@ static int Abc_CommandPrintXCut ( Abc_Frame_t * pAbc, int argc, cha
static int Abc_CommandPrintDsd ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandPrintCone ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandPrintMiter ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandPrintStatus ( 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 );
@@ -103,6 +128,7 @@ static int Abc_CommandMiter ( Abc_Frame_t * pAbc, int argc, cha
static int Abc_CommandDemiter ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandOrPos ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAndPos ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandZeroPo ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAppend ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandFrames ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandDFrames ( Abc_Frame_t * pAbc, int argc, char ** argv );
@@ -131,6 +157,7 @@ static int Abc_CommandGen ( Abc_Frame_t * pAbc, int argc, cha
static int Abc_CommandCover ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandDouble ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandInter ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandBb2Wb ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandTest ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandQuaVar ( Abc_Frame_t * pAbc, int argc, char ** argv );
@@ -143,7 +170,7 @@ static int Abc_CommandICut ( Abc_Frame_t * pAbc, int argc, cha
static int Abc_CommandIRewrite ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandDRewrite ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandDRefactor ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandDC2 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandDc2 ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandDChoice ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandDch ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandDrwsat ( Abc_Frame_t * pAbc, int argc, char ** argv );
@@ -154,7 +181,7 @@ static int Abc_CommandIFraig ( Abc_Frame_t * pAbc, int argc, cha
static int Abc_CommandDFraig ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandCSweep ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandDProve ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandDProve2 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+//static int Abc_CommandDProve2 ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbSec ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandSimSec ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandMatch ( Abc_Frame_t * pAbc, int argc, char ** argv );
@@ -207,7 +234,8 @@ static int Abc_CommandSeqFpga ( Abc_Frame_t * pAbc, int argc, cha
static int Abc_CommandSeqMap ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandSeqSweep ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandSeqSweep2 ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandSeqSweepTest ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandTestSeqSweep ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandTestScorr ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandLcorr ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandSeqCleanup ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandCycle ( Abc_Frame_t * pAbc, int argc, char ** argv );
@@ -231,12 +259,16 @@ static int Abc_CommandIProve ( Abc_Frame_t * pAbc, int argc, cha
static int Abc_CommandDebug ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandBmc ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandBmc2 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandBmc3 ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandBmcInter ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandIndcut ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandEnlarge ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandInduction ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandPBAbstraction ( Abc_Frame_t * pAbc, int argc, char ** argv );
-
+static int Abc_CommandCegar ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandConstr ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandUnfold ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandFold ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandBm ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandTraceStart ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandTraceCheck ( Abc_Frame_t * pAbc, int argc, char ** argv );
@@ -255,7 +287,7 @@ static int Abc_CommandAbc8Pfan ( Abc_Frame_t * pAbc, int argc, cha
static int Abc_CommandAbc8If ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc8DChoice ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc8Dch ( Abc_Frame_t * pAbc, int argc, char ** argv );
-static int Abc_CommandAbc8DC2 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc8Dc2 ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc8Bidec ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc8Strash ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc8Mfs ( Abc_Frame_t * pAbc, int argc, char ** argv );
@@ -278,6 +310,7 @@ static int Abc_CommandAbc8Zero ( Abc_Frame_t * pAbc, int argc, cha
static int Abc_CommandAbc8Cec ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc8DSec ( Abc_Frame_t * pAbc, int argc, char ** argv );
+
static int Abc_CommandAbc9Get ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9Put ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9Read ( Abc_Frame_t * pAbc, int argc, char ** argv );
@@ -296,11 +329,15 @@ static int Abc_CommandAbc9Sim ( Abc_Frame_t * pAbc, int argc, cha
static int Abc_CommandAbc9Resim ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9SpecI ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9Equiv ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Equiv2 ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9Semi ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9Times ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9Frames ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9Retime ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9Enable ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Dc2 ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Bidec ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Shrink ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9Miter ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9Scl ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9Lcorr ( Abc_Frame_t * pAbc, int argc, char ** argv );
@@ -314,16 +351,26 @@ static int Abc_CommandAbc9Cec ( Abc_Frame_t * pAbc, int argc, cha
static int Abc_CommandAbc9Force ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9Embed ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9If ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Trace ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Speedup ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9Era ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9Dch ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9AbsStart ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9AbsStartNew ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9AbsDerive ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9AbsRefine ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9PbaStart ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Reparam ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Posplit ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Reach ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbc9Undo ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9Test ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandAbcTestNew ( Abc_Frame_t * pAbc, int argc, char ** argv );
+
extern int Abc_CommandAbcLivenessToSafety ( Abc_Frame_t * pAbc, int argc, char ** argv );
extern int Abc_CommandAbcLivenessToSafetySim ( Abc_Frame_t * pAbc, int argc, char ** argv );
-
-static int Abc_CommandAbcTestNew ( Abc_Frame_t * pAbc, int argc, char ** argv );
-
-extern Aig_Man_t * Ntl_ManExtract( void * p );
+extern int Abc_CommandAbcLivenessToSafetyWithLTL( Abc_Frame_t * pAbc, int argc, char ** argv );
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
@@ -340,11 +387,26 @@ extern Aig_Man_t * Ntl_ManExtract( void * p );
SeeAlso []
***********************************************************************/
+void Abc_FrameReplaceCex( Abc_Frame_t * pAbc, Abc_Cex_t ** ppCex )
+{
+ ABC_FREE( pAbc->pCex );
+ pAbc->pCex = *ppCex;
+ *ppCex = NULL;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
void Abc_FrameClearDesign()
{
- extern Abc_Frame_t * Abc_FrameGetGlobalFrame();
- extern void Ntl_ManFree( void * p );
- extern void Nwk_ManFree( void * p );
Abc_Frame_t * pAbc;
pAbc = Abc_FrameGetGlobalFrame();
@@ -376,20 +438,33 @@ void Abc_FrameClearDesign()
SeeAlso []
***********************************************************************/
-void Abc_Init( Abc_Frame_t * pAbc )
+void Abc_CommandUpdate9( Abc_Frame_t * pAbc, Gia_Man_t * pNew )
{
-/*
+ if ( pNew == NULL )
{
- Aig_Man_t * pAig;
- pAig = Ioa_ReadAiger( "i10.aig", 1 );
- Aig_ManStop( pAig );
+ Abc_Print( -1, "Abc_CommandUpdate9(): Tranformation has failed.\n" );
+ return;
}
-*/
+ if ( pAbc->pGia2 )
+ Gia_ManStop( pAbc->pGia2 );
+ pAbc->pGia2 = pAbc->pGia;
+ pAbc->pGia = pNew;
+}
+
-// Amap_LibParseTest( "at\\syn\\libraries\\LIBS\\BRDCM\\tsmc13_5.ff.genlib" );
-// Amap_LibParseTest( "at\\syn\\libraries\\LIBS\\GS60\\GS60_W_30_1.7_CORE.genlib" );
-// Amap_LibParseTest( "at\\syn\\libraries\\LIBS\\TYPICAL\\typical.genlib" );
+/**Function*************************************************************
+
+ Synopsis []
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Abc_Init( Abc_Frame_t * pAbc )
+{
Cmd_CommandAdd( pAbc, "Printing", "print_stats", Abc_CommandPrintStats, 0 );
Cmd_CommandAdd( pAbc, "Printing", "print_exdc", Abc_CommandPrintExdc, 0 );
Cmd_CommandAdd( pAbc, "Printing", "print_io", Abc_CommandPrintIo, 0 );
@@ -409,6 +484,7 @@ void Abc_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "Printing", "print_dsd", Abc_CommandPrintDsd, 0 );
Cmd_CommandAdd( pAbc, "Printing", "print_cone", Abc_CommandPrintCone, 0 );
Cmd_CommandAdd( pAbc, "Printing", "print_miter", Abc_CommandPrintMiter, 0 );
+ Cmd_CommandAdd( pAbc, "Printing", "print_status", Abc_CommandPrintStatus, 0 );
Cmd_CommandAdd( pAbc, "Printing", "show", Abc_CommandShow, 0 );
Cmd_CommandAdd( pAbc, "Printing", "show_bdd", Abc_CommandShowBdd, 0 );
@@ -438,7 +514,7 @@ void Abc_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "Synthesis", "refactor", Abc_CommandRefactor, 1 );
// Cmd_CommandAdd( pAbc, "Synthesis", "restructure", Abc_CommandRestructure, 1 );
Cmd_CommandAdd( pAbc, "Synthesis", "resub", Abc_CommandResubstitute, 1 );
- Cmd_CommandAdd( pAbc, "Synthesis", "rr", Abc_CommandRr, 1 );
+// Cmd_CommandAdd( pAbc, "Synthesis", "rr", Abc_CommandRr, 1 );
Cmd_CommandAdd( pAbc, "Synthesis", "cascade", Abc_CommandCascade, 1 );
Cmd_CommandAdd( pAbc, "Various", "logic", Abc_CommandLogic, 1 );
@@ -447,6 +523,7 @@ void Abc_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "Various", "demiter", Abc_CommandDemiter, 1 );
Cmd_CommandAdd( pAbc, "Various", "orpos", Abc_CommandOrPos, 1 );
Cmd_CommandAdd( pAbc, "Various", "andpos", Abc_CommandAndPos, 1 );
+ Cmd_CommandAdd( pAbc, "Various", "zeropo", Abc_CommandZeroPo, 1 );
Cmd_CommandAdd( pAbc, "Various", "append", Abc_CommandAppend, 1 );
Cmd_CommandAdd( pAbc, "Various", "frames", Abc_CommandFrames, 1 );
Cmd_CommandAdd( pAbc, "Various", "dframes", Abc_CommandDFrames, 1 );
@@ -475,7 +552,9 @@ void Abc_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "Various", "cover", Abc_CommandCover, 1 );
Cmd_CommandAdd( pAbc, "Various", "double", Abc_CommandDouble, 1 );
Cmd_CommandAdd( pAbc, "Various", "inter", Abc_CommandInter, 1 );
+ Cmd_CommandAdd( pAbc, "Various", "bb2wb", Abc_CommandBb2Wb, 0 );
Cmd_CommandAdd( pAbc, "Various", "test", Abc_CommandTest, 0 );
+// Cmd_CommandAdd( pAbc, "Various", "qbf_solve", Abc_CommandTest, 0 );
Cmd_CommandAdd( pAbc, "Various", "qvar", Abc_CommandQuaVar, 1 );
Cmd_CommandAdd( pAbc, "Various", "qrel", Abc_CommandQuaRel, 1 );
@@ -487,7 +566,7 @@ void Abc_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "New AIG", "irw", Abc_CommandIRewrite, 1 );
Cmd_CommandAdd( pAbc, "New AIG", "drw", Abc_CommandDRewrite, 1 );
Cmd_CommandAdd( pAbc, "New AIG", "drf", Abc_CommandDRefactor, 1 );
- Cmd_CommandAdd( pAbc, "New AIG", "dc2", Abc_CommandDC2, 1 );
+ Cmd_CommandAdd( pAbc, "New AIG", "dc2", Abc_CommandDc2, 1 );
Cmd_CommandAdd( pAbc, "New AIG", "dchoice", Abc_CommandDChoice, 1 );
Cmd_CommandAdd( pAbc, "New AIG", "dch", Abc_CommandDch, 1 );
Cmd_CommandAdd( pAbc, "New AIG", "drwsat", Abc_CommandDrwsat, 1 );
@@ -544,7 +623,8 @@ void Abc_Init( Abc_Frame_t * pAbc )
// Cmd_CommandAdd( pAbc, "Sequential", "smap", Abc_CommandSeqMap, 1 );
Cmd_CommandAdd( pAbc, "Sequential", "ssweep", Abc_CommandSeqSweep, 1 );
Cmd_CommandAdd( pAbc, "Sequential", "scorr", Abc_CommandSeqSweep2, 1 );
- Cmd_CommandAdd( pAbc, "Sequential", "testssw", Abc_CommandSeqSweepTest, 0 );
+ Cmd_CommandAdd( pAbc, "Sequential", "testssw", Abc_CommandTestSeqSweep, 0 );
+ Cmd_CommandAdd( pAbc, "Sequential", "testscorr", Abc_CommandTestScorr, 0 );
Cmd_CommandAdd( pAbc, "Sequential", "lcorr", Abc_CommandLcorr, 1 );
Cmd_CommandAdd( pAbc, "Sequential", "scleanup", Abc_CommandSeqCleanup, 1 );
Cmd_CommandAdd( pAbc, "Sequential", "cycle", Abc_CommandCycle, 1 );
@@ -558,10 +638,10 @@ void Abc_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "Verification", "cec", Abc_CommandCec, 0 );
Cmd_CommandAdd( pAbc, "Verification", "dcec", Abc_CommandDCec, 0 );
- Cmd_CommandAdd( pAbc, "Verification", "sec", Abc_CommandSec, 0 );
+// Cmd_CommandAdd( pAbc, "Verification", "sec", Abc_CommandSec, 0 );
Cmd_CommandAdd( pAbc, "Verification", "dsec", Abc_CommandDSec, 0 );
Cmd_CommandAdd( pAbc, "Verification", "dprove", Abc_CommandDProve, 0 );
- Cmd_CommandAdd( pAbc, "Verification", "dprove2", Abc_CommandDProve2, 0 );
+// Cmd_CommandAdd( pAbc, "Verification", "dprove2", Abc_CommandDProve2, 0 );
Cmd_CommandAdd( pAbc, "Verification", "absec", Abc_CommandAbSec, 0 );
Cmd_CommandAdd( pAbc, "Verification", "simsec", Abc_CommandSimSec, 0 );
Cmd_CommandAdd( pAbc, "Verification", "match", Abc_CommandMatch, 0 );
@@ -573,11 +653,16 @@ void Abc_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "Verification", "debug", Abc_CommandDebug, 0 );
Cmd_CommandAdd( pAbc, "Verification", "bmc", Abc_CommandBmc, 0 );
Cmd_CommandAdd( pAbc, "Verification", "bmc2", Abc_CommandBmc2, 0 );
- Cmd_CommandAdd( pAbc, "Verification", "int", Abc_CommandBmcInter, 0 );
+ Cmd_CommandAdd( pAbc, "Verification", "bmc3", Abc_CommandBmc3, 1 );
+ Cmd_CommandAdd( pAbc, "Verification", "int", Abc_CommandBmcInter, 1 );
Cmd_CommandAdd( pAbc, "Verification", "indcut", Abc_CommandIndcut, 0 );
Cmd_CommandAdd( pAbc, "Verification", "enlarge", Abc_CommandEnlarge, 1 );
Cmd_CommandAdd( pAbc, "Verification", "ind", Abc_CommandInduction, 0 );
- Cmd_CommandAdd( pAbc, "Verification", "abs", Abc_CommandPBAbstraction, 0 );
+ Cmd_CommandAdd( pAbc, "Verification", "abs", Abc_CommandCegar, 1 );
+ Cmd_CommandAdd( pAbc, "Verification", "constr", Abc_CommandConstr, 0 );
+ Cmd_CommandAdd( pAbc, "Verification", "unfold", Abc_CommandUnfold, 1 );
+ Cmd_CommandAdd( pAbc, "Verification", "fold", Abc_CommandFold, 1 );
+ Cmd_CommandAdd( pAbc, "Verification", "bm", Abc_CommandBm, 1 );
Cmd_CommandAdd( pAbc, "ABC8", "*r", Abc_CommandAbc8Read, 0 );
@@ -593,7 +678,7 @@ void Abc_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "ABC8", "*if", Abc_CommandAbc8If, 0 );
Cmd_CommandAdd( pAbc, "ABC8", "*dchoice", Abc_CommandAbc8DChoice, 0 );
Cmd_CommandAdd( pAbc, "ABC8", "*dch", Abc_CommandAbc8Dch, 0 );
- Cmd_CommandAdd( pAbc, "ABC8", "*dc2", Abc_CommandAbc8DC2, 0 );
+ Cmd_CommandAdd( pAbc, "ABC8", "*dc2", Abc_CommandAbc8Dc2, 0 );
Cmd_CommandAdd( pAbc, "ABC8", "*bidec", Abc_CommandAbc8Bidec, 0 );
Cmd_CommandAdd( pAbc, "ABC8", "*st", Abc_CommandAbc8Strash, 0 );
Cmd_CommandAdd( pAbc, "ABC8", "*mfs", Abc_CommandAbc8Mfs, 0 );
@@ -614,49 +699,65 @@ void Abc_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "ABC8", "*cec", Abc_CommandAbc8Cec, 0 );
Cmd_CommandAdd( pAbc, "ABC8", "*dsec", Abc_CommandAbc8DSec, 0 );
-
- Cmd_CommandAdd( pAbc, "AIG", "&get", Abc_CommandAbc9Get, 0 );
- Cmd_CommandAdd( pAbc, "AIG", "&put", Abc_CommandAbc9Put, 0 );
- Cmd_CommandAdd( pAbc, "AIG", "&r", Abc_CommandAbc9Read, 0 );
- Cmd_CommandAdd( pAbc, "AIG", "&w", Abc_CommandAbc9Write, 0 );
- Cmd_CommandAdd( pAbc, "AIG", "&ps", Abc_CommandAbc9Ps, 0 );
- Cmd_CommandAdd( pAbc, "AIG", "&pfan", Abc_CommandAbc9PFan, 0 );
- Cmd_CommandAdd( pAbc, "AIG", "&psig", Abc_CommandAbc9PSig, 0 );
- Cmd_CommandAdd( pAbc, "AIG", "&status", Abc_CommandAbc9Status, 0 );
- Cmd_CommandAdd( pAbc, "AIG", "&show", Abc_CommandAbc9Show, 0 );
- Cmd_CommandAdd( pAbc, "AIG", "&st", Abc_CommandAbc9Hash, 0 );
- Cmd_CommandAdd( pAbc, "AIG", "&topand", Abc_CommandAbc9Topand, 0 );
- Cmd_CommandAdd( pAbc, "AIG", "&cof", Abc_CommandAbc9Cof, 0 );
- Cmd_CommandAdd( pAbc, "AIG", "&trim", Abc_CommandAbc9Trim, 0 );
- Cmd_CommandAdd( pAbc, "AIG", "&dfs", Abc_CommandAbc9Dfs, 0 );
- Cmd_CommandAdd( pAbc, "AIG", "&sim", Abc_CommandAbc9Sim, 0 );
- Cmd_CommandAdd( pAbc, "AIG", "&resim", Abc_CommandAbc9Resim, 0 );
- Cmd_CommandAdd( pAbc, "AIG", "&speci", Abc_CommandAbc9SpecI, 0 );
- Cmd_CommandAdd( pAbc, "AIG", "&equiv", Abc_CommandAbc9Equiv, 0 );
- Cmd_CommandAdd( pAbc, "AIG", "&semi", Abc_CommandAbc9Semi, 0 );
- Cmd_CommandAdd( pAbc, "AIG", "&times", Abc_CommandAbc9Times, 0 );
- Cmd_CommandAdd( pAbc, "AIG", "&frames", Abc_CommandAbc9Frames, 0 );
- Cmd_CommandAdd( pAbc, "AIG", "&retime", Abc_CommandAbc9Retime, 0 );
- Cmd_CommandAdd( pAbc, "AIG", "&enable", Abc_CommandAbc9Enable, 0 );
- Cmd_CommandAdd( pAbc, "AIG", "&miter", Abc_CommandAbc9Miter, 0 );
- Cmd_CommandAdd( pAbc, "AIG", "&scl", Abc_CommandAbc9Scl, 0 );
- Cmd_CommandAdd( pAbc, "AIG", "&lcorr", Abc_CommandAbc9Lcorr, 0 );
- Cmd_CommandAdd( pAbc, "AIG", "&scorr", Abc_CommandAbc9Scorr, 0 );
- Cmd_CommandAdd( pAbc, "AIG", "&choice", Abc_CommandAbc9Choice, 0 );
- Cmd_CommandAdd( pAbc, "AIG", "&sat", Abc_CommandAbc9Sat, 0 );
- Cmd_CommandAdd( pAbc, "AIG", "&fraig", Abc_CommandAbc9Fraig, 0 );
- Cmd_CommandAdd( pAbc, "AIG", "&srm", Abc_CommandAbc9Srm, 0 );
- Cmd_CommandAdd( pAbc, "AIG", "&reduce", Abc_CommandAbc9Reduce, 0 );
- Cmd_CommandAdd( pAbc, "AIG", "&cec", Abc_CommandAbc9Cec, 0 );
- Cmd_CommandAdd( pAbc, "AIG", "&force", Abc_CommandAbc9Force, 0 );
- Cmd_CommandAdd( pAbc, "AIG", "&embed", Abc_CommandAbc9Embed, 0 );
- Cmd_CommandAdd( pAbc, "AIG", "&if", Abc_CommandAbc9If, 0 );
- Cmd_CommandAdd( pAbc, "AIG", "&era", Abc_CommandAbc9Era, 0 );
- Cmd_CommandAdd( pAbc, "AIG", "&dch", Abc_CommandAbc9Dch, 0 );
- Cmd_CommandAdd( pAbc, "AIG", "&test", Abc_CommandAbc9Test, 0 );
+
+ Cmd_CommandAdd( pAbc, "ABC9", "&get", Abc_CommandAbc9Get, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&put", Abc_CommandAbc9Put, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&r", Abc_CommandAbc9Read, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&w", Abc_CommandAbc9Write, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&ps", Abc_CommandAbc9Ps, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&pfan", Abc_CommandAbc9PFan, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&psig", Abc_CommandAbc9PSig, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&status", Abc_CommandAbc9Status, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&show", Abc_CommandAbc9Show, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&st", Abc_CommandAbc9Hash, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&topand", Abc_CommandAbc9Topand, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&cof", Abc_CommandAbc9Cof, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&trim", Abc_CommandAbc9Trim, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&dfs", Abc_CommandAbc9Dfs, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&sim", Abc_CommandAbc9Sim, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&resim", Abc_CommandAbc9Resim, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&speci", Abc_CommandAbc9SpecI, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&equiv", Abc_CommandAbc9Equiv, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&equiv2", Abc_CommandAbc9Equiv2, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&semi", Abc_CommandAbc9Semi, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&times", Abc_CommandAbc9Times, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&frames", Abc_CommandAbc9Frames, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&retime", Abc_CommandAbc9Retime, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&enable", Abc_CommandAbc9Enable, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&dc2", Abc_CommandAbc9Dc2, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&bidec", Abc_CommandAbc9Bidec, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&shrink", Abc_CommandAbc9Shrink, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&miter", Abc_CommandAbc9Miter, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&scl", Abc_CommandAbc9Scl, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&lcorr", Abc_CommandAbc9Lcorr, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&scorr", Abc_CommandAbc9Scorr, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&choice", Abc_CommandAbc9Choice, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&sat", Abc_CommandAbc9Sat, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&fraig", Abc_CommandAbc9Fraig, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&srm", Abc_CommandAbc9Srm, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&reduce", Abc_CommandAbc9Reduce, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&cec", Abc_CommandAbc9Cec, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&force", Abc_CommandAbc9Force, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&embed", Abc_CommandAbc9Embed, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&if", Abc_CommandAbc9If, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&trace", Abc_CommandAbc9Trace, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&speedup", Abc_CommandAbc9Speedup, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&era", Abc_CommandAbc9Era, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&dch", Abc_CommandAbc9Dch, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&abs_start", Abc_CommandAbc9AbsStart, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&abs_newstart", Abc_CommandAbc9AbsStartNew, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&abs_derive", Abc_CommandAbc9AbsDerive, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&abs_refine", Abc_CommandAbc9AbsRefine, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&pba_start", Abc_CommandAbc9PbaStart, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&reparam", Abc_CommandAbc9Reparam, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&posplit", Abc_CommandAbc9Posplit, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&reach", Abc_CommandAbc9Reach, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&undo", Abc_CommandAbc9Undo, 0 );
+ Cmd_CommandAdd( pAbc, "ABC9", "&test", Abc_CommandAbc9Test, 0 );
Cmd_CommandAdd( pAbc, "Liveness", "l2s", Abc_CommandAbcLivenessToSafety, 0 );
Cmd_CommandAdd( pAbc, "Liveness", "l2ssim", Abc_CommandAbcLivenessToSafetySim, 0 );
+ Cmd_CommandAdd( pAbc, "Liveness", "l3s", Abc_CommandAbcLivenessToSafetyWithLTL, 0 );
Cmd_CommandAdd( pAbc, "Various", "testnew", Abc_CommandAbcTestNew, 0 );
@@ -697,9 +798,24 @@ void Abc_Init( Abc_Frame_t * pAbc )
void For_ManFileExperiment();
// For_ManFileExperiment();
}
+/*
{
+ int i1, i2, i3, i4, i5, i6, N, Counter = 0;
+ for ( N = 20; N < 40; N++ )
+ {
+ Counter = 0;
+ for ( i1 = 0; i1 < N; i1++ )
+ for ( i2 = i1+1; i2 < N; i2++ )
+ for ( i3 = i2; i3 < N; i3++ )
+ for ( i4 = i3; i4 < N; i4++ )
+// for ( i5 = i4+1; i5 < N; i5++ )
+// for ( i6 = i5+1; i6 < N; i6++ )
+ Counter++;
+ printf( "%d=%d ", N, Counter );
+ }
+ printf( "\n" );
}
-
+*/
}
/**Function*************************************************************
@@ -713,13 +829,15 @@ void Abc_Init( Abc_Frame_t * pAbc )
SeeAlso []
***********************************************************************/
-void Abc_End()
+void Abc_End( Abc_Frame_t * pAbc )
{
+ extern Abc_Frame_t * Abc_FrameGetGlobalFrame();
Abc_FrameClearDesign();
+
{
extern void If_LutLibFree( If_Lib_t * pLutLib );
if ( Abc_FrameGetGlobalFrame()->pAbc8Lib )
- If_LutLibFree( Abc_FrameGetGlobalFrame()->pAbc8Lib );
+ If_LutLibFree( (If_Lib_t *)Abc_FrameGetGlobalFrame()->pAbc8Lib );
}
// Dar_LibDumpPriorities();
@@ -729,7 +847,7 @@ void Abc_End()
}
{
- extern void Cnf_ClearMemory();
+// extern void Cnf_ClearMemory();
Cnf_ClearMemory();
}
{
@@ -740,12 +858,11 @@ void Abc_End()
extern void Aig_RManQuit();
Aig_RManQuit();
}
-
Abc_NtkFraigStoreClean();
-// Rwt_Man4ExplorePrint();
-
- if ( Abc_FrameGetGlobalFrame()->pAig )
- Gia_ManStop( Abc_FrameGetGlobalFrame()->pAig );
+ if ( Abc_FrameGetGlobalFrame()->pGia )
+ Gia_ManStop( Abc_FrameGetGlobalFrame()->pGia );
+ if ( Abc_FrameGetGlobalFrame()->pGia2 )
+ Gia_ManStop( Abc_FrameGetGlobalFrame()->pGia2 );
}
/**Function*************************************************************
@@ -761,8 +878,7 @@ void Abc_End()
***********************************************************************/
int Abc_CommandPrintStats( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int fFactor;
int fSaveBest;
int fDumpResult;
@@ -774,8 +890,6 @@ int Abc_CommandPrintStats( Abc_Frame_t * pAbc, int argc, char ** argv )
int c;
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
// set the defaults
fFactor = 0;
@@ -824,36 +938,35 @@ int Abc_CommandPrintStats( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( Abc_FrameReadErr(pAbc), "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsLogic(pNtk) && fUseLutLib )
{
- fprintf( Abc_FrameReadErr(pAbc), "Cannot print LUT delay for a non-logic network.\n" );
+ Abc_Print( -1, "Cannot print LUT delay for a non-logic network.\n" );
return 1;
}
- Abc_NtkPrintStats( pOut, pNtk, fFactor, fSaveBest, fDumpResult, fUseLutLib, fPrintMuxes, fPower, fGlitch );
+ Abc_NtkPrintStats( pNtk, fFactor, fSaveBest, fDumpResult, fUseLutLib, fPrintMuxes, fPower, fGlitch );
if ( fPrintTime )
{
pAbc->TimeTotal += pAbc->TimeCommand;
- fprintf( pAbc->Out, "elapse: %3.2f seconds, total: %3.2f seconds\n",
- pAbc->TimeCommand, pAbc->TimeTotal );
+ Abc_Print( 1, "elapse: %3.2f seconds, total: %3.2f seconds\n", pAbc->TimeCommand, pAbc->TimeTotal );
pAbc->TimeCommand = 0.0;
}
return 0;
usage:
- fprintf( pErr, "usage: print_stats [-fbdltmpgh]\n" );
- fprintf( pErr, "\t prints the network statistics\n" );
- fprintf( pErr, "\t-f : toggles printing the literal count in the factored forms [default = %s]\n", fFactor? "yes": "no" );
- fprintf( pErr, "\t-b : toggles saving the best logic network in \"best.blif\" [default = %s]\n", fSaveBest? "yes": "no" );
- fprintf( pErr, "\t-d : toggles dumping network into file \"<input_file_name>_dump.blif\" [default = %s]\n", fDumpResult? "yes": "no" );
- fprintf( pErr, "\t-l : toggles printing delay of LUT mapping using LUT library [default = %s]\n", fSaveBest? "yes": "no" );
- fprintf( pErr, "\t-t : toggles printing runtime statistics [default = %s]\n", fPrintTime? "yes": "no" );
- fprintf( pErr, "\t-m : toggles printing MUX statistics [default = %s]\n", fPrintMuxes? "yes": "no" );
- fprintf( pErr, "\t-p : toggles printing power dissipation due to switching [default = %s]\n", fPower? "yes": "no" );
- fprintf( pErr, "\t-q : toggles printing percentage of increased power due to glitching [default = %s]\n", fGlitch? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: print_stats [-fbdltmpgh]\n" );
+ Abc_Print( -2, "\t prints the network statistics\n" );
+ Abc_Print( -2, "\t-f : toggles printing the literal count in the factored forms [default = %s]\n", fFactor? "yes": "no" );
+ Abc_Print( -2, "\t-b : toggles saving the best logic network in \"best.blif\" [default = %s]\n", fSaveBest? "yes": "no" );
+ Abc_Print( -2, "\t-d : toggles dumping network into file \"<input_file_name>_dump.blif\" [default = %s]\n", fDumpResult? "yes": "no" );
+ Abc_Print( -2, "\t-l : toggles printing delay of LUT mapping using LUT library [default = %s]\n", fSaveBest? "yes": "no" );
+ Abc_Print( -2, "\t-t : toggles printing runtime statistics [default = %s]\n", fPrintTime? "yes": "no" );
+ Abc_Print( -2, "\t-m : toggles printing MUX statistics [default = %s]\n", fPrintMuxes? "yes": "no" );
+ Abc_Print( -2, "\t-p : toggles printing power dissipation due to switching [default = %s]\n", fPower? "yes": "no" );
+ Abc_Print( -2, "\t-q : toggles printing percentage of increased power due to glitching [default = %s]\n", fGlitch? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -870,18 +983,13 @@ usage:
***********************************************************************/
int Abc_CommandPrintExdc( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkTemp;
double Percentage;
- bool fShort;
+ int fShort;
int c;
int fPrintDc;
-
extern double Abc_NtkSpacePercentage( Abc_Obj_t * pNode );
-
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
// set the defaults
fShort = 1;
@@ -906,12 +1014,12 @@ int Abc_CommandPrintExdc( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( Abc_FrameReadErr(pAbc), "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( pNtk->pExdc == NULL )
{
- fprintf( Abc_FrameReadErr(pAbc), "Network has no EXDC.\n" );
+ Abc_Print( -1, "Network has no EXDC.\n" );
return 1;
}
@@ -926,26 +1034,26 @@ int Abc_CommandPrintExdc( Abc_Frame_t * pAbc, int argc, char ** argv )
else
Percentage = Abc_NtkSpacePercentage( Abc_ObjChild0( Abc_NtkPo(pNtk->pExdc, 0) ) );
- printf( "EXDC network statistics: " );
- printf( "(" );
+ Abc_Print( 1, "EXDC network statistics: " );
+ Abc_Print( 1, "(" );
if ( Percentage > 0.05 && Percentage < 99.95 )
- printf( "%.2f", Percentage );
+ Abc_Print( 1, "%.2f", Percentage );
else if ( Percentage > 0.000005 && Percentage < 99.999995 )
- printf( "%.6f", Percentage );
+ Abc_Print( 1, "%.6f", Percentage );
else
- printf( "%f", Percentage );
- printf( " %% don't-cares)\n" );
+ Abc_Print( 1, "%f", Percentage );
+ Abc_Print( 1, " %% don't-cares)\n" );
}
else
- printf( "EXDC network statistics: \n" );
- Abc_NtkPrintStats( pOut, pNtk->pExdc, 0, 0, 0, 0, 0, 0, 0 );
+ Abc_Print( 1, "EXDC network statistics: \n" );
+ Abc_NtkPrintStats( pNtk->pExdc, 0, 0, 0, 0, 0, 0, 0 );
return 0;
usage:
- fprintf( pErr, "usage: print_exdc [-dh]\n" );
- fprintf( pErr, "\t prints the EXDC network statistics\n" );
- fprintf( pErr, "\t-d : toggles printing don't-care percentage [default = %s]\n", fPrintDc? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: print_exdc [-dh]\n" );
+ Abc_Print( -2, "\t prints the EXDC network statistics\n" );
+ Abc_Print( -2, "\t-d : toggles printing don't-care percentage [default = %s]\n", fPrintDc? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -962,15 +1070,10 @@ usage:
***********************************************************************/
int Abc_CommandPrintIo( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
Abc_Obj_t * pNode;
int c;
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
@@ -986,13 +1089,13 @@ int Abc_CommandPrintIo( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( argc > globalUtilOptind + 1 )
{
- fprintf( pErr, "Wrong number of auguments.\n" );
+ Abc_Print( -1, "Wrong number of auguments.\n" );
goto usage;
}
@@ -1001,21 +1104,21 @@ int Abc_CommandPrintIo( Abc_Frame_t * pAbc, int argc, char ** argv )
pNode = Abc_NtkFindNode( pNtk, argv[globalUtilOptind] );
if ( pNode == NULL )
{
- fprintf( pErr, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
+ Abc_Print( -1, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
return 1;
}
- Abc_NodePrintFanio( pOut, pNode );
+ Abc_NodePrintFanio( stdout, pNode );
return 0;
}
// print the nodes
- Abc_NtkPrintIo( pOut, pNtk );
+ Abc_NtkPrintIo( stdout, pNtk );
return 0;
usage:
- fprintf( pErr, "usage: print_io [-h] <node>\n" );
- fprintf( pErr, "\t prints the PIs/POs or fanins/fanouts of a node\n" );
- fprintf( pErr, "\t-h : print the command usage\n");
- fprintf( pErr, "\tnode : the node to print fanins/fanouts\n");
+ Abc_Print( -2, "usage: print_io [-h] <node>\n" );
+ Abc_Print( -2, "\t prints the PIs/POs or fanins/fanouts of a node\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ Abc_Print( -2, "\tnode : the node to print fanins/fanouts\n");
return 1;
}
@@ -1032,16 +1135,11 @@ usage:
***********************************************************************/
int Abc_CommandPrintLatch( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
int fPrintSccs;
extern void Abc_NtkPrintSccs( Abc_Ntk_t * pNtk, int fVerbose );
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fPrintSccs = 0;
Extra_UtilGetoptReset();
@@ -1061,20 +1159,20 @@ int Abc_CommandPrintLatch( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
// print the nodes
- Abc_NtkPrintLatch( pOut, pNtk );
+ Abc_NtkPrintLatch( stdout, pNtk );
if ( fPrintSccs )
Abc_NtkPrintSccs( pNtk, 0 );
return 0;
usage:
- fprintf( pErr, "usage: print_latch [-sh]\n" );
- fprintf( pErr, "\t prints information about latches\n" );
- fprintf( pErr, "\t-s : toggles printing SCCs of registers [default = %s]\n", fPrintSccs? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: print_latch [-sh]\n" );
+ Abc_Print( -2, "\t prints information about latches\n" );
+ Abc_Print( -2, "\t-s : toggles printing SCCs of registers [default = %s]\n", fPrintSccs? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -1091,15 +1189,10 @@ usage:
***********************************************************************/
int Abc_CommandPrintFanio( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
int fVerbose;
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fVerbose = 0;
Extra_UtilGetoptReset();
@@ -1119,22 +1212,22 @@ int Abc_CommandPrintFanio( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
// print the nodes
if ( fVerbose )
- Abc_NtkPrintFanio( pOut, pNtk );
+ Abc_NtkPrintFanio( stdout, pNtk );
else
- Abc_NtkPrintFanioNew( pOut, pNtk );
+ Abc_NtkPrintFanioNew( stdout, pNtk );
return 0;
usage:
- fprintf( pErr, "usage: print_fanio [-vh]\n" );
- fprintf( pErr, "\t prints the statistics about fanins/fanouts of all nodes\n" );
- fprintf( pErr, "\t-v : toggles verbose way of printing the stats [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: print_fanio [-vh]\n" );
+ Abc_Print( -2, "\t prints the statistics about fanins/fanouts of all nodes\n" );
+ Abc_Print( -2, "\t-v : toggles verbose way of printing the stats [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -1151,15 +1244,10 @@ usage:
***********************************************************************/
int Abc_CommandPrintMffc( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
extern void Abc_NtkPrintMffc( FILE * pFile, Abc_Ntk_t * pNtk );
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
@@ -1175,18 +1263,18 @@ int Abc_CommandPrintMffc( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
// print the nodes
- Abc_NtkPrintMffc( pOut, pNtk );
+ Abc_NtkPrintMffc( stdout, pNtk );
return 0;
usage:
- fprintf( pErr, "usage: print_mffc [-h]\n" );
- fprintf( pErr, "\t prints the MFFC of each node in the network\n" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: print_mffc [-h]\n" );
+ Abc_Print( -2, "\t prints the MFFC of each node in the network\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -1203,16 +1291,11 @@ usage:
***********************************************************************/
int Abc_CommandPrintFactor( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
Abc_Obj_t * pNode;
int c;
int fUseRealNames;
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fUseRealNames = 1;
Extra_UtilGetoptReset();
@@ -1232,19 +1315,19 @@ int Abc_CommandPrintFactor( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsSopLogic(pNtk) )
{
- fprintf( pErr, "Printing factored forms can be done for SOP networks.\n" );
+ Abc_Print( -1, "Printing factored forms can be done for SOP networks.\n" );
return 1;
}
if ( argc > globalUtilOptind + 1 )
{
- fprintf( pErr, "Wrong number of auguments.\n" );
+ Abc_Print( -1, "Wrong number of auguments.\n" );
goto usage;
}
@@ -1253,22 +1336,22 @@ int Abc_CommandPrintFactor( Abc_Frame_t * pAbc, int argc, char ** argv )
pNode = Abc_NtkFindNode( pNtk, argv[globalUtilOptind] );
if ( pNode == NULL )
{
- fprintf( pErr, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
+ Abc_Print( -1, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
return 1;
}
- Abc_NodePrintFactor( pOut, pNode, fUseRealNames );
+ Abc_NodePrintFactor( stdout, pNode, fUseRealNames );
return 0;
}
// print the nodes
- Abc_NtkPrintFactor( pOut, pNtk, fUseRealNames );
+ Abc_NtkPrintFactor( stdout, pNtk, fUseRealNames );
return 0;
usage:
- fprintf( pErr, "usage: print_factor [-nh] <node>\n" );
- fprintf( pErr, "\t prints the factored forms of nodes\n" );
- fprintf( pErr, "\t-n : toggles real/dummy fanin names [default = %s]\n", fUseRealNames? "real": "dummy" );
- fprintf( pErr, "\t-h : print the command usage\n");
- fprintf( pErr, "\tnode : (optional) one node to consider\n");
+ Abc_Print( -2, "usage: print_factor [-nh] <node>\n" );
+ Abc_Print( -2, "\t prints the factored forms of nodes\n" );
+ Abc_Print( -2, "\t-n : toggles real/dummy fanin names [default = %s]\n", fUseRealNames? "real": "dummy" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ Abc_Print( -2, "\tnode : (optional) one node to consider\n");
return 1;
}
@@ -1285,17 +1368,12 @@ usage:
***********************************************************************/
int Abc_CommandPrintLevel( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
Abc_Obj_t * pNode;
int c;
int fListNodes;
int fProfile;
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fListNodes = 0;
fProfile = 1;
@@ -1319,19 +1397,19 @@ int Abc_CommandPrintLevel( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !fProfile && !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "This command works only for AIGs (run \"strash\").\n" );
+ Abc_Print( -1, "This command works only for AIGs (run \"strash\").\n" );
return 1;
}
if ( argc > globalUtilOptind + 1 )
{
- fprintf( pErr, "Wrong number of auguments.\n" );
+ Abc_Print( -1, "Wrong number of auguments.\n" );
goto usage;
}
@@ -1340,23 +1418,23 @@ int Abc_CommandPrintLevel( Abc_Frame_t * pAbc, int argc, char ** argv )
pNode = Abc_NtkFindNode( pNtk, argv[globalUtilOptind] );
if ( pNode == NULL )
{
- fprintf( pErr, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
+ Abc_Print( -1, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
return 1;
}
- Abc_NodePrintLevel( pOut, pNode );
+ Abc_NodePrintLevel( stdout, pNode );
return 0;
}
// process all COs
- Abc_NtkPrintLevel( pOut, pNtk, fProfile, fListNodes );
+ Abc_NtkPrintLevel( stdout, pNtk, fProfile, fListNodes );
return 0;
usage:
- fprintf( pErr, "usage: print_level [-nph] <node>\n" );
- fprintf( pErr, "\t prints information about node level and cone size\n" );
- fprintf( pErr, "\t-n : toggles printing nodes by levels [default = %s]\n", fListNodes? "yes": "no" );
- fprintf( pErr, "\t-p : toggles printing level profile [default = %s]\n", fProfile? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
- fprintf( pErr, "\tnode : (optional) one node to consider\n");
+ Abc_Print( -2, "usage: print_level [-nph] <node>\n" );
+ Abc_Print( -2, "\t prints information about node level and cone size\n" );
+ Abc_Print( -2, "\t-n : toggles printing nodes by levels [default = %s]\n", fListNodes? "yes": "no" );
+ Abc_Print( -2, "\t-p : toggles printing level profile [default = %s]\n", fProfile? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ Abc_Print( -2, "\tnode : (optional) one node to consider\n");
return 1;
}
@@ -1374,18 +1452,13 @@ usage:
int Abc_CommandPrintSupport( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Vec_Ptr_t * vSuppFun;
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
int fStruct;
int fVerbose;
extern Vec_Ptr_t * Sim_ComputeFunSupp( Abc_Ntk_t * pNtk, int fVerbose );
extern void Abc_NtkPrintStrSupports( Abc_Ntk_t * pNtk );
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fStruct = 1;
fVerbose = 0;
@@ -1409,7 +1482,7 @@ int Abc_CommandPrintSupport( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
@@ -1422,12 +1495,12 @@ int Abc_CommandPrintSupport( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( !Abc_NtkIsComb(pNtk) )
{
- fprintf( pErr, "This command works only for combinational networks (run \"comb\").\n" );
+ Abc_Print( -1, "This command works only for combinational networks (run \"comb\").\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "This command works only for AIGs (run \"strash\").\n" );
+ Abc_Print( -1, "This command works only for AIGs (run \"strash\").\n" );
return 1;
}
vSuppFun = Sim_ComputeFunSupp( pNtk, fVerbose );
@@ -1436,11 +1509,11 @@ int Abc_CommandPrintSupport( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: print_supp [-svh]\n" );
- fprintf( pErr, "\t prints the supports of the CO nodes\n" );
- fprintf( pErr, "\t-s : toggle printing structural support only [default = %s].\n", fStruct? "yes": "no" );
- fprintf( pErr, "\t-v : enable verbose output [default = %s].\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: print_supp [-svh]\n" );
+ Abc_Print( -2, "\t prints the supports of the CO nodes\n" );
+ Abc_Print( -2, "\t-s : toggle printing structural support only [default = %s].\n", fStruct? "yes": "no" );
+ Abc_Print( -2, "\t-v : enable verbose output [default = %s].\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -1457,8 +1530,7 @@ usage:
***********************************************************************/
int Abc_CommandPrintSymms( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
int fUseBdds;
int fNaive;
@@ -1466,10 +1538,6 @@ int Abc_CommandPrintSymms( Abc_Frame_t * pAbc, int argc, char ** argv )
int fVerbose;
extern void Abc_NtkSymmetries( Abc_Ntk_t * pNtk, int fUseBdds, int fNaive, int fReorder, int fVerbose );
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fUseBdds = 0;
fNaive = 0;
@@ -1500,12 +1568,12 @@ int Abc_CommandPrintSymms( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsComb(pNtk) )
{
- fprintf( pErr, "This command works only for combinational networks (run \"comb\").\n" );
+ Abc_Print( -1, "This command works only for combinational networks (run \"comb\").\n" );
return 1;
}
if ( Abc_NtkIsStrash(pNtk) )
@@ -1519,13 +1587,13 @@ int Abc_CommandPrintSymms( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: print_symm [-bnrvh]\n" );
- fprintf( pErr, "\t computes symmetries of the PO functions\n" );
- fprintf( pErr, "\t-b : toggle BDD-based or SAT-based computations [default = %s].\n", fUseBdds? "BDD": "SAT" );
- fprintf( pErr, "\t-n : enable naive BDD-based computation [default = %s].\n", fNaive? "yes": "no" );
- fprintf( pErr, "\t-r : enable dynamic BDD variable reordering [default = %s].\n", fReorder? "yes": "no" );
- fprintf( pErr, "\t-v : enable verbose output [default = %s].\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: print_symm [-bnrvh]\n" );
+ Abc_Print( -2, "\t computes symmetries of the PO functions\n" );
+ Abc_Print( -2, "\t-b : toggle BDD-based or SAT-based computations [default = %s].\n", fUseBdds? "BDD": "SAT" );
+ Abc_Print( -2, "\t-n : enable naive BDD-based computation [default = %s].\n", fNaive? "yes": "no" );
+ Abc_Print( -2, "\t-r : enable dynamic BDD variable reordering [default = %s].\n", fReorder? "yes": "no" );
+ Abc_Print( -2, "\t-v : enable verbose output [default = %s].\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -1542,18 +1610,13 @@ usage:
***********************************************************************/
int Abc_CommandPrintUnate( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
int fUseBdds;
int fUseNaive;
int fVerbose;
extern void Abc_NtkPrintUnate( Abc_Ntk_t * pNtk, int fUseBdds, int fUseNaive, int fVerbose );
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fUseBdds = 1;
fUseNaive = 0;
@@ -1580,24 +1643,24 @@ int Abc_CommandPrintUnate( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "This command works only for AIGs (run \"strash\").\n" );
+ Abc_Print( -1, "This command works only for AIGs (run \"strash\").\n" );
return 1;
}
Abc_NtkPrintUnate( pNtk, fUseBdds, fUseNaive, fVerbose );
return 0;
usage:
- fprintf( pErr, "usage: print_unate [-bnvh]\n" );
- fprintf( pErr, "\t computes unate variables of the PO functions\n" );
- fprintf( pErr, "\t-b : toggle BDD-based or SAT-based computations [default = %s].\n", fUseBdds? "BDD": "SAT" );
- fprintf( pErr, "\t-n : toggle naive BDD-based computation [default = %s].\n", fUseNaive? "yes": "no" );
- fprintf( pErr, "\t-v : enable verbose output [default = %s].\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: print_unate [-bnvh]\n" );
+ Abc_Print( -2, "\t computes unate variables of the PO functions\n" );
+ Abc_Print( -2, "\t-b : toggle BDD-based or SAT-based computations [default = %s].\n", fUseBdds? "BDD": "SAT" );
+ Abc_Print( -2, "\t-n : toggle naive BDD-based computation [default = %s].\n", fUseNaive? "yes": "no" );
+ Abc_Print( -2, "\t-v : enable verbose output [default = %s].\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -1614,18 +1677,13 @@ usage:
***********************************************************************/
int Abc_CommandPrintAuto( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
int Output;
int fNaive;
int fVerbose;
extern void Abc_NtkAutoPrint( Abc_Ntk_t * pNtk, int Output, int fNaive, int fVerbose );
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Output = -1;
fNaive = 0;
@@ -1638,7 +1696,7 @@ int Abc_CommandPrintAuto( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'O':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-O\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-O\" should be followed by an integer.\n" );
goto usage;
}
Output = atoi(argv[globalUtilOptind]);
@@ -1660,12 +1718,12 @@ int Abc_CommandPrintAuto( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "This command works only for AIGs (run \"strash\").\n" );
+ Abc_Print( -1, "This command works only for AIGs (run \"strash\").\n" );
return 1;
}
@@ -1674,12 +1732,12 @@ int Abc_CommandPrintAuto( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: print_auto [-O num] [-nvh]\n" );
- fprintf( pErr, "\t computes autosymmetries of the PO functions\n" );
- fprintf( pErr, "\t-O num : (optional) the 0-based number of the output [default = all]\n");
- fprintf( pErr, "\t-n : enable naive BDD-based computation [default = %s].\n", fNaive? "yes": "no" );
- fprintf( pErr, "\t-v : enable verbose output [default = %s].\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: print_auto [-O num] [-nvh]\n" );
+ Abc_Print( -2, "\t computes autosymmetries of the PO functions\n" );
+ Abc_Print( -2, "\t-O num : (optional) the 0-based number of the output [default = all]\n");
+ Abc_Print( -2, "\t-n : enable naive BDD-based computation [default = %s].\n", fNaive? "yes": "no" );
+ Abc_Print( -2, "\t-v : enable verbose output [default = %s].\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -1696,18 +1754,13 @@ usage:
***********************************************************************/
int Abc_CommandPrintKMap( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
Abc_Obj_t * pNode;
int c;
int fUseRealNames;
extern void Abc_NodePrintKMap( Abc_Obj_t * pNode, int fUseRealNames );
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fUseRealNames = 1;
Extra_UtilGetoptReset();
@@ -1727,18 +1780,18 @@ int Abc_CommandPrintKMap( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsLogic(pNtk) )
{
- fprintf( pErr, "Visualization of Karnaugh maps works for logic networks.\n" );
+ Abc_Print( -1, "Visualization of Karnaugh maps works for logic networks.\n" );
return 1;
}
if ( argc > globalUtilOptind + 1 )
{
- fprintf( pErr, "Wrong number of auguments.\n" );
+ Abc_Print( -1, "Wrong number of auguments.\n" );
goto usage;
}
if ( argc == globalUtilOptind )
@@ -1746,7 +1799,7 @@ int Abc_CommandPrintKMap( Abc_Frame_t * pAbc, int argc, char ** argv )
pNode = Abc_ObjFanin0( Abc_NtkPo(pNtk, 0) );
if ( !Abc_ObjIsNode(pNode) )
{
- fprintf( pErr, "The driver \"%s\" of the first PO is not an internal node.\n", Abc_ObjName(pNode) );
+ Abc_Print( -1, "The driver \"%s\" of the first PO is not an internal node.\n", Abc_ObjName(pNode) );
return 1;
}
}
@@ -1755,7 +1808,7 @@ int Abc_CommandPrintKMap( Abc_Frame_t * pAbc, int argc, char ** argv )
pNode = Abc_NtkFindNode( pNtk, argv[globalUtilOptind] );
if ( pNode == NULL )
{
- fprintf( pErr, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
+ Abc_Print( -1, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
return 1;
}
}
@@ -1764,11 +1817,11 @@ int Abc_CommandPrintKMap( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: print_kmap [-nh] <node>\n" );
- fprintf( pErr, " shows the truth table of the node\n" );
- fprintf( pErr, "\t-n : toggles real/dummy fanin names [default = %s]\n", fUseRealNames? "real": "dummy" );
- fprintf( pErr, "\t-h : print the command usage\n");
- fprintf( pErr, "\tnode : the node to consider (default = the driver of the first PO)\n");
+ Abc_Print( -2, "usage: print_kmap [-nh] <node>\n" );
+ Abc_Print( -2, "\t shows the truth table of the node\n" );
+ Abc_Print( -2, "\t-n : toggles real/dummy fanin names [default = %s]\n", fUseRealNames? "real": "dummy" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ Abc_Print( -2, "\tnode : the node to consider (default = the driver of the first PO)\n");
return 1;
}
@@ -1785,17 +1838,12 @@ usage:
***********************************************************************/
int Abc_CommandPrintGates( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
int fUseLibrary;
extern void Abc_NtkPrintGates( Abc_Ntk_t * pNtk, int fUseLibrary );
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fUseLibrary = 1;
Extra_UtilGetoptReset();
@@ -1815,12 +1863,12 @@ int Abc_CommandPrintGates( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( Abc_NtkHasAig(pNtk) )
{
- fprintf( pErr, "Printing gates does not work for AIGs and sequential AIGs.\n" );
+ Abc_Print( -1, "Printing gates does not work for AIGs and sequential AIGs.\n" );
return 1;
}
@@ -1828,10 +1876,10 @@ int Abc_CommandPrintGates( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: print_gates [-lh]\n" );
- fprintf( pErr, "\t prints statistics about gates used in the network\n" );
- fprintf( pErr, "\t-l : used library gate names (if mapped) [default = %s]\n", fUseLibrary? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: print_gates [-lh]\n" );
+ Abc_Print( -2, "\t prints statistics about gates used in the network\n" );
+ Abc_Print( -2, "\t-l : used library gate names (if mapped) [default = %s]\n", fUseLibrary? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -1848,17 +1896,12 @@ usage:
***********************************************************************/
int Abc_CommandPrintSharing( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
int fUseLibrary;
extern void Abc_NtkPrintSharing( Abc_Ntk_t * pNtk );
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fUseLibrary = 1;
Extra_UtilGetoptReset();
@@ -1878,17 +1921,17 @@ int Abc_CommandPrintSharing( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
Abc_NtkPrintSharing( pNtk );
return 0;
usage:
- fprintf( pErr, "usage: print_sharing [-h]\n" );
- fprintf( pErr, "\t prints the number of shared nodes in the TFI cones of the COs\n" );
-// fprintf( pErr, "\t-l : used library gate names (if mapped) [default = %s]\n", fUseLibrary? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: print_sharing [-h]\n" );
+ Abc_Print( -2, "\t prints the number of shared nodes in the TFI cones of the COs\n" );
+// Abc_Print( -2, "\t-l : used library gate names (if mapped) [default = %s]\n", fUseLibrary? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -1905,17 +1948,12 @@ usage:
***********************************************************************/
int Abc_CommandPrintXCut( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
int fUseLibrary;
extern int Abc_NtkCrossCut( Abc_Ntk_t * pNtk );
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fUseLibrary = 1;
Extra_UtilGetoptReset();
@@ -1935,17 +1973,17 @@ int Abc_CommandPrintXCut( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
Abc_NtkCrossCut( pNtk );
return 0;
usage:
- fprintf( pErr, "usage: print_xcut [-h]\n" );
- fprintf( pErr, "\t prints the size of the cross cut of the current network\n" );
-// fprintf( pErr, "\t-l : used library gate names (if mapped) [default = %s]\n", fUseLibrary? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: print_xcut [-h]\n" );
+ Abc_Print( -2, "\t prints the size of the cross cut of the current network\n" );
+// Abc_Print( -2, "\t-l : used library gate names (if mapped) [default = %s]\n", fUseLibrary? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -1962,31 +2000,28 @@ usage:
***********************************************************************/
int Abc_CommandPrintDsd( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
int fCofactor;
int nCofLevel;
+ int fProfile;
extern void Kit_DsdTest( unsigned * pTruth, int nVars );
extern void Kit_DsdPrintCofactors( unsigned * pTruth, int nVars, int nCofLevel, int fVerbose );
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
nCofLevel = 1;
fCofactor = 0;
+ fProfile = 0;
Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "Nch" ) ) != EOF )
+ while ( ( c = Extra_UtilGetopt( argc, argv, "Npch" ) ) != EOF )
{
switch ( c )
{
case 'N':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
goto usage;
}
nCofLevel = atoi(argv[globalUtilOptind]);
@@ -1997,6 +2032,9 @@ int Abc_CommandPrintDsd( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'c':
fCofactor ^= 1;
break;
+ case 'p':
+ fProfile ^= 1;
+ break;
case 'h':
goto usage;
default:
@@ -2006,13 +2044,13 @@ int Abc_CommandPrintDsd( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
// get the truth table of the first output
if ( !Abc_NtkIsLogic(pNtk) )
{
- fprintf( pErr, "Currently works only for logic networks.\n" );
+ Abc_Print( -1, "Currently works only for logic networks.\n" );
return 1;
}
Abc_NtkToAig( pNtk );
@@ -2023,20 +2061,22 @@ int Abc_CommandPrintDsd( Abc_Frame_t * pAbc, int argc, char ** argv )
unsigned * pTruth;
if ( !Abc_ObjIsNode(pObj) )
{
- fprintf( pErr, "The fanin of the first PO node does not have a logic function.\n" );
+ Abc_Print( -1, "The fanin of the first PO node does not have a logic function.\n" );
return 1;
}
if ( Abc_ObjFaninNum(pObj) > 16 )
{
- fprintf( pErr, "Currently works only for up to 16 inputs.\n" );
+ Abc_Print( -1, "Currently works only for up to 16 inputs.\n" );
return 1;
}
- pTruth = Hop_ManConvertAigToTruth( pNtk->pManFunc, Hop_Regular(pObj->pData), Abc_ObjFaninNum(pObj), vMemory, 0 );
- if ( Hop_IsComplement(pObj->pData) )
+ pTruth = Hop_ManConvertAigToTruth( (Hop_Man_t *)pNtk->pManFunc, Hop_Regular((Hop_Obj_t *)pObj->pData), Abc_ObjFaninNum(pObj), vMemory, 0 );
+ if ( Hop_IsComplement((Hop_Obj_t *)pObj->pData) )
Extra_TruthNot( pTruth, pTruth, Abc_ObjFaninNum(pObj) );
// Extra_PrintBinary( stdout, pTruth, 1 << Abc_ObjFaninNum(pObj) );
-// printf( "\n" );
- if ( fCofactor )
+// Abc_Print( -1, "\n" );
+ if ( fProfile )
+ Kit_TruthPrintProfile( pTruth, Abc_ObjFaninNum(pObj) );
+ else if ( fCofactor )
Kit_DsdPrintCofactors( pTruth, Abc_ObjFaninNum(pObj), nCofLevel, 1 );
else
Kit_DsdTest( pTruth, Abc_ObjFaninNum(pObj) );
@@ -2045,11 +2085,12 @@ int Abc_CommandPrintDsd( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: print_dsd [-ch] [-N num]\n" );
- fprintf( pErr, "\t print DSD formula for a single-output function with less than 16 variables\n" );
- fprintf( pErr, "\t-c : toggle recursive cofactoring [default = %s]\n", fCofactor? "yes": "no" );
- fprintf( pErr, "\t-N num : the number of levels to cofactor [default = %d]\n", nCofLevel );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: print_dsd [-pch] [-N num]\n" );
+ Abc_Print( -2, "\t print DSD formula for a single-output function with less than 16 variables\n" );
+ Abc_Print( -2, "\t-p : toggle printing profile [default = %s]\n", fProfile? "yes": "no" );
+ Abc_Print( -2, "\t-c : toggle recursive cofactoring [default = %s]\n", fCofactor? "yes": "no" );
+ Abc_Print( -2, "\t-N num : the number of levels to cofactor [default = %d]\n", nCofLevel );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -2066,17 +2107,10 @@ usage:
***********************************************************************/
int Abc_CommandPrintCone( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
int fUseLibrary;
- extern int Abc_NtkDarPrintCone( Abc_Ntk_t * pNtk );
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fUseLibrary = 1;
Extra_UtilGetoptReset();
@@ -2095,22 +2129,22 @@ int Abc_CommandPrintCone( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( Abc_NtkLatchNum(pNtk) == 0 )
{
- fprintf( pErr, "The network is combinational.\n" );
+ Abc_Print( -1, "The network is combinational.\n" );
return 1;
}
Abc_NtkDarPrintCone( pNtk );
return 0;
usage:
- fprintf( pErr, "usage: print_cone [-h]\n" );
- fprintf( pErr, "\t prints cones of influence info for each primary output\n" );
-// fprintf( pErr, "\t-l : used library gate names (if mapped) [default = %s]\n", fUseLibrary? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: print_cone [-h]\n" );
+ Abc_Print( -2, "\t prints cones of influence info for each primary output\n" );
+// Abc_Print( -2, "\t-l : used library gate names (if mapped) [default = %s]\n", fUseLibrary? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -2128,17 +2162,12 @@ usage:
***********************************************************************/
int Abc_CommandPrintMiter( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
int fUseLibrary;
extern void Abc_NtkPrintMiter( Abc_Ntk_t * pNtk );
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fUseLibrary = 1;
Extra_UtilGetoptReset();
@@ -2157,21 +2186,65 @@ int Abc_CommandPrintMiter( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "The network is should be structurally hashed.\n" );
+ Abc_Print( -1, "The network is should be structurally hashed.\n" );
return 1;
}
Abc_NtkPrintMiter( pNtk );
return 0;
usage:
- fprintf( pErr, "usage: print_miter [-h]\n" );
- fprintf( pErr, "\t prints the status of the miter\n" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: print_miter [-h]\n" );
+ Abc_Print( -2, "\t prints the status of the miter\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_CommandPrintStatus( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+ int c;
+ // set defaults
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+ {
+ switch ( c )
+ {
+ case 'h':
+ goto usage;
+ default:
+ goto usage;
+ }
+ }
+ printf( "Status = %d Frames = %d ", pAbc->Status, pAbc->nFrames );
+ if ( pAbc->pCex == NULL )
+ printf( "Cex is not defined.\n" );
+ else
+ printf( "Cex: PIs = %d Regs = %d PO = %d Frame = %d Bits = %d\n",
+ pAbc->pCex->nPis, pAbc->pCex->nRegs,
+ pAbc->pCex->iPo, pAbc->pCex->iFrame,
+ pAbc->pCex->nBits );
+ return 0;
+
+usage:
+ Abc_Print( -2, "usage: print_status [-h]\n" );
+ Abc_Print( -2, "\t prints verification status\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -2188,24 +2261,22 @@ usage:
***********************************************************************/
int Abc_CommandShow( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
int fSeq;
int fGateNames;
int fUseReverse;
+ int fFlopDep;
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);
+ extern void Abc_NtkShowFlopDependency( Abc_Ntk_t * pNtk );
// set defaults
fSeq = 0;
fGateNames = 0;
fUseReverse = 1;
+ fFlopDep = 0;
Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "rsgh" ) ) != EOF )
+ while ( ( c = Extra_UtilGetopt( argc, argv, "rsgfh" ) ) != EOF )
{
switch ( c )
{
@@ -2218,6 +2289,9 @@ int Abc_CommandShow( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'g':
fGateNames ^= 1;
break;
+ case 'f':
+ fFlopDep ^= 1;
+ break;
default:
goto usage;
}
@@ -2225,24 +2299,28 @@ int Abc_CommandShow( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
- Abc_NtkShow( pNtk, fGateNames, fSeq, fUseReverse );
+ if ( fFlopDep )
+ Abc_NtkShowFlopDependency( pNtk );
+ else
+ Abc_NtkShow( pNtk, fGateNames, fSeq, fUseReverse );
return 0;
usage:
- fprintf( pErr, "usage: show [-srgh]\n" );
- fprintf( pErr, " visualizes the network structure using DOT and GSVIEW\n" );
+ Abc_Print( -2, "usage: show [-srgfh]\n" );
+ Abc_Print( -2, " 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" );
+ Abc_Print( -2, " \"dot.exe\" and \"gsview32.exe\" should be set in the paths\n" );
+ Abc_Print( -2, " (\"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");
+ Abc_Print( -2, "\t-s : toggles visualization of sequential networks [default = %s].\n", fSeq? "yes": "no" );
+ Abc_Print( -2, "\t-r : toggles ordering nodes in reverse order [default = %s].\n", fUseReverse? "yes": "no" );
+ Abc_Print( -2, "\t-g : toggles printing gate names for mapped network [default = %s].\n", fGateNames? "yes": "no" );
+ Abc_Print( -2, "\t-f : toggles visualizing flop dependency graph [default = %s].\n", fFlopDep? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -2259,16 +2337,11 @@ usage:
***********************************************************************/
int Abc_CommandShowBdd( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
Abc_Obj_t * pNode;
int c;
extern void Abc_NodeShowBdd( Abc_Obj_t * pNode );
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
@@ -2284,19 +2357,19 @@ int Abc_CommandShowBdd( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsBddLogic(pNtk) )
{
- fprintf( pErr, "Visualizing BDDs can only be done for logic BDD networks (run \"bdd\").\n" );
+ Abc_Print( -1, "Visualizing BDDs can only be done for logic BDD networks (run \"bdd\").\n" );
return 1;
}
if ( argc > globalUtilOptind + 1 )
{
- fprintf( pErr, "Wrong number of auguments.\n" );
+ Abc_Print( -1, "Wrong number of auguments.\n" );
goto usage;
}
if ( argc == globalUtilOptind )
@@ -2304,7 +2377,7 @@ int Abc_CommandShowBdd( Abc_Frame_t * pAbc, int argc, char ** argv )
pNode = Abc_ObjFanin0( Abc_NtkPo(pNtk, 0) );
if ( !Abc_ObjIsNode(pNode) )
{
- fprintf( pErr, "The driver \"%s\" of the first PO is not an internal node.\n", Abc_ObjName(pNode) );
+ Abc_Print( -1, "The driver \"%s\" of the first PO is not an internal node.\n", Abc_ObjName(pNode) );
return 1;
}
}
@@ -2313,7 +2386,7 @@ int Abc_CommandShowBdd( Abc_Frame_t * pAbc, int argc, char ** argv )
pNode = Abc_NtkFindNode( pNtk, argv[globalUtilOptind] );
if ( pNode == NULL )
{
- fprintf( pErr, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
+ Abc_Print( -1, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
return 1;
}
}
@@ -2321,14 +2394,14 @@ int Abc_CommandShowBdd( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: show_bdd [-h] <node>\n" );
- fprintf( pErr, " visualizes the BDD of a node using DOT and GSVIEW\n" );
+ Abc_Print( -2, "usage: show_bdd [-h] <node>\n" );
+ Abc_Print( -2, " visualizes the BDD of a node 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" );
+ Abc_Print( -2, " \"dot.exe\" and \"gsview32.exe\" should be set in the paths\n" );
+ Abc_Print( -2, " (\"gsview32.exe\" may be in \"C:\\Program Files\\Ghostgum\\gsview\\\")\n" );
#endif
- fprintf( pErr, "\tnode : the node to consider [default = the driver of the first PO]\n");
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "\tnode : the node to consider [default = the driver of the first PO]\n");
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -2345,18 +2418,13 @@ usage:
***********************************************************************/
int Abc_CommandShowCut( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
Abc_Obj_t * pNode;
int c;
int nNodeSizeMax;
int nConeSizeMax;
extern void Abc_NodeShowCut( Abc_Obj_t * pNode, int nNodeSizeMax, int nConeSizeMax );
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
nNodeSizeMax = 10;
nConeSizeMax = ABC_INFINITY;
@@ -2368,7 +2436,7 @@ int Abc_CommandShowCut( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'N':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
goto usage;
}
nNodeSizeMax = atoi(argv[globalUtilOptind]);
@@ -2379,7 +2447,7 @@ int Abc_CommandShowCut( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
nConeSizeMax = atoi(argv[globalUtilOptind]);
@@ -2396,41 +2464,41 @@ int Abc_CommandShowCut( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "Visualizing cuts only works for AIGs (run \"strash\").\n" );
+ Abc_Print( -1, "Visualizing cuts only works for AIGs (run \"strash\").\n" );
return 1;
}
if ( argc != globalUtilOptind + 1 )
{
- fprintf( pErr, "Wrong number of auguments.\n" );
+ Abc_Print( -1, "Wrong number of auguments.\n" );
goto usage;
}
pNode = Abc_NtkFindNode( pNtk, argv[globalUtilOptind] );
if ( pNode == NULL )
{
- fprintf( pErr, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
+ Abc_Print( -1, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
return 1;
}
Abc_NodeShowCut( pNode, nNodeSizeMax, nConeSizeMax );
return 0;
usage:
- fprintf( pErr, "usage: show_cut [-N num] [-C num] [-h] <node>\n" );
- fprintf( pErr, " visualizes the cut of a node using DOT and GSVIEW\n" );
+ Abc_Print( -2, "usage: show_cut [-N num] [-C num] [-h] <node>\n" );
+ Abc_Print( -2, " visualizes the cut of a node 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" );
+ Abc_Print( -2, " \"dot.exe\" and \"gsview32.exe\" should be set in the paths\n" );
+ Abc_Print( -2, " (\"gsview32.exe\" may be in \"C:\\Program Files\\Ghostgum\\gsview\\\")\n" );
#endif
- fprintf( pErr, "\t-N num : the max size of the cut to be computed [default = %d]\n", nNodeSizeMax );
- fprintf( pErr, "\t-C num : the max support of the containing cone [default = %d]\n", nConeSizeMax );
- fprintf( pErr, "\tnode : the node to consider\n");
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "\t-N num : the max size of the cut to be computed [default = %d]\n", nNodeSizeMax );
+ Abc_Print( -2, "\t-C num : the max support of the containing cone [default = %d]\n", nConeSizeMax );
+ Abc_Print( -2, "\tnode : the node to consider\n");
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -2448,17 +2516,13 @@ usage:
***********************************************************************/
int Abc_CommandCollapse( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int fVerbose;
int fBddSizeMax;
int fDualRail;
int fReorder;
int c;
-
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
// set defaults
fVerbose = 1;
@@ -2473,7 +2537,7 @@ int Abc_CommandCollapse( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'B':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-B\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-B\" should be followed by an integer.\n" );
goto usage;
}
fBddSizeMax = atoi(argv[globalUtilOptind]);
@@ -2499,13 +2563,13 @@ int Abc_CommandCollapse( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsLogic(pNtk) && !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "Can only collapse a logic network or an AIG.\n" );
+ Abc_Print( -1, "Can only collapse a logic network or an AIG.\n" );
return 1;
}
@@ -2520,7 +2584,7 @@ int Abc_CommandCollapse( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Collapsing has failed.\n" );
+ Abc_Print( -1, "Collapsing has failed.\n" );
return 1;
}
// replace the current network
@@ -2528,13 +2592,13 @@ int Abc_CommandCollapse( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: collapse [-B num] [-rdvh]\n" );
- fprintf( pErr, "\t collapses the network by constructing global BDDs\n" );
- fprintf( pErr, "\t-B num : limit on live BDD nodes during collapsing [default = %d]\n", fBddSizeMax );
- fprintf( pErr, "\t-r : toggles dynamic variable reordering [default = %s]\n", fReorder? "yes": "no" );
- fprintf( pErr, "\t-d : toggles dual-rail collapsing mode [default = %s]\n", fDualRail? "yes": "no" );
- fprintf( pErr, "\t-v : print verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: collapse [-B num] [-rdvh]\n" );
+ Abc_Print( -2, "\t collapses the network by constructing global BDDs\n" );
+ Abc_Print( -2, "\t-B num : limit on live BDD nodes during collapsing [default = %d]\n", fBddSizeMax );
+ Abc_Print( -2, "\t-r : toggles dynamic variable reordering [default = %s]\n", fReorder? "yes": "no" );
+ Abc_Print( -2, "\t-d : toggles dual-rail collapsing mode [default = %s]\n", fDualRail? "yes": "no" );
+ Abc_Print( -2, "\t-v : print verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -2552,7 +2616,6 @@ usage:
***********************************************************************/
int Abc_CommandStrash( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
Abc_Obj_t * pObj;
int c;
@@ -2560,11 +2623,7 @@ int Abc_CommandStrash( Abc_Frame_t * pAbc, int argc, char ** argv )
int fRecord;
int fCleanup;
int fComplOuts;
-
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fAllNodes = 0;
fCleanup = 1;
@@ -2596,7 +2655,7 @@ int Abc_CommandStrash( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
@@ -2604,7 +2663,7 @@ int Abc_CommandStrash( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtkRes = Abc_NtkStrash( pNtk, fAllNodes, fCleanup, fRecord );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Strashing has failed.\n" );
+ Abc_Print( -1, "Strashing has failed.\n" );
return 1;
}
if ( fComplOuts )
@@ -2615,13 +2674,13 @@ int Abc_CommandStrash( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: strash [-acrih]\n" );
- fprintf( pErr, "\t transforms combinational logic into an AIG\n" );
- fprintf( pErr, "\t-a : toggles between using all nodes and DFS nodes [default = %s]\n", fAllNodes? "all": "DFS" );
- fprintf( pErr, "\t-c : toggles cleanup to remove the dagling AIG nodes [default = %s]\n", fCleanup? "all": "DFS" );
- fprintf( pErr, "\t-r : toggles using the record of AIG subgraphs [default = %s]\n", fRecord? "yes": "no" );
- fprintf( pErr, "\t-i : toggles complementing the COs of the AIG [default = %s]\n", fComplOuts? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: strash [-acrih]\n" );
+ Abc_Print( -2, "\t transforms combinational logic into an AIG\n" );
+ Abc_Print( -2, "\t-a : toggles between using all nodes and DFS nodes [default = %s]\n", fAllNodes? "all": "DFS" );
+ Abc_Print( -2, "\t-c : toggles cleanup to remove the dagling AIG nodes [default = %s]\n", fCleanup? "all": "DFS" );
+ Abc_Print( -2, "\t-r : toggles using the record of AIG subgraphs [default = %s]\n", fRecord? "yes": "no" );
+ Abc_Print( -2, "\t-i : toggles complementing the COs of the AIG [default = %s]\n", fComplOuts? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -2638,19 +2697,15 @@ usage:
***********************************************************************/
int Abc_CommandBalance( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes, * pNtkTemp;
int c;
- bool fDuplicate;
- bool fSelective;
- bool fUpdateLevel;
+ int fDuplicate;
+ int fSelective;
+ int fUpdateLevel;
int fExor;
int fVerbose;
extern Abc_Ntk_t * Abc_NtkBalanceExor( Abc_Ntk_t * pNtk, int fUpdateLevel, int fVerbose );
-
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
// set defaults
fDuplicate = 0;
@@ -2687,7 +2742,7 @@ int Abc_CommandBalance( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
// get the new network
@@ -2703,7 +2758,7 @@ int Abc_CommandBalance( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtkTemp = Abc_NtkStrash( pNtk, 0, 0, 0 );
if ( pNtkTemp == NULL )
{
- fprintf( pErr, "Strashing before balancing has failed.\n" );
+ Abc_Print( -1, "Strashing before balancing has failed.\n" );
return 1;
}
if ( fExor )
@@ -2716,7 +2771,7 @@ int Abc_CommandBalance( Abc_Frame_t * pAbc, int argc, char ** argv )
// check if balancing worked
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Balancing has failed.\n" );
+ Abc_Print( -1, "Balancing has failed.\n" );
return 1;
}
// replace the current network
@@ -2724,14 +2779,14 @@ int Abc_CommandBalance( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: balance [-ldsxvh]\n" );
- fprintf( pErr, "\t transforms the current network into a well-balanced AIG\n" );
- fprintf( pErr, "\t-l : toggle minimizing the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
- fprintf( pErr, "\t-d : toggle duplication of logic [default = %s]\n", fDuplicate? "yes": "no" );
- fprintf( pErr, "\t-s : toggle duplication on the critical paths [default = %s]\n", fSelective? "yes": "no" );
- fprintf( pErr, "\t-x : toggle balancing multi-input EXORs [default = %s]\n", fExor? "yes": "no" );
- fprintf( pErr, "\t-v : print verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: balance [-ldsxvh]\n" );
+ Abc_Print( -2, "\t transforms the current network into a well-balanced AIG\n" );
+ Abc_Print( -2, "\t-l : toggle minimizing the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
+ Abc_Print( -2, "\t-d : toggle duplication of logic [default = %s]\n", fDuplicate? "yes": "no" );
+ Abc_Print( -2, "\t-s : toggle duplication on the critical paths [default = %s]\n", fSelective? "yes": "no" );
+ Abc_Print( -2, "\t-x : toggle balancing multi-input EXORs [default = %s]\n", fExor? "yes": "no" );
+ Abc_Print( -2, "\t-v : print verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -2748,16 +2803,12 @@ usage:
***********************************************************************/
int Abc_CommandMuxStruct( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c;
int fVerbose;
extern Abc_Ntk_t * Abc_NtkMuxRestructure( Abc_Ntk_t * pNtk, int fVerbose );
-
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
// set defaults
fVerbose = 0;
@@ -2778,13 +2829,13 @@ int Abc_CommandMuxStruct( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
// get the new network
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "Does not work for a logic network.\n" );
+ Abc_Print( -1, "Does not work for a logic network.\n" );
return 1;
}
// check if balancing worked
@@ -2792,7 +2843,7 @@ int Abc_CommandMuxStruct( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtkRes = NULL;
if ( pNtkRes == NULL )
{
- fprintf( pErr, "MUX restructuring has failed.\n" );
+ Abc_Print( -1, "MUX restructuring has failed.\n" );
return 1;
}
// replace the current network
@@ -2800,10 +2851,10 @@ int Abc_CommandMuxStruct( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: mux_struct [-vh]\n" );
- fprintf( pErr, "\t performs MUX restructuring of the current network\n" );
- fprintf( pErr, "\t-v : print verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: mux_struct [-vh]\n" );
+ Abc_Print( -2, "\t performs MUX restructuring of the current network\n" );
+ Abc_Print( -2, "\t-v : print verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -2820,7 +2871,6 @@ usage:
***********************************************************************/
int Abc_CommandMulti( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int nThresh, nFaninMax, c;
int fCnf;
@@ -2830,8 +2880,6 @@ int Abc_CommandMulti( Abc_Frame_t * pAbc, int argc, char ** argv )
extern Abc_Ntk_t * Abc_NtkMulti( Abc_Ntk_t * pNtk, int nThresh, int nFaninMax, int fCnf, int fMulti, int fSimple, int fFactor );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
// set defaults
nThresh = 1;
@@ -2848,7 +2896,7 @@ int Abc_CommandMulti( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'T':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-T\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
goto usage;
}
nThresh = atoi(argv[globalUtilOptind]);
@@ -2859,7 +2907,7 @@ int Abc_CommandMulti( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
nFaninMax = atoi(argv[globalUtilOptind]);
@@ -2888,12 +2936,12 @@ int Abc_CommandMulti( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "Cannot renode a network that is not an AIG (run \"strash\").\n" );
+ Abc_Print( -1, "Cannot renode a network that is not an AIG (run \"strash\").\n" );
return 1;
}
@@ -2901,7 +2949,7 @@ int Abc_CommandMulti( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtkRes = Abc_NtkMulti( pNtk, nThresh, nFaninMax, fCnf, fMulti, fSimple, fFactor );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Renoding has failed.\n" );
+ Abc_Print( -1, "Renoding has failed.\n" );
return 1;
}
// replace the current network
@@ -2909,18 +2957,18 @@ int Abc_CommandMulti( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: multi [-T num] [-F num] [-msfch]\n" );
- fprintf( pErr, "\t transforms an AIG into a logic network by creating larger nodes\n" );
- fprintf( pErr, "\t-F num : the maximum fanin size after renoding [default = %d]\n", nFaninMax );
- fprintf( pErr, "\t-T num : the threshold for AIG node duplication [default = %d]\n", nThresh );
- fprintf( pErr, "\t (an AIG node is the root of a new node after renoding\n" );
- fprintf( pErr, "\t if this leads to duplication of no more than %d AIG nodes,\n", nThresh );
- fprintf( pErr, "\t that is, if [(numFanouts(Node)-1) * size(MFFC(Node))] <= %d)\n", nThresh );
- fprintf( pErr, "\t-m : creates multi-input AND graph [default = %s]\n", fMulti? "yes": "no" );
- fprintf( pErr, "\t-s : creates a simple AIG (no renoding) [default = %s]\n", fSimple? "yes": "no" );
- fprintf( pErr, "\t-f : creates a factor-cut network [default = %s]\n", fFactor? "yes": "no" );
- fprintf( pErr, "\t-c : performs renoding to derive the CNF [default = %s]\n", fCnf? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: multi [-T num] [-F num] [-msfch]\n" );
+ Abc_Print( -2, "\t transforms an AIG into a logic network by creating larger nodes\n" );
+ Abc_Print( -2, "\t-F num : the maximum fanin size after renoding [default = %d]\n", nFaninMax );
+ Abc_Print( -2, "\t-T num : the threshold for AIG node duplication [default = %d]\n", nThresh );
+ Abc_Print( -2, "\t (an AIG node is the root of a new node after renoding\n" );
+ Abc_Print( -2, "\t if this leads to duplication of no more than %d AIG nodes,\n", nThresh );
+ Abc_Print( -2, "\t that is, if [(numFanouts(Node)-1) * size(MFFC(Node))] <= %d)\n", nThresh );
+ Abc_Print( -2, "\t-m : creates multi-input AND graph [default = %s]\n", fMulti? "yes": "no" );
+ Abc_Print( -2, "\t-s : creates a simple AIG (no renoding) [default = %s]\n", fSimple? "yes": "no" );
+ Abc_Print( -2, "\t-f : creates a factor-cut network [default = %s]\n", fFactor? "yes": "no" );
+ Abc_Print( -2, "\t-c : performs renoding to derive the CNF [default = %s]\n", fCnf? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -2937,7 +2985,6 @@ usage:
***********************************************************************/
int Abc_CommandRenode( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int nLutSize, nCutsMax, c;
int nFlowIters, nAreaIters;
@@ -2950,8 +2997,6 @@ int Abc_CommandRenode( Abc_Frame_t * pAbc, int argc, char ** argv )
extern Abc_Ntk_t * Abc_NtkRenode( Abc_Ntk_t * pNtk, int nLutSize, int nCutsMax, int nFlowIters, int nAreaIters, int fArea, int fUseBdds, int fUseSops, int fUseCnfs, int fUseMv, int fVerbose );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
// set defaults
nLutSize = 8;
@@ -2972,7 +3017,7 @@ int Abc_CommandRenode( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'K':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
nLutSize = atoi(argv[globalUtilOptind]);
@@ -2983,7 +3028,7 @@ int Abc_CommandRenode( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
nCutsMax = atoi(argv[globalUtilOptind]);
@@ -2994,7 +3039,7 @@ int Abc_CommandRenode( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-F\" should be followed by a positive integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by a positive integer.\n" );
goto usage;
}
nFlowIters = atoi(argv[globalUtilOptind]);
@@ -3005,7 +3050,7 @@ int Abc_CommandRenode( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'A':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-A\" should be followed by a positive integer.\n" );
+ Abc_Print( -1, "Command line switch \"-A\" should be followed by a positive integer.\n" );
goto usage;
}
nAreaIters = atoi(argv[globalUtilOptind]);
@@ -3040,30 +3085,30 @@ int Abc_CommandRenode( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( fUseBdds + fUseSops + fUseCnfs + fUseMv > 1 )
{
- fprintf( pErr, "Cannot optimize two parameters at the same time.\n" );
+ Abc_Print( -1, "Cannot optimize two parameters at the same time.\n" );
return 1;
}
if ( nLutSize < 3 || nLutSize > IF_MAX_FUNC_LUTSIZE )
{
- fprintf( pErr, "Incorrect LUT size (%d).\n", nLutSize );
+ Abc_Print( -1, "Incorrect LUT size (%d).\n", nLutSize );
return 1;
}
if ( nCutsMax < 1 || nCutsMax >= (1<<12) )
{
- fprintf( pErr, "Incorrect number of cuts.\n" );
+ Abc_Print( -1, "Incorrect number of cuts.\n" );
return 1;
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "Cannot renode a network that is not an AIG (run \"strash\").\n" );
+ Abc_Print( -1, "Cannot renode a network that is not an AIG (run \"strash\").\n" );
return 1;
}
@@ -3071,7 +3116,7 @@ int Abc_CommandRenode( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtkRes = Abc_NtkRenode( pNtk, nLutSize, nCutsMax, nFlowIters, nAreaIters, fArea, fUseBdds, fUseSops, fUseCnfs, fUseMv, fVerbose );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Renoding has failed.\n" );
+ Abc_Print( -1, "Renoding has failed.\n" );
return 1;
}
// replace the current network
@@ -3079,20 +3124,20 @@ int Abc_CommandRenode( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: renode [-K num] [-C num] [-F num] [-A num] [-sbciav]\n" );
- fprintf( pErr, "\t transforms the AIG into a logic network with larger nodes\n" );
- fprintf( pErr, "\t while minimizing the number of FF literals of the node SOPs\n" );
- fprintf( pErr, "\t-K num : the max cut size for renoding (2 < num < %d) [default = %d]\n", IF_MAX_FUNC_LUTSIZE+1, nLutSize );
- fprintf( pErr, "\t-C num : the max number of cuts used at a node (0 < num < 2^12) [default = %d]\n", nCutsMax );
- fprintf( pErr, "\t-F num : the number of area flow recovery iterations (num >= 0) [default = %d]\n", nFlowIters );
- fprintf( pErr, "\t-A num : the number of exact area recovery iterations (num >= 0) [default = %d]\n", nAreaIters );
- fprintf( pErr, "\t-s : toggles minimizing SOP cubes instead of FF lits [default = %s]\n", fUseSops? "yes": "no" );
- fprintf( pErr, "\t-b : toggles minimizing BDD nodes instead of FF lits [default = %s]\n", fUseBdds? "yes": "no" );
- fprintf( pErr, "\t-c : toggles minimizing CNF clauses instead of FF lits [default = %s]\n", fUseCnfs? "yes": "no" );
- fprintf( pErr, "\t-i : toggles minimizing MV-SOP instead of FF lits [default = %s]\n", fUseMv? "yes": "no" );
- fprintf( pErr, "\t-a : toggles area-oriented mapping [default = %s]\n", fArea? "yes": "no" );
- fprintf( pErr, "\t-v : print verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: renode [-K num] [-C num] [-F num] [-A num] [-sbciav]\n" );
+ Abc_Print( -2, "\t transforms the AIG into a logic network with larger nodes\n" );
+ Abc_Print( -2, "\t while minimizing the number of FF literals of the node SOPs\n" );
+ Abc_Print( -2, "\t-K num : the max cut size for renoding (2 < num < %d) [default = %d]\n", IF_MAX_FUNC_LUTSIZE+1, nLutSize );
+ Abc_Print( -2, "\t-C num : the max number of cuts used at a node (0 < num < 2^12) [default = %d]\n", nCutsMax );
+ Abc_Print( -2, "\t-F num : the number of area flow recovery iterations (num >= 0) [default = %d]\n", nFlowIters );
+ Abc_Print( -2, "\t-A num : the number of exact area recovery iterations (num >= 0) [default = %d]\n", nAreaIters );
+ Abc_Print( -2, "\t-s : toggles minimizing SOP cubes instead of FF lits [default = %s]\n", fUseSops? "yes": "no" );
+ Abc_Print( -2, "\t-b : toggles minimizing BDD nodes instead of FF lits [default = %s]\n", fUseBdds? "yes": "no" );
+ Abc_Print( -2, "\t-c : toggles minimizing CNF clauses instead of FF lits [default = %s]\n", fUseCnfs? "yes": "no" );
+ Abc_Print( -2, "\t-i : toggles minimizing MV-SOP instead of FF lits [default = %s]\n", fUseMv? "yes": "no" );
+ Abc_Print( -2, "\t-a : toggles area-oriented mapping [default = %s]\n", fArea? "yes": "no" );
+ Abc_Print( -2, "\t-v : print verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -3109,7 +3154,6 @@ usage:
***********************************************************************/
int Abc_CommandCleanup( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c;
int fCleanupPis;
@@ -3119,8 +3163,6 @@ int Abc_CommandCleanup( Abc_Frame_t * pAbc, int argc, char ** argv )
extern Abc_Ntk_t * Abc_NtkDarCleanupAig( Abc_Ntk_t * pNtk, int fCleanupPis, int fCleanupPos, int fVerbose );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
// set defaults
fCleanupPis = 1;
@@ -3149,14 +3191,14 @@ int Abc_CommandCleanup( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( Abc_NtkIsStrash(pNtk) )
{
if ( !fCleanupPos && !fCleanupPos )
{
- printf( "Cleanup for PIs and POs is not enabled.\n" );
+ Abc_Print( -1, "Cleanup for PIs and POs is not enabled.\n" );
pNtkRes = Abc_NtkDup( pNtk );
}
else
@@ -3169,7 +3211,7 @@ int Abc_CommandCleanup( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Cleanup has failed.\n" );
+ Abc_Print( -1, "Cleanup has failed.\n" );
return 1;
}
// replace the current network
@@ -3177,13 +3219,13 @@ int Abc_CommandCleanup( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: cleanup [-iovh]\n" );
- fprintf( pErr, "\t for logic networks, removes dangling combinatinal logic\n" );
- fprintf( pErr, "\t for AIGs, removes PIs w/o fanout and POs driven by const-0\n" );
- fprintf( pErr, "\t-i : toggles removing PIs without fanout [default = %s]\n", fCleanupPis? "yes": "no" );
- fprintf( pErr, "\t-o : toggles removing POs with const-0 drivers [default = %s]\n", fCleanupPos? "yes": "no" );
- fprintf( pErr, "\t-v : print verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: cleanup [-iovh]\n" );
+ Abc_Print( -2, "\t for logic networks, removes dangling combinatinal logic\n" );
+ Abc_Print( -2, "\t for AIGs, removes PIs w/o fanout and POs driven by const-0\n" );
+ Abc_Print( -2, "\t-i : toggles removing PIs without fanout [default = %s]\n", fCleanupPis? "yes": "no" );
+ Abc_Print( -2, "\t-o : toggles removing POs with const-0 drivers [default = %s]\n", fCleanupPos? "yes": "no" );
+ Abc_Print( -2, "\t-v : print verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -3200,14 +3242,9 @@ usage:
***********************************************************************/
int Abc_CommandSweep( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
@@ -3223,12 +3260,12 @@ int Abc_CommandSweep( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsLogic(pNtk) )
{
- fprintf( pErr, "The classical (SIS-like) sweep can only be performed on a logic network.\n" );
+ Abc_Print( -1, "The classical (SIS-like) sweep can only be performed on a logic network.\n" );
return 1;
}
// modify the current network
@@ -3236,9 +3273,9 @@ int Abc_CommandSweep( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: sweep [-h]\n" );
- fprintf( pErr, "\t removes dangling nodes; propagates constant, buffers, inverters\n" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: sweep [-h]\n" );
+ Abc_Print( -2, "\t removes dangling nodes; propagates constant, buffers, inverters\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -3256,17 +3293,12 @@ usage:
***********************************************************************/
int Abc_CommandFastExtract( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- Abc_Ntk_t * pNtk;
- FILE * pOut, * pErr;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
Fxu_Data_t * p = NULL;
int c;
- extern bool Abc_NtkFastExtract( Abc_Ntk_t * pNtk, Fxu_Data_t * p );
+ extern int Abc_NtkFastExtract( Abc_Ntk_t * pNtk, Fxu_Data_t * p );
extern void Abc_NtkFxuFreeInfo( Fxu_Data_t * p );
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// allocate the structure
p = ABC_ALLOC( Fxu_Data_t, 1 );
memset( p, 0, sizeof(Fxu_Data_t) );
@@ -3287,7 +3319,7 @@ int Abc_CommandFastExtract( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'S':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-S\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
goto usage;
}
p->nSingleMax = atoi(argv[globalUtilOptind]);
@@ -3298,7 +3330,7 @@ int Abc_CommandFastExtract( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'D':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-D\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
goto usage;
}
p->nPairsMax = atoi(argv[globalUtilOptind]);
@@ -3309,7 +3341,7 @@ int Abc_CommandFastExtract( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'N':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
goto usage;
}
p->nNodesExt = atoi(argv[globalUtilOptind]);
@@ -3342,21 +3374,21 @@ int Abc_CommandFastExtract( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
Abc_NtkFxuFreeInfo( p );
return 1;
}
if ( Abc_NtkNodeNum(pNtk) == 0 )
{
- fprintf( pErr, "The network does not have internal nodes.\n" );
+ Abc_Print( -1, "The network does not have internal nodes.\n" );
Abc_NtkFxuFreeInfo( p );
return 1;
}
if ( !Abc_NtkIsLogic(pNtk) )
{
- fprintf( pErr, "Fast extract can only be applied to a logic network (run \"renode\").\n" );
+ Abc_Print( -1, "Fast extract can only be applied to a logic network (run \"renode\").\n" );
Abc_NtkFxuFreeInfo( p );
return 1;
}
@@ -3368,17 +3400,17 @@ int Abc_CommandFastExtract( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: fx [-SDN num] [-sdzcvh]\n");
- fprintf( pErr, "\t performs unate fast extract on the current network\n");
- fprintf( pErr, "\t-S num : max number of single-cube divisors to consider [default = %d]\n", p->nSingleMax );
- fprintf( pErr, "\t-D num : max number of double-cube divisors to consider [default = %d]\n", p->nPairsMax );
- fprintf( pErr, "\t-N num : the maximum number of divisors to extract [default = %d]\n", p->nNodesExt );
- fprintf( pErr, "\t-s : use only single-cube divisors [default = %s]\n", p->fOnlyS? "yes": "no" );
- fprintf( pErr, "\t-d : use only double-cube divisors [default = %s]\n", p->fOnlyD? "yes": "no" );
- fprintf( pErr, "\t-z : use zero-weight divisors [default = %s]\n", p->fUse0? "yes": "no" );
- fprintf( pErr, "\t-c : use complement in the binary case [default = %s]\n", p->fUseCompl? "yes": "no" );
- fprintf( pErr, "\t-v : print verbose information [default = %s]\n", p->fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: fx [-SDN num] [-sdzcvh]\n");
+ Abc_Print( -2, "\t performs unate fast extract on the current network\n");
+ Abc_Print( -2, "\t-S num : max number of single-cube divisors to consider [default = %d]\n", p->nSingleMax );
+ Abc_Print( -2, "\t-D num : max number of double-cube divisors to consider [default = %d]\n", p->nPairsMax );
+ Abc_Print( -2, "\t-N num : the maximum number of divisors to extract [default = %d]\n", p->nNodesExt );
+ Abc_Print( -2, "\t-s : use only single-cube divisors [default = %s]\n", p->fOnlyS? "yes": "no" );
+ Abc_Print( -2, "\t-d : use only double-cube divisors [default = %s]\n", p->fOnlyD? "yes": "no" );
+ Abc_Print( -2, "\t-z : use zero-weight divisors [default = %s]\n", p->fUse0? "yes": "no" );
+ Abc_Print( -2, "\t-c : use complement in the binary case [default = %s]\n", p->fUseCompl? "yes": "no" );
+ Abc_Print( -2, "\t-v : print verbose information [default = %s]\n", p->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
Abc_NtkFxuFreeInfo( p );
return 1;
}
@@ -3396,18 +3428,13 @@ usage:
***********************************************************************/
int Abc_CommandEliminate( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- Abc_Ntk_t * pNtk;
- FILE * pOut, * pErr;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int nMaxSize;
int fReverse;
int fVerbose;
int c;
extern int Abc_NtkEliminate( Abc_Ntk_t * pNtk, int nMaxSize, int fReverse, int fVerbose );
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set the defaults
nMaxSize = 8;
fReverse = 0;
@@ -3420,7 +3447,7 @@ int Abc_CommandEliminate( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'N':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-N\" should be followed by a positive integer.\n" );
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by a positive integer.\n" );
goto usage;
}
nMaxSize = atoi(argv[globalUtilOptind]);
@@ -3444,19 +3471,19 @@ int Abc_CommandEliminate( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( Abc_NtkNodeNum(pNtk) == 0 )
{
- fprintf( pErr, "The network does not have internal nodes.\n" );
+ Abc_Print( -1, "The network does not have internal nodes.\n" );
return 1;
}
if ( !Abc_NtkIsLogic(pNtk) )
{
- fprintf( pErr, "This command can only be applied to a logic network (run \"renode\" or \"if\").\n" );
+ Abc_Print( -1, "This command can only be applied to a logic network (run \"renode\" or \"if\").\n" );
return 1;
}
@@ -3465,12 +3492,12 @@ int Abc_CommandEliminate( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: eliminate [-N num] [-rvh]\n");
- fprintf( pErr, "\t greedily eliminates nodes by collapsing them into fanouts\n");
- fprintf( pErr, "\t-N num : the maximum support size after collapsing [default = %d]\n", nMaxSize );
- fprintf( pErr, "\t-r : use the reverse topological order [default = %s]\n", fReverse? "yes": "no" );
- fprintf( pErr, "\t-v : print verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: eliminate [-N num] [-rvh]\n");
+ Abc_Print( -2, "\t greedily eliminates nodes by collapsing them into fanouts\n");
+ Abc_Print( -2, "\t-N num : the maximum support size after collapsing [default = %d]\n", nMaxSize );
+ Abc_Print( -2, "\t-r : use the reverse topological order [default = %s]\n", fReverse? "yes": "no" );
+ Abc_Print( -2, "\t-v : print verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -3487,17 +3514,13 @@ usage:
***********************************************************************/
int Abc_CommandDisjoint( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes, * pNtkNew;
int fGlobal, fRecursive, fVerbose, fPrint, fShort, c;
- extern Abc_Ntk_t * Abc_NtkDsdGlobal( Abc_Ntk_t * pNtk, bool fVerbose, bool fPrint, bool fShort );
- extern int Abc_NtkDsdLocal( Abc_Ntk_t * pNtk, bool fVerbose, bool fRecursive );
+ extern Abc_Ntk_t * Abc_NtkDsdGlobal( Abc_Ntk_t * pNtk, int fVerbose, int fPrint, int fShort );
+ extern int Abc_NtkDsdLocal( Abc_Ntk_t * pNtk, int fVerbose, int fRecursive );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fGlobal = 1;
fRecursive = 0;
@@ -3534,13 +3557,13 @@ int Abc_CommandDisjoint( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( fGlobal )
{
-// fprintf( stdout, "Performing DSD of global functions of the network.\n" );
+// Abc_Print( -1, "Performing DSD of global functions of the network.\n" );
// get the new network
if ( !Abc_NtkIsStrash(pNtk) )
{
@@ -3554,7 +3577,7 @@ int Abc_CommandDisjoint( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Global DSD has failed.\n" );
+ Abc_Print( -1, "Global DSD has failed.\n" );
return 1;
}
// replace the current network
@@ -3564,35 +3587,35 @@ int Abc_CommandDisjoint( Abc_Frame_t * pAbc, int argc, char ** argv )
{
if ( !Abc_NtkIsBddLogic( pNtk ) )
{
- fprintf( pErr, "This command is only applicable to logic BDD networks.\n" );
+ Abc_Print( -1, "This command is only applicable to logic BDD networks.\n" );
return 1;
}
- fprintf( stdout, "Performing recursive DSD and MUX decomposition of local functions.\n" );
+ Abc_Print( -1, "Performing recursive DSD and MUX decomposition of local functions.\n" );
if ( !Abc_NtkDsdLocal( pNtk, fVerbose, fRecursive ) )
- fprintf( pErr, "Recursive DSD has failed.\n" );
+ Abc_Print( -1, "Recursive DSD has failed.\n" );
}
else
{
if ( !Abc_NtkIsBddLogic( pNtk ) )
{
- fprintf( pErr, "This command is only applicable to logic BDD networks (run \"bdd\").\n" );
+ Abc_Print( -1, "This command is only applicable to logic BDD networks (run \"bdd\").\n" );
return 1;
}
- fprintf( stdout, "Performing simple non-recursive DSD of local functions.\n" );
+ Abc_Print( -1, "Performing simple non-recursive DSD of local functions.\n" );
if ( !Abc_NtkDsdLocal( pNtk, fVerbose, fRecursive ) )
- fprintf( pErr, "Simple DSD of local functions has failed.\n" );
+ Abc_Print( -1, "Simple DSD of local functions has failed.\n" );
}
return 0;
usage:
- fprintf( pErr, "usage: dsd [-grvpsh]\n" );
- fprintf( pErr, "\t decomposes the network using disjoint-support decomposition\n" );
- fprintf( pErr, "\t-g : toggle DSD of global and local functions [default = %s]\n", fGlobal? "global": "local" );
- fprintf( pErr, "\t-r : toggle recursive DSD/MUX and simple DSD [default = %s]\n", fRecursive? "recursive DSD/MUX": "simple DSD" );
- fprintf( pErr, "\t-v : prints DSD statistics and runtime [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-p : prints DSD structure to the standard output [default = %s]\n", fPrint? "yes": "no" );
- fprintf( pErr, "\t-s : use short PI names when printing DSD structure [default = %s]\n", fShort? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: dsd [-grvpsh]\n" );
+ Abc_Print( -2, "\t decomposes the network using disjoint-support decomposition\n" );
+ Abc_Print( -2, "\t-g : toggle DSD of global and local functions [default = %s]\n", fGlobal? "global": "local" );
+ Abc_Print( -2, "\t-r : toggle recursive DSD/MUX and simple DSD [default = %s]\n", fRecursive? "recursive DSD/MUX": "simple DSD" );
+ Abc_Print( -2, "\t-v : prints DSD statistics and runtime [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-p : prints DSD structure to the standard output [default = %s]\n", fPrint? "yes": "no" );
+ Abc_Print( -2, "\t-s : use short PI names when printing DSD structure [default = %s]\n", fShort? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -3609,15 +3632,11 @@ usage:
***********************************************************************/
int Abc_CommandLutpack( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
Lpk_Par_t Pars, * pPars = &Pars;
int c;
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
memset( pPars, 0, sizeof(Lpk_Par_t) );
pPars->nLutsMax = 4; // (N) the maximum number of LUTs in the structure
@@ -3638,7 +3657,7 @@ int Abc_CommandLutpack( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'N':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
goto usage;
}
pPars->nLutsMax = atoi(argv[globalUtilOptind]);
@@ -3649,7 +3668,7 @@ int Abc_CommandLutpack( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'Q':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-Q\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-Q\" should be followed by an integer.\n" );
goto usage;
}
pPars->nLutsOver = atoi(argv[globalUtilOptind]);
@@ -3660,7 +3679,7 @@ int Abc_CommandLutpack( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'S':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-S\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
goto usage;
}
pPars->nVarsShared = atoi(argv[globalUtilOptind]);
@@ -3671,7 +3690,7 @@ int Abc_CommandLutpack( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'L':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-L\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
goto usage;
}
pPars->nGrowthLevel = atoi(argv[globalUtilOptind]);
@@ -3706,45 +3725,45 @@ int Abc_CommandLutpack( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsLogic(pNtk) )
{
- fprintf( pErr, "This command can only be applied to a logic network.\n" );
+ Abc_Print( -1, "This command can only be applied to a logic network.\n" );
return 1;
}
if ( pPars->nVarsShared < 0 || pPars->nVarsShared > 3 )
{
- fprintf( pErr, "The number of shared variables (%d) is not in the range 0 <= S <= 3.\n", pPars->nVarsShared );
+ Abc_Print( -1, "The number of shared variables (%d) is not in the range 0 <= S <= 3.\n", pPars->nVarsShared );
return 1;
}
// modify the current network
if ( !Lpk_Resynthesize( pNtk, pPars ) )
{
- fprintf( pErr, "Resynthesis has failed.\n" );
+ Abc_Print( -1, "Resynthesis has failed.\n" );
return 1;
}
return 0;
usage:
- fprintf( pErr, "usage: lutpack [-N <num>] [-Q <num>] [-S <num>] [-L <num>] [-szfovwh]\n" );
- fprintf( pErr, "\t performs \"rewriting\" for LUT network;\n" );
- fprintf( pErr, "\t determines LUT size as the max fanin count of a node;\n" );
- fprintf( pErr, "\t if the network is not LUT-mapped, packs it into 6-LUTs\n" );
- fprintf( pErr, "\t (there is another command for resynthesis after LUT mapping, \"imfs\")\n" );
- fprintf( pErr, "\t-N <num> : the max number of LUTs in the structure (2 <= num) [default = %d]\n", pPars->nLutsMax );
- fprintf( pErr, "\t-Q <num> : the max number of LUTs not in MFFC (0 <= num) [default = %d]\n", pPars->nLutsOver );
- fprintf( pErr, "\t-S <num> : the max number of LUT inputs shared (0 <= num <= 3) [default = %d]\n", pPars->nVarsShared );
- fprintf( pErr, "\t-L <num> : max level increase after resynthesis (0 <= num) [default = %d]\n", pPars->nGrowthLevel );
- fprintf( pErr, "\t-s : toggle iteration till saturation [default = %s]\n", pPars->fSatur? "yes": "no" );
- fprintf( pErr, "\t-z : toggle zero-cost replacements [default = %s]\n", pPars->fZeroCost? "yes": "no" );
- fprintf( pErr, "\t-f : toggle using only first node and first cut [default = %s]\n", pPars->fFirst? "yes": "no" );
- fprintf( pErr, "\t-o : toggle using old implementation [default = %s]\n", pPars->fOldAlgo? "yes": "no" );
- fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", pPars->fVerbose? "yes": "no" );
- fprintf( pErr, "\t-w : toggle detailed printout of decomposed functions [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: lutpack [-N <num>] [-Q <num>] [-S <num>] [-L <num>] [-szfovwh]\n" );
+ Abc_Print( -2, "\t performs \"rewriting\" for LUT network;\n" );
+ Abc_Print( -2, "\t determines LUT size as the max fanin count of a node;\n" );
+ Abc_Print( -2, "\t if the network is not LUT-mapped, packs it into 6-LUTs\n" );
+ Abc_Print( -2, "\t (there is another command for resynthesis after LUT mapping, \"imfs\")\n" );
+ Abc_Print( -2, "\t-N <num> : the max number of LUTs in the structure (2 <= num) [default = %d]\n", pPars->nLutsMax );
+ Abc_Print( -2, "\t-Q <num> : the max number of LUTs not in MFFC (0 <= num) [default = %d]\n", pPars->nLutsOver );
+ Abc_Print( -2, "\t-S <num> : the max number of LUT inputs shared (0 <= num <= 3) [default = %d]\n", pPars->nVarsShared );
+ Abc_Print( -2, "\t-L <num> : max level increase after resynthesis (0 <= num) [default = %d]\n", pPars->nGrowthLevel );
+ Abc_Print( -2, "\t-s : toggle iteration till saturation [default = %s]\n", pPars->fSatur? "yes": "no" );
+ Abc_Print( -2, "\t-z : toggle zero-cost replacements [default = %s]\n", pPars->fZeroCost? "yes": "no" );
+ Abc_Print( -2, "\t-f : toggle using only first node and first cut [default = %s]\n", pPars->fFirst? "yes": "no" );
+ Abc_Print( -2, "\t-o : toggle using old implementation [default = %s]\n", pPars->fOldAlgo? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-w : toggle detailed printout of decomposed functions [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -3761,7 +3780,6 @@ usage:
***********************************************************************/
int Abc_CommandLutmin( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c;
int nLutSize;
@@ -3769,9 +3787,6 @@ int Abc_CommandLutmin( Abc_Frame_t * pAbc, int argc, char ** argv )
extern Abc_Ntk_t * Abc_NtkLutmin( Abc_Ntk_t * pNtk, int nLutSize, int fVerbose );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
nLutSize = 4;
fVerbose = 0;
@@ -3783,7 +3798,7 @@ int Abc_CommandLutmin( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'K':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-K\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
goto usage;
}
nLutSize = atoi(argv[globalUtilOptind]);
@@ -3800,14 +3815,14 @@ int Abc_CommandLutmin( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
// modify the current network
pNtkRes = Abc_NtkLutmin( pNtk, nLutSize, fVerbose );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "The command has failed.\n" );
+ Abc_Print( -1, "The command has failed.\n" );
return 1;
}
// replace the current network
@@ -3815,13 +3830,13 @@ int Abc_CommandLutmin( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: lutmin [-K <num>] [-vh]\n" );
- fprintf( pErr, "\t perform FPGA mapping while minimizing the LUT count\n" );
- fprintf( pErr, "\t as described in the paper T. Sasao and A. Mishchenko:\n" );
- fprintf( pErr, "\t \"On the number of LUTs to implement logic functions\".\n" );
- fprintf( pErr, "\t-K <num> : the LUT size to use for the mapping (2 <= num) [default = %d]\n", nLutSize );
- fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: lutmin [-K <num>] [-vh]\n" );
+ Abc_Print( -2, "\t perform FPGA mapping while minimizing the LUT count\n" );
+ Abc_Print( -2, "\t as described in the paper T. Sasao and A. Mishchenko:\n" );
+ Abc_Print( -2, "\t \"On the number of LUTs to implement logic functions\".\n" );
+ Abc_Print( -2, "\t-K <num> : the LUT size to use for the mapping (2 <= num) [default = %d]\n", nLutSize );
+ Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -3838,18 +3853,10 @@ usage:
***********************************************************************/
int Abc_CommandImfs( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
Res_Par_t Pars, * pPars = &Pars;
int c;
-// printf( "Implementation of this command is not finished.\n" );
-// return 1;
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
pPars->nWindow = 62;
pPars->nCands = 5;
@@ -3866,7 +3873,7 @@ int Abc_CommandImfs( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'W':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-W\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
goto usage;
}
pPars->nWindow = atoi(argv[globalUtilOptind]);
@@ -3877,7 +3884,7 @@ int Abc_CommandImfs( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'S':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-S\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
goto usage;
}
pPars->nSimWords = atoi(argv[globalUtilOptind]);
@@ -3888,7 +3895,7 @@ int Abc_CommandImfs( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
pPars->nCands = atoi(argv[globalUtilOptind]);
@@ -3899,7 +3906,7 @@ int Abc_CommandImfs( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'L':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-L\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
goto usage;
}
pPars->nGrowthLevel = atoi(argv[globalUtilOptind]);
@@ -3925,35 +3932,35 @@ int Abc_CommandImfs( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsLogic(pNtk) )
{
- fprintf( pErr, "This command can only be applied to a logic network.\n" );
+ Abc_Print( -1, "This command can only be applied to a logic network.\n" );
return 1;
}
// modify the current network
if ( !Abc_NtkResynthesize( pNtk, pPars ) )
{
- fprintf( pErr, "Resynthesis has failed.\n" );
+ Abc_Print( -1, "Resynthesis has failed.\n" );
return 1;
}
return 0;
usage:
- fprintf( pErr, "usage: imfs [-W <NM>] [-L <num>] [-C <num>] [-S <num>] [-avwh]\n" );
- fprintf( pErr, "\t performs resubstitution-based resynthesis with interpolation\n" );
- fprintf( pErr, "\t (there is another command for resynthesis after LUT mapping, \"lutpack\")\n" );
- fprintf( pErr, "\t-W <NM> : fanin/fanout levels (NxM) of the window (00 <= NM <= 99) [default = %d%d]\n", pPars->nWindow/10, pPars->nWindow%10 );
- fprintf( pErr, "\t-C <num> : the max number of resub candidates (1 <= n) [default = %d]\n", pPars->nCands );
- fprintf( pErr, "\t-S <num> : the number of simulation words (1 <= n <= 256) [default = %d]\n", pPars->nSimWords );
- fprintf( pErr, "\t-L <num> : the max increase in node level after resynthesis (0 <= num) [default = %d]\n", pPars->nGrowthLevel );
- fprintf( pErr, "\t-a : toggle optimization for area only [default = %s]\n", pPars->fArea? "yes": "no" );
- fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", pPars->fVerbose? "yes": "no" );
- fprintf( pErr, "\t-w : toggle printout subgraph statistics [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: imfs [-W <NM>] [-L <num>] [-C <num>] [-S <num>] [-avwh]\n" );
+ Abc_Print( -2, "\t performs resubstitution-based resynthesis with interpolation\n" );
+ Abc_Print( -2, "\t (there is another command for resynthesis after LUT mapping, \"lutpack\")\n" );
+ Abc_Print( -2, "\t-W <NM> : fanin/fanout levels (NxM) of the window (00 <= NM <= 99) [default = %d%d]\n", pPars->nWindow/10, pPars->nWindow%10 );
+ Abc_Print( -2, "\t-C <num> : the max number of resub candidates (1 <= n) [default = %d]\n", pPars->nCands );
+ Abc_Print( -2, "\t-S <num> : the number of simulation words (1 <= n <= 256) [default = %d]\n", pPars->nSimWords );
+ Abc_Print( -2, "\t-L <num> : the max increase in node level after resynthesis (0 <= num) [default = %d]\n", pPars->nGrowthLevel );
+ Abc_Print( -2, "\t-a : toggle optimization for area only [default = %s]\n", pPars->fArea? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-w : toggle printout subgraph statistics [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -3970,18 +3977,9 @@ usage:
***********************************************************************/
int Abc_CommandMfs( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
Mfs_Par_t Pars, * pPars = &Pars;
int c;
-
-// printf( "Implementation of this command is not finished.\n" );
-// return 1;
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Abc_NtkMfsParsDefault( pPars );
Extra_UtilGetoptReset();
@@ -3992,7 +3990,7 @@ int Abc_CommandMfs( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'W':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-W\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
goto usage;
}
pPars->nWinTfoLevs = atoi(argv[globalUtilOptind]);
@@ -4003,7 +4001,7 @@ int Abc_CommandMfs( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
pPars->nFanoutsMax = atoi(argv[globalUtilOptind]);
@@ -4014,7 +4012,7 @@ int Abc_CommandMfs( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'D':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-D\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
goto usage;
}
pPars->nDepthMax = atoi(argv[globalUtilOptind]);
@@ -4025,7 +4023,7 @@ int Abc_CommandMfs( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'M':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-M\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
goto usage;
}
pPars->nWinSizeMax = atoi(argv[globalUtilOptind]);
@@ -4036,7 +4034,7 @@ int Abc_CommandMfs( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'L':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-L\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
goto usage;
}
pPars->nGrowthLevel = atoi(argv[globalUtilOptind]);
@@ -4047,7 +4045,7 @@ int Abc_CommandMfs( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
pPars->nBTLimit = atoi(argv[globalUtilOptind]);
@@ -4091,42 +4089,42 @@ int Abc_CommandMfs( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsLogic(pNtk) )
{
- fprintf( pErr, "This command can only be applied to a logic network.\n" );
+ Abc_Print( -1, "This command can only be applied to a logic network.\n" );
return 1;
}
// modify the current network
if ( !Abc_NtkMfs( pNtk, pPars ) )
{
- fprintf( pErr, "Resynthesis has failed.\n" );
+ Abc_Print( -1, "Resynthesis has failed.\n" );
return 1;
}
return 0;
usage:
- fprintf( pErr, "usage: mfs [-WFDMLC <num>] [-raestpgvh]\n" );
- fprintf( pErr, "\t performs don't-care-based optimization of logic networks\n" );
- fprintf( pErr, "\t-W <num> : the number of levels in the TFO cone (0 <= num) [default = %d]\n", pPars->nWinTfoLevs );
- fprintf( pErr, "\t-F <num> : the max number of fanouts to skip (1 <= num) [default = %d]\n", pPars->nFanoutsMax );
- fprintf( pErr, "\t-D <num> : the max depth nodes to try (0 = no limit) [default = %d]\n", pPars->nDepthMax );
- fprintf( pErr, "\t-M <num> : the max node count of windows to consider (0 = no limit) [default = %d]\n", pPars->nWinSizeMax );
- fprintf( pErr, "\t-L <num> : the max increase in node level after resynthesis (0 <= num) [default = %d]\n", pPars->nGrowthLevel );
- fprintf( pErr, "\t-C <num> : the max number of conflicts in one SAT run (0 = no limit) [default = %d]\n", pPars->nBTLimit );
- fprintf( pErr, "\t-r : toggle resubstitution and dc-minimization [default = %s]\n", pPars->fResub? "resub": "dc-min" );
- fprintf( pErr, "\t-a : toggle minimizing area or area+edges [default = %s]\n", pPars->fArea? "area": "area+edges" );
- fprintf( pErr, "\t-e : toggle high-effort resubstitution [default = %s]\n", pPars->fMoreEffort? "yes": "no" );
- fprintf( pErr, "\t-s : toggle evaluation of edge swapping [default = %s]\n", pPars->fSwapEdge? "yes": "no" );
- fprintf( pErr, "\t-t : toggle using artificial one-hotness conditions [default = %s]\n", pPars->fOneHotness? "yes": "no" );
- fprintf( pErr, "\t-p : toggle power-aware optimization [default = %s]\n", pPars->fPower? "yes": "no" );
- fprintf( pErr, "\t-g : toggle using new SAT solver [default = %s]\n", pPars->fGiaSat? "yes": "no" );
- fprintf( pErr, "\t-v : toggle printing optimization summary [default = %s]\n", pPars->fVerbose? "yes": "no" );
- fprintf( pErr, "\t-w : toggle printing detailed stats for each node [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: mfs [-WFDMLC <num>] [-raestpgvh]\n" );
+ Abc_Print( -2, "\t performs don't-care-based optimization of logic networks\n" );
+ Abc_Print( -2, "\t-W <num> : the number of levels in the TFO cone (0 <= num) [default = %d]\n", pPars->nWinTfoLevs );
+ Abc_Print( -2, "\t-F <num> : the max number of fanouts to skip (1 <= num) [default = %d]\n", pPars->nFanoutsMax );
+ Abc_Print( -2, "\t-D <num> : the max depth nodes to try (0 = no limit) [default = %d]\n", pPars->nDepthMax );
+ Abc_Print( -2, "\t-M <num> : the max node count of windows to consider (0 = no limit) [default = %d]\n", pPars->nWinSizeMax );
+ Abc_Print( -2, "\t-L <num> : the max increase in node level after resynthesis (0 <= num) [default = %d]\n", pPars->nGrowthLevel );
+ Abc_Print( -2, "\t-C <num> : the max number of conflicts in one SAT run (0 = no limit) [default = %d]\n", pPars->nBTLimit );
+ Abc_Print( -2, "\t-r : toggle resubstitution and dc-minimization [default = %s]\n", pPars->fResub? "resub": "dc-min" );
+ Abc_Print( -2, "\t-a : toggle minimizing area or area+edges [default = %s]\n", pPars->fArea? "area": "area+edges" );
+ Abc_Print( -2, "\t-e : toggle high-effort resubstitution [default = %s]\n", pPars->fMoreEffort? "yes": "no" );
+ Abc_Print( -2, "\t-s : toggle evaluation of edge swapping [default = %s]\n", pPars->fSwapEdge? "yes": "no" );
+ Abc_Print( -2, "\t-t : toggle using artificial one-hotness conditions [default = %s]\n", pPars->fOneHotness? "yes": "no" );
+ Abc_Print( -2, "\t-p : toggle power-aware optimization [default = %s]\n", pPars->fPower? "yes": "no" );
+ Abc_Print( -2, "\t-g : toggle using new SAT solver [default = %s]\n", pPars->fGiaSat? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle printing optimization summary [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-w : toggle printing detailed stats for each node [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -4144,17 +4142,12 @@ usage:
***********************************************************************/
int Abc_CommandTrace( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
int fUseLutLib;
int fVerbose;
extern void Abc_NtkDelayTracePrint( Abc_Ntk_t * pNtk, int fUseLutLib, int fVerbose );
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fUseLutLib = 0;
fVerbose = 0;
@@ -4178,12 +4171,12 @@ int Abc_CommandTrace( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsLogic(pNtk) )
{
- fprintf( pErr, "This command can only be applied to a logic network.\n" );
+ Abc_Print( -1, "This command can only be applied to a logic network.\n" );
return 1;
}
@@ -4192,11 +4185,11 @@ int Abc_CommandTrace( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: trace [-lvh]\n" );
- fprintf( pErr, "\t performs delay trace of LUT-mapped network\n" );
- fprintf( pErr, "\t-l : toggle using unit- or LUT-library-delay model [default = %s]\n", fUseLutLib? "lib": "unit" );
- fprintf( pErr, "\t-v : toggle printing optimization summary [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: trace [-lvh]\n" );
+ Abc_Print( -2, "\t performs delay trace of LUT-mapped network\n" );
+ Abc_Print( -2, "\t-l : toggle using unit- or LUT-library-delay model [default = %s]\n", fUseLutLib? "lib": "unit" );
+ Abc_Print( -2, "\t-v : toggle printing optimization summary [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -4213,7 +4206,6 @@ usage:
***********************************************************************/
int Abc_CommandSpeedup( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c;
int fUseLutLib;
@@ -4222,10 +4214,7 @@ int Abc_CommandSpeedup( Abc_Frame_t * pAbc, int argc, char ** argv )
int fVerbose;
int fVeryVerbose;
extern Abc_Ntk_t * Abc_NtkSpeedup( Abc_Ntk_t * pNtk, int fUseLutLib, int Percentage, int Degree, int fVerbose, int fVeryVerbose );
-
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
// set defaults
fUseLutLib = 0;
@@ -4241,7 +4230,7 @@ int Abc_CommandSpeedup( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'P':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-P\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
goto usage;
}
Percentage = atoi(argv[globalUtilOptind]);
@@ -4252,7 +4241,7 @@ int Abc_CommandSpeedup( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'N':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
goto usage;
}
Degree = atoi(argv[globalUtilOptind]);
@@ -4278,12 +4267,12 @@ int Abc_CommandSpeedup( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsLogic(pNtk) )
{
- fprintf( pErr, "This command can only be applied to a logic network.\n" );
+ Abc_Print( -1, "This command can only be applied to a logic network.\n" );
return 1;
}
@@ -4291,7 +4280,7 @@ int Abc_CommandSpeedup( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtkRes = Abc_NtkSpeedup( pNtk, fUseLutLib, Percentage, Degree, fVerbose, fVeryVerbose );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "The command has failed.\n" );
+ Abc_Print( -1, "The command has failed.\n" );
return 1;
}
// replace the current network
@@ -4299,15 +4288,15 @@ int Abc_CommandSpeedup( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: speedup [-P num] [-N num] [-lvwh]\n" );
- fprintf( pErr, "\t transforms LUT-mapped network into an AIG with choices;\n" );
- fprintf( pErr, "\t the choices are added to speedup the next round of mapping\n" );
- fprintf( pErr, "\t-P <num> : delay delta defining critical path for library model [default = %d%%]\n", Percentage );
- fprintf( pErr, "\t-N <num> : the max critical path degree for resynthesis (0 < num < 6) [default = %d]\n", Degree );
- fprintf( pErr, "\t-l : toggle using unit- or LUT-library-delay model [default = %s]\n", fUseLutLib? "lib" : "unit" );
- fprintf( pErr, "\t-v : toggle printing optimization summary [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-w : toggle printing detailed stats for each node [default = %s]\n", fVeryVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: speedup [-P num] [-N num] [-lvwh]\n" );
+ Abc_Print( -2, "\t transforms LUT-mapped network into an AIG with choices;\n" );
+ Abc_Print( -2, "\t the choices are added to speedup the next round of mapping\n" );
+ Abc_Print( -2, "\t-P <num> : delay delta defining critical path for library model [default = %d%%]\n", Percentage );
+ Abc_Print( -2, "\t-N <num> : the max critical path degree for resynthesis (0 < num < 6) [default = %d]\n", Degree );
+ Abc_Print( -2, "\t-l : toggle using unit- or LUT-library-delay model [default = %s]\n", fUseLutLib? "lib" : "unit" );
+ Abc_Print( -2, "\t-v : toggle printing optimization summary [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-w : toggle printing detailed stats for each node [default = %s]\n", fVeryVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -4324,7 +4313,6 @@ usage:
***********************************************************************/
int Abc_CommandPowerdown( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c;
int fUseLutLib;
@@ -4335,9 +4323,6 @@ int Abc_CommandPowerdown( Abc_Frame_t * pAbc, int argc, char ** argv )
extern Abc_Ntk_t * Abc_NtkPowerdown( Abc_Ntk_t * pNtk, int fUseLutLib, int Percentage, int Degree, int fVerbose, int fVeryVerbose );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fUseLutLib = 0;
Percentage =10;
@@ -4352,7 +4337,7 @@ int Abc_CommandPowerdown( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'P':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-P\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
goto usage;
}
Percentage = atoi(argv[globalUtilOptind]);
@@ -4363,7 +4348,7 @@ int Abc_CommandPowerdown( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'N':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
goto usage;
}
Degree = atoi(argv[globalUtilOptind]);
@@ -4389,12 +4374,12 @@ int Abc_CommandPowerdown( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsLogic(pNtk) )
{
- fprintf( pErr, "This command can only be applied to a logic network.\n" );
+ Abc_Print( -1, "This command can only be applied to a logic network.\n" );
return 1;
}
@@ -4402,7 +4387,7 @@ int Abc_CommandPowerdown( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtkRes = Abc_NtkPowerdown( pNtk, fUseLutLib, Percentage, Degree, fVerbose, fVeryVerbose );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "The command has failed.\n" );
+ Abc_Print( -1, "The command has failed.\n" );
return 1;
}
// replace the current network
@@ -4410,16 +4395,16 @@ int Abc_CommandPowerdown( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: powerdown [-P num] [-N num] [-vwh]\n" );
- fprintf( pErr, "\t transforms LUT-mapped network into an AIG with choices;\n" );
- fprintf( pErr, "\t the choices are added to power down the next round of mapping\n" );
- fprintf( pErr, "\t-P <num> : switching propability delta defining power critical edges [default = %d%%]\n", Percentage );
- fprintf( pErr, "\t (e.g. 5% means hot wires switch with probability: 0.45 <= p <= 0.50 (max)\n" );
- fprintf( pErr, "\t-N <num> : the max critical path degree for resynthesis (0 < num < 6) [default = %d]\n", Degree );
-// fprintf( pErr, "\t-l : toggle using unit- or LUT-library-delay model [default = %s]\n", fUseLutLib? "lib" : "unit" );
- fprintf( pErr, "\t-v : toggle printing optimization summary [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-w : toggle printing detailed stats for each node [default = %s]\n", fVeryVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: powerdown [-P num] [-N num] [-vwh]\n" );
+ Abc_Print( -2, "\t transforms LUT-mapped network into an AIG with choices;\n" );
+ Abc_Print( -2, "\t the choices are added to power down the next round of mapping\n" );
+ Abc_Print( -2, "\t-P <num> : switching propability delta defining power critical edges [default = %d%%]\n", Percentage );
+ Abc_Print( -2, "\t (e.g. 5% means hot wires switch with probability: 0.45 <= p <= 0.50 (max)\n" );
+ Abc_Print( -2, "\t-N <num> : the max critical path degree for resynthesis (0 < num < 6) [default = %d]\n", Degree );
+// Abc_Print( -2, "\t-l : toggle using unit- or LUT-library-delay model [default = %s]\n", fUseLutLib? "lib" : "unit" );
+ Abc_Print( -2, "\t-v : toggle printing optimization summary [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-w : toggle printing detailed stats for each node [default = %s]\n", fVeryVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -4436,13 +4421,11 @@ usage:
***********************************************************************/
int Abc_CommandMerge( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
Nwk_LMPars_t Pars, * pPars = &Pars;
Vec_Int_t * vResult;
int c;
extern Vec_Int_t * Abc_NtkLutMerge( Abc_Ntk_t * pNtk, Nwk_LMPars_t * pPars );
- pNtk = Abc_FrameReadNtk(pAbc);
-
// set defaults
memset( pPars, 0, sizeof(Nwk_LMPars_t) );
pPars->nMaxLutSize = 5; // the max LUT size for merging (N=5)
@@ -4462,7 +4445,7 @@ int Abc_CommandMerge( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'N':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-N\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
goto usage;
}
pPars->nMaxLutSize = atoi(argv[globalUtilOptind]);
@@ -4473,7 +4456,7 @@ int Abc_CommandMerge( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'S':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-S\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
goto usage;
}
pPars->nMaxSuppSize = atoi(argv[globalUtilOptind]);
@@ -4484,7 +4467,7 @@ int Abc_CommandMerge( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'D':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-D\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
goto usage;
}
pPars->nMaxDistance = atoi(argv[globalUtilOptind]);
@@ -4495,7 +4478,7 @@ int Abc_CommandMerge( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'L':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-L\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
goto usage;
}
pPars->nMaxLevelDiff = atoi(argv[globalUtilOptind]);
@@ -4506,7 +4489,7 @@ int Abc_CommandMerge( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-F\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
pPars->nMaxFanout = atoi(argv[globalUtilOptind]);
@@ -4534,7 +4517,7 @@ int Abc_CommandMerge( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL || !Abc_NtkIsLogic(pNtk) )
{
- printf( "Abc_CommandSpeedup(): There is no mapped network to merge LUTs.\n" );
+ Abc_Print( -1, "Abc_CommandMerge(): There is no mapped network to merge LUTs.\n" );
return 1;
}
@@ -4543,18 +4526,18 @@ int Abc_CommandMerge( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( stdout, "usage: merge [-NSDLF num] [-scwvh]\n" );
- fprintf( stdout, "\t creates pairs of topologically-related LUTs\n" );
- fprintf( stdout, "\t-N <num> : the max LUT size for merging (1 < num) [default = %d]\n", pPars->nMaxLutSize );
- fprintf( stdout, "\t-S <num> : the max total support size after merging (1 < num) [default = %d]\n", pPars->nMaxSuppSize );
- fprintf( stdout, "\t-D <num> : the max distance in terms of LUTs (0 < num) [default = %d]\n", pPars->nMaxDistance );
- fprintf( stdout, "\t-L <num> : the max difference in levels (0 <= num) [default = %d]\n", pPars->nMaxLevelDiff );
- fprintf( stdout, "\t-F <num> : the max number of fanouts to stop traversal (0 < num) [default = %d]\n", pPars->nMaxFanout );
- fprintf( stdout, "\t-s : toggle the use of nodes without support overlap [default = %s]\n", pPars->fUseDiffSupp? "yes" : "no" );
- fprintf( stdout, "\t-c : toggle the use of TFI/TFO nodes as candidates [default = %s]\n", pPars->fUseTfiTfo? "yes" : "no" );
- fprintf( stdout, "\t-w : toggle printing detailed stats for each node [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
- fprintf( stdout, "\t-v : toggle printing optimization summary [default = %s]\n", pPars->fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: merge [-NSDLF num] [-scwvh]\n" );
+ Abc_Print( -2, "\t creates pairs of topologically-related LUTs\n" );
+ Abc_Print( -2, "\t-N <num> : the max LUT size for merging (1 < num) [default = %d]\n", pPars->nMaxLutSize );
+ Abc_Print( -2, "\t-S <num> : the max total support size after merging (1 < num) [default = %d]\n", pPars->nMaxSuppSize );
+ Abc_Print( -2, "\t-D <num> : the max distance in terms of LUTs (0 < num) [default = %d]\n", pPars->nMaxDistance );
+ Abc_Print( -2, "\t-L <num> : the max difference in levels (0 <= num) [default = %d]\n", pPars->nMaxLevelDiff );
+ Abc_Print( -2, "\t-F <num> : the max number of fanouts to stop traversal (0 < num) [default = %d]\n", pPars->nMaxFanout );
+ Abc_Print( -2, "\t-s : toggle the use of nodes without support overlap [default = %s]\n", pPars->fUseDiffSupp? "yes" : "no" );
+ Abc_Print( -2, "\t-c : toggle the use of TFI/TFO nodes as candidates [default = %s]\n", pPars->fUseTfiTfo? "yes" : "no" );
+ Abc_Print( -2, "\t-w : toggle printing detailed stats for each node [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle printing optimization summary [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -4571,22 +4554,17 @@ usage:
***********************************************************************/
int Abc_CommandRewrite( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
- bool fUpdateLevel;
- bool fPrecompute;
- bool fUseZeros;
- bool fVerbose;
- bool fVeryVerbose;
- bool fPlaceEnable;
+ int fUpdateLevel;
+ int fPrecompute;
+ int fUseZeros;
+ int fVerbose;
+ int fVeryVerbose;
+ int fPlaceEnable;
// external functions
extern void Rwr_Precompute();
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fUpdateLevel = 1;
fPrecompute = 0;
@@ -4632,37 +4610,37 @@ int Abc_CommandRewrite( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "This command can only be applied to an AIG (run \"strash\").\n" );
+ Abc_Print( -1, "This command can only be applied to an AIG (run \"strash\").\n" );
return 1;
}
if ( Abc_NtkGetChoiceNum(pNtk) )
{
- fprintf( pErr, "AIG resynthesis cannot be applied to AIGs with choice nodes.\n" );
+ Abc_Print( -1, "AIG resynthesis cannot be applied to AIGs with choice nodes.\n" );
return 1;
}
// modify the current network
if ( !Abc_NtkRewrite( pNtk, fUpdateLevel, fUseZeros, fVerbose, fVeryVerbose, fPlaceEnable ) )
{
- fprintf( pErr, "Rewriting has failed.\n" );
+ Abc_Print( -1, "Rewriting has failed.\n" );
return 1;
}
return 0;
usage:
- fprintf( pErr, "usage: rewrite [-lzvwh]\n" );
- fprintf( pErr, "\t performs technology-independent rewriting of the AIG\n" );
- fprintf( pErr, "\t-l : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
- fprintf( pErr, "\t-z : toggle using zero-cost replacements [default = %s]\n", fUseZeros? "yes": "no" );
- fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-w : toggle printout subgraph statistics [default = %s]\n", fVeryVerbose? "yes": "no" );
-// fprintf( pErr, "\t-p : toggle placement-aware rewriting [default = %s]\n", fPlaceEnable? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: rewrite [-lzvwh]\n" );
+ Abc_Print( -2, "\t performs technology-independent rewriting of the AIG\n" );
+ Abc_Print( -2, "\t-l : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
+ Abc_Print( -2, "\t-z : toggle using zero-cost replacements [default = %s]\n", fUseZeros? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-w : toggle printout subgraph statistics [default = %s]\n", fVeryVerbose? "yes": "no" );
+// Abc_Print( -2, "\t-p : toggle placement-aware rewriting [default = %s]\n", fPlaceEnable? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -4679,20 +4657,15 @@ usage:
***********************************************************************/
int Abc_CommandRefactor( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
int nNodeSizeMax;
int nConeSizeMax;
- bool fUpdateLevel;
- bool fUseZeros;
- bool fUseDcs;
- bool fVerbose;
- extern int Abc_NtkRefactor( Abc_Ntk_t * pNtk, int nNodeSizeMax, int nConeSizeMax, bool fUpdateLevel, bool fUseZeros, bool fUseDcs, bool fVerbose );
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
+ int fUpdateLevel;
+ int fUseZeros;
+ int fUseDcs;
+ int fVerbose;
+ extern int Abc_NtkRefactor( Abc_Ntk_t * pNtk, int nNodeSizeMax, int nConeSizeMax, int fUpdateLevel, int fUseZeros, int fUseDcs, int fVerbose );
// set defaults
nNodeSizeMax = 10;
@@ -4709,7 +4682,7 @@ int Abc_CommandRefactor( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'N':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
goto usage;
}
nNodeSizeMax = atoi(argv[globalUtilOptind]);
@@ -4720,7 +4693,7 @@ int Abc_CommandRefactor( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
nConeSizeMax = atoi(argv[globalUtilOptind]);
@@ -4749,44 +4722,44 @@ int Abc_CommandRefactor( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "This command can only be applied to an AIG (run \"strash\").\n" );
+ Abc_Print( -1, "This command can only be applied to an AIG (run \"strash\").\n" );
return 1;
}
if ( Abc_NtkGetChoiceNum(pNtk) )
{
- fprintf( pErr, "AIG resynthesis cannot be applied to AIGs with choice nodes.\n" );
+ Abc_Print( -1, "AIG resynthesis cannot be applied to AIGs with choice nodes.\n" );
return 1;
}
if ( fUseDcs && nNodeSizeMax >= nConeSizeMax )
{
- fprintf( pErr, "For don't-care to work, containing cone should be larger than collapsed node.\n" );
+ Abc_Print( -1, "For don't-care to work, containing cone should be larger than collapsed node.\n" );
return 1;
}
// modify the current network
if ( !Abc_NtkRefactor( pNtk, nNodeSizeMax, nConeSizeMax, fUpdateLevel, fUseZeros, fUseDcs, fVerbose ) )
{
- fprintf( pErr, "Refactoring has failed.\n" );
+ Abc_Print( -1, "Refactoring has failed.\n" );
return 1;
}
return 0;
usage:
- fprintf( pErr, "usage: refactor [-N num] [-C num] [-lzdvh]\n" );
- fprintf( pErr, "\t performs technology-independent refactoring of the AIG\n" );
- fprintf( pErr, "\t-N num : the max support of the collapsed node [default = %d]\n", nNodeSizeMax );
- fprintf( pErr, "\t-C num : the max support of the containing cone [default = %d]\n", nConeSizeMax );
- fprintf( pErr, "\t-l : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
- fprintf( pErr, "\t-z : toggle using zero-cost replacements [default = %s]\n", fUseZeros? "yes": "no" );
- fprintf( pErr, "\t-d : toggle using don't-cares [default = %s]\n", fUseDcs? "yes": "no" );
- fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: refactor [-N num] [-C num] [-lzdvh]\n" );
+ Abc_Print( -2, "\t performs technology-independent refactoring of the AIG\n" );
+ Abc_Print( -2, "\t-N num : the max support of the collapsed node [default = %d]\n", nNodeSizeMax );
+ Abc_Print( -2, "\t-C num : the max support of the containing cone [default = %d]\n", nConeSizeMax );
+ Abc_Print( -2, "\t-l : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
+ Abc_Print( -2, "\t-z : toggle using zero-cost replacements [default = %s]\n", fUseZeros? "yes": "no" );
+ Abc_Print( -2, "\t-d : toggle using don't-cares [default = %s]\n", fUseDcs? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -4803,18 +4776,13 @@ usage:
***********************************************************************/
int Abc_CommandRestructure( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
int nCutsMax;
- bool fUpdateLevel;
- bool fUseZeros;
- bool fVerbose;
- extern int Abc_NtkRestructure( Abc_Ntk_t * pNtk, int nCutsMax, bool fUpdateLevel, bool fUseZeros, bool fVerbose );
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
+ int fUpdateLevel;
+ int fUseZeros;
+ int fVerbose;
+ extern int Abc_NtkRestructure( Abc_Ntk_t * pNtk, int nCutsMax, int fUpdateLevel, int fUseZeros, int fVerbose );
// set defaults
nCutsMax = 5;
@@ -4829,7 +4797,7 @@ int Abc_CommandRestructure( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'K':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-K\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
goto usage;
}
nCutsMax = atoi(argv[globalUtilOptind]);
@@ -4855,41 +4823,41 @@ int Abc_CommandRestructure( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( nCutsMax < 4 || nCutsMax > CUT_SIZE_MAX )
{
- fprintf( pErr, "Can only compute the cuts for %d <= K <= %d.\n", 4, CUT_SIZE_MAX );
+ Abc_Print( -1, "Can only compute the cuts for %d <= K <= %d.\n", 4, CUT_SIZE_MAX );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "This command can only be applied to an AIG (run \"strash\").\n" );
+ Abc_Print( -1, "This command can only be applied to an AIG (run \"strash\").\n" );
return 1;
}
if ( Abc_NtkGetChoiceNum(pNtk) )
{
- fprintf( pErr, "AIG resynthesis cannot be applied to AIGs with choice nodes.\n" );
+ Abc_Print( -1, "AIG resynthesis cannot be applied to AIGs with choice nodes.\n" );
return 1;
}
// modify the current network
if ( !Abc_NtkRestructure( pNtk, nCutsMax, fUpdateLevel, fUseZeros, fVerbose ) )
{
- fprintf( pErr, "Refactoring has failed.\n" );
+ Abc_Print( -1, "Refactoring has failed.\n" );
return 1;
}
return 0;
usage:
- fprintf( pErr, "usage: restructure [-K num] [-lzvh]\n" );
- fprintf( pErr, "\t performs technology-independent restructuring of the AIG\n" );
- fprintf( pErr, "\t-K num : the max cut size (%d <= num <= %d) [default = %d]\n", CUT_SIZE_MIN, CUT_SIZE_MAX, nCutsMax );
- fprintf( pErr, "\t-l : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
- fprintf( pErr, "\t-z : toggle using zero-cost replacements [default = %s]\n", fUseZeros? "yes": "no" );
- fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: restructure [-K num] [-lzvh]\n" );
+ Abc_Print( -2, "\t performs technology-independent restructuring of the AIG\n" );
+ Abc_Print( -2, "\t-K num : the max cut size (%d <= num <= %d) [default = %d]\n", CUT_SIZE_MIN, CUT_SIZE_MAX, nCutsMax );
+ Abc_Print( -2, "\t-l : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
+ Abc_Print( -2, "\t-z : toggle using zero-cost replacements [default = %s]\n", fUseZeros? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -4906,23 +4874,18 @@ usage:
***********************************************************************/
int Abc_CommandResubstitute( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int RS_CUT_MIN = 4;
int RS_CUT_MAX = 16;
int c;
int nCutsMax;
int nNodesMax;
int nLevelsOdc;
- bool fUpdateLevel;
- bool fUseZeros;
- bool fVerbose;
- bool fVeryVerbose;
- extern int Abc_NtkResubstitute( Abc_Ntk_t * pNtk, int nCutsMax, int nNodesMax, int nLevelsOdc, bool fUpdateLevel, bool fVerbose, bool fVeryVerbose );
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
+ int fUpdateLevel;
+ int fUseZeros;
+ int fVerbose;
+ int fVeryVerbose;
+ extern int Abc_NtkResubstitute( Abc_Ntk_t * pNtk, int nCutsMax, int nNodesMax, int nLevelsOdc, int fUpdateLevel, int fVerbose, int fVeryVerbose );
// set defaults
nCutsMax = 8;
@@ -4940,7 +4903,7 @@ int Abc_CommandResubstitute( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'K':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-K\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
goto usage;
}
nCutsMax = atoi(argv[globalUtilOptind]);
@@ -4951,7 +4914,7 @@ int Abc_CommandResubstitute( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'N':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
goto usage;
}
nNodesMax = atoi(argv[globalUtilOptind]);
@@ -4962,7 +4925,7 @@ int Abc_CommandResubstitute( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
nLevelsOdc = atoi(argv[globalUtilOptind]);
@@ -4991,49 +4954,49 @@ int Abc_CommandResubstitute( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( nCutsMax < RS_CUT_MIN || nCutsMax > RS_CUT_MAX )
{
- fprintf( pErr, "Can only compute cuts for %d <= K <= %d.\n", RS_CUT_MIN, RS_CUT_MAX );
+ Abc_Print( -1, "Can only compute cuts for %d <= K <= %d.\n", RS_CUT_MIN, RS_CUT_MAX );
return 1;
}
if ( nNodesMax < 0 || nNodesMax > 3 )
{
- fprintf( pErr, "Can only resubstitute at most 3 nodes.\n" );
+ Abc_Print( -1, "Can only resubstitute at most 3 nodes.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "This command can only be applied to an AIG (run \"strash\").\n" );
+ Abc_Print( -1, "This command can only be applied to an AIG (run \"strash\").\n" );
return 1;
}
if ( Abc_NtkGetChoiceNum(pNtk) )
{
- fprintf( pErr, "AIG resynthesis cannot be applied to AIGs with choice nodes.\n" );
+ Abc_Print( -1, "AIG resynthesis cannot be applied to AIGs with choice nodes.\n" );
return 1;
}
// modify the current network
if ( !Abc_NtkResubstitute( pNtk, nCutsMax, nNodesMax, nLevelsOdc, fUpdateLevel, fVerbose, fVeryVerbose ) )
{
- fprintf( pErr, "Refactoring has failed.\n" );
+ Abc_Print( -1, "Refactoring has failed.\n" );
return 1;
}
return 0;
usage:
- fprintf( pErr, "usage: resub [-K num] [-N num] [-F num] [-lzvwh]\n" );
- fprintf( pErr, "\t performs technology-independent restructuring of the AIG\n" );
- fprintf( pErr, "\t-K num : the max cut size (%d <= num <= %d) [default = %d]\n", RS_CUT_MIN, RS_CUT_MAX, nCutsMax );
- fprintf( pErr, "\t-N num : the max number of nodes to add (0 <= num <= 3) [default = %d]\n", nNodesMax );
- fprintf( pErr, "\t-F num : the number of fanout levels for ODC computation [default = %d]\n", nLevelsOdc );
- fprintf( pErr, "\t-l : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
- fprintf( pErr, "\t-z : toggle using zero-cost replacements [default = %s]\n", fUseZeros? "yes": "no" );
- fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-w : toggle verbose printout of ODC computation [default = %s]\n", fVeryVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: resub [-K num] [-N num] [-F num] [-lzvwh]\n" );
+ Abc_Print( -2, "\t performs technology-independent restructuring of the AIG\n" );
+ Abc_Print( -2, "\t-K num : the max cut size (%d <= num <= %d) [default = %d]\n", RS_CUT_MIN, RS_CUT_MAX, nCutsMax );
+ Abc_Print( -2, "\t-N num : the max number of nodes to add (0 <= num <= 3) [default = %d]\n", nNodesMax );
+ Abc_Print( -2, "\t-F num : the number of fanout levels for ODC computation [default = %d]\n", nLevelsOdc );
+ Abc_Print( -2, "\t-l : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
+ Abc_Print( -2, "\t-z : toggle using zero-cost replacements [default = %s]\n", fUseZeros? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-w : toggle verbose printout of ODC computation [default = %s]\n", fVeryVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -5050,8 +5013,7 @@ usage:
***********************************************************************/
int Abc_CommandRr( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c, Window;
int nFaninLevels;
int nFanoutLevels;
@@ -5059,10 +5021,6 @@ int Abc_CommandRr( Abc_Frame_t * pAbc, int argc, char ** argv )
int fVerbose;
extern int Abc_NtkRR( Abc_Ntk_t * pNtk, int nFaninLevels, int nFanoutLevels, int fUseFanouts, int fVerbose );
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
nFaninLevels = 3;
nFanoutLevels = 3;
@@ -5076,7 +5034,7 @@ int Abc_CommandRr( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'W':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-W\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
goto usage;
}
Window = atoi(argv[globalUtilOptind]);
@@ -5101,35 +5059,35 @@ int Abc_CommandRr( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "This command can only be applied to an AIG (run \"strash\").\n" );
+ Abc_Print( -1, "This command can only be applied to an AIG (run \"strash\").\n" );
return 1;
}
if ( Abc_NtkGetChoiceNum(pNtk) )
{
- fprintf( pErr, "AIG resynthesis cannot be applied to AIGs with choice nodes.\n" );
+ Abc_Print( -1, "AIG resynthesis cannot be applied to AIGs with choice nodes.\n" );
return 1;
}
// modify the current network
if ( !Abc_NtkRR( pNtk, nFaninLevels, nFanoutLevels, fUseFanouts, fVerbose ) )
{
- fprintf( pErr, "Redundancy removal has failed.\n" );
+ Abc_Print( -1, "Redundancy removal has failed.\n" );
return 1;
}
return 0;
usage:
- fprintf( pErr, "usage: rr [-W NM] [-fvh]\n" );
- fprintf( pErr, "\t removes combinational redundancies in the current network\n" );
- fprintf( pErr, "\t-W NM : window size: TFI (N) and TFO (M) logic levels [default = %d%d]\n", nFaninLevels, nFanoutLevels );
- fprintf( pErr, "\t-f : toggle RR w.r.t. fanouts [default = %s]\n", fUseFanouts? "yes": "no" );
- fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: rr [-W NM] [-fvh]\n" );
+ Abc_Print( -2, "\t removes combinational redundancies in the current network\n" );
+ Abc_Print( -2, "\t-W NM : window size: TFI (N) and TFO (M) logic levels [default = %d%d]\n", nFaninLevels, nFanoutLevels );
+ Abc_Print( -2, "\t-f : toggle RR w.r.t. fanouts [default = %s]\n", fUseFanouts? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -5146,16 +5104,12 @@ usage:
***********************************************************************/
int Abc_CommandCascade( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c, nLutSize;
int fCheck;
int fVerbose;
extern Abc_Ntk_t * Abc_NtkCascade( Abc_Ntk_t * pNtk, int nLutSize, int fCheck, int fVerbose );
-
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
// set defaults
nLutSize = 12;
@@ -5169,7 +5123,7 @@ int Abc_CommandCascade( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'K':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-K\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
goto usage;
}
nLutSize = atoi(argv[globalUtilOptind]);
@@ -5192,13 +5146,13 @@ int Abc_CommandCascade( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsLogic(pNtk) && !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "Can only collapse a logic network or an AIG.\n" );
+ Abc_Print( -1, "Can only collapse a logic network or an AIG.\n" );
return 1;
}
@@ -5213,7 +5167,7 @@ int Abc_CommandCascade( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Cascade synthesis has failed.\n" );
+ Abc_Print( -1, "Cascade synthesis has failed.\n" );
return 1;
}
// replace the current network
@@ -5221,18 +5175,18 @@ int Abc_CommandCascade( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: cascade [-K <num>] [-cvh]\n" );
- fprintf( pErr, "\t performs LUT cascade synthesis for the current network\n" );
- fprintf( pErr, "\t-K num : the number of LUT inputs [default = %d]\n", nLutSize );
- fprintf( pErr, "\t-c : check equivalence after synthesis [default = %s]\n", fCheck? "yes": "no" );
- fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
- fprintf( pErr, "\t \n");
- fprintf( pErr, " A lookup-table cascade is a programmable architecture developed by\n");
- fprintf( pErr, " Professor Tsutomu Sasao (sasao@cse.kyutech.ac.jp) at Kyushu Institute\n");
- fprintf( pErr, " of Technology. This work received Takeda Techno-Entrepreneurship Award:\n");
- fprintf( pErr, " http://www.lsi-cad.com/sasao/photo/takeda.html\n");
- fprintf( pErr, "\t \n");
+ Abc_Print( -2, "usage: cascade [-K <num>] [-cvh]\n" );
+ Abc_Print( -2, "\t performs LUT cascade synthesis for the current network\n" );
+ Abc_Print( -2, "\t-K num : the number of LUT inputs [default = %d]\n", nLutSize );
+ Abc_Print( -2, "\t-c : check equivalence after synthesis [default = %s]\n", fCheck? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ Abc_Print( -2, "\t \n");
+ Abc_Print( -2, " A lookup-table cascade is a programmable architecture developed by\n");
+ Abc_Print( -2, " Professor Tsutomu Sasao (sasao@cse.kyutech.ac.jp) at Kyushu Institute\n");
+ Abc_Print( -2, " of Technology. This work received Takeda Techno-Entrepreneurship Award:\n");
+ Abc_Print( -2, " http://www.lsi-cad.com/sasao/photo/takeda.html\n");
+ Abc_Print( -2, "\t \n");
return 1;
}
@@ -5250,14 +5204,10 @@ usage:
***********************************************************************/
int Abc_CommandLogic( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c;
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
@@ -5273,13 +5223,13 @@ int Abc_CommandLogic( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash( pNtk ) )
{
- fprintf( pErr, "This command is only applicable to strashed networks.\n" );
+ Abc_Print( -1, "This command is only applicable to strashed networks.\n" );
return 1;
}
@@ -5287,7 +5237,7 @@ int Abc_CommandLogic( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtkRes = Abc_NtkToLogic( pNtk );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Converting to a logic network has failed.\n" );
+ Abc_Print( -1, "Converting to a logic network has failed.\n" );
return 1;
}
// replace the current network
@@ -5295,9 +5245,9 @@ int Abc_CommandLogic( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: logic [-h]\n" );
- fprintf( pErr, "\t transforms an AIG into a logic network with SOPs\n" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: logic [-h]\n" );
+ Abc_Print( -2, "\t transforms an AIG into a logic network with SOPs\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -5314,7 +5264,6 @@ usage:
***********************************************************************/
int Abc_CommandComb( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c;
int fRemoveLatches;
@@ -5322,9 +5271,6 @@ int Abc_CommandComb( Abc_Frame_t * pAbc, int argc, char ** argv )
extern void Abc_NtkMakeSeq( Abc_Ntk_t * pNtk, int nLatchesToAdd );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fRemoveLatches = 0;
nLatchesToAdd = 0;
@@ -5336,7 +5282,7 @@ int Abc_CommandComb( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'L':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-L\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
goto usage;
}
nLatchesToAdd = atoi(argv[globalUtilOptind]);
@@ -5356,17 +5302,17 @@ int Abc_CommandComb( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( Abc_NtkIsComb(pNtk) && nLatchesToAdd == 0 )
{
- fprintf( pErr, "The network is already combinational.\n" );
+ Abc_Print( -1, "The network is already combinational.\n" );
return 0;
}
if ( !Abc_NtkIsComb(pNtk) && nLatchesToAdd != 0 )
{
- fprintf( pErr, "The network is already combinational.\n" );
+ Abc_Print( -1, "The network is already combinational.\n" );
return 0;
}
@@ -5381,11 +5327,11 @@ int Abc_CommandComb( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: comb [-L num] [-lh]\n" );
- fprintf( pErr, "\t converts comb network into seq, and vice versa\n" );
- fprintf( pErr, "\t-L : number of latches to add to comb network (0 = do not add) [default = %d]\n", nLatchesToAdd );
- fprintf( pErr, "\t-l : toggle converting latches to PIs/POs or removing them [default = %s]\n", fRemoveLatches? "remove": "convert" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: comb [-L num] [-lh]\n" );
+ Abc_Print( -2, "\t converts comb network into seq, and vice versa\n" );
+ Abc_Print( -2, "\t-L : number of latches to add to comb network (0 = do not add) [default = %d]\n", nLatchesToAdd );
+ Abc_Print( -2, "\t-l : toggle converting latches to PIs/POs or removing them [default = %s]\n", fRemoveLatches? "remove": "convert" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -5403,7 +5349,6 @@ usage:
int Abc_CommandMiter( Abc_Frame_t * pAbc, int argc, char ** argv )
{
char Buffer[32];
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtk1, * pNtk2, * pNtkRes;
int fDelete1, fDelete2;
char ** pArgvNew;
@@ -5416,8 +5361,6 @@ int Abc_CommandMiter( Abc_Frame_t * pAbc, int argc, char ** argv )
int nPartSize;
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
// set defaults
fComb = 1;
@@ -5433,7 +5376,7 @@ int Abc_CommandMiter( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'P':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-P\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
goto usage;
}
nPartSize = atoi(argv[globalUtilOptind]);
@@ -5457,7 +5400,7 @@ int Abc_CommandMiter( Abc_Frame_t * pAbc, int argc, char ** argv )
pArgvNew = argv + globalUtilOptind;
nArgcNew = argc - globalUtilOptind;
- if ( !Abc_NtkPrepareTwoNtks( pErr, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
+ if ( !Abc_NtkPrepareTwoNtks( stdout, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
return 1;
// compute the miter
pNtkRes = Abc_NtkMiter( pNtk1, pNtk2, fComb, nPartSize, fImplic, fMulti );
@@ -5467,7 +5410,7 @@ int Abc_CommandMiter( Abc_Frame_t * pAbc, int argc, char ** argv )
// get the new network
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Miter computation has failed.\n" );
+ Abc_Print( -1, "Miter computation has failed.\n" );
return 0;
}
// replace the current network
@@ -5479,17 +5422,17 @@ usage:
strcpy( Buffer, "unused" );
else
sprintf( Buffer, "%d", nPartSize );
- fprintf( pErr, "usage: miter [-P num] [-cimh] <file1> <file2>\n" );
- fprintf( pErr, "\t computes the miter of the two circuits\n" );
- fprintf( pErr, "\t-P num : output partition size [default = %s]\n", Buffer );
- fprintf( pErr, "\t-c : toggles deriving combinational miter (latches as POs) [default = %s]\n", fComb? "yes": "no" );
- fprintf( pErr, "\t-i : toggles deriving implication miter (file1 => file2) [default = %s]\n", fImplic? "yes": "no" );
- fprintf( pErr, "\t-m : toggles creating multi-output miter [default = %s]\n", fMulti? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
- fprintf( pErr, "\tfile1 : (optional) the file with the first network\n");
- fprintf( pErr, "\tfile2 : (optional) the file with the second network\n");
- fprintf( pErr, "\t if no files are given, uses the current network and its spec\n");
- fprintf( pErr, "\t if one file is given, uses the current network and the file\n");
+ Abc_Print( -2, "usage: miter [-P num] [-cimh] <file1> <file2>\n" );
+ Abc_Print( -2, "\t computes the miter of the two circuits\n" );
+ Abc_Print( -2, "\t-P num : output partition size [default = %s]\n", Buffer );
+ Abc_Print( -2, "\t-c : toggles deriving combinational miter (latches as POs) [default = %s]\n", fComb? "yes": "no" );
+ Abc_Print( -2, "\t-i : toggles deriving implication miter (file1 => file2) [default = %s]\n", fImplic? "yes": "no" );
+ Abc_Print( -2, "\t-m : toggles creating multi-output miter [default = %s]\n", fMulti? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ Abc_Print( -2, "\tfile1 : (optional) the file with the first network\n");
+ Abc_Print( -2, "\tfile2 : (optional) the file with the second network\n");
+ Abc_Print( -2, "\t if no files are given, uses the current network and its spec\n");
+ Abc_Print( -2, "\t if one file is given, uses the current network and the file\n");
return 1;
}
@@ -5506,17 +5449,12 @@ usage:
***********************************************************************/
int Abc_CommandDemiter( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;//, * pNtkRes;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);//, * pNtkRes;
int fSeq;
int c;
extern int Abc_NtkDemiter( Abc_Ntk_t * pNtk );
extern int Abc_NtkDarDemiter( Abc_Ntk_t * pNtk );
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fSeq = 1;
Extra_UtilGetoptReset();
@@ -5534,7 +5472,7 @@ int Abc_CommandDemiter( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "The network is not strashed.\n" );
+ Abc_Print( -1, "The network is not strashed.\n" );
return 1;
}
@@ -5543,7 +5481,7 @@ int Abc_CommandDemiter( Abc_Frame_t * pAbc, int argc, char ** argv )
{
if ( !Abc_NtkDarDemiter( pNtk ) )
{
- fprintf( pErr, "Demitering has failed.\n" );
+ Abc_Print( -1, "Demitering has failed.\n" );
return 1;
}
}
@@ -5551,17 +5489,17 @@ int Abc_CommandDemiter( Abc_Frame_t * pAbc, int argc, char ** argv )
{
if ( Abc_NtkPoNum(pNtk) != 1 )
{
- fprintf( pErr, "The network is not a single-output miter.\n" );
+ Abc_Print( -1, "The network is not a single-output miter.\n" );
return 1;
}
if ( !Abc_NodeIsExorType(Abc_ObjFanin0(Abc_NtkPo(pNtk,0))) )
{
- fprintf( pErr, "The miter's PO is not an EXOR.\n" );
+ Abc_Print( -1, "The miter's PO is not an EXOR.\n" );
return 1;
}
if ( !Abc_NtkDemiter( pNtk ) )
{
- fprintf( pErr, "Demitering has failed.\n" );
+ Abc_Print( -1, "Demitering has failed.\n" );
return 1;
}
}
@@ -5570,10 +5508,10 @@ int Abc_CommandDemiter( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: demiter [-sh]\n" );
- fprintf( pErr, "\t removes topmost EXOR from the miter to create two POs\n" );
- fprintf( pErr, "\t-s : applied multi-output algorithm [default = %s]\n", fSeq? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: demiter [-sh]\n" );
+ Abc_Print( -2, "\t removes topmost EXOR from the miter to create two POs\n" );
+ Abc_Print( -2, "\t-s : applied multi-output algorithm [default = %s]\n", fSeq? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -5590,16 +5528,11 @@ usage:
***********************************************************************/
int Abc_CommandOrPos( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;//, * pNtkRes;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);//, * pNtkRes;
int fComb;
int c;
extern int Abc_NtkCombinePos( Abc_Ntk_t * pNtk, int fAnd );
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF )
@@ -5616,27 +5549,27 @@ int Abc_CommandOrPos( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "The network is not strashed.\n" );
+ Abc_Print( -1, "The network is not strashed.\n" );
return 1;
}
/*
if ( Abc_NtkPoNum(pNtk) == 1 )
{
- fprintf( pErr, "The network already has one PO.\n" );
+ Abc_Print( -1, "The network already has one PO.\n" );
return 1;
}
*/
/*
if ( Abc_NtkLatchNum(pNtk) )
{
- fprintf( pErr, "The miter has latches. ORing is not performed.\n" );
+ Abc_Print( -1, "The miter has latches. ORing is not performed.\n" );
return 1;
}
*/
// get the new network
if ( !Abc_NtkCombinePos( pNtk, 0 ) )
{
- fprintf( pErr, "ORing the POs has failed.\n" );
+ Abc_Print( -1, "ORing the POs has failed.\n" );
return 1;
}
// replace the current network
@@ -5644,10 +5577,10 @@ int Abc_CommandOrPos( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: orpos [-h]\n" );
- fprintf( pErr, "\t creates single-output miter by ORing the POs of the current network\n" );
-// fprintf( pErr, "\t-c : computes combinational miter (latches as POs) [default = %s]\n", fComb? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: orpos [-h]\n" );
+ Abc_Print( -2, "\t creates single-output miter by ORing the POs of the current network\n" );
+// Abc_Print( -2, "\t-c : computes combinational miter (latches as POs) [default = %s]\n", fComb? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -5664,15 +5597,9 @@ usage:
***********************************************************************/
int Abc_CommandAndPos( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;//, * pNtkRes;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);//, * pNtkRes;
int fComb;
int c;
- extern int Abc_NtkCombinePos( Abc_Ntk_t * pNtk, int fAnd );
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
// set defaults
Extra_UtilGetoptReset();
@@ -5690,26 +5617,26 @@ int Abc_CommandAndPos( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "The network is not strashed.\n" );
+ Abc_Print( -1, "The network is not strashed.\n" );
return 1;
}
if ( Abc_NtkPoNum(pNtk) == 1 )
{
- fprintf( pErr, "The network already has one PO.\n" );
+ Abc_Print( -1, "The network already has one PO.\n" );
return 1;
}
if ( Abc_NtkLatchNum(pNtk) )
{
- fprintf( pErr, "The miter has latches. ORing is not performed.\n" );
+ Abc_Print( -1, "The miter has latches. ORing is not performed.\n" );
return 1;
}
// get the new network
if ( !Abc_NtkCombinePos( pNtk, 1 ) )
{
- fprintf( pErr, "ANDing the POs has failed.\n" );
+ Abc_Print( -1, "ANDing the POs has failed.\n" );
return 1;
}
// replace the current network
@@ -5717,10 +5644,79 @@ int Abc_CommandAndPos( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: andpos [-h]\n" );
- fprintf( pErr, "\t creates single-output miter by ANDing the POs of the current network\n" );
-// fprintf( pErr, "\t-c : computes combinational miter (latches as POs) [default = %s]\n", fComb? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: andpos [-h]\n" );
+ Abc_Print( -2, "\t creates single-output miter by ANDing the POs of the current network\n" );
+// Abc_Print( -2, "\t-c : computes combinational miter (latches as POs) [default = %s]\n", fComb? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_CommandZeroPo( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc), * pNtkRes;
+ int c, iOutput = -1;
+ extern void Abc_NtkDropOneOutput( Abc_Ntk_t * pNtk, int iOutput );
+
+ // set defaults
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "Nh" ) ) != EOF )
+ {
+ switch ( c )
+ {
+ case 'N':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ iOutput = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( iOutput < 0 )
+ goto usage;
+ break;
+ default:
+ goto usage;
+ }
+ }
+
+ if ( !Abc_NtkIsStrash(pNtk) )
+ {
+ Abc_Print( -1, "The network is not strashed.\n" );
+ return 1;
+ }
+ if ( iOutput < 0 )
+ {
+ Abc_Print( -1, "The output index is not specified.\n" );
+ return 1;
+ }
+ if ( iOutput >= Abc_NtkPoNum(pNtk) )
+ {
+ Abc_Print( -1, "The output index is larger than the allowed POs.\n" );
+ return 1;
+ }
+
+ // get the new network
+ pNtkRes = Abc_NtkDup( pNtk );
+ Abc_NtkDropOneOutput( pNtkRes, iOutput );
+ Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+ return 0;
+
+usage:
+ Abc_Print( -2, "usage: zeropo [-N num] [-h]\n" );
+ Abc_Print( -2, "\t replaces the PO driver by constant 0\n" );
+ Abc_Print( -2, "\t-F num : the zero-based index of the PO to replace [default = %d]\n", iOutput );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -5737,15 +5733,11 @@ usage:
***********************************************************************/
int Abc_CommandAppend( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtk2;
char * FileName;
int fComb;
int c;
-
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
// set defaults
Extra_UtilGetoptReset();
@@ -5764,13 +5756,13 @@ int Abc_CommandAppend( Abc_Frame_t * pAbc, int argc, char ** argv )
// get the second network
if ( argc != globalUtilOptind + 1 )
{
- fprintf( pErr, "The network to append is not given.\n" );
+ Abc_Print( -1, "The network to append is not given.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "The base network should be strashed for the appending to work.\n" );
+ Abc_Print( -1, "The base network should be strashed for the appending to work.\n" );
return 1;
}
@@ -5783,7 +5775,7 @@ int Abc_CommandAppend( Abc_Frame_t * pAbc, int argc, char ** argv )
// check if the second network is combinational
if ( Abc_NtkLatchNum(pNtk2) )
{
- fprintf( pErr, "The second network has latches. Appending does not work for such networks.\n" );
+ Abc_Print( -1, "The second network has latches. Appending does not work for such networks.\n" );
return 0;
}
@@ -5791,22 +5783,22 @@ int Abc_CommandAppend( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( !Abc_NtkAppend( pNtk, pNtk2, 1 ) )
{
Abc_NtkDelete( pNtk2 );
- fprintf( pErr, "Appending the networks failed.\n" );
+ Abc_Print( -1, "Appending the networks failed.\n" );
return 1;
}
Abc_NtkDelete( pNtk2 );
// sweep dangling logic
- Abc_AigCleanup( pNtk->pManFunc );
+ Abc_AigCleanup( (Abc_Aig_t *)pNtk->pManFunc );
// replace the current network
// Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
return 0;
usage:
- fprintf( pErr, "usage: append [-h] <file>\n" );
- fprintf( pErr, "\t appends a combinational network on top of the current network\n" );
-// fprintf( pErr, "\t-c : computes combinational miter (latches as POs) [default = %s]\n", fComb? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
- fprintf( pErr, "\t<file> : file name with the second network\n");
+ Abc_Print( -2, "usage: append [-h] <file>\n" );
+ Abc_Print( -2, "\t appends a combinational network on top of the current network\n" );
+// Abc_Print( -2, "\t-c : computes combinational miter (latches as POs) [default = %s]\n", fComb? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ Abc_Print( -2, "\t<file> : file name with the second network\n");
return 1;
}
@@ -5823,16 +5815,12 @@ usage:
***********************************************************************/
int Abc_CommandFrames( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkTemp, * pNtkRes;
int nFrames;
int fInitial;
int fVerbose;
int c;
-
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
// set defaults
nFrames = 5;
@@ -5846,7 +5834,7 @@ int Abc_CommandFrames( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
nFrames = atoi(argv[globalUtilOptind]);
@@ -5869,7 +5857,7 @@ int Abc_CommandFrames( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
@@ -5884,7 +5872,7 @@ int Abc_CommandFrames( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtkRes = Abc_NtkFrames( pNtk, nFrames, fInitial, fVerbose );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Unrolling the network has failed.\n" );
+ Abc_Print( -1, "Unrolling the network has failed.\n" );
return 1;
}
// replace the current network
@@ -5892,12 +5880,12 @@ int Abc_CommandFrames( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: frames [-F num] [-ivh]\n" );
- fprintf( pErr, "\t unrolls the network for a number of time frames\n" );
- fprintf( pErr, "\t-F num : the number of frames to unroll [default = %d]\n", nFrames );
- fprintf( pErr, "\t-i : toggles initializing the first frame [default = %s]\n", fInitial? "yes": "no" );
- fprintf( pErr, "\t-v : toggles outputting verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: frames [-F num] [-ivh]\n" );
+ Abc_Print( -2, "\t unrolls the network for a number of time frames\n" );
+ Abc_Print( -2, "\t-F num : the number of frames to unroll [default = %d]\n", nFrames );
+ Abc_Print( -2, "\t-i : toggles initializing the first frame [default = %s]\n", fInitial? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggles outputting verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -5914,7 +5902,6 @@ usage:
***********************************************************************/
int Abc_CommandDFrames( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkTemp, * pNtkRes;
int nPrefix;
int nFrames;
@@ -5923,10 +5910,7 @@ int Abc_CommandDFrames( Abc_Frame_t * pAbc, int argc, char ** argv )
int c;
extern Abc_Ntk_t * Abc_NtkDarFrames( Abc_Ntk_t * pNtk, int nPrefix, int nFrames, int fInitial, int fVerbose );
-
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
// set defaults
nPrefix = 5;
@@ -5941,7 +5925,7 @@ int Abc_CommandDFrames( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'N':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
goto usage;
}
nPrefix = atoi(argv[globalUtilOptind]);
@@ -5952,7 +5936,7 @@ int Abc_CommandDFrames( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
nFrames = atoi(argv[globalUtilOptind]);
@@ -5975,12 +5959,12 @@ int Abc_CommandDFrames( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( nPrefix > nFrames )
{
- fprintf( pErr, "Prefix (%d) cannot be more than the number of frames (%d).\n", nPrefix, nFrames );
+ Abc_Print( -1, "Prefix (%d) cannot be more than the number of frames (%d).\n", nPrefix, nFrames );
return 1;
}
@@ -5995,7 +5979,7 @@ int Abc_CommandDFrames( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtkRes = Abc_NtkDarFrames( pNtk, nPrefix, nFrames, fInitial, fVerbose );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Unrolling the network has failed.\n" );
+ Abc_Print( -1, "Unrolling the network has failed.\n" );
return 1;
}
// replace the current network
@@ -6003,13 +5987,13 @@ int Abc_CommandDFrames( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: dframes [-NF num] [-ivh]\n" );
- fprintf( pErr, "\t unrolls the network with simplification\n" );
- fprintf( pErr, "\t-N num : the number of frames to use as prefix [default = %d]\n", nPrefix );
- fprintf( pErr, "\t-F num : the number of frames to unroll [default = %d]\n", nFrames );
- fprintf( pErr, "\t-i : toggles initializing the first frame [default = %s]\n", fInitial? "yes": "no" );
- fprintf( pErr, "\t-v : toggles outputting verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: dframes [-NF num] [-ivh]\n" );
+ Abc_Print( -2, "\t unrolls the network with simplification\n" );
+ Abc_Print( -2, "\t-N num : the number of frames to use as prefix [default = %d]\n", nPrefix );
+ Abc_Print( -2, "\t-F num : the number of frames to unroll [default = %d]\n", nFrames );
+ Abc_Print( -2, "\t-i : toggles initializing the first frame [default = %s]\n", fInitial? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggles outputting verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -6028,15 +6012,10 @@ usage:
***********************************************************************/
int Abc_CommandSop( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int fDirect;
int c;
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fDirect = 0;
Extra_UtilGetoptReset();
@@ -6055,26 +6034,26 @@ int Abc_CommandSop( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsLogic(pNtk) )
{
- fprintf( pErr, "Converting to SOP is possible only for logic networks.\n" );
+ Abc_Print( -1, "Converting to SOP is possible only for logic networks.\n" );
return 1;
}
if ( !Abc_NtkToSop(pNtk, fDirect) )
{
- fprintf( pErr, "Converting to SOP has failed.\n" );
+ Abc_Print( -1, "Converting to SOP has failed.\n" );
return 1;
}
return 0;
usage:
- fprintf( pErr, "usage: sop [-dh]\n" );
- fprintf( pErr, "\t converts node functions to SOP\n" );
- fprintf( pErr, "\t-d : toggles using both phases or only positive [default = %s]\n", fDirect? "direct": "both" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: sop [-dh]\n" );
+ Abc_Print( -2, "\t converts node functions to SOP\n" );
+ Abc_Print( -2, "\t-d : toggles using both phases or only positive [default = %s]\n", fDirect? "direct": "both" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -6091,14 +6070,9 @@ usage:
***********************************************************************/
int Abc_CommandBdd( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
@@ -6113,30 +6087,30 @@ int Abc_CommandBdd( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsLogic(pNtk) )
{
- fprintf( pErr, "Converting to BDD is possible only for logic networks.\n" );
+ Abc_Print( -1, "Converting to BDD is possible only for logic networks.\n" );
return 1;
}
if ( Abc_NtkIsBddLogic(pNtk) )
{
- fprintf( pOut, "The logic network is already in the BDD form.\n" );
+ Abc_Print( -1, "The logic network is already in the BDD form.\n" );
return 0;
}
if ( !Abc_NtkToBdd(pNtk) )
{
- fprintf( pErr, "Converting to BDD has failed.\n" );
+ Abc_Print( -1, "Converting to BDD has failed.\n" );
return 1;
}
return 0;
usage:
- fprintf( pErr, "usage: bdd [-h]\n" );
- fprintf( pErr, "\t converts node functions to BDD\n" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: bdd [-h]\n" );
+ Abc_Print( -2, "\t converts node functions to BDD\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -6153,14 +6127,9 @@ usage:
***********************************************************************/
int Abc_CommandAig( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
@@ -6175,30 +6144,30 @@ int Abc_CommandAig( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsLogic(pNtk) )
{
- fprintf( pErr, "Converting to AIG is possible only for logic networks.\n" );
+ Abc_Print( -1, "Converting to AIG is possible only for logic networks.\n" );
return 1;
}
if ( Abc_NtkIsAigLogic(pNtk) )
{
- fprintf( pOut, "The logic network is already in the AIG form.\n" );
+ Abc_Print( -1, "The logic network is already in the AIG form.\n" );
return 0;
}
if ( !Abc_NtkToAig(pNtk) )
{
- fprintf( pErr, "Converting to AIG has failed.\n" );
+ Abc_Print( -1, "Converting to AIG has failed.\n" );
return 1;
}
return 0;
usage:
- fprintf( pErr, "usage: aig [-h]\n" );
- fprintf( pErr, "\t converts node functions to AIG\n" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: aig [-h]\n" );
+ Abc_Print( -2, "\t converts node functions to AIG\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -6215,16 +6184,11 @@ usage:
***********************************************************************/
int Abc_CommandReorder( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
int fVerbose;
extern void Abc_NtkBddReorder( Abc_Ntk_t * pNtk, int fVerbose );
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fVerbose = 0;
Extra_UtilGetoptReset();
@@ -6244,24 +6208,24 @@ int Abc_CommandReorder( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
// get the new network
if ( !Abc_NtkIsBddLogic(pNtk) )
{
- fprintf( pErr, "Variable reordering is possible when node functions are BDDs (run \"bdd\").\n" );
+ Abc_Print( -1, "Variable reordering is possible when node functions are BDDs (run \"bdd\").\n" );
return 1;
}
Abc_NtkBddReorder( pNtk, fVerbose );
return 0;
usage:
- fprintf( pErr, "usage: reorder [-vh]\n" );
- fprintf( pErr, "\t reorders local functions of the nodes using sifting\n" );
- fprintf( pErr, "\t-v : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: reorder [-vh]\n" );
+ Abc_Print( -2, "\t reorders local functions of the nodes using sifting\n" );
+ Abc_Print( -2, "\t-v : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -6278,16 +6242,11 @@ usage:
***********************************************************************/
int Abc_CommandBidec( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
int fVerbose;
extern void Abc_NtkBidecResyn( Abc_Ntk_t * pNtk, int fVerbose );
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fVerbose = 0;
Extra_UtilGetoptReset();
@@ -6307,24 +6266,24 @@ int Abc_CommandBidec( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
// get the new network
if ( !Abc_NtkIsAigLogic(pNtk) )
{
- fprintf( pErr, "Bi-decomposition only works when node functions are AIGs (run \"aig\").\n" );
+ Abc_Print( -1, "Bi-decomposition only works when node functions are AIGs (run \"aig\").\n" );
return 1;
}
Abc_NtkBidecResyn( pNtk, fVerbose );
return 0;
usage:
- fprintf( pErr, "usage: bidec [-vh]\n" );
- fprintf( pErr, "\t applies bi-decomposition to local functions of the nodes\n" );
- fprintf( pErr, "\t-v : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: bidec [-vh]\n" );
+ Abc_Print( -2, "\t applies bi-decomposition to local functions of the nodes\n" );
+ Abc_Print( -2, "\t-v : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -6341,8 +6300,8 @@ usage:
***********************************************************************/
int Abc_CommandOrder( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr, * pFile;
- Abc_Ntk_t * pNtk;
+ FILE * pFile;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
char * pFileName;
int c;
int fReverse;
@@ -6350,10 +6309,6 @@ int Abc_CommandOrder( Abc_Frame_t * pAbc, int argc, char ** argv )
extern void Abc_NtkImplementCiOrder( Abc_Ntk_t * pNtk, char * pFileName, int fReverse, int fVerbose );
extern void Abc_NtkFindCiOrder( Abc_Ntk_t * pNtk, int fReverse, int fVerbose );
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fReverse = 0;
fVerbose = 0;
@@ -6377,12 +6332,12 @@ int Abc_CommandOrder( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
// if ( Abc_NtkLatchNum(pNtk) > 0 )
// {
-// printf( "Currently this procedure does not work for sequential networks.\n" );
+// Abc_Print( -1, "Currently this procedure does not work for sequential networks.\n" );
// return 1;
// }
@@ -6394,7 +6349,7 @@ int Abc_CommandOrder( Abc_Frame_t * pAbc, int argc, char ** argv )
pFile = fopen( pFileName, "r" );
if ( pFile == NULL )
{
- fprintf( pErr, "Cannot open file \"%s\" with the BDD variable order.\n", pFileName );
+ Abc_Print( -1, "Cannot open file \"%s\" with the BDD variable order.\n", pFileName );
return 1;
}
fclose( pFile );
@@ -6406,12 +6361,12 @@ int Abc_CommandOrder( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: order [-rvh] <file>\n" );
- fprintf( pErr, "\t computes a good static CI variable order\n" );
- fprintf( pErr, "\t-r : toggle reverse ordering [default = %s]\n", fReverse? "yes": "no" );
- fprintf( pErr, "\t-v : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
- fprintf( pErr, "\t<file> : (optional) file with the given variable order\n" );
+ Abc_Print( -2, "usage: order [-rvh] <file>\n" );
+ Abc_Print( -2, "\t computes a good static CI variable order\n" );
+ Abc_Print( -2, "\t-r : toggle reverse ordering [default = %s]\n", fReverse? "yes": "no" );
+ Abc_Print( -2, "\t-v : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ Abc_Print( -2, "\t<file> : (optional) file with the given variable order\n" );
return 1;
}
@@ -6428,14 +6383,10 @@ usage:
***********************************************************************/
int Abc_CommandMuxes( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c;
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
@@ -6451,13 +6402,13 @@ int Abc_CommandMuxes( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsBddLogic(pNtk) )
{
- fprintf( pErr, "Only a BDD logic network can be converted to MUXes.\n" );
+ Abc_Print( -1, "Only a BDD logic network can be converted to MUXes.\n" );
return 1;
}
@@ -6465,7 +6416,7 @@ int Abc_CommandMuxes( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtkRes = Abc_NtkBddToMuxes( pNtk );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Converting to MUXes has failed.\n" );
+ Abc_Print( -1, "Converting to MUXes has failed.\n" );
return 1;
}
// replace the current network
@@ -6473,10 +6424,10 @@ int Abc_CommandMuxes( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: muxes [-h]\n" );
- fprintf( pErr, "\t converts the current network into a network derived by\n" );
- fprintf( pErr, "\t replacing all nodes by DAGs isomorphic to the local BDDs\n" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: muxes [-h]\n" );
+ Abc_Print( -2, "\t converts the current network into a network derived by\n" );
+ Abc_Print( -2, "\t replacing all nodes by DAGs isomorphic to the local BDDs\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -6494,16 +6445,12 @@ usage:
***********************************************************************/
int Abc_CommandExtSeqDcs( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
int fVerbose;
- extern int Abc_NtkExtractSequentialDcs( Abc_Ntk_t * pNet, bool fVerbose );
+ extern int Abc_NtkExtractSequentialDcs( Abc_Ntk_t * pNet, int fVerbose );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fVerbose = 0;
Extra_UtilGetoptReset();
@@ -6523,31 +6470,31 @@ int Abc_CommandExtSeqDcs( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( Abc_NtkLatchNum(pNtk) == 0 )
{
- fprintf( stdout, "The current network has no latches.\n" );
+ Abc_Print( -1, "The current network has no latches.\n" );
return 0;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( stdout, "Extracting sequential don't-cares works only for AIGs (run \"strash\").\n" );
+ Abc_Print( -1, "Extracting sequential don't-cares works only for AIGs (run \"strash\").\n" );
return 0;
}
if ( !Abc_NtkExtractSequentialDcs( pNtk, fVerbose ) )
{
- fprintf( stdout, "Extracting sequential don't-cares has failed.\n" );
+ Abc_Print( -1, "Extracting sequential don't-cares has failed.\n" );
return 1;
}
return 0;
usage:
- fprintf( pErr, "usage: ext_seq_dcs [-vh]\n" );
- fprintf( pErr, "\t create EXDC network using unreachable states\n" );
- fprintf( pErr, "\t-v : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: ext_seq_dcs [-vh]\n" );
+ Abc_Print( -2, "\t create EXDC network using unreachable states\n" );
+ Abc_Print( -2, "\t-v : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -6564,66 +6511,76 @@ usage:
***********************************************************************/
int Abc_CommandReach( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
- int nBddMax;
- int nIterMax;
- int fPartition;
- int fReorder;
- int fReorderImage;
- int fVerbose;
+ Saig_ParBbr_t Pars, * pPars = &Pars;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
- extern void Abc_NtkDarReach( Abc_Ntk_t * pNtk, int nBddMax, int nIterMax, int fPartition, int fReorder, int fReorderImage, int fVerbose );
+ char * pLogFileName = NULL;
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
+ extern int Abc_NtkDarReach( Abc_Ntk_t * pNtk, Saig_ParBbr_t * pPars );
// set defaults
- nBddMax = 50000;
- nIterMax = 1000;
- fPartition = 1;
- fReorder = 1;
- fReorderImage = 0;
- fVerbose = 0;
+ Bbr_ManSetDefaultParams( pPars );
Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "BFprovh" ) ) != EOF )
+ while ( ( c = Extra_UtilGetopt( argc, argv, "TBFLproyvh" ) ) != EOF )
{
switch ( c )
{
+ case 'T':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ pPars->TimeLimit = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->TimeLimit < 0 )
+ goto usage;
+ break;
case 'B':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-B\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-B\" should be followed by an integer.\n" );
goto usage;
}
- nBddMax = atoi(argv[globalUtilOptind]);
+ pPars->nBddMax = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
- if ( nBddMax < 0 )
+ if ( pPars->nBddMax < 0 )
goto usage;
break;
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
- nIterMax = atoi(argv[globalUtilOptind]);
+ pPars->nIterMax = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
- if ( nIterMax < 0 )
+ if ( pPars->nIterMax < 0 )
goto usage;
break;
+ case 'L':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-L\" should be followed by a file name.\n" );
+ goto usage;
+ }
+ pLogFileName = argv[globalUtilOptind];
+ globalUtilOptind++;
+ break;
case 'p':
- fPartition ^= 1;
+ pPars->fPartition ^= 1;
break;
case 'r':
- fReorder ^= 1;
+ pPars->fReorder ^= 1;
break;
case 'o':
- fReorderImage ^= 1;
+ pPars->fReorderImage ^= 1;
+ break;
+ case 'y':
+ pPars->fSkipOutCheck ^= 1;
break;
case 'v':
- fVerbose ^= 1;
+ pPars->fVerbose ^= 1;
break;
case 'h':
goto usage;
@@ -6633,48 +6590,39 @@ int Abc_CommandReach( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( Abc_NtkLatchNum(pNtk) == 0 )
{
- fprintf( stdout, "The current network has no latches.\n" );
+ Abc_Print( -1, "The current network has no latches.\n" );
return 0;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( stdout, "Reachability analysis works only for AIGs (run \"strash\").\n" );
- return 1;
- }
-/*
- if ( Abc_NtkLatchNum(pNtk) > 60 || Abc_NtkNodeNum(pNtk) > 3000 )
- {
- fprintf( stdout, "The number of latches %d and nodes %d. Skippping...\n", Abc_NtkLatchNum(pNtk), Abc_NtkNodeNum(pNtk) );
- return 0;
- }
-*/
-/*
- if ( Abc_NtkPoNum(pNtk) != 1 )
- {
- fprintf( stdout, "The sequential miter has more than one output (run \"orpos\").\n" );
+ Abc_Print( -1, "Reachability analysis works only for AIGs (run \"strash\").\n" );
return 1;
}
-*/
-// Abc_NtkVerifyUsingBdds( pNtk, nBddMax, nIterMax, fPartition, fReorder, fVerbose );
- Abc_NtkDarReach( pNtk, nBddMax, nIterMax, fPartition, fReorder, fReorderImage, fVerbose );
- pAbc->pCex = pNtk->pSeqModel; // temporary ???
+ pAbc->Status = Abc_NtkDarReach( pNtk, pPars );
+ pAbc->nFrames = pPars->iFrame;
+ Abc_FrameReplaceCex( pAbc, &pNtk->pSeqModel );
+ if ( pLogFileName )
+ Abc_NtkWriteLogFile( pLogFileName, pAbc->pCex, pAbc->Status, "reach" );
return 0;
usage:
- fprintf( pErr, "usage: reach [-BF num] [-provh]\n" );
- fprintf( pErr, "\t verifies sequential miter using BDD-based reachability\n" );
- fprintf( pErr, "\t-B num : max number of nodes in the intermediate BDDs [default = %d]\n", nBddMax );
- fprintf( pErr, "\t-F num : max number of reachability iterations [default = %d]\n", nIterMax );
- fprintf( pErr, "\t-p : enable partitioned image computation [default = %s]\n", fPartition? "yes": "no" );
- fprintf( pErr, "\t-r : enable dynamic BDD variable reordering [default = %s]\n", fReorder? "yes": "no" );
- fprintf( pErr, "\t-o : toggles BDD variable reordering during image computation [default = %s]\n", fReorderImage? "yes": "no" );
- fprintf( pErr, "\t-v : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: reach [-TBF num] [-L file] [-proyvh]\n" );
+ Abc_Print( -2, "\t verifies sequential miter using BDD-based reachability\n" );
+ Abc_Print( -2, "\t-T num : approximate time limit in seconds (0=infinite) [default = %d]\n", pPars->TimeLimit );
+ Abc_Print( -2, "\t-B num : max number of nodes in the intermediate BDDs [default = %d]\n", pPars->nBddMax );
+ Abc_Print( -2, "\t-F num : max number of reachability iterations [default = %d]\n", pPars->nIterMax );
+ Abc_Print( -2, "\t-L file: the log file name [default = %s]\n", pLogFileName ? pLogFileName : "no logging" );
+ Abc_Print( -2, "\t-p : enable partitioned image computation [default = %s]\n", pPars->fPartition? "yes": "no" );
+ Abc_Print( -2, "\t-r : enable dynamic BDD variable reordering [default = %s]\n", pPars->fReorder? "yes": "no" );
+ Abc_Print( -2, "\t-o : toggles BDD variable reordering during image computation [default = %s]\n", pPars->fReorderImage? "yes": "no" );
+ Abc_Print( -2, "\t-y : skip checking property outputs [default = %s]\n", pPars->fSkipOutCheck? "yes": "no" );
+ Abc_Print( -2, "\t-v : prints verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -6691,7 +6639,6 @@ usage:
***********************************************************************/
int Abc_CommandCone( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
Abc_Obj_t * pNode, * pNodeCo;
int c;
@@ -6699,27 +6646,26 @@ int Abc_CommandCone( Abc_Frame_t * pAbc, int argc, char ** argv )
int fUseMffc;
int fSeq;
int Output;
+ int nRange;
- extern void Abc_NtkMakeOnePo( Abc_Ntk_t * pNtk, Abc_Obj_t * pNodePo );
+ extern Abc_Ntk_t * Abc_NtkMakeOnePo( Abc_Ntk_t * pNtk, int Output, int nRange );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fUseAllCis = 0;
fUseMffc = 0;
fSeq = 0;
Output = -1;
+ nRange = -1;
Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "Omash" ) ) != EOF )
+ while ( ( c = Extra_UtilGetopt( argc, argv, "ORmash" ) ) != EOF )
{
switch ( c )
{
case 'O':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-O\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-O\" should be followed by an integer.\n" );
goto usage;
}
Output = atoi(argv[globalUtilOptind]);
@@ -6727,6 +6673,17 @@ int Abc_CommandCone( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( Output < 0 )
goto usage;
break;
+ case 'R':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ nRange = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( nRange < 0 )
+ goto usage;
+ break;
case 'm':
fUseMffc ^= 1;
break;
@@ -6745,19 +6702,19 @@ int Abc_CommandCone( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsLogic(pNtk) && !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "Currently can only be applied to the logic network or an AIG.\n" );
+ Abc_Print( -1, "Currently can only be applied to the logic network or an AIG.\n" );
return 1;
}
if ( argc > globalUtilOptind + 1 )
{
- fprintf( pErr, "Wrong number of auguments.\n" );
+ Abc_Print( -1, "Wrong number of auguments.\n" );
goto usage;
}
@@ -6767,7 +6724,7 @@ int Abc_CommandCone( Abc_Frame_t * pAbc, int argc, char ** argv )
pNode = Abc_NtkFindNode( pNtk, argv[globalUtilOptind] );
if ( pNode == NULL )
{
- fprintf( pErr, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
+ Abc_Print( -1, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
return 1;
}
if ( fUseMffc )
@@ -6779,31 +6736,30 @@ int Abc_CommandCone( Abc_Frame_t * pAbc, int argc, char ** argv )
{
if ( Output == -1 )
{
- fprintf( pErr, "The node is not specified.\n" );
+ Abc_Print( -1, "The node is not specified.\n" );
return 1;
}
if ( Output >= Abc_NtkCoNum(pNtk) )
{
- fprintf( pErr, "The 0-based output number (%d) is larger than the number of outputs (%d).\n", Output, Abc_NtkCoNum(pNtk) );
+ Abc_Print( -1, "The 0-based output number (%d) is larger than the number of outputs (%d).\n", Output, Abc_NtkCoNum(pNtk) );
return 1;
}
pNodeCo = Abc_NtkCo( pNtk, Output );
if ( fSeq )
- {
- pNtkRes = Abc_NtkDup( pNtk );
- pNodeCo = Abc_NtkPo( pNtkRes, Output );
- Abc_NtkMakeOnePo( pNtkRes, pNodeCo );
- }
+ pNtkRes = Abc_NtkMakeOnePo( pNtk, Output, nRange );
else if ( fUseMffc )
pNtkRes = Abc_NtkCreateMffc( pNtk, Abc_ObjFanin0(pNodeCo), Abc_ObjName(pNodeCo) );
else
pNtkRes = Abc_NtkCreateCone( pNtk, Abc_ObjFanin0(pNodeCo), Abc_ObjName(pNodeCo), fUseAllCis );
}
if ( pNodeCo && Abc_ObjFaninC0(pNodeCo) && !fSeq )
- printf( "The extracted cone represents the complement function of the CO.\n" );
+ {
+ Abc_NtkPo(pNtkRes, 0)->fCompl0 ^= 1;
+// Abc_Print( -1, "The extracted cone represents the complement function of the CO.\n" );
+ }
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Writing the logic cone of one node has failed.\n" );
+ Abc_Print( -1, "Writing the logic cone of one node has failed.\n" );
return 1;
}
// replace the current network
@@ -6811,14 +6767,15 @@ int Abc_CommandCone( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: cone [-O num] [-amsh] <name>\n" );
- fprintf( pErr, "\t replaces the current network by one logic cone\n" );
- fprintf( pErr, "\t-a : toggle keeping all CIs or structral support only [default = %s]\n", fUseAllCis? "all": "structural" );
- fprintf( pErr, "\t-m : toggle keeping only MFFC or complete TFI cone [default = %s]\n", fUseMffc? "MFFC": "TFI cone" );
- fprintf( pErr, "\t-s : toggle comb or sequential cone (works with \"-O num\") [default = %s]\n", fSeq? "seq": "comb" );
- fprintf( pErr, "\t-h : print the command usage\n");
- fprintf( pErr, "\t-O num : (optional) the 0-based number of the CO to extract\n");
- fprintf( pErr, "\tname : (optional) the name of the node to extract\n");
+ Abc_Print( -2, "usage: cone [-OR num] [-amsh] <name>\n" );
+ Abc_Print( -2, "\t replaces the current network by one logic cone\n" );
+ Abc_Print( -2, "\t-a : toggle keeping all CIs or structral support only [default = %s]\n", fUseAllCis? "all": "structural" );
+ Abc_Print( -2, "\t-m : toggle keeping only MFFC or complete TFI cone [default = %s]\n", fUseMffc? "MFFC": "TFI cone" );
+ Abc_Print( -2, "\t-s : toggle comb or sequential cone (works with \"-O num\") [default = %s]\n", fSeq? "seq": "comb" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ Abc_Print( -2, "\t-O num : (optional) the 0-based number of the CO to extract\n");
+ Abc_Print( -2, "\t-R num : (optional) the number of outputs to extract\n");
+ Abc_Print( -2, "\tname : (optional) the name of the node to extract\n");
return 1;
}
@@ -6835,15 +6792,11 @@ usage:
***********************************************************************/
int Abc_CommandNode( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
Abc_Obj_t * pNode;
int c;
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
@@ -6859,26 +6812,26 @@ int Abc_CommandNode( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsLogic(pNtk) )
{
- fprintf( pErr, "Currently can only be applied to a logic network.\n" );
+ Abc_Print( -1, "Currently can only be applied to a logic network.\n" );
return 1;
}
if ( argc != globalUtilOptind + 1 )
{
- fprintf( pErr, "Wrong number of auguments.\n" );
+ Abc_Print( -1, "Wrong number of auguments.\n" );
goto usage;
}
pNode = Abc_NtkFindNode( pNtk, argv[globalUtilOptind] );
if ( pNode == NULL )
{
- fprintf( pErr, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
+ Abc_Print( -1, "Cannot find node \"%s\".\n", argv[globalUtilOptind] );
return 1;
}
@@ -6886,7 +6839,7 @@ int Abc_CommandNode( Abc_Frame_t * pAbc, int argc, char ** argv )
// pNtkRes = Abc_NtkDeriveFromBdd( pNtk->pManFunc, pNode->pData, NULL, NULL );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Splitting one node has failed.\n" );
+ Abc_Print( -1, "Splitting one node has failed.\n" );
return 1;
}
// replace the current network
@@ -6894,10 +6847,10 @@ int Abc_CommandNode( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: node [-h] <name>\n" );
- fprintf( pErr, "\t replaces the current network by the network composed of one node\n" );
- fprintf( pErr, "\t-h : print the command usage\n");
- fprintf( pErr, "\tname : the node name\n");
+ Abc_Print( -2, "usage: node [-h] <name>\n" );
+ Abc_Print( -2, "\t replaces the current network by the network composed of one node\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ Abc_Print( -2, "\tname : the node name\n");
return 1;
}
@@ -6915,15 +6868,11 @@ usage:
***********************************************************************/
int Abc_CommandTopmost( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c, nLevels;
extern Abc_Ntk_t * Abc_NtkTopmost( Abc_Ntk_t * pNtk, int nLevels );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
nLevels = 10;
Extra_UtilGetoptReset();
@@ -6934,7 +6883,7 @@ int Abc_CommandTopmost( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'N':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
goto usage;
}
nLevels = atoi(argv[globalUtilOptind]);
@@ -6951,31 +6900,31 @@ int Abc_CommandTopmost( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( stdout, "Currently only works for structurally hashed circuits.\n" );
+ Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
return 0;
}
if ( Abc_NtkLatchNum(pNtk) > 0 )
{
- fprintf( stdout, "Currently can only works for combinational circuits.\n" );
+ Abc_Print( -1, "Currently can only works for combinational circuits.\n" );
return 0;
}
if ( Abc_NtkPoNum(pNtk) != 1 )
{
- fprintf( stdout, "Currently expects a single-output miter.\n" );
+ Abc_Print( -1, "Currently expects a single-output miter.\n" );
return 0;
}
pNtkRes = Abc_NtkTopmost( pNtk, nLevels );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "The command has failed.\n" );
+ Abc_Print( -1, "The command has failed.\n" );
return 1;
}
// replace the current network
@@ -6983,11 +6932,11 @@ int Abc_CommandTopmost( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: topmost [-N num] [-h]\n" );
- fprintf( pErr, "\t replaces the current network by several of its topmost levels\n" );
- fprintf( pErr, "\t-N num : max number of levels [default = %d]\n", nLevels );
- fprintf( pErr, "\t-h : print the command usage\n");
- fprintf( pErr, "\tname : the node name\n");
+ Abc_Print( -2, "usage: topmost [-N num] [-h]\n" );
+ Abc_Print( -2, "\t replaces the current network by several of its topmost levels\n" );
+ Abc_Print( -2, "\t-N num : max number of levels [default = %d]\n", nLevels );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ Abc_Print( -2, "\tname : the node name\n");
return 1;
}
@@ -7004,15 +6953,11 @@ usage:
***********************************************************************/
int Abc_CommandTopAnd( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c;
extern Abc_Ntk_t * Abc_NtkTopAnd( Abc_Ntk_t * pNtk );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
@@ -7028,40 +6973,40 @@ int Abc_CommandTopAnd( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( stdout, "Currently only works for structurally hashed circuits.\n" );
+ Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
return 0;
}
if ( Abc_NtkLatchNum(pNtk) > 0 )
{
- fprintf( stdout, "Currently can only works for combinational circuits.\n" );
+ Abc_Print( -1, "Currently can only works for combinational circuits.\n" );
return 0;
}
if ( Abc_NtkPoNum(pNtk) != 1 )
{
- fprintf( stdout, "Currently expects a single-output miter.\n" );
+ Abc_Print( -1, "Currently expects a single-output miter.\n" );
return 0;
}
if ( Abc_ObjFaninC0(Abc_NtkPo(pNtk, 0)) )
{
- fprintf( stdout, "The PO driver is complemented. AND-decomposition is impossible.\n" );
+ Abc_Print( -1, "The PO driver is complemented. AND-decomposition is impossible.\n" );
return 0;
}
if ( !Abc_ObjIsNode(Abc_ObjChild0(Abc_NtkPo(pNtk, 0))) )
{
- fprintf( stdout, "The PO driver is not a node. AND-decomposition is impossible.\n" );
+ Abc_Print( -1, "The PO driver is not a node. AND-decomposition is impossible.\n" );
return 0;
}
pNtkRes = Abc_NtkTopAnd( pNtk );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "The command has failed.\n" );
+ Abc_Print( -1, "The command has failed.\n" );
return 1;
}
// replace the current network
@@ -7069,10 +7014,10 @@ int Abc_CommandTopAnd( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: topand [-h]\n" );
- fprintf( pErr, "\t performs AND-decomposition of single-output combinational miter\n" );
- fprintf( pErr, "\t-h : print the command usage\n");
- fprintf( pErr, "\tname : the node name\n");
+ Abc_Print( -2, "usage: topand [-h]\n" );
+ Abc_Print( -2, "\t performs AND-decomposition of single-output combinational miter\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ Abc_Print( -2, "\tname : the node name\n");
return 1;
}
@@ -7089,15 +7034,11 @@ usage:
***********************************************************************/
int Abc_CommandTrim( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c, nLevels;
extern Abc_Ntk_t * Abc_NtkTrim( Abc_Ntk_t * pNtk );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
nLevels = 10;
Extra_UtilGetoptReset();
@@ -7109,7 +7050,7 @@ int Abc_CommandTrim( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'N':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
goto usage;
}
nLevels = atoi(argv[globalUtilOptind]);
@@ -7127,19 +7068,19 @@ int Abc_CommandTrim( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( Abc_NtkIsStrash(pNtk) )
{
- fprintf( stdout, "Currently only works for logic circuits.\n" );
+ Abc_Print( -1, "Currently only works for logic circuits.\n" );
return 0;
}
pNtkRes = Abc_NtkTrim( pNtk );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "The command has failed.\n" );
+ Abc_Print( -1, "The command has failed.\n" );
return 1;
}
// replace the current network
@@ -7147,10 +7088,10 @@ int Abc_CommandTrim( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: trim [-h]\n" );
- fprintf( pErr, "\t removes POs fed by PIs and constants, and PIs w/o fanout\n" );
-// fprintf( pErr, "\t-N num : max number of levels [default = %d]\n", nLevels );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: trim [-h]\n" );
+ Abc_Print( -2, "\t removes POs fed by PIs and constants, and PIs w/o fanout\n" );
+// Abc_Print( -2, "\t-N num : max number of levels [default = %d]\n", nLevels );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -7168,14 +7109,8 @@ usage:
***********************************************************************/
int Abc_CommandShortNames( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
@@ -7191,16 +7126,16 @@ int Abc_CommandShortNames( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
Abc_NtkShortNames( pNtk );
return 0;
usage:
- fprintf( pErr, "usage: short_names [-h]\n" );
- fprintf( pErr, "\t replaces PI/PO/latch names by short char strings\n" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: short_names [-h]\n" );
+ Abc_Print( -2, "\t replaces PI/PO/latch names by short char strings\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -7217,14 +7152,10 @@ usage:
***********************************************************************/
int Abc_CommandExdcFree( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c;
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
@@ -7240,12 +7171,12 @@ int Abc_CommandExdcFree( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( pNtk->pExdc == NULL )
{
- fprintf( pErr, "The network has no EXDC.\n" );
+ Abc_Print( -1, "The network has no EXDC.\n" );
return 1;
}
@@ -7258,9 +7189,9 @@ int Abc_CommandExdcFree( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: exdc_free [-h]\n" );
- fprintf( pErr, "\t frees the EXDC network of the current network\n" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: exdc_free [-h]\n" );
+ Abc_Print( -2, "\t frees the EXDC network of the current network\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -7277,14 +7208,10 @@ usage:
***********************************************************************/
int Abc_CommandExdcGet( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c;
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
@@ -7300,12 +7227,12 @@ int Abc_CommandExdcGet( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( pNtk->pExdc == NULL )
{
- fprintf( pErr, "The network has no EXDC.\n" );
+ Abc_Print( -1, "The network has no EXDC.\n" );
return 1;
}
@@ -7315,9 +7242,9 @@ int Abc_CommandExdcGet( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: exdc_get [-h]\n" );
- fprintf( pErr, "\t replaces the current network by the EXDC of the current network\n" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: exdc_get [-h]\n" );
+ Abc_Print( -2, "\t replaces the current network by the EXDC of the current network\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -7334,15 +7261,12 @@ usage:
***********************************************************************/
int Abc_CommandExdcSet( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr, * pFile;
+ FILE * pFile;
Abc_Ntk_t * pNtk, * pNtkNew, * pNtkRes;
char * FileName;
int c;
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
@@ -7358,7 +7282,7 @@ int Abc_CommandExdcSet( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
@@ -7371,10 +7295,10 @@ int Abc_CommandExdcSet( Abc_Frame_t * pAbc, int argc, char ** argv )
FileName = argv[globalUtilOptind];
if ( (pFile = fopen( FileName, "r" )) == NULL )
{
- fprintf( pAbc->Err, "Cannot open input file \"%s\". ", FileName );
+ Abc_Print( -1, "Cannot open input file \"%s\". ", FileName );
if ( (FileName = Extra_FileGetSimilarName( FileName, ".mv", ".blif", ".pla", ".eqn", ".bench" )) )
- fprintf( pAbc->Err, "Did you mean \"%s\"?", FileName );
- fprintf( pAbc->Err, "\n" );
+ Abc_Print( 1, "Did you mean \"%s\"?", FileName );
+ Abc_Print( 1, "\n" );
return 1;
}
fclose( pFile );
@@ -7383,7 +7307,7 @@ int Abc_CommandExdcSet( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtkNew = Io_Read( FileName, Io_ReadFileType(FileName), 1 );
if ( pNtkNew == NULL )
{
- fprintf( pAbc->Err, "Reading network from file has failed.\n" );
+ Abc_Print( -1, "Reading network from file has failed.\n" );
return 1;
}
@@ -7401,10 +7325,10 @@ int Abc_CommandExdcSet( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: exdc_set [-h] <file>\n" );
- fprintf( pErr, "\t sets the network from file as EXDC for the current network\n" );
- fprintf( pErr, "\t-h : print the command usage\n");
- fprintf( pErr, "\t<file> : file with the new EXDC network\n");
+ Abc_Print( -2, "usage: exdc_set [-h] <file>\n" );
+ Abc_Print( -2, "\t sets the network from file as EXDC for the current network\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ Abc_Print( -2, "\t<file> : file with the new EXDC network\n");
return 1;
}
@@ -7421,15 +7345,12 @@ usage:
***********************************************************************/
int Abc_CommandCareSet( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr, * pFile;
+ FILE * pFile;
Abc_Ntk_t * pNtk, * pNtkNew, * pNtkRes;
char * FileName;
int c;
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
@@ -7445,7 +7366,7 @@ int Abc_CommandCareSet( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
@@ -7458,10 +7379,10 @@ int Abc_CommandCareSet( Abc_Frame_t * pAbc, int argc, char ** argv )
FileName = argv[globalUtilOptind];
if ( (pFile = fopen( FileName, "r" )) == NULL )
{
- fprintf( pAbc->Err, "Cannot open input file \"%s\". ", FileName );
+ Abc_Print( -1, "Cannot open input file \"%s\". ", FileName );
if ( (FileName = Extra_FileGetSimilarName( FileName, ".mv", ".blif", ".pla", ".eqn", ".bench" )) )
- fprintf( pAbc->Err, "Did you mean \"%s\"?", FileName );
- fprintf( pAbc->Err, "\n" );
+ Abc_Print( 1, "Did you mean \"%s\"?", FileName );
+ Abc_Print( 1, "\n" );
return 1;
}
fclose( pFile );
@@ -7470,14 +7391,14 @@ int Abc_CommandCareSet( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtkNew = Io_Read( FileName, Io_ReadFileType(FileName), 1 );
if ( pNtkNew == NULL )
{
- fprintf( pAbc->Err, "Reading network from file has failed.\n" );
+ Abc_Print( -1, "Reading network from file has failed.\n" );
return 1;
}
// replace the EXDC
if ( pNtk->pExcare )
{
- Abc_NtkDelete( pNtk->pExcare );
+ Abc_NtkDelete( (Abc_Ntk_t *)pNtk->pExcare );
pNtk->pExcare = NULL;
}
pNtkRes = Abc_NtkDup( pNtk );
@@ -7488,10 +7409,10 @@ int Abc_CommandCareSet( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: care_set [-h] <file>\n" );
- fprintf( pErr, "\t sets the network from file as a care for the current network\n" );
- fprintf( pErr, "\t-h : print the command usage\n");
- fprintf( pErr, "\t<file> : file with the new care network\n");
+ Abc_Print( -2, "usage: care_set [-h] <file>\n" );
+ Abc_Print( -2, "\t sets the network from file as a care for the current network\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ Abc_Print( -2, "\t<file> : file with the new care network\n");
return 1;
}
@@ -7511,17 +7432,12 @@ int Abc_CommandCut( Abc_Frame_t * pAbc, int argc, char ** argv )
Cut_Params_t Params, * pParams = &Params;
Cut_Man_t * pCutMan;
Cut_Oracle_t * pCutOracle = NULL;
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
int fOracle;
extern Cut_Man_t * Abc_NtkCuts( Abc_Ntk_t * pNtk, Cut_Params_t * pParams );
extern void Abc_NtkCutsOracle( Abc_Ntk_t * pNtk, Cut_Oracle_t * pCutOracle );
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fOracle = 0;
memset( pParams, 0, sizeof(Cut_Params_t) );
@@ -7547,7 +7463,7 @@ int Abc_CommandCut( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'K':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-K\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
goto usage;
}
pParams->nVarsMax = atoi(argv[globalUtilOptind]);
@@ -7558,7 +7474,7 @@ int Abc_CommandCut( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'M':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-M\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
goto usage;
}
pParams->nKeepMax = atoi(argv[globalUtilOptind]);
@@ -7614,22 +7530,22 @@ int Abc_CommandCut( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "Cut computation is available only for AIGs (run \"strash\").\n" );
+ Abc_Print( -1, "Cut computation is available only for AIGs (run \"strash\").\n" );
return 1;
}
if ( pParams->nVarsMax < CUT_SIZE_MIN || pParams->nVarsMax > CUT_SIZE_MAX )
{
- fprintf( pErr, "Can only compute the cuts for %d <= K <= %d.\n", CUT_SIZE_MIN, CUT_SIZE_MAX );
+ Abc_Print( -1, "Can only compute the cuts for %d <= K <= %d.\n", CUT_SIZE_MIN, CUT_SIZE_MAX );
return 1;
}
if ( pParams->fDag && pParams->fTree )
{
- fprintf( pErr, "Cannot compute both DAG cuts and tree cuts at the same time.\n" );
+ Abc_Print( -1, "Cannot compute both DAG cuts and tree cuts at the same time.\n" );
return 1;
}
@@ -7648,23 +7564,23 @@ int Abc_CommandCut( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: cut [-K num] [-M num] [-tfdcovamjvh]\n" );
- fprintf( pErr, "\t computes k-feasible cuts for the AIG\n" );
- fprintf( pErr, "\t-K num : max number of leaves (%d <= num <= %d) [default = %d]\n", CUT_SIZE_MIN, CUT_SIZE_MAX, pParams->nVarsMax );
- fprintf( pErr, "\t-M num : max number of cuts stored at a node [default = %d]\n", pParams->nKeepMax );
- fprintf( pErr, "\t-t : toggle truth table computation [default = %s]\n", pParams->fTruth? "yes": "no" );
- fprintf( pErr, "\t-f : toggle filtering of duplicated/dominated [default = %s]\n", pParams->fFilter? "yes": "no" );
- fprintf( pErr, "\t-d : toggle dropping when fanouts are done [default = %s]\n", pParams->fDrop? "yes": "no" );
- fprintf( pErr, "\t-x : toggle computing only DAG cuts [default = %s]\n", pParams->fDag? "yes": "no" );
- fprintf( pErr, "\t-y : toggle computing only tree cuts [default = %s]\n", pParams->fTree? "yes": "no" );
- fprintf( pErr, "\t-g : toggle computing only global cuts [default = %s]\n", pParams->fGlobal? "yes": "no" );
- fprintf( pErr, "\t-l : toggle computing only local cuts [default = %s]\n", pParams->fLocal? "yes": "no" );
- fprintf( pErr, "\t-z : toggle fancy computations [default = %s]\n", pParams->fFancy? "yes": "no" );
- fprintf( pErr, "\t-a : toggle recording cut functions [default = %s]\n", pParams->fRecordAig?"yes": "no" );
- fprintf( pErr, "\t-m : toggle delay-oriented FPGA mapping [default = %s]\n", pParams->fMap? "yes": "no" );
- fprintf( pErr, "\t-j : toggle removing fanouts due to XOR/MUX [default = %s]\n", pParams->fAdjust? "yes": "no" );
- fprintf( pErr, "\t-v : toggle printing verbose information [default = %s]\n", pParams->fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: cut [-K num] [-M num] [-tfdcovamjvh]\n" );
+ Abc_Print( -2, "\t computes k-feasible cuts for the AIG\n" );
+ Abc_Print( -2, "\t-K num : max number of leaves (%d <= num <= %d) [default = %d]\n", CUT_SIZE_MIN, CUT_SIZE_MAX, pParams->nVarsMax );
+ Abc_Print( -2, "\t-M num : max number of cuts stored at a node [default = %d]\n", pParams->nKeepMax );
+ Abc_Print( -2, "\t-t : toggle truth table computation [default = %s]\n", pParams->fTruth? "yes": "no" );
+ Abc_Print( -2, "\t-f : toggle filtering of duplicated/dominated [default = %s]\n", pParams->fFilter? "yes": "no" );
+ Abc_Print( -2, "\t-d : toggle dropping when fanouts are done [default = %s]\n", pParams->fDrop? "yes": "no" );
+ Abc_Print( -2, "\t-x : toggle computing only DAG cuts [default = %s]\n", pParams->fDag? "yes": "no" );
+ Abc_Print( -2, "\t-y : toggle computing only tree cuts [default = %s]\n", pParams->fTree? "yes": "no" );
+ Abc_Print( -2, "\t-g : toggle computing only global cuts [default = %s]\n", pParams->fGlobal? "yes": "no" );
+ Abc_Print( -2, "\t-l : toggle computing only local cuts [default = %s]\n", pParams->fLocal? "yes": "no" );
+ Abc_Print( -2, "\t-z : toggle fancy computations [default = %s]\n", pParams->fFancy? "yes": "no" );
+ Abc_Print( -2, "\t-a : toggle recording cut functions [default = %s]\n", pParams->fRecordAig?"yes": "no" );
+ Abc_Print( -2, "\t-m : toggle delay-oriented FPGA mapping [default = %s]\n", pParams->fMap? "yes": "no" );
+ Abc_Print( -2, "\t-j : toggle removing fanouts due to XOR/MUX [default = %s]\n", pParams->fAdjust? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", pParams->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -7683,15 +7599,10 @@ int Abc_CommandScut( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Cut_Params_t Params, * pParams = &Params;
Cut_Man_t * pCutMan;
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
extern Cut_Man_t * Abc_NtkSeqCuts( Abc_Ntk_t * pNtk, Cut_Params_t * pParams );
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
memset( pParams, 0, sizeof(Cut_Params_t) );
pParams->nVarsMax = 5; // the max cut size ("k" of the k-feasible cuts)
@@ -7708,7 +7619,7 @@ int Abc_CommandScut( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'K':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-K\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
goto usage;
}
pParams->nVarsMax = atoi(argv[globalUtilOptind]);
@@ -7719,7 +7630,7 @@ int Abc_CommandScut( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'M':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-M\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
goto usage;
}
pParams->nKeepMax = atoi(argv[globalUtilOptind]);
@@ -7742,19 +7653,19 @@ int Abc_CommandScut( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
/*
if ( !Abc_NtkIsSeq(pNtk) )
{
- fprintf( pErr, "Sequential cuts can be computed for sequential AIGs (run \"seq\").\n" );
+ Abc_Print( -1, "Sequential cuts can be computed for sequential AIGs (run \"seq\").\n" );
return 1;
}
*/
if ( pParams->nVarsMax < CUT_SIZE_MIN || pParams->nVarsMax > CUT_SIZE_MAX )
{
- fprintf( pErr, "Can only compute the cuts for %d <= K <= %d.\n", CUT_SIZE_MIN, CUT_SIZE_MAX );
+ Abc_Print( -1, "Can only compute the cuts for %d <= K <= %d.\n", CUT_SIZE_MIN, CUT_SIZE_MAX );
return 1;
}
@@ -7763,13 +7674,13 @@ int Abc_CommandScut( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: scut [-K num] [-M num] [-tvh]\n" );
- fprintf( pErr, "\t computes k-feasible cuts for the sequential AIG\n" );
- fprintf( pErr, "\t-K num : max number of leaves (%d <= num <= %d) [default = %d]\n", CUT_SIZE_MIN, CUT_SIZE_MAX, pParams->nVarsMax );
- fprintf( pErr, "\t-M num : max number of cuts stored at a node [default = %d]\n", pParams->nKeepMax );
- fprintf( pErr, "\t-t : toggle truth table computation [default = %s]\n", pParams->fTruth? "yes": "no" );
- fprintf( pErr, "\t-v : toggle printing verbose information [default = %s]\n", pParams->fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: scut [-K num] [-M num] [-tvh]\n" );
+ Abc_Print( -2, "\t computes k-feasible cuts for the sequential AIG\n" );
+ Abc_Print( -2, "\t-K num : max number of leaves (%d <= num <= %d) [default = %d]\n", CUT_SIZE_MIN, CUT_SIZE_MAX, pParams->nVarsMax );
+ Abc_Print( -2, "\t-M num : max number of cuts stored at a node [default = %d]\n", pParams->nKeepMax );
+ Abc_Print( -2, "\t-t : toggle truth table computation [default = %s]\n", pParams->fTruth? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", pParams->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -7786,17 +7697,12 @@ usage:
***********************************************************************/
int Abc_CommandEspresso( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
int fVerbose;
extern void Abc_NtkEspresso( Abc_Ntk_t * pNtk, int fVerbose );
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
- printf( "This command is currently disabled.\n" );
+ Abc_Print( -1, "This command is currently disabled.\n" );
return 0;
// set defaults
@@ -7817,22 +7723,22 @@ int Abc_CommandEspresso( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsLogic(pNtk) )
{
- fprintf( pErr, "SOP minimization is possible for logic networks (run \"renode\").\n" );
+ Abc_Print( -1, "SOP minimization is possible for logic networks (run \"renode\").\n" );
return 1;
}
// Abc_NtkEspresso( pNtk, fVerbose );
return 0;
usage:
- fprintf( pErr, "usage: espresso [-vh]\n" );
- fprintf( pErr, "\t minimizes SOPs of the local functions using Espresso\n" );
- fprintf( pErr, "\t-v : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: espresso [-vh]\n" );
+ Abc_Print( -2, "\t minimizes SOPs of the local functions using Espresso\n" );
+ Abc_Print( -2, "\t-v : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -7849,8 +7755,7 @@ usage:
***********************************************************************/
int Abc_CommandGen( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
int nVars;
int fAdder;
@@ -7868,10 +7773,6 @@ int Abc_CommandGen( Abc_Frame_t * pAbc, int argc, char ** argv )
extern void Abc_GenOneHot( char * pFileName, int nVars );
extern void Abc_GenRandom( char * pFileName, int nPis );
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
nVars = 8;
fAdder = 0;
@@ -7889,7 +7790,7 @@ int Abc_CommandGen( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'N':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
goto usage;
}
nVars = atoi(argv[globalUtilOptind]);
@@ -7947,22 +7848,22 @@ int Abc_CommandGen( Abc_Frame_t * pAbc, int argc, char ** argv )
else if ( fRandom )
Abc_GenRandom( FileName, nVars );
else
- printf( "Type of circuit is not specified.\n" );
+ Abc_Print( -1, "Type of circuit is not specified.\n" );
return 0;
usage:
- fprintf( pErr, "usage: gen [-N num] [-asmftrvh] <file>\n" );
- fprintf( pErr, "\t generates simple circuits\n" );
- fprintf( pErr, "\t-N num : the number of variables [default = %d]\n", nVars );
- fprintf( pErr, "\t-a : generate ripple-carry adder [default = %s]\n", fAdder? "yes": "no" );
- fprintf( pErr, "\t-s : generate a sorter [default = %s]\n", fSorter? "yes": "no" );
- fprintf( pErr, "\t-m : generate a mesh [default = %s]\n", fMesh? "yes": "no" );
- fprintf( pErr, "\t-f : generate a LUT FPGA structure [default = %s]\n", fFpga? "yes": "no" );
- fprintf( pErr, "\t-t : generate one-hotness conditions [default = %s]\n", fOneHot? "yes": "no" );
- fprintf( pErr, "\t-r : generate random single-output function [default = %s]\n", fRandom? "yes": "no" );
- fprintf( pErr, "\t-v : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
- fprintf( pErr, "\t<file> : output file name\n");
+ Abc_Print( -2, "usage: gen [-N num] [-asmftrvh] <file>\n" );
+ Abc_Print( -2, "\t generates simple circuits\n" );
+ Abc_Print( -2, "\t-N num : the number of variables [default = %d]\n", nVars );
+ Abc_Print( -2, "\t-a : generate ripple-carry adder [default = %s]\n", fAdder? "yes": "no" );
+ Abc_Print( -2, "\t-s : generate a sorter [default = %s]\n", fSorter? "yes": "no" );
+ Abc_Print( -2, "\t-m : generate a mesh [default = %s]\n", fMesh? "yes": "no" );
+ Abc_Print( -2, "\t-f : generate a LUT FPGA structure [default = %s]\n", fFpga? "yes": "no" );
+ Abc_Print( -2, "\t-t : generate one-hotness conditions [default = %s]\n", fOneHot? "yes": "no" );
+ Abc_Print( -2, "\t-r : generate random single-output function [default = %s]\n", fRandom? "yes": "no" );
+ Abc_Print( -2, "\t-v : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ Abc_Print( -2, "\t<file> : output file name\n");
return 1;
}
@@ -7979,7 +7880,6 @@ usage:
***********************************************************************/
int Abc_CommandCover( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c;
int fVerbose;
@@ -7987,11 +7887,7 @@ int Abc_CommandCover( Abc_Frame_t * pAbc, int argc, char ** argv )
int fUseEsop;
int fUseInvs;
int nFaninMax;
- extern Abc_Ntk_t * Abc_NtkSopEsopCover( Abc_Ntk_t * pNtk, int nFaninMax, bool fUseEsop, bool fUseSop, bool fUseInvs, bool fVerbose );
-
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
// set defaults
fUseSop = 1;
@@ -8007,7 +7903,7 @@ int Abc_CommandCover( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'N':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
goto usage;
}
nFaninMax = atoi(argv[globalUtilOptind]);
@@ -8035,13 +7931,13 @@ int Abc_CommandCover( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "Only works for strashed networks.\n" );
+ Abc_Print( -1, "Only works for strashed networks.\n" );
return 1;
}
@@ -8049,7 +7945,7 @@ int Abc_CommandCover( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtkRes = Abc_NtkSopEsopCover( pNtk, nFaninMax, fUseEsop, fUseSop, fUseInvs, fVerbose );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Command has failed.\n" );
+ Abc_Print( -1, "Command has failed.\n" );
return 0;
}
// replace the current network
@@ -8057,14 +7953,14 @@ int Abc_CommandCover( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: cover [-N num] [-sxvh]\n" );
- fprintf( pErr, "\t decomposition into a network of SOP/ESOP PLAs\n" );
- fprintf( pErr, "\t-N num : maximum number of inputs [default = %d]\n", nFaninMax );
- fprintf( pErr, "\t-s : toggle the use of SOPs [default = %s]\n", fUseSop? "yes": "no" );
- fprintf( pErr, "\t-x : toggle the use of ESOPs [default = %s]\n", fUseEsop? "yes": "no" );
-// fprintf( pErr, "\t-i : toggle the use of interters [default = %s]\n", fUseInvs? "yes": "no" );
- fprintf( pErr, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: cover [-N num] [-sxvh]\n" );
+ Abc_Print( -2, "\t decomposition into a network of SOP/ESOP PLAs\n" );
+ Abc_Print( -2, "\t-N num : maximum number of inputs [default = %d]\n", nFaninMax );
+ Abc_Print( -2, "\t-s : toggle the use of SOPs [default = %s]\n", fUseSop? "yes": "no" );
+ Abc_Print( -2, "\t-x : toggle the use of ESOPs [default = %s]\n", fUseEsop? "yes": "no" );
+// Abc_Print( -2, "\t-i : toggle the use of interters [default = %s]\n", fUseInvs? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -8081,7 +7977,6 @@ usage:
***********************************************************************/
int Abc_CommandInter( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtk1, * pNtk2, * pNtkRes = NULL;
char ** pArgvNew;
int nArgcNew;
@@ -8091,9 +7986,6 @@ int Abc_CommandInter( Abc_Frame_t * pAbc, int argc, char ** argv )
extern Abc_Ntk_t * Abc_NtkInter( Abc_Ntk_t * pNtkOn, Abc_Ntk_t * pNtkOff, int fRelation, int fVerbose );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fRelation = 0;
fVerbose = 0;
@@ -8117,20 +8009,20 @@ int Abc_CommandInter( Abc_Frame_t * pAbc, int argc, char ** argv )
pArgvNew = argv + globalUtilOptind;
nArgcNew = argc - globalUtilOptind;
- if ( !Abc_NtkPrepareTwoNtks( pErr, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
+ if ( !Abc_NtkPrepareTwoNtks( stdout, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
return 1;
if ( nArgcNew == 0 )
{
Abc_Obj_t * pObj;
int i;
- printf( "Deriving new circuit structure for the current network.\n" );
+ Abc_Print( -1, "Deriving new circuit structure for the current network.\n" );
Abc_NtkForEachPo( pNtk2, pObj, i )
Abc_ObjXorFaninC( pObj, 0 );
}
if ( fRelation && Abc_NtkCoNum(pNtk1) != 1 )
{
- printf( "Computation of interplants as a relation only works for single-output functions.\n" );
- printf( "Use command \"cone\" to extract one output cone from the multi-output network.\n" );
+ Abc_Print( -1, "Computation of interplants as a relation only works for single-output functions.\n" );
+ Abc_Print( -1, "Use command \"cone\" to extract one output cone from the multi-output network.\n" );
}
else
pNtkRes = Abc_NtkInter( pNtk1, pNtk2, fRelation, fVerbose );
@@ -8139,33 +8031,33 @@ int Abc_CommandInter( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Command has failed.\n" );
+ Abc_Print( -1, "Command has failed.\n" );
return 0;
}
Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
return 0;
usage:
- fprintf( pErr, "usage: inter [-rvh] <onset.blif> <offset.blif>\n" );
- fprintf( pErr, "\t derives interpolant of two networks representing onset and offset;\n" );
- fprintf( pErr, "\t-r : toggle computing interpolant as a relation [default = %s]\n", fRelation? "yes": "no" );
- fprintf( pErr, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
- fprintf( pErr, "\t \n" );
- fprintf( pErr, "\t Comments:\n" );
- fprintf( pErr, "\t \n" );
- fprintf( pErr, "\t The networks given on the command line should have the same CIs/COs.\n" );
- fprintf( pErr, "\t If only one network is given on the command line, this network\n" );
- fprintf( pErr, "\t is assumed to be the offset, while the current network is the onset.\n" );
- fprintf( pErr, "\t If no network is given on the command line, the current network is\n" );
- fprintf( pErr, "\t assumed to be the onset and its complement is taken to be the offset.\n" );
- fprintf( pErr, "\t The resulting interpolant is stored as the current network.\n" );
- fprintf( pErr, "\t To verify that the interpolant agrees with the onset and the offset,\n" );
- fprintf( pErr, "\t save it in file \"inter.blif\" and run the following:\n" );
- fprintf( pErr, "\t (a) \"miter -i <onset.blif> <inter.blif>; iprove\"\n" );
- fprintf( pErr, "\t (b) \"miter -i <inter.blif> <offset_inv.blif>; iprove\"\n" );
- fprintf( pErr, "\t where <offset_inv.blif> is the network derived by complementing the\n" );
- fprintf( pErr, "\t outputs of <offset.blif>: \"r <onset.blif>; st -i; w <offset_inv.blif>\"\n" );
+ Abc_Print( -2, "usage: inter [-rvh] <onset.blif> <offset.blif>\n" );
+ Abc_Print( -2, "\t derives interpolant of two networks representing onset and offset;\n" );
+ Abc_Print( -2, "\t-r : toggle computing interpolant as a relation [default = %s]\n", fRelation? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ Abc_Print( -2, "\t \n" );
+ Abc_Print( -2, "\t Comments:\n" );
+ Abc_Print( -2, "\t \n" );
+ Abc_Print( -2, "\t The networks given on the command line should have the same CIs/COs.\n" );
+ Abc_Print( -2, "\t If only one network is given on the command line, this network\n" );
+ Abc_Print( -2, "\t is assumed to be the offset, while the current network is the onset.\n" );
+ Abc_Print( -2, "\t If no network is given on the command line, the current network is\n" );
+ Abc_Print( -2, "\t assumed to be the onset and its complement is taken to be the offset.\n" );
+ Abc_Print( -2, "\t The resulting interpolant is stored as the current network.\n" );
+ Abc_Print( -2, "\t To verify that the interpolant agrees with the onset and the offset,\n" );
+ Abc_Print( -2, "\t save it in file \"inter.blif\" and run the following:\n" );
+ Abc_Print( -2, "\t (a) \"miter -i <onset.blif> <inter.blif>; iprove\"\n" );
+ Abc_Print( -2, "\t (b) \"miter -i <inter.blif> <offset_inv.blif>; iprove\"\n" );
+ Abc_Print( -2, "\t where <offset_inv.blif> is the network derived by complementing the\n" );
+ Abc_Print( -2, "\t outputs of <offset.blif>: \"r <onset.blif>; st -i; w <offset_inv.blif>\"\n" );
return 1;
}
@@ -8182,7 +8074,6 @@ usage:
***********************************************************************/
int Abc_CommandDouble( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c;
int nFrames;
@@ -8190,9 +8081,6 @@ int Abc_CommandDouble( Abc_Frame_t * pAbc, int argc, char ** argv )
extern Abc_Ntk_t * Abc_NtkDouble( Abc_Ntk_t * pNtk );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
nFrames = 50;
fVerbose = 0;
@@ -8204,7 +8092,7 @@ int Abc_CommandDouble( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
nFrames = atoi(argv[globalUtilOptind]);
@@ -8223,31 +8111,86 @@ int Abc_CommandDouble( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsSopLogic(pNtk) )
{
- fprintf( pErr, "Only works for logic SOP networks.\n" );
+ Abc_Print( -1, "Only works for logic SOP networks.\n" );
return 1;
}
pNtkRes = Abc_NtkDouble( pNtk );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Command has failed.\n" );
+ Abc_Print( -1, "Command has failed.\n" );
return 0;
}
Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
return 0;
usage:
- fprintf( pErr, "usage: double [-vh]\n" );
- fprintf( pErr, "\t puts together two parallel copies of the current network\n" );
-// fprintf( pErr, "\t-F num : the number of frames to simulate [default = %d]\n", nFrames );
- fprintf( pErr, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: double [-vh]\n" );
+ Abc_Print( -2, "\t puts together two parallel copies of the current network\n" );
+// Abc_Print( -2, "\t-F num : the number of frames to simulate [default = %d]\n", nFrames );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_CommandBb2Wb( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ extern void Abc_NtkConvertBb2Wb( char * pFileNameIn, char * pFileNameOut, int fSeq, int fVerbose );
+ int c;
+ int fSeq;
+ int fVerbose;
+ // set defaults
+ fSeq = 0;
+ fVerbose = 0;
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "svh" ) ) != EOF )
+ {
+ switch ( c )
+ {
+ case 's':
+ fSeq ^= 1;
+ break;
+ case 'v':
+ fVerbose ^= 1;
+ break;
+ default:
+ goto usage;
+ }
+ }
+ if ( argc != globalUtilOptind + 2 )
+ {
+ Abc_Print( -1, "Expecting two files names on the command line.\n" );
+ goto usage;
+ }
+ Abc_NtkConvertBb2Wb( argv[globalUtilOptind], argv[globalUtilOptind+1], fSeq, fVerbose );
+ return 0;
+
+usage:
+ Abc_Print( -2, "usage: bb2wb [-svh] <file_in> <file_out>\n" );
+ Abc_Print( -2, "\t replaces black boxes by white boxes with AND functions\n" );
+ Abc_Print( -2, "\t (file names should have standard extensions, e.g. \"blif\")\n" );
+ Abc_Print( -2, "\t-s : toggle using sequential white boxes [default = %s]\n", fSeq? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ Abc_Print( -2, "\t<file_in> : input file with design containing black boxes\n");
+ Abc_Print( -2, "\t<file_out> : output file with design containing white boxes\n");
return 1;
}
@@ -8264,8 +8207,7 @@ usage:
***********************************************************************/
int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
Abc_Ntk_t * pNtkRes = NULL;
int c;
int fBmc;
@@ -8302,10 +8244,10 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
extern Abc_Ntk_t * Abc_NtkCRetime( Abc_Ntk_t * pNtk, int fVerbose );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-// printf( "This command is temporarily disabled.\n" );
+
+
+// Abc_Print( -1, "This command is temporarily disabled.\n" );
// return 0;
// set defaults
@@ -8322,7 +8264,7 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
nFrames = atoi(argv[globalUtilOptind]);
@@ -8333,7 +8275,7 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'N':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
goto usage;
}
nLevels = atoi(argv[globalUtilOptind]);
@@ -8359,19 +8301,19 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
/*
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( Abc_NtkIsSeq(pNtk) )
{
- fprintf( pErr, "Only works for non-sequential networks.\n" );
+ Abc_Print( -1, "Only works for non-sequential networks.\n" );
return 1;
}
*/
// Abc_NtkTestEsop( pNtk );
// Abc_NtkTestSop( pNtk );
-// printf( "This command is currently not used.\n" );
+// Abc_Print( -1, "This command is currently not used.\n" );
// run the command
// pNtkRes = Abc_NtkMiterForCofactors( pNtk, 0, 0, -1 );
// pNtkRes = Abc_NtkNewAig( pNtk );
@@ -8380,7 +8322,7 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtkRes = NULL;
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Command has failed.\n" );
+ Abc_Print( -1, "Command has failed.\n" );
return 1;
}
// replace the current network
@@ -8414,7 +8356,7 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
// pNtkRes = NULL;
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Command has failed.\n" );
+ Abc_Print( -1, "Command has failed.\n" );
return 1;
}
// replace the current network
@@ -8439,21 +8381,21 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
/*
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "Network should be strashed. Command has failed.\n" );
+ Abc_Print( -1, "Network should be strashed. Command has failed.\n" );
return 1;
}
*/
/*
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( stdout, "Currently only works for structurally hashed circuits.\n" );
+ Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
return 0;
}
*/
/*
if ( Abc_NtkIsStrash(pNtk) )
{
- fprintf( stdout, "Currently only works for logic circuits.\n" );
+ Abc_Print( -1, "Currently only works for logic circuits.\n" );
return 0;
}
*/
@@ -8467,7 +8409,7 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
// pNtkRes = NULL;
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Command has failed.\n" );
+ Abc_Print( -1, "Command has failed.\n" );
return 1;
}
// replace the current network
@@ -8480,7 +8422,7 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
/*
if ( globalUtilOptind != 1 )
{
- fprintf( pErr, "Command has failed.\n" );
+ Abc_Print( -1, "Command has failed.\n" );
return 1;
}
Abc_NtkDarTestBlif( argv[globalUtilOptind] );
@@ -8488,13 +8430,15 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
// Abc_NtkDarPartition( pNtk );
//Abc_NtkDarTest( pNtk );
+//Abc_NtkWriteAig( pNtk, NULL );
+
/*
// pNtkRes = Abc_NtkDarRetimeStep( pNtk, 0 );
pNtkRes = Abc_NtkDarHaigRecord( pNtk, 3, 3000, 0, 0, 0, 0 );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Command has failed.\n" );
+ Abc_Print( -1, "Command has failed.\n" );
return 1;
}
// replace the current network
@@ -8505,7 +8449,7 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtkRes = Abc_NtkDarTestNtk( pNtk );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Command has failed.\n" );
+ Abc_Print( -1, "Command has failed.\n" );
return 1;
}
// replace the current network
@@ -8527,23 +8471,29 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
Aig_ManStop( pAig );
}
*/
+
+/*
// Bbl_ManSimpleDemo();
// pNtkRes = Abc_NtkCRetime( pNtk );
pNtkRes = NULL;
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Command has failed.\n" );
+ Abc_Print( -1, "Command has failed.\n" );
return 1;
}
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+*/
+
+// Abc_NtkHelloWorld( pNtk );
+
return 0;
usage:
- fprintf( pErr, "usage: test [-h] <file_name>\n" );
- fprintf( pErr, "\t testbench for new procedures\n" );
-// fprintf( pErr, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-// fprintf( pErr, "\t-w : toggle printing very verbose information [default = %s]\n", fVeryVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: test [-h] <file_name>\n" );
+ Abc_Print( -2, "\t testbench for new procedures\n" );
+// Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+// Abc_Print( -2, "\t-w : toggle printing very verbose information [default = %s]\n", fVeryVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -8560,15 +8510,11 @@ usage:
***********************************************************************/
int Abc_CommandQuaVar( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c, iVar, fUniv, fVerbose, RetValue;
extern int Abc_NtkQuantify( Abc_Ntk_t * pNtk, int fUniv, int iVar, int fVerbose );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
iVar = 0;
fUniv = 0;
@@ -8581,7 +8527,7 @@ int Abc_CommandQuaVar( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'I':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-I\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
goto usage;
}
iVar = atoi(argv[globalUtilOptind]);
@@ -8603,12 +8549,12 @@ int Abc_CommandQuaVar( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( Abc_NtkGetChoiceNum( pNtk ) )
{
- fprintf( pErr, "This command cannot be applied to an AIG with choice nodes.\n" );
+ Abc_Print( -1, "This command cannot be applied to an AIG with choice nodes.\n" );
return 1;
}
@@ -8617,11 +8563,11 @@ int Abc_CommandQuaVar( Abc_Frame_t * pAbc, int argc, char ** argv )
RetValue = Abc_NtkQuantify( pNtkRes, fUniv, iVar, fVerbose );
// clean temporary storage for the cofactors
Abc_NtkCleanData( pNtkRes );
- Abc_AigCleanup( pNtkRes->pManFunc );
+ Abc_AigCleanup( (Abc_Aig_t *)pNtkRes->pManFunc );
// check the result
if ( !RetValue )
{
- fprintf( pErr, "Command has failed.\n" );
+ Abc_Print( -1, "Command has failed.\n" );
return 0;
}
// replace the current network
@@ -8629,12 +8575,12 @@ int Abc_CommandQuaVar( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: qvar [-I num] [-uvh]\n" );
- fprintf( pErr, "\t quantifies one variable using the AIG\n" );
- fprintf( pErr, "\t-I num : the zero-based index of a variable to quantify [default = %d]\n", iVar );
- fprintf( pErr, "\t-u : toggle universal quantification [default = %s]\n", fUniv? "yes": "no" );
- fprintf( pErr, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: qvar [-I num] [-uvh]\n" );
+ Abc_Print( -2, "\t quantifies one variable using the AIG\n" );
+ Abc_Print( -2, "\t-I num : the zero-based index of a variable to quantify [default = %d]\n", iVar );
+ Abc_Print( -2, "\t-u : toggle universal quantification [default = %s]\n", fUniv? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -8651,15 +8597,11 @@ usage:
***********************************************************************/
int Abc_CommandQuaRel( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c, iVar, fInputs, fVerbose;
extern Abc_Ntk_t * Abc_NtkTransRel( Abc_Ntk_t * pNtk, int fInputs, int fVerbose );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
iVar = 0;
fInputs = 1;
@@ -8672,7 +8614,7 @@ int Abc_CommandQuaRel( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'I':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-I\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
goto usage;
}
iVar = atoi(argv[globalUtilOptind]);
@@ -8694,17 +8636,17 @@ int Abc_CommandQuaRel( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( Abc_NtkGetChoiceNum( pNtk ) )
{
- fprintf( pErr, "This command cannot be applied to an AIG with choice nodes.\n" );
+ Abc_Print( -1, "This command cannot be applied to an AIG with choice nodes.\n" );
return 1;
}
if ( Abc_NtkIsComb(pNtk) )
{
- fprintf( pErr, "This command works only for sequential circuits.\n" );
+ Abc_Print( -1, "This command works only for sequential circuits.\n" );
return 1;
}
@@ -8720,7 +8662,7 @@ int Abc_CommandQuaRel( Abc_Frame_t * pAbc, int argc, char ** argv )
// check if the result is available
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Command has failed.\n" );
+ Abc_Print( -1, "Command has failed.\n" );
return 0;
}
// replace the current network
@@ -8728,12 +8670,12 @@ int Abc_CommandQuaRel( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: qrel [-qvh]\n" );
- fprintf( pErr, "\t computes transition relation of the sequential network\n" );
-// fprintf( pErr, "\t-I num : the zero-based index of a variable to quantify [default = %d]\n", iVar );
- fprintf( pErr, "\t-q : perform quantification of inputs [default = %s]\n", fInputs? "yes": "no" );
- fprintf( pErr, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: qrel [-qvh]\n" );
+ Abc_Print( -2, "\t computes transition relation of the sequential network\n" );
+// Abc_Print( -2, "\t-I num : the zero-based index of a variable to quantify [default = %d]\n", iVar );
+ Abc_Print( -2, "\t-q : perform quantification of inputs [default = %s]\n", fInputs? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -8750,15 +8692,11 @@ usage:
***********************************************************************/
int Abc_CommandQuaReach( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c, nIters, fVerbose;
extern Abc_Ntk_t * Abc_NtkReachability( Abc_Ntk_t * pNtk, int nIters, int fVerbose );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
nIters = 256;
fVerbose = 0;
@@ -8770,7 +8708,7 @@ int Abc_CommandQuaReach( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'I':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-I\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
goto usage;
}
nIters = atoi(argv[globalUtilOptind]);
@@ -8789,39 +8727,39 @@ int Abc_CommandQuaReach( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( Abc_NtkGetChoiceNum( pNtk ) )
{
- fprintf( pErr, "This command cannot be applied to an AIG with choice nodes.\n" );
+ Abc_Print( -1, "This command cannot be applied to an AIG with choice nodes.\n" );
return 1;
}
if ( !Abc_NtkIsComb(pNtk) )
{
- fprintf( pErr, "This command works only for combinational transition relations.\n" );
+ Abc_Print( -1, "This command works only for combinational transition relations.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "This command works only for strashed networks.\n" );
+ Abc_Print( -1, "This command works only for strashed networks.\n" );
return 1;
}
if ( Abc_NtkPoNum(pNtk) > 1 )
{
- fprintf( pErr, "The transition relation should have one output.\n" );
+ Abc_Print( -1, "The transition relation should have one output.\n" );
return 1;
}
if ( Abc_NtkPiNum(pNtk) % 2 != 0 )
{
- fprintf( pErr, "The transition relation should have an even number of inputs.\n" );
+ Abc_Print( -1, "The transition relation should have an even number of inputs.\n" );
return 1;
}
pNtkRes = Abc_NtkReachability( pNtk, nIters, fVerbose );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Command has failed.\n" );
+ Abc_Print( -1, "Command has failed.\n" );
return 0;
}
// replace the current network
@@ -8829,13 +8767,13 @@ int Abc_CommandQuaReach( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: qreach [-I num] [-vh]\n" );
- fprintf( pErr, "\t computes unreachable states using AIG-based quantification\n" );
- fprintf( pErr, "\t assumes that the current network is a transition relation\n" );
- fprintf( pErr, "\t assumes that the initial state is composed of all zeros\n" );
- fprintf( pErr, "\t-I num : the number of image computations to perform [default = %d]\n", nIters );
- fprintf( pErr, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: qreach [-I num] [-vh]\n" );
+ Abc_Print( -2, "\t computes unreachable states using AIG-based quantification\n" );
+ Abc_Print( -2, "\t assumes that the current network is a transition relation\n" );
+ Abc_Print( -2, "\t assumes that the initial state is composed of all zeros\n" );
+ Abc_Print( -2, "\t-I num : the number of image computations to perform [default = %d]\n", nIters );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -8852,17 +8790,11 @@ usage:
***********************************************************************/
int Abc_CommandSenseInput( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
Vec_Int_t * vResult;
int c, nConfLim, fVerbose;
extern Vec_Int_t * Abc_NtkSensitivity( Abc_Ntk_t * pNtk, int nConfLim, int fVerbose );
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
nConfLim = 1000;
fVerbose = 1;
@@ -8874,7 +8806,7 @@ int Abc_CommandSenseInput( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
nConfLim = atoi(argv[globalUtilOptind]);
@@ -8893,27 +8825,27 @@ int Abc_CommandSenseInput( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( Abc_NtkGetChoiceNum( pNtk ) )
{
- fprintf( pErr, "This command cannot be applied to an AIG with choice nodes.\n" );
+ Abc_Print( -1, "This command cannot be applied to an AIG with choice nodes.\n" );
return 1;
}
if ( !Abc_NtkIsComb(pNtk) )
{
- fprintf( pErr, "This command works only for combinational transition relations.\n" );
+ Abc_Print( -1, "This command works only for combinational transition relations.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "This command works only for strashed networks.\n" );
+ Abc_Print( -1, "This command works only for strashed networks.\n" );
return 1;
}
if ( Abc_NtkPoNum(pNtk) < 2 )
{
- fprintf( pErr, "The network should have at least two outputs.\n" );
+ Abc_Print( -1, "The network should have at least two outputs.\n" );
return 1;
}
@@ -8922,12 +8854,12 @@ int Abc_CommandSenseInput( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: senseinput [-C num] [-vh]\n" );
- fprintf( pErr, "\t computes sensitivity of POs to PIs under constraint\n" );
- fprintf( pErr, "\t constraint should be represented as the last PO" );
- fprintf( pErr, "\t-C num : the max number of conflicts at a node [default = %d]\n", nConfLim );
- fprintf( pErr, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: senseinput [-C num] [-vh]\n" );
+ Abc_Print( -2, "\t computes sensitivity of POs to PIs under constraint\n" );
+ Abc_Print( -2, "\t constraint should be represented as the last PO" );
+ Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", nConfLim );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -8945,15 +8877,11 @@ usage:
***********************************************************************/
int Abc_CommandIStrash( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes, * pNtkTemp;
int c;
extern Abc_Ntk_t * Abc_NtkIvyStrash( Abc_Ntk_t * pNtk );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
@@ -8968,7 +8896,7 @@ int Abc_CommandIStrash( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
@@ -8981,7 +8909,7 @@ int Abc_CommandIStrash( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtkRes = Abc_NtkIvyStrash( pNtk );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Command has failed.\n" );
+ Abc_Print( -1, "Command has failed.\n" );
return 0;
}
// replace the current network
@@ -8989,9 +8917,9 @@ int Abc_CommandIStrash( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: istrash [-h]\n" );
- fprintf( pErr, "\t perform sequential structural hashing\n" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: istrash [-h]\n" );
+ Abc_Print( -2, "\t perform sequential structural hashing\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -9008,15 +8936,10 @@ usage:
***********************************************************************/
int Abc_CommandICut( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c, nInputs;
extern void Abc_NtkIvyCuts( Abc_Ntk_t * pNtk, int nInputs );
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
nInputs = 5;
Extra_UtilGetoptReset();
@@ -9027,7 +8950,7 @@ int Abc_CommandICut( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'K':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-K\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
goto usage;
}
nInputs = atoi(argv[globalUtilOptind]);
@@ -9043,12 +8966,12 @@ int Abc_CommandICut( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "This command works only for strashed networks.\n" );
+ Abc_Print( -1, "This command works only for strashed networks.\n" );
return 1;
}
@@ -9056,10 +8979,10 @@ int Abc_CommandICut( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: icut [-K num] [-h]\n" );
- fprintf( pErr, "\t computes sequential cuts of the given size\n" );
- fprintf( pErr, "\t-K num : the number of cut inputs (2 <= num <= 6) [default = %d]\n", nInputs );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: icut [-K num] [-h]\n" );
+ Abc_Print( -2, "\t computes sequential cuts of the given size\n" );
+ Abc_Print( -2, "\t-K num : the number of cut inputs (2 <= num <= 6) [default = %d]\n", nInputs );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -9076,15 +8999,11 @@ usage:
***********************************************************************/
int Abc_CommandIRewrite( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c, fUpdateLevel, fUseZeroCost, fVerbose;
extern Abc_Ntk_t * Abc_NtkIvyRewrite( Abc_Ntk_t * pNtk, int fUpdateLevel, int fUseZeroCost, int fVerbose );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fUpdateLevel = 1;
fUseZeroCost = 0;
@@ -9111,19 +9030,19 @@ int Abc_CommandIRewrite( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "This command works only for strashed networks.\n" );
+ Abc_Print( -1, "This command works only for strashed networks.\n" );
return 1;
}
pNtkRes = Abc_NtkIvyRewrite( pNtk, fUpdateLevel, fUseZeroCost, fVerbose );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Command has failed.\n" );
+ Abc_Print( -1, "Command has failed.\n" );
return 0;
}
// replace the current network
@@ -9131,12 +9050,12 @@ int Abc_CommandIRewrite( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: irw [-lzvh]\n" );
- fprintf( pErr, "\t perform combinational AIG rewriting\n" );
- fprintf( pErr, "\t-l : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
- fprintf( pErr, "\t-z : toggle using zero-cost replacements [default = %s]\n", fUseZeroCost? "yes": "no" );
- fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: irw [-lzvh]\n" );
+ Abc_Print( -2, "\t perform combinational AIG rewriting\n" );
+ Abc_Print( -2, "\t-l : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
+ Abc_Print( -2, "\t-z : toggle using zero-cost replacements [default = %s]\n", fUseZeroCost? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -9153,7 +9072,6 @@ usage:
***********************************************************************/
int Abc_CommandDRewrite( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
Dar_RwrPar_t Pars, * pPars = &Pars;
int c;
@@ -9161,9 +9079,6 @@ int Abc_CommandDRewrite( Abc_Frame_t * pAbc, int argc, char ** argv )
extern Abc_Ntk_t * Abc_NtkDRewrite( Abc_Ntk_t * pNtk, Dar_RwrPar_t * pPars );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Dar_ManDefaultRwrParams( pPars );
Extra_UtilGetoptReset();
@@ -9174,7 +9089,7 @@ int Abc_CommandDRewrite( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
pPars->nCutsMax = atoi(argv[globalUtilOptind]);
@@ -9185,7 +9100,7 @@ int Abc_CommandDRewrite( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'N':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
goto usage;
}
pPars->nSubgMax = atoi(argv[globalUtilOptind]);
@@ -9219,18 +9134,18 @@ int Abc_CommandDRewrite( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "This command works only for strashed networks.\n" );
+ Abc_Print( -1, "This command works only for strashed networks.\n" );
return 1;
}
pNtkRes = Abc_NtkDRewrite( pNtk, pPars );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Command has failed.\n" );
+ Abc_Print( -1, "Command has failed.\n" );
return 0;
}
// replace the current network
@@ -9238,17 +9153,17 @@ int Abc_CommandDRewrite( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: drw [-C num] [-N num] [-lfzrvwh]\n" );
- fprintf( pErr, "\t performs combinational AIG rewriting\n" );
- fprintf( pErr, "\t-C num : the max number of cuts at a node [default = %d]\n", pPars->nCutsMax );
- fprintf( pErr, "\t-N num : the max number of subgraphs tried [default = %d]\n", pPars->nSubgMax );
- fprintf( pErr, "\t-l : toggle preserving the number of levels [default = %s]\n", pPars->fUpdateLevel? "yes": "no" );
- fprintf( pErr, "\t-f : toggle representing fanouts [default = %s]\n", pPars->fFanout? "yes": "no" );
- fprintf( pErr, "\t-z : toggle using zero-cost replacements [default = %s]\n", pPars->fUseZeros? "yes": "no" );
- fprintf( pErr, "\t-r : toggle using cut recycling [default = %s]\n", pPars->fRecycle? "yes": "no" );
- fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", pPars->fVerbose? "yes": "no" );
- fprintf( pErr, "\t-w : toggle very verbose printout [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: drw [-C num] [-N num] [-lfzrvwh]\n" );
+ Abc_Print( -2, "\t performs combinational AIG rewriting\n" );
+ Abc_Print( -2, "\t-C num : the max number of cuts at a node [default = %d]\n", pPars->nCutsMax );
+ Abc_Print( -2, "\t-N num : the max number of subgraphs tried [default = %d]\n", pPars->nSubgMax );
+ Abc_Print( -2, "\t-l : toggle preserving the number of levels [default = %s]\n", pPars->fUpdateLevel? "yes": "no" );
+ Abc_Print( -2, "\t-f : toggle representing fanouts [default = %s]\n", pPars->fFanout? "yes": "no" );
+ Abc_Print( -2, "\t-z : toggle using zero-cost replacements [default = %s]\n", pPars->fUseZeros? "yes": "no" );
+ Abc_Print( -2, "\t-r : toggle using cut recycling [default = %s]\n", pPars->fRecycle? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-w : toggle very verbose printout [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -9265,7 +9180,6 @@ usage:
***********************************************************************/
int Abc_CommandDRefactor( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
Dar_RefPar_t Pars, * pPars = &Pars;
int c;
@@ -9273,9 +9187,6 @@ int Abc_CommandDRefactor( Abc_Frame_t * pAbc, int argc, char ** argv )
extern Abc_Ntk_t * Abc_NtkDRefactor( Abc_Ntk_t * pNtk, Dar_RefPar_t * pPars );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Dar_ManDefaultRefParams( pPars );
Extra_UtilGetoptReset();
@@ -9286,7 +9197,7 @@ int Abc_CommandDRefactor( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'M':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
pPars->nMffcMin = atoi(argv[globalUtilOptind]);
@@ -9297,7 +9208,7 @@ int Abc_CommandDRefactor( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'K':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
goto usage;
}
pPars->nLeafMax = atoi(argv[globalUtilOptind]);
@@ -9308,7 +9219,7 @@ int Abc_CommandDRefactor( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
pPars->nCutsMax = atoi(argv[globalUtilOptind]);
@@ -9339,23 +9250,23 @@ int Abc_CommandDRefactor( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "This command works only for strashed networks.\n" );
+ Abc_Print( -1, "This command works only for strashed networks.\n" );
return 1;
}
if ( pPars->nLeafMax < 4 || pPars->nLeafMax > 15 )
{
- fprintf( pErr, "This command only works for cut sizes 4 <= K <= 15.\n" );
+ Abc_Print( -1, "This command only works for cut sizes 4 <= K <= 15.\n" );
return 1;
}
pNtkRes = Abc_NtkDRefactor( pNtk, pPars );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Command has failed.\n" );
+ Abc_Print( -1, "Command has failed.\n" );
return 0;
}
// replace the current network
@@ -9363,17 +9274,17 @@ int Abc_CommandDRefactor( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: drf [-M num] [-K num] [-C num] [-elzvwh]\n" );
- fprintf( pErr, "\t performs combinational AIG refactoring\n" );
- fprintf( pErr, "\t-M num : the min MFFC size to attempt refactoring [default = %d]\n", pPars->nMffcMin );
- fprintf( pErr, "\t-K num : the max number of cuts leaves [default = %d]\n", pPars->nLeafMax );
- fprintf( pErr, "\t-C num : the max number of cuts to try at a node [default = %d]\n", pPars->nCutsMax );
- fprintf( pErr, "\t-e : toggle extending tbe cut below MFFC [default = %s]\n", pPars->fExtend? "yes": "no" );
- fprintf( pErr, "\t-l : toggle preserving the number of levels [default = %s]\n", pPars->fUpdateLevel? "yes": "no" );
- fprintf( pErr, "\t-z : toggle using zero-cost replacements [default = %s]\n", pPars->fUseZeros? "yes": "no" );
- fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", pPars->fVerbose? "yes": "no" );
- fprintf( pErr, "\t-w : toggle very verbose printout [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: drf [-M num] [-K num] [-C num] [-elzvwh]\n" );
+ Abc_Print( -2, "\t performs combinational AIG refactoring\n" );
+ Abc_Print( -2, "\t-M num : the min MFFC size to attempt refactoring [default = %d]\n", pPars->nMffcMin );
+ Abc_Print( -2, "\t-K num : the max number of cuts leaves [default = %d]\n", pPars->nLeafMax );
+ Abc_Print( -2, "\t-C num : the max number of cuts to try at a node [default = %d]\n", pPars->nCutsMax );
+ Abc_Print( -2, "\t-e : toggle extending tbe cut below MFFC [default = %s]\n", pPars->fExtend? "yes": "no" );
+ Abc_Print( -2, "\t-l : toggle preserving the number of levels [default = %s]\n", pPars->fUpdateLevel? "yes": "no" );
+ Abc_Print( -2, "\t-z : toggle using zero-cost replacements [default = %s]\n", pPars->fUseZeros? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-w : toggle very verbose printout [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -9388,18 +9299,14 @@ usage:
SeeAlso []
***********************************************************************/
-int Abc_CommandDC2( Abc_Frame_t * pAbc, int argc, char ** argv )
+int Abc_CommandDc2( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int fBalance, fVerbose, fUpdateLevel, fFanout, fPower, c;
extern Abc_Ntk_t * Abc_NtkDC2( Abc_Ntk_t * pNtk, int fBalance, int fUpdateLevel, int fFanout, int fPower, int fVerbose );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fBalance = 0;
fVerbose = 0;
@@ -9434,18 +9341,18 @@ int Abc_CommandDC2( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "This command works only for strashed networks.\n" );
+ Abc_Print( -1, "This command works only for strashed networks.\n" );
return 1;
}
pNtkRes = Abc_NtkDC2( pNtk, fBalance, fUpdateLevel, fFanout, fPower, fVerbose );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Command has failed.\n" );
+ Abc_Print( -1, "Command has failed.\n" );
return 0;
}
// replace the current network
@@ -9453,14 +9360,14 @@ int Abc_CommandDC2( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: dc2 [-blfpvh]\n" );
- fprintf( pErr, "\t performs combinational AIG optimization\n" );
- fprintf( pErr, "\t-b : toggle internal balancing [default = %s]\n", fBalance? "yes": "no" );
- fprintf( pErr, "\t-l : toggle updating level [default = %s]\n", fUpdateLevel? "yes": "no" );
- fprintf( pErr, "\t-f : toggle representing fanouts [default = %s]\n", fFanout? "yes": "no" );
- fprintf( pErr, "\t-p : toggle power-aware rewriting [default = %s]\n", fPower? "yes": "no" );
- fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: dc2 [-blfpvh]\n" );
+ Abc_Print( -2, "\t performs combinational AIG optimization\n" );
+ Abc_Print( -2, "\t-b : toggle internal balancing [default = %s]\n", fBalance? "yes": "no" );
+ Abc_Print( -2, "\t-l : toggle updating level [default = %s]\n", fUpdateLevel? "yes": "no" );
+ Abc_Print( -2, "\t-f : toggle representing fanouts [default = %s]\n", fFanout? "yes": "no" );
+ Abc_Print( -2, "\t-p : toggle power-aware rewriting [default = %s]\n", fPower? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -9478,7 +9385,6 @@ usage:
***********************************************************************/
int Abc_CommandDChoice( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int fBalance, fVerbose, fUpdateLevel, fConstruct, c;
int nConfMax, nLevelMax;
@@ -9486,9 +9392,6 @@ int Abc_CommandDChoice( Abc_Frame_t * pAbc, int argc, char ** argv )
extern Abc_Ntk_t * Abc_NtkDChoice( Abc_Ntk_t * pNtk, int fBalance, int fUpdateLevel, int fConstruct, int nConfMax, int nLevelMax, int fVerbose );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fBalance = 1;
fUpdateLevel = 1;
@@ -9504,7 +9407,7 @@ int Abc_CommandDChoice( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
nConfMax = atoi(argv[globalUtilOptind]);
@@ -9515,7 +9418,7 @@ int Abc_CommandDChoice( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'L':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-L\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
goto usage;
}
nLevelMax = atoi(argv[globalUtilOptind]);
@@ -9543,18 +9446,18 @@ int Abc_CommandDChoice( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "This command works only for strashed networks.\n" );
+ Abc_Print( -1, "This command works only for strashed networks.\n" );
return 1;
}
pNtkRes = Abc_NtkDChoice( pNtk, fBalance, fUpdateLevel, fConstruct, nConfMax, nLevelMax, fVerbose );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Command has failed.\n" );
+ Abc_Print( -1, "Command has failed.\n" );
return 0;
}
// replace the current network
@@ -9562,15 +9465,15 @@ int Abc_CommandDChoice( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: dchoice [-C num] [-L num] [-blcvh]\n" );
- fprintf( pErr, "\t performs partitioned choicing using new AIG package\n" );
- fprintf( pErr, "\t-C num : the max number of conflicts at a node [default = %d]\n", nConfMax );
- fprintf( pErr, "\t-L num : the max level of nodes to consider (0 = not used) [default = %d]\n", nLevelMax );
- fprintf( pErr, "\t-b : toggle internal balancing [default = %s]\n", fBalance? "yes": "no" );
- fprintf( pErr, "\t-l : toggle updating level [default = %s]\n", fUpdateLevel? "yes": "no" );
- fprintf( pErr, "\t-c : toggle constructive computation of choices [default = %s]\n", fConstruct? "yes": "no" );
- fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: dchoice [-C num] [-L num] [-blcvh]\n" );
+ Abc_Print( -2, "\t performs partitioned choicing using new AIG package\n" );
+ Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", nConfMax );
+ Abc_Print( -2, "\t-L num : the max level of nodes to consider (0 = not used) [default = %d]\n", nLevelMax );
+ Abc_Print( -2, "\t-b : toggle internal balancing [default = %s]\n", fBalance? "yes": "no" );
+ Abc_Print( -2, "\t-l : toggle updating level [default = %s]\n", fUpdateLevel? "yes": "no" );
+ Abc_Print( -2, "\t-c : toggle constructive computation of choices [default = %s]\n", fConstruct? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -9588,15 +9491,11 @@ usage:
int Abc_CommandDch( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Dch_Pars_t Pars, * pPars = &Pars;
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c;
extern Abc_Ntk_t * Abc_NtkDch( Abc_Ntk_t * pNtk, Dch_Pars_t * pPars );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Dch_ManSetDefaultParams( pPars );
Extra_UtilGetoptReset();
@@ -9607,7 +9506,7 @@ int Abc_CommandDch( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'W':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-W\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
goto usage;
}
pPars->nWords = atoi(argv[globalUtilOptind]);
@@ -9618,7 +9517,7 @@ int Abc_CommandDch( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
pPars->nBTLimit = atoi(argv[globalUtilOptind]);
@@ -9629,7 +9528,7 @@ int Abc_CommandDch( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'S':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-S\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
goto usage;
}
pPars->nSatVarMax = atoi(argv[globalUtilOptind]);
@@ -9666,18 +9565,18 @@ int Abc_CommandDch( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "This command works only for strashed networks.\n" );
+ Abc_Print( -1, "This command works only for strashed networks.\n" );
return 1;
}
pNtkRes = Abc_NtkDch( pNtk, pPars );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Command has failed.\n" );
+ Abc_Print( -1, "Command has failed.\n" );
return 0;
}
// replace the current network
@@ -9685,19 +9584,19 @@ int Abc_CommandDch( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: dch [-WCS num] [-sptgcfvh]\n" );
- fprintf( pErr, "\t computes structural choices using a new approach\n" );
- fprintf( pErr, "\t-W num : the max number of simulation words [default = %d]\n", pPars->nWords );
- fprintf( pErr, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
- fprintf( pErr, "\t-S num : the max number of SAT variables [default = %d]\n", pPars->nSatVarMax );
- fprintf( pErr, "\t-s : toggle synthesizing three snapshots [default = %s]\n", pPars->fSynthesis? "yes": "no" );
- fprintf( pErr, "\t-p : toggle power-aware rewriting [default = %s]\n", pPars->fPower? "yes": "no" );
- fprintf( pErr, "\t-t : toggle simulation of the TFO classes [default = %s]\n", pPars->fSimulateTfo? "yes": "no" );
- fprintf( pErr, "\t-g : toggle using GIA to prove equivalences [default = %s]\n", pPars->fUseGia? "yes": "no" );
- fprintf( pErr, "\t-c : toggle using circuit-based SAT vs. MiniSat [default = %s]\n", pPars->fUseCSat? "yes": "no" );
- fprintf( pErr, "\t-f : toggle using faster logic synthesis [default = %s]\n", pPars->fLightSynth? "yes": "no" );
- fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", pPars->fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: dch [-WCS num] [-sptgcfvh]\n" );
+ Abc_Print( -2, "\t computes structural choices using a new approach\n" );
+ Abc_Print( -2, "\t-W num : the max number of simulation words [default = %d]\n", pPars->nWords );
+ Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
+ Abc_Print( -2, "\t-S num : the max number of SAT variables [default = %d]\n", pPars->nSatVarMax );
+ Abc_Print( -2, "\t-s : toggle synthesizing three snapshots [default = %s]\n", pPars->fSynthesis? "yes": "no" );
+ Abc_Print( -2, "\t-p : toggle power-aware rewriting [default = %s]\n", pPars->fPower? "yes": "no" );
+ Abc_Print( -2, "\t-t : toggle simulation of the TFO classes [default = %s]\n", pPars->fSimulateTfo? "yes": "no" );
+ Abc_Print( -2, "\t-g : toggle using GIA to prove equivalences [default = %s]\n", pPars->fUseGia? "yes": "no" );
+ Abc_Print( -2, "\t-c : toggle using circuit-based SAT vs. MiniSat [default = %s]\n", pPars->fUseCSat? "yes": "no" );
+ Abc_Print( -2, "\t-f : toggle using faster logic synthesis [default = %s]\n", pPars->fLightSynth? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -9714,16 +9613,12 @@ usage:
***********************************************************************/
int Abc_CommandDrwsat( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int fBalance, fVerbose, c;
extern Abc_Ntk_t * Abc_NtkDrwsat( Abc_Ntk_t * pNtk, int fBalance, int fVerbose );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fBalance = 0;
fVerbose = 0;
@@ -9746,18 +9641,18 @@ int Abc_CommandDrwsat( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "This command works only for strashed networks.\n" );
+ Abc_Print( -1, "This command works only for strashed networks.\n" );
return 1;
}
pNtkRes = Abc_NtkDrwsat( pNtk, fBalance, fVerbose );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Command has failed.\n" );
+ Abc_Print( -1, "Command has failed.\n" );
return 0;
}
// replace the current network
@@ -9765,11 +9660,11 @@ int Abc_CommandDrwsat( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: drwsat [-bvh]\n" );
- fprintf( pErr, "\t performs combinational AIG optimization for SAT\n" );
- fprintf( pErr, "\t-b : toggle internal balancing [default = %s]\n", fBalance? "yes": "no" );
- fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: drwsat [-bvh]\n" );
+ Abc_Print( -2, "\t performs combinational AIG optimization for SAT\n" );
+ Abc_Print( -2, "\t-b : toggle internal balancing [default = %s]\n", fBalance? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -9786,15 +9681,11 @@ usage:
***********************************************************************/
int Abc_CommandIRewriteSeq( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c, fUpdateLevel, fUseZeroCost, fVerbose;
extern Abc_Ntk_t * Abc_NtkIvyRewriteSeq( Abc_Ntk_t * pNtk, int fUseZeroCost, int fVerbose );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fUpdateLevel = 0;
fUseZeroCost = 0;
@@ -9821,19 +9712,19 @@ int Abc_CommandIRewriteSeq( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "This command works only for strashed networks.\n" );
+ Abc_Print( -1, "This command works only for strashed networks.\n" );
return 1;
}
pNtkRes = Abc_NtkIvyRewriteSeq( pNtk, fUseZeroCost, fVerbose );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Command has failed.\n" );
+ Abc_Print( -1, "Command has failed.\n" );
return 0;
}
// replace the current network
@@ -9841,12 +9732,12 @@ int Abc_CommandIRewriteSeq( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: irws [-zvh]\n" );
- fprintf( pErr, "\t perform sequential AIG rewriting\n" );
-// fprintf( pErr, "\t-l : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
- fprintf( pErr, "\t-z : toggle using zero-cost replacements [default = %s]\n", fUseZeroCost? "yes": "no" );
- fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: irws [-zvh]\n" );
+ Abc_Print( -2, "\t perform sequential AIG rewriting\n" );
+// Abc_Print( -2, "\t-l : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
+ Abc_Print( -2, "\t-z : toggle using zero-cost replacements [default = %s]\n", fUseZeroCost? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -9863,15 +9754,11 @@ usage:
***********************************************************************/
int Abc_CommandIResyn( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c, fUpdateLevel, fVerbose;
extern Abc_Ntk_t * Abc_NtkIvyResyn( Abc_Ntk_t * pNtk, int fUpdateLevel, int fVerbose );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fUpdateLevel = 1;
fVerbose = 0;
@@ -9894,19 +9781,19 @@ int Abc_CommandIResyn( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "This command works only for strashed networks.\n" );
+ Abc_Print( -1, "This command works only for strashed networks.\n" );
return 1;
}
pNtkRes = Abc_NtkIvyResyn( pNtk, fUpdateLevel, fVerbose );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Command has failed.\n" );
+ Abc_Print( -1, "Command has failed.\n" );
return 0;
}
// replace the current network
@@ -9914,11 +9801,11 @@ int Abc_CommandIResyn( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: iresyn [-lvh]\n" );
- fprintf( pErr, "\t performs combinational resynthesis\n" );
- fprintf( pErr, "\t-l : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
- fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: iresyn [-lvh]\n" );
+ Abc_Print( -2, "\t performs combinational resynthesis\n" );
+ Abc_Print( -2, "\t-l : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -9935,7 +9822,6 @@ usage:
***********************************************************************/
int Abc_CommandISat( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c, fUpdateLevel, fVerbose;
int nConfLimit;
@@ -9943,9 +9829,6 @@ int Abc_CommandISat( Abc_Frame_t * pAbc, int argc, char ** argv )
extern Abc_Ntk_t * Abc_NtkIvySat( Abc_Ntk_t * pNtk, int nConfLimit, int fVerbose );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
nConfLimit = 100000;
fUpdateLevel = 1;
@@ -9958,7 +9841,7 @@ int Abc_CommandISat( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
nConfLimit = atoi(argv[globalUtilOptind]);
@@ -9980,19 +9863,19 @@ int Abc_CommandISat( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "This command works only for strashed networks.\n" );
+ Abc_Print( -1, "This command works only for strashed networks.\n" );
return 1;
}
pNtkRes = Abc_NtkIvySat( pNtk, nConfLimit, fVerbose );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Command has failed.\n" );
+ Abc_Print( -1, "Command has failed.\n" );
return 0;
}
// replace the current network
@@ -10000,12 +9883,12 @@ int Abc_CommandISat( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: isat [-C num] [-vh]\n" );
- fprintf( pErr, "\t tries to prove the miter constant 0\n" );
- fprintf( pErr, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfLimit );
-// fprintf( pErr, "\t-l : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
- fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: isat [-C num] [-vh]\n" );
+ Abc_Print( -2, "\t tries to prove the miter constant 0\n" );
+ Abc_Print( -2, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfLimit );
+// Abc_Print( -2, "\t-l : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -10022,7 +9905,6 @@ usage:
***********************************************************************/
int Abc_CommandIFraig( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c, fProve, fVerbose, fDoSparse;
int nConfLimit;
@@ -10033,9 +9915,6 @@ int Abc_CommandIFraig( Abc_Frame_t * pAbc, int argc, char ** argv )
extern Abc_Ntk_t * Abc_NtkDarFraigPart( Abc_Ntk_t * pNtk, int nPartSize, int nConfLimit, int nLevelMax, int fVerbose );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
nPartSize = 0;
nLevelMax = 0;
@@ -10051,7 +9930,7 @@ int Abc_CommandIFraig( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'P':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-P\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
goto usage;
}
nPartSize = atoi(argv[globalUtilOptind]);
@@ -10062,7 +9941,7 @@ int Abc_CommandIFraig( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
nConfLimit = atoi(argv[globalUtilOptind]);
@@ -10073,7 +9952,7 @@ int Abc_CommandIFraig( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'L':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-L\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
goto usage;
}
nLevelMax = atoi(argv[globalUtilOptind]);
@@ -10098,12 +9977,12 @@ int Abc_CommandIFraig( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "This command works only for strashed networks.\n" );
+ Abc_Print( -1, "This command works only for strashed networks.\n" );
return 1;
}
@@ -10113,7 +9992,7 @@ int Abc_CommandIFraig( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtkRes = Abc_NtkIvyFraig( pNtk, nConfLimit, fDoSparse, fProve, 0, fVerbose );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Command has failed.\n" );
+ Abc_Print( -1, "Command has failed.\n" );
return 0;
}
// replace the current network
@@ -10121,15 +10000,15 @@ int Abc_CommandIFraig( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: ifraig [-P num] [-C num] [-L num] [-spvh]\n" );
- fprintf( pErr, "\t performs fraiging using a new method\n" );
- fprintf( pErr, "\t-P num : partition size (0 = partitioning is not used) [default = %d]\n", nPartSize );
- fprintf( pErr, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfLimit );
- fprintf( pErr, "\t-L num : limit on node level to fraig (0 = fraig all nodes) [default = %d]\n", nLevelMax );
- fprintf( pErr, "\t-s : toggle considering sparse functions [default = %s]\n", fDoSparse? "yes": "no" );
- fprintf( pErr, "\t-p : toggle proving the miter outputs [default = %s]\n", fProve? "yes": "no" );
- fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: ifraig [-P num] [-C num] [-L num] [-spvh]\n" );
+ Abc_Print( -2, "\t performs fraiging using a new method\n" );
+ Abc_Print( -2, "\t-P num : partition size (0 = partitioning is not used) [default = %d]\n", nPartSize );
+ Abc_Print( -2, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfLimit );
+ Abc_Print( -2, "\t-L num : limit on node level to fraig (0 = fraig all nodes) [default = %d]\n", nLevelMax );
+ Abc_Print( -2, "\t-s : toggle considering sparse functions [default = %s]\n", fDoSparse? "yes": "no" );
+ Abc_Print( -2, "\t-p : toggle proving the miter outputs [default = %s]\n", fProve? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -10146,16 +10025,12 @@ usage:
***********************************************************************/
int Abc_CommandDFraig( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c, nConfLimit, fDoSparse, fProve, fSpeculate, fChoicing, fVerbose;
extern Abc_Ntk_t * Abc_NtkDarFraig( Abc_Ntk_t * pNtk, int nConfLimit, int fDoSparse, int fProve, int fTransfer, int fSpeculate, int fChoicing, int fVerbose );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
nConfLimit = 100;
fDoSparse = 1;
@@ -10171,7 +10046,7 @@ int Abc_CommandDFraig( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
nConfLimit = atoi(argv[globalUtilOptind]);
@@ -10202,19 +10077,19 @@ int Abc_CommandDFraig( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "This command works only for strashed networks.\n" );
+ Abc_Print( -1, "This command works only for strashed networks.\n" );
return 1;
}
pNtkRes = Abc_NtkDarFraig( pNtk, nConfLimit, fDoSparse, fProve, 0, fSpeculate, fChoicing, fVerbose );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Command has failed.\n" );
+ Abc_Print( -1, "Command has failed.\n" );
return 0;
}
// replace the current network
@@ -10222,15 +10097,15 @@ int Abc_CommandDFraig( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: dfraig [-C num] [-sprcvh]\n" );
- fprintf( pErr, "\t performs fraiging using a new method\n" );
- fprintf( pErr, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfLimit );
- fprintf( pErr, "\t-s : toggle considering sparse functions [default = %s]\n", fDoSparse? "yes": "no" );
- fprintf( pErr, "\t-p : toggle proving the miter outputs [default = %s]\n", fProve? "yes": "no" );
- fprintf( pErr, "\t-r : toggle speculative reduction [default = %s]\n", fSpeculate? "yes": "no" );
- fprintf( pErr, "\t-c : toggle accumulation of choices [default = %s]\n", fChoicing? "yes": "no" );
- fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: dfraig [-C num] [-sprcvh]\n" );
+ Abc_Print( -2, "\t performs fraiging using a new method\n" );
+ Abc_Print( -2, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfLimit );
+ Abc_Print( -2, "\t-s : toggle considering sparse functions [default = %s]\n", fDoSparse? "yes": "no" );
+ Abc_Print( -2, "\t-p : toggle proving the miter outputs [default = %s]\n", fProve? "yes": "no" );
+ Abc_Print( -2, "\t-r : toggle speculative reduction [default = %s]\n", fSpeculate? "yes": "no" );
+ Abc_Print( -2, "\t-c : toggle accumulation of choices [default = %s]\n", fChoicing? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -10247,16 +10122,12 @@ usage:
***********************************************************************/
int Abc_CommandCSweep( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c, nCutsMax, nLeafMax, fVerbose;
extern Abc_Ntk_t * Abc_NtkCSweep( Abc_Ntk_t * pNtk, int nCutsMax, int nLeafMax, int fVerbose );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
nCutsMax = 8;
nLeafMax = 6;
@@ -10269,7 +10140,7 @@ int Abc_CommandCSweep( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
nCutsMax = atoi(argv[globalUtilOptind]);
@@ -10280,7 +10151,7 @@ int Abc_CommandCSweep( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'K':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-K\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
goto usage;
}
nLeafMax = atoi(argv[globalUtilOptind]);
@@ -10299,31 +10170,31 @@ int Abc_CommandCSweep( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( nCutsMax < 2 )
{
- fprintf( pErr, "The number of cuts cannot be less than 2.\n" );
+ Abc_Print( -1, "The number of cuts cannot be less than 2.\n" );
return 1;
}
if ( nLeafMax < 3 || nLeafMax > 16 )
{
- fprintf( pErr, "The number of leaves is infeasible.\n" );
+ Abc_Print( -1, "The number of leaves is infeasible.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "This command works only for strashed networks.\n" );
+ Abc_Print( -1, "This command works only for strashed networks.\n" );
return 1;
}
pNtkRes = Abc_NtkCSweep( pNtk, nCutsMax, nLeafMax, fVerbose );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Command has failed.\n" );
+ Abc_Print( -1, "Command has failed.\n" );
return 0;
}
// replace the current network
@@ -10331,12 +10202,12 @@ int Abc_CommandCSweep( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: csweep [-C num] [-K num] [-vh]\n" );
- fprintf( pErr, "\t performs cut sweeping using a new method\n" );
- fprintf( pErr, "\t-C num : limit on the number of cuts (C >= 2) [default = %d]\n", nCutsMax );
- fprintf( pErr, "\t-K num : limit on the cut size (3 <= K <= 16) [default = %d]\n", nLeafMax );
- fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: csweep [-C num] [-K num] [-vh]\n" );
+ Abc_Print( -2, "\t performs cut sweeping using a new method\n" );
+ Abc_Print( -2, "\t-C num : limit on the number of cuts (C >= 2) [default = %d]\n", nCutsMax );
+ Abc_Print( -2, "\t-K num : limit on the cut size (3 <= K <= 16) [default = %d]\n", nLeafMax );
+ Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -10354,16 +10225,12 @@ usage:
int Abc_CommandIProve( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Prove_Params_t Params, * pParams = &Params;
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkTemp;
int c, clk, RetValue, iOut = -1;
extern int Abc_NtkIvyProve( Abc_Ntk_t ** ppNtk, void * pPars );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Prove_ParamsSetDefault( pParams );
pParams->fUseRewriting = 1;
@@ -10387,13 +10254,13 @@ int Abc_CommandIProve( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( Abc_NtkLatchNum(pNtk) > 0 )
{
- fprintf( pErr, "The network has registers. Use \"dprove\".\n" );
+ Abc_Print( -1, "The network has registers. Use \"dprove\".\n" );
return 1;
}
@@ -10419,29 +10286,29 @@ int Abc_CommandIProve( Abc_Frame_t * pAbc, int argc, char ** argv )
break;
}
if ( i == Abc_NtkCoNum(pNtk) )
- printf( "ERROR in Abc_NtkMiterProve(): Generated counter-example is invalid.\n" );
+ Abc_Print( 1, "ERROR in Abc_NtkMiterProve(): Generated counter-example is invalid.\n" );
ABC_FREE( pSimInfo );
}
-
+ pAbc->Status = RetValue;
if ( RetValue == -1 )
- printf( "UNDECIDED " );
+ Abc_Print( 1, "UNDECIDED " );
else if ( RetValue == 0 )
- printf( "SATISFIABLE (output = %d) ", iOut );
+ Abc_Print( 1, "SATISFIABLE (output = %d) ", iOut );
else
- printf( "UNSATISFIABLE " );
- //printf( "\n" );
+ Abc_Print( 1, "UNSATISFIABLE " );
+ //Abc_Print( -1, "\n" );
- ABC_PRT( "Time", clock() - clk );
+ Abc_PrintTime( 1, "Time", clock() - clk );
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtkTemp );
return 0;
usage:
- fprintf( pErr, "usage: iprove [-rvh]\n" );
- fprintf( pErr, "\t performs CEC using a new method\n" );
- fprintf( pErr, "\t-r : toggle AIG rewriting [default = %s]\n", pParams->fUseRewriting? "yes": "no" );
- fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", pParams->fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: iprove [-rvh]\n" );
+ Abc_Print( -2, "\t performs CEC using a new method\n" );
+ Abc_Print( -2, "\t-r : toggle AIG rewriting [default = %s]\n", pParams->fUseRewriting? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", pParams->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -10459,7 +10326,7 @@ usage:
/*
int Abc_CommandHaig( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
+ FILE * stdout, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c;
int nIters;
@@ -10472,8 +10339,8 @@ int Abc_CommandHaig( Abc_Frame_t * pAbc, int argc, char ** argv )
extern Abc_Ntk_t * Abc_NtkDarHaigRecord( Abc_Ntk_t * pNtk, int nIters, int nSteps, int fRetimingOnly, int fAddBugs, int fUseCnf, int fVerbose );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
+
+
// set defaults
nIters = 3;
@@ -10490,7 +10357,7 @@ int Abc_CommandHaig( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'I':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-I\" should be followed by a positive integer.\n" );
+ Abc_Print( -1, "Command line switch \"-I\" should be followed by a positive integer.\n" );
goto usage;
}
nIters = atoi(argv[globalUtilOptind]);
@@ -10501,7 +10368,7 @@ int Abc_CommandHaig( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'S':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-S\" should be followed by a positive integer.\n" );
+ Abc_Print( -1, "Command line switch \"-S\" should be followed by a positive integer.\n" );
goto usage;
}
nSteps = atoi(argv[globalUtilOptind]);
@@ -10529,19 +10396,19 @@ int Abc_CommandHaig( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "This command works only for strashed networks.\n" );
+ Abc_Print( -1, "This command works only for strashed networks.\n" );
return 1;
}
pNtkRes = Abc_NtkDarHaigRecord( pNtk, nIters, nSteps, fRetimingOnly, fAddBugs, fUseCnf, fVerbose );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Command has failed.\n" );
+ Abc_Print( -1, "Command has failed.\n" );
return 0;
}
// replace the current network
@@ -10549,19 +10416,19 @@ int Abc_CommandHaig( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: haig [-IS num] [-rbcvh]\n" );
- fprintf( pErr, "\t run a few rounds of comb+seq synthesis to test HAIG recording\n" );
- fprintf( pErr, "\t the current network is set to be the result of synthesis performed\n" );
- fprintf( pErr, "\t (this network can be verified using command \"dsec\")\n" );
- fprintf( pErr, "\t HAIG is written out into the file \"haig.blif\"\n" );
- fprintf( pErr, "\t (this HAIG can be proved using \"r haig.blif; st; dprove -abc -F 16\")\n" );
- fprintf( pErr, "\t-I num : the number of rounds of comb+seq synthesis [default = %d]\n", nIters );
- fprintf( pErr, "\t-S num : the number of forward retiming moves performed [default = %d]\n", nSteps );
- fprintf( pErr, "\t-r : toggle the use of retiming only [default = %s]\n", fRetimingOnly? "yes": "no" );
- fprintf( pErr, "\t-b : toggle bug insertion [default = %s]\n", fAddBugs? "yes": "no" );
- fprintf( pErr, "\t-c : enable CNF-based proof (no speculative reduction) [default = %s]\n", fUseCnf? "yes": "no" );
- fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: haig [-IS num] [-rbcvh]\n" );
+ Abc_Print( -2, "\t run a few rounds of comb+seq synthesis to test HAIG recording\n" );
+ Abc_Print( -2, "\t the current network is set to be the result of synthesis performed\n" );
+ Abc_Print( -2, "\t (this network can be verified using command \"dsec\")\n" );
+ Abc_Print( -2, "\t HAIG is written out into the file \"haig.blif\"\n" );
+ Abc_Print( -2, "\t (this HAIG can be proved using \"r haig.blif; st; dprove -abc -F 16\")\n" );
+ Abc_Print( -2, "\t-I num : the number of rounds of comb+seq synthesis [default = %d]\n", nIters );
+ Abc_Print( -2, "\t-S num : the number of forward retiming moves performed [default = %d]\n", nSteps );
+ Abc_Print( -2, "\t-r : toggle the use of retiming only [default = %s]\n", fRetimingOnly? "yes": "no" );
+ Abc_Print( -2, "\t-b : toggle bug insertion [default = %s]\n", fAddBugs? "yes": "no" );
+ Abc_Print( -2, "\t-c : enable CNF-based proof (no speculative reduction) [default = %s]\n", fUseCnf? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
*/
@@ -10579,14 +10446,11 @@ usage:
***********************************************************************/
int Abc_CommandMini( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c;
extern Abc_Ntk_t * Abc_NtkMiniBalance( Abc_Ntk_t * pNtk );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
// set defaults
Extra_UtilGetoptReset();
@@ -10602,19 +10466,19 @@ int Abc_CommandMini( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "Only works for combinatinally strashed AIG networks.\n" );
+ Abc_Print( -1, "Only works for combinatinally strashed AIG networks.\n" );
return 1;
}
pNtkRes = Abc_NtkMiniBalance( pNtk );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Command has failed.\n" );
+ Abc_Print( -1, "Command has failed.\n" );
return 0;
}
// replace the current network
@@ -10622,9 +10486,9 @@ int Abc_CommandMini( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: mini [-h]\n" );
- fprintf( pErr, "\t perform balancing using new package\n" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: mini [-h]\n" );
+ Abc_Print( -2, "\t perform balancing using new package\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -10641,18 +10505,12 @@ usage:
***********************************************************************/
int Abc_CommandQbf( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
int nPars;
int fVerbose;
extern void Abc_NtkQbf( Abc_Ntk_t * pNtk, int nPars, int fVerbose );
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
nPars = -1;
fVerbose = 1;
@@ -10664,7 +10522,7 @@ int Abc_CommandQbf( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'P':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-P\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
goto usage;
}
nPars = atoi(argv[globalUtilOptind]);
@@ -10683,22 +10541,22 @@ int Abc_CommandQbf( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsComb(pNtk) )
{
- fprintf( pErr, "Works only for combinational networks.\n" );
+ Abc_Print( -1, "Works only for combinational networks.\n" );
return 1;
}
if ( Abc_NtkPoNum(pNtk) != 1 )
{
- fprintf( pErr, "The miter should have one primary output.\n" );
+ Abc_Print( -1, "The miter should have one primary output.\n" );
return 1;
}
if ( !(nPars > 0 && nPars < Abc_NtkPiNum(pNtk)) )
{
- fprintf( pErr, "The number of paramter variables is invalid (should be > 0 and < PI num).\n" );
+ Abc_Print( -1, "The number of paramter variables is invalid (should be > 0 and < PI num).\n" );
return 1;
}
if ( Abc_NtkIsStrash(pNtk) )
@@ -10712,11 +10570,11 @@ int Abc_CommandQbf( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: qbf [-P num] [-vh]\n" );
- fprintf( pErr, "\t solves a quantified boolean formula problem EpVxM(p,x)\n" );
- fprintf( pErr, "\t-P num : number of paramters (should be the first PIs) [default = %d]\n", nPars );
- fprintf( pErr, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: qbf [-P num] [-vh]\n" );
+ Abc_Print( -2, "\t solves a quantified intean formula problem EpVxM(p,x)\n" );
+ Abc_Print( -2, "\t-P num : number of paramters (should be the first PIs) [default = %d]\n", nPars );
+ Abc_Print( -2, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -10736,7 +10594,6 @@ int Abc_CommandFraig( Abc_Frame_t * pAbc, int argc, char ** argv )
{
char Buffer[100];
Fraig_Params_t Params, * pParams = &Params;
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int fAllNodes;
int fExdc;
@@ -10745,9 +10602,6 @@ int Abc_CommandFraig( Abc_Frame_t * pAbc, int argc, char ** argv )
extern void Abc_NtkFraigPartitionedTime( Abc_Ntk_t * pNtk, void * pParams );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fExdc = 0;
fAllNodes = 0;
@@ -10771,7 +10625,7 @@ int Abc_CommandFraig( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'R':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-R\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
goto usage;
}
pParams->nPatsRand = atoi(argv[globalUtilOptind]);
@@ -10782,7 +10636,7 @@ int Abc_CommandFraig( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'D':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-D\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
goto usage;
}
pParams->nPatsDyna = atoi(argv[globalUtilOptind]);
@@ -10793,7 +10647,7 @@ int Abc_CommandFraig( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
pParams->nBTLimit = atoi(argv[globalUtilOptind]);
@@ -10835,12 +10689,12 @@ int Abc_CommandFraig( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsLogic(pNtk) && !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "Can only fraig a logic network or an AIG.\n" );
+ Abc_Print( -1, "Can only fraig a logic network or an AIG.\n" );
return 1;
}
@@ -10873,7 +10727,7 @@ int Abc_CommandFraig( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Fraiging has failed.\n" );
+ Abc_Print( -1, "Fraiging has failed.\n" );
return 1;
}
@@ -10886,21 +10740,21 @@ int Abc_CommandFraig( Abc_Frame_t * pAbc, int argc, char ** argv )
usage:
sprintf( Buffer, "%d", pParams->nBTLimit );
- fprintf( pErr, "usage: fraig [-R num] [-D num] [-C num] [-rscpvtah]\n" );
- fprintf( pErr, "\t transforms a logic network into a functionally reduced AIG\n" );
- fprintf( pErr, "\t (there are also newer fraiging commands, \"ifraig\" and \"dfraig\")\n" );
- fprintf( pErr, "\t-R num : number of random patterns (127 < num < 32769) [default = %d]\n", pParams->nPatsRand );
- fprintf( pErr, "\t-D num : number of systematic patterns (127 < num < 32769) [default = %d]\n", pParams->nPatsDyna );
- fprintf( pErr, "\t-C num : number of backtracks for one SAT problem [default = %s]\n", pParams->nBTLimit==-1? "infinity" : Buffer );
- fprintf( pErr, "\t-r : toggle functional reduction [default = %s]\n", pParams->fFuncRed? "yes": "no" );
- fprintf( pErr, "\t-s : toggle considering sparse functions [default = %s]\n", pParams->fDoSparse? "yes": "no" );
- fprintf( pErr, "\t-c : toggle accumulation of choices [default = %s]\n", pParams->fChoicing? "yes": "no" );
- fprintf( pErr, "\t-p : toggle proving the miter outputs [default = %s]\n", pParams->fTryProve? "yes": "no" );
- fprintf( pErr, "\t-v : toggle verbose output [default = %s]\n", pParams->fVerbose? "yes": "no" );
- fprintf( pErr, "\t-e : toggle functional sweeping using EXDC [default = %s]\n", fExdc? "yes": "no" );
- fprintf( pErr, "\t-a : toggle between all nodes and DFS nodes [default = %s]\n", fAllNodes? "all": "dfs" );
- fprintf( pErr, "\t-t : toggle using partitioned representation [default = %s]\n", fPartition? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: fraig [-R num] [-D num] [-C num] [-rscpvtah]\n" );
+ Abc_Print( -2, "\t transforms a logic network into a functionally reduced AIG\n" );
+ Abc_Print( -2, "\t (there are also newer fraiging commands, \"ifraig\" and \"dfraig\")\n" );
+ Abc_Print( -2, "\t-R num : number of random patterns (127 < num < 32769) [default = %d]\n", pParams->nPatsRand );
+ Abc_Print( -2, "\t-D num : number of systematic patterns (127 < num < 32769) [default = %d]\n", pParams->nPatsDyna );
+ Abc_Print( -2, "\t-C num : number of backtracks for one SAT problem [default = %s]\n", pParams->nBTLimit==-1? "infinity" : Buffer );
+ Abc_Print( -2, "\t-r : toggle functional reduction [default = %s]\n", pParams->fFuncRed? "yes": "no" );
+ Abc_Print( -2, "\t-s : toggle considering sparse functions [default = %s]\n", pParams->fDoSparse? "yes": "no" );
+ Abc_Print( -2, "\t-c : toggle accumulation of choices [default = %s]\n", pParams->fChoicing? "yes": "no" );
+ Abc_Print( -2, "\t-p : toggle proving the miter outputs [default = %s]\n", pParams->fTryProve? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose output [default = %s]\n", pParams->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-e : toggle functional sweeping using EXDC [default = %s]\n", fExdc? "yes": "no" );
+ Abc_Print( -2, "\t-a : toggle between all nodes and DFS nodes [default = %s]\n", fAllNodes? "all": "dfs" );
+ Abc_Print( -2, "\t-t : toggle using partitioned representation [default = %s]\n", fPartition? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -10917,15 +10771,11 @@ usage:
***********************************************************************/
int Abc_CommandFraigTrust( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c;
int fDuplicate;
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fDuplicate = 0;
Extra_UtilGetoptReset();
@@ -10945,7 +10795,7 @@ int Abc_CommandFraigTrust( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
@@ -10953,7 +10803,7 @@ int Abc_CommandFraigTrust( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtkRes = Abc_NtkFraigTrust( pNtk );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Fraiging in the trust mode has failed.\n" );
+ Abc_Print( -1, "Fraiging in the trust mode has failed.\n" );
return 1;
}
// replace the current network
@@ -10961,10 +10811,10 @@ int Abc_CommandFraigTrust( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: fraig_trust [-h]\n" );
- fprintf( pErr, "\t transforms the current network into an AIG assuming it is FRAIG with choices\n" );
-// fprintf( pErr, "\t-d : toggle duplication of logic [default = %s]\n", fDuplicate? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: fraig_trust [-h]\n" );
+ Abc_Print( -2, "\t transforms the current network into an AIG assuming it is FRAIG with choices\n" );
+// Abc_Print( -2, "\t-d : toggle duplication of logic [default = %s]\n", fDuplicate? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -10981,15 +10831,10 @@ usage:
***********************************************************************/
int Abc_CommandFraigStore( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
int fDuplicate;
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fDuplicate = 0;
Extra_UtilGetoptReset();
@@ -11009,23 +10854,23 @@ int Abc_CommandFraigStore( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
// get the new network
if ( !Abc_NtkFraigStore( pNtk ) )
{
- fprintf( pErr, "Fraig storing has failed.\n" );
+ Abc_Print( -1, "Fraig storing has failed.\n" );
return 1;
}
return 0;
usage:
- fprintf( pErr, "usage: fraig_store [-h]\n" );
- fprintf( pErr, "\t saves the current network in the AIG database\n" );
-// fprintf( pErr, "\t-d : toggle duplication of logic [default = %s]\n", fDuplicate? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: fraig_store [-h]\n" );
+ Abc_Print( -2, "\t saves the current network in the AIG database\n" );
+// Abc_Print( -2, "\t-d : toggle duplication of logic [default = %s]\n", fDuplicate? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -11042,15 +10887,11 @@ usage:
***********************************************************************/
int Abc_CommandFraigRestore( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c;
int fDuplicate;
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fDuplicate = 0;
Extra_UtilGetoptReset();
@@ -11070,7 +10911,7 @@ int Abc_CommandFraigRestore( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
@@ -11078,7 +10919,7 @@ int Abc_CommandFraigRestore( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtkRes = Abc_NtkFraigRestore();
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Fraig restoring has failed.\n" );
+ Abc_Print( -1, "Fraig restoring has failed.\n" );
return 1;
}
// replace the current network
@@ -11086,10 +10927,10 @@ int Abc_CommandFraigRestore( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: fraig_restore [-h]\n" );
- fprintf( pErr, "\t makes the current network by fraiging the AIG database\n" );
-// fprintf( pErr, "\t-d : toggle duplication of logic [default = %s]\n", fDuplicate? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: fraig_restore [-h]\n" );
+ Abc_Print( -2, "\t makes the current network by fraiging the AIG database\n" );
+// Abc_Print( -2, "\t-d : toggle duplication of logic [default = %s]\n", fDuplicate? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -11106,15 +10947,9 @@ usage:
***********************************************************************/
int Abc_CommandFraigClean( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
int fDuplicate;
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fDuplicate = 0;
Extra_UtilGetoptReset();
@@ -11135,10 +10970,10 @@ int Abc_CommandFraigClean( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: fraig_clean [-h]\n" );
- fprintf( pErr, "\t cleans the internal FRAIG storage\n" );
-// fprintf( pErr, "\t-d : toggle duplication of logic [default = %s]\n", fDuplicate? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: fraig_clean [-h]\n" );
+ Abc_Print( -2, "\t cleans the internal FRAIG storage\n" );
+// Abc_Print( -2, "\t-d : toggle duplication of logic [default = %s]\n", fDuplicate? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -11155,19 +10990,13 @@ usage:
***********************************************************************/
int Abc_CommandFraigSweep( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
int fUseInv;
int fExdc;
int fVerbose;
int fVeryVerbose;
- extern bool Abc_NtkFraigSweep( Abc_Ntk_t * pNtk, int fUseInv, int fExdc, int fVerbose, int fVeryVerbose );
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
+ extern int Abc_NtkFraigSweep( Abc_Ntk_t * pNtk, int fUseInv, int fExdc, int fVerbose, int fVeryVerbose );
// set defaults
fUseInv = 1;
fExdc = 0;
@@ -11199,34 +11028,34 @@ int Abc_CommandFraigSweep( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "Cannot sweep AIGs (use \"fraig\").\n" );
+ Abc_Print( -1, "Cannot sweep AIGs (use \"fraig\").\n" );
return 1;
}
if ( !Abc_NtkIsLogic(pNtk) )
{
- fprintf( pErr, "Transform the current network into a logic network.\n" );
+ Abc_Print( -1, "Transform the current network into a logic network.\n" );
return 1;
}
// modify the current network
if ( !Abc_NtkFraigSweep( pNtk, fUseInv, fExdc, fVerbose, fVeryVerbose ) )
{
- fprintf( pErr, "Sweeping has failed.\n" );
+ Abc_Print( -1, "Sweeping has failed.\n" );
return 1;
}
return 0;
usage:
- fprintf( pErr, "usage: fraig_sweep [-evwh]\n" );
- fprintf( pErr, "\t performs technology-dependent sweep\n" );
- fprintf( pErr, "\t-e : toggle functional sweeping using EXDC [default = %s]\n", fExdc? "yes": "no" );
- fprintf( pErr, "\t-v : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-w : prints equivalence class information [default = %s]\n", fVeryVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: fraig_sweep [-evwh]\n" );
+ Abc_Print( -2, "\t performs technology-dependent sweep\n" );
+ Abc_Print( -2, "\t-e : toggle functional sweeping using EXDC [default = %s]\n", fExdc? "yes": "no" );
+ Abc_Print( -2, "\t-v : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-w : prints equivalence class information [default = %s]\n", fVeryVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -11243,24 +11072,32 @@ usage:
***********************************************************************/
int Abc_CommandFraigDress( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ extern void Abc_NtkDress( Abc_Ntk_t * pNtk, char * pFileName, int fVerbose );
+ extern void Abc_NtkDress2( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nConflictLimit, int fVerbose );
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc), * pNtk2;
char * pFileName;
int c;
+ int nConfs;
int fVerbose;
- extern void Abc_NtkDress( Abc_Ntk_t * pNtk, char * pFileName, int fVerbose );
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
- fVerbose = 0;
+ nConfs = 1000;
+ fVerbose = 0;
Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
+ while ( ( c = Extra_UtilGetopt( argc, argv, "Cvh" ) ) != EOF )
{
switch ( c )
{
+ case 'C':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ nConfs = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( nConfs < 0 )
+ goto usage;
+ break;
case 'v':
fVerbose ^= 1;
break;
@@ -11272,33 +11109,37 @@ int Abc_CommandFraigDress( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "This command works only for logic networks.\n" );
+ Abc_Print( -1, "This command works only for logic networks.\n" );
return 1;
}
if ( argc != globalUtilOptind && argc != globalUtilOptind + 1 )
goto usage;
if ( argc == globalUtilOptind && Abc_NtkSpec(pNtk) == NULL )
{
- fprintf( pErr, "The current network has no spec.\n" );
+ Abc_Print( -1, "The current network has no spec.\n" );
return 1;
}
// get the input file name
pFileName = (argc == globalUtilOptind + 1) ? argv[globalUtilOptind] : Abc_NtkSpec(pNtk);
// modify the current network
- Abc_NtkDress( pNtk, pFileName, fVerbose );
+// Abc_NtkDress( pNtk, pFileName, fVerbose );
+ pNtk2 = Io_Read( pFileName, Io_ReadFileType(pFileName), 1 );
+ Abc_NtkDress2( pNtk, pNtk2, nConfs, fVerbose );
+ Abc_NtkDelete( pNtk2 );
return 0;
usage:
- fprintf( pErr, "usage: dress [-vh] <file>\n" );
- fprintf( pErr, "\t transfers internal node names from file to the current network\n" );
- fprintf( pErr, "\t<file> : network with names (if not given, the current network spec is used)\n" );
- fprintf( pErr, "\t-v : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: dress [-C num] [-vh] <file>\n" );
+ Abc_Print( -2, "\t transfers internal node names from file to the current network\n" );
+ Abc_Print( -2, "\t<file> : network with names (if not given, the current network spec is used)\n" );
+ Abc_Print( -2, "\t-C num : the maximum number of conflicts at each node [default = %d]\n", nConfs );
+ Abc_Print( -2, "\t-v : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -11317,14 +11158,8 @@ usage:
***********************************************************************/
int Abc_CommandHaigStart( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "dh" ) ) != EOF )
@@ -11339,16 +11174,16 @@ int Abc_CommandHaigStart( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "This command works only for AIGs; run strashing (\"st\").\n" );
+ Abc_Print( -1, "This command works only for AIGs; run strashing (\"st\").\n" );
return 0;
}
Abc_NtkHaigStart( pNtk );
return 0;
usage:
- fprintf( pErr, "usage: haig_start [-h]\n" );
- fprintf( pErr, "\t starts constructive accumulation of combinational choices\n" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: haig_start [-h]\n" );
+ Abc_Print( -2, "\t starts constructive accumulation of combinational choices\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -11365,14 +11200,8 @@ usage:
***********************************************************************/
int Abc_CommandHaigStop( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "dh" ) ) != EOF )
@@ -11387,16 +11216,16 @@ int Abc_CommandHaigStop( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "This command works only for AIGs; run strashing (\"st\").\n" );
+ Abc_Print( -1, "This command works only for AIGs; run strashing (\"st\").\n" );
return 0;
}
Abc_NtkHaigStop( pNtk );
return 0;
usage:
- fprintf( pErr, "usage: haig_stop [-h]\n" );
- fprintf( pErr, "\t cleans the internal storage for combinational choices\n" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: haig_stop [-h]\n" );
+ Abc_Print( -2, "\t cleans the internal storage for combinational choices\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -11413,14 +11242,10 @@ usage:
***********************************************************************/
int Abc_CommandHaigUse( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c;
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "dh" ) ) != EOF )
@@ -11435,14 +11260,14 @@ int Abc_CommandHaigUse( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "This command works only for AIGs; run strashing (\"st\").\n" );
+ Abc_Print( -1, "This command works only for AIGs; run strashing (\"st\").\n" );
return 0;
}
// get the new network
pNtkRes = Abc_NtkHaigUse( pNtk );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Transforming internal storage into AIG with choices has failed.\n" );
+ Abc_Print( -1, "Transforming internal storage into AIG with choices has failed.\n" );
return 1;
}
// replace the current network
@@ -11450,9 +11275,9 @@ int Abc_CommandHaigUse( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: haig_use [-h]\n" );
- fprintf( pErr, "\t transforms internal storage into an AIG with choices\n" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: haig_use [-h]\n" );
+ Abc_Print( -2, "\t transforms internal storage into an AIG with choices\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -11471,16 +11296,12 @@ usage:
***********************************************************************/
int Abc_CommandRecStart( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
int nVars;
int nCuts;
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
nVars = 4;
nCuts = 8;
@@ -11492,7 +11313,7 @@ int Abc_CommandRecStart( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'K':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-K\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
goto usage;
}
nVars = atoi(argv[globalUtilOptind]);
@@ -11503,7 +11324,7 @@ int Abc_CommandRecStart( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
nCuts = atoi(argv[globalUtilOptind]);
@@ -11519,29 +11340,29 @@ int Abc_CommandRecStart( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( !(nVars >= 3 && nVars <= 16) )
{
- fprintf( pErr, "The range of allowed values is 3 <= K <= 16.\n" );
+ Abc_Print( -1, "The range of allowed values is 3 <= K <= 16.\n" );
return 0;
}
if ( Abc_NtkRecIsRunning() )
{
- fprintf( pErr, "The AIG subgraph recording is already started.\n" );
+ Abc_Print( -1, "The AIG subgraph recording is already started.\n" );
return 0;
}
if ( pNtk && !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "This command works only for AIGs; run strashing (\"st\").\n" );
+ Abc_Print( -1, "This command works only for AIGs; run strashing (\"st\").\n" );
return 0;
}
Abc_NtkRecStart( pNtk, nVars, nCuts );
return 0;
usage:
- fprintf( pErr, "usage: rec_start [-K num] [-C num] [-h]\n" );
- fprintf( pErr, "\t starts recording AIG subgraphs (should be called for\n" );
- fprintf( pErr, "\t an empty network or after reading in a previous record)\n" );
- fprintf( pErr, "\t-K num : the largest number of inputs [default = %d]\n", nVars );
- fprintf( pErr, "\t-C num : the max number of cuts used at a node (0 < num < 2^12) [default = %d]\n", nCuts );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: rec_start [-K num] [-C num] [-h]\n" );
+ Abc_Print( -2, "\t starts recording AIG subgraphs (should be called for\n" );
+ Abc_Print( -2, "\t an empty network or after reading in a previous record)\n" );
+ Abc_Print( -2, "\t-K num : the largest number of inputs [default = %d]\n", nVars );
+ Abc_Print( -2, "\t-C num : the max number of cuts used at a node (0 < num < 2^12) [default = %d]\n", nCuts );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -11558,14 +11379,8 @@ usage:
***********************************************************************/
int Abc_CommandRecStop( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "dh" ) ) != EOF )
@@ -11580,16 +11395,16 @@ int Abc_CommandRecStop( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( !Abc_NtkRecIsRunning() )
{
- fprintf( pErr, "This command works only after calling \"rec_start\".\n" );
+ Abc_Print( -1, "This command works only after calling \"rec_start\".\n" );
return 0;
}
Abc_NtkRecStop();
return 0;
usage:
- fprintf( pErr, "usage: rec_stop [-h]\n" );
- fprintf( pErr, "\t cleans the internal storage for AIG subgraphs\n" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: rec_stop [-h]\n" );
+ Abc_Print( -2, "\t cleans the internal storage for AIG subgraphs\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -11606,14 +11421,8 @@ usage:
***********************************************************************/
int Abc_CommandRecAdd( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "dh" ) ) != EOF )
@@ -11628,21 +11437,21 @@ int Abc_CommandRecAdd( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "This command works for AIGs.\n" );
+ Abc_Print( -1, "This command works for AIGs.\n" );
return 0;
}
if ( !Abc_NtkRecIsRunning() )
{
- fprintf( pErr, "This command works for AIGs after calling \"rec_start\".\n" );
+ Abc_Print( -1, "This command works for AIGs after calling \"rec_start\".\n" );
return 0;
}
Abc_NtkRecAdd( pNtk );
return 0;
usage:
- fprintf( pErr, "usage: rec_add [-h]\n" );
- fprintf( pErr, "\t adds subgraphs from the current network to the set\n" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: rec_add [-h]\n" );
+ Abc_Print( -2, "\t adds subgraphs from the current network to the set\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -11659,14 +11468,8 @@ usage:
***********************************************************************/
int Abc_CommandRecPs( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "dh" ) ) != EOF )
@@ -11681,16 +11484,16 @@ int Abc_CommandRecPs( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( !Abc_NtkRecIsRunning() )
{
- fprintf( pErr, "This command works for AIGs only after calling \"rec_start\".\n" );
+ Abc_Print( -1, "This command works for AIGs only after calling \"rec_start\".\n" );
return 0;
}
Abc_NtkRecPs();
return 0;
usage:
- fprintf( pErr, "usage: rec_ps [-h]\n" );
- fprintf( pErr, "\t prints statistics about the recorded AIG subgraphs\n" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: rec_ps [-h]\n" );
+ Abc_Print( -2, "\t prints statistics about the recorded AIG subgraphs\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -11707,14 +11510,10 @@ usage:
***********************************************************************/
int Abc_CommandRecUse( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c;
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "dh" ) ) != EOF )
@@ -11729,14 +11528,14 @@ int Abc_CommandRecUse( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( !Abc_NtkRecIsRunning() )
{
- fprintf( pErr, "This command works for AIGs only after calling \"rec_start\".\n" );
+ Abc_Print( -1, "This command works for AIGs only after calling \"rec_start\".\n" );
return 0;
}
// get the new network
pNtkRes = Abc_NtkRecUse();
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Transforming internal AIG subgraphs into an AIG with choices has failed.\n" );
+ Abc_Print( -1, "Transforming internal AIG subgraphs into an AIG with choices has failed.\n" );
return 1;
}
// replace the current network
@@ -11744,9 +11543,9 @@ int Abc_CommandRecUse( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: rec_use [-h]\n" );
- fprintf( pErr, "\t transforms internal storage into an AIG with choices\n" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: rec_use [-h]\n" );
+ Abc_Print( -2, "\t transforms internal storage into an AIG with choices\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -11765,7 +11564,6 @@ usage:
***********************************************************************/
int Abc_CommandMap( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
char Buffer[100];
double DelayTarget;
@@ -11776,12 +11574,9 @@ int Abc_CommandMap( Abc_Frame_t * pAbc, int argc, char ** argv )
int fVerbose;
int c;
extern Abc_Ntk_t * Abc_NtkMap( Abc_Ntk_t * pNtk, double DelayTarget, int fRecovery, int fSwitching, int fVerbose );
- extern bool Abc_NtkFraigSweep( Abc_Ntk_t * pNtk, int fUseInv, int fExdc, int fVerbose, int fVeryVerbose );
+ extern int Abc_NtkFraigSweep( Abc_Ntk_t * pNtk, int fUseInv, int fExdc, int fVerbose, int fVeryVerbose );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
DelayTarget =-1;
fAreaOnly = 0;
@@ -11797,7 +11592,7 @@ int Abc_CommandMap( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'D':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-D\" should be followed by a floating point number.\n" );
+ Abc_Print( -1, "Command line switch \"-D\" should be followed by a floating point number.\n" );
goto usage;
}
DelayTarget = (float)atof(argv[globalUtilOptind]);
@@ -11829,7 +11624,7 @@ int Abc_CommandMap( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
@@ -11841,23 +11636,23 @@ int Abc_CommandMap( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtk = Abc_NtkStrash( pNtk, 0, 0, 0 );
if ( pNtk == NULL )
{
- fprintf( pErr, "Strashing before mapping has failed.\n" );
+ Abc_Print( -1, "Strashing before mapping has failed.\n" );
return 1;
}
pNtk = Abc_NtkBalance( pNtkRes = pNtk, 0, 0, 1 );
Abc_NtkDelete( pNtkRes );
if ( pNtk == NULL )
{
- fprintf( pErr, "Balancing before mapping has failed.\n" );
+ Abc_Print( -1, "Balancing before mapping has failed.\n" );
return 1;
}
- fprintf( pOut, "The network was strashed and balanced before mapping.\n" );
+ Abc_Print( 0, "The network was strashed and balanced before mapping.\n" );
// get the new network
pNtkRes = Abc_NtkMap( pNtk, DelayTarget, fRecovery, fSwitching, fVerbose );
if ( pNtkRes == NULL )
{
Abc_NtkDelete( pNtk );
- fprintf( pErr, "Mapping has failed.\n" );
+ Abc_Print( -1, "Mapping has failed.\n" );
return 1;
}
Abc_NtkDelete( pNtk );
@@ -11868,7 +11663,7 @@ int Abc_CommandMap( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtkRes = Abc_NtkMap( pNtk, DelayTarget, fRecovery, fSwitching, fVerbose );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Mapping has failed.\n" );
+ Abc_Print( -1, "Mapping has failed.\n" );
return 1;
}
}
@@ -11885,15 +11680,15 @@ usage:
sprintf( Buffer, "not used" );
else
sprintf( Buffer, "%.3f", DelayTarget );
- fprintf( pErr, "usage: map [-D float] [-arspvh]\n" );
- fprintf( pErr, "\t performs standard cell mapping of the current network\n" );
- fprintf( pErr, "\t-D float : sets the global required times [default = %s]\n", Buffer );
- fprintf( pErr, "\t-a : toggles area-only mapping [default = %s]\n", fAreaOnly? "yes": "no" );
- fprintf( pErr, "\t-r : toggles area recovery [default = %s]\n", fRecovery? "yes": "no" );
- fprintf( pErr, "\t-s : toggles sweep after mapping [default = %s]\n", fSweep? "yes": "no" );
- fprintf( pErr, "\t-p : optimizes power by minimizing switching [default = %s]\n", fSwitching? "yes": "no" );
- fprintf( pErr, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: map [-D float] [-arspvh]\n" );
+ Abc_Print( -2, "\t performs standard cell mapping of the current network\n" );
+ Abc_Print( -2, "\t-D float : sets the global required times [default = %s]\n", Buffer );
+ Abc_Print( -2, "\t-a : toggles area-only mapping [default = %s]\n", fAreaOnly? "yes": "no" );
+ Abc_Print( -2, "\t-r : toggles area recovery [default = %s]\n", fRecovery? "yes": "no" );
+ Abc_Print( -2, "\t-s : toggles sweep after mapping [default = %s]\n", fSweep? "yes": "no" );
+ Abc_Print( -2, "\t-p : optimizes power by minimizing switching [default = %s]\n", fSwitching? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -11911,17 +11706,13 @@ usage:
int Abc_CommandAmap( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Amap_Par_t Pars, * pPars = &Pars;
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int fSweep;
int c;
extern Abc_Ntk_t * Abc_NtkDarAmap( Abc_Ntk_t * pNtk, Amap_Par_t * pPars );
- extern bool Abc_NtkFraigSweep( Abc_Ntk_t * pNtk, int fUseInv, int fExdc, int fVerbose, int fVeryVerbose );
+ extern int Abc_NtkFraigSweep( Abc_Ntk_t * pNtk, int fUseInv, int fExdc, int fVerbose, int fVeryVerbose );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fSweep = 0;
Amap_ManSetDefaultParams( pPars );
@@ -11933,7 +11724,7 @@ int Abc_CommandAmap( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-F\" should be followed by a floating point number.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by a floating point number.\n" );
goto usage;
}
pPars->nIterFlow = atoi(argv[globalUtilOptind]);
@@ -11944,7 +11735,7 @@ int Abc_CommandAmap( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'A':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-A\" should be followed by a floating point number.\n" );
+ Abc_Print( -1, "Command line switch \"-A\" should be followed by a floating point number.\n" );
goto usage;
}
pPars->nIterArea = atoi(argv[globalUtilOptind]);
@@ -11955,7 +11746,7 @@ int Abc_CommandAmap( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'E':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-E\" should be followed by a floating point number.\n" );
+ Abc_Print( -1, "Command line switch \"-E\" should be followed by a floating point number.\n" );
goto usage;
}
pPars->fEpsilon = (float)atof(argv[globalUtilOptind]);
@@ -11987,7 +11778,7 @@ int Abc_CommandAmap( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
@@ -11996,23 +11787,23 @@ int Abc_CommandAmap( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtk = Abc_NtkStrash( pNtk, 0, 0, 0 );
if ( pNtk == NULL )
{
- fprintf( pErr, "Strashing before mapping has failed.\n" );
+ Abc_Print( -1, "Strashing before mapping has failed.\n" );
return 1;
}
pNtk = Abc_NtkBalance( pNtkRes = pNtk, 0, 0, 1 );
Abc_NtkDelete( pNtkRes );
if ( pNtk == NULL )
{
- fprintf( pErr, "Balancing before mapping has failed.\n" );
+ Abc_Print( -1, "Balancing before mapping has failed.\n" );
return 1;
}
- fprintf( pOut, "The network was strashed and balanced before mapping.\n" );
+ Abc_Print( 0, "The network was strashed and balanced before mapping.\n" );
// get the new network
pNtkRes = Abc_NtkDarAmap( pNtk, pPars );
if ( pNtkRes == NULL )
{
Abc_NtkDelete( pNtk );
- fprintf( pErr, "Mapping has failed.\n" );
+ Abc_Print( -1, "Mapping has failed.\n" );
return 1;
}
Abc_NtkDelete( pNtk );
@@ -12023,7 +11814,7 @@ int Abc_CommandAmap( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtkRes = Abc_NtkDarAmap( pNtk, pPars );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Mapping has failed.\n" );
+ Abc_Print( -1, "Mapping has failed.\n" );
return 1;
}
}
@@ -12036,17 +11827,17 @@ int Abc_CommandAmap( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: amap [-FA <num>] [-E <float>] [-mxisvh]\n" );
- fprintf( pErr, "\t performs standard cell mapping of the current network\n" );
- fprintf( pErr, "\t-F num : the number of iterations of area flow [default = %d]\n", pPars->nIterFlow );
- fprintf( pErr, "\t-A num : the number of iterations of exact area [default = %d]\n", pPars->nIterArea );
- fprintf( pErr, "\t-E float : sets epsilon used for tie-breaking [default = %f]\n", pPars->fEpsilon );
- fprintf( pErr, "\t-m : toggles using MUX matching [default = %s]\n", pPars->fUseMuxes? "yes": "no" );
- fprintf( pErr, "\t-x : toggles using XOR matching [default = %s]\n", pPars->fUseXors? "yes": "no" );
- fprintf( pErr, "\t-i : toggles assuming inverters are free [default = %s]\n", pPars->fFreeInvs? "yes": "no" );
- fprintf( pErr, "\t-s : toggles sweep after mapping [default = %s]\n", fSweep? "yes": "no" );
- fprintf( pErr, "\t-v : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: amap [-FA <num>] [-E <float>] [-mxisvh]\n" );
+ Abc_Print( -2, "\t performs standard cell mapping of the current network\n" );
+ Abc_Print( -2, "\t-F num : the number of iterations of area flow [default = %d]\n", pPars->nIterFlow );
+ Abc_Print( -2, "\t-A num : the number of iterations of exact area [default = %d]\n", pPars->nIterArea );
+ Abc_Print( -2, "\t-E float : sets epsilon used for tie-breaking [default = %f]\n", pPars->fEpsilon );
+ Abc_Print( -2, "\t-m : toggles using MUX matching [default = %s]\n", pPars->fUseMuxes? "yes": "no" );
+ Abc_Print( -2, "\t-x : toggles using XOR matching [default = %s]\n", pPars->fUseXors? "yes": "no" );
+ Abc_Print( -2, "\t-i : toggles assuming inverters are free [default = %s]\n", pPars->fFreeInvs? "yes": "no" );
+ Abc_Print( -2, "\t-s : toggles sweep after mapping [default = %s]\n", fSweep? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -12064,14 +11855,8 @@ usage:
***********************************************************************/
int Abc_CommandUnmap( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
@@ -12087,27 +11872,27 @@ int Abc_CommandUnmap( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkHasMapping(pNtk) )
{
- fprintf( pErr, "Cannot unmap the network that is not mapped.\n" );
+ Abc_Print( -1, "Cannot unmap the network that is not mapped.\n" );
return 1;
}
// get the new network
if ( !Abc_NtkMapToSop( pNtk ) )
{
- fprintf( pErr, "Unmapping has failed.\n" );
+ Abc_Print( -1, "Unmapping has failed.\n" );
return 1;
}
return 0;
usage:
- fprintf( pErr, "usage: unmap [-h]\n" );
- fprintf( pErr, "\t replaces the library gates by the logic nodes represented using SOPs\n" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: unmap [-h]\n" );
+ Abc_Print( -2, "\t replaces the library gates by the logic nodes represented using SOPs\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -12124,14 +11909,8 @@ usage:
***********************************************************************/
int Abc_CommandAttach( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
@@ -12147,28 +11926,28 @@ int Abc_CommandAttach( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsSopLogic(pNtk) )
{
- fprintf( pErr, "Can only attach gates if the nodes have SOP representations.\n" );
+ Abc_Print( -1, "Can only attach gates if the nodes have SOP representations.\n" );
return 1;
}
// get the new network
if ( !Abc_NtkAttach( pNtk ) )
{
- fprintf( pErr, "Attaching gates has failed.\n" );
+ Abc_Print( -1, "Attaching gates has failed.\n" );
return 1;
}
return 0;
usage:
- fprintf( pErr, "usage: attach [-h]\n" );
- fprintf( pErr, "\t replaces the SOP functions by the gates from the library\n" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: attach [-h]\n" );
+ Abc_Print( -2, "\t replaces the SOP functions by the gates from the library\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -12186,15 +11965,11 @@ usage:
***********************************************************************/
int Abc_CommandSuperChoice( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c;
extern Abc_Ntk_t * Abc_NtkSuperChoice( Abc_Ntk_t * pNtk );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
@@ -12210,13 +11985,13 @@ int Abc_CommandSuperChoice( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "Superchoicing works only for the AIG representation (run \"strash\").\n" );
+ Abc_Print( -1, "Superchoicing works only for the AIG representation (run \"strash\").\n" );
return 1;
}
@@ -12224,7 +11999,7 @@ int Abc_CommandSuperChoice( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtkRes = Abc_NtkSuperChoice( pNtk );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Superchoicing has failed.\n" );
+ Abc_Print( -1, "Superchoicing has failed.\n" );
return 1;
}
// replace the current network
@@ -12232,11 +12007,11 @@ int Abc_CommandSuperChoice( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: sc [-h]\n" );
- fprintf( pErr, "\t performs superchoicing\n" );
- fprintf( pErr, "\t (accumulate: \"r file.blif; rsup; b; sc; f -ac; wb file_sc.blif\")\n" );
- fprintf( pErr, "\t (map without supergate library: \"r file_sc.blif; ft; map\")\n" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: sc [-h]\n" );
+ Abc_Print( -2, "\t performs superchoicing\n" );
+ Abc_Print( -2, "\t (accumulate: \"r file.blif; rsup; b; sc; f -ac; wb file_sc.blif\")\n" );
+ Abc_Print( -2, "\t (map without supergate library: \"r file_sc.blif; ft; map\")\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -12253,7 +12028,6 @@ usage:
***********************************************************************/
int Abc_CommandSuperChoiceLut( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c;
int nLutSize;
@@ -12262,9 +12036,6 @@ int Abc_CommandSuperChoiceLut( Abc_Frame_t * pAbc, int argc, char ** argv )
extern int Abc_NtkSuperChoiceLut( Abc_Ntk_t * pNtk, int nLutSize, int nCutSizeMax, int fVerbose );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fVerbose = 1;
nLutSize = 4;
@@ -12277,7 +12048,7 @@ int Abc_CommandSuperChoiceLut( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'K':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-K\" should be followed by a positive integer.\n" );
+ Abc_Print( -1, "Command line switch \"-K\" should be followed by a positive integer.\n" );
goto usage;
}
nLutSize = atoi(argv[globalUtilOptind]);
@@ -12288,7 +12059,7 @@ int Abc_CommandSuperChoiceLut( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'N':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-N\" should be followed by a positive integer.\n" );
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by a positive integer.\n" );
goto usage;
}
nCutSizeMax = atoi(argv[globalUtilOptind]);
@@ -12308,13 +12079,13 @@ int Abc_CommandSuperChoiceLut( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "Superchoicing works only for the AIG representation (run \"strash\").\n" );
+ Abc_Print( -1, "Superchoicing works only for the AIG representation (run \"strash\").\n" );
return 1;
}
@@ -12325,7 +12096,7 @@ int Abc_CommandSuperChoiceLut( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( !Abc_NtkSuperChoiceLut( pNtkRes, nLutSize, nCutSizeMax, fVerbose ) )
{
Abc_NtkDelete( pNtkRes );
- fprintf( pErr, "Superchoicing has failed.\n" );
+ Abc_Print( -1, "Superchoicing has failed.\n" );
return 1;
}
// replace the current network
@@ -12333,14 +12104,14 @@ int Abc_CommandSuperChoiceLut( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: scl [-K num] [-N num] [-vh]\n" );
- fprintf( pErr, "\t performs superchoicing for K-LUTs\n" );
- fprintf( pErr, "\t (accumulate: \"r file.blif; b; scl; f -ac; wb file_sc.blif\")\n" );
- fprintf( pErr, "\t (FPGA map: \"r file_sc.blif; ft; read_lut lutlibK; fpga\")\n" );
- fprintf( pErr, "\t-K num : the number of LUT inputs [default = %d]\n", nLutSize );
- fprintf( pErr, "\t-N num : the max size of the cut [default = %d]\n", nCutSizeMax );
- fprintf( pErr, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: scl [-K num] [-N num] [-vh]\n" );
+ Abc_Print( -2, "\t performs superchoicing for K-LUTs\n" );
+ Abc_Print( -2, "\t (accumulate: \"r file.blif; b; scl; f -ac; wb file_sc.blif\")\n" );
+ Abc_Print( -2, "\t (FPGA map: \"r file_sc.blif; ft; read_lut lutlibK; fpga\")\n" );
+ Abc_Print( -2, "\t-K num : the number of LUT inputs [default = %d]\n", nLutSize );
+ Abc_Print( -2, "\t-N num : the max size of the cut [default = %d]\n", nCutSizeMax );
+ Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -12359,7 +12130,6 @@ int Abc_CommandFpga( Abc_Frame_t * pAbc, int argc, char ** argv )
{
char Buffer[100];
char LutSize[100];
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c;
int fRecovery;
@@ -12372,9 +12142,6 @@ int Abc_CommandFpga( Abc_Frame_t * pAbc, int argc, char ** argv )
extern Abc_Ntk_t * Abc_NtkFpga( Abc_Ntk_t * pNtk, float DelayTarget, int fRecovery, int fSwitching, int fLatchPaths, int fVerbose );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fRecovery = 1;
fSwitching = 0;
@@ -12404,7 +12171,7 @@ int Abc_CommandFpga( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'D':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-D\" should be followed by a floating point number.\n" );
+ Abc_Print( -1, "Command line switch \"-D\" should be followed by a floating point number.\n" );
goto usage;
}
DelayTarget = (float)atof(argv[globalUtilOptind]);
@@ -12415,7 +12182,7 @@ int Abc_CommandFpga( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'K':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-K\" should be followed by a positive integer.\n" );
+ Abc_Print( -1, "Command line switch \"-K\" should be followed by a positive integer.\n" );
goto usage;
}
nLutSize = atoi(argv[globalUtilOptind]);
@@ -12430,7 +12197,7 @@ int Abc_CommandFpga( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
@@ -12440,7 +12207,7 @@ int Abc_CommandFpga( Abc_Frame_t * pAbc, int argc, char ** argv )
/*
else
{
- fprintf( pErr, "Cannot perform FPGA mapping with LUT size %d.\n", nLutSize );
+ Abc_Print( -1, "Cannot perform FPGA mapping with LUT size %d.\n", nLutSize );
return 1;
}
*/
@@ -12450,23 +12217,23 @@ int Abc_CommandFpga( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtk = Abc_NtkStrash( pNtk, 0, 0, 0 );
if ( pNtk == NULL )
{
- fprintf( pErr, "Strashing before FPGA mapping has failed.\n" );
+ Abc_Print( -1, "Strashing before FPGA mapping has failed.\n" );
return 1;
}
pNtk = Abc_NtkBalance( pNtkRes = pNtk, 0, 0, 1 );
Abc_NtkDelete( pNtkRes );
if ( pNtk == NULL )
{
- fprintf( pErr, "Balancing before FPGA mapping has failed.\n" );
+ Abc_Print( -1, "Balancing before FPGA mapping has failed.\n" );
return 1;
}
- fprintf( pOut, "The network was strashed and balanced before FPGA mapping.\n" );
+ Abc_Print( 1, "The network was strashed and balanced before FPGA mapping.\n" );
// get the new network
pNtkRes = Abc_NtkFpga( pNtk, DelayTarget, fRecovery, fSwitching, fLatchPaths, fVerbose );
if ( pNtkRes == NULL )
{
Abc_NtkDelete( pNtk );
- fprintf( pErr, "FPGA mapping has failed.\n" );
+ Abc_Print( -1, "FPGA mapping has failed.\n" );
return 1;
}
Abc_NtkDelete( pNtk );
@@ -12477,7 +12244,7 @@ int Abc_CommandFpga( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtkRes = Abc_NtkFpga( pNtk, DelayTarget, fRecovery, fSwitching, fLatchPaths, fVerbose );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "FPGA mapping has failed.\n" );
+ Abc_Print( -1, "FPGA mapping has failed.\n" );
return 1;
}
}
@@ -12494,15 +12261,15 @@ usage:
sprintf( LutSize, "library" );
else
sprintf( LutSize, "%d", nLutSize );
- fprintf( pErr, "usage: fpga [-D float] [-K num] [-aplvh]\n" );
- fprintf( pErr, "\t performs FPGA mapping of the current network\n" );
- fprintf( pErr, "\t-a : toggles area recovery [default = %s]\n", fRecovery? "yes": "no" );
- fprintf( pErr, "\t-p : optimizes power by minimizing switching activity [default = %s]\n", fSwitching? "yes": "no" );
- fprintf( pErr, "\t-l : optimizes latch paths for delay, other paths for area [default = %s]\n", fLatchPaths? "yes": "no" );
- fprintf( pErr, "\t-D float : sets the required time for the mapping [default = %s]\n", Buffer );
- fprintf( pErr, "\t-K num : the number of LUT inputs (2 < num < 11) [default = %s]%s\n", LutSize, (nLutSize == -1 ? " (type \"print_lut\")" : "") );
- fprintf( pErr, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : prints the command usage\n");
+ Abc_Print( -2, "usage: fpga [-D float] [-K num] [-aplvh]\n" );
+ Abc_Print( -2, "\t performs FPGA mapping of the current network\n" );
+ Abc_Print( -2, "\t-a : toggles area recovery [default = %s]\n", fRecovery? "yes": "no" );
+ Abc_Print( -2, "\t-p : optimizes power by minimizing switching activity [default = %s]\n", fSwitching? "yes": "no" );
+ Abc_Print( -2, "\t-l : optimizes latch paths for delay, other paths for area [default = %s]\n", fLatchPaths? "yes": "no" );
+ Abc_Print( -2, "\t-D float : sets the required time for the mapping [default = %s]\n", Buffer );
+ Abc_Print( -2, "\t-K num : the number of LUT inputs (2 < num < 11) [default = %s]%s\n", LutSize, (nLutSize == -1 ? " (type \"print_lut\")" : "") );
+ Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : prints the command usage\n");
return 1;
}
@@ -12520,7 +12287,6 @@ usage:
int Abc_CommandFpgaFast( Abc_Frame_t * pAbc, int argc, char ** argv )
{
char Buffer[100];
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c;
int fRecovery;
@@ -12531,9 +12297,6 @@ int Abc_CommandFpgaFast( Abc_Frame_t * pAbc, int argc, char ** argv )
extern Abc_Ntk_t * Abc_NtkFpgaFast( Abc_Ntk_t * pNtk, int nLutSize, int fRecovery, int fVerbose );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fRecovery = 1;
fVerbose = 0;
@@ -12555,7 +12318,7 @@ int Abc_CommandFpgaFast( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'D':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-D\" should be followed by a floating point number.\n" );
+ Abc_Print( -1, "Command line switch \"-D\" should be followed by a floating point number.\n" );
goto usage;
}
DelayTarget = (float)atof(argv[globalUtilOptind]);
@@ -12566,7 +12329,7 @@ int Abc_CommandFpgaFast( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'K':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-K\" should be followed by a positive integer.\n" );
+ Abc_Print( -1, "Command line switch \"-K\" should be followed by a positive integer.\n" );
goto usage;
}
nLutSize = atoi(argv[globalUtilOptind]);
@@ -12581,7 +12344,7 @@ int Abc_CommandFpgaFast( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
@@ -12591,23 +12354,23 @@ int Abc_CommandFpgaFast( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtk = Abc_NtkStrash( pNtk, 0, 0, 0 );
if ( pNtk == NULL )
{
- fprintf( pErr, "Strashing before FPGA mapping has failed.\n" );
+ Abc_Print( -1, "Strashing before FPGA mapping has failed.\n" );
return 1;
}
pNtk = Abc_NtkBalance( pNtkRes = pNtk, 0, 0, 1 );
Abc_NtkDelete( pNtkRes );
if ( pNtk == NULL )
{
- fprintf( pErr, "Balancing before FPGA mapping has failed.\n" );
+ Abc_Print( -1, "Balancing before FPGA mapping has failed.\n" );
return 1;
}
- fprintf( pOut, "The network was strashed and balanced before FPGA mapping.\n" );
+ Abc_Print( 1, "The network was strashed and balanced before FPGA mapping.\n" );
// get the new network
pNtkRes = Abc_NtkFpgaFast( pNtk, nLutSize, fRecovery, fVerbose );
if ( pNtkRes == NULL )
{
Abc_NtkDelete( pNtk );
- fprintf( pErr, "FPGA mapping has failed.\n" );
+ Abc_Print( -1, "FPGA mapping has failed.\n" );
return 1;
}
Abc_NtkDelete( pNtk );
@@ -12618,7 +12381,7 @@ int Abc_CommandFpgaFast( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtkRes = Abc_NtkFpgaFast( pNtk, nLutSize, fRecovery, fVerbose );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "FPGA mapping has failed.\n" );
+ Abc_Print( -1, "FPGA mapping has failed.\n" );
return 1;
}
}
@@ -12631,13 +12394,13 @@ usage:
sprintf( Buffer, "not used" );
else
sprintf( Buffer, "%.2f", DelayTarget );
- fprintf( pErr, "usage: ffpga [-K num] [-avh]\n" );
- fprintf( pErr, "\t performs fast FPGA mapping of the current network\n" );
- fprintf( pErr, "\t-a : toggles area recovery [default = %s]\n", fRecovery? "yes": "no" );
-// fprintf( pErr, "\t-D float : sets the required time for the mapping [default = %s]\n", Buffer );
- fprintf( pErr, "\t-K num : the number of LUT inputs (2 < num < 32) [default = %d]\n", nLutSize );
- fprintf( pErr, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : prints the command usage\n");
+ Abc_Print( -2, "usage: ffpga [-K num] [-avh]\n" );
+ Abc_Print( -2, "\t performs fast FPGA mapping of the current network\n" );
+ Abc_Print( -2, "\t-a : toggles area recovery [default = %s]\n", fRecovery? "yes": "no" );
+// Abc_Print( -2, "\t-D float : sets the required time for the mapping [default = %s]\n", Buffer );
+ Abc_Print( -2, "\t-K num : the number of LUT inputs (2 < num < 32) [default = %d]\n", nLutSize );
+ Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : prints the command usage\n");
return 1;
}
@@ -12656,16 +12419,12 @@ 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;
If_Par_t Pars, * pPars = &Pars;
- int c;
+ int c, fLutMux;
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( pPars, 0, sizeof(If_Par_t) );
// user-controlable paramters
@@ -12690,20 +12449,21 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv )
pPars->fTruth = 0;
pPars->nLatches = pNtk? Abc_NtkLatchNum(pNtk) : 0;
pPars->fLiftLeaves = 0;
- pPars->pLutLib = Abc_FrameReadLibLut();
+ pPars->pLutLib = (If_Lib_t *)Abc_FrameReadLibLut();
pPars->pTimesArr = NULL;
pPars->pTimesArr = NULL;
pPars->pFuncCost = NULL;
+ fLutMux = 0;
Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "KCFADEqaflepmrstbvh" ) ) != EOF )
+ while ( ( c = Extra_UtilGetopt( argc, argv, "KCFADEqaflepmrsdbugvh" ) ) != EOF )
{
switch ( c )
{
case 'K':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-K\" should be followed by a positive integer.\n" );
+ Abc_Print( -1, "Command line switch \"-K\" should be followed by a positive integer.\n" );
goto usage;
}
pPars->nLutSize = atoi(argv[globalUtilOptind]);
@@ -12716,7 +12476,7 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-C\" should be followed by a positive integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by a positive integer.\n" );
goto usage;
}
pPars->nCutsMax = atoi(argv[globalUtilOptind]);
@@ -12727,7 +12487,7 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-F\" should be followed by a positive integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by a positive integer.\n" );
goto usage;
}
pPars->nFlowIters = atoi(argv[globalUtilOptind]);
@@ -12738,7 +12498,7 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'A':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-A\" should be followed by a positive integer.\n" );
+ Abc_Print( -1, "Command line switch \"-A\" should be followed by a positive integer.\n" );
goto usage;
}
pPars->nAreaIters = atoi(argv[globalUtilOptind]);
@@ -12749,7 +12509,7 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'D':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-D\" should be followed by a floating point number.\n" );
+ Abc_Print( -1, "Command line switch \"-D\" should be followed by a floating point number.\n" );
goto usage;
}
pPars->DelayTarget = (float)atof(argv[globalUtilOptind]);
@@ -12760,7 +12520,7 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'E':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-E\" should be followed by a floating point number.\n" );
+ Abc_Print( -1, "Command line switch \"-E\" should be followed by a floating point number.\n" );
goto usage;
}
pPars->Epsilon = (float)atof(argv[globalUtilOptind]);
@@ -12795,11 +12555,17 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv )
case 's':
pPars->fSeqMap ^= 1;
break;
- case 't':
- pPars->fLiftLeaves ^= 1;
+ case 'd':
+ pPars->fBidec ^= 1;
break;
case 'b':
- pPars->fBidec ^= 1;
+ pPars->fUseBat ^= 1;
+ break;
+ case 'u':
+ fLutMux ^= 1;
+ break;
+ case 'g':
+ pPars->fDelayOpt ^= 1;
break;
case 'v':
pPars->fVerbose ^= 1;
@@ -12812,20 +12578,20 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
/*
if ( pPars->fSeqMap )
{
- fprintf( pErr, "Sequential mapping is currently disabled.\n" );
+ Abc_Print( -1, "Sequential mapping is currently disabled.\n" );
return 1;
}
*/
if ( pPars->fSeqMap && pPars->nLatches == 0 )
{
- fprintf( pErr, "The network has no latches. Use combinational mapping instead of sequential.\n" );
+ Abc_Print( -1, "The network has no latches. Use combinational mapping instead of sequential.\n" );
return 1;
}
@@ -12833,7 +12599,7 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv )
{
if ( pPars->pLutLib == NULL )
{
- fprintf( pErr, "The LUT library is not given.\n" );
+ Abc_Print( -1, "The LUT library is not given.\n" );
return 1;
}
// get LUT size from the library
@@ -12845,23 +12611,41 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pPars->nLutSize < 3 || pPars->nLutSize > IF_MAX_LUTSIZE )
{
- fprintf( pErr, "Incorrect LUT size (%d).\n", pPars->nLutSize );
+ Abc_Print( -1, "Incorrect LUT size (%d).\n", pPars->nLutSize );
return 1;
}
if ( pPars->nCutsMax < 1 || pPars->nCutsMax >= (1<<12) )
{
- fprintf( pErr, "Incorrect number of cuts.\n" );
+ Abc_Print( -1, "Incorrect number of cuts.\n" );
return 1;
}
+ if ( fLutMux )
+ {
+ extern int Abc_NtkCutCostMux( If_Cut_t * pCut );
+ pPars->fCutMin = 1;
+ pPars->fTruth = 1;
+ pPars->pFuncCost = Abc_NtkCutCostMux;
+ }
+
// enable truth table computation if choices are selected
if ( (c = Abc_NtkGetChoiceNum( pNtk )) )
{
- printf( "Performing LUT mapping with %d choices.\n", c );
-// pPars->fTruth = 1;
+ Abc_Print( 0, "Performing LUT mapping with %d choices.\n", c );
pPars->fExpRed = 0;
}
+
+ if ( pPars->fUseBat )
+ {
+ if ( pPars->nLutSize < 4 || pPars->nLutSize > 6 )
+ {
+ Abc_Print( -1, "This feature only works for {4,5,6}-LUTs.\n" );
+ return 1;
+ }
+ pPars->fCutMin = 1;
+ }
+
// enable truth table computation if cut minimization is selected
if ( pPars->fCutMin )
{
@@ -12869,10 +12653,19 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv )
pPars->fExpRed = 0;
}
+ // modify for global delay optimization
+ if ( pPars->fDelayOpt )
+ {
+ pPars->fTruth = 1;
+ pPars->fExpRed = 0;
+ pPars->fUsePerm = 1;
+ pPars->pLutLib = NULL;
+ }
+
// complain if truth tables are requested but the cut size is too large
if ( pPars->fTruth && pPars->nLutSize > IF_MAX_FUNC_LUTSIZE )
{
- fprintf( pErr, "Truth tables cannot be computed for LUT larger than %d inputs.\n", IF_MAX_FUNC_LUTSIZE );
+ Abc_Print( -1, "Truth tables cannot be computed for LUT larger than %d inputs.\n", IF_MAX_FUNC_LUTSIZE );
return 1;
}
@@ -12886,23 +12679,23 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtk = Abc_NtkStrash( pNtk, 0, 0, 0 );
if ( pNtk == NULL )
{
- fprintf( pErr, "Strashing before FPGA mapping has failed.\n" );
+ Abc_Print( -1, "Strashing before FPGA mapping has failed.\n" );
return 1;
}
pNtk = Abc_NtkBalance( pNtkRes = pNtk, 0, 0, 1 );
Abc_NtkDelete( pNtkRes );
if ( pNtk == NULL )
{
- fprintf( pErr, "Balancing before FPGA mapping has failed.\n" );
+ Abc_Print( -1, "Balancing before FPGA mapping has failed.\n" );
return 1;
}
- fprintf( pOut, "The network was strashed and balanced before FPGA mapping.\n" );
+ Abc_Print( 1, "The network was strashed and balanced before FPGA mapping.\n" );
// get the new network
pNtkRes = Abc_NtkIf( pNtk, pPars );
if ( pNtkRes == NULL )
{
Abc_NtkDelete( pNtk );
- fprintf( pErr, "FPGA mapping has failed.\n" );
+ Abc_Print( -1, "FPGA mapping has failed.\n" );
return 0;
}
Abc_NtkDelete( pNtk );
@@ -12913,7 +12706,7 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtkRes = Abc_NtkIf( pNtk, pPars );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "FPGA mapping has failed.\n" );
+ Abc_Print( -1, "FPGA mapping has failed.\n" );
return 0;
}
}
@@ -12930,27 +12723,29 @@ usage:
sprintf( LutSize, "library" );
else
sprintf( LutSize, "%d", pPars->nLutSize );
- fprintf( pErr, "usage: if [-KCFA num] [-DE float] [-qarlepmsbvh]\n" );
- fprintf( pErr, "\t performs FPGA technology mapping of the network\n" );
- fprintf( pErr, "\t-K num : the number of LUT inputs (2 < num < %d) [default = %s]\n", IF_MAX_LUTSIZE+1, LutSize );
- fprintf( pErr, "\t-C num : the max number of priority cuts (0 < num < 2^12) [default = %d]\n", pPars->nCutsMax );
- fprintf( pErr, "\t-F num : the number of area flow recovery iterations (num >= 0) [default = %d]\n", pPars->nFlowIters );
- fprintf( pErr, "\t-A num : the number of exact area recovery iterations (num >= 0) [default = %d]\n", pPars->nAreaIters );
- fprintf( pErr, "\t-D float : sets the delay constraint for the mapping [default = %s]\n", Buffer );
- fprintf( pErr, "\t-E float : sets epsilon used for tie-breaking [default = %f]\n", pPars->Epsilon );
- fprintf( pErr, "\t-q : toggles preprocessing using several starting points [default = %s]\n", pPars->fPreprocess? "yes": "no" );
- fprintf( pErr, "\t-a : toggles area-oriented mapping [default = %s]\n", pPars->fArea? "yes": "no" );
-// fprintf( pErr, "\t-f : toggles one fancy feature [default = %s]\n", pPars->fFancy? "yes": "no" );
- fprintf( pErr, "\t-r : enables expansion/reduction of the best cuts [default = %s]\n", pPars->fExpRed? "yes": "no" );
- fprintf( pErr, "\t-l : optimizes latch paths for delay, other paths for area [default = %s]\n", pPars->fLatchPaths? "yes": "no" );
- fprintf( pErr, "\t-e : uses edge-based cut selection heuristics [default = %s]\n", pPars->fEdge? "yes": "no" );
- fprintf( pErr, "\t-p : uses power-aware cut selection heuristics [default = %s]\n", pPars->fPower? "yes": "no" );
- fprintf( pErr, "\t-m : enables cut minimization by removing vacuous variables [default = %s]\n", pPars->fCutMin? "yes": "no" );
- fprintf( pErr, "\t-s : toggles sequential mapping [default = %s]\n", pPars->fSeqMap? "yes": "no" );
-// fprintf( pErr, "\t-t : toggles the use of true sequential cuts [default = %s]\n", pPars->fLiftLeaves? "yes": "no" );
- fprintf( pErr, "\t-b : toggles deriving local AIGs using bi-decomposition [default = %s]\n", pPars->fBidec? "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");
+ Abc_Print( -2, "usage: if [-KCFA num] [-DE float] [-qarlepmsdbugvh]\n" );
+ Abc_Print( -2, "\t performs FPGA technology mapping of the network\n" );
+ Abc_Print( -2, "\t-K num : the number of LUT inputs (2 < num < %d) [default = %s]\n", IF_MAX_LUTSIZE+1, LutSize );
+ Abc_Print( -2, "\t-C num : the max number of priority cuts (0 < num < 2^12) [default = %d]\n", pPars->nCutsMax );
+ Abc_Print( -2, "\t-F num : the number of area flow recovery iterations (num >= 0) [default = %d]\n", pPars->nFlowIters );
+ Abc_Print( -2, "\t-A num : the number of exact area recovery iterations (num >= 0) [default = %d]\n", pPars->nAreaIters );
+ Abc_Print( -2, "\t-D float : sets the delay constraint for the mapping [default = %s]\n", Buffer );
+ Abc_Print( -2, "\t-E float : sets epsilon used for tie-breaking [default = %f]\n", pPars->Epsilon );
+ Abc_Print( -2, "\t-q : toggles preprocessing using several starting points [default = %s]\n", pPars->fPreprocess? "yes": "no" );
+ Abc_Print( -2, "\t-a : toggles area-oriented mapping [default = %s]\n", pPars->fArea? "yes": "no" );
+// Abc_Print( -2, "\t-f : toggles one fancy feature [default = %s]\n", pPars->fFancy? "yes": "no" );
+ Abc_Print( -2, "\t-r : enables expansion/reduction of the best cuts [default = %s]\n", pPars->fExpRed? "yes": "no" );
+ Abc_Print( -2, "\t-l : optimizes latch paths for delay, other paths for area [default = %s]\n", pPars->fLatchPaths? "yes": "no" );
+ Abc_Print( -2, "\t-e : uses edge-based cut selection heuristics [default = %s]\n", pPars->fEdge? "yes": "no" );
+ Abc_Print( -2, "\t-p : uses power-aware cut selection heuristics [default = %s]\n", pPars->fPower? "yes": "no" );
+ Abc_Print( -2, "\t-m : enables cut minimization by removing vacuous variables [default = %s]\n", pPars->fCutMin? "yes": "no" );
+ Abc_Print( -2, "\t-s : toggles sequential mapping [default = %s]\n", pPars->fSeqMap? "yes": "no" );
+ Abc_Print( -2, "\t-d : toggles deriving local AIGs using bi-decomposition [default = %s]\n", pPars->fBidec? "yes": "no" );
+ Abc_Print( -2, "\t-b : toggles the use of one special feature [default = %s]\n", pPars->fUseBat? "yes": "no" );
+ Abc_Print( -2, "\t-u : toggles the use of MUXes along with LUTs [default = %s]\n", fLutMux? "yes": "no" );
+ Abc_Print( -2, "\t-g : toggles global delay optimization [default = %s]\n", pPars->fDelayOpt? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : prints the command usage\n");
return 1;
}
@@ -12969,19 +12764,13 @@ usage:
***********************************************************************/
int Abc_CommandInit( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
Abc_Obj_t * pObj;
int c, i;
int fZeros;
int fOnes;
int fRandom;
int fDontCare;
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fZeros = 0;
fOnes = 0;
@@ -13013,13 +12802,13 @@ int Abc_CommandInit( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( Abc_NtkIsComb(pNtk) )
{
- fprintf( pErr, "The current network is combinational.\n" );
+ Abc_Print( -1, "The current network is combinational.\n" );
return 0;
}
@@ -13048,17 +12837,17 @@ int Abc_CommandInit( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_LatchSetInitDc( pObj );
}
else
- printf( "The initial states remain unchanged.\n" );
+ Abc_Print( -1, "The initial states remain unchanged.\n" );
return 0;
usage:
- fprintf( pErr, "usage: init [-zordh]\n" );
- fprintf( pErr, "\t resets initial states of all latches\n" );
- fprintf( pErr, "\t-z : set zeros initial states [default = %s]\n", fZeros? "yes": "no" );
- fprintf( pErr, "\t-o : set ones initial states [default = %s]\n", fOnes? "yes": "no" );
- fprintf( pErr, "\t-d : set don't-care initial states [default = %s]\n", fDontCare? "yes": "no" );
- fprintf( pErr, "\t-r : set random initial states [default = %s]\n", fRandom? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: init [-zordh]\n" );
+ Abc_Print( -2, "\t resets initial states of all latches\n" );
+ Abc_Print( -2, "\t-z : set zeros initial states [default = %s]\n", fZeros? "yes": "no" );
+ Abc_Print( -2, "\t-o : set ones initial states [default = %s]\n", fOnes? "yes": "no" );
+ Abc_Print( -2, "\t-d : set don't-care initial states [default = %s]\n", fDontCare? "yes": "no" );
+ Abc_Print( -2, "\t-r : set random initial states [default = %s]\n", fRandom? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -13075,16 +12864,12 @@ usage:
***********************************************************************/
int Abc_CommandZero( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c;
- extern Abc_Ntk_t * Abc_NtkRestrashZero( Abc_Ntk_t * pNtk, bool fCleanup );
+ extern Abc_Ntk_t * Abc_NtkRestrashZero( Abc_Ntk_t * pNtk, int fCleanup );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
@@ -13100,19 +12885,19 @@ int Abc_CommandZero( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( Abc_NtkIsComb(pNtk) )
{
- fprintf( pErr, "The current network is combinational.\n" );
+ Abc_Print( -1, "The current network is combinational.\n" );
return 0;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "This command works only for AIGs.\n" );
+ Abc_Print( -1, "This command works only for AIGs.\n" );
return 0;
}
@@ -13120,7 +12905,7 @@ int Abc_CommandZero( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtkRes = Abc_NtkRestrashZero( pNtk, 0 );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Converting to sequential AIG has failed.\n" );
+ Abc_Print( -1, "Converting to sequential AIG has failed.\n" );
return 1;
}
// replace the current network
@@ -13128,9 +12913,9 @@ int Abc_CommandZero( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: zero [-h]\n" );
- fprintf( pErr, "\t converts latches to have const-0 initial value\n" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: zero [-h]\n" );
+ Abc_Print( -2, "\t converts latches to have const-0 initial value\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -13147,14 +12932,8 @@ usage:
***********************************************************************/
int Abc_CommandUndc( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
@@ -13170,19 +12949,19 @@ int Abc_CommandUndc( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( Abc_NtkIsComb(pNtk) )
{
- fprintf( pErr, "The current network is combinational.\n" );
+ Abc_Print( -1, "The current network is combinational.\n" );
return 0;
}
if ( !Abc_NtkIsLogic(pNtk) )
{
- fprintf( pErr, "This command works only for logic networks.\n" );
+ Abc_Print( -1, "This command works only for logic networks.\n" );
return 0;
}
@@ -13191,9 +12970,9 @@ int Abc_CommandUndc( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: undc [-h]\n" );
- fprintf( pErr, "\t converts latches with DC init values into free PIs\n" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: undc [-h]\n" );
+ Abc_Print( -2, "\t converts latches with DC init values into free PIs\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -13210,15 +12989,11 @@ usage:
***********************************************************************/
int Abc_CommandOneHot( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c;
extern Abc_Ntk_t * Abc_NtkConvertOnehot( Abc_Ntk_t * pNtk );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
@@ -13233,24 +13008,24 @@ int Abc_CommandOneHot( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( Abc_NtkIsComb(pNtk) )
{
- fprintf( pErr, "The current network is combinational.\n" );
+ Abc_Print( -1, "The current network is combinational.\n" );
return 0;
}
if ( !Abc_NtkIsLogic(pNtk) )
{
- fprintf( pErr, "This command works only for logic networks.\n" );
+ Abc_Print( -1, "This command works only for logic networks.\n" );
return 0;
}
// get the new network
pNtkRes = Abc_NtkConvertOnehot( pNtk );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Converting to one-hot encoding has failed.\n" );
+ Abc_Print( -1, "Converting to one-hot encoding has failed.\n" );
return 1;
}
// replace the current network
@@ -13258,9 +13033,9 @@ int Abc_CommandOneHot( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: onehot [-h]\n" );
- fprintf( pErr, "\t converts natural encoding into one-hot encoding\n" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: onehot [-h]\n" );
+ Abc_Print( -2, "\t converts natural encoding into one-hot encoding\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -13277,16 +13052,10 @@ usage:
***********************************************************************/
int Abc_CommandPipe( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
int nLatches;
extern void Abc_NtkLatchPipe( Abc_Ntk_t * pNtk, int nLatches );
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
nLatches = 5;
Extra_UtilGetoptReset();
@@ -13297,7 +13066,7 @@ int Abc_CommandPipe( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'L':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-L\" should be followed by a positive integer.\n" );
+ Abc_Print( -1, "Command line switch \"-L\" should be followed by a positive integer.\n" );
goto usage;
}
nLatches = atoi(argv[globalUtilOptind]);
@@ -13314,13 +13083,13 @@ int Abc_CommandPipe( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( Abc_NtkIsComb(pNtk) )
{
- fprintf( pErr, "The current network is combinational.\n" );
+ Abc_Print( -1, "The current network is combinational.\n" );
return 0;
}
@@ -13329,10 +13098,10 @@ int Abc_CommandPipe( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: pipe [-L num] [-h]\n" );
- fprintf( pErr, "\t inserts the given number of latches at each PI for pipelining\n" );
- fprintf( pErr, "\t-L num : the number of latches to insert [default = %d]\n", nLatches );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: pipe [-L num] [-h]\n" );
+ Abc_Print( -2, "\t inserts the given number of latches at each PI for pipelining\n" );
+ Abc_Print( -2, "\t-L num : the number of latches to insert [default = %d]\n", nLatches );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -13349,14 +13118,10 @@ usage:
***********************************************************************/
int Abc_CommandSeq( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c;
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
@@ -13372,19 +13137,19 @@ int Abc_CommandSeq( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( Abc_NtkLatchNum(pNtk) == 0 )
{
- fprintf( pErr, "The network has no latches.\n" );
+ Abc_Print( -1, "The network has no latches.\n" );
return 0;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "Conversion to sequential AIG works only for combinational AIGs (run \"strash\").\n" );
+ Abc_Print( -1, "Conversion to sequential AIG works only for combinational AIGs (run \"strash\").\n" );
return 1;
}
@@ -13393,7 +13158,7 @@ int Abc_CommandSeq( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtkRes = NULL;
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Converting to sequential AIG has failed.\n" );
+ Abc_Print( -1, "Converting to sequential AIG has failed.\n" );
return 1;
}
// replace the current network
@@ -13401,9 +13166,9 @@ int Abc_CommandSeq( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: seq [-h]\n" );
- fprintf( pErr, "\t converts AIG into sequential AIG\n" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: seq [-h]\n" );
+ Abc_Print( -2, "\t converts AIG into sequential AIG\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -13420,15 +13185,11 @@ usage:
***********************************************************************/
int Abc_CommandUnseq( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c;
int fShare;
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fShare = 1;
Extra_UtilGetoptReset();
@@ -13448,13 +13209,13 @@ int Abc_CommandUnseq( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
/*
if ( !Abc_NtkIsSeq(pNtk) )
{
- fprintf( pErr, "Conversion to combinational AIG works only for sequential AIG (run \"seq\").\n" );
+ Abc_Print( -1, "Conversion to combinational AIG works only for sequential AIG (run \"seq\").\n" );
return 1;
}
*/
@@ -13467,7 +13228,7 @@ int Abc_CommandUnseq( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtkRes = NULL;
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Converting sequential AIG into an SOP logic network has failed.\n" );
+ Abc_Print( -1, "Converting sequential AIG into an SOP logic network has failed.\n" );
return 1;
}
// replace the current network
@@ -13475,10 +13236,10 @@ int Abc_CommandUnseq( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: unseq [-sh]\n" );
- fprintf( pErr, "\t converts sequential AIG into an SOP logic network\n" );
- fprintf( pErr, "\t-s : toggle sharing latches [default = %s]\n", fShare? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: unseq [-sh]\n" );
+ Abc_Print( -2, "\t converts sequential AIG into an SOP logic network\n" );
+ Abc_Print( -2, "\t-s : toggle sharing latches [default = %s]\n", fShare? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -13495,7 +13256,6 @@ usage:
***********************************************************************/
int Abc_CommandRetime( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c, nMaxIters;
int fForward;
@@ -13503,28 +13263,26 @@ int Abc_CommandRetime( Abc_Frame_t * pAbc, int argc, char ** argv )
int fOneStep;
int fVerbose;
int Mode;
- extern int Abc_NtkRetime( Abc_Ntk_t * pNtk, int Mode, int fForwardOnly, int fBackwardOnly, int fOneStep, int fVerbose );
+ int nDelayLim;
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Mode = 5;
+ nDelayLim = 0;
fForward = 0;
fBackward = 0;
fOneStep = 0;
fVerbose = 0;
nMaxIters = 15;
Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "Mfbsvh" ) ) != EOF )
+ while ( ( c = Extra_UtilGetopt( argc, argv, "MDfbsvh" ) ) != EOF )
{
switch ( c )
{
case 'M':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-M\" should be followed by a positive integer.\n" );
+ Abc_Print( -1, "Command line switch \"-M\" should be followed by a positive integer.\n" );
goto usage;
}
Mode = atoi(argv[globalUtilOptind]);
@@ -13532,6 +13290,17 @@ int Abc_CommandRetime( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( Mode < 0 )
goto usage;
break;
+ case 'D':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-D\" should be followed by a positive integer.\n" );
+ goto usage;
+ }
+ nDelayLim = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( nDelayLim < 0 )
+ goto usage;
+ break;
case 'f':
fForward ^= 1;
break;
@@ -13553,25 +13322,25 @@ int Abc_CommandRetime( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( fForward && fBackward )
{
- fprintf( pErr, "Only one switch \"-f\" or \"-b\" can be selected at a time.\n" );
+ Abc_Print( -1, "Only one switch \"-f\" or \"-b\" can be selected at a time.\n" );
return 1;
}
if ( !Abc_NtkLatchNum(pNtk) )
{
- fprintf( pErr, "The network has no latches. Retiming is not performed.\n" );
+ Abc_Print( -1, "The network has no latches. Retiming is not performed.\n" );
return 0;
}
if ( Mode < 0 || Mode > 6 )
{
- fprintf( pErr, "The mode (%d) is incorrect. Retiming is not performed.\n", Mode );
+ Abc_Print( -1, "The mode (%d) is incorrect. Retiming is not performed.\n", Mode );
return 0;
}
@@ -13579,13 +13348,13 @@ int Abc_CommandRetime( Abc_Frame_t * pAbc, int argc, char ** argv )
{
if ( Abc_NtkGetChoiceNum(pNtk) )
{
- fprintf( pErr, "Retiming with choice nodes is not implemented.\n" );
+ Abc_Print( -1, "Retiming with choice nodes is not implemented.\n" );
return 0;
}
// convert the network into an SOP network
pNtkRes = Abc_NtkToLogic( pNtk );
// perform the retiming
- Abc_NtkRetime( pNtkRes, Mode, fForward, fBackward, fOneStep, fVerbose );
+ Abc_NtkRetime( pNtkRes, Mode, nDelayLim, fForward, fBackward, fOneStep, fVerbose );
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
return 0;
@@ -13594,40 +13363,41 @@ int Abc_CommandRetime( Abc_Frame_t * pAbc, int argc, char ** argv )
// get the network in the SOP form
if ( !Abc_NtkToSop(pNtk, 0) )
{
- printf( "Converting to SOPs has failed.\n" );
+ Abc_Print( -1, "Converting to SOPs has failed.\n" );
return 0;
}
if ( !Abc_NtkIsLogic(pNtk) )
{
- fprintf( pErr, "The network is not a logic network. Retiming is not performed.\n" );
+ Abc_Print( -1, "The network is not a logic network. Retiming is not performed.\n" );
return 0;
}
// perform the retiming
- Abc_NtkRetime( pNtk, Mode, fForward, fBackward, fOneStep, fVerbose );
+ Abc_NtkRetime( pNtk, Mode, nDelayLim, fForward, fBackward, fOneStep, fVerbose );
return 0;
usage:
- fprintf( pErr, "usage: retime [-M num] [-fbvh]\n" );
- fprintf( pErr, "\t retimes the current network using one of the algorithms:\n" );
- fprintf( pErr, "\t 1: most forward retiming\n" );
- fprintf( pErr, "\t 2: most backward retiming\n" );
- 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" );
- fprintf( pErr, "\t-s : enables retiming one step only in mode 4 [default = %s]\n", fOneStep? "yes": "no" );
- fprintf( pErr, "\t-v : enables verbose output [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: retime [-MD num] [-fbvh]\n" );
+ Abc_Print( -2, "\t retimes the current network using one of the algorithms:\n" );
+ Abc_Print( -2, "\t 1: most forward retiming\n" );
+ Abc_Print( -2, "\t 2: most backward retiming\n" );
+ Abc_Print( -2, "\t 3: forward and backward min-area retiming\n" );
+ Abc_Print( -2, "\t 4: forward and backward min-delay retiming\n" );
+ Abc_Print( -2, "\t 5: mode 3 followed by mode 4\n" );
+ Abc_Print( -2, "\t 6: Pan's optimum-delay retiming using binary search\n" );
+ Abc_Print( -2, "\t-M num : the retiming algorithm to use [default = %d]\n", Mode );
+ Abc_Print( -2, "\t-D num : the minimum delay target (0=unused) [default = %d]\n", nDelayLim );
+ Abc_Print( -2, "\t-f : enables forward-only retiming in modes 3,4,5 [default = %s]\n", fForward? "yes": "no" );
+ Abc_Print( -2, "\t-b : enables backward-only retiming in modes 3,4,5 [default = %s]\n", fBackward? "yes": "no" );
+ Abc_Print( -2, "\t-s : enables retiming one step only in mode 4 [default = %s]\n", fOneStep? "yes": "no" );
+ Abc_Print( -2, "\t-v : enables verbose output [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
-// fprintf( pErr, "\t-I num : max number of iterations of l-value computation [default = %d]\n", nMaxIters );
-// fprintf( pErr, "\t-f : toggle forward retiming (for AIGs) [default = %s]\n", fForward? "yes": "no" );
-// fprintf( pErr, "\t-b : toggle backward retiming (for AIGs) [default = %s]\n", fBackward? "yes": "no" );
-// fprintf( pErr, "\t-i : toggle computation of initial state [default = %s]\n", fInitial? "yes": "no" );
+// Abc_Print( -2, "\t-I num : max number of iterations of l-value computation [default = %d]\n", nMaxIters );
+// Abc_Print( -2, "\t-f : toggle forward retiming (for AIGs) [default = %s]\n", fForward? "yes": "no" );
+// Abc_Print( -2, "\t-b : toggle backward retiming (for AIGs) [default = %s]\n", fBackward? "yes": "no" );
+// Abc_Print( -2, "\t-i : toggle computation of initial state [default = %s]\n", fInitial? "yes": "no" );
}
/**Function*************************************************************
@@ -13643,7 +13413,6 @@ usage:
***********************************************************************/
int Abc_CommandDRetime( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int fMinArea;
int fForwardOnly;
@@ -13659,9 +13428,6 @@ int Abc_CommandDRetime( Abc_Frame_t * pAbc, int argc, char ** argv )
extern Abc_Ntk_t * Abc_NtkDarRetimeMostFwd( Abc_Ntk_t * pNtk, int nMaxIters, int fVerbose );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fMinArea = 1;
fForwardOnly = 0;
@@ -13679,7 +13445,7 @@ int Abc_CommandDRetime( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'N':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-N\" should be followed by a positive integer.\n" );
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by a positive integer.\n" );
goto usage;
}
nMaxIters = atoi(argv[globalUtilOptind]);
@@ -13690,7 +13456,7 @@ int Abc_CommandDRetime( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'S':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-S\" should be followed by a positive integer.\n" );
+ Abc_Print( -1, "Command line switch \"-S\" should be followed by a positive integer.\n" );
goto usage;
}
nStepsMax = atoi(argv[globalUtilOptind]);
@@ -13725,19 +13491,19 @@ int Abc_CommandDRetime( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkLatchNum(pNtk) )
{
- fprintf( pErr, "The network has no latches. Retiming is not performed.\n" );
+ Abc_Print( -1, "The network has no latches. Retiming is not performed.\n" );
return 0;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- printf( "This command works only for structrally hashed networks. Run \"st\".\n" );
+ Abc_Print( -1, "This command works only for structrally hashed networks. Run \"st\".\n" );
return 0;
}
@@ -13751,7 +13517,7 @@ int Abc_CommandDRetime( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtkRes = Abc_NtkDarRetimeMostFwd( pNtk, nMaxIters, fVerbose );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Retiming has failed.\n" );
+ Abc_Print( -1, "Retiming has failed.\n" );
return 1;
}
// replace the current network
@@ -13759,17 +13525,17 @@ int Abc_CommandDRetime( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: dretime [-NS num] [-mfbiavh]\n" );
- fprintf( pErr, "\t new implementation of min-area (or most-forward) retiming\n" );
- fprintf( pErr, "\t-m : toggle min-area retiming and most-forward retiming [default = %s]\n", fMinArea? "min-area": "most-fwd" );
- fprintf( pErr, "\t-f : enables forward-only retiming [default = %s]\n", fForwardOnly? "yes": "no" );
- fprintf( pErr, "\t-b : enables backward-only retiming [default = %s]\n", fBackwardOnly? "yes": "no" );
- fprintf( pErr, "\t-i : enables init state computation [default = %s]\n", fInitial? "yes": "no" );
- fprintf( pErr, "\t-N num : the max number of one-frame iterations to perform [default = %d]\n", nMaxIters );
- fprintf( pErr, "\t-S num : the max number of forward retiming steps to perform [default = %d]\n", nStepsMax );
- fprintf( pErr, "\t-a : enables a fast most-forward algorithm [default = %s]\n", fFastAlgo? "yes": "no" );
- fprintf( pErr, "\t-v : enables verbose output [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: dretime [-NS num] [-mfbiavh]\n" );
+ Abc_Print( -2, "\t new implementation of min-area (or most-forward) retiming\n" );
+ Abc_Print( -2, "\t-m : toggle min-area retiming and most-forward retiming [default = %s]\n", fMinArea? "min-area": "most-fwd" );
+ Abc_Print( -2, "\t-f : enables forward-only retiming [default = %s]\n", fForwardOnly? "yes": "no" );
+ Abc_Print( -2, "\t-b : enables backward-only retiming [default = %s]\n", fBackwardOnly? "yes": "no" );
+ Abc_Print( -2, "\t-i : enables init state computation [default = %s]\n", fInitial? "yes": "no" );
+ Abc_Print( -2, "\t-N num : the max number of one-frame iterations to perform [default = %d]\n", nMaxIters );
+ Abc_Print( -2, "\t-S num : the max number of forward retiming steps to perform [default = %d]\n", nStepsMax );
+ Abc_Print( -2, "\t-a : enables a fast most-forward algorithm [default = %s]\n", fFastAlgo? "yes": "no" );
+ Abc_Print( -2, "\t-v : enables verbose output [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -13786,7 +13552,6 @@ usage:
***********************************************************************/
int Abc_CommandFlowRetime( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c, nMaxIters;
int fForward;
@@ -13796,7 +13561,7 @@ int Abc_CommandFlowRetime( Abc_Frame_t * pAbc, int argc, char ** argv )
int fFastButConservative;
int maxDelay;
- printf( "This command is temporarily disabled.\n" );
+ Abc_Print( -1, "This command is temporarily disabled.\n" );
return 0;
// extern Abc_Ntk_t* Abc_FlowRetime_MinReg( Abc_Ntk_t * pNtk, int fVerbose,
// int fComputeInit, int fGuaranteeInit, int fBlockConst,
@@ -13804,9 +13569,6 @@ int Abc_CommandFlowRetime( Abc_Frame_t * pAbc, int argc, char ** argv )
// int maxDelay, int fFastButConservative);
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fForward = 0;
fFastButConservative = 0;
@@ -13825,7 +13587,7 @@ int Abc_CommandFlowRetime( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'M':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-M\" should be followed by a positive integer.\n" );
+ Abc_Print( -1, "Command line switch \"-M\" should be followed by a positive integer.\n" );
goto usage;
}
nMaxIters = atoi(argv[globalUtilOptind]);
@@ -13836,7 +13598,7 @@ int Abc_CommandFlowRetime( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'D':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-D\" should be followed by a positive integer.\n" );
+ Abc_Print( -1, "Command line switch \"-D\" should be followed by a positive integer.\n" );
goto usage;
}
maxDelay = atoi(argv[globalUtilOptind]);
@@ -13874,31 +13636,31 @@ int Abc_CommandFlowRetime( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( fForward && fBackward )
{
- fprintf( pErr, "Only one switch \"-f\" or \"-b\" can be selected at a time.\n" );
+ Abc_Print( -1, "Only one switch \"-f\" or \"-b\" can be selected at a time.\n" );
return 1;
}
if ( fGuaranteeInit && !fComputeInit )
{
- fprintf( pErr, "Initial state guarantee (-g) requires initial state computation (-i).\n" );
+ Abc_Print( -1, "Initial state guarantee (-g) requires initial state computation (-i).\n" );
return 1;
}
if ( !Abc_NtkLatchNum(pNtk) )
{
- fprintf( pErr, "The network has no latches. Retiming is not performed.\n" );
+ Abc_Print( -1, "The network has no latches. Retiming is not performed.\n" );
return 0;
}
if ( Abc_NtkGetChoiceNum(pNtk) )
{
- fprintf( pErr, "Retiming with choice nodes is not implemented.\n" );
+ Abc_Print( -1, "Retiming with choice nodes is not implemented.\n" );
return 0;
}
@@ -13914,18 +13676,18 @@ int Abc_CommandFlowRetime( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: fretime [-M num] [-D num] [-fbvih]\n" );
- fprintf( pErr, "\t retimes the current network using flow-based algorithm\n" );
- fprintf( pErr, "\t-M num : the maximum number of iterations [default = %d]\n", nMaxIters );
- fprintf( pErr, "\t-D num : the maximum delay [default = none]\n" );
- fprintf( pErr, "\t-i : enables init state computation [default = %s]\n", fComputeInit? "yes": "no" );
- fprintf( pErr, "\t-k : blocks retiming over const nodes [default = %s]\n", fBlockConst? "yes": "no" );
- fprintf( pErr, "\t-g : guarantees init state computation [default = %s]\n", fGuaranteeInit? "yes": "no" );
- fprintf( pErr, "\t-c : very fast (but conserv.) delay constraints [default = %s]\n", fFastButConservative? "yes": "no" );
- fprintf( pErr, "\t-f : enables forward-only retiming [default = %s]\n", fForward? "yes": "no" );
- fprintf( pErr, "\t-b : enables backward-only retiming [default = %s]\n", fBackward? "yes": "no" );
- fprintf( pErr, "\t-v : enables verbose output [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: fretime [-M num] [-D num] [-fbvih]\n" );
+ Abc_Print( -2, "\t retimes the current network using flow-based algorithm\n" );
+ Abc_Print( -2, "\t-M num : the maximum number of iterations [default = %d]\n", nMaxIters );
+ Abc_Print( -2, "\t-D num : the maximum delay [default = none]\n" );
+ Abc_Print( -2, "\t-i : enables init state computation [default = %s]\n", fComputeInit? "yes": "no" );
+ Abc_Print( -2, "\t-k : blocks retiming over const nodes [default = %s]\n", fBlockConst? "yes": "no" );
+ Abc_Print( -2, "\t-g : guarantees init state computation [default = %s]\n", fGuaranteeInit? "yes": "no" );
+ Abc_Print( -2, "\t-c : very fast (but conserv.) delay constraints [default = %s]\n", fFastButConservative? "yes": "no" );
+ Abc_Print( -2, "\t-f : enables forward-only retiming [default = %s]\n", fForward? "yes": "no" );
+ Abc_Print( -2, "\t-b : enables backward-only retiming [default = %s]\n", fBackward? "yes": "no" );
+ Abc_Print( -2, "\t-v : enables verbose output [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -13942,16 +13704,12 @@ usage:
***********************************************************************/
int Abc_CommandCRetime( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c;
int fVerbose;
extern Abc_Ntk_t * Abc_NtkCRetime( Abc_Ntk_t * pNtk, int fVerbose );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fVerbose = 0;
Extra_UtilGetoptReset();
@@ -13970,24 +13728,24 @@ int Abc_CommandCRetime( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "Only works for logic networks.\n" );
+ Abc_Print( -1, "Only works for logic networks.\n" );
return 1;
}
if ( !Abc_NtkLatchNum(pNtk) )
{
- fprintf( pErr, "The network is combinational.\n" );
+ Abc_Print( -1, "The network is combinational.\n" );
return 0;
}
// modify the current network
pNtkRes = Abc_NtkCRetime( pNtk, fVerbose );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Sequential cleanup has failed.\n" );
+ Abc_Print( -1, "Sequential cleanup has failed.\n" );
return 1;
}
// replace the current network
@@ -13995,10 +13753,10 @@ int Abc_CommandCRetime( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: cretime [-vh]\n" );
- fprintf( pErr, "\t performs most-forward retiming with equiv classes\n" );
- fprintf( pErr, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: cretime [-vh]\n" );
+ Abc_Print( -2, "\t performs most-forward retiming with equiv classes\n" );
+ Abc_Print( -2, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -14015,15 +13773,11 @@ usage:
***********************************************************************/
int Abc_CommandSeqFpga( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkNew, * pNtkRes;
int c, nMaxIters;
int fVerbose;
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
nMaxIters = 15;
fVerbose = 0;
@@ -14035,7 +13789,7 @@ int Abc_CommandSeqFpga( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'I':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-I\" should be followed by a positive integer.\n" );
+ Abc_Print( -1, "Command line switch \"-I\" should be followed by a positive integer.\n" );
goto usage;
}
nMaxIters = atoi(argv[globalUtilOptind]);
@@ -14055,7 +13809,7 @@ int Abc_CommandSeqFpga( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
@@ -14065,7 +13819,7 @@ int Abc_CommandSeqFpga( Abc_Frame_t * pAbc, int argc, char ** argv )
// quit if there are choice nodes
if ( Abc_NtkGetChoiceNum(pNtk) )
{
- fprintf( pErr, "Currently cannot map/retime networks with choice nodes.\n" );
+ Abc_Print( -1, "Currently cannot map/retime networks with choice nodes.\n" );
return 0;
}
*/
@@ -14081,7 +13835,7 @@ int Abc_CommandSeqFpga( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtkNew = Abc_NtkStrash( pNtk, 0, 0, 0 );
if ( pNtkNew == NULL )
{
- fprintf( pErr, "Strashing before FPGA mapping/retiming has failed.\n" );
+ Abc_Print( -1, "Strashing before FPGA mapping/retiming has failed.\n" );
return 1;
}
@@ -14089,7 +13843,7 @@ int Abc_CommandSeqFpga( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_NtkDelete( pNtkRes );
if ( pNtkNew == NULL )
{
- fprintf( pErr, "Balancing before FPGA mapping has failed.\n" );
+ Abc_Print( -1, "Balancing before FPGA mapping has failed.\n" );
return 1;
}
@@ -14099,11 +13853,11 @@ int Abc_CommandSeqFpga( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_NtkDelete( pNtkRes );
if ( pNtkNew == NULL )
{
- fprintf( pErr, "Converting into a seq AIG before FPGA mapping/retiming has failed.\n" );
+ Abc_Print( -1, "Converting into a seq AIG before FPGA mapping/retiming has failed.\n" );
return 1;
}
- fprintf( pOut, "The network was strashed and balanced before FPGA mapping/retiming.\n" );
+ Abc_Print( 1, "The network was strashed and balanced before FPGA mapping/retiming.\n" );
}
// get the new network
@@ -14111,7 +13865,7 @@ int Abc_CommandSeqFpga( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtkRes = NULL;
if ( pNtkRes == NULL )
{
-// fprintf( pErr, "Sequential FPGA mapping has failed.\n" );
+// Abc_Print( -1, "Sequential FPGA mapping has failed.\n" );
Abc_NtkDelete( pNtkNew );
return 0;
}
@@ -14121,11 +13875,11 @@ int Abc_CommandSeqFpga( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: sfpga [-I num] [-vh]\n" );
- fprintf( pErr, "\t performs integrated sequential FPGA mapping/retiming\n" );
- fprintf( pErr, "\t-I num : max number of iterations of l-value computation [default = %d]\n", nMaxIters );
- fprintf( pErr, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: sfpga [-I num] [-vh]\n" );
+ Abc_Print( -2, "\t performs integrated sequential FPGA mapping/retiming\n" );
+ Abc_Print( -2, "\t-I num : max number of iterations of l-value computation [default = %d]\n", nMaxIters );
+ Abc_Print( -2, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -14142,15 +13896,11 @@ usage:
***********************************************************************/
int Abc_CommandSeqMap( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkNew, * pNtkRes;
int c, nMaxIters;
int fVerbose;
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
nMaxIters = 15;
fVerbose = 0;
@@ -14162,7 +13912,7 @@ int Abc_CommandSeqMap( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'I':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-I\" should be followed by a positive integer.\n" );
+ Abc_Print( -1, "Command line switch \"-I\" should be followed by a positive integer.\n" );
goto usage;
}
nMaxIters = atoi(argv[globalUtilOptind]);
@@ -14182,7 +13932,7 @@ int Abc_CommandSeqMap( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
@@ -14192,7 +13942,7 @@ int Abc_CommandSeqMap( Abc_Frame_t * pAbc, int argc, char ** argv )
// quit if there are choice nodes
if ( Abc_NtkGetChoiceNum(pNtk) )
{
- fprintf( pErr, "Currently cannot map/retime networks with choice nodes.\n" );
+ Abc_Print( -1, "Currently cannot map/retime networks with choice nodes.\n" );
return 0;
}
*/
@@ -14208,7 +13958,7 @@ int Abc_CommandSeqMap( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtkNew = Abc_NtkStrash( pNtk, 0, 0, 0 );
if ( pNtkNew == NULL )
{
- fprintf( pErr, "Strashing before SC mapping/retiming has failed.\n" );
+ Abc_Print( -1, "Strashing before SC mapping/retiming has failed.\n" );
return 1;
}
@@ -14216,7 +13966,7 @@ int Abc_CommandSeqMap( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_NtkDelete( pNtkRes );
if ( pNtkNew == NULL )
{
- fprintf( pErr, "Balancing before SC mapping/retiming has failed.\n" );
+ Abc_Print( -1, "Balancing before SC mapping/retiming has failed.\n" );
return 1;
}
@@ -14226,11 +13976,11 @@ int Abc_CommandSeqMap( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_NtkDelete( pNtkRes );
if ( pNtkNew == NULL )
{
- fprintf( pErr, "Converting into a seq AIG before SC mapping/retiming has failed.\n" );
+ Abc_Print( -1, "Converting into a seq AIG before SC mapping/retiming has failed.\n" );
return 1;
}
- fprintf( pOut, "The network was strashed and balanced before SC mapping/retiming.\n" );
+ Abc_Print( -1, "The network was strashed and balanced before SC mapping/retiming.\n" );
}
// get the new network
@@ -14238,7 +13988,7 @@ int Abc_CommandSeqMap( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtkRes = NULL;
if ( pNtkRes == NULL )
{
-// fprintf( pErr, "Sequential FPGA mapping has failed.\n" );
+// Abc_Print( -1, "Sequential FPGA mapping has failed.\n" );
Abc_NtkDelete( pNtkNew );
return 0;
}
@@ -14249,11 +13999,11 @@ int Abc_CommandSeqMap( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: smap [-I num] [-vh]\n" );
- fprintf( pErr, "\t performs integrated sequential standard-cell mapping/retiming\n" );
- fprintf( pErr, "\t-I num : max number of iterations of l-value computation [default = %d]\n", nMaxIters );
- fprintf( pErr, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: smap [-I num] [-vh]\n" );
+ Abc_Print( -2, "\t performs integrated sequential standard-cell mapping/retiming\n" );
+ Abc_Print( -2, "\t-I num : max number of iterations of l-value computation [default = %d]\n", nMaxIters );
+ Abc_Print( -2, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -14270,16 +14020,12 @@ usage:
***********************************************************************/
int Abc_CommandSeqSweep( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
Fra_Ssw_t Pars, * pPars = &Pars;
int c;
extern Abc_Ntk_t * Abc_NtkDarSeqSweep( Abc_Ntk_t * pNtk, Fra_Ssw_t * pPars );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
pPars->nPartSize = 0;
pPars->nOverSize = 0;
@@ -14303,7 +14049,7 @@ int Abc_CommandSeqSweep( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'P':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-P\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
goto usage;
}
pPars->nPartSize = atoi(argv[globalUtilOptind]);
@@ -14314,7 +14060,7 @@ int Abc_CommandSeqSweep( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'Q':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-Q\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-Q\" should be followed by an integer.\n" );
goto usage;
}
pPars->nOverSize = atoi(argv[globalUtilOptind]);
@@ -14325,7 +14071,7 @@ int Abc_CommandSeqSweep( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'N':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
goto usage;
}
pPars->nFramesP = atoi(argv[globalUtilOptind]);
@@ -14336,7 +14082,7 @@ int Abc_CommandSeqSweep( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
pPars->nFramesK = atoi(argv[globalUtilOptind]);
@@ -14347,7 +14093,7 @@ int Abc_CommandSeqSweep( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'I':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-I\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
goto usage;
}
pPars->nMaxImps = atoi(argv[globalUtilOptind]);
@@ -14358,7 +14104,7 @@ int Abc_CommandSeqSweep( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'L':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-L\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
goto usage;
}
pPars->nMaxLevs = atoi(argv[globalUtilOptind]);
@@ -14396,31 +14142,31 @@ int Abc_CommandSeqSweep( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( Abc_NtkIsComb(pNtk) )
{
- fprintf( pErr, "The network is combinational (run \"fraig\" or \"fraig_sweep\").\n" );
+ Abc_Print( -1, "The network is combinational (run \"fraig\" or \"fraig_sweep\").\n" );
return 0;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- printf( "This command works only for structrally hashed networks. Run \"st\".\n" );
+ Abc_Print( -1, "This command works only for structrally hashed networks. Run \"st\".\n" );
return 0;
}
if ( pPars->nFramesK > 1 && pPars->fUse1Hot )
{
- printf( "Currrently can only use one-hotness for simple induction (K=1).\n" );
+ Abc_Print( -1, "Currrently can only use one-hotness for simple induction (K=1).\n" );
return 0;
}
if ( pPars->nFramesP && pPars->fUse1Hot )
{
- printf( "Currrently can only use one-hotness without prefix.\n" );
+ Abc_Print( -1, "Currrently can only use one-hotness without prefix.\n" );
return 0;
}
@@ -14428,7 +14174,7 @@ int Abc_CommandSeqSweep( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtkRes = Abc_NtkDarSeqSweep( pNtk, pPars );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Sequential sweeping has failed.\n" );
+ Abc_Print( -1, "Sequential sweeping has failed.\n" );
return 1;
}
// replace the current network
@@ -14436,22 +14182,22 @@ int Abc_CommandSeqSweep( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: ssweep [-PQNFL <num>] [-lrfetvh]\n" );
- fprintf( pErr, "\t performs sequential sweep using K-step induction\n" );
- fprintf( pErr, "\t-P num : max partition size (0 = no partitioning) [default = %d]\n", pPars->nPartSize );
- fprintf( pErr, "\t-Q num : partition overlap (0 = no overlap) [default = %d]\n", pPars->nOverSize );
- fprintf( pErr, "\t-N num : number of time frames to use as the prefix [default = %d]\n", pPars->nFramesP );
- fprintf( pErr, "\t-F num : number of time frames for induction (1=simple) [default = %d]\n", pPars->nFramesK );
- fprintf( pErr, "\t-L num : max number of levels to consider (0=all) [default = %d]\n", pPars->nMaxLevs );
-// fprintf( pErr, "\t-I num : max number of implications to consider [default = %d]\n", pPars->nMaxImps );
-// fprintf( pErr, "\t-i : toggle using implications [default = %s]\n", pPars->fUseImps? "yes": "no" );
- fprintf( pErr, "\t-l : toggle latch correspondence only [default = %s]\n", pPars->fLatchCorr? "yes": "no" );
- fprintf( pErr, "\t-r : toggle AIG rewriting [default = %s]\n", pPars->fRewrite? "yes": "no" );
- fprintf( pErr, "\t-f : toggle fraiging (combinational SAT sweeping) [default = %s]\n", pPars->fFraiging? "yes": "no" );
- fprintf( pErr, "\t-e : toggle writing implications as assertions [default = %s]\n", pPars->fWriteImps? "yes": "no" );
- fprintf( pErr, "\t-t : toggle using one-hotness conditions [default = %s]\n", pPars->fUse1Hot? "yes": "no" );
- fprintf( pErr, "\t-v : toggle verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: ssweep [-PQNFL <num>] [-lrfetvh]\n" );
+ Abc_Print( -2, "\t performs sequential sweep using K-step induction\n" );
+ Abc_Print( -2, "\t-P num : max partition size (0 = no partitioning) [default = %d]\n", pPars->nPartSize );
+ Abc_Print( -2, "\t-Q num : partition overlap (0 = no overlap) [default = %d]\n", pPars->nOverSize );
+ Abc_Print( -2, "\t-N num : number of time frames to use as the prefix [default = %d]\n", pPars->nFramesP );
+ Abc_Print( -2, "\t-F num : number of time frames for induction (1=simple) [default = %d]\n", pPars->nFramesK );
+ Abc_Print( -2, "\t-L num : max number of levels to consider (0=all) [default = %d]\n", pPars->nMaxLevs );
+// Abc_Print( -2, "\t-I num : max number of implications to consider [default = %d]\n", pPars->nMaxImps );
+// Abc_Print( -2, "\t-i : toggle using implications [default = %s]\n", pPars->fUseImps? "yes": "no" );
+ Abc_Print( -2, "\t-l : toggle latch correspondence only [default = %s]\n", pPars->fLatchCorr? "yes": "no" );
+ Abc_Print( -2, "\t-r : toggle AIG rewriting [default = %s]\n", pPars->fRewrite? "yes": "no" );
+ Abc_Print( -2, "\t-f : toggle fraiging (combinational SAT sweeping) [default = %s]\n", pPars->fFraiging? "yes": "no" );
+ Abc_Print( -2, "\t-e : toggle writing implications as assertions [default = %s]\n", pPars->fWriteImps? "yes": "no" );
+ Abc_Print( -2, "\t-t : toggle using one-hotness conditions [default = %s]\n", pPars->fUse1Hot? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -14468,27 +14214,24 @@ usage:
***********************************************************************/
int Abc_CommandSeqSweep2( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
Ssw_Pars_t Pars, * pPars = &Pars;
+ int nConstrs = 0;
int c;
extern Abc_Ntk_t * Abc_NtkDarSeqSweep2( Abc_Ntk_t * pNtk, Ssw_Pars_t * pPars );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Ssw_ManSetDefaultParams( pPars );
Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "PQFCLNSIVMplfudsvwh" ) ) != EOF )
+ while ( ( c = Extra_UtilGetopt( argc, argv, "PQFCLSIVMNcmplofdsvwh" ) ) != EOF )
{
switch ( c )
{
case 'P':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-P\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
goto usage;
}
pPars->nPartSize = atoi(argv[globalUtilOptind]);
@@ -14499,7 +14242,7 @@ int Abc_CommandSeqSweep2( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'Q':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-Q\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-Q\" should be followed by an integer.\n" );
goto usage;
}
pPars->nOverSize = atoi(argv[globalUtilOptind]);
@@ -14510,7 +14253,7 @@ int Abc_CommandSeqSweep2( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
pPars->nFramesK = atoi(argv[globalUtilOptind]);
@@ -14521,7 +14264,7 @@ int Abc_CommandSeqSweep2( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
pPars->nBTLimit = atoi(argv[globalUtilOptind]);
@@ -14532,7 +14275,7 @@ int Abc_CommandSeqSweep2( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'L':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-L\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
goto usage;
}
pPars->nMaxLevs = atoi(argv[globalUtilOptind]);
@@ -14540,21 +14283,10 @@ int Abc_CommandSeqSweep2( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pPars->nMaxLevs <= 0 )
goto usage;
break;
- case 'N':
- if ( globalUtilOptind >= argc )
- {
- fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" );
- goto usage;
- }
- pPars->nConstrs = atoi(argv[globalUtilOptind]);
- globalUtilOptind++;
- if ( pPars->nConstrs < 0 )
- goto usage;
- break;
case 'S':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-S\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
goto usage;
}
pPars->nFramesAddSim = atoi(argv[globalUtilOptind]);
@@ -14565,7 +14297,7 @@ int Abc_CommandSeqSweep2( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'I':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-I\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
goto usage;
}
pPars->nItersStop = atoi(argv[globalUtilOptind]);
@@ -14576,7 +14308,7 @@ int Abc_CommandSeqSweep2( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'V':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-V\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-V\" should be followed by an integer.\n" );
goto usage;
}
pPars->nSatVarMax2 = atoi(argv[globalUtilOptind]);
@@ -14587,7 +14319,7 @@ int Abc_CommandSeqSweep2( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'M':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-M\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
goto usage;
}
pPars->nRecycleCalls2 = atoi(argv[globalUtilOptind]);
@@ -14595,18 +14327,35 @@ int Abc_CommandSeqSweep2( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pPars->nRecycleCalls2 < 0 )
goto usage;
break;
+ case 'N':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ nConstrs = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( nConstrs < 0 )
+ goto usage;
+ break;
+ case 'c':
+ pPars->fConstrs ^= 1;
+ break;
+ case 'm':
+ pPars->fMergeFull ^= 1;
+ break;
case 'p':
pPars->fPolarFlip ^= 1;
break;
case 'l':
pPars->fLatchCorr ^= 1;
break;
+ case 'o':
+ pPars->fOutputCorr ^= 1;
+ break;
case 'f':
pPars->fSemiFormal ^= 1;
break;
- case 'u':
- pPars->fUniqueness ^= 1;
- break;
case 'd':
pPars->fDynamic ^= 1;
break;
@@ -14628,27 +14377,50 @@ int Abc_CommandSeqSweep2( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( Abc_NtkIsComb(pNtk) )
{
- fprintf( pErr, "The network is combinational (run \"fraig\" or \"fraig_sweep\").\n" );
+ Abc_Print( -1, "The network is combinational (run \"fraig\" or \"fraig_sweep\").\n" );
return 0;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- printf( "This command works only for structrally hashed networks. Run \"st\".\n" );
+ Abc_Print( -1, "This command works only for structrally hashed networks. Run \"st\".\n" );
return 0;
}
+ // if constraints are to be used, network should have no constraints
+ if ( nConstrs > 0 )
+ {
+ if ( Abc_NtkConstrNum(pNtk) > 0 )
+ {
+ Abc_Print( -1, "The network already has %d constraints.\n", Abc_NtkConstrNum(pNtk) );
+ return 0;
+ }
+ else
+ {
+ Abc_Print( 0, "Setting the number of constraints to be %d.\n", nConstrs );
+ pNtk->nConstrs = nConstrs;
+ }
+ }
+
+ if ( pPars->fConstrs )
+ {
+ if ( Abc_NtkConstrNum(pNtk) > 0 )
+ Abc_Print( 0, "Performing scorr with %d constraints.\n", Abc_NtkConstrNum(pNtk) );
+ else
+ Abc_Print( 0, "Performing constraint-based scorr without constraints.\n" );
+ }
+
// get the new network
pNtkRes = Abc_NtkDarSeqSweep2( pNtk, pPars );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Sequential sweeping has failed.\n" );
+ Abc_Print( -1, "Sequential sweeping has failed.\n" );
return 1;
}
// replace the current network
@@ -14656,27 +14428,30 @@ int Abc_CommandSeqSweep2( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: scorr [-PQFCLNSIVM <num>] [-pludsvwh]\n" );
- fprintf( pErr, "\t performs sequential sweep using K-step induction\n" );
- fprintf( pErr, "\t-P num : max partition size (0 = no partitioning) [default = %d]\n", pPars->nPartSize );
- fprintf( pErr, "\t-Q num : partition overlap (0 = no overlap) [default = %d]\n", pPars->nOverSize );
- fprintf( pErr, "\t-F num : number of time frames for induction (1=simple) [default = %d]\n", pPars->nFramesK );
- fprintf( pErr, "\t-C num : max number of conflicts at a node (0=inifinite) [default = %d]\n", pPars->nBTLimit );
- fprintf( pErr, "\t-L num : max number of levels to consider (0=all) [default = %d]\n", pPars->nMaxLevs );
- fprintf( pErr, "\t-N num : number of last POs treated as constraints (0=none) [default = %d]\n", pPars->nConstrs );
- fprintf( pErr, "\t-S num : additional simulation frames for c-examples (0=none) [default = %d]\n", pPars->nFramesAddSim );
- fprintf( pErr, "\t-I num : iteration number to stop and output SR-model (-1=none) [default = %d]\n", pPars->nItersStop );
- fprintf( pErr, "\t-V num : min var num needed to recycle the SAT solver [default = %d]\n", pPars->nSatVarMax2 );
- fprintf( pErr, "\t-M num : min call num needed to recycle the SAT solver [default = %d]\n", pPars->nRecycleCalls2 );
- fprintf( pErr, "\t-p : toggle alighning polarity of SAT variables [default = %s]\n", pPars->fPolarFlip? "yes": "no" );
- fprintf( pErr, "\t-l : toggle latch correspondence only [default = %s]\n", pPars->fLatchCorr? "yes": "no" );
-// fprintf( pErr, "\t-f : toggle filtering using iterative BMC [default = %s]\n", pPars->fSemiFormal? "yes": "no" );
- fprintf( pErr, "\t-u : toggle using uniqueness constraints [default = %s]\n", pPars->fUniqueness? "yes": "no" );
- fprintf( pErr, "\t-d : toggle dynamic addition of constraints [default = %s]\n", pPars->fDynamic? "yes": "no" );
- fprintf( pErr, "\t-s : toggle local simulation in the cone of influence [default = %s]\n", pPars->fLocalSim? "yes": "no" );
- fprintf( pErr, "\t-w : toggle printout of flop equivalences [default = %s]\n", pPars->fFlopVerbose? "yes": "no" );
- fprintf( pErr, "\t-v : toggle verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: scorr [-PQFCLSIVMN <num>] [-cmplodsvwh]\n" );
+ Abc_Print( -2, "\t performs sequential sweep using K-step induction\n" );
+ Abc_Print( -2, "\t-P num : max partition size (0 = no partitioning) [default = %d]\n", pPars->nPartSize );
+ Abc_Print( -2, "\t-Q num : partition overlap (0 = no overlap) [default = %d]\n", pPars->nOverSize );
+ Abc_Print( -2, "\t-F num : number of time frames for induction (1=simple) [default = %d]\n", pPars->nFramesK );
+ Abc_Print( -2, "\t-C num : max number of conflicts at a node (0=inifinite) [default = %d]\n", pPars->nBTLimit );
+ Abc_Print( -2, "\t-L num : max number of levels to consider (0=all) [default = %d]\n", pPars->nMaxLevs );
+ Abc_Print( -2, "\t-N num : number of last POs treated as constraints (0=none) [default = %d]\n", pPars->fConstrs );
+ Abc_Print( -2, "\t-S num : additional simulation frames for c-examples (0=none) [default = %d]\n", pPars->nFramesAddSim );
+ Abc_Print( -2, "\t-I num : iteration number to stop and output SR-model (-1=none) [default = %d]\n", pPars->nItersStop );
+ Abc_Print( -2, "\t-V num : min var num needed to recycle the SAT solver [default = %d]\n", pPars->nSatVarMax2 );
+ Abc_Print( -2, "\t-M num : min call num needed to recycle the SAT solver [default = %d]\n", pPars->nRecycleCalls2 );
+ Abc_Print( -2, "\t-N num : set last <num> POs to be constraints (use with -c) [default = %d]\n", nConstrs );
+ Abc_Print( -2, "\t-c : toggle using explicit constraints [default = %s]\n", pPars->fConstrs? "yes": "no" );
+ Abc_Print( -2, "\t-m : toggle full merge if constraints are present [default = %s]\n", pPars->fMergeFull? "yes": "no" );
+ Abc_Print( -2, "\t-p : toggle alighning polarity of SAT variables [default = %s]\n", pPars->fPolarFlip? "yes": "no" );
+ Abc_Print( -2, "\t-l : toggle doing latch correspondence [default = %s]\n", pPars->fLatchCorr? "yes": "no" );
+ Abc_Print( -2, "\t-o : toggle doing \'PO correspondence\' [default = %s]\n", pPars->fOutputCorr? "yes": "no" );
+// Abc_Print( -2, "\t-f : toggle filtering using iterative BMC [default = %s]\n", pPars->fSemiFormal? "yes": "no" );
+ Abc_Print( -2, "\t-d : toggle dynamic addition of constraints [default = %s]\n", pPars->fDynamic? "yes": "no" );
+ Abc_Print( -2, "\t-s : toggle local simulation in the cone of influence [default = %s]\n", pPars->fLocalSim? "yes": "no" );
+ Abc_Print( -2, "\t-w : toggle printout of flop equivalences [default = %s]\n", pPars->fFlopVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -14691,7 +14466,7 @@ usage:
SeeAlso []
***********************************************************************/
-int Abc_CommandSeqSweepTest( Abc_Frame_t * pAbc, int argc, char ** argv )
+int Abc_CommandTestSeqSweep( Abc_Frame_t * pAbc, int argc, char ** argv )
{
char * pFileName;
Fra_Ssw_t Pars, * pPars = &Pars;
@@ -14722,7 +14497,7 @@ int Abc_CommandSeqSweepTest( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'P':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-P\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
goto usage;
}
pPars->nPartSize = atoi(argv[globalUtilOptind]);
@@ -14733,7 +14508,7 @@ int Abc_CommandSeqSweepTest( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'Q':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-Q\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-Q\" should be followed by an integer.\n" );
goto usage;
}
pPars->nOverSize = atoi(argv[globalUtilOptind]);
@@ -14744,7 +14519,7 @@ int Abc_CommandSeqSweepTest( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'N':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-N\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
goto usage;
}
pPars->nFramesP = atoi(argv[globalUtilOptind]);
@@ -14755,7 +14530,7 @@ int Abc_CommandSeqSweepTest( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-F\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
pPars->nFramesK = atoi(argv[globalUtilOptind]);
@@ -14766,7 +14541,7 @@ int Abc_CommandSeqSweepTest( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'I':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-I\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
goto usage;
}
pPars->nMaxImps = atoi(argv[globalUtilOptind]);
@@ -14777,7 +14552,7 @@ int Abc_CommandSeqSweepTest( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'L':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-L\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
goto usage;
}
pPars->nMaxLevs = atoi(argv[globalUtilOptind]);
@@ -14817,30 +14592,140 @@ int Abc_CommandSeqSweepTest( Abc_Frame_t * pAbc, int argc, char ** argv )
pFileName = argv[globalUtilOptind];
else
{
- printf( "File name should be given on the command line.\n" );
+ Abc_Print( -1, "File name should be given on the command line.\n" );
return 1;
}
Fra_FraigInductionTest( pFileName, pPars );
return 0;
usage:
- fprintf( stdout, "usage: testssw [-PQNFL num] [-lrfetvh] <file>\n" );
- fprintf( stdout, "\t performs sequential sweep using K-step induction\n" );
- fprintf( stdout, "\t (outputs a file with a set of pairs of equivalent nodes)\n" );
- fprintf( stdout, "\t-P num : max partition size (0 = no partitioning) [default = %d]\n", pPars->nPartSize );
- fprintf( stdout, "\t-Q num : partition overlap (0 = no overlap) [default = %d]\n", pPars->nOverSize );
- fprintf( stdout, "\t-N num : number of time frames to use as the prefix [default = %d]\n", pPars->nFramesP );
- fprintf( stdout, "\t-F num : number of time frames for induction (1=simple) [default = %d]\n", pPars->nFramesK );
- fprintf( stdout, "\t-L num : max number of levels to consider (0=all) [default = %d]\n", pPars->nMaxLevs );
-// fprintf( stdout, "\t-I num : max number of implications to consider [default = %d]\n", pPars->nMaxImps );
-// fprintf( stdout, "\t-i : toggle using implications [default = %s]\n", pPars->fUseImps? "yes": "no" );
- fprintf( stdout, "\t-l : toggle latch correspondence only [default = %s]\n", pPars->fLatchCorr? "yes": "no" );
- fprintf( stdout, "\t-r : toggle AIG rewriting [default = %s]\n", pPars->fRewrite? "yes": "no" );
- fprintf( stdout, "\t-f : toggle fraiging (combinational SAT sweeping) [default = %s]\n", pPars->fFraiging? "yes": "no" );
- fprintf( stdout, "\t-e : toggle writing implications as assertions [default = %s]\n", pPars->fWriteImps? "yes": "no" );
- fprintf( stdout, "\t-t : toggle using one-hotness conditions [default = %s]\n", pPars->fUse1Hot? "yes": "no" );
- fprintf( stdout, "\t-v : toggle verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: testssw [-PQNFL num] [-lrfetvh] <file>\n" );
+ Abc_Print( -2, "\t performs sequential sweep using K-step induction\n" );
+ Abc_Print( -2, "\t (outputs a file with a set of pairs of equivalent nodes)\n" );
+ Abc_Print( -2, "\t-P num : max partition size (0 = no partitioning) [default = %d]\n", pPars->nPartSize );
+ Abc_Print( -2, "\t-Q num : partition overlap (0 = no overlap) [default = %d]\n", pPars->nOverSize );
+ Abc_Print( -2, "\t-N num : number of time frames to use as the prefix [default = %d]\n", pPars->nFramesP );
+ Abc_Print( -2, "\t-F num : number of time frames for induction (1=simple) [default = %d]\n", pPars->nFramesK );
+ Abc_Print( -2, "\t-L num : max number of levels to consider (0=all) [default = %d]\n", pPars->nMaxLevs );
+// Abc_Print( -2, "\t-I num : max number of implications to consider [default = %d]\n", pPars->nMaxImps );
+// Abc_Print( -2, "\t-i : toggle using implications [default = %s]\n", pPars->fUseImps? "yes": "no" );
+ Abc_Print( -2, "\t-l : toggle latch correspondence only [default = %s]\n", pPars->fLatchCorr? "yes": "no" );
+ Abc_Print( -2, "\t-r : toggle AIG rewriting [default = %s]\n", pPars->fRewrite? "yes": "no" );
+ Abc_Print( -2, "\t-f : toggle fraiging (combinational SAT sweeping) [default = %s]\n", pPars->fFraiging? "yes": "no" );
+ Abc_Print( -2, "\t-e : toggle writing implications as assertions [default = %s]\n", pPars->fWriteImps? "yes": "no" );
+ Abc_Print( -2, "\t-t : toggle using one-hotness conditions [default = %s]\n", pPars->fUse1Hot? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_CommandTestScorr( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ extern Abc_Ntk_t * Abc_NtkTestScorr( char * pFileNameIn, char * pFileNameOut, int nStepsMax, int nBTLimit, int fNewAlgo, int fFlopOnly, int fFfNdOnly, int fVerbose );
+
+ Abc_Ntk_t * pNtkRes;
+ int c;
+ int nConfMax;
+ int nStepsMax;
+ int fNewAlgo;
+ int fFlopOnly;
+ int fFfNdOnly;
+ int fVerbose;
+ // set defaults
+ nConfMax = 100;
+ nStepsMax = -1;
+ fNewAlgo = 0;
+ fFlopOnly = 0;
+ fFfNdOnly = 0;
+ fVerbose = 0;
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "CSnfsvh" ) ) != EOF )
+ {
+ switch ( c )
+ {
+ case 'C':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ nConfMax = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( nConfMax < 0 )
+ goto usage;
+ break;
+ case 'S':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ nStepsMax = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( nStepsMax < 0 )
+ goto usage;
+ break;
+ case 'n':
+ fNewAlgo ^= 1;
+ break;
+ case 'f':
+ fFlopOnly ^= 1;
+ break;
+ case 's':
+ fFfNdOnly ^= 1;
+ break;
+ case 'v':
+ fVerbose ^= 1;
+ break;
+ default:
+ goto usage;
+ }
+ }
+ if ( argc != globalUtilOptind + 2 )
+ {
+ Abc_Print( -1, "Expecting two files names on the command line.\n" );
+ goto usage;
+ }
+ if ( fFlopOnly && fFfNdOnly )
+ {
+ Abc_Print( -1, "These two options (-f and -s) are incompatible.\n" );
+ goto usage;
+ }
+ // get the new network
+ pNtkRes = Abc_NtkTestScorr( argv[globalUtilOptind], argv[globalUtilOptind+1], nStepsMax, nConfMax, fNewAlgo, fFlopOnly, fFfNdOnly, fVerbose );
+ if ( pNtkRes == NULL )
+ {
+ Abc_Print( -1, "Sequential sweeping has failed.\n" );
+ return 1;
+ }
+ // replace the current network
+ Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+ return 0;
+
+usage:
+ Abc_Print( -2, "usage: testscorr [-CS num] [-nfsvh] <file_in> <file_out>\n" );
+ Abc_Print( -2, "\t outputs the list of sequential equivalences into a file\n" );
+ Abc_Print( -2, "\t (if <file_in> is in BENCH, init state file should be the same directory)\n" );
+ Abc_Print( -2, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfMax );
+ Abc_Print( -2, "\t-S num : limit on refinement iterations (-1=no limit, 0=after BMC, etc) [default = %d]\n", nStepsMax );
+ Abc_Print( -2, "\t-n : toggle between \"scorr\" and \"&scorr\" [default = %s]\n", fNewAlgo? "&scorr": "scorr" );
+ Abc_Print( -2, "\t-f : toggle reporting only flop/flop equivs [default = %s]\n", fFlopOnly? "yes": "no" );
+ Abc_Print( -2, "\t-s : toggle reporting only flop/flop and flop/node equivs [default = %s]\n", fFfNdOnly? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ Abc_Print( -2, "\t<file_in> : input file with design for sequential equivalence computation\n");
+ Abc_Print( -2, "\t<file_out> : output file with the list of pairs of equivalent signals\n");
return 1;
}
@@ -14857,7 +14742,6 @@ usage:
***********************************************************************/
int Abc_CommandLcorr( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c;
int nFramesP;
@@ -14869,8 +14753,8 @@ int Abc_CommandLcorr( Abc_Frame_t * pAbc, int argc, char ** argv )
extern Abc_Ntk_t * Abc_NtkDarLcorrNew( Abc_Ntk_t * pNtk, int nVarsMax, int nConfMax, int fVerbose );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
+
+
// set defaults
nFramesP = 0;
@@ -14886,7 +14770,7 @@ int Abc_CommandLcorr( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'P':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-P\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
goto usage;
}
nFramesP = atoi(argv[globalUtilOptind]);
@@ -14897,7 +14781,7 @@ int Abc_CommandLcorr( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
nConfMax = atoi(argv[globalUtilOptind]);
@@ -14908,7 +14792,7 @@ int Abc_CommandLcorr( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'S':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-S\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
goto usage;
}
nVarsMax = atoi(argv[globalUtilOptind]);
@@ -14931,19 +14815,19 @@ int Abc_CommandLcorr( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( Abc_NtkIsComb(pNtk) )
{
- fprintf( pErr, "The network is combinational (run \"fraig\" or \"fraig_sweep\").\n" );
+ Abc_Print( -1, "The network is combinational (run \"fraig\" or \"fraig_sweep\").\n" );
return 0;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- printf( "This command works only for structrally hashed networks. Run \"st\".\n" );
+ Abc_Print( -1, "This command works only for structrally hashed networks. Run \"st\".\n" );
return 0;
}
@@ -14954,7 +14838,7 @@ int Abc_CommandLcorr( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtkRes = Abc_NtkDarLcorr( pNtk, nFramesP, nConfMax, fVerbose );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Sequential sweeping has failed.\n" );
+ Abc_Print( -1, "Sequential sweeping has failed.\n" );
return 1;
}
// replace the current network
@@ -14962,14 +14846,14 @@ int Abc_CommandLcorr( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: lcorr [-PCS num] [-nvh]\n" );
- fprintf( pErr, "\t computes latch correspondence using 1-step induction\n" );
- fprintf( pErr, "\t-P num : number of time frames to use as the prefix [default = %d]\n", nFramesP );
- fprintf( pErr, "\t-C num : max conflict number when proving latch equivalence [default = %d]\n", nConfMax );
- fprintf( pErr, "\t-S num : the max number of SAT variables [default = %d]\n", nVarsMax );
- fprintf( pErr, "\t-n : toggle using new algorithm [default = %s]\n", fNewAlgor? "yes": "no" );
- fprintf( pErr, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: lcorr [-PCS num] [-nvh]\n" );
+ Abc_Print( -2, "\t computes latch correspondence using 1-step induction\n" );
+ Abc_Print( -2, "\t-P num : number of time frames to use as the prefix [default = %d]\n", nFramesP );
+ Abc_Print( -2, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfMax );
+ Abc_Print( -2, "\t-S num : the max number of SAT variables [default = %d]\n", nVarsMax );
+ Abc_Print( -2, "\t-n : toggle using new algorithm [default = %s]\n", fNewAlgor? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -14986,24 +14870,23 @@ usage:
***********************************************************************/
int Abc_CommandSeqCleanup( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c;
int fLatchConst;
int fLatchEqual;
+ int fSaveNames;
int fVerbose;
- extern Abc_Ntk_t * Abc_NtkDarLatchSweep( Abc_Ntk_t * pNtk, int fLatchConst, int fLatchEqual, int fVerbose );
+ extern Abc_Ntk_t * Abc_NtkDarLatchSweep( Abc_Ntk_t * pNtk, int fLatchConst, int fLatchEqual, int fSaveNames, int fVerbose );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
// set defaults
fLatchConst = 1;
fLatchEqual = 1;
+ fSaveNames = 0;
fVerbose = 0;
Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "cevh" ) ) != EOF )
+ while ( ( c = Extra_UtilGetopt( argc, argv, "cenvh" ) ) != EOF )
{
switch ( c )
{
@@ -15013,6 +14896,9 @@ int Abc_CommandSeqCleanup( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'e':
fLatchEqual ^= 1;
break;
+ case 'n':
+ fSaveNames ^= 1;
+ break;
case 'v':
fVerbose ^= 1;
break;
@@ -15024,24 +14910,24 @@ int Abc_CommandSeqCleanup( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "Only works for structrally hashed networks.\n" );
+ Abc_Print( -1, "Only works for structrally hashed networks.\n" );
return 1;
}
if ( !Abc_NtkLatchNum(pNtk) )
{
- fprintf( pErr, "The network is combinational.\n" );
+ Abc_Print( -1, "The network is combinational.\n" );
return 0;
}
// modify the current network
- pNtkRes = Abc_NtkDarLatchSweep( pNtk, fLatchConst, fLatchEqual, fVerbose );
+ pNtkRes = Abc_NtkDarLatchSweep( pNtk, fLatchConst, fLatchEqual, fSaveNames, fVerbose );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Sequential cleanup has failed.\n" );
+ Abc_Print( -1, "Sequential cleanup has failed.\n" );
return 1;
}
// replace the current network
@@ -15049,13 +14935,14 @@ int Abc_CommandSeqCleanup( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: scleanup [-cevh]\n" );
- fprintf( pErr, "\t performs sequential cleanup of the current network\n" );
- fprintf( pErr, "\t by removing nodes and latches that do not feed into POs\n" );
- fprintf( pErr, "\t-c : sweep stuck-at latches detected by ternary simulation [default = %s]\n", fLatchConst? "yes": "no" );
- fprintf( pErr, "\t-e : merge equal latches (same data inputs and init states) [default = %s]\n", fLatchEqual? "yes": "no" );
- fprintf( pErr, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: scleanup [-cenvh]\n" );
+ Abc_Print( -2, "\t performs sequential cleanup of the current network\n" );
+ Abc_Print( -2, "\t by removing nodes and latches that do not feed into POs\n" );
+ Abc_Print( -2, "\t-c : sweep stuck-at latches detected by ternary simulation [default = %s]\n", fLatchConst? "yes": "no" );
+ Abc_Print( -2, "\t-e : merge equal latches (same data inputs and init states) [default = %s]\n", fLatchEqual? "yes": "no" );
+ Abc_Print( -2, "\t-n : toggle preserving latch names [default = %s]\n", fSaveNames? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -15072,19 +14959,13 @@ usage:
***********************************************************************/
int Abc_CommandCycle( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
int nFrames;
int fUseXval;
int fVerbose;
extern void Abc_NtkCycleInitState( Abc_Ntk_t * pNtk, int nFrames, int fUseXval, int fVerbose );
extern void Abc_NtkCycleInitStateSop( Abc_Ntk_t * pNtk, int nFrames, int fVerbose );
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
nFrames = 100;
fUseXval = 0;
@@ -15097,7 +14978,7 @@ int Abc_CommandCycle( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
nFrames = atoi(argv[globalUtilOptind]);
@@ -15119,23 +15000,23 @@ int Abc_CommandCycle( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) && !Abc_NtkIsSopLogic(pNtk) )
{
- fprintf( pErr, "Only works for strashed networks or logic SOP networks.\n" );
+ Abc_Print( -1, "Only works for strashed networks or logic SOP networks.\n" );
return 1;
}
if ( !Abc_NtkLatchNum(pNtk) )
{
- fprintf( pErr, "The network is combinational.\n" );
+ Abc_Print( -1, "The network is combinational.\n" );
return 0;
}
if ( fUseXval && !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "X-valued simulation only works for AIGs. Run \"strash\".\n" );
+ Abc_Print( -1, "X-valued simulation only works for AIGs. Run \"strash\".\n" );
return 0;
}
if ( fUseXval )
@@ -15147,13 +15028,13 @@ int Abc_CommandCycle( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: cycle [-F num] [-xvh]\n" );
- fprintf( pErr, "\t cycles sequential circuit for the given number of timeframes\n" );
- fprintf( pErr, "\t to derive a new initial state (which may be on the envelope)\n" );
- fprintf( pErr, "\t-F num : the number of frames to simulate [default = %d]\n", nFrames );
- fprintf( pErr, "\t-x : use x-valued primary inputs [default = %s]\n", fUseXval? "yes": "no" );
- fprintf( pErr, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: cycle [-F num] [-xvh]\n" );
+ Abc_Print( -2, "\t cycles sequential circuit for the given number of timeframes\n" );
+ Abc_Print( -2, "\t to derive a new initial state (which may be on the envelope)\n" );
+ Abc_Print( -2, "\t-F num : the number of frames to simulate [default = %d]\n", nFrames );
+ Abc_Print( -2, "\t-x : use x-valued primary inputs [default = %s]\n", fUseXval? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -15170,19 +15051,13 @@ usage:
***********************************************************************/
int Abc_CommandXsim( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
int nFrames;
int fXInputs;
int fXState;
int fVerbose;
extern void Abc_NtkXValueSimulate( Abc_Ntk_t * pNtk, int nFrames, int fXInputs, int fXState, int fVerbose );
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
nFrames = 10;
fXInputs = 0;
@@ -15196,7 +15071,7 @@ int Abc_CommandXsim( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
nFrames = atoi(argv[globalUtilOptind]);
@@ -15221,31 +15096,31 @@ int Abc_CommandXsim( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "Only works for strashed networks.\n" );
+ Abc_Print( -1, "Only works for strashed networks.\n" );
return 1;
}
if ( !Abc_NtkLatchNum(pNtk) )
{
- fprintf( pErr, "The network is combinational.\n" );
+ Abc_Print( -1, "The network is combinational.\n" );
return 0;
}
Abc_NtkXValueSimulate( pNtk, nFrames, fXInputs, fXState, fVerbose );
return 0;
usage:
- fprintf( pErr, "usage: xsim [-F num] [-isvh]\n" );
- fprintf( pErr, "\t performs X-valued simulation of the AIG\n" );
- fprintf( pErr, "\t-F num : the number of frames to simulate [default = %d]\n", nFrames );
- fprintf( pErr, "\t-i : toggle X-valued representation of inputs [default = %s]\n", fXInputs? "yes": "no" );
- fprintf( pErr, "\t-s : toggle X-valued representation of state [default = %s]\n", fXState? "yes": "no" );
- fprintf( pErr, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: xsim [-F num] [-isvh]\n" );
+ Abc_Print( -2, "\t performs X-valued simulation of the AIG\n" );
+ Abc_Print( -2, "\t-F num : the number of frames to simulate [default = %d]\n", nFrames );
+ Abc_Print( -2, "\t-i : toggle X-valued representation of inputs [default = %s]\n", fXInputs? "yes": "no" );
+ Abc_Print( -2, "\t-s : toggle X-valued representation of state [default = %s]\n", fXState? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -15263,8 +15138,7 @@ usage:
***********************************************************************/
int Abc_CommandSim( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
int fNew;
int fComb;
@@ -15274,11 +15148,6 @@ int Abc_CommandSim( Abc_Frame_t * pAbc, int argc, char ** argv )
int fMiter;
int fVerbose;
extern int Abc_NtkDarSeqSim( Abc_Ntk_t * pNtk, int nFrames, int nWords, int TimeOut, int fNew, int fComb, int fMiter, int fVerbose );
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fNew = 0;
fComb = 0;
@@ -15295,7 +15164,7 @@ int Abc_CommandSim( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
nFrames = atoi(argv[globalUtilOptind]);
@@ -15306,7 +15175,7 @@ int Abc_CommandSim( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'W':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-W\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
goto usage;
}
nWords = atoi(argv[globalUtilOptind]);
@@ -15317,7 +15186,7 @@ int Abc_CommandSim( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'T':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-T\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
goto usage;
}
TimeOut = atoi(argv[globalUtilOptind]);
@@ -15345,29 +15214,30 @@ int Abc_CommandSim( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "Only works for strashed networks.\n" );
+ Abc_Print( -1, "Only works for strashed networks.\n" );
return 1;
}
ABC_FREE( pNtk->pSeqModel );
- Abc_NtkDarSeqSim( pNtk, nFrames, nWords, TimeOut, fNew, fComb, fMiter, fVerbose );
+ pAbc->Status = Abc_NtkDarSeqSim( pNtk, nFrames, nWords, TimeOut, fNew, fComb, fMiter, fVerbose );
+ Abc_FrameReplaceCex( pAbc, &pNtk->pSeqModel );
return 0;
usage:
- fprintf( pErr, "usage: sim [-FWT num] [-ncmvh]\n" );
- fprintf( pErr, "\t performs random simulation of the sequential miter\n" );
- fprintf( pErr, "\t-F num : the number of frames to simulate [default = %d]\n", nFrames );
- fprintf( pErr, "\t-W num : the number of words to simulate [default = %d]\n", nWords );
- fprintf( pErr, "\t-T num : approximate runtime limit in seconds [default = %d]\n", TimeOut );
- fprintf( pErr, "\t-n : toggle new vs. old implementation [default = %s]\n", fNew? "new": "old" );
- fprintf( pErr, "\t-c : toggle comb vs. seq simulaton [default = %s]\n", fComb? "comb": "seq" );
- fprintf( pErr, "\t-m : toggle miter vs. any circuit [default = %s]\n", fMiter? "miter": "circuit" );
- fprintf( pErr, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: sim [-FWT num] [-ncmvh]\n" );
+ Abc_Print( -2, "\t performs random simulation of the sequential miter\n" );
+ Abc_Print( -2, "\t-F num : the number of frames to simulate [default = %d]\n", nFrames );
+ Abc_Print( -2, "\t-W num : the number of words to simulate [default = %d]\n", nWords );
+ Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n", TimeOut );
+ Abc_Print( -2, "\t-n : toggle new vs. old implementation [default = %s]\n", fNew? "new": "old" );
+ Abc_Print( -2, "\t-c : toggle comb vs. seq simulaton [default = %s]\n", fComb? "comb": "seq" );
+ Abc_Print( -2, "\t-m : toggle miter vs. any circuit [default = %s]\n", fMiter? "miter": "circuit" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -15384,7 +15254,6 @@ usage:
***********************************************************************/
int Abc_CommandDarPhase( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c;
int nFrames, nPref;
@@ -15394,9 +15263,6 @@ int Abc_CommandDarPhase( Abc_Frame_t * pAbc, int argc, char ** argv )
extern Abc_Ntk_t * Abc_NtkPhaseAbstract( Abc_Ntk_t * pNtk, int nFrames, int nPref, int fIgnore, int fPrint, int fVerbose );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
nFrames = 0;
nPref = 0;
@@ -15411,7 +15277,7 @@ int Abc_CommandDarPhase( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
nFrames = atoi(argv[globalUtilOptind]);
@@ -15422,7 +15288,7 @@ int Abc_CommandDarPhase( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'P':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-P\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
goto usage;
}
nPref = atoi(argv[globalUtilOptind]);
@@ -15447,17 +15313,17 @@ int Abc_CommandDarPhase( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "Only works for structrally hashed networks.\n" );
+ Abc_Print( -1, "Only works for structrally hashed networks.\n" );
return 1;
}
if ( !Abc_NtkLatchNum(pNtk) )
{
- fprintf( pErr, "The network is combinational.\n" );
+ Abc_Print( -1, "The network is combinational.\n" );
return 0;
}
if ( fPrint )
@@ -15469,7 +15335,7 @@ int Abc_CommandDarPhase( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtkRes = Abc_NtkPhaseAbstract( pNtk, nFrames, nPref, fIgnore, 0, fVerbose );
if ( pNtkRes == NULL )
{
-// fprintf( pErr, "Phase abstraction has failed.\n" );
+// Abc_Print( -1, "Phase abstraction has failed.\n" );
return 0;
}
// replace the current network
@@ -15477,15 +15343,15 @@ int Abc_CommandDarPhase( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: phase [-FP <num>] [-ipvh]\n" );
- fprintf( pErr, "\t performs sequential cleanup of the current network\n" );
- fprintf( pErr, "\t by removing nodes and latches that do not feed into POs\n" );
- fprintf( pErr, "\t-F num : the number of frames to abstract [default = %d]\n", nFrames );
- fprintf( pErr, "\t-P num : the number of prefix frames to skip [default = %d]\n", nPref );
- fprintf( pErr, "\t-i : toggle ignoring the initial state [default = %s]\n", fIgnore? "yes": "no" );
- fprintf( pErr, "\t-p : toggle printing statistics about generators [default = %s]\n", fPrint? "yes": "no" );
- fprintf( pErr, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: phase [-FP <num>] [-ipvh]\n" );
+ Abc_Print( -2, "\t performs sequential cleanup of the current network\n" );
+ Abc_Print( -2, "\t by removing nodes and latches that do not feed into POs\n" );
+ Abc_Print( -2, "\t-F num : the number of frames to abstract [default = %d]\n", nFrames );
+ Abc_Print( -2, "\t-P num : the number of prefix frames to skip [default = %d]\n", nPref );
+ Abc_Print( -2, "\t-i : toggle ignoring the initial state [default = %s]\n", fIgnore? "yes": "no" );
+ Abc_Print( -2, "\t-p : toggle printing statistics about generators [default = %s]\n", fPrint? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -15502,7 +15368,6 @@ usage:
***********************************************************************/
int Abc_CommandSynch( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtkRes, * pNtk1, * pNtk2, * pNtk;
char ** pArgvNew;
int nArgcNew;
@@ -15515,9 +15380,6 @@ int Abc_CommandSynch( Abc_Frame_t * pAbc, int argc, char ** argv )
extern Abc_Ntk_t * Abc_NtkDarSynchOne( Abc_Ntk_t * pNtk, int nWords, int fVerbose );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
nWords = 32;
fVerbose = 1;
@@ -15529,7 +15391,7 @@ int Abc_CommandSynch( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'W':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-W\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
goto usage;
}
nWords = atoi(argv[globalUtilOptind]);
@@ -15553,20 +15415,20 @@ int Abc_CommandSynch( Abc_Frame_t * pAbc, int argc, char ** argv )
{
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
pNtkRes = Abc_NtkDarSynchOne( pNtk, nWords, fVerbose );
}
else
{
- if ( !Abc_NtkPrepareTwoNtks( pErr, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
+ if ( !Abc_NtkPrepareTwoNtks( stdout, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
return 1;
if ( Abc_NtkLatchNum(pNtk1) == 0 || Abc_NtkLatchNum(pNtk2) == 0 )
{
if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
- printf( "The network has no latches..\n" );
+ Abc_Print( -1, "The network has no latches..\n" );
return 0;
}
@@ -15577,7 +15439,7 @@ int Abc_CommandSynch( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Synchronization has failed.\n" );
+ Abc_Print( -1, "Synchronization has failed.\n" );
return 0;
}
// replace the current network
@@ -15585,23 +15447,23 @@ int Abc_CommandSynch( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: synch [-W <num>] [-vh] <file1> <file2>\n" );
- fprintf( pErr, "\t derives and applies synchronization sequence\n" );
- fprintf( pErr, "\t-W num : the number of simulation words [default = %d]\n", nWords );
- fprintf( pErr, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
- fprintf( pErr, "\tfile1 : (optional) the file with the first design\n");
- fprintf( pErr, "\tfile2 : (optional) the file with the second design\n\n");
- fprintf( pErr, "\t If no designs are given on the command line,\n" );
- fprintf( pErr, "\t assumes the current network has no initial state,\n" );
- fprintf( pErr, "\t derives synchronization sequence and applies it.\n\n" );
- fprintf( pErr, "\t If two designs are given on the command line\n" );
- fprintf( pErr, "\t assumes both of them have no initial state,\n" );
- fprintf( pErr, "\t derives sequences for both designs, synchorinizes\n" );
- fprintf( pErr, "\t them, and creates SEC miter comparing two designs.\n\n" );
- fprintf( pErr, "\t If only one design is given on the command line,\n" );
- fprintf( pErr, "\t considers the second design to be the current network,\n" );
- fprintf( pErr, "\t and derives SEC miter for them, as described above.\n" );
+ Abc_Print( -2, "usage: synch [-W <num>] [-vh] <file1> <file2>\n" );
+ Abc_Print( -2, "\t derives and applies synchronization sequence\n" );
+ Abc_Print( -2, "\t-W num : the number of simulation words [default = %d]\n", nWords );
+ Abc_Print( -2, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ Abc_Print( -2, "\tfile1 : (optional) the file with the first design\n");
+ Abc_Print( -2, "\tfile2 : (optional) the file with the second design\n\n");
+ Abc_Print( -2, "\t If no designs are given on the command line,\n" );
+ Abc_Print( -2, "\t assumes the current network has no initial state,\n" );
+ Abc_Print( -2, "\t derives synchronization sequence and applies it.\n\n" );
+ Abc_Print( -2, "\t If two designs are given on the command line\n" );
+ Abc_Print( -2, "\t assumes both of them have no initial state,\n" );
+ Abc_Print( -2, "\t derives sequences for both designs, synchorinizes\n" );
+ Abc_Print( -2, "\t them, and creates SEC miter comparing two designs.\n\n" );
+ Abc_Print( -2, "\t If only one design is given on the command line,\n" );
+ Abc_Print( -2, "\t considers the second design to be the current network,\n" );
+ Abc_Print( -2, "\t and derives SEC miter for them, as described above.\n" );
return 1;
}
@@ -15618,7 +15480,6 @@ usage:
***********************************************************************/
int Abc_CommandClockGate( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Cgt_Par_t Pars, * pPars = &Pars;
Abc_Ntk_t * pNtkRes, * pNtk, * pNtkCare;
int c;
@@ -15626,9 +15487,6 @@ int Abc_CommandClockGate( Abc_Frame_t * pAbc, int argc, char ** argv )
extern Abc_Ntk_t * Abc_NtkDarClockGate( Abc_Ntk_t * pNtk, Abc_Ntk_t * pCare, Cgt_Par_t * pPars );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Cgt_SetDefaultParams( pPars );
Extra_UtilGetoptReset();
@@ -15639,7 +15497,7 @@ int Abc_CommandClockGate( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'L':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-L\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
goto usage;
}
pPars->nLevelMax = atoi(argv[globalUtilOptind]);
@@ -15650,7 +15508,7 @@ int Abc_CommandClockGate( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'N':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
goto usage;
}
pPars->nCandMax = atoi(argv[globalUtilOptind]);
@@ -15661,7 +15519,7 @@ int Abc_CommandClockGate( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'D':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-D\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
goto usage;
}
pPars->nOdcMax = atoi(argv[globalUtilOptind]);
@@ -15672,7 +15530,7 @@ int Abc_CommandClockGate( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
pPars->nConfMax = atoi(argv[globalUtilOptind]);
@@ -15683,7 +15541,7 @@ int Abc_CommandClockGate( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'V':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-V\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-V\" should be followed by an integer.\n" );
goto usage;
}
pPars->nVarsMin = atoi(argv[globalUtilOptind]);
@@ -15694,7 +15552,7 @@ int Abc_CommandClockGate( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'K':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-K\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
goto usage;
}
pPars->nFlopsMin = atoi(argv[globalUtilOptind]);
@@ -15719,7 +15577,7 @@ int Abc_CommandClockGate( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
@@ -15728,7 +15586,7 @@ int Abc_CommandClockGate( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtkCare = Io_Read( argv[globalUtilOptind], Io_ReadFileType(argv[globalUtilOptind]), 1 );
if ( pNtkCare == NULL )
{
- printf( "Reading care network has failed.\n" );
+ Abc_Print( -1, "Reading care network has failed.\n" );
return 1;
}
// modify the current network
@@ -15741,12 +15599,12 @@ int Abc_CommandClockGate( Abc_Frame_t * pAbc, int argc, char ** argv )
}
else
{
- fprintf( pErr, "Wrong number of arguments.\n" );
+ Abc_Print( -1, "Wrong number of arguments.\n" );
return 0;
}
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Clock gating has failed.\n" );
+ Abc_Print( -1, "Clock gating has failed.\n" );
return 0;
}
// replace the current network
@@ -15754,19 +15612,19 @@ int Abc_CommandClockGate( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: clockgate [-LNDCVK <num>] [-avwh] <file>\n" );
- fprintf( pErr, "\t sequential clock gating with observability don't-cares\n" );
- fprintf( pErr, "\t-L num : max level number of a clock gate [default = %d]\n", pPars->nLevelMax );
- fprintf( pErr, "\t-N num : max number of candidates for a flop [default = %d]\n", pPars->nCandMax );
- fprintf( pErr, "\t-D num : max number of ODC levels to consider [default = %d]\n", pPars->nOdcMax );
- fprintf( pErr, "\t-C num : max number of conflicts at a node [default = %d]\n", pPars->nConfMax );
- fprintf( pErr, "\t-V num : min number of vars to recycle SAT solver [default = %d]\n", pPars->nVarsMin );
- fprintf( pErr, "\t-K num : min number of flops to recycle SAT solver [default = %d]\n", pPars->nFlopsMin );
- fprintf( pErr, "\t-a : toggle minimizing area-only [default = %s]\n", pPars->fAreaOnly? "yes": "no" );
- fprintf( pErr, "\t-v : toggle verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
- fprintf( pErr, "\t-w : toggle even more detailed output [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
- fprintf( pErr, "\tfile : (optional) constraints for primary inputs and register outputs\n");
+ Abc_Print( -2, "usage: clockgate [-LNDCVK <num>] [-avwh] <file>\n" );
+ Abc_Print( -2, "\t sequential clock gating with observability don't-cares\n" );
+ Abc_Print( -2, "\t-L num : max level number of a clock gate [default = %d]\n", pPars->nLevelMax );
+ Abc_Print( -2, "\t-N num : max number of candidates for a flop [default = %d]\n", pPars->nCandMax );
+ Abc_Print( -2, "\t-D num : max number of ODC levels to consider [default = %d]\n", pPars->nOdcMax );
+ Abc_Print( -2, "\t-C num : max number of conflicts at a node [default = %d]\n", pPars->nConfMax );
+ Abc_Print( -2, "\t-V num : min number of vars to recycle SAT solver [default = %d]\n", pPars->nVarsMin );
+ Abc_Print( -2, "\t-K num : min number of flops to recycle SAT solver [default = %d]\n", pPars->nFlopsMin );
+ Abc_Print( -2, "\t-a : toggle minimizing area-only [default = %s]\n", pPars->fAreaOnly? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-w : toggle even more detailed output [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ Abc_Print( -2, "\tfile : (optional) constraints for primary inputs and register outputs\n");
return 1;
}
@@ -15783,7 +15641,6 @@ usage:
***********************************************************************/
int Abc_CommandExtWin( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtkRes, * pNtk;
int c;
int nObjId;
@@ -15793,9 +15650,6 @@ int Abc_CommandExtWin( Abc_Frame_t * pAbc, int argc, char ** argv )
extern Abc_Ntk_t * Abc_NtkDarExtWin( Abc_Ntk_t * pNtk, int nObjId, int nDist, int fVerbose );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
nObjId = -1;
nDist = 5;
@@ -15808,7 +15662,7 @@ int Abc_CommandExtWin( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'N':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
goto usage;
}
nObjId = atoi(argv[globalUtilOptind]);
@@ -15819,7 +15673,7 @@ int Abc_CommandExtWin( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'D':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-D\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
goto usage;
}
nDist = atoi(argv[globalUtilOptind]);
@@ -15838,25 +15692,25 @@ int Abc_CommandExtWin( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "Only works for structrally hashed networks.\n" );
+ Abc_Print( -1, "Only works for structrally hashed networks.\n" );
return 1;
}
if ( argc != globalUtilOptind )
{
- fprintf( pErr, "Not enough command-line arguments.\n" );
+ Abc_Print( -1, "Not enough command-line arguments.\n" );
return 1;
}
// modify the current network
pNtkRes = Abc_NtkDarExtWin( pNtk, nObjId, nDist, fVerbose );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Extracting sequential window has failed.\n" );
+ Abc_Print( -1, "Extracting sequential window has failed.\n" );
return 0;
}
// replace the current network
@@ -15864,12 +15718,12 @@ int Abc_CommandExtWin( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: extwin [-ND <num>] [-vh]\n" );
- fprintf( pErr, "\t extracts sequential window from the AIG\n" );
- fprintf( pErr, "\t-N num : the ID of the object to use as the center [default = %d]\n", nObjId );
- fprintf( pErr, "\t-D num : the \"radius\" of the window [default = %d]\n", nDist );
- fprintf( pErr, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: extwin [-ND <num>] [-vh]\n" );
+ Abc_Print( -2, "\t extracts sequential window from the AIG\n" );
+ Abc_Print( -2, "\t-N num : the ID of the object to use as the center [default = %d]\n", nObjId );
+ Abc_Print( -2, "\t-D num : the \"radius\" of the window [default = %d]\n", nDist );
+ Abc_Print( -2, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -15886,7 +15740,6 @@ usage:
***********************************************************************/
int Abc_CommandInsWin( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtkRes, * pNtk, * pNtkCare;
int c;
int nObjId;
@@ -15896,9 +15749,6 @@ int Abc_CommandInsWin( Abc_Frame_t * pAbc, int argc, char ** argv )
extern Abc_Ntk_t * Abc_NtkDarInsWin( Abc_Ntk_t * pNtk, Abc_Ntk_t * pWnd, int nObjId, int nDist, int fVerbose );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
nObjId = -1;
nDist = 5;
@@ -15911,7 +15761,7 @@ int Abc_CommandInsWin( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'N':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
goto usage;
}
nObjId = atoi(argv[globalUtilOptind]);
@@ -15922,7 +15772,7 @@ int Abc_CommandInsWin( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'D':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-D\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
goto usage;
}
nDist = atoi(argv[globalUtilOptind]);
@@ -15941,24 +15791,24 @@ int Abc_CommandInsWin( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "Only works for structrally hashed networks.\n" );
+ Abc_Print( -1, "Only works for structrally hashed networks.\n" );
return 1;
}
if ( argc != globalUtilOptind + 1 )
{
- fprintf( pErr, "Not enough command-line arguments.\n" );
+ Abc_Print( -1, "Not enough command-line arguments.\n" );
return 1;
}
pNtkCare = Io_Read( argv[globalUtilOptind], Io_ReadFileType(argv[globalUtilOptind]), 1 );
if ( pNtkCare == NULL )
{
- printf( "Reading care network has failed.\n" );
+ Abc_Print( -1, "Reading care network has failed.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtkCare) )
@@ -15972,7 +15822,7 @@ int Abc_CommandInsWin( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_NtkDelete( pNtkCare );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Inserting sequential window has failed.\n" );
+ Abc_Print( -1, "Inserting sequential window has failed.\n" );
return 0;
}
// replace the current network
@@ -15980,13 +15830,13 @@ int Abc_CommandInsWin( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: inswin [-ND <num>] [-vh] <file>\n" );
- fprintf( pErr, "\t inserts sequential window into the AIG\n" );
- fprintf( pErr, "\t-N num : the ID of the object to use as the center [default = %d]\n", nObjId );
- fprintf( pErr, "\t-D num : the \"radius\" of the window [default = %d]\n", nDist );
- fprintf( pErr, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
- fprintf( pErr, "\tfile : file with the AIG to be inserted\n");
+ Abc_Print( -2, "usage: inswin [-ND <num>] [-vh] <file>\n" );
+ Abc_Print( -2, "\t inserts sequential window into the AIG\n" );
+ Abc_Print( -2, "\t-N num : the ID of the object to use as the center [default = %d]\n", nObjId );
+ Abc_Print( -2, "\t-D num : the \"radius\" of the window [default = %d]\n", nDist );
+ Abc_Print( -2, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ Abc_Print( -2, "\tfile : file with the AIG to be inserted\n");
return 1;
}
@@ -16004,7 +15854,6 @@ usage:
int Abc_CommandCec( Abc_Frame_t * pAbc, int argc, char ** argv )
{
char Buffer[16];
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtk1, * pNtk2;
int fDelete1, fDelete2;
char ** pArgvNew;
@@ -16025,9 +15874,6 @@ int Abc_CommandCec( Abc_Frame_t * pAbc, int argc, char ** argv )
extern void Abc_NtkCecFraigPartAuto( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nSeconds, int fVerbose );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fSat = 0;
fVerbose = 0;
@@ -16045,7 +15891,7 @@ int Abc_CommandCec( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'T':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-T\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
goto usage;
}
nSeconds = atoi(argv[globalUtilOptind]);
@@ -16056,7 +15902,7 @@ int Abc_CommandCec( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
nConfLimit = atoi(argv[globalUtilOptind]);
@@ -16067,7 +15913,7 @@ int Abc_CommandCec( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'I':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-I\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
goto usage;
}
nInsLimit = atoi(argv[globalUtilOptind]);
@@ -16078,7 +15924,7 @@ int Abc_CommandCec( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'P':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-P\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
goto usage;
}
nPartSize = atoi(argv[globalUtilOptind]);
@@ -16105,7 +15951,7 @@ int Abc_CommandCec( Abc_Frame_t * pAbc, int argc, char ** argv )
pArgvNew = argv + globalUtilOptind;
nArgcNew = argc - globalUtilOptind;
- if ( !Abc_NtkPrepareTwoNtks( pErr, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
+ if ( !Abc_NtkPrepareTwoNtks( stdout, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
return 1;
if ( fIgnoreNames )
@@ -16133,21 +15979,21 @@ usage:
strcpy( Buffer, "unused" );
else
sprintf( Buffer, "%d", nPartSize );
- fprintf( pErr, "usage: cec [-T num] [-C num] [-I num] [-P num] [-psnvh] <file1> <file2>\n" );
- fprintf( pErr, "\t performs combinational equivalence checking\n" );
- fprintf( pErr, "\t-T num : approximate runtime limit in seconds [default = %d]\n", nSeconds );
- fprintf( pErr, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfLimit );
- fprintf( pErr, "\t-I num : limit on the number of clause inspections [default = %d]\n", nInsLimit );
- fprintf( pErr, "\t-P num : partition size for multi-output networks [default = %s]\n", Buffer );
- fprintf( pErr, "\t-p : toggle automatic partitioning [default = %s]\n", fPartition? "yes": "no" );
- fprintf( pErr, "\t-s : toggle \"SAT only\" and \"FRAIG + SAT\" [default = %s]\n", fSat? "SAT only": "FRAIG + SAT" );
- fprintf( pErr, "\t-n : toggle ignoring names when matching CIs/COs [default = %s]\n", fIgnoreNames? "yes": "no" );
- fprintf( pErr, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
- fprintf( pErr, "\tfile1 : (optional) the file with the first network\n");
- fprintf( pErr, "\tfile2 : (optional) the file with the second network\n");
- fprintf( pErr, "\t if no files are given, uses the current network and its spec\n");
- fprintf( pErr, "\t if one file is given, uses the current network and the file\n");
+ Abc_Print( -2, "usage: cec [-T num] [-C num] [-I num] [-P num] [-psnvh] <file1> <file2>\n" );
+ Abc_Print( -2, "\t performs combinational equivalence checking\n" );
+ Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n", nSeconds );
+ Abc_Print( -2, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfLimit );
+ Abc_Print( -2, "\t-I num : limit on the number of clause inspections [default = %d]\n", nInsLimit );
+ Abc_Print( -2, "\t-P num : partition size for multi-output networks [default = %s]\n", Buffer );
+ Abc_Print( -2, "\t-p : toggle automatic partitioning [default = %s]\n", fPartition? "yes": "no" );
+ Abc_Print( -2, "\t-s : toggle \"SAT only\" and \"FRAIG + SAT\" [default = %s]\n", fSat? "SAT only": "FRAIG + SAT" );
+ Abc_Print( -2, "\t-n : toggle ignoring names when matching CIs/COs [default = %s]\n", fIgnoreNames? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ Abc_Print( -2, "\tfile1 : (optional) the file with the first network\n");
+ Abc_Print( -2, "\tfile2 : (optional) the file with the second network\n");
+ Abc_Print( -2, "\t if no files are given, uses the current network and its spec\n");
+ Abc_Print( -2, "\t if one file is given, uses the current network and the file\n");
return 1;
}
@@ -16165,7 +16011,6 @@ usage:
***********************************************************************/
int Abc_CommandDCec( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtk1, * pNtk2;
int fDelete1, fDelete2;
char ** pArgvNew;
@@ -16183,9 +16028,6 @@ int Abc_CommandDCec( Abc_Frame_t * pAbc, int argc, char ** argv )
extern int Abc_NtkDarCec( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nConfLimit, int fPartition, int fVerbose );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fSat = 0;
fVerbose = 0;
@@ -16202,7 +16044,7 @@ int Abc_CommandDCec( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'T':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-T\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
goto usage;
}
nSeconds = atoi(argv[globalUtilOptind]);
@@ -16213,7 +16055,7 @@ int Abc_CommandDCec( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
nConfLimit = atoi(argv[globalUtilOptind]);
@@ -16224,7 +16066,7 @@ int Abc_CommandDCec( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'I':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-I\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
goto usage;
}
nInsLimit = atoi(argv[globalUtilOptind]);
@@ -16255,7 +16097,7 @@ int Abc_CommandDCec( Abc_Frame_t * pAbc, int argc, char ** argv )
{
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( Abc_NtkIsStrash(pNtk) )
@@ -16273,7 +16115,7 @@ int Abc_CommandDCec( Abc_Frame_t * pAbc, int argc, char ** argv )
}
else
{
- if ( !Abc_NtkPrepareTwoNtks( pErr, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
+ if ( !Abc_NtkPrepareTwoNtks( stdout, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
return 1;
}
@@ -16281,7 +16123,7 @@ int Abc_CommandDCec( Abc_Frame_t * pAbc, int argc, char ** argv )
{
if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
- printf( "Currently this command only works for networks without latches. Run \"comb\".\n" );
+ Abc_Print( -1, "Currently this command only works for networks without latches. Run \"comb\".\n" );
return 1;
}
@@ -16296,20 +16138,20 @@ int Abc_CommandDCec( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: dcec [-T num] [-C num] [-I num] [-mpsvh] <file1> <file2>\n" );
- fprintf( pErr, "\t performs combinational equivalence checking\n" );
- fprintf( pErr, "\t-T num : approximate runtime limit in seconds [default = %d]\n", nSeconds );
- fprintf( pErr, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfLimit );
- fprintf( pErr, "\t-I num : limit on the number of clause inspections [default = %d]\n", nInsLimit );
- fprintf( pErr, "\t-m : toggle working on two networks or a miter [default = %s]\n", fMiter? "miter": "two networks" );
- fprintf( pErr, "\t-p : toggle automatic partitioning [default = %s]\n", fPartition? "yes": "no" );
- fprintf( pErr, "\t-s : toggle \"SAT only\" (miter) or \"FRAIG + SAT\" [default = %s]\n", fSat? "SAT only": "FRAIG + SAT" );
- fprintf( pErr, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
- fprintf( pErr, "\tfile1 : (optional) the file with the first network\n");
- fprintf( pErr, "\tfile2 : (optional) the file with the second network\n");
- fprintf( pErr, "\t if no files are given, uses the current network and its spec\n");
- fprintf( pErr, "\t if one file is given, uses the current network and the file\n");
+ Abc_Print( -2, "usage: dcec [-T num] [-C num] [-I num] [-mpsvh] <file1> <file2>\n" );
+ Abc_Print( -2, "\t performs combinational equivalence checking\n" );
+ Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n", nSeconds );
+ Abc_Print( -2, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfLimit );
+ Abc_Print( -2, "\t-I num : limit on the number of clause inspections [default = %d]\n", nInsLimit );
+ Abc_Print( -2, "\t-m : toggle working on two networks or a miter [default = %s]\n", fMiter? "miter": "two networks" );
+ Abc_Print( -2, "\t-p : toggle automatic partitioning [default = %s]\n", fPartition? "yes": "no" );
+ Abc_Print( -2, "\t-s : toggle \"SAT only\" (miter) or \"FRAIG + SAT\" [default = %s]\n", fSat? "SAT only": "FRAIG + SAT" );
+ Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ Abc_Print( -2, "\tfile1 : (optional) the file with the first network\n");
+ Abc_Print( -2, "\tfile2 : (optional) the file with the second network\n");
+ Abc_Print( -2, "\t if no files are given, uses the current network and its spec\n");
+ Abc_Print( -2, "\t if one file is given, uses the current network and the file\n");
return 1;
}
@@ -16326,7 +16168,6 @@ usage:
***********************************************************************/
int Abc_CommandSec( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtk1, * pNtk2;
int fDelete1, fDelete2;
char ** pArgvNew;
@@ -16343,11 +16184,10 @@ int Abc_CommandSec( Abc_Frame_t * pAbc, int argc, char ** argv )
extern void Abc_NtkSecSat( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nConfLimit, int nInsLimit, int nFrames );
extern int Abc_NtkSecFraig( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nSeconds, int nFrames, int fVerbose );
+ Abc_Print( 0, "This command is no longer used.\n" );
+ return 0;
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fRetime = 0; // verification after retiming
fSat = 0;
@@ -16364,7 +16204,7 @@ int Abc_CommandSec( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
nFrames = atoi(argv[globalUtilOptind]);
@@ -16375,7 +16215,7 @@ int Abc_CommandSec( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'T':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-T\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
goto usage;
}
nSeconds = atoi(argv[globalUtilOptind]);
@@ -16386,7 +16226,7 @@ int Abc_CommandSec( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
nConfLimit = atoi(argv[globalUtilOptind]);
@@ -16397,7 +16237,7 @@ int Abc_CommandSec( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'I':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-I\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
goto usage;
}
nInsLimit = atoi(argv[globalUtilOptind]);
@@ -16421,14 +16261,14 @@ int Abc_CommandSec( Abc_Frame_t * pAbc, int argc, char ** argv )
pArgvNew = argv + globalUtilOptind;
nArgcNew = argc - globalUtilOptind;
- if ( !Abc_NtkPrepareTwoNtks( pErr, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
+ if ( !Abc_NtkPrepareTwoNtks( stdout, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
return 1;
if ( Abc_NtkLatchNum(pNtk1) == 0 || Abc_NtkLatchNum(pNtk2) == 0 )
{
if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
- printf( "The network has no latches. Used combinational command \"cec\".\n" );
+ Abc_Print( -1, "The network has no latches. Used combinational command \"cec\".\n" );
return 0;
}
@@ -16443,21 +16283,21 @@ int Abc_CommandSec( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: sec [-F num] [-T num] [-C num] [-I num] [-srvh] <file1> <file2>\n" );
- fprintf( pErr, "\t performs bounded sequential equivalence checking\n" );
- fprintf( pErr, "\t (there is also an unbounded SEC commands, \"dsec\" and \"dprove\")\n" );
- fprintf( pErr, "\t-s : toggle \"SAT only\" and \"FRAIG + SAT\" [default = %s]\n", fSat? "SAT only": "FRAIG + SAT" );
- fprintf( pErr, "\t-r : toggles retiming verification [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
- fprintf( pErr, "\t-F num : the number of time frames to use [default = %d]\n", nFrames );
- fprintf( pErr, "\t-T num : approximate runtime limit in seconds [default = %d]\n", nSeconds );
- fprintf( pErr, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfLimit );
- fprintf( pErr, "\t-I num : limit on the number of inspections [default = %d]\n", nInsLimit );
- fprintf( pErr, "\tfile1 : (optional) the file with the first network\n");
- fprintf( pErr, "\tfile2 : (optional) the file with the second network\n");
- fprintf( pErr, "\t if no files are given, uses the current network and its spec\n");
- fprintf( pErr, "\t if one file is given, uses the current network and the file\n");
+ Abc_Print( -2, "usage: sec [-F num] [-T num] [-C num] [-I num] [-srvh] <file1> <file2>\n" );
+ Abc_Print( -2, "\t performs bounded sequential equivalence checking\n" );
+ Abc_Print( -2, "\t (there is also an unbounded SEC commands, \"dsec\" and \"dprove\")\n" );
+ Abc_Print( -2, "\t-s : toggle \"SAT only\" and \"FRAIG + SAT\" [default = %s]\n", fSat? "SAT only": "FRAIG + SAT" );
+ Abc_Print( -2, "\t-r : toggles retiming verification [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ Abc_Print( -2, "\t-F num : the number of time frames to use [default = %d]\n", nFrames );
+ Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n", nSeconds );
+ Abc_Print( -2, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfLimit );
+ Abc_Print( -2, "\t-I num : limit on the number of inspections [default = %d]\n", nInsLimit );
+ Abc_Print( -2, "\tfile1 : (optional) the file with the first network\n");
+ Abc_Print( -2, "\tfile2 : (optional) the file with the second network\n");
+ Abc_Print( -2, "\t if no files are given, uses the current network and its spec\n");
+ Abc_Print( -2, "\t if one file is given, uses the current network and the file\n");
return 1;
}
@@ -16475,7 +16315,6 @@ usage:
int Abc_CommandDSec( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Fra_Sec_t SecPar, * pSecPar = &SecPar;
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtk1, * pNtk2;
int fDelete1, fDelete2;
char ** pArgvNew;
@@ -16487,9 +16326,6 @@ int Abc_CommandDSec( Abc_Frame_t * pAbc, int argc, char ** argv )
extern int Abc_NtkDarSec( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, Fra_Sec_t * p );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Fra_SecSetDefaultParams( pSecPar );
pSecPar->TimeLimit = 0;
@@ -16502,7 +16338,7 @@ int Abc_CommandDSec( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
pSecPar->nFramesMax = atoi(argv[globalUtilOptind]);
@@ -16513,7 +16349,7 @@ int Abc_CommandDSec( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'T':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-T\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
goto usage;
}
pSecPar->TimeLimit = atoi(argv[globalUtilOptind]);
@@ -16549,13 +16385,13 @@ int Abc_CommandDSec( Abc_Frame_t * pAbc, int argc, char ** argv )
pArgvNew = argv + globalUtilOptind;
nArgcNew = argc - globalUtilOptind;
- if ( !Abc_NtkPrepareTwoNtks( pErr, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
+ if ( !Abc_NtkPrepareTwoNtks( stdout, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
return 1;
if ( Abc_NtkLatchNum(pNtk1) == 0 || Abc_NtkLatchNum(pNtk2) == 0 )
{
if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
- printf( "The network has no latches. Used combinational command \"cec\".\n" );
+ Abc_Print( -1, "The network has no latches. Used combinational command \"cec\".\n" );
return 0;
}
@@ -16573,22 +16409,22 @@ int Abc_CommandDSec( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: dsec [-F num] [-T num] [-armfnwvh] <file1> <file2>\n" );
- fprintf( pErr, "\t performs inductive sequential equivalence checking\n" );
- fprintf( pErr, "\t-F num : the limit on the depth of induction [default = %d]\n", pSecPar->nFramesMax );
- fprintf( pErr, "\t-T num : the approximate runtime limit (in seconds) [default = %d]\n", pSecPar->TimeLimit );
- fprintf( pErr, "\t-a : toggles the use of phase abstraction [default = %s]\n", pSecPar->fPhaseAbstract? "yes": "no" );
- fprintf( pErr, "\t-r : toggles forward retiming at the beginning [default = %s]\n", pSecPar->fRetimeFirst? "yes": "no" );
- fprintf( pErr, "\t-m : toggles min-register retiming [default = %s]\n", pSecPar->fRetimeRegs? "yes": "no" );
- fprintf( pErr, "\t-f : toggles the internal use of fraiging [default = %s]\n", pSecPar->fFraiging? "yes": "no" );
- fprintf( pErr, "\t-n : toggle ignoring names when matching PIs/POs [default = %s]\n", fIgnoreNames? "yes": "no" );
- fprintf( pErr, "\t-v : toggles verbose output [default = %s]\n", pSecPar->fVerbose? "yes": "no" );
- fprintf( pErr, "\t-w : toggles additional verbose output [default = %s]\n", pSecPar->fVeryVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
- fprintf( pErr, "\tfile1 : (optional) the file with the first network\n");
- fprintf( pErr, "\tfile2 : (optional) the file with the second network\n");
- fprintf( pErr, "\t if no files are given, uses the current network and its spec\n");
- fprintf( pErr, "\t if one file is given, uses the current network and the file\n");
+ Abc_Print( -2, "usage: dsec [-F num] [-T num] [-armfnwvh] <file1> <file2>\n" );
+ Abc_Print( -2, "\t performs inductive sequential equivalence checking\n" );
+ Abc_Print( -2, "\t-F num : the limit on the depth of induction [default = %d]\n", pSecPar->nFramesMax );
+ Abc_Print( -2, "\t-T num : the approximate runtime limit (in seconds) [default = %d]\n", pSecPar->TimeLimit );
+ Abc_Print( -2, "\t-a : toggles the use of phase abstraction [default = %s]\n", pSecPar->fPhaseAbstract? "yes": "no" );
+ Abc_Print( -2, "\t-r : toggles forward retiming at the beginning [default = %s]\n", pSecPar->fRetimeFirst? "yes": "no" );
+ Abc_Print( -2, "\t-m : toggles min-register retiming [default = %s]\n", pSecPar->fRetimeRegs? "yes": "no" );
+ Abc_Print( -2, "\t-f : toggles the internal use of fraiging [default = %s]\n", pSecPar->fFraiging? "yes": "no" );
+ Abc_Print( -2, "\t-n : toggle ignoring names when matching PIs/POs [default = %s]\n", fIgnoreNames? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", pSecPar->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-w : toggles additional verbose output [default = %s]\n", pSecPar->fVeryVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ Abc_Print( -2, "\tfile1 : (optional) the file with the first network\n");
+ Abc_Print( -2, "\tfile2 : (optional) the file with the second network\n");
+ Abc_Print( -2, "\t if no files are given, uses the current network and its spec\n");
+ Abc_Print( -2, "\t if one file is given, uses the current network and the file\n");
return 1;
}
@@ -16606,22 +16442,17 @@ usage:
int Abc_CommandDProve( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Fra_Sec_t SecPar, * pSecPar = &SecPar;
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
+ char * pLogFileName = NULL;
extern void Fra_SecSetDefaultParams( Fra_Sec_t * p );
extern int Abc_NtkDarProve( Abc_Ntk_t * pNtk, Fra_Sec_t * pSecPar );
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Fra_SecSetDefaultParams( pSecPar );
// pSecPar->TimeLimit = 300;
Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "cbFCGDVBRarmfijkouwvh" ) ) != EOF )
+ while ( ( c = Extra_UtilGetopt( argc, argv, "cbFCGDVBRLarmfijkouwvh" ) ) != EOF )
{
switch ( c )
{
@@ -16634,7 +16465,7 @@ int Abc_CommandDProve( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
pSecPar->nFramesMax = atoi(argv[globalUtilOptind]);
@@ -16645,7 +16476,7 @@ int Abc_CommandDProve( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
pSecPar->nBTLimit = atoi(argv[globalUtilOptind]);
@@ -16656,7 +16487,7 @@ int Abc_CommandDProve( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'G':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-G\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-G\" should be followed by an integer.\n" );
goto usage;
}
pSecPar->nBTLimitGlobal = atoi(argv[globalUtilOptind]);
@@ -16667,7 +16498,7 @@ int Abc_CommandDProve( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'D':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-D\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
goto usage;
}
pSecPar->nBTLimitInter = atoi(argv[globalUtilOptind]);
@@ -16678,7 +16509,7 @@ int Abc_CommandDProve( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'V':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-V\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-V\" should be followed by an integer.\n" );
goto usage;
}
pSecPar->nBddVarsMax = atoi(argv[globalUtilOptind]);
@@ -16689,7 +16520,7 @@ int Abc_CommandDProve( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'B':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-B\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-B\" should be followed by an integer.\n" );
goto usage;
}
pSecPar->nBddMax = atoi(argv[globalUtilOptind]);
@@ -16700,7 +16531,7 @@ int Abc_CommandDProve( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'R':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-R\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
goto usage;
}
pSecPar->nBddIterMax = atoi(argv[globalUtilOptind]);
@@ -16708,6 +16539,15 @@ int Abc_CommandDProve( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pSecPar->nBddIterMax < 0 )
goto usage;
break;
+ case 'L':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-L\" should be followed by a file name.\n" );
+ goto usage;
+ }
+ pLogFileName = argv[globalUtilOptind];
+ globalUtilOptind++;
+ break;
case 'a':
pSecPar->fPhaseAbstract ^= 1;
break;
@@ -16747,19 +16587,21 @@ int Abc_CommandDProve( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- printf( "This command works only for structrally hashed networks. Run \"st\".\n" );
+ Abc_Print( -1, "This command works only for structrally hashed networks. Run \"st\".\n" );
return 0;
}
// perform verification
- Abc_NtkDarProve( pNtk, pSecPar );
- pAbc->pCex = pNtk->pSeqModel; // temporary ???
+ pAbc->Status = Abc_NtkDarProve( pNtk, pSecPar );
+ Abc_FrameReplaceCex( pAbc, &pNtk->pSeqModel );
+ if ( pLogFileName )
+ Abc_NtkWriteLogFile( pLogFileName, pAbc->pCex, pAbc->Status, "dprove" );
// read back the resulting unsolved reduced sequential miter
if ( pSecPar->fReadUnsolved && pSecPar->nSMnumber >= 0 )
@@ -16768,36 +16610,37 @@ int Abc_CommandDProve( Abc_Frame_t * pAbc, int argc, char ** argv )
sprintf( FileName, "sm%02d.aig", pSecPar->nSMnumber );
pNtk = Io_Read( FileName, Io_ReadFileType(FileName), 1 );
if ( pNtk == NULL )
- printf( "Cannot read back unsolved reduced sequential miter \"%s\",\n", FileName );
+ Abc_Print( -1, "Cannot read back unsolved reduced sequential miter \"%s\",\n", FileName );
else
Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
}
return 0;
usage:
- fprintf( pErr, "usage: dprove [-FCGDVBR num] [-cbarmfijouwvh]\n" );
- fprintf( pErr, "\t performs SEC on the sequential miter\n" );
- fprintf( pErr, "\t-F num : the limit on the depth of induction [default = %d]\n", pSecPar->nFramesMax );
- fprintf( pErr, "\t-C num : the conflict limit at a node during induction [default = %d]\n", pSecPar->nBTLimit );
- fprintf( pErr, "\t-G num : the global conflict limit during induction [default = %d]\n", pSecPar->nBTLimitGlobal );
- fprintf( pErr, "\t-D num : the conflict limit during interpolation [default = %d]\n", pSecPar->nBTLimitInter );
- fprintf( pErr, "\t-V num : the flop count limit for BDD-based reachablity [default = %d]\n", pSecPar->nBddVarsMax );
- fprintf( pErr, "\t-B num : the BDD size limit in BDD-based reachablity [default = %d]\n", pSecPar->nBddMax );
- fprintf( pErr, "\t-R num : the max number of reachability iterations [default = %d]\n", pSecPar->nBddIterMax );
- fprintf( pErr, "\t-c : toggles using CEC before attempting SEC [default = %s]\n", pSecPar->fTryComb? "yes": "no" );
- fprintf( pErr, "\t-b : toggles using BMC before attempting SEC [default = %s]\n", pSecPar->fTryBmc? "yes": "no" );
- fprintf( pErr, "\t-a : toggles the use of phase abstraction [default = %s]\n", pSecPar->fPhaseAbstract? "yes": "no" );
- fprintf( pErr, "\t-r : toggles forward retiming at the beginning [default = %s]\n", pSecPar->fRetimeFirst? "yes": "no" );
- fprintf( pErr, "\t-m : toggles min-register retiming [default = %s]\n", pSecPar->fRetimeRegs? "yes": "no" );
- fprintf( pErr, "\t-f : toggles the internal use of fraiging [default = %s]\n", pSecPar->fFraiging? "yes": "no" );
- fprintf( pErr, "\t-i : toggles the use of induction [default = %s]\n", pSecPar->fInduction? "yes": "no" );
- fprintf( pErr, "\t-j : toggles the use of interpolation [default = %s]\n", pSecPar->fInterpolation? "yes": "no" );
- fprintf( pErr, "\t-k : toggles applying interpolation to each output [default = %s]\n", pSecPar->fInterSeparate? "yes": "no" );
- fprintf( pErr, "\t-o : toggles using BDD variable reordering during image computation [default = %s]\n", pSecPar->fReorderImage? "yes": "no" );
- fprintf( pErr, "\t-u : toggles reading back unsolved reduced sequential miter [default = %s]\n", pSecPar->fReadUnsolved? "yes": "no" );
- fprintf( pErr, "\t-v : toggles verbose output [default = %s]\n", pSecPar->fVerbose? "yes": "no" );
- fprintf( pErr, "\t-w : toggles additional verbose output [default = %s]\n", pSecPar->fVeryVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: dprove [-FCGDVBR num] [-L file] [-cbarmfijouwvh]\n" );
+ Abc_Print( -2, "\t performs SEC on the sequential miter\n" );
+ Abc_Print( -2, "\t-F num : the limit on the depth of induction [default = %d]\n", pSecPar->nFramesMax );
+ Abc_Print( -2, "\t-C num : the conflict limit at a node during induction [default = %d]\n", pSecPar->nBTLimit );
+ Abc_Print( -2, "\t-G num : the global conflict limit during induction [default = %d]\n", pSecPar->nBTLimitGlobal );
+ Abc_Print( -2, "\t-D num : the conflict limit during interpolation [default = %d]\n", pSecPar->nBTLimitInter );
+ Abc_Print( -2, "\t-V num : the flop count limit for BDD-based reachablity [default = %d]\n", pSecPar->nBddVarsMax );
+ Abc_Print( -2, "\t-B num : the BDD size limit in BDD-based reachablity [default = %d]\n", pSecPar->nBddMax );
+ Abc_Print( -2, "\t-R num : the max number of reachability iterations [default = %d]\n", pSecPar->nBddIterMax );
+ Abc_Print( -2, "\t-L file: the log file name [default = %s]\n", pLogFileName ? pLogFileName : "no logging" );
+ Abc_Print( -2, "\t-c : toggles using CEC before attempting SEC [default = %s]\n", pSecPar->fTryComb? "yes": "no" );
+ Abc_Print( -2, "\t-b : toggles using BMC before attempting SEC [default = %s]\n", pSecPar->fTryBmc? "yes": "no" );
+ Abc_Print( -2, "\t-a : toggles the use of phase abstraction [default = %s]\n", pSecPar->fPhaseAbstract? "yes": "no" );
+ Abc_Print( -2, "\t-r : toggles forward retiming at the beginning [default = %s]\n", pSecPar->fRetimeFirst? "yes": "no" );
+ Abc_Print( -2, "\t-m : toggles min-register retiming [default = %s]\n", pSecPar->fRetimeRegs? "yes": "no" );
+ Abc_Print( -2, "\t-f : toggles the internal use of fraiging [default = %s]\n", pSecPar->fFraiging? "yes": "no" );
+ Abc_Print( -2, "\t-i : toggles the use of induction [default = %s]\n", pSecPar->fInduction? "yes": "no" );
+ Abc_Print( -2, "\t-j : toggles the use of interpolation [default = %s]\n", pSecPar->fInterpolation? "yes": "no" );
+ Abc_Print( -2, "\t-k : toggles applying interpolation to each output [default = %s]\n", pSecPar->fInterSeparate? "yes": "no" );
+ Abc_Print( -2, "\t-o : toggles using BDD variable reordering during image computation [default = %s]\n", pSecPar->fReorderImage? "yes": "no" );
+ Abc_Print( -2, "\t-u : toggles reading back unsolved reduced sequential miter [default = %s]\n", pSecPar->fReadUnsolved? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", pSecPar->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-w : toggles additional verbose output [default = %s]\n", pSecPar->fVeryVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -16815,20 +16658,14 @@ usage:
***********************************************************************/
int Abc_CommandDProve2( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int nConfLast;
int fSeparate;
int fVeryVerbose;
int fVerbose;
int c;
- extern int Abc_NtkDProve2( Abc_Ntk_t * pNtk, int nConfLast, int fSeparate, int fVeryVerbose, int fVerbose );
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
+// extern int Abc_NtkDProve2( Abc_Ntk_t * pNtk, int nConfLast, int fSeparate, int fVeryVerbose, int fVerbose );
// set defaults
nConfLast = 75000;
fSeparate = 0;
@@ -16842,7 +16679,7 @@ int Abc_CommandDProve2( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
nConfLast = atoi(argv[globalUtilOptind]);
@@ -16865,31 +16702,31 @@ int Abc_CommandDProve2( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- printf( "This command works only for structrally hashed networks. Run \"st\".\n" );
+ Abc_Print( -1, "This command works only for structrally hashed networks. Run \"st\".\n" );
return 0;
}
if ( Abc_NtkLatchNum(pNtk) == 0 )
{
- printf( "This command works only for sequential networks.\n" );
+ Abc_Print( -1, "This command works only for sequential networks.\n" );
return 0;
}
// perform verification
- Abc_NtkDProve2( pNtk, nConfLast, fSeparate, fVeryVerbose, fVerbose );
+// Abc_NtkDProve2( pNtk, nConfLast, fSeparate, fVeryVerbose, fVerbose );
return 0;
usage:
- fprintf( pErr, "usage: dprove2 [-C num] [-kwvh]\n" );
- fprintf( pErr, "\t improved integrated solver of sequential miters\n" );
- fprintf( pErr, "\t-C num : the conflict limit during final BMC [default = %d]\n", nConfLast );
- fprintf( pErr, "\t-k : toggles solving each output separately [default = %s]\n", fSeparate? "yes": "no" );
- fprintf( pErr, "\t-w : toggles very verbose output [default = %s]\n", fVeryVerbose? "yes": "no" );
- fprintf( pErr, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: dprove2 [-C num] [-kwvh]\n" );
+ Abc_Print( -2, "\t improved integrated solver of sequential miters\n" );
+ Abc_Print( -2, "\t-C num : the conflict limit during final BMC [default = %d]\n", nConfLast );
+ Abc_Print( -2, "\t-k : toggles solving each output separately [default = %s]\n", fSeparate? "yes": "no" );
+ Abc_Print( -2, "\t-w : toggles very verbose output [default = %s]\n", fVeryVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -16906,7 +16743,6 @@ usage:
***********************************************************************/
int Abc_CommandAbSec( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtk1, * pNtk2;
int fDelete1, fDelete2;
char ** pArgvNew;
@@ -16916,9 +16752,6 @@ int Abc_CommandAbSec( Abc_Frame_t * pAbc, int argc, char ** argv )
extern int Abc_NtkDarAbSec( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nFrames, int fVerbose );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fMiter = 1;
nFrames = 2;
@@ -16931,7 +16764,7 @@ int Abc_CommandAbSec( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
nFrames = atoi(argv[globalUtilOptind]);
@@ -16954,7 +16787,7 @@ int Abc_CommandAbSec( Abc_Frame_t * pAbc, int argc, char ** argv )
{
if ( !Abc_NtkIsStrash(pNtk) )
{
- printf( "This command works only for structrally hashed networks. Run \"st\".\n" );
+ Abc_Print( -1, "This command works only for structrally hashed networks. Run \"st\".\n" );
return 0;
}
Abc_NtkDarAbSec( pNtk, NULL, nFrames, fVerbose );
@@ -16963,13 +16796,13 @@ int Abc_CommandAbSec( Abc_Frame_t * pAbc, int argc, char ** argv )
{
pArgvNew = argv + globalUtilOptind;
nArgcNew = argc - globalUtilOptind;
- if ( !Abc_NtkPrepareTwoNtks( pErr, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
+ if ( !Abc_NtkPrepareTwoNtks( stdout, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
return 1;
if ( Abc_NtkLatchNum(pNtk1) == 0 || Abc_NtkLatchNum(pNtk2) == 0 )
{
if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
- printf( "The network has no latches. Used combinational command \"cec\".\n" );
+ Abc_Print( -1, "The network has no latches. Used combinational command \"cec\".\n" );
return 0;
}
// perform verification
@@ -16980,15 +16813,15 @@ int Abc_CommandAbSec( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: absec [-F num] [-mv] <file1> <file2>\n" );
- fprintf( pErr, "\t performs SEC by applying CEC to several timeframes\n" );
- fprintf( pErr, "\t-F num : the total number of timeframes to use [default = %d]\n", nFrames );
- fprintf( pErr, "\t-m : toggles miter vs. two networks [default = %s]\n", fMiter? "miter": "two networks" );
- fprintf( pErr, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\tfile1 : (optional) the file with the first network\n");
- fprintf( pErr, "\tfile2 : (optional) the file with the second network\n");
- fprintf( pErr, "\t if no files are given, uses the current network and its spec\n");
- fprintf( pErr, "\t if one file is given, uses the current network and the file\n");
+ Abc_Print( -2, "usage: absec [-F num] [-mv] <file1> <file2>\n" );
+ Abc_Print( -2, "\t performs SEC by applying CEC to several timeframes\n" );
+ Abc_Print( -2, "\t-F num : the total number of timeframes to use [default = %d]\n", nFrames );
+ Abc_Print( -2, "\t-m : toggles miter vs. two networks [default = %s]\n", fMiter? "miter": "two networks" );
+ Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\tfile1 : (optional) the file with the first network\n");
+ Abc_Print( -2, "\tfile2 : (optional) the file with the second network\n");
+ Abc_Print( -2, "\t if no files are given, uses the current network and its spec\n");
+ Abc_Print( -2, "\t if one file is given, uses the current network and the file\n");
return 1;
}
@@ -17006,7 +16839,6 @@ usage:
int Abc_CommandSimSec( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Ssw_Pars_t Pars, * pPars = &Pars;
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtk1, * pNtk2;
int fDelete1, fDelete2;
char ** pArgvNew;
@@ -17016,9 +16848,6 @@ int Abc_CommandSimSec( Abc_Frame_t * pAbc, int argc, char ** argv )
extern int Abc_NtkDarSimSec( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, Ssw_Pars_t * pPars );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fMiter = 1;
Ssw_ManSetDefaultParams( pPars );
@@ -17032,7 +16861,7 @@ int Abc_CommandSimSec( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
pPars->nFramesK = atoi(argv[globalUtilOptind]);
@@ -17043,7 +16872,7 @@ int Abc_CommandSimSec( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'D':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-D\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
goto usage;
}
pPars->nIsleDist = atoi(argv[globalUtilOptind]);
@@ -17073,7 +16902,7 @@ int Abc_CommandSimSec( Abc_Frame_t * pAbc, int argc, char ** argv )
// Abc_Ntk_t * pNtkA, * pNtkB;
if ( !Abc_NtkIsStrash(pNtk) )
{
- printf( "This command works only for structrally hashed networks. Run \"st\".\n" );
+ Abc_Print( -1, "This command works only for structrally hashed networks. Run \"st\".\n" );
return 0;
}
Abc_NtkDarSimSec( pNtk, NULL, pPars );
@@ -17089,13 +16918,13 @@ int Abc_CommandSimSec( Abc_Frame_t * pAbc, int argc, char ** argv )
{
pArgvNew = argv + globalUtilOptind;
nArgcNew = argc - globalUtilOptind;
- if ( !Abc_NtkPrepareTwoNtks( pErr, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
+ if ( !Abc_NtkPrepareTwoNtks( stdout, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
return 1;
if ( Abc_NtkLatchNum(pNtk1) == 0 || Abc_NtkLatchNum(pNtk2) == 0 )
{
if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
- printf( "The network has no latches. Used combinational command \"cec\".\n" );
+ Abc_Print( -1, "The network has no latches. Used combinational command \"cec\".\n" );
return 0;
}
// perform verification
@@ -17106,18 +16935,18 @@ int Abc_CommandSimSec( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: simsec [-FD num] [-mcyv] <file1> <file2>\n" );
- fprintf( pErr, "\t performs SEC using structural similarity\n" );
- fprintf( pErr, "\t-F num : the limit on the depth of induction [default = %d]\n", pPars->nFramesK );
- fprintf( pErr, "\t-D num : the distance for extending islands [default = %d]\n", pPars->nIsleDist );
- fprintf( pErr, "\t-m : toggles miter vs. two networks [default = %s]\n", fMiter? "miter": "two networks" );
- fprintf( pErr, "\t-c : uses partial vs. full signal correspondence [default = %s]\n", pPars->fPartSigCorr? "partial": "full" );
- fprintf( pErr, "\t-y : dumps speculatively reduced miter of the classes [default = %s]\n", pPars->fDumpSRInit? "yes": "no" );
- fprintf( pErr, "\t-v : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
- fprintf( pErr, "\tfile1 : (optional) the file with the first network\n");
- fprintf( pErr, "\tfile2 : (optional) the file with the second network\n");
- fprintf( pErr, "\t if no files are given, uses the current network and its spec\n");
- fprintf( pErr, "\t if one file is given, uses the current network and the file\n");
+ Abc_Print( -2, "usage: simsec [-FD num] [-mcyv] <file1> <file2>\n" );
+ Abc_Print( -2, "\t performs SEC using structural similarity\n" );
+ Abc_Print( -2, "\t-F num : the limit on the depth of induction [default = %d]\n", pPars->nFramesK );
+ Abc_Print( -2, "\t-D num : the distance for extending islands [default = %d]\n", pPars->nIsleDist );
+ Abc_Print( -2, "\t-m : toggles miter vs. two networks [default = %s]\n", fMiter? "miter": "two networks" );
+ Abc_Print( -2, "\t-c : uses partial vs. full signal correspondence [default = %s]\n", pPars->fPartSigCorr? "partial": "full" );
+ Abc_Print( -2, "\t-y : dumps speculatively reduced miter of the classes [default = %s]\n", pPars->fDumpSRInit? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\tfile1 : (optional) the file with the first network\n");
+ Abc_Print( -2, "\tfile2 : (optional) the file with the second network\n");
+ Abc_Print( -2, "\t if no files are given, uses the current network and its spec\n");
+ Abc_Print( -2, "\t if one file is given, uses the current network and the file\n");
return 1;
}
@@ -17134,7 +16963,6 @@ usage:
***********************************************************************/
int Abc_CommandMatch( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtk1, * pNtk2, * pNtkRes;
int fDelete1, fDelete2;
char ** pArgvNew;
@@ -17146,9 +16974,6 @@ int Abc_CommandMatch( Abc_Frame_t * pAbc, int argc, char ** argv )
extern Abc_Ntk_t * Abc_NtkDarMatch( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nDist, int fVerbose );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fMiter = 0;
nDist = 0;
@@ -17161,7 +16986,7 @@ int Abc_CommandMatch( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'D':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-D\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
goto usage;
}
nDist = atoi(argv[globalUtilOptind]);
@@ -17185,7 +17010,7 @@ int Abc_CommandMatch( Abc_Frame_t * pAbc, int argc, char ** argv )
// Abc_Ntk_t * pNtkA, * pNtkB;
if ( !Abc_NtkIsStrash(pNtk) )
{
- printf( "This command works only for structrally hashed networks. Run \"st\".\n" );
+ Abc_Print( -1, "This command works only for structrally hashed networks. Run \"st\".\n" );
return 0;
}
pNtkRes = Abc_NtkDarMatch( pNtk, NULL, nDist, fVerbose );
@@ -17201,13 +17026,13 @@ int Abc_CommandMatch( Abc_Frame_t * pAbc, int argc, char ** argv )
{
pArgvNew = argv + globalUtilOptind;
nArgcNew = argc - globalUtilOptind;
- if ( !Abc_NtkPrepareTwoNtks( pErr, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
+ if ( !Abc_NtkPrepareTwoNtks( stdout, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
return 1;
if ( Abc_NtkLatchNum(pNtk1) == 0 || Abc_NtkLatchNum(pNtk2) == 0 )
{
if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
- printf( "The network has no latches. Used combinational command \"cec\".\n" );
+ Abc_Print( -1, "The network has no latches. Used combinational command \"cec\".\n" );
return 0;
}
// perform verification
@@ -17217,7 +17042,7 @@ int Abc_CommandMatch( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtkRes == NULL )
{
- printf( "Matching has failed.\n" );
+ Abc_Print( -1, "Matching has failed.\n" );
return 1;
}
// replace the current network
@@ -17225,16 +17050,16 @@ int Abc_CommandMatch( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: match [-D num] [-mv] <file1> <file2>\n" );
- fprintf( pErr, "\t detects structural similarity using simulation\n" );
- fprintf( pErr, "\t replaces the current network by the miter of differences\n" );
- fprintf( pErr, "\t-D num : the distance for extending differences [default = %d]\n", nDist );
- fprintf( pErr, "\t-m : toggles miter vs. two networks [default = %s]\n", fMiter? "miter": "two networks" );
- fprintf( pErr, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\tfile1 : (optional) the file with the first network\n");
- fprintf( pErr, "\tfile2 : (optional) the file with the second network\n");
- fprintf( pErr, "\t if no files are given, uses the current network and its spec\n");
- fprintf( pErr, "\t if one file is given, uses the current network and the file\n");
+ Abc_Print( -2, "usage: match [-D num] [-mv] <file1> <file2>\n" );
+ Abc_Print( -2, "\t detects structural similarity using simulation\n" );
+ Abc_Print( -2, "\t replaces the current network by the miter of differences\n" );
+ Abc_Print( -2, "\t-D num : the distance for extending differences [default = %d]\n", nDist );
+ Abc_Print( -2, "\t-m : toggles miter vs. two networks [default = %s]\n", fMiter? "miter": "two networks" );
+ Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\tfile1 : (optional) the file with the first network\n");
+ Abc_Print( -2, "\tfile2 : (optional) the file with the second network\n");
+ Abc_Print( -2, "\t if no files are given, uses the current network and its spec\n");
+ Abc_Print( -2, "\t if one file is given, uses the current network and the file\n");
return 1;
}
@@ -17251,19 +17076,13 @@ usage:
***********************************************************************/
int Abc_CommandSat( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
int RetValue;
int fVerbose;
int nConfLimit;
int nInsLimit;
int clk;
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fVerbose = 0;
nConfLimit = 100000;
@@ -17276,7 +17095,7 @@ int Abc_CommandSat( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
nConfLimit = atoi(argv[globalUtilOptind]);
@@ -17287,7 +17106,7 @@ int Abc_CommandSat( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'I':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-I\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
goto usage;
}
nInsLimit = atoi(argv[globalUtilOptind]);
@@ -17307,12 +17126,12 @@ int Abc_CommandSat( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( Abc_NtkLatchNum(pNtk) > 0 )
{
- fprintf( stdout, "Currently can only solve the miter for combinational circuits.\n" );
+ Abc_Print( -1, "Currently can only solve the miter for combinational circuits.\n" );
return 0;
}
@@ -17335,39 +17154,39 @@ int Abc_CommandSat( Abc_Frame_t * pAbc, int argc, char ** argv )
//Abc_Obj_t * pObj;
int * pSimInfo = Abc_NtkVerifySimulatePattern( pNtk, pNtk->pModel );
if ( pSimInfo[0] != 1 )
- printf( "ERROR in Abc_NtkMiterSat(): Generated counter example is invalid.\n" );
+ Abc_Print( 1, "ERROR in Abc_NtkMiterSat(): Generated counter example is invalid.\n" );
ABC_FREE( pSimInfo );
/*
// print model
Abc_NtkForEachPi( pNtk, pObj, i )
{
- printf( "%d", (int)(pNtk->pModel[i] > 0) );
+ Abc_Print( -1, "%d", (int)(pNtk->pModel[i] > 0) );
if ( i == 70 )
break;
}
- printf( "\n" );
+ Abc_Print( -1, "\n" );
*/
}
-
+ pAbc->Status = RetValue;
if ( RetValue == -1 )
- printf( "UNDECIDED " );
+ Abc_Print( 1, "UNDECIDED " );
else if ( RetValue == 0 )
- printf( "SATISFIABLE " );
+ Abc_Print( 1, "SATISFIABLE " );
else
- printf( "UNSATISFIABLE " );
- //printf( "\n" );
- ABC_PRT( "Time", clock() - clk );
+ Abc_Print( 1, "UNSATISFIABLE " );
+ //Abc_Print( -1, "\n" );
+ Abc_PrintTime( 1, "Time", clock() - clk );
return 0;
usage:
- fprintf( pErr, "usage: sat [-C num] [-I num] [-vh]\n" );
- fprintf( pErr, "\t solves the combinational miter using SAT solver MiniSat-1.14\n" );
- fprintf( pErr, "\t derives CNF from the current network and leave it unchanged\n" );
- fprintf( pErr, "\t (there is also a newer SAT solving command \"dsat\")\n" );
- fprintf( pErr, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfLimit );
- fprintf( pErr, "\t-I num : limit on the number of inspections [default = %d]\n", nInsLimit );
- fprintf( pErr, "\t-v : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: sat [-C num] [-I num] [-vh]\n" );
+ Abc_Print( -2, "\t solves the combinational miter using SAT solver MiniSat-1.14\n" );
+ Abc_Print( -2, "\t derives CNF from the current network and leave it unchanged\n" );
+ Abc_Print( -2, "\t (there is also a newer SAT solving command \"dsat\")\n" );
+ Abc_Print( -2, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfLimit );
+ Abc_Print( -2, "\t-I num : limit on the number of inspections [default = %d]\n", nInsLimit );
+ Abc_Print( -2, "\t-v : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -17384,8 +17203,7 @@ usage:
***********************************************************************/
int Abc_CommandDSat( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
int RetValue;
int fAlignPol;
@@ -17396,12 +17214,6 @@ int Abc_CommandDSat( Abc_Frame_t * pAbc, int argc, char ** argv )
int clk;
extern int Abc_NtkDSat( Abc_Ntk_t * pNtk, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, int fAlignPol, int fAndOuts, int fVerbose );
-
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
fAlignPol = 0;
fAndOuts = 0;
@@ -17416,7 +17228,7 @@ int Abc_CommandDSat( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
nConfLimit = atoi(argv[globalUtilOptind]);
@@ -17427,7 +17239,7 @@ int Abc_CommandDSat( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'I':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-I\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
goto usage;
}
nInsLimit = atoi(argv[globalUtilOptind]);
@@ -17453,24 +17265,24 @@ int Abc_CommandDSat( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( Abc_NtkLatchNum(pNtk) > 0 )
{
- fprintf( stdout, "Currently can only solve the miter for combinational circuits.\n" );
+ Abc_Print( -1, "Currently can only solve the miter for combinational circuits.\n" );
return 0;
}
/*
if ( Abc_NtkPoNum(pNtk) != 1 )
{
- fprintf( stdout, "Currently expects a single-output miter.\n" );
+ Abc_Print( -1, "Currently expects a single-output miter.\n" );
return 0;
}
*/
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( stdout, "Currently only works for structurally hashed circuits.\n" );
+ Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
return 0;
}
@@ -17479,44 +17291,33 @@ int Abc_CommandDSat( Abc_Frame_t * pAbc, int argc, char ** argv )
// verify that the pattern is correct
if ( RetValue == 0 && Abc_NtkPoNum(pNtk) == 1 )
{
- //int i;
- //Abc_Obj_t * pObj;
int * pSimInfo = Abc_NtkVerifySimulatePattern( pNtk, pNtk->pModel );
if ( pSimInfo[0] != 1 )
- printf( "ERROR in Abc_NtkMiterSat(): Generated counter example is invalid.\n" );
+ Abc_Print( 1, "ERROR in Abc_NtkMiterSat(): Generated counter example is invalid.\n" );
ABC_FREE( pSimInfo );
- /*
- // print model
- Abc_NtkForEachPi( pNtk, pObj, i )
- {
- printf( "%d", (int)(pNtk->pModel[i] > 0) );
- if ( i == 70 )
- break;
- }
- printf( "\n" );
- */
+ pAbc->pCex = Gia_ManCreateFromComb( 0, Abc_NtkPiNum(pNtk), 0, pNtk->pModel );
}
-
+ pAbc->Status = RetValue;
if ( RetValue == -1 )
- printf( "UNDECIDED " );
+ Abc_Print( 1, "UNDECIDED " );
else if ( RetValue == 0 )
- printf( "SATISFIABLE " );
+ Abc_Print( 1, "SATISFIABLE " );
else
- printf( "UNSATISFIABLE " );
- //printf( "\n" );
- ABC_PRT( "Time", clock() - clk );
+ Abc_Print( 1, "UNSATISFIABLE " );
+ //Abc_Print( -1, "\n" );
+ Abc_PrintTime( 1, "Time", clock() - clk );
return 0;
usage:
- fprintf( pErr, "usage: dsat [-C num] [-I num] [-pavh]\n" );
- fprintf( pErr, "\t solves the combinational miter using SAT solver MiniSat-1.14\n" );
- fprintf( pErr, "\t derives CNF from the current network and leave it unchanged\n" );
- fprintf( pErr, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfLimit );
- fprintf( pErr, "\t-I num : limit on the number of inspections [default = %d]\n", nInsLimit );
- fprintf( pErr, "\t-p : alighn polarity of SAT variables [default = %s]\n", fAlignPol? "yes": "no" );
- fprintf( pErr, "\t-a : toggle ANDing/ORing of miter outputs [default = %s]\n", fAndOuts? "ANDing": "ORing" );
- fprintf( pErr, "\t-v : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: dsat [-C num] [-I num] [-pavh]\n" );
+ Abc_Print( -2, "\t solves the combinational miter using SAT solver MiniSat-1.14\n" );
+ Abc_Print( -2, "\t derives CNF from the current network and leave it unchanged\n" );
+ Abc_Print( -2, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfLimit );
+ Abc_Print( -2, "\t-I num : limit on the number of inspections [default = %d]\n", nInsLimit );
+ Abc_Print( -2, "\t-p : alighn polarity of SAT variables [default = %s]\n", fAlignPol? "yes": "no" );
+ Abc_Print( -2, "\t-a : toggle ANDing/ORing of miter outputs [default = %s]\n", fAndOuts? "ANDing": "ORing" );
+ Abc_Print( -2, "\t-v : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -17533,8 +17334,7 @@ usage:
***********************************************************************/
int Abc_CommandPSat( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int RetValue;
int c, clk;
int nAlgo;
@@ -17546,11 +17346,6 @@ int Abc_CommandPSat( Abc_Frame_t * pAbc, int argc, char ** argv )
int fVerbose;
extern int Abc_NtkPartitionedSat( Abc_Ntk_t * pNtk, int nAlgo, int nPartSize, int nConfPart, int nConfTotal, int fAlignPol, int fSynthesize, int fVerbose );
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
nAlgo = 0;
nPartSize = 10000;
@@ -17567,7 +17362,7 @@ int Abc_CommandPSat( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'A':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-A\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-A\" should be followed by an integer.\n" );
goto usage;
}
nAlgo = atoi(argv[globalUtilOptind]);
@@ -17578,7 +17373,7 @@ int Abc_CommandPSat( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'P':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-P\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
goto usage;
}
nPartSize = atoi(argv[globalUtilOptind]);
@@ -17589,7 +17384,7 @@ int Abc_CommandPSat( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
nConfTotal = atoi(argv[globalUtilOptind]);
@@ -17615,17 +17410,17 @@ int Abc_CommandPSat( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( Abc_NtkLatchNum(pNtk) > 0 )
{
- fprintf( stdout, "Currently can only solve the miter for combinational circuits.\n" );
+ Abc_Print( -1, "Currently can only solve the miter for combinational circuits.\n" );
return 0;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( stdout, "Currently only works for structurally hashed circuits.\n" );
+ Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
return 0;
}
@@ -17638,49 +17433,49 @@ int Abc_CommandPSat( Abc_Frame_t * pAbc, int argc, char ** argv )
//Abc_Obj_t * pObj;
int * pSimInfo = Abc_NtkVerifySimulatePattern( pNtk, pNtk->pModel );
if ( pSimInfo[0] != 1 )
- printf( "ERROR in Abc_NtkMiterSat(): Generated counter example is invalid.\n" );
+ Abc_Print( 1, "ERROR in Abc_NtkMiterSat(): Generated counter example is invalid.\n" );
ABC_FREE( pSimInfo );
/*
// print model
Abc_NtkForEachPi( pNtk, pObj, i )
{
- printf( "%d", (int)(pNtk->pModel[i] > 0) );
+ Abc_Print( -1, "%d", (int)(pNtk->pModel[i] > 0) );
if ( i == 70 )
break;
}
- printf( "\n" );
+ Abc_Print( -1, "\n" );
*/
}
if ( RetValue == -1 )
- printf( "UNDECIDED " );
+ Abc_Print( 1, "UNDECIDED " );
else if ( RetValue == 0 )
- printf( "SATISFIABLE " );
+ Abc_Print( 1, "SATISFIABLE " );
else
- printf( "UNSATISFIABLE " );
- //printf( "\n" );
- ABC_PRT( "Time", clock() - clk );
+ Abc_Print( 1, "UNSATISFIABLE " );
+ //Abc_Print( -1, "\n" );
+ Abc_PrintTime( 1, "Time", clock() - clk );
return 0;
usage:
- fprintf( pErr, "usage: psat [-APC num] [-psvh]\n" );
- fprintf( pErr, "\t solves the combinational miter using partitioning\n" );
- fprintf( pErr, "\t (derives CNF from the current network and leave it unchanged)\n" );
- fprintf( pErr, "\t for multi-output miters, tries to prove that the AND of POs is always 0\n" );
- fprintf( pErr, "\t (if POs should be ORed instead of ANDed, use command \"orpos\")\n" );
- fprintf( pErr, "\t-A num : partitioning algorithm [default = %d]\n", nAlgo );
- fprintf( pErr, "\t 0 : no partitioning\n" );
- fprintf( pErr, "\t 1 : partitioning by level\n" );
- fprintf( pErr, "\t 2 : DFS post-order\n" );
- fprintf( pErr, "\t 3 : DFS pre-order\n" );
- fprintf( pErr, "\t 4 : bit-slicing\n" );
- fprintf( pErr, "\t partitions are ordered by level (high level first)\n" );
- fprintf( pErr, "\t-P num : limit on the partition size [default = %d]\n", nPartSize );
- fprintf( pErr, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfTotal );
- fprintf( pErr, "\t-p : align polarity of SAT variables [default = %s]\n", fAlignPol? "yes": "no" );
- fprintf( pErr, "\t-s : apply logic synthesis to each partition [default = %s]\n", fSynthesize? "yes": "no" );
- fprintf( pErr, "\t-v : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: psat [-APC num] [-psvh]\n" );
+ Abc_Print( -2, "\t solves the combinational miter using partitioning\n" );
+ Abc_Print( -2, "\t (derives CNF from the current network and leave it unchanged)\n" );
+ Abc_Print( -2, "\t for multi-output miters, tries to prove that the AND of POs is always 0\n" );
+ Abc_Print( -2, "\t (if POs should be ORed instead of ANDed, use command \"orpos\")\n" );
+ Abc_Print( -2, "\t-A num : partitioning algorithm [default = %d]\n", nAlgo );
+ Abc_Print( -2, "\t 0 : no partitioning\n" );
+ Abc_Print( -2, "\t 1 : partitioning by level\n" );
+ Abc_Print( -2, "\t 2 : DFS post-order\n" );
+ Abc_Print( -2, "\t 3 : DFS pre-order\n" );
+ Abc_Print( -2, "\t 4 : bit-slicing\n" );
+ Abc_Print( -2, "\t partitions are ordered by level (high level first)\n" );
+ Abc_Print( -2, "\t-P num : limit on the partition size [default = %d]\n", nPartSize );
+ Abc_Print( -2, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfTotal );
+ Abc_Print( -2, "\t-p : align polarity of SAT variables [default = %s]\n", fAlignPol? "yes": "no" );
+ Abc_Print( -2, "\t-s : apply logic synthesis to each partition [default = %s]\n", fSynthesize? "yes": "no" );
+ Abc_Print( -2, "\t-v : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -17697,15 +17492,11 @@ usage:
***********************************************************************/
int Abc_CommandProve( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkTemp;
Prove_Params_t Params, * pParams = &Params;
int c, clk, RetValue;
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Prove_ParamsSetDefault( pParams );
Extra_UtilGetoptReset();
@@ -17716,7 +17507,7 @@ int Abc_CommandProve( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'N':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
goto usage;
}
pParams->nItersMax = atoi(argv[globalUtilOptind]);
@@ -17727,7 +17518,7 @@ int Abc_CommandProve( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
pParams->nMiteringLimitStart = atoi(argv[globalUtilOptind]);
@@ -17738,7 +17529,7 @@ int Abc_CommandProve( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
pParams->nFraigingLimitStart = atoi(argv[globalUtilOptind]);
@@ -17749,7 +17540,7 @@ int Abc_CommandProve( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'L':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-L\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
goto usage;
}
pParams->nMiteringLimitLast = atoi(argv[globalUtilOptind]);
@@ -17760,7 +17551,7 @@ int Abc_CommandProve( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'I':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-I\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
goto usage;
}
pParams->nTotalInspectLimit = atoi(argv[globalUtilOptind]);
@@ -17789,17 +17580,17 @@ int Abc_CommandProve( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( Abc_NtkLatchNum(pNtk) > 0 )
{
- fprintf( stdout, "Currently can only solve the miter for combinational circuits.\n" );
+ Abc_Print( -1, "Currently can only solve the miter for combinational circuits.\n" );
return 0;
}
if ( Abc_NtkCoNum(pNtk) != 1 )
{
- fprintf( stdout, "Currently can only solve the miter with one output.\n" );
+ Abc_Print( -1, "Currently can only solve the miter with one output.\n" );
return 0;
}
clk = clock();
@@ -17816,38 +17607,38 @@ int Abc_CommandProve( Abc_Frame_t * pAbc, int argc, char ** argv )
{
int * pSimInfo = Abc_NtkVerifySimulatePattern( pNtk, pNtkTemp->pModel );
if ( pSimInfo[0] != 1 )
- printf( "ERROR in Abc_NtkMiterProve(): Generated counter-example is invalid.\n" );
+ Abc_Print( 1, "ERROR in Abc_NtkMiterProve(): Generated counter-example is invalid.\n" );
ABC_FREE( pSimInfo );
}
-
+ pAbc->Status = RetValue;
if ( RetValue == -1 )
- printf( "UNDECIDED " );
+ Abc_Print( 1, "UNDECIDED " );
else if ( RetValue == 0 )
- printf( "SATISFIABLE " );
+ Abc_Print( 1, "SATISFIABLE " );
else
- printf( "UNSATISFIABLE " );
- //printf( "\n" );
+ Abc_Print( 1, "UNSATISFIABLE " );
+ //Abc_Print( -1, "\n" );
- ABC_PRT( "Time", clock() - clk );
+ Abc_PrintTime( 1, "Time", clock() - clk );
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtkTemp );
return 0;
usage:
- fprintf( pErr, "usage: prove [-N num] [-C num] [-F num] [-L num] [-I num] [-rfbvh]\n" );
- fprintf( pErr, "\t solves combinational miter by rewriting, FRAIGing, and SAT\n" );
- fprintf( pErr, "\t replaces the current network by the cone modified by rewriting\n" );
- fprintf( pErr, "\t (there are also newer CEC commands, \"iprove\" and \"dprove\")\n" );
- fprintf( pErr, "\t-N num : max number of iterations [default = %d]\n", pParams->nItersMax );
- fprintf( pErr, "\t-C num : max starting number of conflicts in mitering [default = %d]\n", pParams->nMiteringLimitStart );
- fprintf( pErr, "\t-F num : max starting number of conflicts in fraiging [default = %d]\n", pParams->nFraigingLimitStart );
- fprintf( pErr, "\t-L num : max last-gasp number of conflicts in mitering [default = %d]\n", pParams->nMiteringLimitLast );
- fprintf( pErr, "\t-I num : max number of clause inspections in all SAT calls [default = %d]\n", (int)pParams->nTotalInspectLimit );
- fprintf( pErr, "\t-r : toggle the use of rewriting [default = %s]\n", pParams->fUseRewriting? "yes": "no" );
- fprintf( pErr, "\t-f : toggle the use of FRAIGing [default = %s]\n", pParams->fUseFraiging? "yes": "no" );
- fprintf( pErr, "\t-b : toggle the use of BDDs [default = %s]\n", pParams->fUseBdds? "yes": "no" );
- fprintf( pErr, "\t-v : prints verbose information [default = %s]\n", pParams->fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: prove [-N num] [-C num] [-F num] [-L num] [-I num] [-rfbvh]\n" );
+ Abc_Print( -2, "\t solves combinational miter by rewriting, FRAIGing, and SAT\n" );
+ Abc_Print( -2, "\t replaces the current network by the cone modified by rewriting\n" );
+ Abc_Print( -2, "\t (there are also newer CEC commands, \"iprove\" and \"dprove\")\n" );
+ Abc_Print( -2, "\t-N num : max number of iterations [default = %d]\n", pParams->nItersMax );
+ Abc_Print( -2, "\t-C num : max starting number of conflicts in mitering [default = %d]\n", pParams->nMiteringLimitStart );
+ Abc_Print( -2, "\t-F num : max starting number of conflicts in fraiging [default = %d]\n", pParams->nFraigingLimitStart );
+ Abc_Print( -2, "\t-L num : max last-gasp number of conflicts in mitering [default = %d]\n", pParams->nMiteringLimitLast );
+ Abc_Print( -2, "\t-I num : max number of clause inspections in all SAT calls [default = %d]\n", (int)pParams->nTotalInspectLimit );
+ Abc_Print( -2, "\t-r : toggle the use of rewriting [default = %s]\n", pParams->fUseRewriting? "yes": "no" );
+ Abc_Print( -2, "\t-f : toggle the use of FRAIGing [default = %s]\n", pParams->fUseFraiging? "yes": "no" );
+ Abc_Print( -2, "\t-b : toggle the use of BDDs [default = %s]\n", pParams->fUseBdds? "yes": "no" );
+ Abc_Print( -2, "\t-v : prints verbose information [default = %s]\n", pParams->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -17864,16 +17655,10 @@ usage:
***********************************************************************/
int Abc_CommandDebug( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
extern void Abc_NtkAutoDebug( Abc_Ntk_t * pNtk, int (*pFuncError) (Abc_Ntk_t *) );
extern int Abc_NtkRetimeDebug( Abc_Ntk_t * pNtk );
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
@@ -17889,12 +17674,12 @@ int Abc_CommandDebug( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsLogic(pNtk) )
{
- fprintf( pErr, "This command is applicable to logic networks.\n" );
+ Abc_Print( -1, "This command is applicable to logic networks.\n" );
return 1;
}
@@ -17902,9 +17687,9 @@ int Abc_CommandDebug( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( pErr, "usage: debug [-h]\n" );
- fprintf( pErr, "\t performs automated debugging of the given procedure\n" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: debug [-h]\n" );
+ Abc_Print( -2, "\t performs automated debugging of the given procedure\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -17921,8 +17706,7 @@ usage:
***********************************************************************/
int Abc_CommandBmc( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
int nFrames;
int nSizeMax;
@@ -17933,13 +17717,10 @@ int Abc_CommandBmc( Abc_Frame_t * pAbc, int argc, char ** argv )
int fNewAlgo;
int nCofFanLit;
int fVerbose;
+ int iFrames;
+ char * pLogFileName = NULL;
- extern int Abc_NtkDarBmc( Abc_Ntk_t * pNtk, int nStart, int nFrames, int nSizeMax, int nNodeDelta, int nTimeOut, int nBTLimit, int nBTLimitAll, int fRewrite, int fNewAlgo, int nCofFanLit, int fVerbose );
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
+ extern int Abc_NtkDarBmc( Abc_Ntk_t * pNtk, int nStart, int nFrames, int nSizeMax, int nNodeDelta, int nTimeOut, int nBTLimit, int nBTLimitAll, int fRewrite, int fNewAlgo, int nCofFanLit, int fVerbose, int * piFrames );
// set defaults
nFrames = 20;
nSizeMax = 100000;
@@ -17958,7 +17739,7 @@ int Abc_CommandBmc( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
nFrames = atoi(argv[globalUtilOptind]);
@@ -17969,7 +17750,7 @@ int Abc_CommandBmc( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'N':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
goto usage;
}
nSizeMax = atoi(argv[globalUtilOptind]);
@@ -17980,7 +17761,7 @@ int Abc_CommandBmc( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
nBTLimit = atoi(argv[globalUtilOptind]);
@@ -17991,7 +17772,7 @@ int Abc_CommandBmc( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'G':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-G\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-G\" should be followed by an integer.\n" );
goto usage;
}
nBTLimitAll = atoi(argv[globalUtilOptind]);
@@ -18002,7 +17783,7 @@ int Abc_CommandBmc( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'D':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-D\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
goto usage;
}
nNodeDelta = atoi(argv[globalUtilOptind]);
@@ -18010,10 +17791,11 @@ int Abc_CommandBmc( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( nNodeDelta < 0 )
goto usage;
break;
+/*
case 'L':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-L\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
goto usage;
}
nCofFanLit = atoi(argv[globalUtilOptind]);
@@ -18021,6 +17803,16 @@ int Abc_CommandBmc( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( nCofFanLit < 0 )
goto usage;
break;
+*/
+ case 'L':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-L\" should be followed by a file name.\n" );
+ goto usage;
+ }
+ pLogFileName = argv[globalUtilOptind];
+ globalUtilOptind++;
+ break;
case 'r':
fRewrite ^= 1;
break;
@@ -18038,37 +17830,38 @@ int Abc_CommandBmc( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( stdout, "Currently only works for structurally hashed circuits.\n" );
+ Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
return 0;
}
if ( Abc_NtkLatchNum(pNtk) == 0 )
{
- fprintf( stdout, "Does not work for combinational networks.\n" );
+ Abc_Print( -1, "Does not work for combinational networks.\n" );
return 0;
}
- Abc_NtkDarBmc( pNtk, 0, nFrames, nSizeMax, nNodeDelta, 0, nBTLimit, nBTLimitAll, fRewrite, fNewAlgo, nCofFanLit, fVerbose );
- pAbc->pCex = pNtk->pSeqModel; // temporary ???
+ pAbc->Status = Abc_NtkDarBmc( pNtk, 0, nFrames, nSizeMax, nNodeDelta, 0, nBTLimit, nBTLimitAll, fRewrite, fNewAlgo, nCofFanLit, fVerbose, &iFrames );
+ pAbc->nFrames = iFrames;
+ Abc_FrameReplaceCex( pAbc, &pNtk->pSeqModel );
+ if ( pLogFileName )
+ Abc_NtkWriteLogFile( pLogFileName, pAbc->pCex, pAbc->Status, "bmc" );
return 0;
usage:
-// fprintf( pErr, "usage: bmc [-FNCGD num] [-ravh]\n" );
- fprintf( pErr, "usage: bmc [-FNCL num] [-rcvh]\n" );
- fprintf( pErr, "\t performs bounded model checking with static unrolling\n" );
- fprintf( pErr, "\t-F num : the number of time frames [default = %d]\n", nFrames );
- fprintf( pErr, "\t-N num : the max number of nodes in the frames [default = %d]\n", nSizeMax );
- fprintf( pErr, "\t-C num : the max number of conflicts at a node [default = %d]\n", nBTLimit );
-// fprintf( pErr, "\t-G num : the max number of conflicts globally [default = %d]\n", nBTLimitAll );
-// fprintf( pErr, "\t-D num : the delta in the number of nodes [default = %d]\n", nNodeDelta );
- fprintf( pErr, "\t-L num : the limit on fanout count of resets/enables to cofactor [default = %d]\n", nCofFanLit );
- fprintf( pErr, "\t-r : toggle the use of rewriting [default = %s]\n", fRewrite? "yes": "no" );
-// fprintf( pErr, "\t-a : toggle SAT sweeping and SAT solving [default = %s]\n", fNewAlgo? "SAT solving": "SAT sweeping" );
- fprintf( pErr, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: bmc [-FNC num] [-L file] [-rcvh]\n" );
+ Abc_Print( -2, "\t performs bounded model checking with static unrolling\n" );
+ Abc_Print( -2, "\t-F num : the number of time frames [default = %d]\n", nFrames );
+ Abc_Print( -2, "\t-N num : the max number of nodes in the frames [default = %d]\n", nSizeMax );
+ Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", nBTLimit );
+// Abc_Print( -2, "\t-L num : the limit on fanout count of resets/enables to cofactor [default = %d]\n", nCofFanLit );
+ Abc_Print( -2, "\t-L file: the log file name [default = %s]\n", pLogFileName ? pLogFileName : "no logging" );
+ Abc_Print( -2, "\t-r : toggle the use of rewriting [default = %s]\n", fRewrite? "yes": "no" );
+// Abc_Print( -2, "\t-a : toggle SAT sweeping and SAT solving [default = %s]\n", fNewAlgo? "SAT solving": "SAT sweeping" );
+ Abc_Print( -2, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -18085,8 +17878,7 @@ usage:
***********************************************************************/
int Abc_CommandBmc2( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
int nStart;
int nFrames;
@@ -18098,12 +17890,10 @@ int Abc_CommandBmc2( Abc_Frame_t * pAbc, int argc, char ** argv )
int fRewrite;
int fNewAlgo;
int fVerbose;
+ int iFrames;
+ char * pLogFileName = NULL;
- extern int Abc_NtkDarBmc( Abc_Ntk_t * pNtk, int nStart, int nFrames, int nSizeMax, int nNodeDelta, int nTimeOut, int nBTLimit, int nBTLimitAll, int fRewrite, int fNewAlgo, int nCofFanLit, int fVerbose );
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
+ extern int Abc_NtkDarBmc( Abc_Ntk_t * pNtk, int nStart, int nFrames, int nSizeMax, int nNodeDelta, int nTimeOut, int nBTLimit, int nBTLimitAll, int fRewrite, int fNewAlgo, int nCofFanLit, int fVerbose, int * piFrames );
// set defaults
nStart = 0;
@@ -18117,14 +17907,14 @@ int Abc_CommandBmc2( Abc_Frame_t * pAbc, int argc, char ** argv )
fNewAlgo = 0;
fVerbose = 0;
Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "SFNTCGDrvh" ) ) != EOF )
+ while ( ( c = Extra_UtilGetopt( argc, argv, "SFNTCGDLrvh" ) ) != EOF )
{
switch ( c )
{
case 'S':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-S\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
goto usage;
}
nStart = atoi(argv[globalUtilOptind]);
@@ -18135,7 +17925,7 @@ int Abc_CommandBmc2( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
nFrames = atoi(argv[globalUtilOptind]);
@@ -18146,7 +17936,7 @@ int Abc_CommandBmc2( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'N':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
goto usage;
}
nSizeMax = atoi(argv[globalUtilOptind]);
@@ -18157,7 +17947,7 @@ int Abc_CommandBmc2( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'T':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-T\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
goto usage;
}
nTimeOut = atoi(argv[globalUtilOptind]);
@@ -18168,7 +17958,7 @@ int Abc_CommandBmc2( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
nBTLimit = atoi(argv[globalUtilOptind]);
@@ -18179,7 +17969,7 @@ int Abc_CommandBmc2( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'G':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-G\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-G\" should be followed by an integer.\n" );
goto usage;
}
nBTLimitAll = atoi(argv[globalUtilOptind]);
@@ -18190,7 +17980,7 @@ int Abc_CommandBmc2( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'D':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-D\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
goto usage;
}
nNodeDelta = atoi(argv[globalUtilOptind]);
@@ -18198,6 +17988,15 @@ int Abc_CommandBmc2( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( nNodeDelta < 0 )
goto usage;
break;
+ case 'L':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-L\" should be followed by a file name.\n" );
+ goto usage;
+ }
+ pLogFileName = argv[globalUtilOptind];
+ globalUtilOptind++;
+ break;
case 'r':
fRewrite ^= 1;
break;
@@ -18215,41 +18014,193 @@ int Abc_CommandBmc2( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( stdout, "Currently only works for structurally hashed circuits.\n" );
+ Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
return 0;
}
if ( Abc_NtkLatchNum(pNtk) == 0 )
{
- fprintf( stdout, "Does not work for combinational networks.\n" );
+ Abc_Print( -1, "Does not work for combinational networks.\n" );
return 0;
}
- Abc_NtkDarBmc( pNtk, nStart, nFrames, nSizeMax, nNodeDelta, nTimeOut, nBTLimit, nBTLimitAll, fRewrite, fNewAlgo, 0, fVerbose );
- pAbc->pCex = pNtk->pSeqModel; // temporary ???
+ pAbc->Status = Abc_NtkDarBmc( pNtk, nStart, nFrames, nSizeMax, nNodeDelta, nTimeOut, nBTLimit, nBTLimitAll, fRewrite, fNewAlgo, 0, fVerbose, &iFrames );
+ pAbc->nFrames = iFrames;
+ Abc_FrameReplaceCex( pAbc, &pNtk->pSeqModel );
+ if ( pLogFileName )
+ Abc_NtkWriteLogFile( pLogFileName, pAbc->pCex, pAbc->Status, "bmc2" );
return 0;
usage:
-// fprintf( pErr, "usage: bmc2 [-FNCGD num] [-ravh]\n" );
- fprintf( pErr, "usage: bmc2 [-SFTCGD num] [-vh]\n" );
- fprintf( pErr, "\t performs bounded model checking with dynamic unrolling\n" );
- fprintf( pErr, "\t-S num : the starting time frame [default = %d]\n", nStart );
- fprintf( pErr, "\t-F num : the max number of time frames [default = %d]\n", nFrames );
-// fprintf( pErr, "\t-N num : the max number of nodes in the frames [default = %d]\n", nSizeMax );
- fprintf( pErr, "\t-T num : approximate runtime limit in seconds [default = %d]\n", nTimeOut );
- fprintf( pErr, "\t-C num : the max number of conflicts at a node [default = %d]\n", nBTLimit );
- fprintf( pErr, "\t-G num : the max number of conflicts globally [default = %d]\n", nBTLimitAll );
- fprintf( pErr, "\t-D num : the delta in the number of nodes [default = %d]\n", nNodeDelta );
-// fprintf( pErr, "\t-r : toggle the use of rewriting [default = %s]\n", fRewrite? "yes": "no" );
-// fprintf( pErr, "\t-a : toggle SAT sweeping and SAT solving [default = %s]\n", fNewAlgo? "SAT solving": "SAT sweeping" );
- fprintf( pErr, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+// Abc_Print( -2, "usage: bmc2 [-FNCGD num] [-ravh]\n" );
+ Abc_Print( -2, "usage: bmc2 [-SFTCGD num] [-L file] [-vh]\n" );
+ Abc_Print( -2, "\t performs bounded model checking with dynamic unrolling\n" );
+ Abc_Print( -2, "\t-S num : the starting time frame [default = %d]\n", nStart );
+ Abc_Print( -2, "\t-F num : the max number of time frames [default = %d]\n", nFrames );
+// Abc_Print( -2, "\t-N num : the max number of nodes in the frames [default = %d]\n", nSizeMax );
+ Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n", nTimeOut );
+ Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", nBTLimit );
+ Abc_Print( -2, "\t-G num : the max number of conflicts globally [default = %d]\n", nBTLimitAll );
+ Abc_Print( -2, "\t-D num : the delta in the number of nodes [default = %d]\n", nNodeDelta );
+ Abc_Print( -2, "\t-L file: the log file name [default = %s]\n", pLogFileName ? pLogFileName : "no logging" );
+// Abc_Print( -2, "\t-r : toggle the use of rewriting [default = %s]\n", fRewrite? "yes": "no" );
+// Abc_Print( -2, "\t-a : toggle SAT sweeping and SAT solving [default = %s]\n", fNewAlgo? "SAT solving": "SAT sweeping" );
+ Abc_Print( -2, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_CommandBmc3( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ extern Abc_Ntk_t * Abc_NtkDarLatchSweep( Abc_Ntk_t * pNtk, int fLatchConst, int fLatchEqual, int fSaveNames, int fVerbose );
+ extern int Abc_NtkDarBmc3( Abc_Ntk_t * pNtk, Saig_ParBmc_t * pPars );
+ Saig_ParBmc_t Pars, * pPars = &Pars;
+ Abc_Ntk_t * pNtkRes, * pNtk = Abc_FrameReadNtk(pAbc);
+ char * pLogFileName = NULL;
+ int c;
+ Saig_ParBmcSetDefaultParams( pPars );
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "SFTCLsdrvh" ) ) != EOF )
+ {
+ switch ( c )
+ {
+ case 'S':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ pPars->nStart = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->nStart < 0 )
+ goto usage;
+ break;
+ case 'F':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ pPars->nFramesMax = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->nFramesMax < 0 )
+ goto usage;
+ break;
+ case 'T':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ pPars->nTimeOut = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->nTimeOut < 0 )
+ goto usage;
+ break;
+ case 'C':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ pPars->nConfLimit = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->nConfLimit < 0 )
+ goto usage;
+ break;
+ case 'L':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-L\" should be followed by a file name.\n" );
+ goto usage;
+ }
+ pLogFileName = argv[globalUtilOptind];
+ globalUtilOptind++;
+ break;
+ case 's':
+ pPars->fSolveAll ^= 1;
+ break;
+ case 'd':
+ pPars->fDropSatOuts ^= 1;
+ break;
+ case 'v':
+ pPars->fVerbose ^= 1;
+ break;
+ case 'h':
+ goto usage;
+ default:
+ goto usage;
+ }
+ }
+ if ( pNtk == NULL )
+ {
+ Abc_Print( -1, "Empty network.\n" );
+ return 1;
+ }
+ if ( !Abc_NtkIsStrash(pNtk) )
+ {
+ Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
+ return 0;
+ }
+ if ( Abc_NtkLatchNum(pNtk) == 0 )
+ {
+ Abc_Print( -1, "Does not work for combinational networks.\n" );
+ return 0;
+ }
+ pAbc->Status = Abc_NtkDarBmc3( pNtk, pPars );
+ pAbc->nFrames = pPars->iFrame;
+ Abc_FrameReplaceCex( pAbc, &pNtk->pSeqModel );
+ if ( pLogFileName )
+ Abc_NtkWriteLogFile( pLogFileName, pAbc->pCex, pAbc->Status, "bmc3" );
+ if ( pPars->fSolveAll && pPars->fDropSatOuts )
+ {
+ if ( pNtk->pSeqModelVec == NULL )
+ printf( "The array of counter-examples is not available.\n" );
+ else if ( Vec_PtrSize(pNtk->pSeqModelVec) != Abc_NtkPoNum(pNtk) )
+ printf( "The array size does not match the number of outputs.\n" );
+ else
+ {
+ extern void Abc_NtkDropSatOutputs( Abc_Ntk_t * pNtk, Vec_Ptr_t * vCexes, int fVerbose );
+ Abc_NtkDropSatOutputs( pNtk, pNtk->pSeqModelVec, pPars->fVerbose );
+ pNtkRes = Abc_NtkDarLatchSweep( pNtk, 1, 1, 1, 0 );
+ if ( pNtkRes == NULL )
+ {
+ Abc_Print( -1, "Removing SAT outputs has failed.\n" );
+ return 1;
+ }
+ Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+ }
+ }
+ return 0;
+
+usage:
+ Abc_Print( -2, "usage: bmc3 [-SFTC num] [-L file] [-sdvh]\n" );
+ Abc_Print( -2, "\t performs bounded model checking with dynamic unrolling\n" );
+ Abc_Print( -2, "\t-S num : the starting time frame [default = %d]\n", pPars->nStart );
+ Abc_Print( -2, "\t-F num : the max number of time frames [default = %d]\n", pPars->nFramesMax );
+ Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n", pPars->nTimeOut );
+ Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nConfLimit );
+ Abc_Print( -2, "\t-L file: the log file name [default = %s]\n", pLogFileName ? pLogFileName : "no logging" );
+ Abc_Print( -2, "\t-s : solve all outputs (do not stop when one is SAT) [default = %s]\n", pPars->fSolveAll? "yes": "no" );
+ Abc_Print( -2, "\t-d : drops (replaces by 0) satisfiable outputs [default = %s]\n", pPars->fDropSatOuts? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
-
/**Function*************************************************************
@@ -18265,27 +18216,22 @@ usage:
int Abc_CommandBmcInter( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Inter_ManParams_t Pars, * pPars = &Pars;
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtkRes, * pNtk = Abc_FrameReadNtk(pAbc);
int c;
+ char * pLogFileName = NULL;
- extern int Abc_NtkDarBmcInter( Abc_Ntk_t * pNtk, Inter_ManParams_t * pPars );
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
+ extern int Abc_NtkDarBmcInter( Abc_Ntk_t * pNtk, Inter_ManParams_t * pPars, Abc_Ntk_t ** ppNtkRes );
// set defaults
Inter_ManSetDefaultParams( pPars );
Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "CNFrtpomcgbkvh" ) ) != EOF )
+ while ( ( c = Extra_UtilGetopt( argc, argv, "CFTNLrtpomcgbkdvh" ) ) != EOF )
{
switch ( c )
{
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
pPars->nBTLimit = atoi(argv[globalUtilOptind]);
@@ -18293,10 +18239,10 @@ int Abc_CommandBmcInter( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pPars->nBTLimit < 0 )
goto usage;
break;
- case 'N':
+ case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
pPars->nFramesMax = atoi(argv[globalUtilOptind]);
@@ -18304,10 +18250,21 @@ int Abc_CommandBmcInter( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pPars->nFramesMax < 0 )
goto usage;
break;
- case 'F':
+ case 'T':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ pPars->nSecLimit = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->nSecLimit < 0 )
+ goto usage;
+ break;
+ case 'N':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
goto usage;
}
pPars->nFramesK = atoi(argv[globalUtilOptind]);
@@ -18315,6 +18272,15 @@ int Abc_CommandBmcInter( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pPars->nFramesK < 0 )
goto usage;
break;
+ case 'L':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-L\" should be followed by a file name.\n" );
+ goto usage;
+ }
+ pLogFileName = argv[globalUtilOptind];
+ globalUtilOptind++;
+ break;
case 'r':
pPars->fRewrite ^= 1;
break;
@@ -18342,6 +18308,9 @@ int Abc_CommandBmcInter( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'k':
pPars->fUseSeparate ^= 1;
break;
+ case 'd':
+ pPars->fDropSatOuts ^= 1;
+ break;
case 'v':
pPars->fVerbose ^= 1;
break;
@@ -18353,64 +18322,84 @@ int Abc_CommandBmcInter( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( stdout, "Currently only works for structurally hashed circuits.\n" );
+ Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
return 0;
- }
+ }
if ( Abc_NtkLatchNum(pNtk) == 0 )
{
- fprintf( stdout, "Does not work for combinational networks.\n" );
+ Abc_Print( -1, "Does not work for combinational networks.\n" );
return 0;
}
- if ( Abc_NtkPoNum(pNtk) != 1 )
+ if ( Abc_NtkPoNum(pNtk)-Abc_NtkConstrNum(pNtk) != 1 )
{
+ if ( Abc_NtkConstrNum(pNtk) > 0 )
+ {
+ printf( "Cannot solve multiple-output miter with constraints.\n" );
+ return 0;
+ }
if ( pPars->fUseSeparate )
{
- printf( "Each of %d outputs will be solved separately.\n", Abc_NtkPoNum(pNtk) );
- Abc_NtkDarBmcInter( pNtk, pPars );
+ Abc_Print( 0, "Each of %d outputs will be solved separately.\n", Abc_NtkPoNum(pNtk) );
+ pAbc->Status = Abc_NtkDarBmcInter( pNtk, pPars, &pNtkRes );
+ Abc_FrameReplaceCex( pAbc, &pNtk->pSeqModel );
+ if ( pNtkRes == NULL )
+ {
+ Abc_Print( -1, "Generating resulting network has failed.\n" );
+ return 0;
+ }
+ Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
}
else
{
Abc_Ntk_t * pNtkNew = Abc_NtkDup( pNtk );
- printf( "All %d outputs will be ORed together.\n", Abc_NtkPoNum(pNtk) );
+ Abc_Print( 0, "All %d outputs will be ORed together.\n", Abc_NtkPoNum(pNtk) );
if ( !Abc_NtkCombinePos( pNtkNew, 0 ) )
{
Abc_NtkDelete( pNtkNew );
- printf( "ORing outputs has failed.\n" );
+ Abc_Print( -1, "ORing outputs has failed.\n" );
return 0;
}
- Abc_NtkDarBmcInter( pNtkNew, pPars );
+ pAbc->Status = Abc_NtkDarBmcInter( pNtkNew, pPars, NULL );
+ Abc_FrameReplaceCex( pAbc, &pNtkNew->pSeqModel );
Abc_NtkDelete( pNtkNew );
}
+ pAbc->nFrames = -1;
}
else
{
- Abc_NtkDarBmcInter( pNtk, pPars );
+ pAbc->Status = Abc_NtkDarBmcInter( pNtk, pPars, NULL );
+ pAbc->nFrames = pPars->iFrameMax;
+ Abc_FrameReplaceCex( pAbc, &pNtk->pSeqModel );
}
- pAbc->pCex = pNtk->pSeqModel; // temporary ???
+ if ( pLogFileName )
+ Abc_NtkWriteLogFile( pLogFileName, pAbc->pCex, pAbc->Status, "int" );
return 0;
usage:
- fprintf( pErr, "usage: int [-CNF num] [-rtpomcgbvh]\n" );
- fprintf( pErr, "\t uses interpolation to prove the property\n" );
- fprintf( pErr, "\t-C num : the limit on conflicts for one SAT run [default = %d]\n", pPars->nBTLimit );
- fprintf( pErr, "\t-N num : the limit on number of frames to unroll [default = %d]\n", pPars->nFramesMax );
- fprintf( pErr, "\t-F num : the number of steps in inductive checking [default = %d]\n", pPars->nFramesK );
- fprintf( pErr, "\t-r : toggle rewriting of the unrolled timeframes [default = %s]\n", pPars->fRewrite? "yes": "no" );
- fprintf( pErr, "\t-t : toggle adding transition into the initial state [default = %s]\n", pPars->fTransLoop? "yes": "no" );
- fprintf( pErr, "\t-p : toggle using original Pudlak's interpolation procedure [default = %s]\n", pPars->fUsePudlak? "yes": "no" );
- fprintf( pErr, "\t-o : toggle using optimized Pudlak's interpolation procedure [default = %s]\n", pPars->fUseOther? "yes": "no" );
- fprintf( pErr, "\t-m : toggle using MiniSat-1.14p (now, Windows-only) [default = %s]\n", pPars->fUseMiniSat? "yes": "no" );
- fprintf( pErr, "\t-c : toggle using inductive containment check [default = %s]\n", pPars->fCheckKstep? "yes": "no" );
- fprintf( pErr, "\t-g : toggle using bias for global variables using SAT [default = %s]\n", pPars->fUseBias? "yes": "no" );
- fprintf( pErr, "\t-b : toggle using backward interpolation [default = %s]\n", pPars->fUseBackward? "yes": "no" );
- fprintf( pErr, "\t-k : toggle solving each output separately [default = %s]\n", pPars->fUseSeparate? "yes": "no" );
- fprintf( pErr, "\t-v : toggle verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: int [-CFTN num] [-L file] [-rtpomcgbkdvh]\n" );
+ Abc_Print( -2, "\t uses interpolation to prove the property\n" );
+ Abc_Print( -2, "\t-C num : the limit on conflicts for one SAT run [default = %d]\n", pPars->nBTLimit );
+ Abc_Print( -2, "\t-F num : the limit on number of frames to unroll [default = %d]\n", pPars->nFramesMax );
+ Abc_Print( -2, "\t-T num : the limit on runtime per output in seconds [default = %d]\n", pPars->nSecLimit );
+ Abc_Print( -2, "\t-N num : the number of steps in inductive checking [default = %d]\n", pPars->nFramesK );
+ Abc_Print( -2, "\t-L file: the log file name [default = %s]\n", pLogFileName ? pLogFileName : "no logging" );
+ Abc_Print( -2, "\t-r : toggle rewriting of the unrolled timeframes [default = %s]\n", pPars->fRewrite? "yes": "no" );
+ Abc_Print( -2, "\t-t : toggle adding transition into the initial state [default = %s]\n", pPars->fTransLoop? "yes": "no" );
+ Abc_Print( -2, "\t-p : toggle using original Pudlak's interpolation procedure [default = %s]\n", pPars->fUsePudlak? "yes": "no" );
+ Abc_Print( -2, "\t-o : toggle using optimized Pudlak's interpolation procedure [default = %s]\n", pPars->fUseOther? "yes": "no" );
+ Abc_Print( -2, "\t-m : toggle using MiniSat-1.14p (now, Windows-only) [default = %s]\n", pPars->fUseMiniSat? "yes": "no" );
+ Abc_Print( -2, "\t-c : toggle using inductive containment check [default = %s]\n", pPars->fCheckKstep? "yes": "no" );
+ Abc_Print( -2, "\t-g : toggle using bias for global variables using SAT [default = %s]\n", pPars->fUseBias? "yes": "no" );
+ Abc_Print( -2, "\t-b : toggle using backward interpolation [default = %s]\n", pPars->fUseBackward? "yes": "no" );
+ Abc_Print( -2, "\t-k : toggle solving each output separately [default = %s]\n", pPars->fUseSeparate? "yes": "no" );
+ Abc_Print( -2, "\t-d : drops (replaces by 0) sat outputs (with -k is used) [default = %s]\n", pPars->fDropSatOuts? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -18427,8 +18416,7 @@ usage:
***********************************************************************/
int Abc_CommandIndcut( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int nFrames;
int nPref;
int nClauses;
@@ -18444,11 +18432,6 @@ int Abc_CommandIndcut( Abc_Frame_t * pAbc, int argc, char ** argv )
int fVeryVerbose;
int c;
extern int Abc_NtkDarClau( Abc_Ntk_t * pNtk, int nFrames, int nPref, int nClauses, int nLutSize, int nLevels, int nCutsMax, int nBatches, int fStepUp, int fBmc, int fRegs, int fTarget, int fVerbose, int fVeryVerbose );
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
nFrames = 1;
nPref = 0;
@@ -18471,7 +18454,7 @@ int Abc_CommandIndcut( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
nFrames = atoi(argv[globalUtilOptind]);
@@ -18482,7 +18465,7 @@ int Abc_CommandIndcut( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'P':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-P\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
goto usage;
}
nPref = atoi(argv[globalUtilOptind]);
@@ -18493,7 +18476,7 @@ int Abc_CommandIndcut( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
nClauses = atoi(argv[globalUtilOptind]);
@@ -18504,7 +18487,7 @@ int Abc_CommandIndcut( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'M':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-K\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
goto usage;
}
nLutSize = atoi(argv[globalUtilOptind]);
@@ -18515,7 +18498,7 @@ int Abc_CommandIndcut( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'L':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-L\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
goto usage;
}
nLevels = atoi(argv[globalUtilOptind]);
@@ -18526,7 +18509,7 @@ int Abc_CommandIndcut( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'N':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
goto usage;
}
nCutsMax = atoi(argv[globalUtilOptind]);
@@ -18537,7 +18520,7 @@ int Abc_CommandIndcut( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'B':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-B\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-B\" should be followed by an integer.\n" );
goto usage;
}
nBatches = atoi(argv[globalUtilOptind]);
@@ -18571,43 +18554,43 @@ int Abc_CommandIndcut( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( Abc_NtkIsComb(pNtk) )
{
- fprintf( pErr, "The network is combinational.\n" );
+ Abc_Print( -1, "The network is combinational.\n" );
return 0;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( stdout, "Currently only works for structurally hashed circuits.\n" );
+ Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
return 0;
}
if ( nLutSize > 12 )
{
- fprintf( stdout, "The cut size should be not exceed 12.\n" );
+ Abc_Print( -1, "The cut size should be not exceed 12.\n" );
return 0;
}
Abc_NtkDarClau( pNtk, nFrames, nPref, nClauses, nLutSize, nLevels, nCutsMax, nBatches, fStepUp, fBmc, fRegs, fTarget, fVerbose, fVeryVerbose );
return 0;
usage:
- fprintf( pErr, "usage: indcut [-FPCMLNB num] [-sbrtvh]\n" );
- fprintf( pErr, "\t K-step induction strengthened with cut properties\n" );
- fprintf( pErr, "\t-F num : number of time frames for induction (1=simple) [default = %d]\n", nFrames );
- fprintf( pErr, "\t-P num : number of time frames in the prefix (0=no prefix) [default = %d]\n", nPref );
- fprintf( pErr, "\t-C num : the max number of clauses to use for strengthening [default = %d]\n", nClauses );
- fprintf( pErr, "\t-M num : the cut size (2 <= M <= 12) [default = %d]\n", nLutSize );
- fprintf( pErr, "\t-L num : the max number of levels for cut computation [default = %d]\n", nLevels );
- fprintf( pErr, "\t-N num : the max number of cuts to compute at a node [default = %d]\n", nCutsMax );
- fprintf( pErr, "\t-B num : the max number of invariant batches to try [default = %d]\n", nBatches );
- fprintf( pErr, "\t-s : toggle increment cut size in each batch [default = %s]\n", fStepUp? "yes": "no" );
- fprintf( pErr, "\t-b : toggle enabling BMC check [default = %s]\n", fBmc? "yes": "no" );
- fprintf( pErr, "\t-r : toggle enabling register clauses [default = %s]\n", fRegs? "yes": "no" );
- fprintf( pErr, "\t-t : toggle proving target / computing don't-cares [default = %s]\n", fTarget? "yes": "no" );
- fprintf( pErr, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
-// fprintf( pErr, "\t-w : toggle printing very verbose information [default = %s]\n", fVeryVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: indcut [-FPCMLNB num] [-sbrtvh]\n" );
+ Abc_Print( -2, "\t K-step induction strengthened with cut properties\n" );
+ Abc_Print( -2, "\t-F num : number of time frames for induction (1=simple) [default = %d]\n", nFrames );
+ Abc_Print( -2, "\t-P num : number of time frames in the prefix (0=no prefix) [default = %d]\n", nPref );
+ Abc_Print( -2, "\t-C num : the max number of clauses to use for strengthening [default = %d]\n", nClauses );
+ Abc_Print( -2, "\t-M num : the cut size (2 <= M <= 12) [default = %d]\n", nLutSize );
+ Abc_Print( -2, "\t-L num : the max number of levels for cut computation [default = %d]\n", nLevels );
+ Abc_Print( -2, "\t-N num : the max number of cuts to compute at a node [default = %d]\n", nCutsMax );
+ Abc_Print( -2, "\t-B num : the max number of invariant batches to try [default = %d]\n", nBatches );
+ Abc_Print( -2, "\t-s : toggle increment cut size in each batch [default = %s]\n", fStepUp? "yes": "no" );
+ Abc_Print( -2, "\t-b : toggle enabling BMC check [default = %s]\n", fBmc? "yes": "no" );
+ Abc_Print( -2, "\t-r : toggle enabling register clauses [default = %s]\n", fRegs? "yes": "no" );
+ Abc_Print( -2, "\t-t : toggle proving target / computing don't-cares [default = %s]\n", fTarget? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+// Abc_Print( -2, "\t-w : toggle printing very verbose information [default = %s]\n", fVeryVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -18624,7 +18607,6 @@ usage:
***********************************************************************/
int Abc_CommandEnlarge( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int nFrames;
int fVerbose;
@@ -18632,9 +18614,6 @@ int Abc_CommandEnlarge( Abc_Frame_t * pAbc, int argc, char ** argv )
extern Abc_Ntk_t * Abc_NtkDarEnlarge( Abc_Ntk_t * pNtk, int nFrames, int fVerbose );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
nFrames = 5;
fVerbose = 0;
@@ -18646,7 +18625,7 @@ int Abc_CommandEnlarge( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
nFrames = atoi(argv[globalUtilOptind]);
@@ -18665,17 +18644,17 @@ int Abc_CommandEnlarge( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( Abc_NtkIsComb(pNtk) )
{
- fprintf( pErr, "The network is combinational.\n" );
+ Abc_Print( -1, "The network is combinational.\n" );
return 0;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( stdout, "Currently only works for structurally hashed circuits.\n" );
+ Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
return 0;
}
@@ -18683,18 +18662,18 @@ int Abc_CommandEnlarge( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtkRes = Abc_NtkDarEnlarge( pNtk, nFrames, fVerbose );
if ( pNtkRes == NULL )
{
- fprintf( pErr, "Target enlargement has failed.\n" );
+ Abc_Print( -1, "Target enlargement has failed.\n" );
return 1;
}
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
return 0;
usage:
- fprintf( pErr, "usage: enlarge [-F num] [-vh]\n" );
- fprintf( pErr, "\t performs structural K-step target enlargement\n" );
- fprintf( pErr, "\t-F num : the number of timeframes for enlargement [default = %d]\n", nFrames );
- fprintf( pErr, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: enlarge [-F num] [-vh]\n" );
+ Abc_Print( -2, "\t performs structural K-step target enlargement\n" );
+ Abc_Print( -2, "\t-F num : the number of timeframes for enlargement [default = %d]\n", nFrames );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -18711,31 +18690,31 @@ usage:
***********************************************************************/
int Abc_CommandInduction( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int nFramesMax;
int nConfMax;
+ int fUnique;
+ int fUniqueAll;
int fVerbose;
+ int fVeryVerbose;
int c;
- extern void Abc_NtkDarInduction( Abc_Ntk_t * pNtk, int nFramesMax, int nConfMax, int fVerbose );
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
+ extern int Abc_NtkDarInduction( Abc_Ntk_t * pNtk, int nFramesMax, int nConfMax, int fUnique, int fUniqueAll, int fVerbose, int fVeryVerbose );
// set defaults
- nFramesMax = 100;
- nConfMax = 1000;
- fVerbose = 0;
+ nFramesMax = 100;
+ nConfMax = 1000;
+ fUnique = 0;
+ fUniqueAll = 0;
+ fVerbose = 0;
+ fVeryVerbose = 0;
Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "FCvh" ) ) != EOF )
+ while ( ( c = Extra_UtilGetopt( argc, argv, "FCuavwh" ) ) != EOF )
{
switch ( c )
{
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
nFramesMax = atoi(argv[globalUtilOptind]);
@@ -18746,7 +18725,7 @@ int Abc_CommandInduction( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
nConfMax = atoi(argv[globalUtilOptind]);
@@ -18754,9 +18733,18 @@ int Abc_CommandInduction( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( nConfMax < 0 )
goto usage;
break;
+ case 'u':
+ fUnique ^= 1;
+ break;
+ case 'a':
+ fUniqueAll ^= 1;
+ break;
case 'v':
fVerbose ^= 1;
break;
+ case 'w':
+ fVeryVerbose ^= 1;
+ break;
case 'h':
goto usage;
default:
@@ -18765,35 +18753,43 @@ int Abc_CommandInduction( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( Abc_NtkIsComb(pNtk) )
{
- fprintf( pErr, "The network is combinational.\n" );
+ Abc_Print( -1, "The network is combinational.\n" );
return 0;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( stdout, "Currently only works for structurally hashed circuits.\n" );
+ Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
return 0;
}
if ( Abc_NtkPoNum(pNtk) != 1 )
{
- fprintf( pErr, "Currently this command works only for single-output miter.\n" );
+ Abc_Print( -1, "Currently this command works only for single-output miter.\n" );
+ return 0;
+ }
+ if ( fUnique && fUniqueAll )
+ {
+ Abc_Print( -1, "Only one of the options, \"-u\" or \"-a\", should be selected.\n" );
return 0;
}
// modify the current network
- Abc_NtkDarInduction( pNtk, nFramesMax, nConfMax, fVerbose );
+ pAbc->Status = Abc_NtkDarInduction( pNtk, nFramesMax, nConfMax, fUnique, fUniqueAll, fVerbose, fVeryVerbose );
return 0;
usage:
- fprintf( pErr, "usage: ind [-FC num] [-vh]\n" );
- fprintf( pErr, "\t runs the inductive case of the K-step induction\n" );
- fprintf( pErr, "\t-F num : the max number of timeframes [default = %d]\n", nFramesMax );
- fprintf( pErr, "\t-C num : the max number of conflicts by SAT solver [default = %d]\n", nConfMax );
- fprintf( pErr, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: ind [-FC num] [-uavwh]\n" );
+ Abc_Print( -2, "\t runs the inductive case of the K-step induction\n" );
+ Abc_Print( -2, "\t-F num : the max number of timeframes [default = %d]\n", nFramesMax );
+ Abc_Print( -2, "\t-C num : the max number of conflicts by SAT solver [default = %d]\n", nConfMax );
+ Abc_Print( -2, "\t-u : toggle adding uniqueness constraints on demand [default = %s]\n", fUnique? "yes": "no" );
+ Abc_Print( -2, "\t-a : toggle adding uniqueness constraints always [default = %s]\n", fUniqueAll? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-w : toggle printing additional verbose information [default = %s]\n", fVeryVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -18808,51 +18804,25 @@ usage:
SeeAlso []
***********************************************************************/
-int Abc_CommandPBAbstraction( Abc_Frame_t * pAbc, int argc, char ** argv )
+int Abc_CommandCegar( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Gia_ParAbs_t Pars, * pPars = &Pars;
- FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes;
int c;
- extern Abc_Ntk_t * Abc_NtkDarPBAbstraction( Abc_Ntk_t * pNtk, Gia_ParAbs_t * pPars );
+ extern Abc_Ntk_t * Abc_NtkDarCegar( Abc_Ntk_t * pNtk, Gia_ParAbs_t * pPars );
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Gia_ManAbsSetDefaultParams( pPars );
Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "FCGDRdesrpfvh" ) ) != EOF )
+ while ( ( c = Extra_UtilGetopt( argc, argv, "FCRcrpfvh" ) ) != EOF )
{
switch ( c )
{
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" );
- goto usage;
- }
- pPars->nFramesMax = atoi(argv[globalUtilOptind]);
- globalUtilOptind++;
- if ( pPars->nFramesMax < 0 )
- goto usage;
- break;
- case 'C':
- if ( globalUtilOptind >= argc )
- {
- fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
- goto usage;
- }
- pPars->nConfMax = atoi(argv[globalUtilOptind]);
- globalUtilOptind++;
- if ( pPars->nConfMax < 0 )
- goto usage;
- break;
- case 'G':
- if ( globalUtilOptind >= argc )
- {
- fprintf( pErr, "Command line switch \"-G\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
pPars->nFramesBmc = atoi(argv[globalUtilOptind]);
@@ -18860,10 +18830,10 @@ int Abc_CommandPBAbstraction( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pPars->nFramesBmc < 0 )
goto usage;
break;
- case 'D':
+ case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-D\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
pPars->nConfMaxBmc = atoi(argv[globalUtilOptind]);
@@ -18874,7 +18844,7 @@ int Abc_CommandPBAbstraction( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'R':
if ( globalUtilOptind >= argc )
{
- fprintf( pErr, "Command line switch \"-R\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
goto usage;
}
pPars->nRatio = atoi(argv[globalUtilOptind]);
@@ -18882,14 +18852,8 @@ int Abc_CommandPBAbstraction( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pPars->nRatio < 0 )
goto usage;
break;
- case 'd':
- pPars->fDynamic ^= 1;
- break;
- case 'e':
- pPars->fExtend ^= 1;
- break;
- case 's':
- pPars->fSkipProof ^= 1;
+ case 'c':
+ pPars->fConstr ^= 1;
break;
case 'r':
pPars->fUseBdds ^= 1;
@@ -18911,56 +18875,357 @@ int Abc_CommandPBAbstraction( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( Abc_NtkIsComb(pNtk) )
{
- fprintf( pErr, "The network is combinational.\n" );
+ Abc_Print( -1, "The network is combinational.\n" );
return 0;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( stdout, "Currently only works for structurally hashed circuits.\n" );
+ Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
return 0;
}
if ( !(0 <= pPars->nRatio && pPars->nRatio <= 100) )
{
- fprintf( stdout, "Wrong value of parameter \"-R <num>\".\n" );
+ Abc_Print( -1, "Wrong value of parameter \"-R <num>\".\n" );
return 0;
}
// modify the current network
- pNtkRes = Abc_NtkDarPBAbstraction( pNtk, pPars );
+ pNtkRes = Abc_NtkDarCegar( pNtk, pPars );
if ( pNtkRes == NULL )
{
if ( pNtk->pSeqModel == NULL )
- printf( "Abstraction has failed.\n" );
+ Abc_Print( -1, "Abstraction has failed.\n" );
return 0;
}
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
return 0;
usage:
- fprintf( pErr, "usage: abs [-FCGDR num] [-desrpfvh]\n" );
- fprintf( pErr, "\t proof-based abstraction (PBA) using UNSAT core of BMC\n" );
- fprintf( pErr, "\t followed by counter-example-based abstraction\n" );
- fprintf( pErr, "\t-F num : the max number of timeframes for PBA [default = %d]\n", pPars->nFramesMax );
- fprintf( pErr, "\t-C num : the max number of conflicts by SAT solver for PBA [default = %d]\n", pPars->nConfMax );
- fprintf( pErr, "\t-G num : the max number of timeframes for BMC [default = %d]\n", pPars->nFramesBmc );
- fprintf( pErr, "\t-D num : the max number of conflicts by SAT solver for BMC [default = %d]\n", pPars->nConfMaxBmc );
- fprintf( pErr, "\t-R num : the %% of abstracted flops when refinement stops (0<=num<=100) [default = %d]\n", pPars->nRatio );
- fprintf( pErr, "\t-d : toggle dynamic unrolling of timeframes [default = %s]\n", pPars->fDynamic? "yes": "no" );
- fprintf( pErr, "\t-e : toggle extending abstraction using COI of flops [default = %s]\n", pPars->fExtend? "yes": "no" );
- fprintf( pErr, "\t-s : toggle skipping proof-based abstraction [default = %s]\n", pPars->fSkipProof? "yes": "no" );
- fprintf( pErr, "\t-r : toggle using BDD-based reachability for filtering [default = %s]\n", pPars->fUseBdds? "yes": "no" );
- fprintf( pErr, "\t-p : toggle using \"dprove\" for filtering [default = %s]\n", pPars->fUseDprove? "yes": "no" );
- fprintf( pErr, "\t-f : toggle starting BMC from a later frame [default = %s]\n", pPars->fUseStart? "yes": "no" );
- fprintf( pErr, "\t-v : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: abs [-FCR num] [-crpfvh]\n" );
+ Abc_Print( -2, "\t performs counter-example-based abstraction\n" );
+ Abc_Print( -2, "\t-F num : the max number of timeframes for BMC [default = %d]\n", pPars->nFramesBmc );
+ Abc_Print( -2, "\t-C num : the max number of conflicts by SAT solver for BMC [default = %d]\n", pPars->nConfMaxBmc );
+ Abc_Print( -2, "\t-R num : the %% of abstracted flops when refinement stops (0<=num<=100) [default = %d]\n", pPars->nRatio );
+ Abc_Print( -2, "\t-c : toggle dynamic addition of constraints [default = %s]\n", pPars->fConstr? "yes": "no" );
+ Abc_Print( -2, "\t-r : toggle using BDD-based reachability for filtering [default = %s]\n", pPars->fUseBdds? "yes": "no" );
+ Abc_Print( -2, "\t-p : toggle using \"dprove\" for filtering [default = %s]\n", pPars->fUseDprove? "yes": "no" );
+ Abc_Print( -2, "\t-f : toggle starting BMC from a later frame [default = %s]\n", pPars->fUseStart? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_CommandConstr( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ Abc_Ntk_t * pNtk;
+ int c;
+ int nFrames;
+ int nConfs;
+ int nProps;
+ int fStruct;
+ int fInvert;
+ int fOldAlgo;
+ int fVerbose;
+ int nConstrs;
+ extern void Abc_NtkDarConstr( Abc_Ntk_t * pNtk, int nFrames, int nConfs, int nProps, int fStruct, int fOldAlgo, int fVerbose );
+
+ pNtk = Abc_FrameReadNtk(pAbc);
+ // set defaults
+ nFrames = 1;
+ nConfs = 1000;
+ nProps = 1000;
+ fStruct = 0;
+ fInvert = 0;
+ fOldAlgo = 0;
+ fVerbose = 0;
+ nConstrs = 0;
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "FCPNsiavh" ) ) != EOF )
+ {
+ switch ( c )
+ {
+ case 'F':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ nFrames = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( nFrames < 0 )
+ goto usage;
+ break;
+ case 'C':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ nConfs = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( nConfs < 0 )
+ goto usage;
+ break;
+ case 'P':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ nProps = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( nProps < 0 )
+ goto usage;
+ break;
+ case 'N':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ nConstrs = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( nConstrs < 0 )
+ goto usage;
+ break;
+ case 's':
+ fStruct ^= 1;
+ break;
+ case 'i':
+ fInvert ^= 1;
+ break;
+ case 'a':
+ fOldAlgo ^= 1;
+ break;
+ case 'v':
+ fVerbose ^= 1;
+ break;
+ case 'h':
+ goto usage;
+ default:
+ goto usage;
+ }
+ }
+ if ( pNtk == NULL )
+ {
+ Abc_Print( -1, "Empty network.\n" );
+ return 1;
+ }
+ if ( Abc_NtkIsComb(pNtk) )
+ {
+ Abc_Print( -1, "The network is combinational.\n" );
+ return 0;
+ }
+ if ( !Abc_NtkIsStrash(pNtk) )
+ {
+ Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
+ return 0;
+ }
+ // consider the case of already defined constraints
+ if ( Abc_NtkConstrNum(pNtk) > 0 )
+ {
+ extern void Abc_NtkDarConstrProfile( Abc_Ntk_t * pNtk, int fVerbose );
+ if ( fInvert )
+ {
+ Abc_Obj_t * pObj;
+ int i;
+ Abc_NtkForEachPo( pNtk, pObj, i )
+ {
+ if ( i >= Abc_NtkPoNum(pNtk) - Abc_NtkConstrNum(pNtk) )
+ Abc_ObjXorFaninC( pObj, 0 );
+ }
+ if ( Abc_NtkConstrNum(pNtk) == 1 )
+ Abc_Print( 1, "The outputs of %d constraint is complemented.\n", Abc_NtkConstrNum(pNtk) );
+ else
+ Abc_Print( 1, "The outputs of %d constraints are complemented.\n", Abc_NtkConstrNum(pNtk) );
+ }
+ if ( fVerbose )
+ Abc_NtkDarConstrProfile( pNtk, fVerbose );
+ return 0;
+ }
+ // consider the case of manual constraint definition
+ if ( nConstrs > 0 )
+ {
+ if ( Abc_NtkConstrNum(pNtk) > 0 )
+ {
+ Abc_Print( -1, "The network already has constraints.\n" );
+ return 0;
+ }
+ if ( nConstrs >= Abc_NtkPoNum(pNtk) )
+ {
+ Abc_Print( -1, "The number of constraints specified (%d) should be less than POs (%d).\n", nConstrs, Abc_NtkPoNum(pNtk) );
+ return 0;
+ }
+ Abc_Print( 0, "Considering the last %d POs as constraint outputs.\n", nConstrs );
+ pNtk->nConstrs = nConstrs;
+ return 0;
+ }
+ // detect constraints using functional/structural methods
+ Abc_NtkDarConstr( pNtk, nFrames, nConfs, nProps, fStruct, fOldAlgo, fVerbose );
+ return 0;
+usage:
+ Abc_Print( -2, "usage: constr [-FCPN num] [-isavh]\n" );
+ Abc_Print( -2, "\t a toolkit for constraint manipulation\n" );
+ Abc_Print( -2, "\t if constraints are absent, detect them functionally\n" );
+ Abc_Print( -2, "\t if constraints are present, profiles them using random simulation\n" );
+ Abc_Print( -2, "\t-F num : the max number of timeframes to consider [default = %d]\n", nFrames );
+ Abc_Print( -2, "\t-C num : the max number of conflicts in SAT solving [default = %d]\n", nConfs );
+ Abc_Print( -2, "\t-P num : the max number of propagations in SAT solving [default = %d]\n", nProps );
+ Abc_Print( -2, "\t-N num : manually set the last <num> POs to be constraints [default = %d]\n", nConstrs );
+ Abc_Print( -2, "\t-i : toggle inverting already defined constraints [default = %s]\n", fInvert? "yes": "no" );
+ Abc_Print( -2, "\t-s : toggle using structural detection methods [default = %s]\n", fStruct? "yes": "no" );
+ Abc_Print( -2, "\t-a : toggle fast implication detection [default = %s]\n", !fOldAlgo? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_CommandUnfold( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ Abc_Ntk_t * pNtk, * pNtkRes;
+ int nFrames;
+ int nConfs;
+ int nProps;
+ int fStruct;
+ int fOldAlgo;
+ int fVerbose;
+ int c;
+ extern Abc_Ntk_t * Abc_NtkDarUnfold( Abc_Ntk_t * pNtk, int nFrames, int nConfs, int nProps, int fStruct, int fOldAlgo, int fVerbose );
+ pNtk = Abc_FrameReadNtk(pAbc);
+ // set defaults
+ nFrames = 1;
+ nConfs = 1000;
+ nProps = 1000;
+ fStruct = 0;
+ fOldAlgo = 0;
+ fVerbose = 0;
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "FCPsavh" ) ) != EOF )
+ {
+ switch ( c )
+ {
+ case 'F':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ nFrames = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( nFrames < 0 )
+ goto usage;
+ break;
+ case 'C':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ nConfs = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( nConfs < 0 )
+ goto usage;
+ break;
+ case 'P':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ nProps = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( nProps < 0 )
+ goto usage;
+ break;
+ case 's':
+ fStruct ^= 1;
+ break;
+ case 'a':
+ fOldAlgo ^= 1;
+ break;
+ case 'v':
+ fVerbose ^= 1;
+ break;
+ case 'h':
+ goto usage;
+ default:
+ goto usage;
+ }
+ }
+ if ( pNtk == NULL )
+ {
+ Abc_Print( -1, "Empty network.\n" );
+ return 1;
+ }
+ if ( Abc_NtkIsComb(pNtk) )
+ {
+ Abc_Print( -1, "The network is combinational.\n" );
+ return 0;
+ }
+ if ( !Abc_NtkIsStrash(pNtk) )
+ {
+ Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
+ return 0;
+ }
+ if ( Abc_NtkConstrNum(pNtk) > 0 )
+ {
+ Abc_Print( -1, "Constraints are already extracted.\n" );
+ return 0;
+ }
+ if ( Abc_NtkPoNum(pNtk) > 1 )
+ {
+ Abc_Print( -1, "Constraint extraction works for single-output miters (use \"orpos\").\n" );
+ return 0;
+ }
+ // modify the current network
+ pNtkRes = Abc_NtkDarUnfold( pNtk, nFrames, nConfs, nProps, fStruct, fOldAlgo, fVerbose );
+ if ( pNtkRes == NULL )
+ {
+ printf( "Transformation has failed.\n" );
+ return 0;
+ }
+ // replace the current network
+ Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+ return 0;
+usage:
+ Abc_Print( -2, "usage: unfold [-FCP num] [-savh]\n" );
+ Abc_Print( -2, "\t unfold hidden constraints as separate outputs\n" );
+ Abc_Print( -2, "\t-F num : the max number of timeframes to consider [default = %d]\n", nFrames );
+ Abc_Print( -2, "\t-C num : the max number of conflicts in SAT solving [default = %d]\n", nConfs );
+ Abc_Print( -2, "\t-P num : the max number of constraint propagations [default = %d]\n", nProps );
+ Abc_Print( -2, "\t-s : toggle detecting structural constraints [default = %s]\n", fStruct? "yes": "no" );
+ Abc_Print( -2, "\t-a : toggle fast implication detection [default = %s]\n", !fOldAlgo? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ return 1;
+}
/**Function*************************************************************
@@ -18973,16 +19238,169 @@ usage:
SeeAlso []
***********************************************************************/
-int Abc_CommandTraceStart( Abc_Frame_t * pAbc, int argc, char ** argv )
+int Abc_CommandFold( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk, * pNtkRes;
+ int fCompl;
+ int fVerbose;
int c;
+ extern Abc_Ntk_t * Abc_NtkDarFold( Abc_Ntk_t * pNtk, int fCompl, int fVerbose );
+ pNtk = Abc_FrameReadNtk(pAbc);
+ // set defaults
+ fCompl = 0;
+ fVerbose = 0;
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "cvh" ) ) != EOF )
+ {
+ switch ( c )
+ {
+ case 'c':
+ fCompl ^= 1;
+ break;
+ case 'v':
+ fVerbose ^= 1;
+ break;
+ case 'h':
+ goto usage;
+ default:
+ goto usage;
+ }
+ }
+ if ( pNtk == NULL )
+ {
+ Abc_Print( -1, "Empty network.\n" );
+ return 1;
+ }
+ if ( Abc_NtkIsComb(pNtk) )
+ {
+ Abc_Print( -1, "The network is combinational.\n" );
+ return 0;
+ }
+ if ( !Abc_NtkIsStrash(pNtk) )
+ {
+ Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" );
+ return 0;
+ }
+ if ( Abc_NtkConstrNum(pNtk) == 0 )
+ {
+ Abc_Print( -1, "The network has no constraints.\n" );
+ return 0;
+ }
+ // modify the current network
+ pNtkRes = Abc_NtkDarFold( pNtk, fCompl, fVerbose );
+ if ( pNtkRes == NULL )
+ {
+ printf( "Transformation has failed.\n" );
+ return 0;
+ }
+ // replace the current network
+ Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+ return 0;
+usage:
+ Abc_Print( -2, "usage: fold [-cvh]\n" );
+ Abc_Print( -2, "\t folds constraints represented as separate outputs\n" );
+ Abc_Print( -2, "\t-c : toggle complementing constraints while folding [default = %s]\n", fCompl? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_CommandBm( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ FILE * pOut, * pErr;
+ Abc_Ntk_t *pNtk, *pNtk1, *pNtk2;
+ int fDelete1, fDelete2;
+ char ** pArgvNew;
+ int c, nArgcNew;
+ int p_equivalence = FALSE;
+ extern void bmGateWay( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int p_equivalence );
pNtk = Abc_FrameReadNtk(pAbc);
pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
+ pErr = Abc_FrameReadErr(pAbc);
+
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "Ph" ) ) != EOF )
+ {
+ switch ( c )
+ {
+ case 'h':
+ goto usage;
+ case 'P':
+ p_equivalence = 1;
+ break;
+ default:
+ fprintf( pErr, "Unkown switch.\n");
+ goto usage;
+ }
+ }
+
+ pArgvNew = argv + globalUtilOptind;
+ nArgcNew = argc - globalUtilOptind;
+ if ( !Abc_NtkPrepareTwoNtks( pErr, pNtk, pArgvNew, nArgcNew , &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) )
+ return 1;
+
+ if( (unsigned)Abc_NtkPiNum(pNtk1) != (unsigned)Abc_NtkPiNum(pNtk2) || (unsigned)Abc_NtkPoNum(pNtk1) != (unsigned)Abc_NtkPoNum(pNtk2) )
+ {
+ fprintf( pErr, "Mismatch in the number of inputs or outputs\n");
+ if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
+ if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
+ return 1;
+ }
+
+ bmGateWay( pNtk1, pNtk2, p_equivalence );
+
+ if ( fDelete1 ) Abc_NtkDelete( pNtk1 );
+ if ( fDelete2 ) Abc_NtkDelete( pNtk2 );
+ return 0;
+
+usage:
+ fprintf( pErr, "usage: bm [-P] <file1> <file2>\n" );
+ fprintf( pErr, "\t performs Boolean matching (P-equivalence & PP-equivalence)\n" );
+ fprintf( pErr, "\t for equivalent circuits, I/O matches are printed in IOmatch.txt\n" );
+ fprintf( pErr, "\t-P : performs P-equivalnce checking\n");
+ fprintf( pErr, "\t default is PP-equivalence checking (when -P is not provided)\n" );
+ fprintf( pErr, "\t-h : print the command usage\n");
+ fprintf( pErr, "\tfile1 : the file with the first network\n");
+ fprintf( pErr, "\tfile2 : the file with the second network\n");
+
+ fprintf( pErr, "\t \n" );
+ fprintf( pErr, "\t This command was contributed by Hadi Katebi from U Michigan.\n" );
+ fprintf( pErr, "\t The paper describing the method: H. Katebi and I. L. Markov.\n" );
+ fprintf( pErr, "\t \"Large-scale Boolean matching\". Proc. DATE 2010. \n" );
+ fprintf( pErr, "\t http://www.eecs.umich.edu/~imarkov/pubs/conf/date10-match.pdf\n" );
+ fprintf( pErr, "\t \n" );
+
+ return 1;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+***********************************************************************/
+int Abc_CommandTraceStart( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+ int c;
// set defaults
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
@@ -18998,28 +19416,28 @@ int Abc_CommandTraceStart( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "This command is applicable to AIGs.\n" );
+ Abc_Print( -1, "This command is applicable to AIGs.\n" );
return 1;
}
/*
Abc_HManStart();
if ( !Abc_HManPopulate( pNtk ) )
{
- fprintf( pErr, "Failed to start the tracing database.\n" );
+ Abc_Print( -1, "Failed to start the tracing database.\n" );
return 1;
}
*/
return 0;
usage:
- fprintf( pErr, "usage: trace_start [-h]\n" );
- fprintf( pErr, "\t starts verification tracing\n" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: trace_start [-h]\n" );
+ Abc_Print( -2, "\t starts verification tracing\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -19036,14 +19454,8 @@ usage:
***********************************************************************/
int Abc_CommandTraceCheck( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
// set defaults
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
@@ -19059,31 +19471,31 @@ int Abc_CommandTraceCheck( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pNtk == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
- fprintf( pErr, "This command is applicable to AIGs.\n" );
+ Abc_Print( -1, "This command is applicable to AIGs.\n" );
return 1;
}
/*
if ( !Abc_HManIsRunning(pNtk) )
{
- fprintf( pErr, "The tracing database is not available.\n" );
+ Abc_Print( -1, "The tracing database is not available.\n" );
return 1;
}
if ( !Abc_HManVerify( 1, pNtk->Id ) )
- fprintf( pErr, "Verification failed.\n" );
+ Abc_Print( -1, "Verification failed.\n" );
Abc_HManStop();
*/
return 0;
usage:
- fprintf( pErr, "usage: trace_check [-h]\n" );
- fprintf( pErr, "\t checks the current network using verification trace\n" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: trace_check [-h]\n" );
+ Abc_Print( -2, "\t checks the current network using verification trace\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -19107,18 +19519,12 @@ int Abc_CommandAbc8Read( Abc_Frame_t * pAbc, int argc, char ** argv )
int c;
int fMapped;
int fTest;
- int fAlter;
- extern void * Ioa_ReadBlif( char * pFileName, int fCheck );
- extern void Ioa_WriteBlif( void * p, char * pFileName );
- extern void * Ntl_ManExtractNwk( void * p, Aig_Man_t * pAig, Tim_Man_t * pManTime );
- extern void Ntl_ManPrintStats( void * p );
// set defaults
fMapped = 0;
fTest = 0;
- fAlter = 0;
Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "mtah" ) ) != EOF )
+ while ( ( c = Extra_UtilGetopt( argc, argv, "mth" ) ) != EOF )
{
switch ( c )
{
@@ -19128,9 +19534,6 @@ int Abc_CommandAbc8Read( Abc_Frame_t * pAbc, int argc, char ** argv )
case 't':
fTest ^= 1;
break;
- case 'a':
- fAlter ^= 1;
- break;
case 'h':
goto usage;
default:
@@ -19142,69 +19545,52 @@ int Abc_CommandAbc8Read( Abc_Frame_t * pAbc, int argc, char ** argv )
pFileName = argv[globalUtilOptind];
if ( (pFile = fopen( pFileName, "r" )) == NULL )
{
- fprintf( stdout, "Cannot open input file \"%s\". ", pFileName );
+ Abc_Print( -1, "Cannot open input file \"%s\". ", pFileName );
if ( (pFileName = Extra_FileGetSimilarName( pFileName, ".blif", NULL, NULL, NULL, NULL )) )
- fprintf( stdout, "Did you mean \"%s\"?", pFileName );
- fprintf( stdout, "\n" );
+ Abc_Print( 1, "Did you mean \"%s\"?", pFileName );
+ Abc_Print( 1, "\n" );
return 1;
}
fclose( pFile );
if ( fTest )
{
- extern void Ntl_ManFree( void * p );
- void * pTemp = Ioa_ReadBlif( pFileName, 1 );
+ Ntl_Man_t * pTemp = Ntl_ManReadBlif( pFileName, 1 );
if ( pTemp )
{
- Ntl_ManPrintStats( pTemp );
-// Ioa_WriteBlif( pTemp, "test_boxes.blif" );
- Ntl_ManFree( pTemp );
+// Ntl_ManWriteBlif( pTemp, "test_boxes.blif" );
+ Ntl_ManPrintStats( pTemp );
+ Ntl_ManFree( pTemp );
}
return 0;
}
Abc_FrameClearDesign();
- if ( !fAlter )
- {
- pAbc->pAbc8Ntl = Ioa_ReadBlif( pFileName, 1 );
- if ( pAbc->pAbc8Ntl == NULL )
- {
- printf( "Abc_CommandAbc8Read(): Reading BLIF has failed.\n" );
- return 1;
- }
- }
- else
+ pAbc->pAbc8Ntl = Ntl_ManReadBlif( pFileName, 1 );
+ if ( pAbc->pAbc8Ntl == NULL )
{
- pAbc->pAbc8Ntl = NULL;
-// extern void * Nal_ManRead( char * pFileName );
-// pAbc->pAbc8Ntl = Nal_ManRead( pFileName );
-// Ioa_WriteBlif( pAbc->pAbc8Ntl, "test_boxes.blif" );
- if ( pAbc->pAbc8Ntl == NULL )
- {
- printf( "Abc_CommandAbc8Read(): Reading design has failed.\n" );
- return 1;
- }
+ Abc_Print( -1, "Abc_CommandAbc8Read(): Reading BLIF has failed.\n" );
+ return 1;
}
pAbc->pAbc8Aig = Ntl_ManExtract( pAbc->pAbc8Ntl );
if ( pAbc->pAbc8Aig == NULL )
{
- printf( "Abc_CommandAbc8Read(): AIG extraction has failed.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Read(): AIG extraction has failed.\n" );
return 1;
}
if ( fMapped )
{
pAbc->pAbc8Nwk = Ntl_ManExtractNwk( pAbc->pAbc8Ntl, pAbc->pAbc8Aig, NULL );
if ( pAbc->pAbc8Nwk == NULL )
- printf( "Abc_CommandAbc8Read(): Warning! Mapped network is not extracted.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Read(): Warning! Mapped network is not extracted.\n" );
}
return 0;
usage:
- fprintf( stdout, "usage: *r [-mtah]\n" );
- fprintf( stdout, "\t reads the design with whiteboxes\n" );
- fprintf( stdout, "\t-m : toggle extracting mapped network [default = %s]\n", fMapped? "yes": "no" );
- fprintf( stdout, "\t-t : toggle reading in the test mode [default = %s]\n", fTest? "yes": "no" );
- fprintf( stdout, "\t-a : toggle reading another file type [default = %s]\n", fAlter? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: *r [-mth]\n" );
+ Abc_Print( -2, "\t reads the design with whiteboxes\n" );
+ Abc_Print( -2, "\t-m : toggle extracting mapped network [default = %s]\n", fMapped? "yes": "no" );
+ Abc_Print( -2, "\t-t : toggle reading in the test mode [default = %s]\n", fTest? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -19223,11 +19609,8 @@ int Abc_CommandAbc8ReadLogic( Abc_Frame_t * pAbc, int argc, char ** argv )
{
FILE * pFile;
char * pFileName;
- void * pNtkNew;
+ Nwk_Man_t * pNtkNew;
int c;
- extern void * Ntl_ManReadNwk( char * pFileName, Aig_Man_t * pAig, Tim_Man_t * pManTime );
- extern Tim_Man_t * Ntl_ManReadTimeMan( void * p );
- extern void Nwk_ManFree( void * p );
// set defaults
Extra_UtilGetoptReset();
@@ -19246,17 +19629,17 @@ int Abc_CommandAbc8ReadLogic( Abc_Frame_t * pAbc, int argc, char ** argv )
pFileName = argv[globalUtilOptind];
if ( (pFile = fopen( pFileName, "r" )) == NULL )
{
- fprintf( stdout, "Cannot open input file \"%s\". ", pFileName );
+ Abc_Print( -1, "Cannot open input file \"%s\". ", pFileName );
if ( (pFileName = Extra_FileGetSimilarName( pFileName, ".blif", NULL, NULL, NULL, NULL )) )
- fprintf( stdout, "Did you mean \"%s\"?", pFileName );
- fprintf( stdout, "\n" );
+ Abc_Print( 1, "Did you mean \"%s\"?", pFileName );
+ Abc_Print( 1, "\n" );
return 1;
}
fclose( pFile );
if ( pAbc->pAbc8Ntl == NULL || pAbc->pAbc8Aig == NULL )
{
- printf( "Abc_CommandAbc8ReadLogic(): There is no design or its AIG.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8ReadLogic(): There is no design or its AIG.\n" );
return 1;
}
@@ -19264,7 +19647,7 @@ int Abc_CommandAbc8ReadLogic( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtkNew = Ntl_ManReadNwk( pFileName, pAbc->pAbc8Aig, Ntl_ManReadTimeMan(pAbc->pAbc8Ntl) );
if ( pNtkNew == NULL )
{
- printf( "Abc_CommandAbc8ReadLogic(): Procedure has failed.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8ReadLogic(): Procedure has failed.\n" );
return 1;
}
if ( pAbc->pAbc8Nwk != NULL )
@@ -19273,11 +19656,11 @@ int Abc_CommandAbc8ReadLogic( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( stdout, "usage: *rlogic [-h]\n" );
- fprintf( stdout, "\t reads the logic part of the design without whiteboxes\n" );
- fprintf( stdout, "\t and sets the new logic as the current mapped network\n" );
- fprintf( stdout, "\t (the logic part should be comb and with the same PIs/POs)\n" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: *rlogic [-h]\n" );
+ Abc_Print( -2, "\t reads the logic part of the design without whiteboxes\n" );
+ Abc_Print( -2, "\t and sets the new logic as the current mapped network\n" );
+ Abc_Print( -2, "\t (the logic part should be comb and with the same PIs/POs)\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -19295,17 +19678,12 @@ usage:
int Abc_CommandAbc8Write( Abc_Frame_t * pAbc, int argc, char ** argv )
{
char * pFileName;
- void * pTemp;
+ Aig_Man_t * pTemp;
+ Ntl_Man_t * pTemp2;
int fAig;
int fBlif;
int fCollapsed;
int c;
- extern void Ioa_WriteBlif( void * p, char * pFileName );
- extern void * Ntl_ManInsertNtk( void * p, void * pNtk );
- extern void * Ntl_ManInsertAig( void * p, Aig_Man_t * pAig );
- extern void * Ntl_ManDup( void * pOld );
- extern void Ntl_ManFree( void * p );
- extern Aig_Man_t * Ntl_ManCollapseSeq( void * p, int nMinDomSize, int fVerbose );
// set defaults
fAig = 0;
@@ -19333,7 +19711,7 @@ int Abc_CommandAbc8Write( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pAbc->pAbc8Ntl == NULL )
{
- printf( "Abc_CommandAbc8Write(): There is no design to write.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Write(): There is no design to write.\n" );
return 1;
}
// create the design to write
@@ -19342,7 +19720,6 @@ int Abc_CommandAbc8Write( Abc_Frame_t * pAbc, int argc, char ** argv )
{
if ( fCollapsed )
{
- extern void Ioa_WriteAiger( Aig_Man_t * pMan, char * pFileName, int fWriteSymbols, int fCompact );
pTemp = Ntl_ManCollapseSeq( pAbc->pAbc8Ntl, 0, 0 );
if ( fBlif )
Saig_ManDumpBlif( pTemp, pFileName );
@@ -19356,21 +19733,21 @@ int Abc_CommandAbc8Write( Abc_Frame_t * pAbc, int argc, char ** argv )
{
if ( fBlif )
{
- pTemp = Ntl_ManInsertAig( pAbc->pAbc8Ntl, pAbc->pAbc8Aig );
- if ( pTemp == NULL )
+ pTemp2 = Ntl_ManInsertAig( pAbc->pAbc8Ntl, pAbc->pAbc8Aig );
+ if ( pTemp2 == NULL )
{
- printf( "Abc_CommandAbc8Write(): Inserting AIG has failed.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Write(): Inserting AIG has failed.\n" );
return 1;
}
- Ioa_WriteBlif( pTemp, pFileName );
- Ntl_ManFree( pTemp );
+ Ntl_ManWriteBlif( pTemp2, pFileName );
+ Ntl_ManFree( pTemp2 );
}
else
Ioa_WriteAiger( pAbc->pAbc8Aig, pFileName, 0, 0 );
}
else
{
- printf( "There is no AIG to write.\n" );
+ Abc_Print( -1, "There is no AIG to write.\n" );
return 1;
}
}
@@ -19379,31 +19756,31 @@ int Abc_CommandAbc8Write( Abc_Frame_t * pAbc, int argc, char ** argv )
{
if ( pAbc->pAbc8Nwk != NULL )
{
- pTemp = Ntl_ManInsertNtk( pAbc->pAbc8Ntl, pAbc->pAbc8Nwk );
- if ( pTemp == NULL )
+ pTemp2 = Ntl_ManInsertNtk( pAbc->pAbc8Ntl, pAbc->pAbc8Nwk );
+ if ( pTemp2 == NULL )
{
- printf( "Abc_CommandAbc8Write(): Inserting mapped network has failed.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Write(): Inserting mapped network has failed.\n" );
return 1;
}
- Ioa_WriteBlif( pTemp, pFileName );
- Ntl_ManFree( pTemp );
+ Ntl_ManWriteBlif( pTemp2, pFileName );
+ Ntl_ManFree( pTemp2 );
}
else
{
- printf( "Writing the unmapped netlist.\n" );
- pTemp = pAbc->pAbc8Ntl;
- Ioa_WriteBlif( pTemp, pFileName );
+ Abc_Print( -1, "Writing the unmapped netlist.\n" );
+ pTemp2 = pAbc->pAbc8Ntl;
+ Ntl_ManWriteBlif( pTemp2, pFileName );
}
}
return 0;
usage:
- fprintf( stdout, "usage: *w [-abch]\n" );
- fprintf( stdout, "\t write the design with whiteboxes\n" );
- fprintf( stdout, "\t-a : toggle writing mapped network or AIG [default = %s]\n", fAig? "AIG": "mapped" );
- fprintf( stdout, "\t-b : toggle writing AIG as BLIF or AIGER [default = %s]\n", fBlif? "BLIF": "AIGER" );
- fprintf( stdout, "\t-c : toggle writing collapsed sequential AIG [default = %s]\n", fCollapsed? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: *w [-abch]\n" );
+ Abc_Print( -2, "\t write the design with whiteboxes\n" );
+ Abc_Print( -2, "\t-a : toggle writing design or internal AIG [default = %s]\n", fAig? "AIG": "design" );
+ Abc_Print( -2, "\t-b : toggle writing AIG as BLIF or AIGER [default = %s]\n", fBlif? "BLIF": "AIGER" );
+ Abc_Print( -2, "\t-c : toggle writing collapsed sequential AIG [default = %s]\n", fCollapsed? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -19424,9 +19801,6 @@ int Abc_CommandAbc8WriteLogic( Abc_Frame_t * pAbc, int argc, char ** argv )
char * pFileName;
int fAig;
int c;
- extern Vec_Ptr_t * Ntl_ManCollectCiNames( void * p );
- extern Vec_Ptr_t * Ntl_ManCollectCoNames( void * p );
- extern void Nwk_ManDumpBlif( void * p, char * pFileName, Vec_Ptr_t * vCiNames, Vec_Ptr_t * vCoNames );
// set defaults
fAig = 0;
@@ -19446,7 +19820,7 @@ int Abc_CommandAbc8WriteLogic( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pAbc->pAbc8Ntl == NULL )
{
- printf( "Abc_CommandAbc8Write(): There is no design to write.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Write(): There is no design to write.\n" );
return 1;
}
// create the design to write
@@ -19460,7 +19834,7 @@ int Abc_CommandAbc8WriteLogic( Abc_Frame_t * pAbc, int argc, char ** argv )
Aig_ManDumpBlif( pAbc->pAbc8Aig, pFileName, vCiNames, vCoNames );
else
{
- printf( "There is no AIG to write.\n" );
+ Abc_Print( -1, "There is no AIG to write.\n" );
return 1;
}
}
@@ -19470,7 +19844,7 @@ int Abc_CommandAbc8WriteLogic( Abc_Frame_t * pAbc, int argc, char ** argv )
Nwk_ManDumpBlif( pAbc->pAbc8Nwk, pFileName, vCiNames, vCoNames );
else
{
- printf( "There is no mapped network to write.\n" );
+ Abc_Print( -1, "There is no mapped network to write.\n" );
return 1;
}
}
@@ -19479,10 +19853,10 @@ int Abc_CommandAbc8WriteLogic( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( stdout, "usage: *wlogic [-ah]\n" );
- fprintf( stdout, "\t write the logic part of the design without whiteboxes\n" );
- fprintf( stdout, "\t-a : toggle writing mapped network or AIG [default = %s]\n", fAig? "AIG": "mapped" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: *wlogic [-ah]\n" );
+ Abc_Print( -2, "\t write the logic part of the design without whiteboxes\n" );
+ Abc_Print( -2, "\t-a : toggle writing mapped network or AIG [default = %s]\n", fAig? "AIG": "network" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -19501,7 +19875,7 @@ int Abc_CommandAbc8ReadLut( Abc_Frame_t * pAbc, int argc, char **argv )
{
FILE * pFile;
char * FileName;
- void * pLib;
+ If_Lib_t * pLib;
int c;
extern If_Lib_t * If_LutLibRead( char * FileName );
extern void If_LutLibFree( If_Lib_t * pLutLib );
@@ -19530,10 +19904,10 @@ int Abc_CommandAbc8ReadLut( Abc_Frame_t * pAbc, int argc, char **argv )
FileName = argv[globalUtilOptind];
if ( (pFile = fopen( FileName, "r" )) == NULL )
{
- fprintf( stdout, "Cannot open input file \"%s\". ", FileName );
+ Abc_Print( -1, "Cannot open input file \"%s\". ", FileName );
if ( (FileName = Extra_FileGetSimilarName( FileName, ".lut", NULL, NULL, NULL, NULL )) )
- fprintf( stdout, "Did you mean \"%s\"?", FileName );
- fprintf( stdout, "\n" );
+ Abc_Print( 1, "Did you mean \"%s\"?", FileName );
+ Abc_Print( 1, "\n" );
return 1;
}
fclose( pFile );
@@ -19542,7 +19916,7 @@ int Abc_CommandAbc8ReadLut( Abc_Frame_t * pAbc, int argc, char **argv )
pLib = If_LutLibRead( FileName );
if ( pLib == NULL )
{
- fprintf( stdout, "Reading LUT library has failed.\n" );
+ Abc_Print( -1, "Reading LUT library has failed.\n" );
goto usage;
}
// replace the current library
@@ -19552,21 +19926,21 @@ int Abc_CommandAbc8ReadLut( Abc_Frame_t * pAbc, int argc, char **argv )
return 0;
usage:
- fprintf( stdout, "\nusage: *rlut [-h]\n");
- fprintf( stdout, "\t read the LUT library from the file\n" );
- fprintf( stdout, "\t-h : print the command usage\n");
- fprintf( stdout, "\t \n");
- fprintf( stdout, "\t File format for a LUT library:\n");
- fprintf( stdout, "\t (the default library is shown)\n");
- fprintf( stdout, "\t \n");
- fprintf( stdout, "\t # The area/delay of k-variable LUTs:\n");
- fprintf( stdout, "\t # k area delay\n");
- fprintf( stdout, "\t 1 1 1\n");
- fprintf( stdout, "\t 2 2 2\n");
- fprintf( stdout, "\t 3 4 3\n");
- fprintf( stdout, "\t 4 8 4\n");
- fprintf( stdout, "\t 5 16 5\n");
- fprintf( stdout, "\t 6 32 6\n");
+ Abc_Print( -2, "\nusage: *rlut [-h]\n");
+ Abc_Print( -2, "\t read the LUT library from the file\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ Abc_Print( -2, "\t \n");
+ Abc_Print( -2, "\t File format for a LUT library:\n");
+ Abc_Print( -2, "\t (the default library is shown)\n");
+ Abc_Print( -2, "\t \n");
+ Abc_Print( -2, "\t # The area/delay of k-variable LUTs:\n");
+ Abc_Print( -2, "\t # k area delay\n");
+ Abc_Print( -2, "\t 1 1 1\n");
+ Abc_Print( -2, "\t 2 2 2\n");
+ Abc_Print( -2, "\t 3 4 3\n");
+ Abc_Print( -2, "\t 4 8 4\n");
+ Abc_Print( -2, "\t 5 16 5\n");
+ Abc_Print( -2, "\t 6 32 6\n");
return 1; /* error exit */
}
@@ -19607,15 +19981,15 @@ int Abc_CommandAbc8PrintLut( Abc_Frame_t * pAbc, int argc, char **argv )
// set the new network
if ( pAbc->pAbc8Lib == NULL )
- printf( "Abc_CommandAbc8PrintLut(): LUT library is not specified.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8PrintLut(): LUT library is not specified.\n" );
else
- If_LutLibPrint( pAbc->pAbc8Lib );
+ If_LutLibPrint( (If_Lib_t *)pAbc->pAbc8Lib );
return 0;
usage:
- fprintf( stdout, "\nusage: *plut [-h]\n");
- fprintf( stdout, "\t print the current LUT library\n" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "\nusage: *plut [-h]\n");
+ Abc_Print( -2, "\t print the current LUT library\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1; /* error exit */
}
@@ -19633,7 +20007,6 @@ usage:
int Abc_CommandAbc8Check( Abc_Frame_t * pAbc, int argc, char **argv )
{
int c;
- extern int Nwk_ManCheck( void * p );
// set the defaults
Extra_UtilGetoptReset();
@@ -19656,15 +20029,15 @@ int Abc_CommandAbc8Check( Abc_Frame_t * pAbc, int argc, char **argv )
// set the new network
if ( pAbc->pAbc8Nwk == NULL )
- printf( "Abc_CommandAbc8Check(): There is no mapped network.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Check(): There is no mapped network.\n" );
else
Nwk_ManCheck( pAbc->pAbc8Nwk );
return 0;
usage:
- fprintf( stdout, "\nusage: *check [-h]\n");
- fprintf( stdout, "\t checks if the current mapped network has duplicated fanins\n" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "\nusage: *check [-h]\n");
+ Abc_Print( -2, "\t checks if the current mapped network has duplicated fanins\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1; /* error exit */
}
@@ -19687,9 +20060,7 @@ int Abc_CommandAbc8Ps( Abc_Frame_t * pAbc, int argc, char ** argv )
int fDumpResult;
int fPower;
int fShort;
- extern void Ntl_ManPrintStats( void * p );
- extern void Nwk_ManPrintStats( void * p, void * pLutLib, int fSaveBest, int fDumpResult, int fPower, void * pNtl );
- extern void Nwk_ManPrintStatsShort( void * p, void * pAig, void * pNtk );
+ extern If_Lib_t * If_SetSimpleLutLib( int nLutSize );
// set defaults
fSaveBest = 0;
@@ -19721,7 +20092,7 @@ int Abc_CommandAbc8Ps( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pAbc->pAbc8Ntl == NULL )
{
- printf( "Abc_CommandAbc8Ps(): There is no design to show.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Ps(): There is no design to show.\n" );
return 1;
}
@@ -19733,34 +20104,34 @@ int Abc_CommandAbc8Ps( Abc_Frame_t * pAbc, int argc, char ** argv )
// get the input file name
if ( pAbc->pAbc8Ntl )
{
- printf( "NETLIST: " );
+ Abc_Print( -1, "NETLIST: " );
Ntl_ManPrintStats( pAbc->pAbc8Ntl );
}
if ( pAbc->pAbc8Aig )
{
- printf( "AIG: " );
+ Abc_Print( -1, "AIG: " );
Aig_ManPrintStats( pAbc->pAbc8Aig );
}
if ( pAbc->pAbc8Nwk )
{
if ( pAbc->pAbc8Lib == NULL )
{
- printf( "LUT library is not given. Using default LUT library.\n" );
+ Abc_Print( -1, "LUT library is not given. Using default LUT library.\n" );
pAbc->pAbc8Lib = If_SetSimpleLutLib( 6 );
}
- printf( "MAPPED: " );
+ Abc_Print( -1, "MAPPED: " );
Nwk_ManPrintStats( pAbc->pAbc8Nwk, pAbc->pAbc8Lib, fSaveBest, fDumpResult, fPower, pAbc->pAbc8Ntl );
}
return 0;
usage:
- fprintf( stdout, "usage: *ps [-bdpsh]\n" );
- fprintf( stdout, "\t prints design statistics\n" );
- fprintf( stdout, "\t-b : toggles saving the best logic network in \"best.blif\" [default = %s]\n", fSaveBest? "yes": "no" );
- fprintf( stdout, "\t-d : toggles dumping network into file \"<input_file_name>_dump.blif\" [default = %s]\n", fDumpResult? "yes": "no" );
- fprintf( stdout, "\t-p : toggles printing power dissipation due to switching [default = %s]\n", fPower? "yes": "no" );
- fprintf( stdout, "\t-s : toggles short printing mode [default = %s]\n", fShort? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: *ps [-bdpsh]\n" );
+ Abc_Print( -2, "\t prints design statistics\n" );
+ Abc_Print( -2, "\t-b : toggles saving the best logic network in \"best.blif\" [default = %s]\n", fSaveBest? "yes": "no" );
+ Abc_Print( -2, "\t-d : toggles dumping network into file \"<input_file_name>_dump.blif\" [default = %s]\n", fDumpResult? "yes": "no" );
+ Abc_Print( -2, "\t-p : toggles printing power dissipation due to switching [default = %s]\n", fPower? "yes": "no" );
+ Abc_Print( -2, "\t-s : toggles short printing mode [default = %s]\n", fShort? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -19778,7 +20149,6 @@ usage:
int Abc_CommandAbc8Pfan( Abc_Frame_t * pAbc, int argc, char ** argv )
{
int c;
- extern void Nwk_ManPrintFanioNew( void * p );
// set defaults
Extra_UtilGetoptReset();
@@ -19794,16 +20164,16 @@ int Abc_CommandAbc8Pfan( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pAbc->pAbc8Nwk == NULL )
{
- printf( "Abc_CommandAbc8Pfan(): There is no mapped network for print fanin/fanout.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Pfan(): There is no mapped network for print fanin/fanout.\n" );
return 1;
}
Nwk_ManPrintFanioNew( pAbc->pAbc8Nwk );
return 0;
usage:
- fprintf( stdout, "usage: *pfan [-h]\n" );
- fprintf( stdout, "\t prints fanin/fanout stats of the mapped network\n" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: *pfan [-h]\n" );
+ Abc_Print( -2, "\t prints fanin/fanout stats of the mapped network\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -19823,17 +20193,12 @@ int Abc_CommandAbc8If( Abc_Frame_t * pAbc, int argc, char ** argv )
char Buffer[200];
char LutSize[200];
If_Par_t Pars, * pPars = &Pars;
- void * pNtkNew;
+ Nwk_Man_t * pNtkNew;
int c;
- extern void * Nwk_MappingIf( Aig_Man_t * p, Tim_Man_t * pManTime, If_Par_t * pPars );
- extern Tim_Man_t * Ntl_ManReadTimeMan( void * p );
- extern If_Lib_t * If_SetSimpleLutLib( int nLutSize );
- extern void Nwk_ManSetIfParsDefault( If_Par_t * pPars );
- extern void Nwk_ManFree( void * p );
if ( pAbc->pAbc8Lib == NULL )
{
-// printf( "LUT library is not given. Using default LUT library.\n" );
+// Abc_Print( -1, "LUT library is not given. Using default LUT library.\n" );
pAbc->pAbc8Lib = If_SetSimpleLutLib( 6 );
}
@@ -19841,14 +20206,14 @@ int Abc_CommandAbc8If( Abc_Frame_t * pAbc, int argc, char ** argv )
Nwk_ManSetIfParsDefault( pPars );
pPars->pLutLib = pAbc->pAbc8Lib;
Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "KCFADEqaflepmrstbvh" ) ) != EOF )
+ while ( ( c = Extra_UtilGetopt( argc, argv, "KCFADEqaflepmrsdbvh" ) ) != EOF )
{
switch ( c )
{
case 'K':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-K\" should be followed by a positive integer.\n" );
+ Abc_Print( -1, "Command line switch \"-K\" should be followed by a positive integer.\n" );
goto usage;
}
pPars->nLutSize = atoi(argv[globalUtilOptind]);
@@ -19861,7 +20226,7 @@ int Abc_CommandAbc8If( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-C\" should be followed by a positive integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by a positive integer.\n" );
goto usage;
}
pPars->nCutsMax = atoi(argv[globalUtilOptind]);
@@ -19872,7 +20237,7 @@ int Abc_CommandAbc8If( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-F\" should be followed by a positive integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by a positive integer.\n" );
goto usage;
}
pPars->nFlowIters = atoi(argv[globalUtilOptind]);
@@ -19883,7 +20248,7 @@ int Abc_CommandAbc8If( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'A':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-A\" should be followed by a positive integer.\n" );
+ Abc_Print( -1, "Command line switch \"-A\" should be followed by a positive integer.\n" );
goto usage;
}
pPars->nAreaIters = atoi(argv[globalUtilOptind]);
@@ -19894,7 +20259,7 @@ int Abc_CommandAbc8If( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'D':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-D\" should be followed by a floating point number.\n" );
+ Abc_Print( -1, "Command line switch \"-D\" should be followed by a floating point number.\n" );
goto usage;
}
pPars->DelayTarget = (float)atof(argv[globalUtilOptind]);
@@ -19905,7 +20270,7 @@ int Abc_CommandAbc8If( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'E':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-E\" should be followed by a floating point number.\n" );
+ Abc_Print( -1, "Command line switch \"-E\" should be followed by a floating point number.\n" );
goto usage;
}
pPars->Epsilon = (float)atof(argv[globalUtilOptind]);
@@ -19940,11 +20305,11 @@ int Abc_CommandAbc8If( Abc_Frame_t * pAbc, int argc, char ** argv )
case 's':
pPars->fSeqMap ^= 1;
break;
- case 't':
- pPars->fLiftLeaves ^= 1;
+ case 'd':
+ pPars->fBidec ^= 1;
break;
case 'b':
- pPars->fBidec ^= 1;
+ pPars->fUseBat ^= 1;
break;
case 'v':
pPars->fVerbose ^= 1;
@@ -19956,28 +20321,39 @@ int Abc_CommandAbc8If( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pAbc->pAbc8Aig == NULL )
{
- printf( "Abc_CommandAbc8If(): There is no AIG to map.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8If(): There is no AIG to map.\n" );
return 1;
}
if ( pPars->nLutSize < 3 || pPars->nLutSize > IF_MAX_LUTSIZE )
{
- fprintf( stdout, "Incorrect LUT size (%d).\n", pPars->nLutSize );
+ Abc_Print( -1, "Incorrect LUT size (%d).\n", pPars->nLutSize );
return 1;
}
if ( pPars->nCutsMax < 1 || pPars->nCutsMax >= (1<<12) )
{
- fprintf( stdout, "Incorrect number of cuts.\n" );
+ Abc_Print( -1, "Incorrect number of cuts.\n" );
return 1;
}
// enable truth table computation if choices are selected
if ( (c = Aig_ManChoiceNum( pAbc->pAbc8Aig )) )
{
-// printf( "Performing LUT mapping with %d choices.\n", c );
+// Abc_Print( 0, "Performing LUT mapping with %d choices.\n", c );
pPars->fExpRed = 0;
}
+
+ if ( pPars->fUseBat )
+ {
+ if ( pPars->nLutSize < 4 || pPars->nLutSize > 6 )
+ {
+ Abc_Print( -1, "This feature only works for {4,5,6}-LUTs.\n" );
+ return 1;
+ }
+ pPars->fCutMin = 1;
+ }
+
// enable truth table computation if cut minimization is selected
if ( pPars->fCutMin )
{
@@ -19988,14 +20364,14 @@ int Abc_CommandAbc8If( Abc_Frame_t * pAbc, int argc, char ** argv )
// complain if truth tables are requested but the cut size is too large
if ( pPars->fTruth && pPars->nLutSize > IF_MAX_FUNC_LUTSIZE )
{
- fprintf( stdout, "Truth tables cannot be computed for LUT larger than %d inputs.\n", IF_MAX_FUNC_LUTSIZE );
+ Abc_Print( -1, "Truth tables cannot be computed for LUT larger than %d inputs.\n", IF_MAX_FUNC_LUTSIZE );
return 1;
}
pNtkNew = Nwk_MappingIf( pAbc->pAbc8Aig, Ntl_ManReadTimeMan(pAbc->pAbc8Ntl), pPars );
if ( pNtkNew == NULL )
{
- printf( "Abc_CommandAbc8If(): Mapping of the AIG has failed.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8If(): Mapping of the AIG has failed.\n" );
return 1;
}
if ( pAbc->pAbc8Nwk != NULL )
@@ -20012,27 +20388,27 @@ usage:
sprintf( LutSize, "library" );
else
sprintf( LutSize, "%d", pPars->nLutSize );
- fprintf( stdout, "usage: *if [-KCFA num] [-DE float] [-qarlepmbvh]\n" );
- fprintf( stdout, "\t performs FPGA technology mapping of the network\n" );
- fprintf( stdout, "\t-K num : the number of LUT inputs (2 < num < %d) [default = %s]\n", IF_MAX_LUTSIZE+1, LutSize );
- fprintf( stdout, "\t-C num : the max number of priority cuts (0 < num < 2^12) [default = %d]\n", pPars->nCutsMax );
- fprintf( stdout, "\t-F num : the number of area flow recovery iterations (num >= 0) [default = %d]\n", pPars->nFlowIters );
- fprintf( stdout, "\t-A num : the number of exact area recovery iterations (num >= 0) [default = %d]\n", pPars->nAreaIters );
- fprintf( stdout, "\t-D float : sets the delay constraint for the mapping [default = %s]\n", Buffer );
- fprintf( stdout, "\t-E float : sets epsilon used for tie-breaking [default = %f]\n", pPars->Epsilon );
- fprintf( stdout, "\t-q : toggles preprocessing using several starting points [default = %s]\n", pPars->fPreprocess? "yes": "no" );
- fprintf( stdout, "\t-a : toggles area-oriented mapping [default = %s]\n", pPars->fArea? "yes": "no" );
-// fprintf( stdout, "\t-f : toggles one fancy feature [default = %s]\n", pPars->fFancy? "yes": "no" );
- fprintf( stdout, "\t-r : enables expansion/reduction of the best cuts [default = %s]\n", pPars->fExpRed? "yes": "no" );
- fprintf( stdout, "\t-l : optimizes latch paths for delay, other paths for area [default = %s]\n", pPars->fLatchPaths? "yes": "no" );
- fprintf( stdout, "\t-e : uses edge-based cut selection heuristics [default = %s]\n", pPars->fEdge? "yes": "no" );
- fprintf( stdout, "\t-p : uses power-aware cut selection heuristics [default = %s]\n", pPars->fPower? "yes": "no" );
- fprintf( stdout, "\t-m : enables cut minimization by removing vacuous variables [default = %s]\n", pPars->fCutMin? "yes": "no" );
-// fprintf( stdout, "\t-s : toggles sequential mapping [default = %s]\n", pPars->fSeqMap? "yes": "no" );
-// fprintf( stdout, "\t-t : toggles the use of true sequential cuts [default = %s]\n", pPars->fLiftLeaves? "yes": "no" );
- fprintf( stdout, "\t-b : toggles deriving local AIGs using bi-decomposition [default = %s]\n", pPars->fBidec? "yes": "no" );
- fprintf( stdout, "\t-v : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : prints the command usage\n");
+ Abc_Print( -2, "usage: *if [-KCFA num] [-DE float] [-qarlepmdbvh]\n" );
+ Abc_Print( -2, "\t performs FPGA technology mapping of the network\n" );
+ Abc_Print( -2, "\t-K num : the number of LUT inputs (2 < num < %d) [default = %s]\n", IF_MAX_LUTSIZE+1, LutSize );
+ Abc_Print( -2, "\t-C num : the max number of priority cuts (0 < num < 2^12) [default = %d]\n", pPars->nCutsMax );
+ Abc_Print( -2, "\t-F num : the number of area flow recovery iterations (num >= 0) [default = %d]\n", pPars->nFlowIters );
+ Abc_Print( -2, "\t-A num : the number of exact area recovery iterations (num >= 0) [default = %d]\n", pPars->nAreaIters );
+ Abc_Print( -2, "\t-D float : sets the delay constraint for the mapping [default = %s]\n", Buffer );
+ Abc_Print( -2, "\t-E float : sets epsilon used for tie-breaking [default = %f]\n", pPars->Epsilon );
+ Abc_Print( -2, "\t-q : toggles preprocessing using several starting points [default = %s]\n", pPars->fPreprocess? "yes": "no" );
+ Abc_Print( -2, "\t-a : toggles area-oriented mapping [default = %s]\n", pPars->fArea? "yes": "no" );
+// Abc_Print( -2, "\t-f : toggles one fancy feature [default = %s]\n", pPars->fFancy? "yes": "no" );
+ Abc_Print( -2, "\t-r : enables expansion/reduction of the best cuts [default = %s]\n", pPars->fExpRed? "yes": "no" );
+ Abc_Print( -2, "\t-l : optimizes latch paths for delay, other paths for area [default = %s]\n", pPars->fLatchPaths? "yes": "no" );
+ Abc_Print( -2, "\t-e : uses edge-based cut selection heuristics [default = %s]\n", pPars->fEdge? "yes": "no" );
+ Abc_Print( -2, "\t-p : uses power-aware cut selection heuristics [default = %s]\n", pPars->fPower? "yes": "no" );
+ Abc_Print( -2, "\t-m : enables cut minimization by removing vacuous variables [default = %s]\n", pPars->fCutMin? "yes": "no" );
+// Abc_Print( -2, "\t-s : toggles sequential mapping [default = %s]\n", pPars->fSeqMap? "yes": "no" );
+ Abc_Print( -2, "\t-d : toggles deriving local AIGs using bi-decomposition [default = %s]\n", pPars->fBidec? "yes": "no" );
+ Abc_Print( -2, "\t-b : toggles the use of one special feature [default = %s]\n", pPars->fUseBat? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : prints the command usage\n");
return 1;
}
@@ -20070,7 +20446,7 @@ int Abc_CommandAbc8DChoice( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
nConfMax = atoi(argv[globalUtilOptind]);
@@ -20081,7 +20457,7 @@ int Abc_CommandAbc8DChoice( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'L':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-L\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
goto usage;
}
nLevelMax = atoi(argv[globalUtilOptind]);
@@ -20109,7 +20485,7 @@ int Abc_CommandAbc8DChoice( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pAbc->pAbc8Aig == NULL )
{
- printf( "Abc_CommandAbc8DChoice(): There is no AIG to synthesize.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8DChoice(): There is no AIG to synthesize.\n" );
return 1;
}
@@ -20117,7 +20493,7 @@ int Abc_CommandAbc8DChoice( Abc_Frame_t * pAbc, int argc, char ** argv )
pAigNew = Ntl_ManPerformChoicing( pAbc->pAbc8Aig, fBalance, fUpdateLevel, fConstruct, nConfMax, nLevelMax, fVerbose );
if ( pAigNew == NULL )
{
- printf( "Abc_CommandAbc8DChoice(): Tranformation of the AIG has failed.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8DChoice(): Tranformation has failed.\n" );
return 1;
}
Aig_ManStop( pAbc->pAbc8Aig );
@@ -20125,15 +20501,15 @@ int Abc_CommandAbc8DChoice( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( stdout, "usage: *dchoice [-C num] [-L num] [-blcvh]\n" );
- fprintf( stdout, "\t performs AIG-based synthesis and derives choices\n" );
- fprintf( stdout, "\t-C num : the max number of conflicts at a node [default = %d]\n", nConfMax );
- fprintf( stdout, "\t-L num : the max level of nodes to consider (0 = not used) [default = %d]\n", nLevelMax );
- fprintf( stdout, "\t-b : toggle internal balancing [default = %s]\n", fBalance? "yes": "no" );
- fprintf( stdout, "\t-l : toggle updating level [default = %s]\n", fUpdateLevel? "yes": "no" );
- fprintf( stdout, "\t-c : toggle constructive computation of choices [default = %s]\n", fConstruct? "yes": "no" );
- fprintf( stdout, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: *dchoice [-C num] [-L num] [-blcvh]\n" );
+ Abc_Print( -2, "\t performs AIG-based synthesis and derives choices\n" );
+ Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", nConfMax );
+ Abc_Print( -2, "\t-L num : the max level of nodes to consider (0 = not used) [default = %d]\n", nLevelMax );
+ Abc_Print( -2, "\t-b : toggle internal balancing [default = %s]\n", fBalance? "yes": "no" );
+ Abc_Print( -2, "\t-l : toggle updating level [default = %s]\n", fUpdateLevel? "yes": "no" );
+ Abc_Print( -2, "\t-c : toggle constructive computation of choices [default = %s]\n", fConstruct? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -20165,7 +20541,7 @@ int Abc_CommandAbc8Dch( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'W':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-W\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
goto usage;
}
pPars->nWords = atoi(argv[globalUtilOptind]);
@@ -20176,7 +20552,7 @@ int Abc_CommandAbc8Dch( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
pPars->nBTLimit = atoi(argv[globalUtilOptind]);
@@ -20187,7 +20563,7 @@ int Abc_CommandAbc8Dch( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'S':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-S\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
goto usage;
}
pPars->nSatVarMax = atoi(argv[globalUtilOptind]);
@@ -20218,7 +20594,7 @@ int Abc_CommandAbc8Dch( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pAbc->pAbc8Aig == NULL )
{
- printf( "Abc_CommandAbc8Dch(): There is no AIG to synthesize.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Dch(): There is no AIG to synthesize.\n" );
return 1;
}
@@ -20226,7 +20602,7 @@ int Abc_CommandAbc8Dch( Abc_Frame_t * pAbc, int argc, char ** argv )
pAigNew = Ntl_ManPerformChoicingNew( pAbc->pAbc8Aig, pPars );
if ( pAigNew == NULL )
{
- printf( "Abc_CommandAbc8Dch(): Tranformation of the AIG has failed.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Dch(): Tranformation has failed.\n" );
return 1;
}
// Aig_ManStop( pAbc->pAbc8Aig );
@@ -20234,17 +20610,17 @@ int Abc_CommandAbc8Dch( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( stdout, "usage: *dch [-WCS num] [-sptfvh]\n" );
- fprintf( stdout, "\t computes structural choices using a new approach\n" );
- fprintf( stdout, "\t-W num : the max number of simulation words [default = %d]\n", pPars->nWords );
- fprintf( stdout, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
- fprintf( stdout, "\t-S num : the max number of SAT variables [default = %d]\n", pPars->nSatVarMax );
- fprintf( stdout, "\t-s : toggle synthesizing three snapshots [default = %s]\n", pPars->fSynthesis? "yes": "no" );
- fprintf( stdout, "\t-p : toggle power-aware rewriting [default = %s]\n", pPars->fPower? "yes": "no" );
- fprintf( stdout, "\t-t : toggle simulation of the TFO classes [default = %s]\n", pPars->fSimulateTfo? "yes": "no" );
- fprintf( stdout, "\t-f : toggle using lighter logic synthesis [default = %s]\n", pPars->fLightSynth? "yes": "no" );
- fprintf( stdout, "\t-v : toggle verbose printout [default = %s]\n", pPars->fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: *dch [-WCS num] [-sptfvh]\n" );
+ Abc_Print( -2, "\t computes structural choices using a new approach\n" );
+ Abc_Print( -2, "\t-W num : the max number of simulation words [default = %d]\n", pPars->nWords );
+ Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
+ Abc_Print( -2, "\t-S num : the max number of SAT variables [default = %d]\n", pPars->nSatVarMax );
+ Abc_Print( -2, "\t-s : toggle synthesizing three snapshots [default = %s]\n", pPars->fSynthesis? "yes": "no" );
+ Abc_Print( -2, "\t-p : toggle power-aware rewriting [default = %s]\n", pPars->fPower? "yes": "no" );
+ Abc_Print( -2, "\t-t : toggle simulation of the TFO classes [default = %s]\n", pPars->fSimulateTfo? "yes": "no" );
+ Abc_Print( -2, "\t-f : toggle using lighter logic synthesis [default = %s]\n", pPars->fLightSynth? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -20259,7 +20635,7 @@ usage:
SeeAlso []
***********************************************************************/
-int Abc_CommandAbc8DC2( Abc_Frame_t * pAbc, int argc, char ** argv )
+int Abc_CommandAbc8Dc2( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Aig_Man_t * pAigNew;
int c;
@@ -20300,7 +20676,7 @@ int Abc_CommandAbc8DC2( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pAbc->pAbc8Aig == NULL )
{
- printf( "Abc_CommandAbc8DC2(): There is no AIG to synthesize.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Dc2(): There is no AIG to synthesize.\n" );
return 1;
}
@@ -20308,7 +20684,7 @@ int Abc_CommandAbc8DC2( Abc_Frame_t * pAbc, int argc, char ** argv )
pAigNew = Dar_ManCompress2( pAbc->pAbc8Aig, fBalance, fUpdateLevel, 1, fPower, fVerbose );
if ( pAigNew == NULL )
{
- printf( "Abc_CommandAbc8DC2(): Tranformation of the AIG has failed.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Dc2(): Tranformation has failed.\n" );
return 1;
}
Aig_ManStop( pAbc->pAbc8Aig );
@@ -20316,13 +20692,13 @@ int Abc_CommandAbc8DC2( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( stdout, "usage: *dc2 [-blpvh]\n" );
- fprintf( stdout, "\t performs AIG-based synthesis without deriving choices\n" );
- fprintf( stdout, "\t-b : toggle internal balancing [default = %s]\n", fBalance? "yes": "no" );
- fprintf( stdout, "\t-l : toggle updating level [default = %s]\n", fUpdateLevel? "yes": "no" );
- fprintf( stdout, "\t-p : toggle power-aware rewriting [default = %s]\n", fPower? "yes": "no" );
- fprintf( stdout, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: *dc2 [-blpvh]\n" );
+ Abc_Print( -2, "\t performs AIG-based synthesis without deriving choices\n" );
+ Abc_Print( -2, "\t-b : toggle internal balancing [default = %s]\n", fBalance? "yes": "no" );
+ Abc_Print( -2, "\t-l : toggle updating level [default = %s]\n", fUpdateLevel? "yes": "no" );
+ Abc_Print( -2, "\t-p : toggle power-aware rewriting [default = %s]\n", fPower? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -20341,7 +20717,6 @@ usage:
int Abc_CommandAbc8Bidec( Abc_Frame_t * pAbc, int argc, char ** argv )
{
int c;
- extern void Nwk_ManBidecResyn( void * pNtk, int fVerbose );
// set defaults
Extra_UtilGetoptReset();
@@ -20357,16 +20732,16 @@ int Abc_CommandAbc8Bidec( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pAbc->pAbc8Nwk == NULL )
{
- printf( "Abc_CommandAbc8Bidec(): There is no mapped network to strash.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Bidec(): There is no mapped network to strash.\n" );
return 1;
}
Nwk_ManBidecResyn( pAbc->pAbc8Nwk, 0 );
return 0;
usage:
- fprintf( stdout, "usage: *bidec [-h]\n" );
- fprintf( stdout, "\t performs bi-decomposition of local functions\n" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: *bidec [-h]\n" );
+ Abc_Print( -2, "\t performs bi-decomposition of local functions\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -20385,7 +20760,6 @@ int Abc_CommandAbc8Strash( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Aig_Man_t * pAigNew;
int c;
- extern Aig_Man_t * Nwk_ManStrash( void * pNtk );
// set defaults
Extra_UtilGetoptReset();
@@ -20401,14 +20775,14 @@ int Abc_CommandAbc8Strash( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pAbc->pAbc8Nwk == NULL )
{
- printf( "Abc_CommandAbc8Strash(): There is no mapped network to strash.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Strash(): There is no mapped network to strash.\n" );
return 1;
}
pAigNew = Nwk_ManStrash( pAbc->pAbc8Nwk );
if ( pAigNew == NULL )
{
- printf( "Abc_CommandAbc8Strash(): Tranformation of the AIG has failed.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Strash(): Tranformation has failed.\n" );
return 1;
}
Aig_ManStop( pAbc->pAbc8Aig );
@@ -20416,9 +20790,9 @@ int Abc_CommandAbc8Strash( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( stdout, "usage: *st [-h]\n" );
- fprintf( stdout, "\t performs structural hashing of mapped network\n" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: *st [-h]\n" );
+ Abc_Print( -2, "\t performs structural hashing of mapped network\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -20438,7 +20812,7 @@ int Abc_CommandAbc8Mfs( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Mfx_Par_t Pars, * pPars = &Pars;
int c;
- extern int Mfx_Perform( void * pNtk, Mfx_Par_t * pPars, If_Lib_t * pLutLib );
+// extern int Mfx_Perform( void * pNtk, Mfx_Par_t * pPars, If_Lib_t * pLutLib );
// set defaults
Mfx_ParsDefault( pPars );
@@ -20450,7 +20824,7 @@ int Abc_CommandAbc8Mfs( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'W':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-W\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
goto usage;
}
pPars->nWinTfoLevs = atoi(argv[globalUtilOptind]);
@@ -20461,7 +20835,7 @@ int Abc_CommandAbc8Mfs( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-F\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
pPars->nFanoutsMax = atoi(argv[globalUtilOptind]);
@@ -20472,7 +20846,7 @@ int Abc_CommandAbc8Mfs( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'D':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-D\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
goto usage;
}
pPars->nDepthMax = atoi(argv[globalUtilOptind]);
@@ -20483,7 +20857,7 @@ int Abc_CommandAbc8Mfs( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'M':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-M\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
goto usage;
}
pPars->nWinSizeMax = atoi(argv[globalUtilOptind]);
@@ -20494,7 +20868,7 @@ int Abc_CommandAbc8Mfs( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'L':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-L\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
goto usage;
}
pPars->nGrowthLevel = atoi(argv[globalUtilOptind]);
@@ -20505,7 +20879,7 @@ int Abc_CommandAbc8Mfs( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
pPars->nBTLimit = atoi(argv[globalUtilOptind]);
@@ -20542,18 +20916,18 @@ int Abc_CommandAbc8Mfs( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pAbc->pAbc8Nwk == NULL )
{
- printf( "Abc_CommandAbc8Mfs(): There is no mapped network.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Mfs(): There is no mapped network.\n" );
return 1;
}
if ( pAbc->pAbc8Lib == NULL )
{
- printf( "Abc_CommandAbc8Mfs(): There is no LUT library.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Mfs(): There is no LUT library.\n" );
return 1;
}
if ( If_LutLibDelaysAreDifferent(pAbc->pAbc8Lib) )
{
- printf( "Abc_CommandAbc8Mfs(): Cannot perform don't-care simplication with variable-pin-delay LUT model.\n" );
- printf( "The delay model should be fixed-pin-delay, for example, the delay of all pins of all LUTs is 0.4.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Mfs(): Cannot perform don't-care simplication with variable-pin-delay LUT model.\n" );
+ Abc_Print( -1, "The delay model should be fixed-pin-delay, for example, the delay of all pins of all LUTs is 0.4.\n" );
return 1;
}
@@ -20561,28 +20935,28 @@ int Abc_CommandAbc8Mfs( Abc_Frame_t * pAbc, int argc, char ** argv )
// modify the current network
if ( !Mfx_Perform( pAbc->pAbc8Nwk, pPars, pAbc->pAbc8Lib ) )
{
- fprintf( stdout, "Abc_CommandAbc8Mfs(): Command has failed.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Mfs(): Command has failed.\n" );
return 1;
}
return 0;
usage:
- fprintf( stdout, "usage: *mfs [-WFDMLC <num>] [-raespvh]\n" );
- fprintf( stdout, "\t performs don't-care-based optimization of logic networks\n" );
- fprintf( stdout, "\t-W <num> : the number of levels in the TFO cone (0 <= num) [default = %d]\n", pPars->nWinTfoLevs );
- fprintf( stdout, "\t-F <num> : the max number of fanouts to skip (1 <= num) [default = %d]\n", pPars->nFanoutsMax );
- fprintf( stdout, "\t-D <num> : the max depth nodes to try (0 = no limit) [default = %d]\n", pPars->nDepthMax );
- fprintf( stdout, "\t-M <num> : the max node count of windows to consider (0 = no limit) [default = %d]\n", pPars->nWinSizeMax );
- fprintf( stdout, "\t-L <num> : the max increase in node level after resynthesis (0 <= num) [default = %d]\n", pPars->nGrowthLevel );
- fprintf( stdout, "\t-C <num> : the max number of conflicts in one SAT run (0 = no limit) [default = %d]\n", pPars->nBTLimit );
- fprintf( stdout, "\t-r : toggle resubstitution and dc-minimization [default = %s]\n", pPars->fResub? "resub": "dc-min" );
- fprintf( stdout, "\t-a : toggle minimizing area or area+edges [default = %s]\n", pPars->fArea? "area": "area+edges" );
- fprintf( stdout, "\t-e : toggle high-effort resubstitution [default = %s]\n", pPars->fMoreEffort? "yes": "no" );
- fprintf( stdout, "\t-s : toggle evaluation of edge swapping [default = %s]\n", pPars->fSwapEdge? "yes": "no" );
- fprintf( stdout, "\t-p : toggle power-aware optimization [default = %s]\n", pPars->fPower? "yes": "no" );
- fprintf( stdout, "\t-v : toggle printing optimization summary [default = %s]\n", pPars->fVerbose? "yes": "no" );
- fprintf( stdout, "\t-w : toggle printing detailed stats for each node [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: *mfs [-WFDMLC <num>] [-raespvh]\n" );
+ Abc_Print( -2, "\t performs don't-care-based optimization of logic networks\n" );
+ Abc_Print( -2, "\t-W <num> : the number of levels in the TFO cone (0 <= num) [default = %d]\n", pPars->nWinTfoLevs );
+ Abc_Print( -2, "\t-F <num> : the max number of fanouts to skip (1 <= num) [default = %d]\n", pPars->nFanoutsMax );
+ Abc_Print( -2, "\t-D <num> : the max depth nodes to try (0 = no limit) [default = %d]\n", pPars->nDepthMax );
+ Abc_Print( -2, "\t-M <num> : the max node count of windows to consider (0 = no limit) [default = %d]\n", pPars->nWinSizeMax );
+ Abc_Print( -2, "\t-L <num> : the max increase in node level after resynthesis (0 <= num) [default = %d]\n", pPars->nGrowthLevel );
+ Abc_Print( -2, "\t-C <num> : the max number of conflicts in one SAT run (0 = no limit) [default = %d]\n", pPars->nBTLimit );
+ Abc_Print( -2, "\t-r : toggle resubstitution and dc-minimization [default = %s]\n", pPars->fResub? "resub": "dc-min" );
+ Abc_Print( -2, "\t-a : toggle minimizing area or area+edges [default = %s]\n", pPars->fArea? "area": "area+edges" );
+ Abc_Print( -2, "\t-e : toggle high-effort resubstitution [default = %s]\n", pPars->fMoreEffort? "yes": "no" );
+ Abc_Print( -2, "\t-s : toggle evaluation of edge swapping [default = %s]\n", pPars->fSwapEdge? "yes": "no" );
+ Abc_Print( -2, "\t-p : toggle power-aware optimization [default = %s]\n", pPars->fPower? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle printing optimization summary [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-w : toggle printing detailed stats for each node [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -20601,7 +20975,7 @@ int Abc_CommandAbc8Lutpack( Abc_Frame_t * pAbc, int argc, char ** argv )
{
int c;
- printf( "This command is temporarily disabled.\n" );
+ Abc_Print( -1, "This command is temporarily disabled.\n" );
return 0;
// set defaults
@@ -20618,7 +20992,7 @@ int Abc_CommandAbc8Lutpack( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pAbc->pAbc8Nwk == NULL )
{
- printf( "Abc_CommandAbc8Lutpack(): There is no mapped network to strash.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Lutpack(): There is no mapped network to strash.\n" );
return 1;
}
@@ -20626,23 +21000,23 @@ int Abc_CommandAbc8Lutpack( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
/*
- fprintf( stdout, "usage: *lp [-h]\n" );
- fprintf( stdout, "usage: lutpack [-N <num>] [-Q <num>] [-S <num>] [-L <num>] [-szfovwh]\n" );
- fprintf( stdout, "\t performs \"rewriting\" for LUT network;\n" );
- fprintf( stdout, "\t determines LUT size as the max fanin count of a node;\n" );
- fprintf( stdout, "\t if the network is not LUT-mapped, packs it into 6-LUTs\n" );
- fprintf( stdout, "\t (there is another command for resynthesis after LUT mapping, \"imfs\")\n" );
- fprintf( stdout, "\t-N <num> : the max number of LUTs in the structure (2 <= num) [default = %d]\n", pPars->nLutsMax );
- fprintf( stdout, "\t-Q <num> : the max number of LUTs not in MFFC (0 <= num) [default = %d]\n", pPars->nLutsOver );
- fprintf( stdout, "\t-S <num> : the max number of LUT inputs shared (0 <= num <= 3) [default = %d]\n", pPars->nVarsShared );
- fprintf( stdout, "\t-L <num> : max level increase after resynthesis (0 <= num) [default = %d]\n", pPars->nGrowthLevel );
- fprintf( stdout, "\t-s : toggle iteration till saturation [default = %s]\n", pPars->fSatur? "yes": "no" );
- fprintf( stdout, "\t-z : toggle zero-cost replacements [default = %s]\n", pPars->fZeroCost? "yes": "no" );
- fprintf( stdout, "\t-f : toggle using only first node and first cut [default = %s]\n", pPars->fFirst? "yes": "no" );
- fprintf( stdout, "\t-o : toggle using old implementation [default = %s]\n", pPars->fOldAlgo? "yes": "no" );
- fprintf( stdout, "\t-v : toggle verbose printout [default = %s]\n", pPars->fVerbose? "yes": "no" );
- fprintf( stdout, "\t-w : toggle detailed printout of decomposed functions [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: *lp [-h]\n" );
+ Abc_Print( -2, "usage: lutpack [-N <num>] [-Q <num>] [-S <num>] [-L <num>] [-szfovwh]\n" );
+ Abc_Print( -2, "\t performs \"rewriting\" for LUT network;\n" );
+ Abc_Print( -2, "\t determines LUT size as the max fanin count of a node;\n" );
+ Abc_Print( -2, "\t if the network is not LUT-mapped, packs it into 6-LUTs\n" );
+ Abc_Print( -2, "\t (there is another command for resynthesis after LUT mapping, \"imfs\")\n" );
+ Abc_Print( -2, "\t-N <num> : the max number of LUTs in the structure (2 <= num) [default = %d]\n", pPars->nLutsMax );
+ Abc_Print( -2, "\t-Q <num> : the max number of LUTs not in MFFC (0 <= num) [default = %d]\n", pPars->nLutsOver );
+ Abc_Print( -2, "\t-S <num> : the max number of LUT inputs shared (0 <= num <= 3) [default = %d]\n", pPars->nVarsShared );
+ Abc_Print( -2, "\t-L <num> : max level increase after resynthesis (0 <= num) [default = %d]\n", pPars->nGrowthLevel );
+ Abc_Print( -2, "\t-s : toggle iteration till saturation [default = %s]\n", pPars->fSatur? "yes": "no" );
+ Abc_Print( -2, "\t-z : toggle zero-cost replacements [default = %s]\n", pPars->fZeroCost? "yes": "no" );
+ Abc_Print( -2, "\t-f : toggle using only first node and first cut [default = %s]\n", pPars->fFirst? "yes": "no" );
+ Abc_Print( -2, "\t-o : toggle using old implementation [default = %s]\n", pPars->fOldAlgo? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-w : toggle detailed printout of decomposed functions [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
*/
return 1;
}
@@ -20693,7 +21067,7 @@ int Abc_CommandAbc8Balance( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pAbc->pAbc8Aig == NULL )
{
- printf( "Abc_CommandAbc8Balance(): There is no AIG to synthesize.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Balance(): There is no AIG to synthesize.\n" );
return 1;
}
@@ -20701,7 +21075,7 @@ int Abc_CommandAbc8Balance( Abc_Frame_t * pAbc, int argc, char ** argv )
pAigNew = Dar_ManBalanceXor( pAbc->pAbc8Aig, fExor, fUpdateLevel, fVerbose );
if ( pAigNew == NULL )
{
- printf( "Abc_CommandAbc8Balance(): Tranformation of the AIG has failed.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Balance(): Tranformation has failed.\n" );
return 1;
}
Aig_ManStop( pAbc->pAbc8Aig );
@@ -20709,12 +21083,12 @@ int Abc_CommandAbc8Balance( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( stdout, "usage: *b [-xlvh]\n" );
- fprintf( stdout, "\t performs balanacing of the AIG\n" );
- fprintf( stdout, "\t-x : toggle using XOR-balancing [default = %s]\n", fExor? "yes": "no" );
- fprintf( stdout, "\t-l : toggle updating level [default = %s]\n", fUpdateLevel? "yes": "no" );
- fprintf( stdout, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: *b [-xlvh]\n" );
+ Abc_Print( -2, "\t performs balancing of the AIG\n" );
+ Abc_Print( -2, "\t-x : toggle using XOR-balancing [default = %s]\n", fExor? "yes": "no" );
+ Abc_Print( -2, "\t-l : toggle updating level [default = %s]\n", fUpdateLevel? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -20738,7 +21112,6 @@ int Abc_CommandAbc8Speedup( Abc_Frame_t * pAbc, int argc, char ** argv )
int Degree = 5;
int fVerbose = 0;
int fVeryVerbose = 0;
- extern Aig_Man_t * Nwk_ManSpeedup( void * pNtk, int fUseLutLib, int Percentage, int Degree, int fVerbose, int fVeryVerbose );
// set defaults
fUseLutLib = 0;
@@ -20754,7 +21127,7 @@ int Abc_CommandAbc8Speedup( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'P':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-P\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
goto usage;
}
Percentage = atoi(argv[globalUtilOptind]);
@@ -20765,7 +21138,7 @@ int Abc_CommandAbc8Speedup( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'N':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-N\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
goto usage;
}
Degree = atoi(argv[globalUtilOptind]);
@@ -20790,14 +21163,14 @@ int Abc_CommandAbc8Speedup( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pAbc->pAbc8Nwk == NULL )
{
- printf( "Abc_CommandAbc8Speedup(): There is no mapped network to strash.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Speedup(): There is no mapped network to strash.\n" );
return 1;
}
pAigNew = Nwk_ManSpeedup( pAbc->pAbc8Nwk, fUseLutLib, Percentage, Degree, fVerbose, fVeryVerbose );
if ( pAigNew == NULL )
{
- printf( "Abc_CommandAbc8Speedup(): Tranformation of the AIG has failed.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Speedup(): Tranformation has failed.\n" );
return 1;
}
Aig_ManStop( pAbc->pAbc8Aig );
@@ -20805,15 +21178,15 @@ int Abc_CommandAbc8Speedup( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( stdout, "usage: *speedup [-P num] [-N num] [-lvwh]\n" );
- fprintf( stdout, "\t transforms LUT-mapped network into an AIG with choices;\n" );
- fprintf( stdout, "\t the choices are added to speedup the next round of mapping\n" );
- fprintf( stdout, "\t-P <num> : delay delta defining critical path for library model [default = %d%%]\n", Percentage );
- fprintf( stdout, "\t-N <num> : the max critical path degree for resynthesis (0 < num < 6) [default = %d]\n", Degree );
- fprintf( stdout, "\t-l : toggle using unit- or LUT-library-delay model [default = %s]\n", fUseLutLib? "lib" : "unit" );
- fprintf( stdout, "\t-v : toggle printing optimization summary [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( stdout, "\t-w : toggle printing detailed stats for each node [default = %s]\n", fVeryVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: *speedup [-P num] [-N num] [-lvwh]\n" );
+ Abc_Print( -2, "\t transforms LUT-mapped network into an AIG with choices;\n" );
+ Abc_Print( -2, "\t the choices are added to speedup the next round of mapping\n" );
+ Abc_Print( -2, "\t-P <num> : delay delta defining critical path for library model [default = %d%%]\n", Percentage );
+ Abc_Print( -2, "\t-N <num> : the max critical path degree for resynthesis (0 < num < 6) [default = %d]\n", Degree );
+ Abc_Print( -2, "\t-l : toggle using unit- or LUT-library-delay model [default = %s]\n", fUseLutLib? "lib" : "unit" );
+ Abc_Print( -2, "\t-v : toggle printing optimization summary [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-w : toggle printing detailed stats for each node [default = %s]\n", fVeryVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -20833,7 +21206,6 @@ int Abc_CommandAbc8Merge( Abc_Frame_t * pAbc, int argc, char ** argv )
Nwk_LMPars_t Pars, * pPars = &Pars;
Vec_Int_t * vResult;
int c;
- extern Vec_Int_t * Nwk_ManLutMerge( void * pNtk, Nwk_LMPars_t * pPars );
// set defaults
memset( pPars, 0, sizeof(Nwk_LMPars_t) );
@@ -20854,7 +21226,7 @@ int Abc_CommandAbc8Merge( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'N':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-N\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
goto usage;
}
pPars->nMaxLutSize = atoi(argv[globalUtilOptind]);
@@ -20865,7 +21237,7 @@ int Abc_CommandAbc8Merge( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'S':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-S\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
goto usage;
}
pPars->nMaxSuppSize = atoi(argv[globalUtilOptind]);
@@ -20876,7 +21248,7 @@ int Abc_CommandAbc8Merge( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'D':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-D\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
goto usage;
}
pPars->nMaxDistance = atoi(argv[globalUtilOptind]);
@@ -20887,7 +21259,7 @@ int Abc_CommandAbc8Merge( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'L':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-L\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
goto usage;
}
pPars->nMaxLevelDiff = atoi(argv[globalUtilOptind]);
@@ -20898,7 +21270,7 @@ int Abc_CommandAbc8Merge( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-F\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
pPars->nMaxFanout = atoi(argv[globalUtilOptind]);
@@ -20926,7 +21298,7 @@ int Abc_CommandAbc8Merge( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pAbc->pAbc8Nwk == NULL )
{
- printf( "Abc_CommandAbc8Speedup(): There is no mapped network to merge LUTs.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Speedup(): There is no mapped network to merge LUTs.\n" );
return 1;
}
@@ -20935,18 +21307,18 @@ int Abc_CommandAbc8Merge( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( stdout, "usage: *merge [-NSDLF num] [-scwvh]\n" );
- fprintf( stdout, "\t creates pairs of topologically-related LUTs\n" );
- fprintf( stdout, "\t-N <num> : the max LUT size for merging (1 < num) [default = %d]\n", pPars->nMaxLutSize );
- fprintf( stdout, "\t-S <num> : the max total support size after merging (1 < num) [default = %d]\n", pPars->nMaxSuppSize );
- fprintf( stdout, "\t-D <num> : the max distance in terms of LUTs (0 < num) [default = %d]\n", pPars->nMaxDistance );
- fprintf( stdout, "\t-L <num> : the max difference in levels (0 <= num) [default = %d]\n", pPars->nMaxLevelDiff );
- fprintf( stdout, "\t-F <num> : the max number of fanouts to stop traversal (0 < num) [default = %d]\n", pPars->nMaxFanout );
- fprintf( stdout, "\t-s : toggle the use of nodes without support overlap [default = %s]\n", pPars->fUseDiffSupp? "yes" : "no" );
- fprintf( stdout, "\t-c : toggle the use of TFI/TFO nodes as candidates [default = %s]\n", pPars->fUseTfiTfo? "yes" : "no" );
- fprintf( stdout, "\t-w : toggle printing detailed stats for each node [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
- fprintf( stdout, "\t-v : toggle printing optimization summary [default = %s]\n", pPars->fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: *merge [-NSDLF num] [-scwvh]\n" );
+ Abc_Print( -2, "\t creates pairs of topologically-related LUTs\n" );
+ Abc_Print( -2, "\t-N <num> : the max LUT size for merging (1 < num) [default = %d]\n", pPars->nMaxLutSize );
+ Abc_Print( -2, "\t-S <num> : the max total support size after merging (1 < num) [default = %d]\n", pPars->nMaxSuppSize );
+ Abc_Print( -2, "\t-D <num> : the max distance in terms of LUTs (0 < num) [default = %d]\n", pPars->nMaxDistance );
+ Abc_Print( -2, "\t-L <num> : the max difference in levels (0 <= num) [default = %d]\n", pPars->nMaxLevelDiff );
+ Abc_Print( -2, "\t-F <num> : the max number of fanouts to stop traversal (0 < num) [default = %d]\n", pPars->nMaxFanout );
+ Abc_Print( -2, "\t-s : toggle the use of nodes without support overlap [default = %s]\n", pPars->fUseDiffSupp? "yes" : "no" );
+ Abc_Print( -2, "\t-c : toggle the use of TFI/TFO nodes as candidates [default = %s]\n", pPars->fUseTfiTfo? "yes" : "no" );
+ Abc_Print( -2, "\t-w : toggle printing detailed stats for each node [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle printing optimization summary [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -20963,8 +21335,7 @@ usage:
***********************************************************************/
int Abc_CommandAbc8Insert( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- extern void * Ntl_ManInsertNtk( void * p, void * pNtk );
- void * pNtlNew;
+ Ntl_Man_t * pNtlNew;
int c;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
@@ -20979,12 +21350,12 @@ int Abc_CommandAbc8Insert( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pAbc->pAbc8Ntl == NULL )
{
- printf( "Abc_CommandAbc8Insert(): There is no design.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Insert(): There is no design.\n" );
return 1;
}
if ( pAbc->pAbc8Nwk == NULL )
{
- printf( "Abc_CommandAbc8Insert(): There is no network to insert.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Insert(): There is no network to insert.\n" );
return 1;
}
pNtlNew = Ntl_ManInsertNtk( pAbc->pAbc8Ntl, pAbc->pAbc8Nwk );
@@ -20993,9 +21364,9 @@ int Abc_CommandAbc8Insert( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( stdout, "usage: *insert [-h]\n" );
- fprintf( stdout, "\t inserts the mapped network into the netlist\n" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: *insert [-h]\n" );
+ Abc_Print( -2, "\t inserts the mapped network into the netlist\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -21013,8 +21384,7 @@ usage:
***********************************************************************/
int Abc_CommandAbc8ClpLut( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- extern void * Ntl_ManDupCollapseLuts( void * p );
- void * pNtlNew;
+ Ntl_Man_t * pNtlNew;
int c;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
@@ -21029,7 +21399,7 @@ int Abc_CommandAbc8ClpLut( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pAbc->pAbc8Ntl == NULL )
{
- printf( "Abc_CommandAbc8Insert(): There is no design.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Insert(): There is no design.\n" );
return 1;
}
pNtlNew = Ntl_ManDupCollapseLuts( pAbc->pAbc8Ntl );
@@ -21039,9 +21409,9 @@ int Abc_CommandAbc8ClpLut( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( stdout, "usage: *clplut [-h]\n" );
- fprintf( stdout, "\t collapses comb white boxes whose model name begins with \"LUT\"\n" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: *clplut [-h]\n" );
+ Abc_Print( -2, "\t collapses comb white boxes whose model name begins with \"LUT\"\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
/**Function*************************************************************
@@ -21057,14 +21427,12 @@ usage:
***********************************************************************/
int Abc_CommandAbc8Fraig( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- void * pNtlNew, * pNtlOld;
+ Ntl_Man_t * pNtlNew, * pNtlOld;
int c, fVerbose;
int nPartSize;
int nConfLimit;
int nLevelMax;
int fUseCSat;
- extern void * Ntl_ManFraig( void * p, int nPartSize, int nConfLimit, int nLevelMax, int fUseCSat, int fVerbose );
- extern void Ntl_ManFree( void * p );
// set defaults
nPartSize = 0;
@@ -21080,7 +21448,7 @@ int Abc_CommandAbc8Fraig( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'P':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-P\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
goto usage;
}
nPartSize = atoi(argv[globalUtilOptind]);
@@ -21091,7 +21459,7 @@ int Abc_CommandAbc8Fraig( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
nConfLimit = atoi(argv[globalUtilOptind]);
@@ -21102,7 +21470,7 @@ int Abc_CommandAbc8Fraig( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'L':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-L\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
goto usage;
}
nLevelMax = atoi(argv[globalUtilOptind]);
@@ -21125,7 +21493,7 @@ int Abc_CommandAbc8Fraig( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pAbc->pAbc8Ntl == NULL )
{
- printf( "Abc_CommandAbc8Fraig(): There is no design to SAT sweep.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Fraig(): There is no design to SAT sweep.\n" );
return 1;
}
@@ -21134,7 +21502,7 @@ int Abc_CommandAbc8Fraig( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtlNew = Ntl_ManFraig( pNtlOld, nPartSize, nConfLimit, nLevelMax, fUseCSat, fVerbose );
if ( pNtlNew == NULL )
{
- printf( "Abc_CommandAbc8Fraig(): Tranformation of the AIG has failed.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Fraig(): Tranformation has failed.\n" );
return 1;
}
@@ -21142,26 +21510,26 @@ int Abc_CommandAbc8Fraig( Abc_Frame_t * pAbc, int argc, char ** argv )
pAbc->pAbc8Ntl = pNtlNew;
if ( pAbc->pAbc8Ntl == NULL )
{
- printf( "Abc_CommandAbc8Fraig(): Reading BLIF has failed.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Fraig(): Reading BLIF has failed.\n" );
return 1;
}
pAbc->pAbc8Aig = Ntl_ManExtract( pAbc->pAbc8Ntl );
if ( pAbc->pAbc8Aig == NULL )
{
- printf( "Abc_CommandAbc8Fraig(): AIG extraction has failed.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Fraig(): AIG extraction has failed.\n" );
return 1;
}
return 0;
usage:
- fprintf( stdout, "usage: *fraig [-P num] [-C num] [-L num] [-vh]\n" );
- fprintf( stdout, "\t applies SAT sweeping to netlist with white-boxes\n" );
- fprintf( stdout, "\t-P num : partition size (0 = partitioning is not used) [default = %d]\n", nPartSize );
- fprintf( stdout, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfLimit );
- fprintf( stdout, "\t-L num : limit on node level to fraig (0 = fraig all nodes) [default = %d]\n", nLevelMax );
-// fprintf( stdout, "\t-c : toggle using new AIG package and SAT solver [default = %s]\n", fUseCSat? "yes": "no" );
- fprintf( stdout, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: *fraig [-P num] [-C num] [-L num] [-vh]\n" );
+ Abc_Print( -2, "\t applies SAT sweeping to netlist with white-boxes\n" );
+ Abc_Print( -2, "\t-P num : partition size (0 = partitioning is not used) [default = %d]\n", nPartSize );
+ Abc_Print( -2, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfLimit );
+ Abc_Print( -2, "\t-L num : limit on node level to fraig (0 = fraig all nodes) [default = %d]\n", nLevelMax );
+// Abc_Print( -2, "\t-c : toggle using new AIG package and SAT solver [default = %s]\n", fUseCSat? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -21178,13 +21546,11 @@ usage:
***********************************************************************/
int Abc_CommandAbc8Scl( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- void * pNtlNew, * pNtlOld;
+ Ntl_Man_t * pNtlNew, * pNtlOld;
int c;
int fLatchConst;
int fLatchEqual;
int fVerbose;
- extern void * Ntl_ManScl( void * p, int fLatchConst, int fLatchEqual, int fVerbose );
- extern int Ntl_ManIsComb( void * p );
// set defaults
fLatchConst = 1;
@@ -21213,13 +21579,13 @@ int Abc_CommandAbc8Scl( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pAbc->pAbc8Ntl == NULL )
{
- printf( "Abc_CommandAbc8Scl(): There is no design to SAT sweep.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Scl(): There is no design to SAT sweep.\n" );
return 1;
}
if ( Ntl_ManIsComb(pAbc->pAbc8Ntl) )
{
- fprintf( stdout, "Abc_CommandAbc8Scl(): The network is combinational.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Scl(): The network is combinational.\n" );
return 0;
}
@@ -21228,7 +21594,7 @@ int Abc_CommandAbc8Scl( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtlNew = Ntl_ManScl( pNtlOld, fLatchConst, fLatchEqual, fVerbose );
if ( pNtlNew == NULL )
{
- printf( "Abc_CommandAbc8Scl(): Tranformation of the AIG has failed.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Scl(): Tranformation has failed.\n" );
return 1;
}
@@ -21236,25 +21602,25 @@ int Abc_CommandAbc8Scl( Abc_Frame_t * pAbc, int argc, char ** argv )
pAbc->pAbc8Ntl = pNtlNew;
if ( pAbc->pAbc8Ntl == NULL )
{
- printf( "Abc_CommandAbc8Scl(): Reading BLIF has failed.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Scl(): Reading BLIF has failed.\n" );
return 1;
}
pAbc->pAbc8Aig = Ntl_ManExtract( pAbc->pAbc8Ntl );
if ( pAbc->pAbc8Aig == NULL )
{
- printf( "Abc_CommandAbc8Scl(): AIG extraction has failed.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Scl(): AIG extraction has failed.\n" );
return 1;
}
return 0;
usage:
- fprintf( stdout, "usage: *scl [-cevh]\n" );
- fprintf( stdout, "\t performs sequential cleanup of the netlist\n" );
- fprintf( stdout, "\t by removing nodes and latches that do not feed into POs\n" );
- fprintf( stdout, "\t-c : sweep stuck-at latches detected by ternary simulation [default = %s]\n", fLatchConst? "yes": "no" );
- fprintf( stdout, "\t-e : merge equal latches (same data inputs and init states) [default = %s]\n", fLatchEqual? "yes": "no" );
- fprintf( stdout, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: *scl [-cevh]\n" );
+ Abc_Print( -2, "\t performs sequential cleanup of the netlist\n" );
+ Abc_Print( -2, "\t by removing nodes and latches that do not feed into POs\n" );
+ Abc_Print( -2, "\t-c : sweep stuck-at latches detected by ternary simulation [default = %s]\n", fLatchConst? "yes": "no" );
+ Abc_Print( -2, "\t-e : merge equal latches (same data inputs and init states) [default = %s]\n", fLatchEqual? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -21271,15 +21637,13 @@ usage:
***********************************************************************/
int Abc_CommandAbc8Lcorr( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- void * pNtlNew, * pNtlOld;
+ Ntl_Man_t * pNtlNew, * pNtlOld;
int c;
int fScorrGia;
int fUseCSat;
int nFramesP;
int nConfMax;
int fVerbose;
- extern void * Ntl_ManLcorr( void * p, int nConfMax, int fScorrGia, int fUseCSat, int fVerbose );
- extern int Ntl_ManIsComb( void * p );
// set defaults
fScorrGia = 0;
@@ -21295,7 +21659,7 @@ int Abc_CommandAbc8Lcorr( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'P':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-P\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
goto usage;
}
nFramesP = atoi(argv[globalUtilOptind]);
@@ -21306,7 +21670,7 @@ int Abc_CommandAbc8Lcorr( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
nConfMax = atoi(argv[globalUtilOptind]);
@@ -21332,13 +21696,13 @@ int Abc_CommandAbc8Lcorr( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pAbc->pAbc8Ntl == NULL )
{
- printf( "Abc_CommandAbc8Lcorr(): There is no design to SAT sweep.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Lcorr(): There is no design to SAT sweep.\n" );
return 1;
}
if ( Ntl_ManIsComb(pAbc->pAbc8Ntl) )
{
- fprintf( stdout, "Abc_CommandAbc8Lcorr(): The network is combinational.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Lcorr(): The network is combinational.\n" );
return 0;
}
@@ -21347,7 +21711,7 @@ int Abc_CommandAbc8Lcorr( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtlNew = Ntl_ManLcorr( pNtlOld, nConfMax, fScorrGia, fUseCSat, fVerbose );
if ( pNtlNew == NULL )
{
- printf( "Abc_CommandAbc8Lcorr(): Tranformation of the AIG has failed.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Lcorr(): Tranformation has failed.\n" );
return 1;
}
@@ -21355,26 +21719,26 @@ int Abc_CommandAbc8Lcorr( Abc_Frame_t * pAbc, int argc, char ** argv )
pAbc->pAbc8Ntl = pNtlNew;
if ( pAbc->pAbc8Ntl == NULL )
{
- printf( "Abc_CommandAbc8Lcorr(): Reading BLIF has failed.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Lcorr(): Reading BLIF has failed.\n" );
return 1;
}
pAbc->pAbc8Aig = Ntl_ManExtract( pAbc->pAbc8Ntl );
if ( pAbc->pAbc8Aig == NULL )
{
- printf( "Abc_CommandAbc8Lcorr(): AIG extraction has failed.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Lcorr(): AIG extraction has failed.\n" );
return 1;
}
return 0;
usage:
- fprintf( stdout, "usage: *lcorr [-C num] [-ncvh]\n" );
- fprintf( stdout, "\t computes latch correspondence for the netlist\n" );
-// fprintf( stdout, "\t-P num : number of time frames to use as the prefix [default = %d]\n", nFramesP );
- fprintf( stdout, "\t-C num : max conflict number when proving latch equivalence [default = %d]\n", nConfMax );
- fprintf( stdout, "\t-n : toggle using new AIG package [default = %s]\n", fScorrGia? "yes": "no" );
- fprintf( stdout, "\t-c : toggle using new AIG package and SAT solver [default = %s]\n", fUseCSat? "yes": "no" );
- fprintf( stdout, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: *lcorr [-C num] [-ncvh]\n" );
+ Abc_Print( -2, "\t computes latch correspondence for the netlist\n" );
+// Abc_Print( -2, "\t-P num : number of time frames to use as the prefix [default = %d]\n", nFramesP );
+ Abc_Print( -2, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfMax );
+ Abc_Print( -2, "\t-n : toggle using new AIG package [default = %s]\n", fScorrGia? "yes": "no" );
+ Abc_Print( -2, "\t-c : toggle using new AIG package and SAT solver [default = %s]\n", fUseCSat? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -21391,11 +21755,9 @@ usage:
***********************************************************************/
int Abc_CommandAbc8Ssw( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- void * pNtlNew, * pNtlOld;
+ Ntl_Man_t * pNtlNew, * pNtlOld;
Fra_Ssw_t Pars, * pPars = &Pars;
int c;
- extern void * Ntl_ManSsw( void * p, Fra_Ssw_t * pPars );
- extern int Ntl_ManIsComb( void * p );
// set defaults
pPars->nPartSize = 0;
@@ -21421,7 +21783,7 @@ int Abc_CommandAbc8Ssw( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'P':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-P\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
goto usage;
}
pPars->nPartSize = atoi(argv[globalUtilOptind]);
@@ -21432,7 +21794,7 @@ int Abc_CommandAbc8Ssw( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'Q':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-Q\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-Q\" should be followed by an integer.\n" );
goto usage;
}
pPars->nOverSize = atoi(argv[globalUtilOptind]);
@@ -21443,7 +21805,7 @@ int Abc_CommandAbc8Ssw( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'N':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-N\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
goto usage;
}
pPars->nFramesP = atoi(argv[globalUtilOptind]);
@@ -21454,7 +21816,7 @@ int Abc_CommandAbc8Ssw( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-F\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
pPars->nFramesK = atoi(argv[globalUtilOptind]);
@@ -21465,7 +21827,7 @@ int Abc_CommandAbc8Ssw( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'I':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-I\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
goto usage;
}
pPars->nMaxImps = atoi(argv[globalUtilOptind]);
@@ -21476,7 +21838,7 @@ int Abc_CommandAbc8Ssw( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'L':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-L\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
goto usage;
}
pPars->nMaxLevs = atoi(argv[globalUtilOptind]);
@@ -21487,7 +21849,7 @@ int Abc_CommandAbc8Ssw( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'D':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-D\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
goto usage;
}
pPars->nMinDomSize = atoi(argv[globalUtilOptind]);
@@ -21525,25 +21887,25 @@ int Abc_CommandAbc8Ssw( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pAbc->pAbc8Ntl == NULL )
{
- printf( "Abc_CommandAbc8Ssw(): There is no design to SAT sweep.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Ssw(): There is no design to SAT sweep.\n" );
return 1;
}
if ( Ntl_ManIsComb(pAbc->pAbc8Ntl) )
{
- fprintf( stdout, "The network is combinational.\n" );
+ Abc_Print( -1, "The network is combinational.\n" );
return 0;
}
if ( pPars->nFramesK > 1 && pPars->fUse1Hot )
{
- printf( "Currrently can only use one-hotness for simple induction (K=1).\n" );
+ Abc_Print( -1, "Currrently can only use one-hotness for simple induction (K=1).\n" );
return 0;
}
if ( pPars->nFramesP && pPars->fUse1Hot )
{
- printf( "Currrently can only use one-hotness without prefix.\n" );
+ Abc_Print( -1, "Currrently can only use one-hotness without prefix.\n" );
return 0;
}
@@ -21552,7 +21914,7 @@ int Abc_CommandAbc8Ssw( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtlNew = Ntl_ManSsw( pNtlOld, pPars );
if ( pNtlNew == NULL )
{
- printf( "Abc_CommandAbc8Ssw(): Tranformation of the AIG has failed.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Ssw(): Tranformation has failed.\n" );
return 1;
}
@@ -21560,35 +21922,35 @@ int Abc_CommandAbc8Ssw( Abc_Frame_t * pAbc, int argc, char ** argv )
pAbc->pAbc8Ntl = pNtlNew;
if ( pAbc->pAbc8Ntl == NULL )
{
- printf( "Abc_CommandAbc8Ssw(): Reading BLIF has failed.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Ssw(): Reading BLIF has failed.\n" );
return 1;
}
pAbc->pAbc8Aig = Ntl_ManExtract( pAbc->pAbc8Ntl );
if ( pAbc->pAbc8Aig == NULL )
{
- printf( "Abc_CommandAbc8Ssw(): AIG extraction has failed.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Ssw(): AIG extraction has failed.\n" );
return 1;
}
return 0;
usage:
- fprintf( stdout, "usage: *ssw [-PQNFLD num] [-lrfetvh]\n" );
- fprintf( stdout, "\t performs sequential sweep using K-step induction on the netlist \n" );
- fprintf( stdout, "\t-P num : max partition size (0 = no partitioning) [default = %d]\n", pPars->nPartSize );
- fprintf( stdout, "\t-Q num : partition overlap (0 = no overlap) [default = %d]\n", pPars->nOverSize );
- fprintf( stdout, "\t-N num : number of time frames to use as the prefix [default = %d]\n", pPars->nFramesP );
- fprintf( stdout, "\t-F num : number of time frames for induction (1=simple) [default = %d]\n", pPars->nFramesK );
- fprintf( stdout, "\t-L num : max number of levels to consider (0=all) [default = %d]\n", pPars->nMaxLevs );
- fprintf( stdout, "\t-D num : min size of a clock domain used for synthesis [default = %d]\n", pPars->nMinDomSize );
-// fprintf( stdout, "\t-I num : max number of implications to consider [default = %d]\n", pPars->nMaxImps );
-// fprintf( stdout, "\t-i : toggle using implications [default = %s]\n", pPars->fUseImps? "yes": "no" );
- fprintf( stdout, "\t-l : toggle latch correspondence only [default = %s]\n", pPars->fLatchCorr? "yes": "no" );
- fprintf( stdout, "\t-r : toggle AIG rewriting [default = %s]\n", pPars->fRewrite? "yes": "no" );
- fprintf( stdout, "\t-f : toggle fraiging (combinational SAT sweeping) [default = %s]\n", pPars->fFraiging? "yes": "no" );
- fprintf( stdout, "\t-e : toggle writing implications as assertions [default = %s]\n", pPars->fWriteImps? "yes": "no" );
- fprintf( stdout, "\t-t : toggle using one-hotness conditions [default = %s]\n", pPars->fUse1Hot? "yes": "no" );
- fprintf( stdout, "\t-v : toggle verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: *ssw [-PQNFLD num] [-lrfetvh]\n" );
+ Abc_Print( -2, "\t performs sequential sweep using K-step induction on the netlist \n" );
+ Abc_Print( -2, "\t-P num : max partition size (0 = no partitioning) [default = %d]\n", pPars->nPartSize );
+ Abc_Print( -2, "\t-Q num : partition overlap (0 = no overlap) [default = %d]\n", pPars->nOverSize );
+ Abc_Print( -2, "\t-N num : number of time frames to use as the prefix [default = %d]\n", pPars->nFramesP );
+ Abc_Print( -2, "\t-F num : number of time frames for induction (1=simple) [default = %d]\n", pPars->nFramesK );
+ Abc_Print( -2, "\t-L num : max number of levels to consider (0=all) [default = %d]\n", pPars->nMaxLevs );
+ Abc_Print( -2, "\t-D num : min size of a clock domain used for synthesis [default = %d]\n", pPars->nMinDomSize );
+// Abc_Print( -2, "\t-I num : max number of implications to consider [default = %d]\n", pPars->nMaxImps );
+// Abc_Print( -2, "\t-i : toggle using implications [default = %s]\n", pPars->fUseImps? "yes": "no" );
+ Abc_Print( -2, "\t-l : toggle latch correspondence only [default = %s]\n", pPars->fLatchCorr? "yes": "no" );
+ Abc_Print( -2, "\t-r : toggle AIG rewriting [default = %s]\n", pPars->fRewrite? "yes": "no" );
+ Abc_Print( -2, "\t-f : toggle fraiging (combinational SAT sweeping) [default = %s]\n", pPars->fFraiging? "yes": "no" );
+ Abc_Print( -2, "\t-e : toggle writing implications as assertions [default = %s]\n", pPars->fWriteImps? "yes": "no" );
+ Abc_Print( -2, "\t-t : toggle using one-hotness conditions [default = %s]\n", pPars->fUse1Hot? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -21605,23 +21967,21 @@ usage:
***********************************************************************/
int Abc_CommandAbc8Scorr( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- void * pNtlNew, * pNtlOld;
+ Ntl_Man_t * pNtlNew, * pNtlOld;
Ssw_Pars_t Pars, * pPars = &Pars;
int c;
- extern void * Ntl_ManScorr( void * p, Ssw_Pars_t * pPars );
- extern int Ntl_ManIsComb( void * p );
// set defaults
Ssw_ManSetDefaultParams( pPars );
Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "PQFCLNSDVMpldsncvh" ) ) != EOF )
+ while ( ( c = Extra_UtilGetopt( argc, argv, "PQFCLSDVMpldsncvh" ) ) != EOF )
{
switch ( c )
{
case 'P':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-P\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
goto usage;
}
pPars->nPartSize = atoi(argv[globalUtilOptind]);
@@ -21632,7 +21992,7 @@ int Abc_CommandAbc8Scorr( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'Q':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-Q\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-Q\" should be followed by an integer.\n" );
goto usage;
}
pPars->nOverSize = atoi(argv[globalUtilOptind]);
@@ -21643,7 +22003,7 @@ int Abc_CommandAbc8Scorr( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-F\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
pPars->nFramesK = atoi(argv[globalUtilOptind]);
@@ -21654,7 +22014,7 @@ int Abc_CommandAbc8Scorr( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
pPars->nBTLimit = atoi(argv[globalUtilOptind]);
@@ -21665,7 +22025,7 @@ int Abc_CommandAbc8Scorr( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'L':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-L\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
goto usage;
}
pPars->nMaxLevs = atoi(argv[globalUtilOptind]);
@@ -21673,21 +22033,10 @@ int Abc_CommandAbc8Scorr( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pPars->nMaxLevs <= 0 )
goto usage;
break;
- case 'N':
- if ( globalUtilOptind >= argc )
- {
- fprintf( stdout, "Command line switch \"-N\" should be followed by an integer.\n" );
- goto usage;
- }
- pPars->nConstrs = atoi(argv[globalUtilOptind]);
- globalUtilOptind++;
- if ( pPars->nConstrs < 0 )
- goto usage;
- break;
case 'S':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-S\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
goto usage;
}
pPars->nFramesAddSim = atoi(argv[globalUtilOptind]);
@@ -21698,7 +22047,7 @@ int Abc_CommandAbc8Scorr( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'D':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-D\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
goto usage;
}
pPars->nMinDomSize = atoi(argv[globalUtilOptind]);
@@ -21709,7 +22058,7 @@ int Abc_CommandAbc8Scorr( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'V':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-V\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-V\" should be followed by an integer.\n" );
goto usage;
}
pPars->nSatVarMax2 = atoi(argv[globalUtilOptind]);
@@ -21720,7 +22069,7 @@ int Abc_CommandAbc8Scorr( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'M':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-M\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
goto usage;
}
pPars->nRecycleCalls2 = atoi(argv[globalUtilOptind]);
@@ -21758,13 +22107,13 @@ int Abc_CommandAbc8Scorr( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pAbc->pAbc8Ntl == NULL )
{
- printf( "Abc_CommandAbc8Ssw(): There is no design to SAT sweep.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Ssw(): There is no design to SAT sweep.\n" );
return 1;
}
if ( Ntl_ManIsComb(pAbc->pAbc8Ntl) )
{
- fprintf( stdout, "The network is combinational.\n" );
+ Abc_Print( -1, "The network is combinational.\n" );
return 0;
}
@@ -21772,7 +22121,7 @@ int Abc_CommandAbc8Scorr( Abc_Frame_t * pAbc, int argc, char ** argv )
{
pPars->nPartSize = 0;
pPars->nOverSize = 0;
- printf( "With dynamic partitioning (-d) enabled, static one (-P <num> -Q <num>) is ignored.\n" );
+ Abc_Print( -1, "With dynamic partitioning (-d) enabled, static one (-P <num> -Q <num>) is ignored.\n" );
}
// get the input file name
@@ -21780,7 +22129,7 @@ int Abc_CommandAbc8Scorr( Abc_Frame_t * pAbc, int argc, char ** argv )
pNtlNew = Ntl_ManScorr( pNtlOld, pPars );
if ( pNtlNew == NULL )
{
- printf( "Abc_CommandAbc8Scorr(): Tranformation of the AIG has failed.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Scorr(): Tranformation has failed.\n" );
return 1;
}
@@ -21788,38 +22137,37 @@ int Abc_CommandAbc8Scorr( Abc_Frame_t * pAbc, int argc, char ** argv )
pAbc->pAbc8Ntl = pNtlNew;
if ( pAbc->pAbc8Ntl == NULL )
{
- printf( "Abc_CommandAbc8Scorr(): Reading BLIF has failed.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Scorr(): Reading BLIF has failed.\n" );
return 1;
}
pAbc->pAbc8Aig = Ntl_ManExtract( pAbc->pAbc8Ntl );
if ( pAbc->pAbc8Aig == NULL )
{
- printf( "Abc_CommandAbc8Scorr(): AIG extraction has failed.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Scorr(): AIG extraction has failed.\n" );
return 1;
}
return 0;
usage:
- fprintf( stdout, "usage: *scorr [-PQFCLNSDVM <num>] [-pldsncvh]\n" );
- fprintf( stdout, "\t performs sequential sweep using K-step induction\n" );
- fprintf( stdout, "\t-P num : max partition size (0 = no partitioning) [default = %d]\n", pPars->nPartSize );
- fprintf( stdout, "\t-Q num : partition overlap (0 = no overlap) [default = %d]\n", pPars->nOverSize );
- fprintf( stdout, "\t-F num : number of time frames for induction (1=simple) [default = %d]\n", pPars->nFramesK );
- fprintf( stdout, "\t-C num : max number of conflicts at a node (0=inifinite) [default = %d]\n", pPars->nBTLimit );
- fprintf( stdout, "\t-L num : max number of levels to consider (0=all) [default = %d]\n", pPars->nMaxLevs );
- fprintf( stdout, "\t-N num : number of last POs treated as constraints (0=none) [default = %d]\n", pPars->nConstrs );
- fprintf( stdout, "\t-S num : additional simulation frames for c-examples (0=none) [default = %d]\n", pPars->nFramesAddSim );
- fprintf( stdout, "\t-D num : min size of a clock domain used for synthesis [default = %d]\n", pPars->nMinDomSize );
- fprintf( stdout, "\t-V num : min var num needed to recycle the SAT solver [default = %d]\n", pPars->nSatVarMax2 );
- fprintf( stdout, "\t-M num : min call num needed to recycle the SAT solver [default = %d]\n", pPars->nRecycleCalls2 );
- fprintf( stdout, "\t-p : toggle alighning polarity of SAT variables [default = %s]\n", pPars->fPolarFlip? "yes": "no" );
- fprintf( stdout, "\t-l : toggle latch correspondence only [default = %s]\n", pPars->fLatchCorr? "yes": "no" );
- fprintf( stdout, "\t-d : toggle dynamic addition of constraints [default = %s]\n", pPars->fDynamic? "yes": "no" );
- fprintf( stdout, "\t-s : toggle local simulation in the cone of influence [default = %s]\n", pPars->fLocalSim? "yes": "no" );
- fprintf( stdout, "\t-n : toggle using new AIG package [default = %s]\n", pPars->fScorrGia? "yes": "no" );
- fprintf( stdout, "\t-c : toggle using new AIG package and SAT solver [default = %s]\n", pPars->fUseCSat? "yes": "no" );
- fprintf( stdout, "\t-v : toggle verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: *scorr [-PQFCLSDVM <num>] [-pldsncvh]\n" );
+ Abc_Print( -2, "\t performs sequential sweep using K-step induction\n" );
+ Abc_Print( -2, "\t-P num : max partition size (0 = no partitioning) [default = %d]\n", pPars->nPartSize );
+ Abc_Print( -2, "\t-Q num : partition overlap (0 = no overlap) [default = %d]\n", pPars->nOverSize );
+ Abc_Print( -2, "\t-F num : number of time frames for induction (1=simple) [default = %d]\n", pPars->nFramesK );
+ Abc_Print( -2, "\t-C num : max number of conflicts at a node (0=inifinite) [default = %d]\n", pPars->nBTLimit );
+ Abc_Print( -2, "\t-L num : max number of levels to consider (0=all) [default = %d]\n", pPars->nMaxLevs );
+ Abc_Print( -2, "\t-S num : additional simulation frames for c-examples (0=none) [default = %d]\n", pPars->nFramesAddSim );
+ Abc_Print( -2, "\t-D num : min size of a clock domain used for synthesis [default = %d]\n", pPars->nMinDomSize );
+ Abc_Print( -2, "\t-V num : min var num needed to recycle the SAT solver [default = %d]\n", pPars->nSatVarMax2 );
+ Abc_Print( -2, "\t-M num : min call num needed to recycle the SAT solver [default = %d]\n", pPars->nRecycleCalls2 );
+ Abc_Print( -2, "\t-p : toggle alighning polarity of SAT variables [default = %s]\n", pPars->fPolarFlip? "yes": "no" );
+ Abc_Print( -2, "\t-l : toggle latch correspondence only [default = %s]\n", pPars->fLatchCorr? "yes": "no" );
+ Abc_Print( -2, "\t-d : toggle dynamic addition of constraints [default = %s]\n", pPars->fDynamic? "yes": "no" );
+ Abc_Print( -2, "\t-s : toggle local simulation in the cone of influence [default = %s]\n", pPars->fLocalSim? "yes": "no" );
+ Abc_Print( -2, "\t-n : toggle using new AIG package [default = %s]\n", pPars->fScorrGia? "yes": "no" );
+ Abc_Print( -2, "\t-c : toggle using new AIG package and SAT solver [default = %s]\n", pPars->fUseCSat? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -21836,15 +22184,11 @@ usage:
***********************************************************************/
int Abc_CommandAbc8Sweep( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- void * pNtlTemp;
+ Ntl_Man_t * pNtlTemp;
int Counter;
int fMapped;
int fVerbose;
int c;
- extern int Ntl_ManSweep( void * p, int fVerbose );
- extern void * Ntl_ManInsertNtk( void * p, void * pNtk );
- extern Aig_Man_t * Ntl_ManExtract( void * p );
- extern void * Ntl_ManExtractNwk( void * p, Aig_Man_t * pAig, Tim_Man_t * pManTime );
// set defaults
fMapped = 0;
@@ -21868,7 +22212,7 @@ int Abc_CommandAbc8Sweep( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pAbc->pAbc8Ntl == NULL )
{
- printf( "Abc_CommandAbc8Sweep(): There is no design to sweep.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Sweep(): There is no design to sweep.\n" );
return 1;
}
@@ -21877,13 +22221,13 @@ int Abc_CommandAbc8Sweep( Abc_Frame_t * pAbc, int argc, char ** argv )
{
if ( pAbc->pAbc8Nwk == NULL )
{
- printf( "Abc_CommandAbc8Sweep(): There is no mapped network to sweep.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Sweep(): There is no mapped network to sweep.\n" );
return 1;
}
pNtlTemp = Ntl_ManInsertNtk( pAbc->pAbc8Ntl, pAbc->pAbc8Nwk );
if ( pNtlTemp == NULL )
{
- printf( "Abc_CommandAbc8Sweep(): Inserting mapped network has failed.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Sweep(): Inserting mapped network has failed.\n" );
return 1;
}
Abc_FrameClearDesign();
@@ -21893,7 +22237,7 @@ int Abc_CommandAbc8Sweep( Abc_Frame_t * pAbc, int argc, char ** argv )
// sweep the current design
Counter = Ntl_ManSweep( pAbc->pAbc8Ntl, fVerbose );
if ( Counter == 0 && fVerbose )
- printf( "The netlist is unchanged by sweep.\n" );
+ Abc_Print( -1, "The netlist is unchanged by sweep.\n" );
// if mapped, create new AIG and new mapped network
if ( fMapped )
@@ -21901,13 +22245,13 @@ int Abc_CommandAbc8Sweep( Abc_Frame_t * pAbc, int argc, char ** argv )
pAbc->pAbc8Aig = Ntl_ManExtract( pAbc->pAbc8Ntl );
if ( pAbc->pAbc8Aig == NULL )
{
- printf( "Abc_CommandAbc8Sweep(): AIG extraction has failed.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Sweep(): AIG extraction has failed.\n" );
return 1;
}
pAbc->pAbc8Nwk = Ntl_ManExtractNwk( pAbc->pAbc8Ntl, pAbc->pAbc8Aig, NULL );
if ( pAbc->pAbc8Nwk == NULL )
{
- printf( "Abc_CommandAbc8Sweep(): Failed to extract the mapped network.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Sweep(): Failed to extract the mapped network.\n" );
return 1;
}
}
@@ -21920,19 +22264,19 @@ int Abc_CommandAbc8Sweep( Abc_Frame_t * pAbc, int argc, char ** argv )
pAbc->pAbc8Aig = Ntl_ManExtract( pAbc->pAbc8Ntl );
if ( pAbc->pAbc8Aig == NULL )
{
- printf( "Abc_CommandAbc8Sweep(): AIG extraction has failed.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Sweep(): AIG extraction has failed.\n" );
return 1;
}
}
return 0;
usage:
- fprintf( stdout, "usage: *sw [-mvh]\n" );
- fprintf( stdout, "\t performs structural sweep of the netlist\n" );
- fprintf( stdout, "\t removes dangling nodes, registers, and white-boxes\n" );
- fprintf( stdout, "\t-m : inserts mapped network into netlist and sweeps it [default = %s]\n", fMapped? "yes": "no" );
- fprintf( stdout, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: *sw [-mvh]\n" );
+ Abc_Print( -2, "\t performs structural sweep of the netlist\n" );
+ Abc_Print( -2, "\t removes dangling nodes, registers, and white-boxes\n" );
+ Abc_Print( -2, "\t-m : inserts mapped network into netlist and sweeps it [default = %s]\n", fMapped? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -21949,10 +22293,9 @@ usage:
***********************************************************************/
int Abc_CommandAbc8Zero( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- void * pNtlNew;
+ Ntl_Man_t * pNtlNew;
int fVerbose;
int c;
- extern void Ntl_ManTransformInitValues( void * p );
// set defaults
fVerbose = 0;
@@ -21972,7 +22315,7 @@ int Abc_CommandAbc8Zero( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pAbc->pAbc8Ntl == NULL )
{
- printf( "Abc_CommandAbc8Zero(): There is no design to convert.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Zero(): There is no design to convert.\n" );
return 1;
}
@@ -21987,10 +22330,10 @@ int Abc_CommandAbc8Zero( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( stdout, "usage: *zero [-h]\n" );
- fprintf( stdout, "\t converts registers to have constant-0 initial value\n" );
- fprintf( stdout, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: *zero [-h]\n" );
+ Abc_Print( -2, "\t converts registers to have constant-0 initial value\n" );
+ Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -22008,7 +22351,7 @@ usage:
int Abc_CommandAbc8Cec( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Aig_Man_t * pAig1, * pAig2;
- void * pTemp1, * pTemp2;
+ Ntl_Man_t * pTemp1, * pTemp2;
char ** pArgvNew;
int nArgcNew;
int c;
@@ -22016,14 +22359,7 @@ int Abc_CommandAbc8Cec( Abc_Frame_t * pAbc, int argc, char ** argv )
int nConfLimit;
int fSmart;
int nPartSize;
- extern Aig_Man_t * Ntl_ManCollapse( void * p, int fSeq );
- extern void * Ntl_ManDup( void * pOld );
- extern void Ntl_ManFree( void * p );
- extern void * Ntl_ManInsertNtk( void * p, void * pNtk );
-
- extern void Ntl_ManPrepareCecMans( void * pMan1, void * pMan2, Aig_Man_t ** ppAig1, Aig_Man_t ** ppAig2 );
- extern void Ntl_ManPrepareCec( char * pFileName1, char * pFileName2, Aig_Man_t ** ppMan1, Aig_Man_t ** ppMan2 );
- extern int Fra_FraigCecTop( Aig_Man_t * pMan1, Aig_Man_t * pMan2, int nConfLimit, int nPartSize, int fSmart, int fVerbose );
+ extern int Fra_FraigCecTop( Aig_Man_t * pMan1, Aig_Man_t * pMan2, int nConfLimit, int nPartSize, int fSmart, int fVerbose );
// set defaults
nConfLimit = 100000;
@@ -22038,7 +22374,7 @@ int Abc_CommandAbc8Cec( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
nConfLimit = atoi(argv[globalUtilOptind]);
@@ -22049,7 +22385,7 @@ int Abc_CommandAbc8Cec( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'P':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-P\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
goto usage;
}
nPartSize = atoi(argv[globalUtilOptind]);
@@ -22072,7 +22408,7 @@ int Abc_CommandAbc8Cec( Abc_Frame_t * pAbc, int argc, char ** argv )
nArgcNew = argc - globalUtilOptind;
if ( nArgcNew != 0 && nArgcNew != 2 )
{
- printf( "Currently can only compare current mapped network against the spec, or designs derived from two files.\n" );
+ Abc_Print( -1, "Currently can only compare current mapped network against the spec, or designs derived from two files.\n" );
return 0;
}
if ( nArgcNew == 2 )
@@ -22088,15 +22424,15 @@ int Abc_CommandAbc8Cec( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pAbc->pAbc8Ntl == NULL )
{
- printf( "Abc_CommandAbc8Cec(): There is no design to verify.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Cec(): There is no design to verify.\n" );
return 1;
}
if ( pAbc->pAbc8Nwk == NULL )
{
- printf( "Abc_CommandAbc8Cec(): There is no mapped network to verify.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Cec(): There is no mapped network to verify.\n" );
return 1;
}
-// printf( "Currently *cec works only for two designs given on command line.\n" );
+// Abc_Print( -1, "Currently *cec works only for two designs given on command line.\n" );
// insert the mapped network
pTemp1 = Ntl_ManDup( pAbc->pAbc8Ntl );
@@ -22104,7 +22440,7 @@ int Abc_CommandAbc8Cec( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pTemp2 == NULL )
{
Ntl_ManFree( pTemp1 );
- printf( "Abc_CommandAbc8Cec(): Inserting the design has failed.\n" );
+ Abc_Print( -1, "Abc_CommandAbc8Cec(): Inserting the design has failed.\n" );
return 1;
}
Ntl_ManPrepareCecMans( pTemp1, pTemp2, &pAig1, &pAig2 );
@@ -22118,17 +22454,17 @@ int Abc_CommandAbc8Cec( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( stdout, "usage: *cec [-C num] [-P num] [-svh] <file1> <file2>\n" );
- fprintf( stdout, "\t performs combinational equivalence checking\n" );
- fprintf( stdout, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfLimit );
- fprintf( stdout, "\t-P num : the partition size for partitioned CEC [default = %d]\n", nPartSize );
- fprintf( stdout, "\t-s : toggle smart and natural output partitioning [default = %s]\n", fSmart? "smart": "natural" );
- fprintf( stdout, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
- fprintf( stdout, "\tfile1 : (optional) the file with the first network\n");
- fprintf( stdout, "\tfile2 : (optional) the file with the second network\n");
- fprintf( stdout, "\t if no files are given, uses the current network and its spec\n");
- fprintf( stdout, "\t if two files are given, compares designs derived from files\n");
+ Abc_Print( -2, "usage: *cec [-C num] [-P num] [-svh] <file1> <file2>\n" );
+ Abc_Print( -2, "\t performs combinational equivalence checking\n" );
+ Abc_Print( -2, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfLimit );
+ Abc_Print( -2, "\t-P num : the partition size for partitioned CEC [default = %d]\n", nPartSize );
+ Abc_Print( -2, "\t-s : toggle smart and natural output partitioning [default = %s]\n", fSmart? "smart": "natural" );
+ Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ Abc_Print( -2, "\tfile1 : (optional) the file with the first network\n");
+ Abc_Print( -2, "\tfile2 : (optional) the file with the second network\n");
+ Abc_Print( -2, "\t if no files are given, uses the current network and its spec\n");
+ Abc_Print( -2, "\t if two files are given, compares designs derived from files\n");
return 1;
}
@@ -22153,7 +22489,6 @@ int Abc_CommandAbc8DSec( Abc_Frame_t * pAbc, int argc, char ** argv )
extern void Fra_SecSetDefaultParams( Fra_Sec_t * pSecPar );
extern int Fra_FraigSec( Aig_Man_t * p, Fra_Sec_t * pSecPar, Aig_Man_t ** ppResult );
- extern Aig_Man_t * Ntl_ManPrepareSec( char * pFileName1, char * pFileName2 );
// set defaults
Fra_SecSetDefaultParams( pSecPar );
@@ -22169,7 +22504,7 @@ int Abc_CommandAbc8DSec( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-F\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
pSecPar->nFramesMax = atoi(argv[globalUtilOptind]);
@@ -22204,7 +22539,7 @@ int Abc_CommandAbc8DSec( Abc_Frame_t * pAbc, int argc, char ** argv )
nArgcNew = argc - globalUtilOptind;
if ( nArgcNew != 2 )
{
- printf( "Only works for two designs written from files specified on the command line.\n" );
+ Abc_Print( -1, "Only works for two designs written from files specified on the command line.\n" );
return 1;
}
@@ -22216,20 +22551,77 @@ int Abc_CommandAbc8DSec( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( stdout, "usage: *dsec [-F num] [-armfwvh] <file1> <file2>\n" );
- fprintf( stdout, "\t performs sequential equivalence checking for two designs\n" );
- fprintf( stdout, "\t-F num : the limit on the depth of induction [default = %d]\n", pSecPar->nFramesMax );
- fprintf( stdout, "\t-a : toggles the use of phase abstraction [default = %s]\n", pSecPar->fPhaseAbstract? "yes": "no" );
- fprintf( stdout, "\t-r : toggles forward retiming at the beginning [default = %s]\n", pSecPar->fRetimeFirst? "yes": "no" );
- fprintf( stdout, "\t-m : toggles min-register retiming [default = %s]\n", pSecPar->fRetimeRegs? "yes": "no" );
- fprintf( stdout, "\t-f : toggles the internal use of fraiging [default = %s]\n", pSecPar->fFraiging? "yes": "no" );
- fprintf( stdout, "\t-v : toggles verbose output [default = %s]\n", pSecPar->fVerbose? "yes": "no" );
- fprintf( stdout, "\t-w : toggles additional verbose output [default = %s]\n", pSecPar->fVeryVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
- fprintf( stdout, "\tfile1 : the file with the first design\n");
- fprintf( stdout, "\tfile2 : the file with the second design\n");
-// fprintf( stdout, "\t if no files are given, uses the current network and its spec\n");
-// fprintf( stdout, "\t if one file is given, uses the current network and the file\n");
+ Abc_Print( -2, "usage: *dsec [-F num] [-armfwvh] <file1> <file2>\n" );
+ Abc_Print( -2, "\t performs sequential equivalence checking for two designs\n" );
+ Abc_Print( -2, "\t-F num : the limit on the depth of induction [default = %d]\n", pSecPar->nFramesMax );
+ Abc_Print( -2, "\t-a : toggles the use of phase abstraction [default = %s]\n", pSecPar->fPhaseAbstract? "yes": "no" );
+ Abc_Print( -2, "\t-r : toggles forward retiming at the beginning [default = %s]\n", pSecPar->fRetimeFirst? "yes": "no" );
+ Abc_Print( -2, "\t-m : toggles min-register retiming [default = %s]\n", pSecPar->fRetimeRegs? "yes": "no" );
+ Abc_Print( -2, "\t-f : toggles the internal use of fraiging [default = %s]\n", pSecPar->fFraiging? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", pSecPar->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-w : toggles additional verbose output [default = %s]\n", pSecPar->fVeryVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ Abc_Print( -2, "\tfile1 : the file with the first design\n");
+ Abc_Print( -2, "\tfile2 : the file with the second design\n");
+// Abc_Print( -2, "\t if no files are given, uses the current network and its spec\n");
+// Abc_Print( -2, "\t if one file is given, uses the current network and the file\n");
+ return 1;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_CommandAbcTestNew( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ extern int Abc_NtkTestProcedure( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2 );
+
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+ int c;
+
+ pNtk = Abc_FrameReadNtk(pAbc);
+
+ // set defaults
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+ {
+ switch ( c )
+ {
+ case 'h':
+ goto usage;
+ default:
+ goto usage;
+ }
+ }
+
+ if ( pNtk == NULL )
+ {
+ Abc_Print( -1, "Empty network.\n" );
+ return 1;
+ }
+
+ if ( !Abc_NtkIsStrash( pNtk) )
+ {
+ Abc_Print( -1, "The current network is not an AIG. Cannot continue.\n" );
+ return 1;
+ }
+
+// Abc_NtkTestProcedure( pNtk, NULL );
+
+ return 0;
+
+usage:
+ Abc_Print( -2, "usage: testnew [-h]\n" );
+ Abc_Print( -2, "\t new testing procedure\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -22269,7 +22661,7 @@ int Abc_CommandAbc9Read( Abc_Frame_t * pAbc, int argc, char ** argv )
nArgcNew = argc - globalUtilOptind;
if ( nArgcNew != 1 )
{
- printf( "There is no file name.\n" );
+ Abc_Print( -1, "There is no file name.\n" );
return 1;
}
@@ -22281,31 +22673,24 @@ int Abc_CommandAbc9Read( Abc_Frame_t * pAbc, int argc, char ** argv )
*pTemp = '\\';
if ( (pFile = fopen( FileName, "r" )) == NULL )
{
- fprintf( pAbc->Err, "Cannot open input file \"%s\". ", FileName );
+ Abc_Print( -1, "Cannot open input file \"%s\". ", FileName );
if ( (FileName = Extra_FileGetSimilarName( FileName, ".aig", ".blif", ".pla", ".eqn", ".bench" )) )
- fprintf( pAbc->Err, "Did you mean \"%s\"?", FileName );
- fprintf( pAbc->Err, "\n" );
+ Abc_Print( 1, "Did you mean \"%s\"?", FileName );
+ Abc_Print( 1, "\n" );
return 1;
}
fclose( pFile );
pAig = Gia_ReadAiger( FileName, 0 );
- if ( pAig == NULL )
- {
- printf( "Reading AIGER has failed.\n" );
- return 0;
- }
- if ( pAbc->pAig )
- Gia_ManStop( pAbc->pAig );
- pAbc->pAig = pAig;
+ Abc_CommandUpdate9( pAbc, pAig );
return 0;
usage:
- fprintf( stdout, "usage: &r [-vh] <file>\n" );
- fprintf( stdout, "\t reads the current AIG from the AIGER file\n" );
- fprintf( stdout, "\t-v : toggles additional verbose output [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
- fprintf( stdout, "\t<file> : the file name\n");
+ Abc_Print( -2, "usage: &r [-vh] <file>\n" );
+ Abc_Print( -2, "\t reads the current AIG from the AIGER file\n" );
+ Abc_Print( -2, "\t-v : toggles additional verbose output [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ Abc_Print( -2, "\t<file> : the file name\n");
return 1;
}
@@ -22347,17 +22732,17 @@ int Abc_CommandAbc9Get( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( pAbc->pNtkCur == NULL )
{
- printf( "There is no current network\n" );
+ Abc_Print( -1, "There is no current network\n" );
return 1;
}
if ( !Abc_NtkIsStrash( pAbc->pNtkCur ) )
{
- printf( "The current network should be strashed.\n" );
+ Abc_Print( -1, "The current network should be strashed.\n" );
return 1;
}
// if ( Abc_NtkGetChoiceNum(pAbc->pNtkCur) )
// {
-// printf( "Removing %d choices from the AIG.\n", Abc_NtkGetChoiceNum(pAbc->pNtkCur) );
+// Abc_Print( -1, "Removing %d choices from the AIG.\n", Abc_NtkGetChoiceNum(pAbc->pNtkCur) );
// Abc_AigCleanup(pAbc->pNtkCur->pManFunc);
// }
if ( Abc_NtkGetChoiceNum(pAbc->pNtkCur) )
@@ -22366,14 +22751,7 @@ int Abc_CommandAbc9Get( Abc_Frame_t * pAbc, int argc, char ** argv )
pMan = Abc_NtkToDar( pAbc->pNtkCur, 0, 1 );
pAig = Gia_ManFromAig( pMan );
Aig_ManStop( pMan );
- if ( pAig == NULL )
- {
- printf( "Transferring AIG has failed.\n" );
- return 0;
- }
- if ( pAbc->pAig )
- Gia_ManStop( pAbc->pAig );
- pAbc->pAig = pAig;
+ Abc_CommandUpdate9( pAbc, pAig );
if ( fNames )
{
pAig->vNamesIn = Abc_NtkCollectCiNames( pAbc->pNtkCur );
@@ -22382,12 +22760,12 @@ int Abc_CommandAbc9Get( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( stdout, "usage: &get [-nvh] <file>\n" );
- fprintf( stdout, "\t converts the network into an AIG and moves to the new ABC\n" );
- fprintf( stdout, "\t-n : toggles saving CI/CO names of the AIG [default = %s]\n", fNames? "yes": "no" );
- fprintf( stdout, "\t-v : toggles additional verbose output [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
- fprintf( stdout, "\t<file> : the file name\n");
+ Abc_Print( -2, "usage: &get [-nvh] <file>\n" );
+ Abc_Print( -2, "\t converts the network into an AIG and moves to the new ABC\n" );
+ Abc_Print( -2, "\t-n : toggles saving CI/CO names of the AIG [default = %s]\n", fNames? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggles additional verbose output [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ Abc_Print( -2, "\t<file> : the file name\n");
return 1;
}
@@ -22407,14 +22785,13 @@ int Abc_CommandAbc9Put( Abc_Frame_t * pAbc, int argc, char ** argv )
extern Abc_Ntk_t * Abc_NtkFromAigPhase( Aig_Man_t * pMan );
extern Abc_Ntk_t * Abc_NtkFromDarChoices( Abc_Ntk_t * pNtkOld, Aig_Man_t * pMan );
Aig_Man_t * pMan;
- FILE * pOut, * pErr;
- Abc_Ntk_t * pNtk;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int c;
int fVerbose;
pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
+
+
// set defaults
fVerbose = 0;
@@ -22432,14 +22809,14 @@ int Abc_CommandAbc9Put( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage;
}
}
- if ( pAbc->pAig == NULL )
+ if ( pAbc->pGia == NULL )
{
- fprintf( pErr, "Empty network.\n" );
+ Abc_Print( -1, "Empty network.\n" );
return 1;
}
- if ( Gia_ManHasDandling(pAbc->pAig) == 0 )
+ if ( Gia_ManHasDangling(pAbc->pGia) == 0 )
{
- pMan = Gia_ManToAig( pAbc->pAig, 0 );
+ pMan = Gia_ManToAig( pAbc->pGia, 0 );
pNtk = Abc_NtkFromAigPhase( pMan );
pNtk->pName = Extra_UtilStrsav(pMan->pName);
Aig_ManStop( pMan );
@@ -22447,27 +22824,28 @@ int Abc_CommandAbc9Put( Abc_Frame_t * pAbc, int argc, char ** argv )
else
{
Abc_Ntk_t * pNtkNoCh;
-// printf( "Transforming AIG with %d choice nodes.\n", Gia_ManEquivCountClasses(pAbc->pAig) );
+// Abc_Print( -1, "Transforming AIG with %d choice nodes.\n", Gia_ManEquivCountClasses(pAbc->pGia) );
// create network without choices
- pMan = Gia_ManToAig( pAbc->pAig, 0 );
+ pMan = Gia_ManToAig( pAbc->pGia, 0 );
pNtkNoCh = Abc_NtkFromAigPhase( pMan );
pNtkNoCh->pName = Extra_UtilStrsav(pMan->pName);
Aig_ManStop( pMan );
// derive network with choices
- pMan = Gia_ManToAig( pAbc->pAig, 1 );
+ pMan = Gia_ManToAig( pAbc->pGia, 1 );
pNtk = Abc_NtkFromDarChoices( pNtkNoCh, pMan );
Abc_NtkDelete( pNtkNoCh );
Aig_ManStop( pMan );
}
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
+ Abc_FrameClearVerifStatus( pAbc );
return 0;
usage:
- fprintf( pErr, "usage: &put [-vh]\n" );
- fprintf( pErr, "\t transfer the current network into the old ABC\n" );
- fprintf( pErr, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: &put [-vh]\n" );
+ Abc_Print( -2, "\t transfer the current network into the old ABC\n" );
+ Abc_Print( -2, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -22503,24 +22881,24 @@ int Abc_CommandAbc9Write( Abc_Frame_t * pAbc, int argc, char ** argv )
nArgcNew = argc - globalUtilOptind;
if ( nArgcNew != 1 )
{
- printf( "There is no file name.\n" );
+ Abc_Print( -1, "There is no file name.\n" );
return 1;
}
- if ( pAbc->pAig == NULL )
+ if ( pAbc->pGia == NULL )
{
- printf( "Abc_CommandAbc9Write(): There is no AIG to write.\n" );
+ Abc_Print( -1, "Abc_CommandAbc9Write(): There is no AIG to write.\n" );
return 1;
}
// create the design to write
pFileName = argv[globalUtilOptind];
- Gia_WriteAiger( pAbc->pAig, pFileName, 0, 0 );
+ Gia_WriteAiger( pAbc->pGia, pFileName, 0, 0 );
return 0;
usage:
- fprintf( stdout, "usage: &w [-h] <file>\n" );
- fprintf( stdout, "\t writes the current AIG into the AIGER file\n" );
- fprintf( stdout, "\t-h : print the command usage\n");
- fprintf( stdout, "\t<file> : the file name\n");
+ Abc_Print( -2, "usage: &w [-h] <file>\n" );
+ Abc_Print( -2, "\t writes the current AIG into the AIGER file\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ Abc_Print( -2, "\t<file> : the file name\n");
return 1;
}
@@ -22553,19 +22931,19 @@ int Abc_CommandAbc9Ps( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage;
}
}
- if ( pAbc->pAig == NULL )
+ if ( pAbc->pGia == NULL )
{
- printf( "Abc_CommandAbc9Ps(): There is no AIG.\n" );
+ Abc_Print( -1, "Abc_CommandAbc9Ps(): There is no AIG.\n" );
return 1;
}
- Gia_ManPrintStats( pAbc->pAig, fSwitch );
+ Gia_ManPrintStats( pAbc->pGia, fSwitch );
return 0;
usage:
- fprintf( stdout, "usage: &ps [-ph]\n" );
- fprintf( stdout, "\t prints stats of the current AIG\n" );
- fprintf( stdout, "\t-p : toggle printing switching activity [default = %s]\n", fSwitch? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: &ps [-ph]\n" );
+ Abc_Print( -2, "\t prints stats of the current AIG\n" );
+ Abc_Print( -2, "\t-p : toggle printing switching activity [default = %s]\n", fSwitch? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -22592,7 +22970,7 @@ int Abc_CommandAbc9PFan( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'N':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-N\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
goto usage;
}
nNodes = atoi(argv[globalUtilOptind]);
@@ -22606,19 +22984,19 @@ int Abc_CommandAbc9PFan( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage;
}
}
- if ( pAbc->pAig == NULL )
+ if ( pAbc->pGia == NULL )
{
- printf( "Abc_CommandAbc9PFan(): There is no AIG.\n" );
+ Abc_Print( -1, "Abc_CommandAbc9PFan(): There is no AIG.\n" );
return 1;
}
- Gia_ManPrintFanio( pAbc->pAig, nNodes );
+ Gia_ManPrintFanio( pAbc->pGia, nNodes );
return 0;
usage:
- fprintf( stdout, "usage: &pfan [-N num] [-h]\n" );
- fprintf( stdout, "\t prints fanin/fanout statistics\n" );
- fprintf( stdout, "\t-N num : the number of high-fanout nodes to explore [default = %d]\n", nNodes );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: &pfan [-N num] [-h]\n" );
+ Abc_Print( -2, "\t prints fanin/fanout statistics\n" );
+ Abc_Print( -2, "\t-N num : the number of high-fanout nodes to explore [default = %d]\n", nNodes );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -22651,24 +23029,24 @@ int Abc_CommandAbc9PSig( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage;
}
}
- if ( pAbc->pAig == NULL )
+ if ( pAbc->pGia == NULL )
{
- printf( "Abc_CommandAbc9PSigs(): There is no AIG.\n" );
+ Abc_Print( -1, "Abc_CommandAbc9PSigs(): There is no AIG.\n" );
return 1;
}
- if ( Gia_ManRegNum(pAbc->pAig) == 0 )
+ if ( Gia_ManRegNum(pAbc->pGia) == 0 )
{
- printf( "Abc_CommandAbc9PSigs(): Works only for sequential circuits.\n" );
+ Abc_Print( -1, "Abc_CommandAbc9PSigs(): Works only for sequential circuits.\n" );
return 1;
}
- Gia_ManDetectSeqSignals( pAbc->pAig, fSetReset, 1 );
+ Gia_ManDetectSeqSignals( pAbc->pGia, fSetReset, 1 );
return 0;
usage:
- fprintf( stdout, "usage: &psig [-rh]\n" );
- fprintf( stdout, "\t prints enable/set/reset statistics\n" );
- fprintf( stdout, "\t-r : toggle printing set/reset signals [default = %s]\n", fSetReset? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: &psig [-rh]\n" );
+ Abc_Print( -2, "\t prints enable/set/reset statistics\n" );
+ Abc_Print( -2, "\t-r : toggle printing set/reset signals [default = %s]\n", fSetReset? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -22697,18 +23075,18 @@ int Abc_CommandAbc9Status( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage;
}
}
- if ( pAbc->pAig == NULL )
+ if ( pAbc->pGia == NULL )
{
- printf( "Abc_CommandAbc9Status(): There is no AIG.\n" );
+ Abc_Print( -1, "Abc_CommandAbc9Status(): There is no AIG.\n" );
return 1;
}
- Gia_ManPrintMiterStatus( pAbc->pAig );
+ Gia_ManPrintMiterStatus( pAbc->pGia );
return 0;
usage:
- fprintf( stdout, "usage: &status [-h]\n" );
- fprintf( stdout, "\t prints status of the miter\n" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: &status [-h]\n" );
+ Abc_Print( -2, "\t prints status of the miter\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -22738,20 +23116,20 @@ int Abc_CommandAbc9Show( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage;
}
}
- if ( pAbc->pAig == NULL )
+ if ( pAbc->pGia == NULL )
{
- printf( "Abc_CommandAbc9Show(): There is no AIG.\n" );
+ Abc_Print( -1, "Abc_CommandAbc9Show(): There is no AIG.\n" );
return 1;
}
- pMan = Gia_ManToAig( pAbc->pAig, 0 );
+ pMan = Gia_ManToAig( pAbc->pGia, 0 );
Aig_ManShow( pMan, 0, NULL );
Aig_ManStop( pMan );
return 0;
usage:
- fprintf( stdout, "usage: &show [-h]\n" );
- fprintf( stdout, "\t shows the current AIG using GSView\n" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: &show [-h]\n" );
+ Abc_Print( -2, "\t shows the current AIG using GSView\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -22785,20 +23163,20 @@ int Abc_CommandAbc9Hash( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage;
}
}
- if ( pAbc->pAig == NULL )
+ if ( pAbc->pGia == NULL )
{
- printf( "Abc_CommandAbc9Hash(): There is no AIG.\n" );
+ Abc_Print( -1, "Abc_CommandAbc9Hash(): There is no AIG.\n" );
return 1;
}
- pAbc->pAig = Gia_ManRehash( pTemp = pAbc->pAig, fAddStrash );
- Gia_ManStop( pTemp );
+ pTemp = Gia_ManRehash( pAbc->pGia, fAddStrash );
+ Abc_CommandUpdate9( pAbc, pTemp );
return 0;
usage:
- fprintf( stdout, "usage: &st [-ah]\n" );
- fprintf( stdout, "\t performs structural hashing\n" );
- fprintf( stdout, "\t-a : toggle additional hashing [default = %s]\n", fAddStrash? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: &st [-ah]\n" );
+ Abc_Print( -2, "\t performs structural hashing\n" );
+ Abc_Print( -2, "\t-a : toggle additional hashing [default = %s]\n", fAddStrash? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -22831,25 +23209,25 @@ int Abc_CommandAbc9Topand( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage;
}
}
- if ( pAbc->pAig == NULL )
+ if ( pAbc->pGia == NULL )
{
- printf( "Abc_CommandAbc9Topand(): There is no AIG.\n" );
+ Abc_Print( -1, "Abc_CommandAbc9Topand(): There is no AIG.\n" );
return 1;
}
- if ( Gia_ManRegNum(pAbc->pAig) > 0 )
+ if ( Gia_ManRegNum(pAbc->pGia) > 0 )
{
- printf( "Abc_CommandAbc9Topand(): Can only be applied to a combinational miter.\n" );
+ Abc_Print( -1, "Abc_CommandAbc9Topand(): Can only be applied to a combinational miter.\n" );
return 1;
}
- pAbc->pAig = Gia_ManDupTopAnd( pTemp = pAbc->pAig, fVerbose );
- Gia_ManStop( pTemp );
+ pTemp = Gia_ManDupTopAnd( pAbc->pGia, fVerbose );
+ Abc_CommandUpdate9( pAbc, pTemp );
return 0;
usage:
- fprintf( stdout, "usage: &topand [-vh]\n" );
- fprintf( stdout, "\t performs AND decomposition for combinational miter\n" );
- fprintf( stdout, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: &topand [-vh]\n" );
+ Abc_Print( -2, "\t performs AND decomposition for combinational miter\n" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -22877,7 +23255,7 @@ int Abc_CommandAbc9Cof( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'V':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-V\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-V\" should be followed by an integer.\n" );
goto usage;
}
iVar = atoi(argv[globalUtilOptind]);
@@ -22888,7 +23266,7 @@ int Abc_CommandAbc9Cof( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'L':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-L\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
goto usage;
}
nLimFan = atoi(argv[globalUtilOptind]);
@@ -22905,42 +23283,37 @@ int Abc_CommandAbc9Cof( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage;
}
}
- if ( pAbc->pAig == NULL )
+ if ( pAbc->pGia == NULL )
{
- printf( "Abc_CommandAbc9Cof(): There is no AIG.\n" );
+ Abc_Print( -1, "Abc_CommandAbc9Cof(): There is no AIG.\n" );
return 1;
}
if ( nLimFan )
{
- printf( "Cofactoring all variables whose fanout count is higher than %d.\n", nLimFan );
- pAbc->pAig = Gia_ManDupCofAll( pTemp = pAbc->pAig, nLimFan, fVerbose );
+ Abc_Print( -1, "Cofactoring all variables whose fanout count is higher than %d.\n", nLimFan );
+ pTemp = Gia_ManDupCofAll( pAbc->pGia, nLimFan, fVerbose );
+ Abc_CommandUpdate9( pAbc, pTemp );
}
else if ( iVar )
{
- printf( "Cofactoring one variable with object ID %d.\n", iVar );
- pAbc->pAig = Gia_ManDupCof( pTemp = pAbc->pAig, iVar );
+ Abc_Print( -1, "Cofactoring one variable with object ID %d.\n", iVar );
+ pTemp = Gia_ManDupCof( pAbc->pGia, iVar );
+ Abc_CommandUpdate9( pAbc, pTemp );
}
else
{
- printf( "One of the paramters, -V <num> or -L <num>, should be set on the command line.\n" );
+ Abc_Print( -1, "One of the paramters, -V <num> or -L <num>, should be set on the command line.\n" );
goto usage;
}
- if ( pAbc->pAig == NULL )
- {
- pAbc->pAig = pTemp;
- printf( "Abc_CommandAbc9Cof(): Transformation has failed.\n" );
- return 1;
- }
- Gia_ManStop( pTemp );
return 0;
usage:
- fprintf( stdout, "usage: &cof [-VL num] [-vh]\n" );
- fprintf( stdout, "\t performs cofactoring w.r.t. variable(s)\n" );
- fprintf( stdout, "\t-V num : the zero-based ID of one variable to cofactor [default = %d]\n", iVar );
- fprintf( stdout, "\t-L num : cofactor vars with fanout count higher than this [default = %d]\n", nLimFan );
- fprintf( stdout, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: &cof [-VL num] [-vh]\n" );
+ Abc_Print( -2, "\t performs cofactoring w.r.t. variable(s)\n" );
+ Abc_Print( -2, "\t-V num : the zero-based ID of one variable to cofactor [default = %d]\n", iVar );
+ Abc_Print( -2, "\t-L num : cofactor vars with fanout count higher than this [default = %d]\n", nLimFan );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -22978,21 +23351,21 @@ int Abc_CommandAbc9Trim( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage;
}
}
- if ( pAbc->pAig == NULL )
+ if ( pAbc->pGia == NULL )
{
- printf( "Abc_CommandAbc9Trim(): There is no AIG.\n" );
+ Abc_Print( -1, "Abc_CommandAbc9Trim(): There is no AIG.\n" );
return 1;
}
- pAbc->pAig = Gia_ManDupTrimmed( pTemp = pAbc->pAig, fTrimCis, fTrimCos );
- Gia_ManStop( pTemp );
+ pTemp = Gia_ManDupTrimmed( pAbc->pGia, fTrimCis, fTrimCos );
+ Abc_CommandUpdate9( pAbc, pTemp );
return 0;
usage:
- fprintf( stdout, "usage: &trim [-ioh]\n" );
- fprintf( stdout, "\t removes PIs without fanout and PO driven by constants\n" );
- fprintf( stdout, "\t-i : toggle removing PIs [default = %s]\n", fTrimCis? "yes": "no" );
- fprintf( stdout, "\t-o : toggle removing POs [default = %s]\n", fTrimCos? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: &trim [-ioh]\n" );
+ Abc_Print( -2, "\t removes PIs without fanout and PO driven by constants\n" );
+ Abc_Print( -2, "\t-i : toggle removing PIs [default = %s]\n", fTrimCis? "yes": "no" );
+ Abc_Print( -2, "\t-o : toggle removing POs [default = %s]\n", fTrimCos? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -23034,39 +23407,39 @@ int Abc_CommandAbc9Dfs( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage;
}
}
- if ( pAbc->pAig == NULL )
+ if ( pAbc->pGia == NULL )
{
- printf( "Abc_CommandAbc9Dfs(): There is no AIG.\n" );
+ Abc_Print( -1, "Abc_CommandAbc9Dfs(): There is no AIG.\n" );
return 1;
}
if ( fNormal )
{
- pAbc->pAig = Gia_ManDupOrderAiger( pTemp = pAbc->pAig );
+ pTemp = Gia_ManDupOrderAiger( pAbc->pGia );
if ( fVerbose )
- printf( "AIG objects are reordered as follows: CIs, ANDs, COs.\n" );
+ Abc_Print( -1, "AIG objects are reordered as follows: CIs, ANDs, COs.\n" );
}
else if ( fReverse )
{
- pAbc->pAig = Gia_ManDupOrderDfsReverse( pTemp = pAbc->pAig );
+ pTemp = Gia_ManDupOrderDfsReverse( pAbc->pGia );
if ( fVerbose )
- printf( "AIG objects are reordered in the reserve DFS order.\n" );
+ Abc_Print( -1, "AIG objects are reordered in the reserve DFS order.\n" );
}
else
{
- pAbc->pAig = Gia_ManDupOrderDfs( pTemp = pAbc->pAig );
+ pTemp = Gia_ManDupOrderDfs( pAbc->pGia );
if ( fVerbose )
- printf( "AIG objects are reordered in the DFS order.\n" );
+ Abc_Print( -1, "AIG objects are reordered in the DFS order.\n" );
}
- Gia_ManStop( pTemp );
+ Abc_CommandUpdate9( pAbc, pTemp );
return 0;
usage:
- fprintf( stdout, "usage: &dfs [-nrvh]\n" );
- fprintf( stdout, "\t orders objects in the DFS order\n" );
- fprintf( stdout, "\t-n : toggle using normalized ordering [default = %s]\n", fNormal? "yes": "no" );
- fprintf( stdout, "\t-r : toggle using reverse DFS ordering [default = %s]\n", fReverse? "yes": "no" );
- fprintf( stdout, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: &dfs [-nrvh]\n" );
+ Abc_Print( -2, "\t orders objects in the DFS order\n" );
+ Abc_Print( -2, "\t-n : toggle using normalized ordering [default = %s]\n", fNormal? "yes": "no" );
+ Abc_Print( -2, "\t-r : toggle using reverse DFS ordering [default = %s]\n", fReverse? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -23094,7 +23467,7 @@ int Abc_CommandAbc9Sim( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'W':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-W\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
goto usage;
}
pPars->nWords = atoi(argv[globalUtilOptind]);
@@ -23105,7 +23478,7 @@ int Abc_CommandAbc9Sim( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-F\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
pPars->nIters = atoi(argv[globalUtilOptind]);
@@ -23116,7 +23489,7 @@ int Abc_CommandAbc9Sim( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'T':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-T\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
goto usage;
}
pPars->TimeLimit = atoi(argv[globalUtilOptind]);
@@ -23136,23 +23509,28 @@ int Abc_CommandAbc9Sim( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage;
}
}
- if ( pAbc->pAig == NULL )
+ if ( pAbc->pGia == NULL )
{
- printf( "Abc_CommandAbc9Sim(): There is no AIG.\n" );
+ Abc_Print( -1, "Abc_CommandAbc9Sim(): There is no AIG.\n" );
return 1;
}
- Gia_ManSimSimulate( pAbc->pAig, pPars );
+ if ( Gia_ManRegNum(pAbc->pGia) == 0 )
+ {
+ Abc_Print( -1, "The network is combinational.\n" );
+ return 0;
+ }
+ Gia_ManSimSimulate( pAbc->pGia, pPars );
return 0;
usage:
- fprintf( stdout, "usage: &sim [-WFT <num>] [-mvh]\n" );
- fprintf( stdout, "\t performs random simulation of the sequential miter\n" );
- fprintf( stdout, "\t-W num : the number of words to simulate [default = %d]\n", pPars->nWords );
- fprintf( stdout, "\t-F num : the number of frames to simulate [default = %d]\n", pPars->nIters );
- fprintf( stdout, "\t-T num : approximate runtime limit in seconds [default = %d]\n", pPars->TimeLimit );
- fprintf( stdout, "\t-m : toggle miter vs. any circuit [default = %s]\n", pPars->fCheckMiter? "miter": "circuit" );
- fprintf( stdout, "\t-v : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: &sim [-WFT <num>] [-mvh]\n" );
+ Abc_Print( -2, "\t performs random simulation of the sequential miter\n" );
+ Abc_Print( -2, "\t-W num : the number of words to simulate [default = %d]\n", pPars->nWords );
+ Abc_Print( -2, "\t-F num : the number of frames to simulate [default = %d]\n", pPars->nIters );
+ Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n", pPars->TimeLimit );
+ Abc_Print( -2, "\t-m : toggle miter vs. any circuit [default = %s]\n", pPars->fCheckMiter? "miter": "circuit" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -23170,7 +23548,7 @@ usage:
int Abc_CommandAbc9Resim( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Cec_ParSim_t Pars, * pPars = &Pars;
- int c;
+ int c, RetValue;
Cec_ManSimSetDefaultParams( pPars );
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "Fmvh" ) ) != EOF )
@@ -23180,7 +23558,7 @@ int Abc_CommandAbc9Resim( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-F\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
pPars->nFrames = atoi(argv[globalUtilOptind]);
@@ -23200,21 +23578,24 @@ int Abc_CommandAbc9Resim( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage;
}
}
- if ( pAbc->pAig == NULL )
+ if ( pAbc->pGia == NULL )
{
- printf( "Abc_CommandAbc9Resim(): There is no AIG.\n" );
+ Abc_Print( -1, "Abc_CommandAbc9Resim(): There is no AIG.\n" );
return 1;
}
- Cec_ManSeqResimulateCounter( pAbc->pAig, pPars, pAbc->pCex );
+ RetValue = Cec_ManSeqResimulateCounter( pAbc->pGia, pPars, pAbc->pCex );
+ pAbc->Status = RetValue ? 0 : -1;
+ pAbc->nFrames = pAbc->pCex->iFrame;
+// Abc_FrameReplaceCex( pAbc, &pAbc->pCex );
return 0;
usage:
- fprintf( stdout, "usage: &resim [-F <num>] [-mvh]\n" );
- fprintf( stdout, "\t resimulates equivalence classes using counter-example\n" );
- fprintf( stdout, "\t-F num : the number of additinal frames to simulate [default = %d]\n", pPars->nFrames );
- fprintf( stdout, "\t-m : toggle miter vs. any circuit [default = %s]\n", pPars->fCheckMiter? "miter": "circuit" );
- fprintf( stdout, "\t-v : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: &resim [-F <num>] [-mvh]\n" );
+ Abc_Print( -2, "\t resimulates equivalence classes using counter-example\n" );
+ Abc_Print( -2, "\t-F num : the number of additinal frames to simulate [default = %d]\n", pPars->nFrames );
+ Abc_Print( -2, "\t-m : toggle miter vs. any circuit [default = %s]\n", pPars->fCheckMiter? "miter": "circuit" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -23246,7 +23627,7 @@ int Abc_CommandAbc9SpecI( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-F\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
nFrames = atoi(argv[globalUtilOptind]);
@@ -23257,7 +23638,7 @@ int Abc_CommandAbc9SpecI( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
nBTLimit = atoi(argv[globalUtilOptind]);
@@ -23280,23 +23661,23 @@ int Abc_CommandAbc9SpecI( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage;
}
}
- if ( pAbc->pAig == NULL )
+ if ( pAbc->pGia == NULL )
{
- printf( "Abc_CommandAbc9SpecI(): There is no AIG.\n" );
+ Abc_Print( -1, "Abc_CommandAbc9SpecI(): There is no AIG.\n" );
return 1;
}
- Gia_CommandSpecI( pAbc->pAig, nFrames, nBTLimit, fUseStart, fCheckMiter, fVerbose );
+ Gia_CommandSpecI( pAbc->pGia, nFrames, nBTLimit, fUseStart, fCheckMiter, fVerbose );
return 0;
usage:
- fprintf( stdout, "usage: &speci [-FC <num>] [-fmvh]\n" );
- fprintf( stdout, "\t refines equivalence classes using speculative reduction\n" );
- fprintf( stdout, "\t-F num : the max number of time frames [default = %d]\n", nFrames );
- fprintf( stdout, "\t-C num : the max number of conflicts at a node [default = %d]\n", nBTLimit );
- fprintf( stdout, "\t-f : toggle starting BMC from a later frame [default = %s]\n", fUseStart? "yes": "no" );
- fprintf( stdout, "\t-m : toggle miter vs. any circuit [default = %s]\n", fCheckMiter? "miter": "circuit" );
- fprintf( stdout, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: &speci [-FC <num>] [-fmvh]\n" );
+ Abc_Print( -2, "\t refines equivalence classes using speculative reduction\n" );
+ Abc_Print( -2, "\t-F num : the max number of time frames [default = %d]\n", nFrames );
+ Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", nBTLimit );
+ Abc_Print( -2, "\t-f : toggle starting BMC from a later frame [default = %s]\n", fUseStart? "yes": "no" );
+ Abc_Print( -2, "\t-m : toggle miter vs. any circuit [default = %s]\n", fCheckMiter? "miter": "circuit" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -23326,7 +23707,7 @@ int Abc_CommandAbc9Equiv( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'W':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-W\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
goto usage;
}
pPars->nWords = atoi(argv[globalUtilOptind]);
@@ -23337,7 +23718,7 @@ int Abc_CommandAbc9Equiv( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-F\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
pPars->nFrames = atoi(argv[globalUtilOptind]);
@@ -23348,7 +23729,7 @@ int Abc_CommandAbc9Equiv( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'R':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-R\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
goto usage;
}
pPars->nRounds = atoi(argv[globalUtilOptind]);
@@ -23359,7 +23740,7 @@ int Abc_CommandAbc9Equiv( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'S':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-S\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
goto usage;
}
pPars->nNonRefines = atoi(argv[globalUtilOptind]);
@@ -23370,7 +23751,7 @@ int Abc_CommandAbc9Equiv( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'T':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-T\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
goto usage;
}
pPars->TimeLimit = atoi(argv[globalUtilOptind]);
@@ -23396,27 +23777,155 @@ int Abc_CommandAbc9Equiv( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage;
}
}
- if ( pAbc->pAig == NULL )
+ if ( pAbc->pGia == NULL )
{
- printf( "Abc_CommandAbc9Equiv(): There is no AIG.\n" );
+ Abc_Print( -1, "Abc_CommandAbc9Equiv(): There is no AIG.\n" );
return 1;
}
- Cec_ManSimulation( pAbc->pAig, pPars );
+ Cec_ManSimulation( pAbc->pGia, pPars );
return 0;
usage:
- fprintf( stdout, "usage: &equiv [-WFRST <num>] [-smdvh]\n" );
- fprintf( stdout, "\t computes candidate equivalence classes\n" );
- fprintf( stdout, "\t-W num : the number of words to simulate [default = %d]\n", pPars->nWords );
- fprintf( stdout, "\t-F num : the number of frames to simulate [default = %d]\n", pPars->nFrames );
- fprintf( stdout, "\t-R num : the max number of simulation rounds [default = %d]\n", pPars->nRounds );
- fprintf( stdout, "\t-S num : the max number of rounds w/o refinement to stop [default = %d]\n", pPars->nNonRefines );
- fprintf( stdout, "\t-T num : approximate runtime limit in seconds [default = %d]\n", pPars->TimeLimit );
- fprintf( stdout, "\t-s : toggle seq vs. comb simulation [default = %s]\n", pPars->fSeqSimulate? "yes": "no" );
- fprintf( stdout, "\t-m : toggle miter vs. any circuit [default = %s]\n", pPars->fCheckMiter? "miter": "circuit" );
- fprintf( stdout, "\t-d : toggle using two POs intead of XOR [default = %s]\n", pPars->fDualOut? "yes": "no" );
- fprintf( stdout, "\t-v : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: &equiv [-WFRST <num>] [-smdvh]\n" );
+ Abc_Print( -2, "\t computes candidate equivalence classes\n" );
+ Abc_Print( -2, "\t-W num : the number of words to simulate [default = %d]\n", pPars->nWords );
+ Abc_Print( -2, "\t-F num : the number of frames to simulate [default = %d]\n", pPars->nFrames );
+ Abc_Print( -2, "\t-R num : the max number of simulation rounds [default = %d]\n", pPars->nRounds );
+ Abc_Print( -2, "\t-S num : the max number of rounds w/o refinement to stop [default = %d]\n", pPars->nNonRefines );
+ Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n", pPars->TimeLimit );
+ Abc_Print( -2, "\t-s : toggle seq vs. comb simulation [default = %s]\n", pPars->fSeqSimulate? "yes": "no" );
+ Abc_Print( -2, "\t-m : toggle miter vs. any circuit [default = %s]\n", pPars->fCheckMiter? "miter": "circuit" );
+ Abc_Print( -2, "\t-d : toggle using two POs intead of XOR [default = %s]\n", pPars->fDualOut? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_CommandAbc9Equiv2( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ extern void Ssw_SignalFilterGia( Gia_Man_t * p, int nFramesMax, int nConfMax, int nRounds, int TimeLimit, int TimeLimit2, Abc_Cex_t * pCex, int fVerbose );
+ int nFramesMax = 20;
+ int nConfMax = 500;
+ int nRounds = 10;
+ int TimeLimit = 0;
+ int TimeLimit2 = 0;
+ int fUseCex = 0;
+ int fVerbose = 0;
+ int c;
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "FCRTSxvh" ) ) != EOF )
+ {
+ switch ( c )
+ {
+ case 'F':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ nFramesMax = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( nFramesMax < 0 )
+ goto usage;
+ break;
+ case 'C':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ nConfMax = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( nConfMax < 0 )
+ goto usage;
+ break;
+ case 'R':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ nRounds = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( nRounds < 0 )
+ goto usage;
+ break;
+ case 'T':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ TimeLimit = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( TimeLimit < 0 )
+ goto usage;
+ break;
+ case 'S':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ TimeLimit2 = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( TimeLimit2 < 0 )
+ goto usage;
+ break;
+ case 'x':
+ fUseCex ^= 1;
+ break;
+ case 'v':
+ fVerbose ^= 1;
+ break;
+ case 'h':
+ goto usage;
+ default:
+ goto usage;
+ }
+ }
+ if ( pAbc->pGia == NULL )
+ {
+ Abc_Print( -1, "Abc_CommandAbc9Equiv2(): There is no AIG.\n" );
+ return 1;
+ }
+ if ( fUseCex )
+ {
+ if ( pAbc->pCex->nPis != Gia_ManPiNum(pAbc->pGia) )
+ {
+ Abc_Print( -1, "Abc_CommandAbc9Equiv2(): The number of PIs differs in cex (%d) and in AIG (%d).\n",
+ pAbc->pCex->nPis, Gia_ManPiNum(pAbc->pGia) );
+ return 1;
+ }
+ }
+ Ssw_SignalFilterGia( pAbc->pGia, nFramesMax, nConfMax, nRounds, TimeLimit, TimeLimit2, fUseCex? pAbc->pCex: NULL, fVerbose );
+ pAbc->Status = -1;
+// pAbc->nFrames = pAbc->pCex->iFrame;
+// Abc_FrameReplaceCex( pAbc, &pAbc->pCex );
+ return 0;
+
+usage:
+ Abc_Print( -2, "usage: &equiv2 [-FCRTS <num>] [-xvh]\n" );
+ Abc_Print( -2, "\t computes candidate equivalence classes\n" );
+ Abc_Print( -2, "\t-F num : the max number of frames for BMC [default = %d]\n", nFramesMax );
+ Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", nConfMax );
+ Abc_Print( -2, "\t-R num : the max number of BMC rounds [default = %d]\n", nRounds );
+ Abc_Print( -2, "\t-T num : runtime limit in seconds for all rounds [default = %d]\n", TimeLimit );
+ Abc_Print( -2, "\t-S num : runtime limit in seconds for one round [default = %d]\n", TimeLimit2 );
+ Abc_Print( -2, "\t-x : toggle using the current cex to perform refinement [default = %s]\n", fUseCex? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -23444,7 +23953,7 @@ int Abc_CommandAbc9Semi( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'W':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-W\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
goto usage;
}
pPars->nWords = atoi(argv[globalUtilOptind]);
@@ -23455,7 +23964,7 @@ int Abc_CommandAbc9Semi( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'R':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-R\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
goto usage;
}
pPars->nRounds = atoi(argv[globalUtilOptind]);
@@ -23466,7 +23975,7 @@ int Abc_CommandAbc9Semi( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-F\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
pPars->nFrames = atoi(argv[globalUtilOptind]);
@@ -23477,7 +23986,7 @@ int Abc_CommandAbc9Semi( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'S':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-S\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
goto usage;
}
pPars->nNonRefines = atoi(argv[globalUtilOptind]);
@@ -23488,7 +23997,7 @@ int Abc_CommandAbc9Semi( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'M':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-M\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
goto usage;
}
pPars->nMinOutputs = atoi(argv[globalUtilOptind]);
@@ -23499,7 +24008,7 @@ int Abc_CommandAbc9Semi( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
pPars->nBTLimit = atoi(argv[globalUtilOptind]);
@@ -23510,7 +24019,7 @@ int Abc_CommandAbc9Semi( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'T':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-T\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
goto usage;
}
pPars->TimeLimit = atoi(argv[globalUtilOptind]);
@@ -23533,28 +24042,28 @@ int Abc_CommandAbc9Semi( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage;
}
}
- if ( pAbc->pAig == NULL )
+ if ( pAbc->pGia == NULL )
{
- printf( "Abc_CommandAbc9Resim(): There is no AIG.\n" );
+ Abc_Print( -1, "Abc_CommandAbc9Resim(): There is no AIG.\n" );
return 1;
}
- Cec_ManSeqSemiformal( pAbc->pAig, pPars );
+ Cec_ManSeqSemiformal( pAbc->pGia, pPars );
return 0;
usage:
- fprintf( stdout, "usage: &semi [-WRFSMCT <num>] [-mdvh]\n" );
- fprintf( stdout, "\t performs semiformal refinement of equivalence classes\n" );
- fprintf( stdout, "\t-W num : the number of words to simulate [default = %d]\n", pPars->nWords );
- fprintf( stdout, "\t-R num : the max number of rounds to simulate [default = %d]\n", pPars->nRounds );
- fprintf( stdout, "\t-F num : the max number of frames to unroll [default = %d]\n", pPars->nFrames );
- fprintf( stdout, "\t-S num : the max number of rounds w/o refinement to stop [default = %d]\n", pPars->nNonRefines );
- fprintf( stdout, "\t-M num : the min number of outputs of bounded SRM [default = %d]\n", pPars->nMinOutputs );
- fprintf( stdout, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
- fprintf( stdout, "\t-T num : approximate runtime limit in seconds [default = %d]\n", pPars->TimeLimit );
- fprintf( stdout, "\t-m : toggle miter vs. any circuit [default = %s]\n", pPars->fCheckMiter? "miter": "circuit" );
- fprintf( stdout, "\t-d : toggle using two POs intead of XOR [default = %s]\n", pPars->fDualOut? "yes": "no" );
- fprintf( stdout, "\t-v : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: &semi [-WRFSMCT <num>] [-mdvh]\n" );
+ Abc_Print( -2, "\t performs semiformal refinement of equivalence classes\n" );
+ Abc_Print( -2, "\t-W num : the number of words to simulate [default = %d]\n", pPars->nWords );
+ Abc_Print( -2, "\t-R num : the max number of rounds to simulate [default = %d]\n", pPars->nRounds );
+ Abc_Print( -2, "\t-F num : the max number of frames to unroll [default = %d]\n", pPars->nFrames );
+ Abc_Print( -2, "\t-S num : the max number of rounds w/o refinement to stop [default = %d]\n", pPars->nNonRefines );
+ Abc_Print( -2, "\t-M num : the min number of outputs of bounded SRM [default = %d]\n", pPars->nMinOutputs );
+ Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
+ Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n", pPars->TimeLimit );
+ Abc_Print( -2, "\t-m : toggle miter vs. any circuit [default = %s]\n", pPars->fCheckMiter? "miter": "circuit" );
+ Abc_Print( -2, "\t-d : toggle using two POs intead of XOR [default = %s]\n", pPars->fDualOut? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -23582,7 +24091,7 @@ int Abc_CommandAbc9Times( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'N':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-T\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
goto usage;
}
nTimes = atoi(argv[globalUtilOptind]);
@@ -23599,21 +24108,21 @@ int Abc_CommandAbc9Times( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage;
}
}
- if ( pAbc->pAig == NULL )
+ if ( pAbc->pGia == NULL )
{
- printf( "Abc_CommandAbc9Times(): There is no AIG.\n" );
+ Abc_Print( -1, "Abc_CommandAbc9Times(): There is no AIG.\n" );
return 1;
}
- pAbc->pAig = Gia_ManDupTimes( pTemp = pAbc->pAig, nTimes );
- Gia_ManStop( pTemp );
+ pTemp = Gia_ManDupTimes( pAbc->pGia, nTimes );
+ Abc_CommandUpdate9( pAbc, pTemp );
return 0;
usage:
- fprintf( stdout, "usage: &times [-N <num>] [-vh]\n" );
- fprintf( stdout, "\t creates several \"parallel\" copies of the design\n" );
- fprintf( stdout, "\t-N num : number of copies to create [default = %d]\n", nTimes );
- fprintf( stdout, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: &times [-N <num>] [-vh]\n" );
+ Abc_Print( -2, "\t creates several \"parallel\" copies of the design\n" );
+ Abc_Print( -2, "\t-N num : number of copies to create [default = %d]\n", nTimes );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -23643,7 +24152,7 @@ int Abc_CommandAbc9Frames( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-F\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
pPars->nFrames = atoi(argv[globalUtilOptind]);
@@ -23654,7 +24163,7 @@ int Abc_CommandAbc9Frames( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'L':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-L\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
goto usage;
}
nCofFanLit = atoi(argv[globalUtilOptind]);
@@ -23674,26 +24183,31 @@ int Abc_CommandAbc9Frames( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage;
}
}
- if ( pAbc->pAig == NULL )
+ if ( pAbc->pGia == NULL )
{
- printf( "Abc_CommandAbc9Frames(): There is no AIG.\n" );
+ Abc_Print( -1, "Abc_CommandAbc9Frames(): There is no AIG.\n" );
return 1;
}
+ if ( Gia_ManRegNum(pAbc->pGia) == 0 )
+ {
+ Abc_Print( -1, "The network is combinational.\n" );
+ return 0;
+ }
if ( nCofFanLit )
- pAbc->pAig = Gia_ManUnrollAndCofactor( pTemp = pAbc->pAig, pPars->nFrames, nCofFanLit, pPars->fVerbose );
+ pTemp = Gia_ManUnrollAndCofactor( pAbc->pGia, pPars->nFrames, nCofFanLit, pPars->fVerbose );
else
- pAbc->pAig = Gia_ManFrames( pTemp = pAbc->pAig, pPars );
- Gia_ManStop( pTemp );
+ pTemp = Gia_ManFrames( pAbc->pGia, pPars );
+ Abc_CommandUpdate9( pAbc, pTemp );
return 0;
usage:
- fprintf( stdout, "usage: &frames [-FL <num>] [-ivh]\n" );
- fprintf( stdout, "\t unrolls the design for several timeframes\n" );
- fprintf( stdout, "\t-F num : the number of frames to unroll [default = %d]\n", pPars->nFrames );
- fprintf( stdout, "\t-L num : the limit on fanout count of resets/enables to cofactor [default = %d]\n", nCofFanLit );
- fprintf( stdout, "\t-i : toggle initializing registers [default = %s]\n", pPars->fInit? "yes": "no" );
- fprintf( stdout, "\t-v : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: &frames [-FL <num>] [-ivh]\n" );
+ Abc_Print( -2, "\t unrolls the design for several timeframes\n" );
+ Abc_Print( -2, "\t-F num : the number of frames to unroll [default = %d]\n", pPars->nFrames );
+ Abc_Print( -2, "\t-L num : the limit on fanout count of resets/enables to cofactor [default = %d]\n", nCofFanLit );
+ Abc_Print( -2, "\t-i : toggle initializing registers [default = %s]\n", pPars->fInit? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -23722,7 +24236,7 @@ int Abc_CommandAbc9Retime( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'N':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-N\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
goto usage;
}
nMaxIters = atoi(argv[globalUtilOptind]);
@@ -23739,21 +24253,26 @@ int Abc_CommandAbc9Retime( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage;
}
}
- if ( pAbc->pAig == NULL )
+ if ( pAbc->pGia == NULL )
{
- printf( "Abc_CommandAbc9Retime(): There is no AIG.\n" );
+ Abc_Print( -1, "Abc_CommandAbc9Retime(): There is no AIG.\n" );
return 1;
}
- pAbc->pAig = Gia_ManRetimeForward( pTemp = pAbc->pAig, nMaxIters, fVerbose );
- Gia_ManStop( pTemp );
+ if ( Gia_ManRegNum(pAbc->pGia) == 0 )
+ {
+ Abc_Print( -1, "The network is combinational.\n" );
+ return 0;
+ }
+ pTemp = Gia_ManRetimeForward( pAbc->pGia, nMaxIters, fVerbose );
+ Abc_CommandUpdate9( pAbc, pTemp );
return 0;
usage:
- fprintf( stdout, "usage: &retime [-N <num>] [-vh]\n" );
- fprintf( stdout, "\t performs most-forward retiming\n" );
- fprintf( stdout, "\t-N num : the number of incremental iterations [default = %d]\n", nMaxIters );
- fprintf( stdout, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: &retime [-N <num>] [-vh]\n" );
+ Abc_Print( -2, "\t performs most-forward retiming\n" );
+ Abc_Print( -2, "\t-N num : the number of incremental iterations [default = %d]\n", nMaxIters );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -23791,24 +24310,187 @@ int Abc_CommandAbc9Enable( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage;
}
}
- if ( pAbc->pAig == NULL )
+ if ( pAbc->pGia == NULL )
{
- printf( "Abc_CommandAbc9Enable(): There is no AIG.\n" );
+ Abc_Print( -1, "Abc_CommandAbc9Enable(): There is no AIG.\n" );
return 1;
}
if ( fRemove )
- pAbc->pAig = Gia_ManRemoveEnables( pTemp = pAbc->pAig );
+ pTemp = Gia_ManRemoveEnables( pAbc->pGia );
else
- pAbc->pAig = Gia_ManDupSelf( pTemp = pAbc->pAig );
- Gia_ManStop( pTemp );
+ pTemp = Gia_ManDupSelf( pAbc->pGia );
+ Abc_CommandUpdate9( pAbc, pTemp );
return 0;
usage:
- fprintf( stdout, "usage: &enable [-rvh]\n" );
- fprintf( stdout, "\t adds or removes flop enable signals\n" );
- fprintf( stdout, "\t-r : toggle adding vs. removing enables [default = %s]\n", fRemove? "remove": "add" );
- fprintf( stdout, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: &enable [-rvh]\n" );
+ Abc_Print( -2, "\t adds or removes flop enable signals\n" );
+ Abc_Print( -2, "\t-r : toggle adding vs. removing enables [default = %s]\n", fRemove? "remove": "add" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_CommandAbc9Dc2( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ Gia_Man_t * pTemp;
+ int c, fVerbose = 0;
+ int fUpdateLevel = 1;
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "lvh" ) ) != EOF )
+ {
+ switch ( c )
+ {
+ case 'l':
+ fUpdateLevel ^= 1;
+ break;
+ case 'v':
+ fVerbose ^= 1;
+ break;
+ case 'h':
+ goto usage;
+ default:
+ goto usage;
+ }
+ }
+ if ( pAbc->pGia == NULL )
+ {
+ Abc_Print( -1, "Abc_CommandAbc9Dc2(): There is no AIG.\n" );
+ return 1;
+ }
+ pTemp = Gia_ManCompress2( pAbc->pGia, fUpdateLevel, fVerbose );
+ Abc_CommandUpdate9( pAbc, pTemp );
+ return 0;
+
+usage:
+ Abc_Print( -2, "usage: &dc2 [-lvh]\n" );
+ Abc_Print( -2, "\t performs heavy rewriting of the AIG\n" );
+ Abc_Print( -2, "\t-l : toggle level update during rewriting [default = %s]\n", fUpdateLevel? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_CommandAbc9Bidec( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ Gia_Man_t * pTemp;
+ int c, fVerbose = 0;
+ int fUpdateLevel = 1;
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "lvh" ) ) != EOF )
+ {
+ switch ( c )
+ {
+ case 'l':
+ fUpdateLevel ^= 1;
+ break;
+ case 'v':
+ fVerbose ^= 1;
+ break;
+ case 'h':
+ goto usage;
+ default:
+ goto usage;
+ }
+ }
+ if ( pAbc->pGia == NULL )
+ {
+ Abc_Print( -1, "Abc_CommandAbc9Bidec(): There is no AIG.\n" );
+ return 1;
+ }
+ if ( pAbc->pGia->pMapping == NULL )
+ {
+ Abc_Print( -1, "Abc_CommandAbc9Bidec(): Mapping of the AIG is not defined.\n" );
+ return 1;
+ }
+ pTemp = Gia_ManPerformBidec( pAbc->pGia, fVerbose );
+ Abc_CommandUpdate9( pAbc, pTemp );
+ return 0;
+
+usage:
+ Abc_Print( -2, "usage: &bidec [-vh]\n" );
+ Abc_Print( -2, "\t performs heavy rewriting of the AIG\n" );
+// Abc_Print( -2, "\t-l : toggle level update during rewriting [default = %s]\n", fUpdateLevel? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_CommandAbc9Shrink( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ Gia_Man_t * pTemp;
+ int c,fVerbose = 0;
+ int fKeepLevel = 0;
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "lvh" ) ) != EOF )
+ {
+ switch ( c )
+ {
+ case 'l':
+ fKeepLevel ^= 1;
+ break;
+ case 'v':
+ fVerbose ^= 1;
+ break;
+ case 'h':
+ goto usage;
+ default:
+ goto usage;
+ }
+ }
+ if ( pAbc->pGia == NULL )
+ {
+ Abc_Print( -1, "Abc_CommandAbc9Shrink(): There is no AIG.\n" );
+ return 1;
+ }
+ if ( pAbc->pGia->pMapping == NULL )
+ {
+ Abc_Print( -1, "Abc_CommandAbc9Shrink(): Mapping of the AIG is not defined.\n" );
+ return 1;
+ }
+ pTemp = Gia_ManPerformMapShrink( pAbc->pGia, fKeepLevel, fVerbose );
+ Abc_CommandUpdate9( pAbc, pTemp );
+ return 0;
+
+usage:
+ Abc_Print( -2, "usage: &shrink [-lvh]\n" );
+ Abc_Print( -2, "\t performs fast shrinking using current mapping\n" );
+ Abc_Print( -2, "\t-l : toggle level update during shrinking [default = %s]\n", fKeepLevel? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -23861,14 +24543,14 @@ int Abc_CommandAbc9Miter( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( fTrans )
{
- if ( (Gia_ManPoNum(pAbc->pAig) & 1) == 1 )
+ if ( (Gia_ManPoNum(pAbc->pGia) & 1) == 1 )
{
- printf( "Abc_CommandAbc9Miter(): The number of outputs should be even.\n" );
+ Abc_Print( -1, "Abc_CommandAbc9Miter(): The number of outputs should be even.\n" );
return 0;
}
- pAbc->pAig = Gia_ManTransformMiter( pAux = pAbc->pAig );
+ pAbc->pGia = Gia_ManTransformMiter( pAux = pAbc->pGia );
Gia_ManStop( pAux );
- printf( "The miter (current AIG) is transformed by XORing POs pair-wise.\n" );
+ Abc_Print( -1, "The miter (current AIG) is transformed by XORing POs pair-wise.\n" );
return 0;
}
@@ -23876,7 +24558,7 @@ int Abc_CommandAbc9Miter( Abc_Frame_t * pAbc, int argc, char ** argv )
nArgcNew = argc - globalUtilOptind;
if ( nArgcNew != 1 )
{
- printf( "File name is not given on the command line.\n" );
+ Abc_Print( -1, "File name is not given on the command line.\n" );
return 1;
}
@@ -23888,40 +24570,34 @@ int Abc_CommandAbc9Miter( Abc_Frame_t * pAbc, int argc, char ** argv )
*pTemp = '\\';
if ( (pFile = fopen( FileName, "r" )) == NULL )
{
- fprintf( pAbc->Err, "Cannot open input file \"%s\". ", FileName );
+ Abc_Print( -1, "Cannot open input file \"%s\". ", FileName );
if ( (FileName = Extra_FileGetSimilarName( FileName, ".aig", NULL, NULL, NULL, NULL )) )
- fprintf( pAbc->Err, "Did you mean \"%s\"?", FileName );
- fprintf( pAbc->Err, "\n" );
+ Abc_Print( 1, "Did you mean \"%s\"?", FileName );
+ Abc_Print( 1, "\n" );
return 1;
}
fclose( pFile );
pSecond = Gia_ReadAiger( FileName, 0 );
if ( pSecond == NULL )
{
- printf( "Reading AIGER has failed.\n" );
+ Abc_Print( -1, "Reading AIGER has failed.\n" );
return 0;
}
// compute the miter
- pAbc->pAig = Gia_ManMiter( pAux = pAbc->pAig, pSecond, fDualOut, fSeq, fVerbose );
+ pAux = Gia_ManMiter( pAbc->pGia, pSecond, fDualOut, fSeq, fVerbose );
Gia_ManStop( pSecond );
- if ( pAbc->pAig == NULL )
- {
- printf( "Miter construction has failed.\n" );
- pAbc->pAig = pAux;
- }
- else
- Gia_ManStop( pAux );
+ Abc_CommandUpdate9( pAbc, pAux );
return 0;
usage:
- fprintf( stdout, "usage: &miter [-dstvh] <file>\n" );
- fprintf( stdout, "\t creates miter of two designs (current AIG vs. <file>)\n" );
- fprintf( stdout, "\t-d : toggle creating dual output miter [default = %s]\n", fDualOut? "yes": "no" );
- fprintf( stdout, "\t-s : toggle creating sequential miter [default = %s]\n", fSeq? "yes": "no" );
- fprintf( stdout, "\t-t : toggle XORing pair-wise POs of the miter [default = %s]\n", fTrans? "yes": "no" );
- fprintf( stdout, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
- fprintf( stdout, "\t<file> : AIGER file with the design to miter\n");
+ Abc_Print( -2, "usage: &miter [-dstvh] <file>\n" );
+ Abc_Print( -2, "\t creates miter of two designs (current AIG vs. <file>)\n" );
+ Abc_Print( -2, "\t-d : toggle creating dual output miter [default = %s]\n", fDualOut? "yes": "no" );
+ Abc_Print( -2, "\t-s : toggle creating sequential miter [default = %s]\n", fSeq? "yes": "no" );
+ Abc_Print( -2, "\t-t : toggle XORing pair-wise POs of the miter [default = %s]\n", fTrans? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ Abc_Print( -2, "\t<file> : AIGER file with the design to miter\n");
return 1;
}
@@ -23961,22 +24637,22 @@ int Abc_CommandAbc9Scl( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage;
}
}
- if ( pAbc->pAig == NULL )
+ if ( pAbc->pGia == NULL )
{
- printf( "Abc_CommandAbc9Scl(): There is no AIG.\n" );
+ Abc_Print( -1, "Abc_CommandAbc9Scl(): There is no AIG.\n" );
return 1;
}
- pAbc->pAig = Gia_ManSeqStructSweep( pTemp = pAbc->pAig, fConst, fEquiv, fVerbose );
- Gia_ManStop( pTemp );
+ pTemp = Gia_ManSeqStructSweep( pAbc->pGia, fConst, fEquiv, fVerbose );
+ Abc_CommandUpdate9( pAbc, pTemp );
return 0;
usage:
- fprintf( stdout, "usage: &scl [-cevh]\n" );
- fprintf( stdout, "\t performs structural sequential cleanup\n" );
- fprintf( stdout, "\t-c : toggle removing stuck-at constant registers [default = %s]\n", fConst? "yes": "no" );
- fprintf( stdout, "\t-e : toggle removing equivalent-driver registers [default = %s]\n", fEquiv? "yes": "no" );
- fprintf( stdout, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: &scl [-cevh]\n" );
+ Abc_Print( -2, "\t performs structural sequential cleanup\n" );
+ Abc_Print( -2, "\t-c : toggle removing stuck-at constant registers [default = %s]\n", fConst? "yes": "no" );
+ Abc_Print( -2, "\t-e : toggle removing equivalent-driver registers [default = %s]\n", fEquiv? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -24006,7 +24682,7 @@ int Abc_CommandAbc9Lcorr( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-F\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
pPars->nFrames = atoi(argv[globalUtilOptind]);
@@ -24017,7 +24693,7 @@ int Abc_CommandAbc9Lcorr( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
pPars->nBTLimit = atoi(argv[globalUtilOptind]);
@@ -24028,7 +24704,7 @@ int Abc_CommandAbc9Lcorr( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'P':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-P\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
goto usage;
}
pPars->nPrefix = atoi(argv[globalUtilOptind]);
@@ -24049,31 +24725,30 @@ int Abc_CommandAbc9Lcorr( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage;
}
}
- if ( pAbc->pAig == NULL )
+ if ( pAbc->pGia == NULL )
{
- printf( "Abc_CommandAbc9Lcorr(): There is no AIG.\n" );
+ Abc_Print( -1, "Abc_CommandAbc9Lcorr(): There is no AIG.\n" );
return 1;
}
- pAbc->pAig = Cec_ManLSCorrespondence( pTemp = pAbc->pAig, pPars );
- if ( pAbc->pAig == NULL )
+ if ( Gia_ManRegNum(pAbc->pGia) == 0 )
{
- pAbc->pAig = pTemp;
- printf( "Abc_CommandAbc9Lcorr(): Command has failed.\n" );
+ Abc_Print( -1, "The network is combinational.\n" );
+ return 0;
}
- else
- Gia_ManStop( pTemp );
+ pTemp = Cec_ManLSCorrespondence( pAbc->pGia, pPars );
+ Abc_CommandUpdate9( pAbc, pTemp );
return 0;
usage:
- fprintf( stdout, "usage: &lcorr [-FCP num] [-rcvh]\n" );
- fprintf( stdout, "\t performs latch correpondence computation\n" );
- fprintf( stdout, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
- fprintf( stdout, "\t-F num : the number of timeframes in inductive case [default = %d]\n", pPars->nFrames );
- fprintf( stdout, "\t-P num : the number of timeframes in the prefix [default = %d]\n", pPars->nPrefix );
- fprintf( stdout, "\t-r : toggle using implication rings during refinement [default = %s]\n", pPars->fUseRings? "yes": "no" );
- fprintf( stdout, "\t-c : toggle using circuit-based SAT solver [default = %s]\n", pPars->fUseCSat? "yes": "no" );
- fprintf( stdout, "\t-v : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: &lcorr [-FCP num] [-rcvh]\n" );
+ Abc_Print( -2, "\t performs latch correpondence computation\n" );
+ Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
+ Abc_Print( -2, "\t-F num : the number of timeframes in inductive case [default = %d]\n", pPars->nFrames );
+ Abc_Print( -2, "\t-P num : the number of timeframes in the prefix [default = %d]\n", pPars->nPrefix );
+ Abc_Print( -2, "\t-r : toggle using implication rings during refinement [default = %s]\n", pPars->fUseRings? "yes": "no" );
+ Abc_Print( -2, "\t-c : toggle using circuit-based SAT solver [default = %s]\n", pPars->fUseCSat? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -24102,7 +24777,7 @@ int Abc_CommandAbc9Scorr( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-F\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
pPars->nFrames = atoi(argv[globalUtilOptind]);
@@ -24113,7 +24788,7 @@ int Abc_CommandAbc9Scorr( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
pPars->nBTLimit = atoi(argv[globalUtilOptind]);
@@ -24124,7 +24799,7 @@ int Abc_CommandAbc9Scorr( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'P':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-P\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
goto usage;
}
pPars->nPrefix = atoi(argv[globalUtilOptind]);
@@ -24151,33 +24826,32 @@ int Abc_CommandAbc9Scorr( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage;
}
}
- if ( pAbc->pAig == NULL )
+ if ( pAbc->pGia == NULL )
{
- printf( "Abc_CommandAbc9Scorr(): There is no AIG.\n" );
+ Abc_Print( -1, "Abc_CommandAbc9Scorr(): There is no AIG.\n" );
return 1;
}
- pAbc->pAig = Cec_ManLSCorrespondence( pTemp = pAbc->pAig, pPars );
- if ( pAbc->pAig == NULL )
+ if ( Gia_ManRegNum(pAbc->pGia) == 0 )
{
- pAbc->pAig = pTemp;
- printf( "Abc_CommandAbc9Scorr(): Command has failed.\n" );
+ Abc_Print( -1, "The network is combinational.\n" );
+ return 0;
}
- else
- Gia_ManStop( pTemp );
+ pTemp = Cec_ManLSCorrespondence( pAbc->pGia, pPars );
+ Abc_CommandUpdate9( pAbc, pTemp );
return 0;
usage:
- fprintf( stdout, "usage: &scorr [-FCP num] [-recwvh]\n" );
- fprintf( stdout, "\t performs signal correpondence computation\n" );
- fprintf( stdout, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
- fprintf( stdout, "\t-F num : the number of timeframes in inductive case [default = %d]\n", pPars->nFrames );
- fprintf( stdout, "\t-P num : the number of timeframes in the prefix [default = %d]\n", pPars->nPrefix );
- fprintf( stdout, "\t-r : toggle using implication rings during refinement [default = %s]\n", pPars->fUseRings? "yes": "no" );
- fprintf( stdout, "\t-e : toggle using equivalences as choices [default = %s]\n", pPars->fMakeChoices? "yes": "no" );
- fprintf( stdout, "\t-c : toggle using circuit-based SAT solver [default = %s]\n", pPars->fUseCSat? "yes": "no" );
- fprintf( stdout, "\t-w : toggle printing verbose info about equivalent flops [default = %s]\n", pPars->fVerboseFlops? "yes": "no" );
- fprintf( stdout, "\t-v : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: &scorr [-FCP num] [-recwvh]\n" );
+ Abc_Print( -2, "\t performs signal correpondence computation\n" );
+ Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
+ Abc_Print( -2, "\t-F num : the number of timeframes in inductive case [default = %d]\n", pPars->nFrames );
+ Abc_Print( -2, "\t-P num : the number of timeframes in the prefix [default = %d]\n", pPars->nPrefix );
+ Abc_Print( -2, "\t-r : toggle using implication rings during refinement [default = %s]\n", pPars->fUseRings? "yes": "no" );
+ Abc_Print( -2, "\t-e : toggle using equivalences as choices [default = %s]\n", pPars->fMakeChoices? "yes": "no" );
+ Abc_Print( -2, "\t-c : toggle using circuit-based SAT solver [default = %s]\n", pPars->fUseCSat? "yes": "no" );
+ Abc_Print( -2, "\t-w : toggle printing verbose info about equivalent flops [default = %s]\n", pPars->fVerboseFlops? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -24206,7 +24880,7 @@ int Abc_CommandAbc9Choice( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
pPars->nBTLimit = atoi(argv[globalUtilOptind]);
@@ -24224,28 +24898,22 @@ int Abc_CommandAbc9Choice( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage;
}
}
- if ( pAbc->pAig == NULL )
+ if ( pAbc->pGia == NULL )
{
- printf( "Abc_CommandAbc9Choice(): There is no AIG.\n" );
+ Abc_Print( -1, "Abc_CommandAbc9Choice(): There is no AIG.\n" );
return 1;
}
- pAbc->pAig = Cec_ManChoiceComputation( pTemp = pAbc->pAig, pPars );
- if ( pAbc->pAig == NULL )
- {
- pAbc->pAig = pTemp;
- printf( "Abc_CommandAbc9Choice(): Command has failed.\n" );
- }
- else
- Gia_ManStop( pTemp );
+ pTemp = Cec_ManChoiceComputation( pAbc->pGia, pPars );
+ Abc_CommandUpdate9( pAbc, pTemp );
return 0;
usage:
- fprintf( stdout, "usage: &choice [-C num] [-cvh]\n" );
- fprintf( stdout, "\t performs computation of structural choices\n" );
- fprintf( stdout, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
- fprintf( stdout, "\t-c : toggle using circuit-based SAT solver [default = %s]\n", pPars->fUseCSat? "yes": "no" );
- fprintf( stdout, "\t-v : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: &choice [-C num] [-cvh]\n" );
+ Abc_Print( -2, "\t performs computation of structural choices\n" );
+ Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
+ Abc_Print( -2, "\t-c : toggle using circuit-based SAT solver [default = %s]\n", pPars->fUseCSat? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -24275,7 +24943,7 @@ int Abc_CommandAbc9Sat( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
pPars->nBTLimit = atoi(argv[globalUtilOptind]);
@@ -24286,7 +24954,7 @@ int Abc_CommandAbc9Sat( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'S':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-S\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
goto usage;
}
pPars->nSatVarMax = atoi(argv[globalUtilOptind]);
@@ -24297,7 +24965,7 @@ int Abc_CommandAbc9Sat( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'N':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-N\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
goto usage;
}
pPars->nCallsRecycle = atoi(argv[globalUtilOptind]);
@@ -24324,9 +24992,9 @@ int Abc_CommandAbc9Sat( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage;
}
}
- if ( pAbc->pAig == NULL )
+ if ( pAbc->pGia == NULL )
{
- printf( "Abc_CommandAbc9Sat(): There is no AIG.\n" );
+ Abc_Print( -1, "Abc_CommandAbc9Sat(): There is no AIG.\n" );
return 1;
}
if ( fCSat )
@@ -24334,33 +25002,33 @@ int Abc_CommandAbc9Sat( Abc_Frame_t * pAbc, int argc, char ** argv )
Vec_Int_t * vCounters;
Vec_Str_t * vStatus;
if ( pPars->fLearnCls )
- vCounters = Tas_ManSolveMiterNc( pAbc->pAig, pPars->nBTLimit, &vStatus, pPars->fVerbose );
+ vCounters = Tas_ManSolveMiterNc( pAbc->pGia, pPars->nBTLimit, &vStatus, pPars->fVerbose );
else if ( pPars->fNonChrono )
- vCounters = Cbs_ManSolveMiterNc( pAbc->pAig, pPars->nBTLimit, &vStatus, pPars->fVerbose );
+ vCounters = Cbs_ManSolveMiterNc( pAbc->pGia, pPars->nBTLimit, &vStatus, pPars->fVerbose );
else
- vCounters = Cbs_ManSolveMiter( pAbc->pAig, pPars->nBTLimit, &vStatus, pPars->fVerbose );
+ vCounters = Cbs_ManSolveMiter( pAbc->pGia, pPars->nBTLimit, &vStatus, pPars->fVerbose );
Vec_IntFree( vCounters );
Vec_StrFree( vStatus );
}
else
{
- pAbc->pAig = Cec_ManSatSolving( pTemp = pAbc->pAig, pPars );
- Gia_ManStop( pTemp );
+ pTemp = Cec_ManSatSolving( pAbc->pGia, pPars );
+ Abc_CommandUpdate9( pAbc, pTemp );
}
return 0;
usage:
- fprintf( stdout, "usage: &sat [-CSN <num>] [-nmctvh]\n" );
- fprintf( stdout, "\t performs SAT solving for the combinational outputs\n" );
- fprintf( stdout, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
- fprintf( stdout, "\t-S num : the min number of variables to recycle the solver [default = %d]\n", pPars->nSatVarMax );
- fprintf( stdout, "\t-N num : the min number of calls to recycle the solver [default = %d]\n", pPars->nCallsRecycle );
- fprintf( stdout, "\t-n : toggle using non-chronological backtracking [default = %s]\n", pPars->fNonChrono? "yes": "no" );
- fprintf( stdout, "\t-m : toggle miter vs. any circuit [default = %s]\n", pPars->fCheckMiter? "miter": "circuit" );
- fprintf( stdout, "\t-c : toggle using circuit-based SAT solver [default = %s]\n", fCSat? "yes": "no" );
- fprintf( stdout, "\t-t : toggle using learning in curcuit-based solver [default = %s]\n", pPars->fLearnCls? "yes": "no" );
- fprintf( stdout, "\t-v : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: &sat [-CSN <num>] [-nmctvh]\n" );
+ Abc_Print( -2, "\t performs SAT solving for the combinational outputs\n" );
+ Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
+ Abc_Print( -2, "\t-S num : the min number of variables to recycle the solver [default = %d]\n", pPars->nSatVarMax );
+ Abc_Print( -2, "\t-N num : the min number of calls to recycle the solver [default = %d]\n", pPars->nCallsRecycle );
+ Abc_Print( -2, "\t-n : toggle using non-chronological backtracking [default = %s]\n", pPars->fNonChrono? "yes": "no" );
+ Abc_Print( -2, "\t-m : toggle miter vs. any circuit [default = %s]\n", pPars->fCheckMiter? "miter": "circuit" );
+ Abc_Print( -2, "\t-c : toggle using circuit-based SAT solver [default = %s]\n", fCSat? "yes": "no" );
+ Abc_Print( -2, "\t-t : toggle using learning in curcuit-based solver [default = %s]\n", pPars->fLearnCls? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -24381,6 +25049,7 @@ int Abc_CommandAbc9Fraig( Abc_Frame_t * pAbc, int argc, char ** argv )
Gia_Man_t * pTemp;
int c;
Cec_ManFraSetDefaultParams( pPars );
+ pPars->fSatSweeping = 1;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "WRILDCrmdwvh" ) ) != EOF )
{
@@ -24389,7 +25058,7 @@ int Abc_CommandAbc9Fraig( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'W':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-W\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
goto usage;
}
pPars->nWords = atoi(argv[globalUtilOptind]);
@@ -24400,7 +25069,7 @@ int Abc_CommandAbc9Fraig( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'R':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-R\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
goto usage;
}
pPars->nRounds = atoi(argv[globalUtilOptind]);
@@ -24411,7 +25080,7 @@ int Abc_CommandAbc9Fraig( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'I':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-I\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
goto usage;
}
pPars->nItersMax = atoi(argv[globalUtilOptind]);
@@ -24422,7 +25091,7 @@ int Abc_CommandAbc9Fraig( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'L':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-L\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
goto usage;
}
pPars->nLevelMax = atoi(argv[globalUtilOptind]);
@@ -24433,7 +25102,7 @@ int Abc_CommandAbc9Fraig( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'D':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-D\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
goto usage;
}
pPars->nDepthMax = atoi(argv[globalUtilOptind]);
@@ -24444,7 +25113,7 @@ int Abc_CommandAbc9Fraig( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
pPars->nBTLimit = atoi(argv[globalUtilOptind]);
@@ -24471,34 +25140,30 @@ int Abc_CommandAbc9Fraig( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage;
}
}
- if ( pAbc->pAig == NULL )
+ if ( pAbc->pGia == NULL )
{
- printf( "Abc_CommandAbc9Fraig(): There is no AIG.\n" );
+ Abc_Print( -1, "Abc_CommandAbc9Fraig(): There is no AIG.\n" );
return 1;
}
- pTemp = Cec_ManSatSweeping( pAbc->pAig, pPars );
- if ( pTemp )
- {
- Gia_ManStop( pAbc->pAig );
- pAbc->pAig = pTemp;
- }
+ pTemp = Cec_ManSatSweeping( pAbc->pGia, pPars );
+ Abc_CommandUpdate9( pAbc, pTemp );
return 0;
usage:
- fprintf( stdout, "usage: &fraig [-WRILDC <num>] [-rmdwvh]\n" );
- fprintf( stdout, "\t performs combinational SAT sweeping\n" );
- fprintf( stdout, "\t-W num : the number of simulation words [default = %d]\n", pPars->nWords );
- fprintf( stdout, "\t-R num : the number of simulation rounds [default = %d]\n", pPars->nRounds );
- fprintf( stdout, "\t-I num : the number of sweeping iterations [default = %d]\n", pPars->nItersMax );
- fprintf( stdout, "\t-L num : the max number of levels of nodes to consider [default = %d]\n", pPars->nLevelMax );
- fprintf( stdout, "\t-D num : the max number of steps of speculative reduction [default = %d]\n", pPars->nDepthMax );
- fprintf( stdout, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
- fprintf( stdout, "\t-r : toggle the use of AIG rewriting [default = %s]\n", pPars->fRewriting? "yes": "no" );
- fprintf( stdout, "\t-m : toggle miter vs. any circuit [default = %s]\n", pPars->fCheckMiter? "miter": "circuit" );
- fprintf( stdout, "\t-d : toggle using double output miters [default = %s]\n", pPars->fDualOut? "yes": "no" );
- fprintf( stdout, "\t-w : toggle printing even more verbose information [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
- fprintf( stdout, "\t-v : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: &fraig [-WRILDC <num>] [-rmdwvh]\n" );
+ Abc_Print( -2, "\t performs combinational SAT sweeping\n" );
+ Abc_Print( -2, "\t-W num : the number of simulation words [default = %d]\n", pPars->nWords );
+ Abc_Print( -2, "\t-R num : the number of simulation rounds [default = %d]\n", pPars->nRounds );
+ Abc_Print( -2, "\t-I num : the number of sweeping iterations [default = %d]\n", pPars->nItersMax );
+ Abc_Print( -2, "\t-L num : the max number of levels of nodes to consider [default = %d]\n", pPars->nLevelMax );
+ Abc_Print( -2, "\t-D num : the max number of steps of speculative reduction [default = %d]\n", pPars->nDepthMax );
+ Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
+ Abc_Print( -2, "\t-r : toggle the use of AIG rewriting [default = %s]\n", pPars->fRewriting? "yes": "no" );
+ Abc_Print( -2, "\t-m : toggle miter vs. any circuit [default = %s]\n", pPars->fCheckMiter? "miter": "circuit" );
+ Abc_Print( -2, "\t-d : toggle using double output miters [default = %s]\n", pPars->fDualOut? "yes": "no" );
+ Abc_Print( -2, "\t-w : toggle printing even more verbose information [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -24541,32 +25206,32 @@ int Abc_CommandAbc9Srm( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage;
}
}
- if ( pAbc->pAig == NULL )
+ if ( pAbc->pGia == NULL )
{
- printf( "Abc_CommandAbc9Srm(): There is no AIG.\n" );
+ Abc_Print( -1, "Abc_CommandAbc9Srm(): There is no AIG.\n" );
return 1;
}
- pTemp = Gia_ManSpecReduce( pAbc->pAig, fDualOut, fVerbose );
+ pTemp = Gia_ManSpecReduce( pAbc->pGia, fDualOut, fSynthesis, fVerbose );
if ( pTemp )
{
pTemp = Gia_ManSeqStructSweep( pAux = pTemp, 1, 1, 0 );
Gia_ManStop( pAux );
Gia_WriteAiger( pTemp, pFileName, 0, 0 );
- printf( "Speculatively reduced model was written into file \"%s\".\n", pFileName );
+ Abc_Print( 1, "Speculatively reduced model was written into file \"%s\".\n", pFileName );
Gia_ManPrintStatsShort( pTemp );
Gia_ManStop( pTemp );
}
if ( fSynthesis )
{
- pTemp = Gia_ManEquivReduce( pAbc->pAig, 1, fDualOut, fVerbose );
+ pTemp = Gia_ManEquivReduce( pAbc->pGia, 1, fDualOut, fVerbose );
if ( pTemp )
{
pTemp = Gia_ManSeqStructSweep( pAux = pTemp, 1, 1, 0 );
Gia_ManStop( pAux );
Gia_WriteAiger( pTemp, pFileName2, 0, 0 );
- printf( "Reduced original network was written into file \"%s\".\n", pFileName2 );
+ Abc_Print( 1, "Reduced original network was written into file \"%s\".\n", pFileName2 );
Gia_ManPrintStatsShort( pTemp );
Gia_ManStop( pTemp );
}
@@ -24574,12 +25239,12 @@ int Abc_CommandAbc9Srm( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( stdout, "usage: &srm [-dsvh]\n" );
- fprintf( stdout, "\t writes speculatively reduced model into file \"%s\"\n", pFileName );
- fprintf( stdout, "\t-d : toggle creating dual output miter [default = %s]\n", fDualOut? "yes": "no" );
- fprintf( stdout, "\t-s : toggle writing reduced network for synthesis [default = %s]\n", fSynthesis? "yes": "no" );
- fprintf( stdout, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: &srm [-dsvh]\n" );
+ Abc_Print( -2, "\t writes speculatively reduced model into file \"%s\"\n", pFileName );
+ Abc_Print( -2, "\t-d : toggle creating dual output miter [default = %s]\n", fDualOut? "yes": "no" );
+ Abc_Print( -2, "\t-s : toggle writing reduced network for synthesis [default = %s]\n", fSynthesis? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -24596,7 +25261,7 @@ usage:
***********************************************************************/
int Abc_CommandAbc9Reduce( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- Gia_Man_t * pTemp;
+ Gia_Man_t * pTemp, * pTemp2;
int c, fVerbose = 0;
int fUseAll = 0;
int fDualOut = 0;
@@ -24620,29 +25285,27 @@ int Abc_CommandAbc9Reduce( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage;
}
}
- if ( pAbc->pAig == NULL )
+ if ( pAbc->pGia == NULL )
{
- printf( "Abc_CommandAbc9Reduce(): There is no AIG.\n" );
+ Abc_Print( -1, "Abc_CommandAbc9Reduce(): There is no AIG.\n" );
return 1;
}
- pAbc->pAig = Gia_ManEquivReduce( pTemp = pAbc->pAig, fUseAll, fDualOut, fVerbose );
- if ( pAbc->pAig == NULL )
- pAbc->pAig = pTemp;
- else
+ pTemp = Gia_ManEquivReduce( pAbc->pGia, fUseAll, fDualOut, fVerbose );
+ if ( pTemp != NULL )
{
- Gia_ManStop( pTemp );
- pAbc->pAig = Gia_ManSeqStructSweep( pTemp = pAbc->pAig, 1, 1, 0 );
- Gia_ManStop( pTemp );
+ pTemp = Gia_ManSeqStructSweep( pTemp2 = pTemp, 1, 1, 0 );
+ Gia_ManStop( pTemp2 );
+ Abc_CommandUpdate9( pAbc, pTemp );
}
return 0;
usage:
- fprintf( stdout, "usage: &reduce [-advh]\n" );
- fprintf( stdout, "\t reduces the circuit using equivalence classes\n" );
- fprintf( stdout, "\t-a : toggle merging all equivalences [default = %s]\n", fUseAll? "yes": "no" );
- fprintf( stdout, "\t-d : toggle using dual-output merging [default = %s]\n", fDualOut? "yes": "no" );
- fprintf( stdout, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: &reduce [-advh]\n" );
+ Abc_Print( -2, "\t reduces the circuit using equivalence classes\n" );
+ Abc_Print( -2, "\t-a : toggle merging all equivalences [default = %s]\n", fUseAll? "yes": "no" );
+ Abc_Print( -2, "\t-d : toggle using dual-output merging [default = %s]\n", fDualOut? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -24674,7 +25337,7 @@ int Abc_CommandAbc9Cec( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
pPars->nBTLimit = atoi(argv[globalUtilOptind]);
@@ -24685,7 +25348,7 @@ int Abc_CommandAbc9Cec( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'T':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-T\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
goto usage;
}
pPars->TimeLimit = atoi(argv[globalUtilOptind]);
@@ -24707,8 +25370,13 @@ int Abc_CommandAbc9Cec( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( fMiter )
{
- printf( "Assuming the current network is a double-output miter. (Conflict limit = %d.)\n", pPars->nBTLimit );
- Cec_ManVerify( pAbc->pAig, pPars );
+ if ( Gia_ManPoNum(pAbc->pGia) & 1 )
+ {
+ Abc_Print( -1, "The dual-output miter should have an even number of outputs.\n" );
+ return 1;
+ }
+ Abc_Print( 1, "Assuming the current network is a double-output miter. (Conflict limit = %d.)\n", pPars->nBTLimit );
+ Cec_ManVerify( pAbc->pGia, pPars );
return 0;
}
@@ -24716,7 +25384,7 @@ int Abc_CommandAbc9Cec( Abc_Frame_t * pAbc, int argc, char ** argv )
nArgcNew = argc - globalUtilOptind;
if ( nArgcNew != 1 )
{
- printf( "File name is not given on the command line.\n" );
+ Abc_Print( -1, "File name is not given on the command line.\n" );
return 1;
}
@@ -24728,21 +25396,21 @@ int Abc_CommandAbc9Cec( Abc_Frame_t * pAbc, int argc, char ** argv )
*pTemp = '\\';
if ( (pFile = fopen( FileName, "r" )) == NULL )
{
- fprintf( pAbc->Err, "Cannot open input file \"%s\". ", FileName );
+ Abc_Print( -1, "Cannot open input file \"%s\". ", FileName );
if ( (FileName = Extra_FileGetSimilarName( FileName, ".aig", NULL, NULL, NULL, NULL )) )
- fprintf( pAbc->Err, "Did you mean \"%s\"?", FileName );
- fprintf( pAbc->Err, "\n" );
+ Abc_Print( 1, "Did you mean \"%s\"?", FileName );
+ Abc_Print( 1, "\n" );
return 1;
}
fclose( pFile );
pSecond = Gia_ReadAiger( FileName, 0 );
if ( pSecond == NULL )
{
- printf( "Reading AIGER has failed.\n" );
+ Abc_Print( -1, "Reading AIGER has failed.\n" );
return 0;
}
// compute the miter
- pMiter = Gia_ManMiter( pAbc->pAig, pSecond, 1, 0, pPars->fVerbose );
+ pMiter = Gia_ManMiter( pAbc->pGia, pSecond, 1, 0, pPars->fVerbose );
if ( pMiter )
{
Cec_ManVerify( pMiter, pPars );
@@ -24752,13 +25420,13 @@ int Abc_CommandAbc9Cec( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- fprintf( stdout, "usage: &cec [-CT num] [-mvh]\n" );
- fprintf( stdout, "\t new combinational equivalence checker\n" );
- fprintf( stdout, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
- fprintf( stdout, "\t-T num : approximate runtime limit in seconds [default = %d]\n", pPars->TimeLimit );
- fprintf( stdout, "\t-m : toggle miter vs. two circuits [default = %s]\n", fMiter? "miter":"two circuits");
- fprintf( stdout, "\t-v : toggle verbose output [default = %s]\n", pPars->fVerbose? "yes":"no");
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: &cec [-CT num] [-mvh]\n" );
+ Abc_Print( -2, "\t new combinational equivalence checker\n" );
+ Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
+ Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n", pPars->TimeLimit );
+ Abc_Print( -2, "\t-m : toggle miter vs. two circuits [default = %s]\n", fMiter? "miter":"two circuits");
+ Abc_Print( -2, "\t-v : toggle verbose output [default = %s]\n", pPars->fVerbose? "yes":"no");
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -24787,7 +25455,7 @@ int Abc_CommandAbc9Force( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'I':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-I\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" );
goto usage;
}
nIters = atoi(argv[globalUtilOptind]);
@@ -24807,22 +25475,22 @@ int Abc_CommandAbc9Force( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage;
}
}
- if ( pAbc->pAig == NULL )
+ if ( pAbc->pGia == NULL )
{
- printf( "Abc_CommandAbc9Force(): There is no AIG.\n" );
+ Abc_Print( -1, "Abc_CommandAbc9Force(): There is no AIG.\n" );
return 1;
}
- For_ManExperiment( pAbc->pAig, nIters, fClustered, fVerbose );
+ For_ManExperiment( pAbc->pGia, nIters, fClustered, fVerbose );
return 0;
usage:
- fprintf( stdout, "usage: &force [-I <num>] [-cvh]\n" );
- fprintf( stdout, "\t one-dimensional placement algorithm FORCE introduced by\n" );
- fprintf( stdout, "\t F. A. Aloul, I. L. Markov, and K. A. Sakallah (GLSVLSI’03).\n" );
- fprintf( stdout, "\t-I num : the number of refinement iterations [default = %d]\n", nIters );
- fprintf( stdout, "\t-c : toggle clustered representation [default = %s]\n", fClustered? "yes":"no");
- fprintf( stdout, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes":"no");
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: &force [-I <num>] [-cvh]\n" );
+ Abc_Print( -2, "\t one-dimensional placement algorithm FORCE introduced by\n" );
+ Abc_Print( -2, "\t F. A. Aloul, I. L. Markov, and K. A. Sakallah (GLSVLSI�03).\n" );
+ Abc_Print( -2, "\t-I num : the number of refinement iterations [default = %d]\n", nIters );
+ Abc_Print( -2, "\t-c : toggle clustered representation [default = %s]\n", fClustered? "yes":"no");
+ Abc_Print( -2, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes":"no");
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -24858,7 +25526,7 @@ int Abc_CommandAbc9Embed( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'D':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-D\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
goto usage;
}
pPars->nDims = atoi(argv[globalUtilOptind]);
@@ -24869,7 +25537,7 @@ int Abc_CommandAbc9Embed( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'I':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-D\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-D\" should be followed by an integer.\n" );
goto usage;
}
pPars->nIters = atoi(argv[globalUtilOptind]);
@@ -24901,28 +25569,28 @@ int Abc_CommandAbc9Embed( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage;
}
}
- if ( pAbc->pAig == NULL )
+ if ( pAbc->pGia == NULL )
{
- printf( "Abc_CommandAbc9Embed(): There is no AIG.\n" );
+ Abc_Print( -1, "Abc_CommandAbc9Embed(): There is no AIG.\n" );
return 1;
}
- Gia_ManSolveProblem( pAbc->pAig, pPars );
+ Gia_ManSolveProblem( pAbc->pGia, pPars );
return 0;
usage:
- fprintf( stdout, "usage: &embed [-DI <num>] [-rdlscvh]\n" );
- fprintf( stdout, "\t fast placement based on high-dimensional embedding from\n" );
- fprintf( stdout, "\t D. Harel and Y. Koren, \"Graph drawing by high-dimensional\n" );
- fprintf( stdout, "\t embedding\", J. Graph Algs & Apps, 2004, Vol 8(2), pp. 195-217\n" );
- fprintf( stdout, "\t-D num : the number of dimensions for embedding [default = %d]\n", pPars->nDims );
- fprintf( stdout, "\t-I num : the number of refinement iterations [default = %d]\n", pPars->nIters );
- fprintf( stdout, "\t-r : toggle the use of refinement [default = %s]\n", pPars->fRefine? "yes":"no");
- fprintf( stdout, "\t-c : toggle clustered representation [default = %s]\n", pPars->fCluster? "yes":"no");
- fprintf( stdout, "\t-d : toggle dumping placement into a Gnuplot file [default = %s]\n", pPars->fDump? "yes":"no");
- fprintf( stdout, "\t-l : toggle dumping Gnuplot for large placement [default = %s]\n", pPars->fDumpLarge? "yes":"no");
- fprintf( stdout, "\t-s : toggle showing image if Gnuplot is installed [default = %s]\n", pPars->fShowImage? "yes":"no");
- fprintf( stdout, "\t-v : toggle verbose output [default = %s]\n", pPars->fVerbose? "yes":"no");
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: &embed [-DI <num>] [-rdlscvh]\n" );
+ Abc_Print( -2, "\t fast placement based on high-dimensional embedding from\n" );
+ Abc_Print( -2, "\t D. Harel and Y. Koren, \"Graph drawing by high-dimensional\n" );
+ Abc_Print( -2, "\t embedding\", J. Graph Algs & Apps, 2004, Vol 8(2), pp. 195-217\n" );
+ Abc_Print( -2, "\t-D num : the number of dimensions for embedding [default = %d]\n", pPars->nDims );
+ Abc_Print( -2, "\t-I num : the number of refinement iterations [default = %d]\n", pPars->nIters );
+ Abc_Print( -2, "\t-r : toggle the use of refinement [default = %s]\n", pPars->fRefine? "yes":"no");
+ Abc_Print( -2, "\t-c : toggle clustered representation [default = %s]\n", pPars->fCluster? "yes":"no");
+ Abc_Print( -2, "\t-d : toggle dumping placement into a Gnuplot file [default = %s]\n", pPars->fDump? "yes":"no");
+ Abc_Print( -2, "\t-l : toggle dumping Gnuplot for large placement [default = %s]\n", pPars->fDumpLarge? "yes":"no");
+ Abc_Print( -2, "\t-s : toggle showing image if Gnuplot is installed [default = %s]\n", pPars->fShowImage? "yes":"no");
+ Abc_Print( -2, "\t-v : toggle verbose output [default = %s]\n", pPars->fVerbose? "yes":"no");
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -24947,21 +25615,21 @@ int Abc_CommandAbc9If( Abc_Frame_t * pAbc, int argc, char ** argv )
extern int Gia_MappingIf( Gia_Man_t * p, If_Par_t * pPars );
if ( pAbc->pAbc8Lib == NULL )
{
- printf( "LUT library is not given. Using default LUT library.\n" );
+ Abc_Print( -1, "LUT library is not given. Using default LUT library.\n" );
pAbc->pAbc8Lib = If_SetSimpleLutLib( 6 );
}
// set defaults
Gia_ManSetIfParsDefault( pPars );
pPars->pLutLib = pAbc->pAbc8Lib;
Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "KCFADEqaflepmrstbvh" ) ) != EOF )
+ while ( ( c = Extra_UtilGetopt( argc, argv, "KCFADEqaflepmrsdbvh" ) ) != EOF )
{
switch ( c )
{
case 'K':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-K\" should be followed by a positive integer.\n" );
+ Abc_Print( -1, "Command line switch \"-K\" should be followed by a positive integer.\n" );
goto usage;
}
pPars->nLutSize = atoi(argv[globalUtilOptind]);
@@ -24974,7 +25642,7 @@ int Abc_CommandAbc9If( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-C\" should be followed by a positive integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by a positive integer.\n" );
goto usage;
}
pPars->nCutsMax = atoi(argv[globalUtilOptind]);
@@ -24985,7 +25653,7 @@ int Abc_CommandAbc9If( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'F':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-F\" should be followed by a positive integer.\n" );
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by a positive integer.\n" );
goto usage;
}
pPars->nFlowIters = atoi(argv[globalUtilOptind]);
@@ -24996,7 +25664,7 @@ int Abc_CommandAbc9If( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'A':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-A\" should be followed by a positive integer.\n" );
+ Abc_Print( -1, "Command line switch \"-A\" should be followed by a positive integer.\n" );
goto usage;
}
pPars->nAreaIters = atoi(argv[globalUtilOptind]);
@@ -25007,7 +25675,7 @@ int Abc_CommandAbc9If( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'D':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-D\" should be followed by a floating point number.\n" );
+ Abc_Print( -1, "Command line switch \"-D\" should be followed by a floating point number.\n" );
goto usage;
}
pPars->DelayTarget = (float)atof(argv[globalUtilOptind]);
@@ -25018,7 +25686,7 @@ int Abc_CommandAbc9If( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'E':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-E\" should be followed by a floating point number.\n" );
+ Abc_Print( -1, "Command line switch \"-E\" should be followed by a floating point number.\n" );
goto usage;
}
pPars->Epsilon = (float)atof(argv[globalUtilOptind]);
@@ -25053,11 +25721,11 @@ int Abc_CommandAbc9If( Abc_Frame_t * pAbc, int argc, char ** argv )
case 's':
pPars->fSeqMap ^= 1;
break;
- case 't':
- pPars->fLiftLeaves ^= 1;
+ case 'd':
+ pPars->fBidec ^= 1;
break;
case 'b':
- pPars->fBidec ^= 1;
+ pPars->fUseBat ^= 1;
break;
case 'v':
pPars->fVerbose ^= 1;
@@ -25067,31 +25735,41 @@ int Abc_CommandAbc9If( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage;
}
}
- if ( pAbc->pAig == NULL )
+ if ( pAbc->pGia == NULL )
{
- printf( "Abc_CommandAbc9If(): There is no AIG to map.\n" );
+ Abc_Print( -1, "Abc_CommandAbc9If(): There is no AIG to map.\n" );
return 1;
}
if ( pPars->nLutSize < 3 || pPars->nLutSize > IF_MAX_LUTSIZE )
{
- fprintf( stdout, "Incorrect LUT size (%d).\n", pPars->nLutSize );
+ Abc_Print( -1, "Incorrect LUT size (%d).\n", pPars->nLutSize );
return 1;
}
if ( pPars->nCutsMax < 1 || pPars->nCutsMax >= (1<<12) )
{
- fprintf( stdout, "Incorrect number of cuts.\n" );
+ Abc_Print( -1, "Incorrect number of cuts.\n" );
return 1;
}
-/*
+
// enable truth table computation if choices are selected
- if ( (c = Aig_ManChoiceNum( pAbc->pAbc8Aig )) )
+ if ( (c = Gia_ManCountChoiceNodes( pAbc->pGia )) )
{
- printf( "Performing LUT mapping with %d choices.\n", c );
+ Abc_Print( 0, "Performing LUT mapping with %d choices.\n", c );
pPars->fExpRed = 0;
}
-*/
+
+ if ( pPars->fUseBat )
+ {
+ if ( pPars->nLutSize < 4 || pPars->nLutSize > 6 )
+ {
+ Abc_Print( -1, "This feature only works for {4,5,6}-LUTs.\n" );
+ return 1;
+ }
+ pPars->fCutMin = 1;
+ }
+
// enable truth table computation if cut minimization is selected
if ( pPars->fCutMin )
{
@@ -25102,13 +25780,13 @@ int Abc_CommandAbc9If( Abc_Frame_t * pAbc, int argc, char ** argv )
// complain if truth tables are requested but the cut size is too large
if ( pPars->fTruth && pPars->nLutSize > IF_MAX_FUNC_LUTSIZE )
{
- fprintf( stdout, "Truth tables cannot be computed for LUT larger than %d inputs.\n", IF_MAX_FUNC_LUTSIZE );
+ Abc_Print( -1, "Truth tables cannot be computed for LUT larger than %d inputs.\n", IF_MAX_FUNC_LUTSIZE );
return 1;
}
- if ( !Gia_MappingIf( pAbc->pAig, pPars ) )
+ if ( !Gia_MappingIf( pAbc->pGia, pPars ) )
{
- printf( "Abc_CommandAbc9If(): Mapping of the AIG has failed.\n" );
+ Abc_Print( -1, "Abc_CommandAbc9If(): Mapping of the AIG has failed.\n" );
return 1;
}
return 0;
@@ -25122,27 +25800,184 @@ usage:
sprintf( LutSize, "library" );
else
sprintf( LutSize, "%d", pPars->nLutSize );
- fprintf( stdout, "usage: &if [-KCFA num] [-DE float] [-qarlepmbvh]\n" );
- fprintf( stdout, "\t performs FPGA technology mapping of the network\n" );
- fprintf( stdout, "\t-K num : the number of LUT inputs (2 < num < %d) [default = %s]\n", IF_MAX_LUTSIZE+1, LutSize );
- fprintf( stdout, "\t-C num : the max number of priority cuts (0 < num < 2^12) [default = %d]\n", pPars->nCutsMax );
- fprintf( stdout, "\t-F num : the number of area flow recovery iterations (num >= 0) [default = %d]\n", pPars->nFlowIters );
- fprintf( stdout, "\t-A num : the number of exact area recovery iterations (num >= 0) [default = %d]\n", pPars->nAreaIters );
- fprintf( stdout, "\t-D float : sets the delay constraint for the mapping [default = %s]\n", Buffer );
- fprintf( stdout, "\t-E float : sets epsilon used for tie-breaking [default = %f]\n", pPars->Epsilon );
- fprintf( stdout, "\t-q : toggles preprocessing using several starting points [default = %s]\n", pPars->fPreprocess? "yes": "no" );
- fprintf( stdout, "\t-a : toggles area-oriented mapping [default = %s]\n", pPars->fArea? "yes": "no" );
-// fprintf( stdout, "\t-f : toggles one fancy feature [default = %s]\n", pPars->fFancy? "yes": "no" );
- fprintf( stdout, "\t-r : enables expansion/reduction of the best cuts [default = %s]\n", pPars->fExpRed? "yes": "no" );
- fprintf( stdout, "\t-l : optimizes latch paths for delay, other paths for area [default = %s]\n", pPars->fLatchPaths? "yes": "no" );
- fprintf( stdout, "\t-e : uses edge-based cut selection heuristics [default = %s]\n", pPars->fEdge? "yes": "no" );
- fprintf( stdout, "\t-p : uses power-aware cut selection heuristics [default = %s]\n", pPars->fPower? "yes": "no" );
- fprintf( stdout, "\t-m : enables cut minimization by removing vacuous variables [default = %s]\n", pPars->fCutMin? "yes": "no" );
-// fprintf( stdout, "\t-s : toggles sequential mapping [default = %s]\n", pPars->fSeqMap? "yes": "no" );
-// fprintf( stdout, "\t-t : toggles the use of true sequential cuts [default = %s]\n", pPars->fLiftLeaves? "yes": "no" );
- fprintf( stdout, "\t-b : toggles deriving local AIGs using bi-decomposition [default = %s]\n", pPars->fBidec? "yes": "no" );
- fprintf( stdout, "\t-v : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : prints the command usage\n");
+ Abc_Print( -2, "usage: &if [-KCFA num] [-DE float] [-qarlepmdbvh]\n" );
+ Abc_Print( -2, "\t performs FPGA technology mapping of the network\n" );
+ Abc_Print( -2, "\t-K num : the number of LUT inputs (2 < num < %d) [default = %s]\n", IF_MAX_LUTSIZE+1, LutSize );
+ Abc_Print( -2, "\t-C num : the max number of priority cuts (0 < num < 2^12) [default = %d]\n", pPars->nCutsMax );
+ Abc_Print( -2, "\t-F num : the number of area flow recovery iterations (num >= 0) [default = %d]\n", pPars->nFlowIters );
+ Abc_Print( -2, "\t-A num : the number of exact area recovery iterations (num >= 0) [default = %d]\n", pPars->nAreaIters );
+ Abc_Print( -2, "\t-D float : sets the delay constraint for the mapping [default = %s]\n", Buffer );
+ Abc_Print( -2, "\t-E float : sets epsilon used for tie-breaking [default = %f]\n", pPars->Epsilon );
+ Abc_Print( -2, "\t-q : toggles preprocessing using several starting points [default = %s]\n", pPars->fPreprocess? "yes": "no" );
+ Abc_Print( -2, "\t-a : toggles area-oriented mapping [default = %s]\n", pPars->fArea? "yes": "no" );
+// Abc_Print( -2, "\t-f : toggles one fancy feature [default = %s]\n", pPars->fFancy? "yes": "no" );
+ Abc_Print( -2, "\t-r : enables expansion/reduction of the best cuts [default = %s]\n", pPars->fExpRed? "yes": "no" );
+ Abc_Print( -2, "\t-l : optimizes latch paths for delay, other paths for area [default = %s]\n", pPars->fLatchPaths? "yes": "no" );
+ Abc_Print( -2, "\t-e : uses edge-based cut selection heuristics [default = %s]\n", pPars->fEdge? "yes": "no" );
+ Abc_Print( -2, "\t-p : uses power-aware cut selection heuristics [default = %s]\n", pPars->fPower? "yes": "no" );
+ Abc_Print( -2, "\t-m : enables cut minimization by removing vacuous variables [default = %s]\n", pPars->fCutMin? "yes": "no" );
+// Abc_Print( -2, "\t-s : toggles sequential mapping [default = %s]\n", pPars->fSeqMap? "yes": "no" );
+ Abc_Print( -2, "\t-d : toggles deriving local AIGs using bi-decomposition [default = %s]\n", pPars->fBidec? "yes": "no" );
+ Abc_Print( -2, "\t-b : toggles the use of one special feature [default = %s]\n", pPars->fUseBat? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : prints the command usage\n");
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_CommandAbc9Trace( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+ int c;
+ int fUseLutLib;
+ int fVerbose;
+ pNtk = Abc_FrameReadNtk(pAbc);
+ // set defaults
+ fUseLutLib = 0;
+ fVerbose = 0;
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "lvh" ) ) != EOF )
+ {
+ switch ( c )
+ {
+ case 'l':
+ fUseLutLib ^= 1;
+ break;
+ case 'v':
+ fVerbose ^= 1;
+ break;
+ case 'h':
+ goto usage;
+ default:
+ goto usage;
+ }
+ }
+ if ( pAbc->pGia == NULL )
+ {
+ Abc_Print( -1, "Abc_CommandAbc9Speedup(): There is no AIG to map.\n" );
+ return 1;
+ }
+ if ( pAbc->pGia->pMapping == NULL )
+ {
+ Abc_Print( -1, "Abc_CommandAbc9Speedup(): Mapping of the AIG is not defined.\n" );
+ return 1;
+ }
+ pAbc->pGia->pLutLib = fUseLutLib ? pAbc->pLibLut : NULL;
+ Gia_ManDelayTraceLutPrint( pAbc->pGia, fVerbose );
+ return 0;
+
+usage:
+ Abc_Print( -2, "usage: &trace [-lvh]\n" );
+ Abc_Print( -2, "\t performs delay trace of LUT-mapped network\n" );
+ Abc_Print( -2, "\t-l : toggle using unit- or LUT-library-delay model [default = %s]\n", fUseLutLib? "lib": "unit" );
+ Abc_Print( -2, "\t-v : toggle printing optimization summary [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_CommandAbc9Speedup( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ Gia_Man_t * pTemp;
+ int fUseLutLib;
+ int Percentage;
+ int Degree;
+ int fVerbose;
+ int c, fVeryVerbose;
+
+ // set defaults
+ fUseLutLib = 0;
+ Percentage = 5;
+ Degree = 2;
+ fVerbose = 0;
+ fVeryVerbose = 0;
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "PNlvwh" ) ) != EOF )
+ {
+ switch ( c )
+ {
+ case 'P':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ Percentage = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( Percentage < 1 || Percentage > 100 )
+ goto usage;
+ break;
+ case 'N':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ Degree = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( Degree < 1 || Degree > 5 )
+ goto usage;
+ break;
+ case 'l':
+ fUseLutLib ^= 1;
+ break;
+ case 'v':
+ fVerbose ^= 1;
+ break;
+ case 'w':
+ fVeryVerbose ^= 1;
+ break;
+ case 'h':
+ goto usage;
+ default:
+ goto usage;
+ }
+ }
+ if ( pAbc->pGia == NULL )
+ {
+ Abc_Print( -1, "Abc_CommandAbc9Speedup(): There is no AIG to map.\n" );
+ return 1;
+ }
+ if ( pAbc->pGia->pMapping == NULL )
+ {
+ Abc_Print( -1, "Abc_CommandAbc9Speedup(): Mapping of the AIG is not defined.\n" );
+ return 1;
+ }
+ pAbc->pGia->pLutLib = fUseLutLib ? pAbc->pLibLut : NULL;
+ pTemp = Gia_ManSpeedup( pAbc->pGia, Percentage, Degree, fVerbose, fVeryVerbose );
+ Abc_CommandUpdate9( pAbc, pTemp );
+ return 0;
+
+usage:
+ Abc_Print( -2, "usage: &speedup [-P num] [-N num] [-lvwh]\n" );
+ Abc_Print( -2, "\t transforms LUT-mapped network into an AIG with choices;\n" );
+ Abc_Print( -2, "\t the choices are added to speedup the next round of mapping\n" );
+ Abc_Print( -2, "\t-P <num> : delay delta defining critical path for library model [default = %d%%]\n", Percentage );
+ Abc_Print( -2, "\t-N <num> : the max critical path degree for resynthesis (0 < num < 6) [default = %d]\n", Degree );
+ Abc_Print( -2, "\t-l : toggle using unit- or LUT-library-delay model [default = %s]\n", fUseLutLib? "lib" : "unit" );
+ Abc_Print( -2, "\t-v : toggle printing optimization summary [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-w : toggle printing detailed stats for each node [default = %s]\n", fVeryVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -25164,8 +25999,8 @@ int Abc_CommandAbc9Era( Abc_Frame_t * pAbc, int argc, char ** argv )
int fUseCubes = 1;
int fMiter = 0;
int nStatesMax = 1000000000;
- extern void Gia_ManCollectReachable( Gia_Man_t * pAig, int nStatesMax, int fMiter, int fVerbose );
- extern void Gia_ManArePerform( Gia_Man_t * pAig, int nStatesMax, int fMiter, int fVerbose );
+ extern int Gia_ManCollectReachable( Gia_Man_t * pAig, int nStatesMax, int fMiter, int fVerbose );
+ extern int Gia_ManArePerform( Gia_Man_t * pAig, int nStatesMax, int fMiter, int fVerbose );
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "Smcvh" ) ) != EOF )
@@ -25175,7 +26010,7 @@ int Abc_CommandAbc9Era( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'S':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-S\" should be followed by a positive integer.\n" );
+ Abc_Print( -1, "Command line switch \"-S\" should be followed by a positive integer.\n" );
goto usage;
}
nStatesMax = atoi(argv[globalUtilOptind]);
@@ -25198,38 +26033,37 @@ int Abc_CommandAbc9Era( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage;
}
}
- if ( pAbc->pAig == NULL )
+ if ( pAbc->pGia == NULL )
{
- printf( "Abc_CommandAbc9Era(): There is no AIG.\n" );
+ Abc_Print( -1, "Abc_CommandAbc9Era(): There is no AIG.\n" );
return 1;
}
- if ( Gia_ManRegNum(pAbc->pAig) == 0 )
+ if ( Gia_ManRegNum(pAbc->pGia) == 0 )
{
- printf( "Abc_CommandAbc9Era(): The network is combinational.\n" );
+ Abc_Print( -1, "Abc_CommandAbc9Era(): The network is combinational.\n" );
return 1;
}
- if ( !fUseCubes && Gia_ManPiNum(pAbc->pAig) > 12 )
+ if ( !fUseCubes && Gia_ManPiNum(pAbc->pGia) > 12 )
{
- printf( "Abc_CommandAbc9Era(): The number of PIs (%d) should be no more than 12 when cubes are not used.\n", Gia_ManPiNum(pAbc->pAig) );
+ Abc_Print( -1, "Abc_CommandAbc9Era(): The number of PIs (%d) should be no more than 12 when cubes are not used.\n", Gia_ManPiNum(pAbc->pGia) );
return 1;
}
if ( fUseCubes )
- Gia_ManArePerform( pAbc->pAig, nStatesMax, fMiter, fVerbose );
+ pAbc->Status = Gia_ManArePerform( pAbc->pGia, nStatesMax, fMiter, fVerbose );
else
- Gia_ManCollectReachable( pAbc->pAig, nStatesMax, fMiter, fVerbose );
- pAbc->pCex = ((Gia_Man_t *)pAbc->pAig)->pCexSeq; // temporary ???
- ((Gia_Man_t *)pAbc->pAig)->pCexSeq = NULL;
+ pAbc->Status = Gia_ManCollectReachable( pAbc->pGia, nStatesMax, fMiter, fVerbose );
+ Abc_FrameReplaceCex( pAbc, &pAbc->pGia->pCexSeq );
return 0;
usage:
- fprintf( stdout, "usage: &era [-S num] [-mcvh]\n" );
-// fprintf( stdout, "usage: &era [-S num] [-mvh]\n" );
- fprintf( stdout, "\t explicit reachability analysis for small sequential AIGs\n" );
- fprintf( stdout, "\t-S num : the max number of states (num > 0) [default = %d]\n", nStatesMax );
- fprintf( stdout, "\t-m : stop when the miter output is 1 [default = %s]\n", fMiter? "yes": "no" );
- fprintf( stdout, "\t-c : use state cubes instead of state minterms [default = %s]\n", fUseCubes? "yes": "no" );
- fprintf( stdout, "\t-v : print verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: &era [-S num] [-mcvh]\n" );
+// Abc_Print( -2, "usage: &era [-S num] [-mvh]\n" );
+ Abc_Print( -2, "\t explicit reachability analysis for small sequential AIGs\n" );
+ Abc_Print( -2, "\t-S num : the max number of states (num > 0) [default = %d]\n", nStatesMax );
+ Abc_Print( -2, "\t-m : stop when the miter output is 1 [default = %s]\n", fMiter? "yes": "no" );
+ Abc_Print( -2, "\t-c : use state cubes instead of state minterms [default = %s]\n", fUseCubes? "yes": "no" );
+ Abc_Print( -2, "\t-v : print verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -25246,36 +26080,63 @@ usage:
***********************************************************************/
int Abc_CommandAbc9Dch( Abc_Frame_t * pAbc, int argc, char ** argv )
{
-// extern void Hcd_ComputeChoicesTest( Gia_Man_t * pAig, int nBTLimit, int fSynthesis, int fUseMiniSat, int fVerbose );
- Gia_Man_t * pTemp = NULL;
- int nBTLimit = 100;
- int fSynthesis = 1;
- int fUseMiniSat = 0;
- int c, fVerbose = 0;
+ Gia_Man_t * pTemp;
+ Dch_Pars_t Pars, * pPars = &Pars;
+ int c;
+ // set defaults
+ Dch_ManSetDefaultParams( pPars );
Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "Csmvh" ) ) != EOF )
+ while ( ( c = Extra_UtilGetopt( argc, argv, "WCSsptfvh" ) ) != EOF )
{
switch ( c )
{
+ case 'W':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ pPars->nWords = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->nWords < 0 )
+ goto usage;
+ break;
case 'C':
if ( globalUtilOptind >= argc )
{
- fprintf( stdout, "Command line switch \"-C\" should be followed by a positive integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
- nBTLimit = atoi(argv[globalUtilOptind]);
+ pPars->nBTLimit = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
- if ( nBTLimit < 0 )
+ if ( pPars->nBTLimit < 0 )
+ goto usage;
+ break;
+ case 'S':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ pPars->nSatVarMax = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->nSatVarMax < 0 )
goto usage;
break;
case 's':
- fSynthesis ^= 1;
+ pPars->fSynthesis ^= 1;
break;
- case 'm':
- fUseMiniSat ^= 1;
+ case 'p':
+ pPars->fPower ^= 1;
+ break;
+ case 't':
+ pPars->fSimulateTfo ^= 1;
+ break;
+ case 'f':
+ pPars->fLightSynth ^= 1;
break;
case 'v':
- fVerbose ^= 1;
+ pPars->fVerbose ^= 1;
break;
case 'h':
goto usage;
@@ -25283,22 +26144,27 @@ int Abc_CommandAbc9Dch( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage;
}
}
- if ( pAbc->pAig == NULL )
+ if ( pAbc->pGia == NULL )
{
- printf( "Abc_CommandAbc9Test(): There is no AIG.\n" );
+ Abc_Print( -1, "Abc_CommandAbc9Test(): There is no AIG.\n" );
return 1;
}
-// Hcd_ComputeChoicesTest( pAbc->pAig, nBTLimit, fSynthesis, fUseMiniSat, fVerbose );
+ pTemp = Gia_ManPerformDch( pAbc->pGia, pPars );
+ Abc_CommandUpdate9( pAbc, pTemp );
return 0;
usage:
- fprintf( stdout, "usage: &dch [-C num] [-smvh]\n" );
- fprintf( stdout, "\t computing choices using the latest algorithm\n" );
- fprintf( stdout, "\t-C num : the max number of states to traverse (num > 0) [default = %d]\n", nBTLimit );
- fprintf( stdout, "\t-s : toggle printing verbose information [default = %s]\n", fSynthesis? "yes": "no" );
- fprintf( stdout, "\t-m : toggle using MiniSat as a SAT solver [default = %s]\n", fUseMiniSat? "yes": "no" );
- fprintf( stdout, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: &dch [-WCS num] [-sptfvh]\n" );
+ Abc_Print( -2, "\t computes structural choices using a new approach\n" );
+ Abc_Print( -2, "\t-W num : the max number of simulation words [default = %d]\n", pPars->nWords );
+ Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit );
+ Abc_Print( -2, "\t-S num : the max number of SAT variables [default = %d]\n", pPars->nSatVarMax );
+ Abc_Print( -2, "\t-s : toggle synthesizing three snapshots [default = %s]\n", pPars->fSynthesis? "yes": "no" );
+ Abc_Print( -2, "\t-p : toggle power-aware rewriting [default = %s]\n", pPars->fPower? "yes": "no" );
+ Abc_Print( -2, "\t-t : toggle simulation of the TFO classes [default = %s]\n", pPars->fSimulateTfo? "yes": "no" );
+ Abc_Print( -2, "\t-f : toggle using lighter logic synthesis [default = %s]\n", pPars->fLightSynth? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -25313,24 +26179,76 @@ usage:
SeeAlso []
***********************************************************************/
-int Abc_CommandAbc9Test( Abc_Frame_t * pAbc, int argc, char ** argv )
+int Abc_CommandAbc9AbsStart( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- Gia_Man_t * pTemp = NULL;
- int c, fVerbose = 0;
- int fSwitch = 0;
- extern void Gia_SatSolveTest( Gia_Man_t * p );
- extern void Cbs_ManSolveTest( Gia_Man_t * pGia );
+ Gia_ParAbs_t Pars, * pPars = &Pars;
+ int c;
+ extern void Gia_ManCexAbstractionStart( Gia_Man_t * pGia, Gia_ParAbs_t * pPars );
+ // set defaults
+ Gia_ManAbsSetDefaultParams( pPars );
Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "svh" ) ) != EOF )
+ while ( ( c = Extra_UtilGetopt( argc, argv, "FCRrpfvh" ) ) != EOF )
{
switch ( c )
{
- case 's':
- fSwitch ^= 1;
+ case 'F':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ pPars->nFramesBmc = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->nFramesBmc < 0 )
+ goto usage;
+ break;
+/*
+ case 'S':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ pPars->nStableMax = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->nStableMax < 0 )
+ goto usage;
+ break;
+*/
+ case 'C':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ pPars->nConfMaxBmc = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->nConfMaxBmc < 0 )
+ goto usage;
+ break;
+ case 'R':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ pPars->nRatio = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->nRatio < 0 )
+ goto usage;
+ break;
+ case 'r':
+ pPars->fUseBdds ^= 1;
+ break;
+ case 'p':
+ pPars->fUseDprove ^= 1;
+ break;
+ case 'f':
+ pPars->fUseStart ^= 1;
break;
case 'v':
- fVerbose ^= 1;
+ pPars->fVerbose ^= 1;
break;
case 'h':
goto usage;
@@ -25338,33 +26256,356 @@ int Abc_CommandAbc9Test( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage;
}
}
- if ( pAbc->pAig == NULL )
+ if ( pAbc->pGia == NULL )
{
- printf( "Abc_CommandAbc9Test(): There is no AIG.\n" );
+ Abc_Print( -1, "Abc_CommandAbc9AbsStart(): There is no AIG.\n" );
return 1;
+ }
+ if ( Gia_ManRegNum(pAbc->pGia) == 0 )
+ {
+ Abc_Print( -1, "Abc_CommandAbc9AbsStart(): The AIG is combinational.\n" );
+ return 0;
+ }
+ if ( !(0 <= pPars->nRatio && pPars->nRatio <= 100) )
+ {
+ Abc_Print( -1, "Abc_CommandAbc9AbsStart(): Wrong value of parameter \"-R <num>\".\n" );
+ return 0;
+ }
+ Gia_ManCexAbstractionStart( pAbc->pGia, pPars );
+ pAbc->Status = pPars->Status;
+ pAbc->nFrames = pPars->nFramesDone;
+ Abc_FrameReplaceCex( pAbc, &pAbc->pGia->pCexSeq );
+ return 0;
+usage:
+ Abc_Print( -2, "usage: &abs_start [-FCR num] [-rpfvh]\n" );
+ Abc_Print( -2, "\t initializes flop map using cex-based abstraction\n" );
+ Abc_Print( -2, "\t-F num : the max number of timeframes for BMC [default = %d]\n", pPars->nFramesBmc );
+// Abc_Print( -2, "\t-S num : the max number of stable frames for BMC [default = %d]\n", pPars->nStableMax );
+ Abc_Print( -2, "\t-C num : the max number of conflicts by SAT solver for BMC [default = %d]\n", pPars->nConfMaxBmc );
+ Abc_Print( -2, "\t-R num : the %% of abstracted flops when refinement stops (0<=num<=100) [default = %d]\n", pPars->nRatio );
+ Abc_Print( -2, "\t-r : toggle using BDD-based reachability for filtering [default = %s]\n", pPars->fUseBdds? "yes": "no" );
+ Abc_Print( -2, "\t-p : toggle using \"dprove\" for filtering [default = %s]\n", pPars->fUseDprove? "yes": "no" );
+ Abc_Print( -2, "\t-f : toggle starting BMC from a later frame [default = %s]\n", pPars->fUseStart? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_CommandAbc9AbsStartNew( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ Gia_ParAbs_t Pars, * pPars = &Pars;
+ int c;
+ extern void Gia_ManCexAbstractionStartNew( Gia_Man_t * pGia, Gia_ParAbs_t * pPars );
+
+ // set defaults
+ Gia_ManAbsSetDefaultParams( pPars );
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "AFSCRBTVrpfvwh" ) ) != EOF )
+ {
+ switch ( c )
+ {
+ case 'A':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ pPars->Algo = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->Algo < 0 )
+ goto usage;
+ break;
+ case 'F':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ pPars->nFramesBmc = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->nFramesBmc < 0 )
+ goto usage;
+ break;
+ case 'S':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ pPars->nStableMax = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->nStableMax < 0 )
+ goto usage;
+ break;
+ case 'C':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ pPars->nConfMaxBmc = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->nConfMaxBmc < 0 )
+ goto usage;
+ break;
+ case 'R':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ pPars->nRatio = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->nRatio < 0 )
+ goto usage;
+ break;
+ case 'B':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-B\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ pPars->nBobPar = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->nBobPar < 0 )
+ goto usage;
+ break;
+ case 'T':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ pPars->TimeOut = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->TimeOut < 0 )
+ goto usage;
+ break;
+ case 'V':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-V\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ pPars->TimeOutVT = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->TimeOutVT < 0 )
+ goto usage;
+ break;
+ case 'r':
+ pPars->fUseBdds ^= 1;
+ break;
+ case 'p':
+ pPars->fUseDprove ^= 1;
+ break;
+ case 'f':
+ pPars->fUseStart ^= 1;
+ break;
+ case 'v':
+ pPars->fVerbose ^= 1;
+ break;
+ case 'w':
+ pPars->fVeryVerbose ^= 1;
+ break;
+ case 'h':
+ goto usage;
+ default:
+ goto usage;
+ }
+ }
+ if ( pAbc->pGia == NULL )
+ {
+ Abc_Print( -1, "Abc_CommandAbc9AbsStartNew(): There is no AIG.\n" );
+ return 1;
+ }
+ if ( Gia_ManRegNum(pAbc->pGia) == 0 )
+ {
+ Abc_Print( -1, "Abc_CommandAbc9AbsStartNew(): The AIG is combinational.\n" );
+ return 0;
+ }
+ if ( !(0 <= pPars->nRatio && pPars->nRatio <= 100) )
+ {
+ Abc_Print( -1, "Abc_CommandAbc9AbsStartNew(): Wrong value of parameter \"-R <num>\".\n" );
+ return 0;
+ }
+ Gia_ManCexAbstractionStartNew( pAbc->pGia, pPars );
+ pAbc->Status = pPars->Status;
+ pAbc->nFrames = pPars->nFramesDone;
+ Abc_FrameReplaceCex( pAbc, &pAbc->pGia->pCexSeq );
+ if ( pPars->fVerbose )
+ printf( "Updating ABC solving status to be %d and bmc_frames_done to be %d.\n", pPars->Status, pAbc->nFrames );
+ return 0;
+usage:
+ Abc_Print( -2, "usage: &abs_newstart [-AFSCBTV num] [-vwh]\n" );
+ Abc_Print( -2, "\t initializes flop map using cex-based abstraction (by Niklas Een)\n" );
+ Abc_Print( -2, "\t-A num : selects the algorithm to use [default = %d]\n", pPars->Algo );
+ Abc_Print( -2, "\t 0 = cba\n" );
+ Abc_Print( -2, "\t 1 = pba\n" );
+ Abc_Print( -2, "\t 2 = cba-then-pba\n" );
+ Abc_Print( -2, "\t 3 = cba-with-pba\n" );
+ Abc_Print( -2, "\t-F num : the max number of timeframes for BMC [default = %d]\n", pPars->nFramesBmc );
+ Abc_Print( -2, "\t-S num : the max number of stable frames for BMC [default = %d]\n", pPars->nStableMax );
+ Abc_Print( -2, "\t-C num : the max number of conflicts by SAT solver for BMC [default = %d]\n", pPars->nConfMaxBmc );
+ Abc_Print( -2, "\t-B num : the max number of frames to wait before trying to quit [default = %d]\n", pPars->nBobPar );
+ Abc_Print( -2, "\t-T num : approximate time limit in seconds (0=infinite) [default = %d]\n", pPars->TimeOut );
+ Abc_Print( -2, "\t-V num : approximate \"virtual time\" limit in seconds (0=infinite) [default = %d]\n", pPars->TimeOutVT );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-w : toggle printing additional information [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_CommandAbc9PbaStart( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ Gia_ParAbs_t Pars, * pPars = &Pars;
+ int c;
+ extern void Gia_ManProofAbstractionStart( Gia_Man_t * pGia, Gia_ParAbs_t * pPars );
+
+ // set defaults
+ Gia_ManAbsSetDefaultParams( pPars );
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "FCdvh" ) ) != EOF )
+ {
+ switch ( c )
+ {
+ case 'F':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ pPars->nFramesMax = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->nFramesMax < 0 )
+ goto usage;
+ break;
+ case 'C':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ pPars->nConfMax = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->nConfMax < 0 )
+ goto usage;
+ break;
+ case 'd':
+ pPars->fDynamic ^= 1;
+ break;
+ case 'v':
+ pPars->fVerbose ^= 1;
+ break;
+ case 'h':
+ goto usage;
+ default:
+ goto usage;
+ }
+ }
+ if ( pAbc->pGia == NULL )
+ {
+ Abc_Print( -1, "Abc_CommandAbc9PbaStart(): There is no AIG.\n" );
+ return 1;
+ }
+ if ( Gia_ManRegNum(pAbc->pGia) == 0 )
+ {
+ Abc_Print( -1, "Abc_CommandAbc9PbaStart(): The AIG is combinational.\n" );
+ return 0;
}
-// Gia_ManFrontTest( pAbc->pAig );
-// Gia_ManReduceConst( pAbc->pAig, 1 );
-// Sat_ManTest( pAbc->pAig, Gia_ManCo(pAbc->pAig, 0), 0 );
-// Gia_ManTestDistance( pAbc->pAig );
-// Gia_SatSolveTest( pAbc->pAig );
-// For_ManExperiment( pAbc->pAig, 20, 1, 1 );
-// Gia_ManUnrollSpecial( pAbc->pAig, 5, 100, 1 );
+ Gia_ManProofAbstractionStart( pAbc->pGia, pPars );
+ pAbc->Status = pPars->Status;
+ Abc_FrameReplaceCex( pAbc, &pAbc->pGia->pCexSeq );
+ return 0;
+usage:
+ Abc_Print( -2, "usage: &pba_start [-FC num] [-dvh]\n" );
+ Abc_Print( -2, "\t computes initial flop map using proof-based abstraction\n" );
+ Abc_Print( -2, "\t-F num : the max number of timeframes for PBA [default = %d]\n", pPars->nFramesMax );
+ Abc_Print( -2, "\t-C num : the max number of conflicts by SAT solver for PBA [default = %d]\n", pPars->nConfMax );
+// Abc_Print( -2, "\t-G num : the max number of timeframes for BMC [default = %d]\n", pPars->nFramesBmc );
+// Abc_Print( -2, "\t-D num : the max number of conflicts by SAT solver for BMC [default = %d]\n", pPars->nConfMaxBmc );
+// Abc_Print( -2, "\t-R num : the %% of abstracted flops when refinement stops (0<=num<=100) [default = %d]\n", pPars->nRatio );
+ Abc_Print( -2, "\t-d : toggle dynamic unrolling of timeframes [default = %s]\n", pPars->fDynamic? "yes": "no" );
+// Abc_Print( -2, "\t-e : toggle extending abstraction using COI of flops [default = %s]\n", pPars->fExtend? "yes": "no" );
+// Abc_Print( -2, "\t-s : toggle skipping proof-based abstraction [default = %s]\n", pPars->fSkipProof? "yes": "no" );
+// Abc_Print( -2, "\t-r : toggle using BDD-based reachability for filtering [default = %s]\n", pPars->fUseBdds? "yes": "no" );
+// Abc_Print( -2, "\t-p : toggle using \"dprove\" for filtering [default = %s]\n", pPars->fUseDprove? "yes": "no" );
+// Abc_Print( -2, "\t-f : toggle starting BMC from a later frame [default = %s]\n", pPars->fUseStart? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ return 1;
+}
- if ( fSwitch )
- pAbc->pAig = Gia_ManDupSelf( pTemp = pAbc->pAig );
- else
- pAbc->pAig = Gia_ManRemoveEnables( pTemp = pAbc->pAig );
- Gia_ManStop( pTemp );
-// Cbs_ManSolveTest( pAbc->pAig );
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_CommandAbc9AbsDerive( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ Gia_Man_t * pTemp = NULL;
+ int c, fVerbose = 0;
+ extern Gia_Man_t * Gia_ManCexAbstractionDerive( Gia_Man_t * pGia );
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
+ {
+ switch ( c )
+ {
+ case 'v':
+ fVerbose ^= 1;
+ break;
+ case 'h':
+ goto usage;
+ default:
+ goto usage;
+ }
+ }
+ if ( pAbc->pGia == NULL )
+ {
+ Abc_Print( -1, "Abc_CommandAbc9AbsDerive(): There is no AIG.\n" );
+ return 1;
+ }
+ if ( Gia_ManRegNum(pAbc->pGia) == 0 )
+ {
+ Abc_Print( -1, "The network is combinational.\n" );
+ return 0;
+ }
+ pTemp = Gia_ManCexAbstractionDerive( pAbc->pGia );
+ Abc_CommandUpdate9( pAbc, pTemp );
return 0;
usage:
- fprintf( stdout, "usage: &test [-svh]\n" );
- fprintf( stdout, "\t testing various procedures\n" );
- fprintf( stdout, "\t-s : toggle enable (yes) vs. disable (no) [default = %s]\n", fSwitch? "yes": "no" );
- fprintf( stdout, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: &abs_derive [-vh]\n" );
+ Abc_Print( -2, "\t performs abstraction using the pre-computed flop map\n" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@@ -25379,54 +26620,458 @@ usage:
SeeAlso []
***********************************************************************/
-int Abc_CommandAbcTestNew( Abc_Frame_t * pAbc, int argc, char ** argv )
+int Abc_CommandAbc9AbsRefine( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- extern int Abc_NtkTestProcedure( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2 );
+ Gia_Man_t * pTemp = NULL;
+ int c, fVerbose = 0;
+ extern int Gia_ManCexAbstractionRefine( Gia_Man_t * pGia, Abc_Cex_t * pCex, int fVerbose );
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
+ {
+ switch ( c )
+ {
+ case 'v':
+ fVerbose ^= 1;
+ break;
+ case 'h':
+ goto usage;
+ default:
+ goto usage;
+ }
+ }
+ if ( pAbc->pGia == NULL )
+ {
+ Abc_Print( -1, "Abc_CommandAbc9AbsRefine(): There is no AIG.\n" );
+ return 1;
+ }
+ if ( Gia_ManRegNum(pAbc->pGia) == 0 )
+ {
+ Abc_Print( -1, "The network is combinational.\n" );
+ return 0;
+ }
+ if ( pAbc->pCex == NULL )
+ {
+ Abc_Print( -1, "Abc_CommandAbc9AbsRefine(): There is no counter-example.\n" );
+ return 1;
+ }
+ pAbc->Status = Gia_ManCexAbstractionRefine( pAbc->pGia, pAbc->pCex, fVerbose );
+ Abc_FrameReplaceCex( pAbc, &pAbc->pGia->pCexSeq );
+ return 0;
- Abc_Ntk_t * pNtk;
- int c;
+usage:
+ Abc_Print( -2, "usage: &abs_refine [-vh]\n" );
+ Abc_Print( -2, "\t refines the pre-computed flop map using the counter-example\n" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ return 1;
+}
- pNtk = Abc_FrameReadNtk(pAbc);
+/**Function*************************************************************
- // set defaults
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_CommandAbc9Reparam( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ Gia_Man_t * pTemp = NULL;
+ int c, fVerbose = 0;
Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+ while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
{
switch ( c )
{
+ case 'v':
+ fVerbose ^= 1;
+ break;
case 'h':
goto usage;
default:
goto usage;
}
}
+ if ( pAbc->pGia == NULL )
+ {
+ Abc_Print( -1, "Abc_CommandAbc9Reparam(): There is no AIG.\n" );
+ return 1;
+ }
+ pTemp = Gia_ManReparm( pAbc->pGia, fVerbose );
+ Abc_CommandUpdate9( pAbc, pTemp );
+ return 0;
- if ( pNtk == NULL )
+usage:
+ Abc_Print( -2, "usage: &reparam [-vh]\n" );
+ Abc_Print( -2, "\t performs input trimming nad reparameterization\n" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_CommandAbc9Posplit( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ extern Aig_Man_t * Aig_ManSplit( Aig_Man_t * p, int nVars, int fVerbose );
+ Aig_Man_t * pMan, * pAux;
+ Gia_Man_t * pTemp = NULL;
+ int c, nVars = 5, fVerbose = 0;
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "Nvh" ) ) != EOF )
+ {
+ switch ( c )
+ {
+ case 'N':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ nVars = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( nVars < 0 )
+ goto usage;
+ break;
+ case 'v':
+ fVerbose ^= 1;
+ break;
+ case 'h':
+ goto usage;
+ default:
+ goto usage;
+ }
+ }
+ if ( pAbc->pGia == NULL )
{
- fprintf( stdout, "Empty network.\n" );
+ Abc_Print( -1, "Abc_CommandAbc9Posplit(): There is no AIG.\n" );
return 1;
+ }
+ pMan = Gia_ManToAigSimple( pAbc->pGia );
+ pMan = Aig_ManSplit( pAux = pMan, nVars, fVerbose );
+ Aig_ManStop( pAux );
+ if ( pMan != NULL )
+ {
+ pTemp = Gia_ManFromAigSimple( pMan );
+ Aig_ManStop( pMan );
+ Abc_CommandUpdate9( pAbc, pTemp );
}
+ return 0;
- if ( !Abc_NtkIsStrash( pNtk) )
+usage:
+ Abc_Print( -2, "usage: &posplit [-N num] [-vh]\n" );
+ Abc_Print( -2, "\t cofactors the property output w.r.t. a support subset\n" );
+ Abc_Print( -2, "\t (the OR of new PO functions is equal to the original property)\n" );
+ Abc_Print( -2, "\t-N num : the number of random cofactoring variables [default = %d]\n", nVars );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_CommandAbc9Reach( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ Gia_ParLlb_t Pars, * pPars = &Pars;
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+ char * pLogFileName = NULL;
+ int c;
+ extern int Llb_ManModelCheckGia( Gia_Man_t * pGia, Gia_ParLlb_t * pPars );
+
+ // set defaults
+ Llb_ManSetDefaultParams( pPars );
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "TBFCHSLripcsyzvwh" ) ) != EOF )
+ {
+ switch ( c )
+ {
+ case 'T':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ pPars->TimeLimit = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->TimeLimit < 0 )
+ goto usage;
+ break;
+ case 'B':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-B\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ pPars->nBddMax = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->nBddMax < 0 )
+ goto usage;
+ break;
+ case 'F':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ pPars->nIterMax = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->nIterMax < 0 )
+ goto usage;
+ break;
+ case 'C':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ pPars->nClusterMax = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->nClusterMax < 0 )
+ goto usage;
+ break;
+ case 'H':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-H\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ pPars->nHintDepth = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->nHintDepth < 0 )
+ goto usage;
+ break;
+ case 'S':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ pPars->HintFirst = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( pPars->HintFirst < 0 )
+ goto usage;
+ break;
+ case 'L':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-L\" should be followed by a file name.\n" );
+ goto usage;
+ }
+ pLogFileName = argv[globalUtilOptind];
+ globalUtilOptind++;
+ break;
+ case 'r':
+ pPars->fReorder ^= 1;
+ break;
+ case 'i':
+ pPars->fIndConstr ^= 1;
+ break;
+ case 'p':
+ pPars->fUsePivots ^= 1;
+ break;
+ case 'c':
+ pPars->fCluster ^= 1;
+ break;
+ case 's':
+ pPars->fSchedule ^= 1;
+ break;
+ case 'y':
+ pPars->fSkipOutCheck ^= 1;
+ break;
+ case 'z':
+ pPars->fSkipReach ^= 1;
+ break;
+ case 'v':
+ pPars->fVerbose ^= 1;
+ break;
+ case 'w':
+ pPars->fVeryVerbose ^= 1;
+ break;
+ case 'h':
+ goto usage;
+ default:
+ goto usage;
+ }
+ }
+ if ( pAbc->pGia == NULL )
{
- fprintf( stdout, "The current network is not an AIG. Cannot continue.\n" );
+ Abc_Print( -1, "Abc_CommandAbc9Reach(): There is no AIG.\n" );
return 1;
}
+ if ( Gia_ManRegNum(pAbc->pGia) == 0 )
+ {
+ Abc_Print( -1, "Abc_CommandAbc9Reach(): The current AIG has no latches.\n" );
+ return 0;
+ }
+ pAbc->Status = Llb_ManModelCheckGia( pAbc->pGia, pPars );
+ pAbc->nFrames = pPars->iFrame;
+ Abc_FrameReplaceCex( pAbc, &pAbc->pGia->pCexSeq );
+ if ( pLogFileName )
+ Abc_NtkWriteLogFile( pLogFileName, pAbc->pCex, pAbc->Status, "&reach" );
+ return 0;
-// Abc_NtkTestProcedure( pNtk, NULL );
+usage:
+ Abc_Print( -2, "usage: &reach [-TBFCHS num] [-L file] [-ripcsyzvwh]\n" );
+ Abc_Print( -2, "\t verifies sequential miter using BDD-based reachability\n" );
+ Abc_Print( -2, "\t-T num : approximate time limit in seconds (0=infinite) [default = %d]\n", pPars->TimeLimit );
+ Abc_Print( -2, "\t-B num : max number of nodes in the intermediate BDDs [default = %d]\n", pPars->nBddMax );
+ Abc_Print( -2, "\t-F num : max number of reachability iterations [default = %d]\n", pPars->nIterMax );
+ Abc_Print( -2, "\t-C num : max number of variables in a cluster [default = %d]\n", pPars->nClusterMax );
+ Abc_Print( -2, "\t-H num : max number of hints to use [default = %d]\n", pPars->nHintDepth );
+ Abc_Print( -2, "\t-S num : the number of the starting hint [default = %d]\n", pPars->HintFirst );
+ Abc_Print( -2, "\t-L file: the log file name [default = %s]\n", pLogFileName ? pLogFileName : "no logging" );
+ Abc_Print( -2, "\t-r : enable dynamic BDD variable reordering [default = %s]\n", pPars->fReorder? "yes": "no" );
+ Abc_Print( -2, "\t-i : enable extraction of inductive constraints [default = %s]\n", pPars->fIndConstr? "yes": "no" );
+ Abc_Print( -2, "\t-p : enable partitions for internal cut-points [default = %s]\n", pPars->fUsePivots? "yes": "no" );
+ Abc_Print( -2, "\t-c : enable clustering of partitions [default = %s]\n", pPars->fCluster? "yes": "no" );
+ Abc_Print( -2, "\t-s : enable scheduling of clusters [default = %s]\n", pPars->fSchedule? "yes": "no" );
+ Abc_Print( -2, "\t-y : skip checking property outputs [default = %s]\n", pPars->fSkipOutCheck? "yes": "no" );
+ Abc_Print( -2, "\t-z : skip reachability (run preparation phase only) [default = %s]\n", pPars->fSkipReach? "yes": "no" );
+ Abc_Print( -2, "\t-v : prints verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-w : prints dependency matrix [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ return 1;
+}
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_CommandAbc9Undo( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ int c;
+ // set defaults
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+ {
+ switch ( c )
+ {
+ case 'h':
+ goto usage;
+ default:
+ goto usage;
+ }
+ }
+ if ( pAbc->pGia == NULL )
+ {
+ Abc_Print( -1, "Abc_CommandAbc9Undo(): There is no design.\n" );
+ return 1;
+ }
+ if ( pAbc->pGia2 == NULL )
+ {
+ Abc_Print( -1, "Abc_CommandAbc9Undo(): There is no previously saved network.\n" );
+ return 1;
+ }
+ Gia_ManStop( pAbc->pGia );
+ pAbc->pGia = pAbc->pGia2;
+ pAbc->pGia2 = NULL;
return 0;
usage:
- fprintf( stdout, "usage: testnew [-h]\n" );
- fprintf( stdout, "\t new testing procedure\n" );
- fprintf( stdout, "\t-h : print the command usage\n");
+ Abc_Print( -2, "usage: &undo [-h]\n" );
+ Abc_Print( -2, "\t reverses the previous AIG transformation\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_CommandAbc9Test( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ Gia_Man_t * pTemp = NULL;
+ int c, fVerbose = 0;
+ int fSwitch = 0;
+ extern void Gia_SatSolveTest( Gia_Man_t * p );
+ extern void Cbs_ManSolveTest( Gia_Man_t * pGia );
+
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "svh" ) ) != EOF )
+ {
+ switch ( c )
+ {
+ case 's':
+ fSwitch ^= 1;
+ break;
+ case 'v':
+ fVerbose ^= 1;
+ break;
+ case 'h':
+ goto usage;
+ default:
+ goto usage;
+ }
+ }
+ if ( pAbc->pGia == NULL )
+ {
+ Abc_Print( -1, "Abc_CommandAbc9Test(): There is no AIG.\n" );
+ return 1;
+ }
+// Gia_ManFrontTest( pAbc->pGia );
+// Gia_ManReduceConst( pAbc->pGia, 1 );
+// Sat_ManTest( pAbc->pGia, Gia_ManCo(pAbc->pGia, 0), 0 );
+// Gia_ManTestDistance( pAbc->pGia );
+// Gia_SatSolveTest( pAbc->pGia );
+// For_ManExperiment( pAbc->pGia, 20, 1, 1 );
+// Gia_ManUnrollSpecial( pAbc->pGia, 5, 100, 1 );
+
+ if ( fSwitch )
+ pAbc->pGia = Gia_ManDupSelf( pTemp = pAbc->pGia );
+ else
+ pAbc->pGia = Gia_ManRemoveEnables( pTemp = pAbc->pGia );
+ Gia_ManStop( pTemp );
+// Cbs_ManSolveTest( pAbc->pGia );
+ return 0;
+
+usage:
+ Abc_Print( -2, "usage: &test [-svh]\n" );
+ Abc_Print( -2, "\t testing various procedures\n" );
+ Abc_Print( -2, "\t-s : toggle enable (yes) vs. disable (no) [default = %s]\n", fSwitch? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ return 1;
+}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcAbc8.c b/src/base/abci/abcAbc8.c
index a306a8e4..3bfaaa98 100644
--- a/src/base/abci/abcAbc8.c
+++ b/src/base/abci/abcAbc8.c
@@ -22,6 +22,11 @@
#include "nwk.h"
#include "mfx.h"
+#include "main.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -67,12 +72,12 @@ Nwk_Man_t * Abc_NtkToNtkNew( Abc_Ntk_t * pNtk )
Abc_NtkForEachCi( pNtk, pObj, i )
pObj->pCopy = (Abc_Obj_t *)Nwk_ManCreateCi( pNtkNew, Abc_ObjFanoutNum(pObj) );
vNodes = Abc_NtkDfs( pNtk, 1 );
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
{
pObjNew = Nwk_ManCreateNode( pNtkNew, Abc_ObjFaninNum(pObj), Abc_ObjFanoutNum(pObj) );
Abc_ObjForEachFanin( pObj, pFanin, k )
Nwk_ObjAddFanin( pObjNew, (Nwk_Obj_t *)pFanin->pCopy );
- pObjNew->pFunc = Hop_Transfer( pNtk->pManFunc, pNtkNew->pManHop, pObj->pData, Abc_ObjFaninNum(pObj) );
+ pObjNew->pFunc = Hop_Transfer( (Hop_Man_t *)pNtk->pManFunc, pNtkNew->pManHop, (Hop_Obj_t *)pObj->pData, Abc_ObjFaninNum(pObj) );
pObj->pCopy = (Abc_Obj_t *)pObjNew;
}
Vec_PtrFree( vNodes );
@@ -115,14 +120,14 @@ Abc_Ntk_t * Abc_NtkFromNtkNew( Abc_Ntk_t * pNtkOld, Nwk_Man_t * pNtk )
Abc_ObjAssignName( pObjNew, Abc_ObjName( Abc_NtkCi(pNtkOld, i) ), NULL );
}
vNodes = Nwk_ManDfs( pNtk );
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Nwk_Obj_t *, vNodes, pObj, i )
{
if ( !Nwk_ObjIsNode(pObj) )
continue;
pObjNew = Abc_NtkCreateNode( pNtkNew );
Nwk_ObjForEachFanin( pObj, pFanin, k )
- Abc_ObjAddFanin( pObjNew, pFanin->pCopy );
- pObjNew->pData = Hop_Transfer( pNtk->pManHop, pNtkNew->pManFunc, pObj->pFunc, Nwk_ObjFaninNum(pObj) );
+ Abc_ObjAddFanin( pObjNew, (Abc_Obj_t *)pFanin->pCopy );
+ pObjNew->pData = Hop_Transfer( pNtk->pManHop, (Hop_Man_t *)pNtkNew->pManFunc, pObj->pFunc, Nwk_ObjFaninNum(pObj) );
pObj->pCopy = (Nwk_Obj_t *)pObjNew;
}
Vec_PtrFree( vNodes );
@@ -130,9 +135,9 @@ Abc_Ntk_t * Abc_NtkFromNtkNew( Abc_Ntk_t * pNtkOld, Nwk_Man_t * pNtk )
{
pObjNew = Abc_NtkCreatePo( pNtkNew );
if ( pObj->fInvert )
- pFaninNew = Abc_NtkCreateNodeInv( pNtkNew, Nwk_ObjFanin0(pObj)->pCopy );
+ pFaninNew = Abc_NtkCreateNodeInv( pNtkNew, (Abc_Obj_t *)Nwk_ObjFanin0(pObj)->pCopy );
else
- pFaninNew = Nwk_ObjFanin0(pObj)->pCopy;
+ pFaninNew = (Abc_Obj_t *)Nwk_ObjFanin0(pObj)->pCopy;
Abc_ObjAddFanin( pObjNew, pFaninNew );
Abc_ObjAssignName( pObjNew, Abc_ObjName( Abc_NtkCo(pNtkOld, i) ), NULL );
}
@@ -198,7 +203,7 @@ clk = clock();
ABC_PRT( "Time", clock() - clk );
pMan = Abc_NtkToNtkNew( pNtk );
- pMan->pLutLib = Abc_FrameReadLibLut();
+ pMan->pLutLib = (If_Lib_t *)Abc_FrameReadLibLut();
clk = clock();
printf( "%6.2f\n", Nwk_ManDelayTraceLut( pMan ) );
ABC_PRT( "Time", clock() - clk );
@@ -221,7 +226,6 @@ ABC_PRT( "Time", clock() - clk );
***********************************************************************/
Abc_Ntk_t * Abc_NtkNtkTest4( Abc_Ntk_t * pNtk, If_Lib_t * pLutLib )
{
- extern int Mfx_Perform( Nwk_Man_t * pNtk, Mfx_Par_t * pPars, If_Lib_t * pLutLib );
Mfx_Par_t Pars, * pPars = &Pars;
Abc_Ntk_t * pNtkNew;
@@ -272,3 +276,5 @@ Abc_Ntk_t * Abc_NtkNtkTest( Abc_Ntk_t * pNtk, If_Lib_t * pLutLib )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcAttach.c b/src/base/abci/abcAttach.c
index e35cfdf6..d1712f4d 100644
--- a/src/base/abci/abcAttach.c
+++ b/src/base/abci/abcAttach.c
@@ -22,6 +22,9 @@
#include "main.h"
#include "mio.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -66,7 +69,7 @@ int Abc_NtkAttach( Abc_Ntk_t * pNtk )
assert( Abc_NtkIsSopLogic(pNtk) );
// check that the library is available
- pGenlib = Abc_FrameReadLibGen();
+ pGenlib = (Mio_Library_t *)Abc_FrameReadLibGen();
if ( pGenlib == NULL )
{
printf( "The current library is not available.\n" );
@@ -94,14 +97,14 @@ int Abc_NtkAttach( Abc_Ntk_t * pNtk )
nFanins = Abc_ObjFaninNum(pNode);
if ( nFanins == 0 )
{
- if ( Abc_SopIsConst1(pNode->pData) )
+ if ( Abc_SopIsConst1((char *)pNode->pData) )
pNode->pCopy = (Abc_Obj_t *)Mio_LibraryReadConst1(pGenlib);
else
pNode->pCopy = (Abc_Obj_t *)Mio_LibraryReadConst0(pGenlib);
}
else if ( nFanins == 1 )
{
- if ( Abc_SopIsBuf(pNode->pData) )
+ if ( Abc_SopIsBuf((char *)pNode->pData) )
pNode->pCopy = (Abc_Obj_t *)Mio_LibraryReadBuf(pGenlib);
else
pNode->pCopy = (Abc_Obj_t *)Mio_LibraryReadInv(pGenlib);
@@ -142,7 +145,7 @@ int Abc_NtkAttach( Abc_Ntk_t * pNtk )
Abc_NtkForEachNode( pNtk, pNode, i )
pNode->pData = pNode->pCopy, pNode->pCopy = NULL;
pNtk->ntkFunc = ABC_FUNC_MAP;
- Extra_MmFlexStop( pNtk->pManFunc );
+ Extra_MmFlexStop( (Extra_MmFlex_t *)pNtk->pManFunc );
pNtk->pManFunc = pGenlib;
printf( "Library gates are successfully attached to the nodes.\n" );
@@ -177,7 +180,7 @@ int Abc_NodeAttach( Abc_Obj_t * pNode, Mio_Gate_t ** ppGates, unsigned ** puTrut
int nFanins, i;
// compute the node's truth table
- Abc_AttachComputeTruth( pNode->pData, uTruths, uTruthNode );
+ Abc_AttachComputeTruth( (char *)pNode->pData, uTruths, uTruthNode );
// find the matching gate and permutation
pGate = Abc_AttachFind( ppGates, puTruthGates, nGates, uTruthNode, Perm );
if ( pGate == NULL )
@@ -402,3 +405,5 @@ void Abc_TruthPermute( char * pPerm, int nVars, unsigned * uTruthNode, unsigned
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcAuto.c b/src/base/abci/abcAuto.c
index 13be6eea..b595a536 100644
--- a/src/base/abci/abcAuto.c
+++ b/src/base/abci/abcAuto.c
@@ -20,6 +20,9 @@
#include "abc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -237,3 +240,5 @@ void Abc_NtkAutoPrintOne( DdManager * dd, int nInputs, DdNode * pbOutputs[], int
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcBalance.c b/src/base/abci/abcBalance.c
index 134a175a..9c16bd2c 100644
--- a/src/base/abci/abcBalance.c
+++ b/src/base/abci/abcBalance.c
@@ -20,14 +20,17 @@
#include "abc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
-static void Abc_NtkBalancePerform( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkAig, bool fDuplicate, bool fSelective, bool fUpdateLevel );
-static Abc_Obj_t * Abc_NodeBalance_rec( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNode, Vec_Vec_t * vStorage, int Level, bool fDuplicate, bool fSelective, bool fUpdateLevel );
-static Vec_Ptr_t * Abc_NodeBalanceCone( Abc_Obj_t * pNode, Vec_Vec_t * vSuper, int Level, int fDuplicate, bool fSelective );
-static int Abc_NodeBalanceCone_rec( Abc_Obj_t * pNode, Vec_Ptr_t * vSuper, bool fFirst, bool fDuplicate, bool fSelective );
+static void Abc_NtkBalancePerform( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkAig, int fDuplicate, int fSelective, int fUpdateLevel );
+static Abc_Obj_t * Abc_NodeBalance_rec( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNode, Vec_Vec_t * vStorage, int Level, int fDuplicate, int fSelective, int fUpdateLevel );
+static Vec_Ptr_t * Abc_NodeBalanceCone( Abc_Obj_t * pNode, Vec_Vec_t * vSuper, int Level, int fDuplicate, int fSelective );
+static int Abc_NodeBalanceCone_rec( Abc_Obj_t * pNode, Vec_Ptr_t * vSuper, int fFirst, int fDuplicate, int fSelective );
static void Abc_NtkMarkCriticalNodes( Abc_Ntk_t * pNtk );
static Vec_Ptr_t * Abc_NodeBalanceConeExor( Abc_Obj_t * pNode );
@@ -47,7 +50,7 @@ static Vec_Ptr_t * Abc_NodeBalanceConeExor( Abc_Obj_t * pNode );
SeeAlso []
***********************************************************************/
-Abc_Ntk_t * Abc_NtkBalance( Abc_Ntk_t * pNtk, bool fDuplicate, bool fSelective, bool fUpdateLevel )
+Abc_Ntk_t * Abc_NtkBalance( Abc_Ntk_t * pNtk, int fDuplicate, int fSelective, int fUpdateLevel )
{
// extern void Abc_NtkHaigTranfer( Abc_Ntk_t * pNtkOld, Abc_Ntk_t * pNtkNew );
Abc_Ntk_t * pNtkAig;
@@ -65,6 +68,7 @@ Abc_Ntk_t * Abc_NtkBalance( Abc_Ntk_t * pNtk, bool fDuplicate, bool fSelective,
// perform balancing
Abc_NtkBalancePerform( pNtk, pNtkAig, fDuplicate, fSelective, fUpdateLevel );
Abc_NtkFinalize( pNtk, pNtkAig );
+ Abc_AigCleanup( pNtkAig->pManFunc );
// undo the required times
if ( fSelective )
{
@@ -94,7 +98,7 @@ Abc_Ntk_t * Abc_NtkBalance( Abc_Ntk_t * pNtk, bool fDuplicate, bool fSelective,
SeeAlso []
***********************************************************************/
-void Abc_NtkBalancePerform( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkAig, bool fDuplicate, bool fSelective, bool fUpdateLevel )
+void Abc_NtkBalancePerform( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkAig, int fDuplicate, int fSelective, int fUpdateLevel )
{
ProgressBar * pProgress;
Vec_Vec_t * vStorage;
@@ -142,19 +146,19 @@ int Abc_NodeBalanceFindLeft( Vec_Ptr_t * vSuper )
return 0;
// set the pointer to the one before the last
Current = Vec_PtrSize(vSuper) - 2;
- pNodeRight = Vec_PtrEntry( vSuper, Current );
+ pNodeRight = (Abc_Obj_t *)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
- pNodeLeft = Vec_PtrEntry( vSuper, Current );
+ pNodeLeft = (Abc_Obj_t *)Vec_PtrEntry( vSuper, Current );
// if the level of this node is different, quit the loop
if ( Abc_ObjRegular(pNodeLeft)->Level != Abc_ObjRegular(pNodeRight)->Level )
break;
}
Current++;
// get the node, for which the equality holds
- pNodeLeft = Vec_PtrEntry( vSuper, Current );
+ pNodeLeft = (Abc_Obj_t *)Vec_PtrEntry( vSuper, Current );
assert( Abc_ObjRegular(pNodeLeft)->Level == Abc_ObjRegular(pNodeRight)->Level );
return Current;
}
@@ -181,13 +185,13 @@ void Abc_NodeBalancePermute( Abc_Ntk_t * pNtkNew, Vec_Ptr_t * vSuper, int LeftBo
if ( LeftBound == RightBound )
return;
// get the two last nodes
- pNode1 = Vec_PtrEntry( vSuper, RightBound + 1 );
- pNode2 = Vec_PtrEntry( vSuper, RightBound );
+ pNode1 = (Abc_Obj_t *)Vec_PtrEntry( vSuper, RightBound + 1 );
+ pNode2 = (Abc_Obj_t *)Vec_PtrEntry( vSuper, RightBound );
// find the first node that can be shared
for ( i = RightBound; i >= LeftBound; i-- )
{
- pNode3 = Vec_PtrEntry( vSuper, i );
- if ( Abc_AigAndLookup( pNtkNew->pManFunc, pNode1, pNode3 ) )
+ pNode3 = (Abc_Obj_t *)Vec_PtrEntry( vSuper, i );
+ if ( Abc_AigAndLookup( (Abc_Aig_t *)pNtkNew->pManFunc, pNode1, pNode3 ) )
{
if ( pNode3 == pNode2 )
return;
@@ -220,9 +224,9 @@ void Abc_NodeBalancePermute( Abc_Ntk_t * pNtkNew, Vec_Ptr_t * vSuper, int LeftBo
SeeAlso []
***********************************************************************/
-Abc_Obj_t * Abc_NodeBalance_rec( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNodeOld, Vec_Vec_t * vStorage, int Level, bool fDuplicate, bool fSelective, bool fUpdateLevel )
+Abc_Obj_t * Abc_NodeBalance_rec( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNodeOld, Vec_Vec_t * vStorage, int Level, int fDuplicate, int fSelective, int fUpdateLevel )
{
- Abc_Aig_t * pMan = pNtkNew->pManFunc;
+ Abc_Aig_t * pMan = (Abc_Aig_t *)pNtkNew->pManFunc;
Abc_Obj_t * pNodeNew, * pNode1, * pNode2;
Vec_Ptr_t * vSuper;
int i, LeftBound;
@@ -242,13 +246,13 @@ Abc_Obj_t * Abc_NodeBalance_rec( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNodeOld, Vec_
// for each old node, derive the new well-balanced node
for ( i = 0; i < vSuper->nSize; i++ )
{
- pNodeNew = Abc_NodeBalance_rec( pNtkNew, Abc_ObjRegular(vSuper->pArray[i]), vStorage, Level + 1, fDuplicate, fSelective, fUpdateLevel );
- vSuper->pArray[i] = Abc_ObjNotCond( pNodeNew, Abc_ObjIsComplement(vSuper->pArray[i]) );
+ pNodeNew = Abc_NodeBalance_rec( pNtkNew, Abc_ObjRegular((Abc_Obj_t *)vSuper->pArray[i]), vStorage, Level + 1, fDuplicate, fSelective, fUpdateLevel );
+ vSuper->pArray[i] = Abc_ObjNotCond( pNodeNew, Abc_ObjIsComplement((Abc_Obj_t *)vSuper->pArray[i]) );
}
if ( vSuper->nSize < 2 )
printf( "BUG!\n" );
// sort the new nodes by level in the decreasing order
- Vec_PtrSort( vSuper, Abc_NodeCompareLevelsDecrease );
+ Vec_PtrSort( vSuper, (int (*)(void))Abc_NodeCompareLevelsDecrease );
// balance the nodes
assert( vSuper->nSize > 1 );
while ( vSuper->nSize > 1 )
@@ -258,14 +262,14 @@ Abc_Obj_t * Abc_NodeBalance_rec( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNodeOld, Vec_
// find the node that can be shared (if no such node, randomize choice)
Abc_NodeBalancePermute( pNtkNew, vSuper, LeftBound );
// pull out the last two nodes
- pNode1 = Vec_PtrPop(vSuper);
- pNode2 = Vec_PtrPop(vSuper);
+ pNode1 = (Abc_Obj_t *)Vec_PtrPop(vSuper);
+ pNode2 = (Abc_Obj_t *)Vec_PtrPop(vSuper);
Abc_VecObjPushUniqueOrderByLevel( vSuper, Abc_AigAnd(pMan, pNode1, pNode2) );
}
// make sure the balanced node is not assigned
assert( pNodeOld->pCopy == NULL );
// mark the old node with the new node
- pNodeOld->pCopy = vSuper->pArray[0];
+ pNodeOld->pCopy = (Abc_Obj_t *)vSuper->pArray[0];
vSuper->nSize = 0;
// if ( Abc_ObjRegular(pNodeOld->pCopy) == Abc_AigConst1(pNtkNew) )
// printf( "Constant node\n" );
@@ -289,7 +293,7 @@ Abc_Obj_t * Abc_NodeBalance_rec( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNodeOld, Vec_
SeeAlso []
***********************************************************************/
-Vec_Ptr_t * Abc_NodeBalanceCone( Abc_Obj_t * pNode, Vec_Vec_t * vStorage, int Level, int fDuplicate, bool fSelective )
+Vec_Ptr_t * Abc_NodeBalanceCone( Abc_Obj_t * pNode, Vec_Vec_t * vStorage, int Level, int fDuplicate, int fSelective )
{
Vec_Ptr_t * vNodes;
int RetValue, i;
@@ -298,7 +302,7 @@ Vec_Ptr_t * Abc_NodeBalanceCone( Abc_Obj_t * pNode, Vec_Vec_t * vStorage, int Le
if ( Vec_VecSize( vStorage ) <= Level )
Vec_VecPush( vStorage, Level, 0 );
// get the temporary array of nodes
- vNodes = Vec_VecEntry( vStorage, Level );
+ vNodes = (Vec_Ptr_t *)Vec_VecEntry( vStorage, Level );
Vec_PtrClear( vNodes );
// collect the nodes in the implication supergate
RetValue = Abc_NodeBalanceCone_rec( pNode, vNodes, 1, fDuplicate, fSelective );
@@ -327,7 +331,7 @@ Vec_Ptr_t * Abc_NodeBalanceCone( Abc_Obj_t * pNode, Vec_Vec_t * vStorage, int Le
SeeAlso []
***********************************************************************/
-int Abc_NodeBalanceCone_rec( Abc_Obj_t * pNode, Vec_Ptr_t * vSuper, bool fFirst, bool fDuplicate, bool fSelective )
+int Abc_NodeBalanceCone_rec( Abc_Obj_t * pNode, Vec_Ptr_t * vSuper, int fFirst, int fDuplicate, int fSelective )
{
int RetValue1, RetValue2, i;
// check if the node is visited
@@ -374,7 +378,7 @@ int Abc_NodeBalanceCone_rec( Abc_Obj_t * pNode, Vec_Ptr_t * vSuper, bool fFirst,
SeeAlso []
***********************************************************************/
-int Abc_NodeBalanceConeExor_rec( Abc_Obj_t * pNode, Vec_Ptr_t * vSuper, bool fFirst )
+int Abc_NodeBalanceConeExor_rec( Abc_Obj_t * pNode, Vec_Ptr_t * vSuper, int fFirst )
{
int RetValue1, RetValue2, i;
// check if the node occurs in the same polarity
@@ -459,7 +463,7 @@ Vec_Ptr_t * Abc_NodeFindCone_rec( Abc_Obj_t * pNode )
RetValue = Abc_NodeBalanceCone_rec( pNode, vNodes, 1, 1, 0 );
assert( vNodes->nSize > 1 );
// unmark the visited nodes
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
Abc_ObjRegular(pNode)->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)
@@ -467,7 +471,7 @@ Vec_Ptr_t * Abc_NodeFindCone_rec( Abc_Obj_t * pNode )
vNodes->nSize = 0;
}
// call for the fanin
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
{
pNode = Abc_ObjRegular(pNode);
if ( pNode->pCopy )
@@ -549,7 +553,7 @@ int Abc_NtkBalanceLevel_rec( Abc_Obj_t * pNode )
vSuper = (Vec_Ptr_t *)pNode->pCopy;
assert( vSuper != NULL );
LevelMax = 0;
- Vec_PtrForEachEntry( vSuper, pFanin, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vSuper, pFanin, i )
{
pFanin = Abc_ObjRegular(pFanin);
Abc_NtkBalanceLevel_rec(pFanin);
@@ -610,3 +614,5 @@ void Abc_NtkMarkCriticalNodes( Abc_Ntk_t * pNtk )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcBidec.c b/src/base/abci/abcBidec.c
index 0b6165fb..bae29e07 100644
--- a/src/base/abci/abcBidec.c
+++ b/src/base/abci/abcBidec.c
@@ -20,12 +20,16 @@
#include "abc.h"
#include "bdc.h"
+#include "kit.h"
+
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
-static inline Hop_Obj_t * Bdc_FunCopyHop( Bdc_Fun_t * pObj ) { return Hop_NotCond( Bdc_FuncCopy(Bdc_Regular(pObj)), Bdc_IsComplement(pObj) ); }
+static inline Hop_Obj_t * Bdc_FunCopyHop( Bdc_Fun_t * pObj ) { return Hop_NotCond( (Hop_Obj_t *)Bdc_FuncCopy(Bdc_Regular(pObj)), Bdc_IsComplement(pObj) ); }
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
@@ -128,9 +132,9 @@ void Abc_NtkBidecResyn( Abc_Ntk_t * pNtk, int fVerbose )
{
if ( Abc_ObjFaninNum(pObj) > 15 )
continue;
- nNodes1 = Hop_DagSize(pObj->pData);
- pObj->pData = Abc_NodeIfNodeResyn( p, pNtk->pManFunc, pObj->pData, Abc_ObjFaninNum(pObj), vTruth, NULL, -1.0 );
- nNodes2 = Hop_DagSize(pObj->pData);
+ nNodes1 = Hop_DagSize((Hop_Obj_t *)pObj->pData);
+ pObj->pData = Abc_NodeIfNodeResyn( p, (Hop_Man_t *)pNtk->pManFunc, (Hop_Obj_t *)pObj->pData, Abc_ObjFaninNum(pObj), vTruth, NULL, -1.0 );
+ nNodes2 = Hop_DagSize((Hop_Obj_t *)pObj->pData);
nGainTotal += nNodes1 - nNodes2;
}
Bdc_ManFree( p );
@@ -148,3 +152,5 @@ void Abc_NtkBidecResyn( Abc_Ntk_t * pNtk, int fVerbose )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcBm.c b/src/base/abci/abcBm.c
new file mode 100644
index 00000000..8855fd9e
--- /dev/null
+++ b/src/base/abci/abcBm.c
@@ -0,0 +1,2047 @@
+/**CFile****************************************************************
+
+ FileName [bm.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Boolean Matching package.]
+
+ Synopsis [Check P-equivalence and PP-equivalence of two circuits.]
+
+ Author [Hadi Katebi]
+
+ Affiliation [University of Michigan]
+
+ Date [Ver. 1.0. Started - January, 2009.]
+
+ Revision [No revisions so far]
+
+ Comments [This is the cleaned up version of the code I used for DATE 2010 publication.]
+ [If you have any question or if you find a bug, contact me at hadik@umich.edu.]
+ [I don't guarantee that I can fix all the bugs, but I can definitely point you to
+ the right direction so you can fix the bugs yourself].
+
+ Debugging [There are some part of the code that are commented out. Those parts mostly print
+ the contents of the data structures to the standard output. Un-comment them if you
+ find them useful for debugging.]
+
+***********************************************************************/
+
+#include "abc.h"
+#include "sim.h"
+#include "satSolver.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+int match1by1(Abc_Ntk_t * pNtk1, Vec_Ptr_t ** nodesInLevel1, Vec_Int_t ** iMatch1, Vec_Int_t ** iDep1, Vec_Int_t * matchedInputs1, int * iGroup1, Vec_Int_t ** oMatch1, int * oGroup1,
+ Abc_Ntk_t * pNtk2, Vec_Ptr_t ** nodesInLevel2, Vec_Int_t ** iMatch2, Vec_Int_t ** iDep2, Vec_Int_t * matchedInputs2, int * iGroup2, Vec_Int_t ** oMatch2, int * oGroup2,
+ Vec_Int_t * matchedOutputs1, Vec_Int_t * matchedOutputs2, Vec_Int_t * oMatchedGroups, Vec_Int_t * iNonSingleton, int ii, int idx);
+
+int Abc_NtkBmSat( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, Vec_Ptr_t * iMatchPairs, Vec_Ptr_t * oMatchPairs, Vec_Int_t * mismatch, int mode);
+
+void getDependencies(Abc_Ntk_t *pNtk, Vec_Int_t** iDep, Vec_Int_t** oDep)
+{
+ Vec_Ptr_t * vSuppFun;
+ int i, j;
+
+ vSuppFun = Sim_ComputeFunSupp(pNtk, 0);
+ for(i = 0; i < Abc_NtkPoNum(pNtk); i++) {
+ char * seg = (char *)vSuppFun->pArray[i];
+
+ for(j = 0; j < Abc_NtkPiNum(pNtk); j+=8) {
+ if(((*seg) & 0x01) == 0x01)
+ Vec_IntPushOrder(oDep[i], j);
+ if(((*seg) & 0x02) == 0x02)
+ Vec_IntPushOrder(oDep[i], j+1);
+ if(((*seg) & 0x04) == 0x04)
+ Vec_IntPushOrder(oDep[i], j+2);
+ if(((*seg) & 0x08) == 0x08)
+ Vec_IntPushOrder(oDep[i], j+3);
+ if(((*seg) & 0x10) == 0x10)
+ Vec_IntPushOrder(oDep[i], j+4);
+ if(((*seg) & 0x20) == 0x20)
+ Vec_IntPushOrder(oDep[i], j+5);
+ if(((*seg) & 0x40) == 0x40)
+ Vec_IntPushOrder(oDep[i], j+6);
+ if(((*seg) & 0x80) == 0x80)
+ Vec_IntPushOrder(oDep[i], j+7);
+
+ seg++;
+ }
+ }
+
+ for(i = 0; i < Abc_NtkPoNum(pNtk); i++)
+ for(j = 0; j < Vec_IntSize(oDep[i]); j++)
+ Vec_IntPush(iDep[Vec_IntEntry(oDep[i], j)], i);
+
+
+ /*for(i = 0; i < Abc_NtkPoNum(pNtk); i++)
+ {
+ printf("Output %d: ", i);
+ for(j = 0; j < Vec_IntSize(oDep[i]); j++)
+ printf("%d ", Vec_IntEntry(oDep[i], j));
+ printf("\n");
+ }
+
+ printf("\n");
+
+ for(i = 0; i < Abc_NtkPiNum(pNtk); i++)
+ {
+ printf("Input %d: ", i);
+ for(j = 0; j < Vec_IntSize(iDep[i]); j++)
+ printf("%d ", Vec_IntEntry(iDep[i], j));
+ printf("\n");
+ }
+
+ printf("\n"); */
+}
+
+void initMatchList(Abc_Ntk_t *pNtk, Vec_Int_t** iDep, Vec_Int_t** oDep, Vec_Int_t** iMatch, int* iLastItem, Vec_Int_t** oMatch, int* oLastItem, int* iGroup, int* oGroup, int p_equivalence)
+{
+ int i, j, curr;
+ Vec_Int_t** temp;
+
+ if(!p_equivalence) {
+ temp = ABC_ALLOC( Vec_Int_t*, Abc_NtkPiNum(pNtk)+1);
+
+ for(i = 0; i < Abc_NtkPiNum(pNtk)+1; i++)
+ temp[i] = Vec_IntAlloc( 0 );
+
+ for(i = 0; i < Abc_NtkPoNum(pNtk); i++)
+ Vec_IntPush(temp[Vec_IntSize(oDep[i])], i);
+
+ curr = 0;
+ for(i = 0; i < Abc_NtkPiNum(pNtk)+1; i++)
+ {
+ if(Vec_IntSize(temp[i]) == 0)
+ Vec_IntFree( temp[i] );
+
+ else
+ {
+ oMatch[curr] = temp[i];
+
+ for(j = 0; j < Vec_IntSize(temp[i]); j++)
+ oGroup[Vec_IntEntry(oMatch[curr], j)] = curr;
+
+ curr++;
+ }
+ }
+
+ *oLastItem = curr;
+
+ ABC_FREE( temp );
+ }
+ else {
+ // the else part fixes the outputs for P-equivalence checking
+ for(i = 0; i < Abc_NtkPoNum(pNtk); i++)
+ {
+ Vec_IntPush(oMatch[i], i);
+ oGroup[i] = i;
+ (*oLastItem) = Abc_NtkPoNum(pNtk);
+ }
+ }
+
+ /*for(j = 0; j < *oLastItem; j++)
+ {
+ printf("oMatch %d: ", j);
+ for(i = 0; i < Vec_IntSize(oMatch[j]); i++)
+ printf("%d ", Vec_IntEntry(oMatch[j], i));
+ printf("\n");
+ }
+
+ for(i = 0; i < Abc_NtkPoNum(pNtk); i++)
+ printf("%d: %d ", i, oGroup[i]);*/
+
+ //////////////////////////////////////////////////////////////////////////////
+
+ temp = ABC_ALLOC( Vec_Int_t*, Abc_NtkPoNum(pNtk)+1 );
+
+ for(i = 0; i < Abc_NtkPoNum(pNtk)+1; i++)
+ temp[i] = Vec_IntAlloc( 0 );
+
+ for(i = 0; i < Abc_NtkPiNum(pNtk); i++)
+ Vec_IntPush(temp[Vec_IntSize(iDep[i])], i);
+
+ curr = 0;
+ for(i = 0; i < Abc_NtkPoNum(pNtk)+1; i++)
+ {
+ if(Vec_IntSize(temp[i]) == 0)
+ Vec_IntFree( temp[i] );
+ else
+ {
+ iMatch[curr] = temp[i];
+ for(j = 0; j < Vec_IntSize(iMatch[curr]); j++)
+ iGroup[Vec_IntEntry(iMatch[curr], j)] = curr;
+ curr++;
+ }
+ }
+
+ *iLastItem = curr;
+
+ ABC_FREE( temp );
+
+ /*printf("\n");
+ for(j = 0; j < *iLastItem; j++)
+ {
+ printf("iMatch %d: ", j);
+ for(i = 0; i < Vec_IntSize(iMatch[j]); i++)
+ printf("%d ", Vec_IntEntry(iMatch[j], i));
+ printf("\n");
+ }
+
+ for(i = 0; i < Abc_NtkPiNum(pNtk); i++)
+ printf("%d: %d ", i, iGroup[i]);
+ printf("\n");*/
+}
+
+void iSortDependencies(Abc_Ntk_t *pNtk, Vec_Int_t** iDep, int* oGroup)
+{
+ int i, j, k;
+ Vec_Int_t * temp;
+ Vec_Int_t * oGroupList;
+
+ oGroupList = Vec_IntAlloc( 10 );
+
+ for(i = 0; i < Abc_NtkPiNum(pNtk); i++)
+ {
+ if(Vec_IntSize(iDep[i]) == 1)
+ continue;
+
+ temp = Vec_IntAlloc( Vec_IntSize(iDep[i]) );
+
+ for(j = 0; j < Vec_IntSize(iDep[i]); j++)
+ Vec_IntPushUniqueOrder(oGroupList, oGroup[Vec_IntEntry(iDep[i], j)]);
+
+ for(j = 0; j < Vec_IntSize(oGroupList); j++)
+ {
+ for(k = 0; k < Vec_IntSize(iDep[i]); k++)
+ if(oGroup[Vec_IntEntry(iDep[i], k)] == Vec_IntEntry(oGroupList, j))
+ {
+ Vec_IntPush( temp, Vec_IntEntry(iDep[i], k) );
+ Vec_IntRemove( iDep[i], Vec_IntEntry(iDep[i], k) );
+ k--;
+ }
+ }
+
+ Vec_IntFree( iDep[i] );
+ iDep[i] = temp;
+ Vec_IntClear( oGroupList );
+
+ /*printf("Input %d: ", i);
+ for(j = 0; j < Vec_IntSize(iDep[i]); j++)
+ printf("%d ", Vec_IntEntry(iDep[i], j));
+ printf("\n");*/
+ }
+
+ Vec_IntFree( oGroupList );
+}
+
+void oSortDependencies(Abc_Ntk_t *pNtk, Vec_Int_t** oDep, int* iGroup)
+{
+ int i, j, k;
+ Vec_Int_t * temp;
+ Vec_Int_t * iGroupList;
+
+ iGroupList = Vec_IntAlloc( 10 );
+
+ for(i = 0; i < Abc_NtkPoNum(pNtk); i++)
+ {
+ if(Vec_IntSize(oDep[i]) == 1)
+ continue;
+
+ temp = Vec_IntAlloc( Vec_IntSize(oDep[i]) );
+
+ for(j = 0; j < Vec_IntSize(oDep[i]); j++)
+ Vec_IntPushUniqueOrder(iGroupList, iGroup[Vec_IntEntry(oDep[i], j)]);
+
+ for(j = 0; j < Vec_IntSize(iGroupList); j++)
+ {
+ for(k = 0; k < Vec_IntSize(oDep[i]); k++)
+ if(iGroup[Vec_IntEntry(oDep[i], k)] == Vec_IntEntry(iGroupList, j))
+ {
+ Vec_IntPush( temp, Vec_IntEntry(oDep[i], k) );
+ Vec_IntRemove( oDep[i], Vec_IntEntry(oDep[i], k) );
+ k--;
+ }
+ }
+
+ Vec_IntFree( oDep[i] );
+ oDep[i] = temp;
+ Vec_IntClear( iGroupList );
+
+ /*printf("Output %d: ", i);
+ for(j = 0; j < Vec_IntSize(oDep[i]); j++)
+ printf("%d ", Vec_IntEntry(oDep[i], j));
+ printf("\n");*/
+ }
+
+ Vec_IntFree( iGroupList );
+}
+
+int oSplitByDep(Abc_Ntk_t *pNtk, Vec_Int_t** oDep, Vec_Int_t** oMatch, int* oGroup, int* oLastItem, int* iGroup)
+{
+ int i, j, k;
+ int numOfItemsAdded;
+ Vec_Int_t * array, * sortedArray;
+
+ numOfItemsAdded = 0;
+
+ for(i = 0; i < *oLastItem; i++)
+ {
+ if(Vec_IntSize(oMatch[i]) == 1)
+ continue;
+
+ array = Vec_IntAlloc( Vec_IntSize(oMatch[i]) );
+ sortedArray = Vec_IntAlloc( Vec_IntSize(oMatch[i]) );
+
+ for(j = 0; j < Vec_IntSize(oMatch[i]); j++)
+ {
+ int factor, encode;
+
+ encode = 0;
+ factor = 1;
+
+ for(k = 0; k < Vec_IntSize(oDep[Vec_IntEntry(oMatch[i], j)]); k++)
+ encode += iGroup[Vec_IntEntry(oDep[Vec_IntEntry(oMatch[i], j)], k)] * factor;
+
+ Vec_IntPush(array, encode);
+ Vec_IntPushUniqueOrder(sortedArray, encode);
+
+ if( encode < 0)
+ printf("WARNING! Integer overflow!");
+
+ //printf("%d ", Vec_IntEntry(array, j));
+ }
+
+ while( Vec_IntSize(sortedArray) > 1 )
+ {
+ for(k = 0; k < Vec_IntSize(oMatch[i]); k++)
+ {
+ if(Vec_IntEntry(array, k) == Vec_IntEntryLast(sortedArray))
+ {
+ Vec_IntPush(oMatch[*oLastItem+numOfItemsAdded], Vec_IntEntry(oMatch[i], k));
+ oGroup[Vec_IntEntry(oMatch[i], k)] = *oLastItem+numOfItemsAdded;
+ Vec_IntRemove( oMatch[i], Vec_IntEntry(oMatch[i], k) );
+ Vec_IntRemove( array, Vec_IntEntry(array, k) );
+ k--;
+ }
+ }
+ numOfItemsAdded++;
+ Vec_IntPop(sortedArray);
+ }
+
+ Vec_IntFree( array );
+ Vec_IntFree( sortedArray );
+ //printf("\n");
+ }
+
+ *oLastItem += numOfItemsAdded;
+
+ /*printf("\n");
+ for(j = 0; j < *oLastItem ; j++)
+ {
+ printf("oMatch %d: ", j);
+ for(i = 0; i < Vec_IntSize(oMatch[j]); i++)
+ printf("%d ", Vec_IntEntry(oMatch[j], i));
+ printf("\n");
+ }*/
+
+ return numOfItemsAdded;
+}
+
+int iSplitByDep(Abc_Ntk_t *pNtk, Vec_Int_t** iDep, Vec_Int_t** iMatch, int* iGroup, int* iLastItem, int* oGroup)
+{
+ int i, j, k;
+ int numOfItemsAdded = 0;
+ Vec_Int_t * array, * sortedArray;
+
+ for(i = 0; i < *iLastItem; i++)
+ {
+ if(Vec_IntSize(iMatch[i]) == 1)
+ continue;
+
+ array = Vec_IntAlloc( Vec_IntSize(iMatch[i]) );
+ sortedArray = Vec_IntAlloc( Vec_IntSize(iMatch[i]) );
+
+ for(j = 0; j < Vec_IntSize(iMatch[i]); j++)
+ {
+ int factor, encode;
+
+ encode = 0;
+ factor = 1;
+
+ for(k = 0; k < Vec_IntSize(iDep[Vec_IntEntry(iMatch[i], j)]); k++)
+ encode += oGroup[Vec_IntEntry(iDep[Vec_IntEntry(iMatch[i], j)], k)] * factor;
+
+ Vec_IntPush(array, encode);
+ Vec_IntPushUniqueOrder(sortedArray, encode);
+
+ //printf("%d ", Vec_IntEntry(array, j));
+ }
+
+ while( Vec_IntSize(sortedArray) > 1 )
+ {
+ for(k = 0; k < Vec_IntSize(iMatch[i]); k++)
+ {
+ if(Vec_IntEntry(array, k) == Vec_IntEntryLast(sortedArray))
+ {
+ Vec_IntPush(iMatch[*iLastItem+numOfItemsAdded], Vec_IntEntry(iMatch[i], k));
+ iGroup[Vec_IntEntry(iMatch[i], k)] = *iLastItem+numOfItemsAdded;
+ Vec_IntRemove( iMatch[i], Vec_IntEntry(iMatch[i], k) );
+ Vec_IntRemove( array, Vec_IntEntry(array, k) );
+ k--;
+ }
+ }
+ numOfItemsAdded++;
+ Vec_IntPop(sortedArray);
+ }
+
+ Vec_IntFree( array );
+ Vec_IntFree( sortedArray );
+ //printf("\n");
+ }
+
+ *iLastItem += numOfItemsAdded;
+
+ /*printf("\n");
+ for(j = 0; j < *iLastItem ; j++)
+ {
+ printf("iMatch %d: ", j);
+ for(i = 0; i < Vec_IntSize(iMatch[j]); i++)
+ printf("%d ", Vec_IntEntry(iMatch[j], i));
+ printf("\n");
+ }*/
+
+ return numOfItemsAdded;
+}
+
+Vec_Ptr_t ** findTopologicalOrder( Abc_Ntk_t * pNtk )
+{
+ Vec_Ptr_t ** vNodes;
+ Abc_Obj_t * pObj, * pFanout;
+ int i, k;
+
+ extern void Abc_NtkDfsReverse_rec( Abc_Obj_t * pNode, Vec_Ptr_t * vNodes );
+
+ // start the array of nodes
+ vNodes = ABC_ALLOC(Vec_Ptr_t *, Abc_NtkPiNum(pNtk));
+ for(i = 0; i < Abc_NtkPiNum(pNtk); i++)
+ vNodes[i] = Vec_PtrAlloc(50);
+
+ Abc_NtkForEachCi( pNtk, pObj, i )
+ {
+ // set the traversal ID
+ Abc_NtkIncrementTravId( pNtk );
+ Abc_NodeSetTravIdCurrent( pObj );
+ pObj = Abc_ObjFanout0Ntk(pObj);
+ Abc_ObjForEachFanout( pObj, pFanout, k )
+ Abc_NtkDfsReverse_rec( pFanout, vNodes[i] );
+ }
+
+ return vNodes;
+}
+
+
+int * Abc_NtkSimulateOneNode( Abc_Ntk_t * pNtk, int * pModel, int input, Vec_Ptr_t ** topOrder )
+{
+ Abc_Obj_t * pNode;
+ Vec_Ptr_t * vNodes;
+ int * pValues, Value0, Value1, i;
+
+ vNodes = Vec_PtrAlloc( 50 );
+/*
+ printf( "Counter example: " );
+ Abc_NtkForEachCi( pNtk, pNode, i )
+ printf( " %d", pModel[i] );
+ printf( "\n" );
+*/
+ // increment the trav ID
+ Abc_NtkIncrementTravId( pNtk );
+ // set the CI values
+ Abc_AigConst1(pNtk)->pCopy = (Abc_Obj_t *)1;
+ pNode = Abc_NtkCi(pNtk, input);
+ pNode->pCopy = (Abc_Obj_t *)pModel[input];
+
+ // simulate in the topological order
+ for(i = Vec_PtrSize(topOrder[input])-1; i >= 0; i--)
+ {
+ pNode = (Abc_Obj_t *)Vec_PtrEntry(topOrder[input], i);
+
+ Value0 = ((int)(ABC_PTRUINT_T)Abc_ObjFanin0(pNode)->pCopy) ^ Abc_ObjFaninC0(pNode);
+ Value1 = ((int)(ABC_PTRUINT_T)Abc_ObjFanin1(pNode)->pCopy) ^ Abc_ObjFaninC1(pNode);
+
+ if( pNode->pCopy != (Abc_Obj_t *)(Value0 & Value1))
+ {
+ pNode->pCopy = (Abc_Obj_t *)(Value0 & Value1);
+ Vec_PtrPush(vNodes, pNode);
+ }
+
+ }
+ // fill the output values
+ pValues = ABC_ALLOC( int, Abc_NtkCoNum(pNtk) );
+ Abc_NtkForEachCo( pNtk, pNode, i )
+ pValues[i] = ((int)(ABC_PTRUINT_T)Abc_ObjFanin0(pNode)->pCopy) ^ Abc_ObjFaninC0(pNode);
+
+ pNode = Abc_NtkCi(pNtk, input);
+ if(pNode->pCopy == (Abc_Obj_t *)1)
+ pNode->pCopy = (Abc_Obj_t *)0;
+ else
+ pNode->pCopy = (Abc_Obj_t *)1;
+
+ for(i = 0; i < Vec_PtrSize(vNodes); i++)
+ {
+ pNode = (Abc_Obj_t *)Vec_PtrEntry(vNodes, i);
+
+ if(pNode->pCopy == (Abc_Obj_t *)1)
+ pNode->pCopy = (Abc_Obj_t *)0;
+ else
+ pNode->pCopy = (Abc_Obj_t *)1;
+ }
+
+ Vec_PtrFree( vNodes );
+
+ return pValues;
+}
+
+int refineIOBySimulation(Abc_Ntk_t *pNtk, Vec_Int_t** iMatch, int* iLastItem, int * iGroup, Vec_Int_t** iDep, Vec_Int_t** oMatch, int* oLastItem, int * oGroup, Vec_Int_t** oDep, char * vPiValues, int * observability, Vec_Ptr_t ** topOrder)
+{
+ Abc_Obj_t * pObj;
+ int * pModel;//, ** pModel2;
+ int * output, * output2;
+ int lastItem;
+ int i, j, k;
+ Vec_Int_t * iComputedNum, * iComputedNumSorted;
+ Vec_Int_t * oComputedNum; // encoding the number of flips
+ int factor;
+ int isRefined = FALSE;
+
+ pModel = ABC_ALLOC( int, Abc_NtkCiNum(pNtk) );
+
+ Abc_NtkForEachPi( pNtk, pObj, i )
+ pModel[i] = vPiValues[i] - '0';
+ Abc_NtkForEachLatch( pNtk, pObj, i )
+ pModel[Abc_NtkPiNum(pNtk)+i] = pObj->iData - 1;
+
+ output = Abc_NtkVerifySimulatePattern( pNtk, pModel );
+
+ oComputedNum = Vec_IntAlloc( Abc_NtkPoNum(pNtk) );
+ for(i = 0; i < Abc_NtkPoNum(pNtk); i++)
+ Vec_IntPush(oComputedNum, 0);
+
+ /****************************************************************************************/
+ /********** group outputs that produce 1 and outputs that produce 0 together ************/
+
+ lastItem = *oLastItem;
+ for(i = 0; i < lastItem && (*oLastItem) != Abc_NtkPoNum(pNtk); i++)
+ {
+ int flag = FALSE;
+
+ if(Vec_IntSize(oMatch[i]) == 1)
+ continue;
+
+ for(j = 1; j < Vec_IntSize(oMatch[i]); j++)
+ if(output[Vec_IntEntry(oMatch[i], 0)] != output[Vec_IntEntry(oMatch[i], j)])
+ {
+ flag = TRUE;
+ break;
+ }
+
+ if(flag)
+ {
+ for(j = 0; j < Vec_IntSize(oMatch[i]); j++)
+ if(output[Vec_IntEntry(oMatch[i], j)])
+ {
+ Vec_IntPush(oMatch[*oLastItem], Vec_IntEntry(oMatch[i], j));
+ oGroup[Vec_IntEntry(oMatch[i], j)] = *oLastItem;
+ Vec_IntRemove(oMatch[i], Vec_IntEntry(oMatch[i], j));
+ j--;
+ }
+
+ (*oLastItem)++;
+ }
+ }
+
+ if( (*oLastItem) > lastItem )
+ {
+ isRefined = TRUE;
+ iSortDependencies(pNtk, iDep, oGroup);
+ }
+
+ /****************************************************************************************/
+ /************* group inputs that make the same number of flips in outpus ****************/
+
+ lastItem = *iLastItem;
+ for(i = 0; i < lastItem && (*iLastItem) != Abc_NtkPiNum(pNtk); i++)
+ {
+ int num;
+
+ if(Vec_IntSize(iMatch[i]) == 1)
+ continue;
+
+ iComputedNum = Vec_IntAlloc( Vec_IntSize(iMatch[i]) );
+ iComputedNumSorted = Vec_IntAlloc( Vec_IntSize(iMatch[i]) );
+
+ for(j = 0; j < Vec_IntSize(iMatch[i]); j++)
+ {
+ if( vPiValues[Vec_IntEntry(iMatch[i], j)] == '0' )
+ pModel[Vec_IntEntry(iMatch[i], j)] = 1;
+ else
+ pModel[Vec_IntEntry(iMatch[i], j)] = 0;
+
+ //output2 = Abc_NtkVerifySimulatePattern( pNtk, pModel );
+ output2 = Abc_NtkSimulateOneNode( pNtk, pModel, Vec_IntEntry(iMatch[i], j), topOrder );
+
+ num = 0;
+ factor = 1;
+ for(k = 0; k < Vec_IntSize(iDep[Vec_IntEntry(iMatch[i], j)]); k++)
+ {
+ int outputIndex = Vec_IntEntry(iDep[Vec_IntEntry(iMatch[i], j)], k);
+
+ if(output2[outputIndex])
+ num += (oGroup[outputIndex] + 1) * factor;
+
+ if(output[outputIndex] != output2[outputIndex])
+ {
+ int temp = Vec_IntEntry(oComputedNum, outputIndex) + i + 1;
+ Vec_IntWriteEntry(oComputedNum, outputIndex, temp);
+ observability[Vec_IntEntry(iMatch[i], j)]++;
+ }
+ }
+
+ Vec_IntPush(iComputedNum, num);
+ Vec_IntPushUniqueOrder(iComputedNumSorted, num);
+
+ pModel[Vec_IntEntry(iMatch[i], j)] = vPiValues[Vec_IntEntry(iMatch[i], j)] - '0';
+ ABC_FREE( output2 );
+ }
+
+ while( Vec_IntSize( iComputedNumSorted ) > 1 )
+ {
+ for(k = 0; k < Vec_IntSize(iMatch[i]); k++)
+ {
+ if(Vec_IntEntry(iComputedNum, k) == Vec_IntEntryLast(iComputedNumSorted) )
+ {
+ Vec_IntPush(iMatch[*iLastItem], Vec_IntEntry(iMatch[i], k));
+ iGroup[Vec_IntEntry(iMatch[i], k)] = *iLastItem;
+ Vec_IntRemove( iMatch[i], Vec_IntEntry(iMatch[i], k) );
+ Vec_IntRemove( iComputedNum, Vec_IntEntry(iComputedNum, k) );
+ k--;
+ }
+ }
+ (*iLastItem)++;
+ Vec_IntPop( iComputedNumSorted );
+ }
+
+ Vec_IntFree( iComputedNum );
+ Vec_IntFree( iComputedNumSorted );
+ }
+
+ if( (*iLastItem) > lastItem )
+ {
+ isRefined = TRUE;
+ oSortDependencies(pNtk, oDep, iGroup);
+ }
+
+ /****************************************************************************************/
+ /********** encode the number of flips in each output by flipping the outputs ***********/
+ /********** and group all the outputs that have the same encoding ***********/
+
+ lastItem = *oLastItem;
+ for(i = 0; i < lastItem && (*oLastItem) != Abc_NtkPoNum(pNtk); i++)
+ {
+ Vec_Int_t * encode, * sortedEncode; // encoding the number of flips
+
+ if(Vec_IntSize(oMatch[i]) == 1)
+ continue;
+
+ encode = Vec_IntAlloc( Vec_IntSize(oMatch[i]) );
+ sortedEncode = Vec_IntAlloc( Vec_IntSize(oMatch[i]) );
+
+ for(j = 0; j < Vec_IntSize(oMatch[i]); j++)
+ {
+ Vec_IntPush(encode, Vec_IntEntry(oComputedNum, Vec_IntEntry(oMatch[i], j)) );
+ Vec_IntPushUniqueOrder( sortedEncode, Vec_IntEntry(encode, j) );
+ }
+
+ while( Vec_IntSize(sortedEncode) > 1 )
+ {
+ for(j = 0; j < Vec_IntSize(oMatch[i]); j++)
+ if(Vec_IntEntry(encode, j) == Vec_IntEntryLast(sortedEncode))
+ {
+ Vec_IntPush(oMatch[*oLastItem], Vec_IntEntry(oMatch[i], j));
+ oGroup[Vec_IntEntry(oMatch[i], j)] = *oLastItem;
+ Vec_IntRemove( oMatch[i], Vec_IntEntry(oMatch[i], j) );
+ Vec_IntRemove( encode, Vec_IntEntry(encode, j) );
+ j --;
+ }
+
+ (*oLastItem)++;
+ Vec_IntPop( sortedEncode );
+ }
+
+ Vec_IntFree( encode );
+ Vec_IntFree( sortedEncode );
+ }
+
+ if( (*oLastItem) > lastItem )
+ isRefined = TRUE;
+
+ ABC_FREE( pModel );
+ ABC_FREE( output );
+ Vec_IntFree( oComputedNum );
+
+ return isRefined;
+}
+
+Abc_Ntk_t * Abc_NtkMiterBm( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, Vec_Ptr_t * iCurrMatch, Vec_Ptr_t * oCurrMatch )
+{
+ char Buffer[1000];
+ Abc_Ntk_t * pNtkMiter;
+
+ pNtkMiter = Abc_NtkAlloc( ABC_NTK_STRASH, ABC_FUNC_AIG, 1 );
+ sprintf( Buffer, "%s_%s_miter", pNtk1->pName, pNtk2->pName );
+ pNtkMiter->pName = Extra_UtilStrsav(Buffer);
+
+ //Abc_NtkMiterPrepare( pNtk1, pNtk2, pNtkMiter, fComb, nPartSize );
+ {
+ Abc_Obj_t * pObj, * pObjNew;
+ int i;
+
+ Abc_AigConst1(pNtk1)->pCopy = Abc_AigConst1(pNtkMiter);
+ Abc_AigConst1(pNtk2)->pCopy = Abc_AigConst1(pNtkMiter);
+
+ // create new PIs and remember them in the old PIs
+ if(iCurrMatch == NULL)
+ {
+ Abc_NtkForEachCi( pNtk1, pObj, i )
+ {
+ pObjNew = Abc_NtkCreatePi( pNtkMiter );
+ // remember this PI in the old PIs
+ pObj->pCopy = pObjNew;
+ pObj = Abc_NtkCi(pNtk2, i);
+ pObj->pCopy = pObjNew;
+ // add name
+ Abc_ObjAssignName( pObjNew, Abc_ObjName(pObj), NULL );
+ }
+ }
+ else
+ {
+ for(i = 0; i < Vec_PtrSize( iCurrMatch ); i += 2)
+ {
+ pObjNew = Abc_NtkCreatePi( pNtkMiter );
+ pObj = (Abc_Obj_t *)Vec_PtrEntry(iCurrMatch, i);
+ pObj->pCopy = pObjNew;
+ pObj = (Abc_Obj_t *)Vec_PtrEntry(iCurrMatch, i+1);
+ pObj->pCopy = pObjNew;
+ // add name
+ Abc_ObjAssignName( pObjNew, Abc_ObjName(pObj), NULL );
+ }
+ }
+
+ // create the only PO
+ pObjNew = Abc_NtkCreatePo( pNtkMiter );
+ // add the PO name
+ Abc_ObjAssignName( pObjNew, "miter", NULL );
+ }
+
+ // Abc_NtkMiterAddOne( pNtk1, pNtkMiter );
+ {
+ Abc_Obj_t * pNode;
+ int i;
+ assert( Abc_NtkIsDfsOrdered(pNtk1) );
+ Abc_AigForEachAnd( pNtk1, pNode, i )
+ pNode->pCopy = Abc_AigAnd( (Abc_Aig_t *)pNtkMiter->pManFunc, Abc_ObjChild0Copy(pNode), Abc_ObjChild1Copy(pNode) );
+ }
+
+ // Abc_NtkMiterAddOne( pNtk2, pNtkMiter );
+ {
+ Abc_Obj_t * pNode;
+ int i;
+ assert( Abc_NtkIsDfsOrdered(pNtk2) );
+ Abc_AigForEachAnd( pNtk2, pNode, i )
+ pNode->pCopy = Abc_AigAnd( (Abc_Aig_t *)pNtkMiter->pManFunc, Abc_ObjChild0Copy(pNode), Abc_ObjChild1Copy(pNode) );
+ }
+
+ // Abc_NtkMiterFinalize( pNtk1, pNtk2, pNtkMiter, fComb, nPartSize );
+ {
+ Vec_Ptr_t * vPairs;
+ Abc_Obj_t * pMiter;
+ int i;
+
+ vPairs = Vec_PtrAlloc( 100 );
+
+ // collect the CO nodes for the miter
+ if(oCurrMatch != NULL)
+ {
+ for(i = 0; i < Vec_PtrSize( oCurrMatch ); i += 2)
+ {
+ Vec_PtrPush( vPairs, Abc_ObjChild0Copy((Abc_Obj_t *)Vec_PtrEntry(oCurrMatch, i)) );
+ Vec_PtrPush( vPairs, Abc_ObjChild0Copy((Abc_Obj_t *)Vec_PtrEntry(oCurrMatch, i+1)) );
+ }
+ }
+ else
+ {
+ Abc_Obj_t * pNode;
+
+ Abc_NtkForEachCo( pNtk1, pNode, i )
+ {
+ Vec_PtrPush( vPairs, Abc_ObjChild0Copy(pNode) );
+ pNode = Abc_NtkCo( pNtk2, i );
+ Vec_PtrPush( vPairs, Abc_ObjChild0Copy(pNode) );
+ }
+ }
+
+ pMiter = Abc_AigMiter( (Abc_Aig_t *)pNtkMiter->pManFunc, vPairs, 0 );
+ Abc_ObjAddFanin( Abc_NtkPo(pNtkMiter,0), pMiter );
+ Vec_PtrFree(vPairs);
+ }
+
+ //Abc_AigCleanup(pNtkMiter->pManFunc);
+
+ return pNtkMiter;
+}
+
+int * pValues1__, * pValues2__;
+
+void Abc_NtkVerifyReportError( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int * pModel, Vec_Int_t * mismatch )
+{
+ Vec_Ptr_t * vNodes;
+ Abc_Obj_t * pNode;
+ int nErrors, nPrinted, i, iNode = -1;
+
+ assert( Abc_NtkCiNum(pNtk1) == Abc_NtkCiNum(pNtk2) );
+ assert( Abc_NtkCoNum(pNtk1) == Abc_NtkCoNum(pNtk2) );
+ // get the CO values under this model
+ pValues1__ = Abc_NtkVerifySimulatePattern( pNtk1, pModel );
+ pValues2__ = Abc_NtkVerifySimulatePattern( pNtk2, pModel );
+ // count the mismatches
+ nErrors = 0;
+ for ( i = 0; i < Abc_NtkCoNum(pNtk1); i++ )
+ nErrors += (int)( pValues1__[i] != pValues2__[i] );
+ //printf( "Verification failed for at least %d outputs: ", nErrors );
+ // print the first 3 outputs
+ nPrinted = 0;
+ for ( i = 0; i < Abc_NtkCoNum(pNtk1); i++ )
+ if ( pValues1__[i] != pValues2__[i] )
+ {
+ if ( iNode == -1 )
+ iNode = i;
+ //printf( " %s", Abc_ObjName(Abc_NtkCo(pNtk1,i)) );
+ if ( ++nPrinted == 3 )
+ break;
+ }
+ /*if ( nPrinted != nErrors )
+ printf( " ..." );
+ printf( "\n" );*/
+ // report mismatch for the first output
+ if ( iNode >= 0 )
+ {
+ /*printf( "Output %s: Value in Network1 = %d. Value in Network2 = %d.\n",
+ Abc_ObjName(Abc_NtkCo(pNtk1,iNode)), pValues1[iNode], pValues2[iNode] );
+ printf( "Input pattern: " );*/
+ // collect PIs in the cone
+ pNode = Abc_NtkCo(pNtk1,iNode);
+ vNodes = Abc_NtkNodeSupport( pNtk1, &pNode, 1 );
+ // set the PI numbers
+ Abc_NtkForEachCi( pNtk1, pNode, i )
+ pNode->pCopy = (Abc_Obj_t *)i;
+ // print the model
+ pNode = (Abc_Obj_t *)Vec_PtrEntry( vNodes, 0 );
+ if ( Abc_ObjIsCi(pNode) )
+ {
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
+ {
+ assert( Abc_ObjIsCi(pNode) );
+ //printf( " %s=%d", Abc_ObjName(pNode), pModel[(int)pNode->pCopy] );
+ Vec_IntPush(mismatch, Abc_ObjId(pNode)-1);
+ Vec_IntPush(mismatch, pModel[(int)(size_t)pNode->pCopy]);
+ }
+ }
+ //printf( "\n" );
+ Vec_PtrFree( vNodes );
+ }
+ free( pValues1__ );
+ free( pValues2__ );
+}
+
+int Abc_NtkMiterSatBm( Abc_Ntk_t * pNtk, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, int fVerbose, ABC_INT64_T * pNumConfs, ABC_INT64_T * pNumInspects)
+{
+ static sat_solver * pSat = NULL;
+ lbool status;
+ int RetValue, clk;
+
+ extern int Abc_NodeAddClausesTop( sat_solver * pSat, Abc_Obj_t * pNode, Vec_Int_t * vVars );
+ extern Vec_Int_t * Abc_NtkGetCiSatVarNums( Abc_Ntk_t * pNtk );
+
+ if ( pNumConfs )
+ *pNumConfs = 0;
+ if ( pNumInspects )
+ *pNumInspects = 0;
+
+ assert( Abc_NtkLatchNum(pNtk) == 0 );
+
+// if ( Abc_NtkPoNum(pNtk) > 1 )
+// fprintf( stdout, "Warning: The miter has %d outputs. SAT will try to prove all of them.\n", Abc_NtkPoNum(pNtk) );
+
+ // load clauses into the sat_solver
+ clk = clock();
+
+
+
+ pSat = (sat_solver *)Abc_NtkMiterSatCreate( pNtk, 0 );
+
+ if ( pSat == NULL )
+ return 1;
+//printf( "%d \n", pSat->clauses.size );
+//sat_solver_delete( pSat );
+//return 1;
+
+// printf( "Created SAT problem with %d variable and %d clauses. ", sat_solver_nvars(pSat), sat_solver_nclauses(pSat) );
+// PRT( "Time", clock() - clk );
+
+ // simplify the problem
+ clk = clock();
+ status = sat_solver_simplify(pSat);
+// printf( "Simplified the problem to %d variables and %d clauses. ", sat_solver_nvars(pSat), sat_solver_nclauses(pSat) );
+// PRT( "Time", clock() - clk );
+ if ( status == 0 )
+ {
+ sat_solver_delete( pSat );
+// printf( "The problem is UNSATISFIABLE after simplification.\n" );
+ return 1;
+ }
+
+ // solve the miter
+ clk = clock();
+ if ( fVerbose )
+ pSat->verbosity = 1;
+ status = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)nConfLimit, (ABC_INT64_T)nInsLimit, (ABC_INT64_T)0, (ABC_INT64_T)0 );
+ if ( status == l_Undef )
+ {
+// printf( "The problem timed out.\n" );
+ RetValue = -1;
+ }
+ else if ( status == l_True )
+ {
+// printf( "The problem is SATISFIABLE.\n" );
+ RetValue = 0;
+ }
+ else if ( status == l_False )
+ {
+// printf( "The problem is UNSATISFIABLE.\n" );
+ RetValue = 1;
+ }
+ else
+ assert( 0 );
+// PRT( "SAT sat_solver time", clock() - clk );
+// printf( "The number of conflicts = %d.\n", (int)pSat->sat_solver_stats.conflicts );
+
+ // if the problem is SAT, get the counterexample
+ if ( status == l_True )
+ {
+// Vec_Int_t * vCiIds = Abc_NtkGetCiIds( pNtk );
+ Vec_Int_t * vCiIds = Abc_NtkGetCiSatVarNums( pNtk );
+ pNtk->pModel = Sat_SolverGetModel( pSat, vCiIds->pArray, vCiIds->nSize );
+ Vec_IntFree( vCiIds );
+ }
+ // free the sat_solver
+ if ( fVerbose )
+ Sat_SolverPrintStats( stdout, pSat );
+
+ if ( pNumConfs )
+ *pNumConfs = (int)pSat->stats.conflicts;
+ if ( pNumInspects )
+ *pNumInspects = (int)pSat->stats.inspects;
+
+//sat_solver_store_write( pSat, "trace.cnf" );
+ sat_solver_store_free( pSat );
+ sat_solver_delete( pSat );
+ return RetValue;
+}
+
+int Abc_NtkBmSat( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, Vec_Ptr_t * iMatchPairs, Vec_Ptr_t * oMatchPairs, Vec_Int_t * mismatch, int mode)
+{
+ extern Abc_Ntk_t * Abc_NtkMulti( Abc_Ntk_t * pNtk, int nThresh, int nFaninMax, int fCnf, int fMulti, int fSimple, int fFactor );
+
+ Abc_Ntk_t * pMiter = NULL;
+ Abc_Ntk_t * pCnf;
+ int RetValue;
+
+ // get the miter of the two networks
+ if( mode == 0 )
+ {
+ //Abc_NtkDelete( pMiter );
+ pMiter = Abc_NtkMiterBm( pNtk1, pNtk2, iMatchPairs, oMatchPairs );
+ }
+ else if( mode == 1 ) // add new outputs
+ {
+ int i;
+ Abc_Obj_t * pObj;
+ Vec_Ptr_t * vPairs;
+ Abc_Obj_t * pNtkMiter;
+
+ vPairs = Vec_PtrAlloc( 100 );
+
+ Abc_NtkForEachCo( pMiter, pObj, i )
+ Abc_ObjRemoveFanins( pObj );
+
+ for(i = 0; i < Vec_PtrSize( oMatchPairs ); i += 2)
+ {
+ Vec_PtrPush( vPairs, Abc_ObjChild0Copy((Abc_Obj_t *)Vec_PtrEntry(oMatchPairs, i)) );
+ Vec_PtrPush( vPairs, Abc_ObjChild0Copy((Abc_Obj_t *)Vec_PtrEntry(oMatchPairs, i+1)) );
+ }
+ pNtkMiter = Abc_AigMiter( (Abc_Aig_t *)pMiter->pManFunc, vPairs, 0 );
+ Abc_ObjAddFanin( Abc_NtkPo(pMiter,0), pNtkMiter );
+ Vec_PtrFree( vPairs);
+ }
+ else if( mode == 2 ) // add some outputs
+ {
+
+ }
+ else if( mode == 3) // remove all outputs
+ {
+ }
+
+ if ( pMiter == NULL )
+ {
+ printf("Miter computation has failed.");
+ return -1;
+ }
+ RetValue = Abc_NtkMiterIsConstant( pMiter );
+ if ( RetValue == 0)
+ {
+ /*printf("Networks are NOT EQUIVALENT after structural hashing."); */
+ // report the error
+ if(mismatch != NULL)
+ {
+ pMiter->pModel = Abc_NtkVerifyGetCleanModel( pMiter, 1 );
+ Abc_NtkVerifyReportError( pNtk1, pNtk2, pMiter->pModel, mismatch );
+ ABC_FREE( pMiter->pModel );
+ }
+ Abc_NtkDelete( pMiter );
+ return RetValue;
+ }
+ if( RetValue == 1 )
+ {
+ /*printf("Networks are equivalent after structural hashing."); */
+ Abc_NtkDelete( pMiter );
+ return RetValue;
+ }
+
+ // convert the miter into a CNF
+ //if(mode == 0)
+ pCnf = Abc_NtkMulti( pMiter, 0, 100, 1, 0, 0, 0 );
+ Abc_NtkDelete( pMiter );
+ if ( pCnf == NULL )
+ {
+ printf("Renoding for CNF has failed.");
+ return -1;
+ }
+
+ // solve the CNF using the SAT solver
+ RetValue = Abc_NtkMiterSat( pCnf, (ABC_INT64_T)10000, (ABC_INT64_T)0, 0, NULL, NULL);
+ /*if ( RetValue == -1 )
+ printf("Networks are undecided (SAT solver timed out).");
+ else if ( RetValue == 0 )
+ printf("Networks are NOT EQUIVALENT after SAT.");
+ else
+ printf("Networks are equivalent after SAT."); */
+ if ( mismatch != NULL && pCnf->pModel )
+ Abc_NtkVerifyReportError( pNtk1, pNtk2, pCnf->pModel, mismatch );
+
+ ABC_FREE( pCnf->pModel );
+ Abc_NtkDelete( pCnf );
+
+ return RetValue;
+}
+
+int checkEquivalence( Abc_Ntk_t * pNtk1, Vec_Int_t* matchedInputs1, Vec_Int_t * matchedOutputs1,
+ Abc_Ntk_t * pNtk2, Vec_Int_t* matchedInputs2, Vec_Int_t * matchedOutputs2)
+{
+ Vec_Ptr_t * iMatchPairs, * oMatchPairs;
+ int i;
+ int result;
+
+ iMatchPairs = Vec_PtrAlloc( Abc_NtkPiNum( pNtk1 ) * 2);
+ oMatchPairs = Vec_PtrAlloc( Abc_NtkPoNum( pNtk1 ) * 2);
+
+ for(i = 0; i < Abc_NtkPiNum(pNtk1); i++)
+ {
+ Vec_PtrPush(iMatchPairs, Abc_NtkPi(pNtk2, Vec_IntEntry(matchedInputs2, i)));
+ Vec_PtrPush(iMatchPairs, Abc_NtkPi(pNtk1, Vec_IntEntry(matchedInputs1, i)));
+ }
+
+
+ for(i = 0; i < Abc_NtkPoNum(pNtk1); i++)
+ {
+ Vec_PtrPush(oMatchPairs, Abc_NtkPo(pNtk2, Vec_IntEntry(matchedOutputs2, i)));
+ Vec_PtrPush(oMatchPairs, Abc_NtkPo(pNtk1, Vec_IntEntry(matchedOutputs1, i)));
+ }
+
+ result = Abc_NtkBmSat(pNtk1, pNtk2, iMatchPairs, oMatchPairs, NULL, 0);
+
+ if( result )
+ printf("*** Circuits are equivalent ***\n");
+ else
+ printf("*** Circuits are NOT equivalent ***\n");
+
+ Vec_PtrFree( iMatchPairs );
+ Vec_PtrFree( oMatchPairs );
+
+ return result;
+}
+
+Abc_Ntk_t * computeCofactor(Abc_Ntk_t * pNtk, Vec_Ptr_t ** nodesInLevel, int * bitVector, Vec_Int_t * currInputs)
+{
+ Abc_Ntk_t * subNtk;
+ Abc_Obj_t * pObj, * pObjNew;
+ int i, j, numOfLevels;
+
+ numOfLevels = Abc_AigLevel( pNtk ); // number of levels excludes PI/POs
+
+ // start a new network
+ subNtk = Abc_NtkAlloc( ABC_NTK_STRASH, ABC_FUNC_AIG, 1 );
+ subNtk->pName = Extra_UtilStrsav("subNtk");
+
+ Abc_AigConst1(pNtk)->pCopy = Abc_AigConst1(subNtk);
+
+ // clean the node copy fields and mark the nodes that need to be copied to the new network
+ Abc_NtkCleanCopy( pNtk );
+
+ if(bitVector != NULL)
+ {
+ for(i = 0; i < Abc_NtkPiNum(pNtk); i++)
+ if(bitVector[i])
+ {
+ pObj = Abc_NtkPi(pNtk, i);
+ pObj->pCopy = (Abc_Obj_t *)(1);
+ }
+ }
+
+ for(i = 0; i < Vec_IntSize(currInputs); i++)
+ {
+ pObj = Abc_NtkPi(pNtk, Vec_IntEntry(currInputs, i));
+ pObjNew = Abc_NtkDupObj( subNtk, pObj, 1 );
+ pObj->pCopy = pObjNew;
+ }
+
+
+ // i = 0 are the inputs and the inputs are not added to the 2d array ( nodesInLevel )
+ for( i = 0; i <= numOfLevels; i++ )
+ for( j = 0; j < Vec_PtrSize( nodesInLevel[i] ); j++)
+ {
+ pObj = (Abc_Obj_t *)Vec_PtrEntry( nodesInLevel[i], j );
+
+ if(Abc_ObjChild0Copy(pObj) == NULL && Abc_ObjChild1Copy(pObj) == NULL)
+ pObj->pCopy = NULL;
+ else if(Abc_ObjChild0Copy(pObj) == NULL && Abc_ObjChild1Copy(pObj) == (void*)(1))
+ pObj->pCopy = NULL;
+ else if(Abc_ObjChild0Copy(pObj) == NULL && (Abc_ObjChild1Copy(pObj) != (NULL) && Abc_ObjChild1Copy(pObj) != (void*)(1)) )
+ pObj->pCopy = NULL;
+ else if(Abc_ObjChild0Copy(pObj) == (void*)(1) && Abc_ObjChild1Copy(pObj) == NULL)
+ pObj->pCopy = NULL;
+ else if(Abc_ObjChild0Copy(pObj) == (void*)(1) && Abc_ObjChild1Copy(pObj) == (void*)(1))
+ pObj->pCopy = (Abc_Obj_t *)(1);
+ else if(Abc_ObjChild0Copy(pObj) == (void*)(1) && (Abc_ObjChild1Copy(pObj) != (NULL) && Abc_ObjChild1Copy(pObj) != (void*)(1)) )
+ pObj->pCopy = Abc_ObjChild1Copy(pObj);
+ else if( (Abc_ObjChild0Copy(pObj) != (NULL) && Abc_ObjChild0Copy(pObj) != (void*)(1)) && Abc_ObjChild1Copy(pObj) == NULL )
+ pObj->pCopy = NULL;
+ else if( (Abc_ObjChild0Copy(pObj) != (NULL) && Abc_ObjChild0Copy(pObj) != (void*)(1)) && Abc_ObjChild1Copy(pObj) == (void*)(1) )
+ pObj->pCopy = Abc_ObjChild0Copy(pObj);
+ else if( (Abc_ObjChild0Copy(pObj) != (NULL) && Abc_ObjChild0Copy(pObj) != (void*)(1)) &&
+ (Abc_ObjChild1Copy(pObj) != (NULL) && Abc_ObjChild1Copy(pObj) != (void*)(1)) )
+ pObj->pCopy = Abc_AigAnd( (Abc_Aig_t *)subNtk->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
+ }
+
+ for(i = 0; i < Abc_NtkPoNum(pNtk); i++)
+ {
+ pObj = Abc_NtkPo(pNtk, i);
+ pObjNew = Abc_NtkDupObj( subNtk, pObj, 1 );
+
+ if( Abc_ObjChild0Copy(pObj) == NULL)
+ {
+ Abc_ObjAddFanin( pObjNew, Abc_AigConst1(subNtk));
+ pObjNew->fCompl0 = 1;
+ }
+ else if( Abc_ObjChild0Copy(pObj) == (void*)(1) )
+ {
+ Abc_ObjAddFanin( pObjNew, Abc_AigConst1(subNtk));
+ pObjNew->fCompl0 = 0;
+ }
+ else
+ Abc_ObjAddFanin( pObjNew, Abc_ObjChild0Copy(pObj) );
+ }
+
+ return subNtk;
+}
+
+FILE *matchFile;
+
+int matchNonSingletonOutputs(Abc_Ntk_t * pNtk1, Vec_Ptr_t ** nodesInLevel1, Vec_Int_t ** iMatch1, Vec_Int_t ** iDep1, Vec_Int_t * matchedInputs1, int * iGroup1, Vec_Int_t ** oMatch1, int * oGroup1,
+ Abc_Ntk_t * pNtk2, Vec_Ptr_t ** nodesInLevel2, Vec_Int_t ** iMatch2, Vec_Int_t ** iDep2, Vec_Int_t * matchedInputs2, int * iGroup2, Vec_Int_t ** oMatch2, int * oGroup2,
+ Vec_Int_t * matchedOutputs1, Vec_Int_t * matchedOutputs2, Vec_Int_t * oMatchedGroups, Vec_Int_t * iNonSingleton,
+ Abc_Ntk_t * subNtk1, Abc_Ntk_t * subNtk2, Vec_Ptr_t * oMatchPairs,
+ Vec_Int_t * oNonSingleton, int oI, int idx, int ii, int iidx)
+{
+ static int MATCH_FOUND;
+ int i;
+ int j, temp;
+ Vec_Int_t * mismatch;
+ int * skipList;
+ static int counter = 0;
+
+ MATCH_FOUND = FALSE;
+
+ if( oI == Vec_IntSize( oNonSingleton ) )
+ {
+ if( iNonSingleton != NULL)
+ if( match1by1(pNtk1, nodesInLevel1, iMatch1, iDep1, matchedInputs1, iGroup1, oMatch1, oGroup1,
+ pNtk2, nodesInLevel2, iMatch2, iDep2, matchedInputs2, iGroup2, oMatch2, oGroup2,
+ matchedOutputs1, matchedOutputs2, oMatchedGroups, iNonSingleton, ii, iidx) )
+ MATCH_FOUND = TRUE;
+
+ if( iNonSingleton == NULL)
+ MATCH_FOUND = TRUE;
+
+ return MATCH_FOUND;
+ }
+
+ i = Vec_IntEntry(oNonSingleton, oI);
+
+ mismatch = Vec_IntAlloc(10);
+
+ skipList = ABC_ALLOC(int, Vec_IntSize(oMatch1[i]));
+
+ for(j = 0; j < Vec_IntSize(oMatch1[i]); j++)
+ skipList[j] = FALSE;
+
+ Vec_PtrPush(oMatchPairs, Abc_NtkPo(subNtk1, Vec_IntEntry(oMatch1[i], idx)) );
+ Vec_IntPush(matchedOutputs1, Vec_IntEntry(oMatch1[i], idx));
+
+ for(j = 0; j < Vec_IntSize( oMatch2[i] ) && MATCH_FOUND == FALSE; j++)
+ {
+ if( Vec_IntEntry(oMatch2[i], j) == -1 || skipList[j] == TRUE)
+ continue;
+
+ Vec_PtrPush(oMatchPairs, Abc_NtkPo(subNtk2, Vec_IntEntry(oMatch2[i], j)));
+ Vec_IntPush(matchedOutputs2, Vec_IntEntry(oMatch2[i], j));
+
+ counter++;
+ if( Abc_NtkBmSat( subNtk1, subNtk2, NULL, oMatchPairs, mismatch, 0) )
+ {
+ /*fprintf(matchFile, "%s matched to %s\n", Abc_ObjName(Abc_NtkPo(pNtk1, Vec_IntEntry(oMatch1[i], idx))),
+ Abc_ObjName(Abc_NtkPo(pNtk2, Vec_IntEntry(oMatch2[i], j)))); */
+
+ temp = Vec_IntEntry(oMatch2[i], j);
+ Vec_IntWriteEntry(oMatch2[i], j, -1);
+
+ if(idx != Vec_IntSize( oMatch1[i] ) - 1)
+ // call the same function with idx+1
+ matchNonSingletonOutputs(pNtk1, nodesInLevel1, iMatch1, iDep1, matchedInputs1, iGroup1, oMatch1, oGroup1,
+ pNtk2, nodesInLevel2, iMatch2, iDep2, matchedInputs2, iGroup2, oMatch2, oGroup2,
+ matchedOutputs1, matchedOutputs2, oMatchedGroups, iNonSingleton,
+ subNtk1, subNtk2, oMatchPairs,
+ oNonSingleton, oI, idx+1, ii, iidx);
+ else
+ // call the same function with idx = 0 and oI++
+ matchNonSingletonOutputs(pNtk1, nodesInLevel1, iMatch1, iDep1, matchedInputs1, iGroup1, oMatch1, oGroup1,
+ pNtk2, nodesInLevel2, iMatch2, iDep2, matchedInputs2, iGroup2, oMatch2, oGroup2,
+ matchedOutputs1, matchedOutputs2, oMatchedGroups, iNonSingleton,
+ subNtk1, subNtk2, oMatchPairs,
+ oNonSingleton, oI+1, 0, ii, iidx);
+
+ Vec_IntWriteEntry(oMatch2[i], j, temp);
+ }
+ else
+ {
+ int * output1, * output2;
+ int k;
+ Abc_Obj_t * pObj;
+ int * pModel;
+ char * vPiValues;
+
+
+ vPiValues = ABC_ALLOC( char, Abc_NtkPiNum(subNtk1) + 1);
+ vPiValues[Abc_NtkPiNum(subNtk1)] = '\0';
+
+ for(k = 0; k < Abc_NtkPiNum(subNtk1); k++)
+ vPiValues[k] = '0';
+
+ for(k = 0; k < Vec_IntSize(mismatch); k += 2)
+ vPiValues[Vec_IntEntry(mismatch, k)] = Vec_IntEntry(mismatch, k+1);
+
+ pModel = ABC_ALLOC( int, Abc_NtkCiNum(subNtk1) );
+
+ Abc_NtkForEachPi( subNtk1, pObj, k )
+ pModel[k] = vPiValues[k] - '0';
+ Abc_NtkForEachLatch( subNtk1, pObj, k )
+ pModel[Abc_NtkPiNum(subNtk1)+k] = pObj->iData - 1;
+
+ output1 = Abc_NtkVerifySimulatePattern( subNtk1, pModel );
+
+ Abc_NtkForEachLatch( subNtk2, pObj, k )
+ pModel[Abc_NtkPiNum(subNtk2)+k] = pObj->iData - 1;
+
+ output2 = Abc_NtkVerifySimulatePattern( subNtk2, pModel );
+
+
+ for(k = 0; k < Vec_IntSize( oMatch1[i] ); k++)
+ if(output1[Vec_IntEntry(oMatch1[i], idx)] != output2[Vec_IntEntry(oMatch2[i], k)])
+ {
+ skipList[k] = TRUE;
+ /*printf("Output is SKIPPED");*/
+ }
+
+ ABC_FREE( vPiValues );
+ ABC_FREE( pModel );
+ ABC_FREE( output1 );
+ ABC_FREE( output2 );
+ }
+
+ if(MATCH_FOUND == FALSE )
+ {
+ Vec_PtrPop(oMatchPairs);
+ Vec_IntPop(matchedOutputs2);
+ }
+ }
+
+ if(MATCH_FOUND == FALSE )
+ {
+ Vec_PtrPop(oMatchPairs);
+ Vec_IntPop(matchedOutputs1);
+ }
+
+ if(MATCH_FOUND && counter != 0)
+ {
+ /*printf("Number of OUTPUT SAT instances = %d", counter);*/
+ counter = 0;
+ }
+
+ ABC_FREE( mismatch );
+ ABC_FREE( skipList );
+
+ return MATCH_FOUND;
+}
+
+int match1by1(Abc_Ntk_t * pNtk1, Vec_Ptr_t ** nodesInLevel1, Vec_Int_t ** iMatch1, Vec_Int_t ** iDep1, Vec_Int_t * matchedInputs1, int * iGroup1, Vec_Int_t ** oMatch1, int * oGroup1,
+ Abc_Ntk_t * pNtk2, Vec_Ptr_t ** nodesInLevel2, Vec_Int_t ** iMatch2, Vec_Int_t ** iDep2, Vec_Int_t * matchedInputs2, int * iGroup2, Vec_Int_t ** oMatch2, int * oGroup2,
+ Vec_Int_t * matchedOutputs1, Vec_Int_t * matchedOutputs2, Vec_Int_t * oMatchedGroups, Vec_Int_t * iNonSingleton, int ii, int idx)
+{
+ static int MATCH_FOUND = FALSE;
+ Abc_Ntk_t * subNtk1, * subNtk2;
+ Vec_Int_t * oNonSingleton;
+ Vec_Ptr_t * oMatchPairs;
+ int * skipList;
+ int j, m;
+ int i;
+ static int counter = 0;
+
+ MATCH_FOUND = FALSE;
+
+ if( ii == Vec_IntSize(iNonSingleton) )
+ {
+ MATCH_FOUND = TRUE;
+ return TRUE;
+ }
+
+ i = Vec_IntEntry(iNonSingleton, ii);
+
+ if( idx == Vec_IntSize(iMatch1[i]) )
+ {
+ // call again with the next element in iNonSingleton
+ return match1by1(pNtk1, nodesInLevel1, iMatch1, iDep1, matchedInputs1, iGroup1, oMatch1, oGroup1,
+ pNtk2, nodesInLevel2, iMatch2, iDep2, matchedInputs2, iGroup2, oMatch2, oGroup2,
+ matchedOutputs1, matchedOutputs2, oMatchedGroups, iNonSingleton, ii+1, 0);
+
+ }
+
+ oNonSingleton = Vec_IntAlloc(10);
+ oMatchPairs = Vec_PtrAlloc(100);
+ skipList = ABC_ALLOC(int, Vec_IntSize(iMatch1[i]));
+
+ for(j = 0; j < Vec_IntSize(iMatch1[i]); j++)
+ skipList[j] = FALSE;
+
+ Vec_IntPush(matchedInputs1, Vec_IntEntry(iMatch1[i], idx));
+ idx++;
+
+ if(idx == 1)
+ {
+ for(j = 0; j < Vec_IntSize(iDep1[Vec_IntEntryLast(iMatch1[i])]); j++)
+ {
+ if( Vec_IntSize(oMatch1[oGroup1[Vec_IntEntry(iDep1[Vec_IntEntryLast(iMatch1[i])], j)]]) == 1 )
+ continue;
+ if( Vec_IntFind( oMatchedGroups, oGroup1[Vec_IntEntry(iDep1[Vec_IntEntryLast(iMatch1[i])], j)]) != -1)
+ continue;
+
+ Vec_IntPushUnique(oNonSingleton, oGroup1[Vec_IntEntry(iDep1[Vec_IntEntryLast(iMatch1[i])], j)]);
+ Vec_IntPushUnique(oMatchedGroups, oGroup1[Vec_IntEntry(iDep1[Vec_IntEntryLast(iMatch1[i])], j)]);
+ }
+ }
+
+ subNtk1 = computeCofactor(pNtk1, nodesInLevel1, NULL, matchedInputs1);
+
+ for(j = idx-1; j < Vec_IntSize(iMatch2[i]) && MATCH_FOUND == FALSE; j++)
+ {
+ int tempJ;
+ Vec_Int_t * mismatch;
+
+ if( skipList[j] )
+ continue;
+
+ mismatch = Vec_IntAlloc(10);
+
+ Vec_IntPush(matchedInputs2, Vec_IntEntry(iMatch2[i], j));
+
+ subNtk2 = computeCofactor(pNtk2, nodesInLevel2, NULL, matchedInputs2);
+
+ for(m = 0; m < Vec_IntSize(matchedOutputs1); m++)
+ {
+ Vec_PtrPush(oMatchPairs, Abc_NtkPo(subNtk1, Vec_IntEntry(matchedOutputs1, m)));
+ Vec_PtrPush(oMatchPairs, Abc_NtkPo(subNtk2, Vec_IntEntry(matchedOutputs2, m)));
+ }
+
+ counter++;
+
+ if( Abc_NtkBmSat( subNtk2, subNtk1, NULL, oMatchPairs, mismatch, 0) )
+ {
+ if(idx-1 != j)
+ {
+ tempJ = Vec_IntEntry(iMatch2[i], idx-1);
+ Vec_IntWriteEntry(iMatch2[i], idx-1, Vec_IntEntry(iMatch2[i], j));
+ Vec_IntWriteEntry(iMatch2[i], j, tempJ);
+ }
+
+ /*fprintf(matchFile, "%s matched to %s\n", Abc_ObjName(Abc_NtkPi(pNtk1, Vec_IntEntry(iMatch1[i], idx-1))),
+ Abc_ObjName(Abc_NtkPi(pNtk2, Vec_IntEntry(iMatch2[i], j))));*/
+
+ // we look for a match for outputs in oNonSingleton
+ matchNonSingletonOutputs(pNtk1, nodesInLevel1, iMatch1, iDep1, matchedInputs1, iGroup1, oMatch1, oGroup1,
+ pNtk2, nodesInLevel2, iMatch2, iDep2, matchedInputs2, iGroup2, oMatch2, oGroup2,
+ matchedOutputs1, matchedOutputs2, oMatchedGroups, iNonSingleton,
+ subNtk1, subNtk2, oMatchPairs, oNonSingleton, 0, 0, ii, idx);
+
+
+ if(idx-1 != j)
+ {
+ tempJ = Vec_IntEntry(iMatch2[i], idx-1);
+ Vec_IntWriteEntry(iMatch2[i], idx-1, Vec_IntEntry(iMatch2[i], j));
+ Vec_IntWriteEntry(iMatch2[i], j, tempJ);
+ }
+ }
+ else
+ {
+ Abc_Ntk_t * FpNtk1, * FpNtk2;
+ int * bitVector1, * bitVector2;
+ Vec_Int_t * currInputs1, * currInputs2;
+ Vec_Ptr_t * vSupp;
+ Abc_Obj_t * pObj;
+ int suppNum1 = 0;
+ int * suppNum2;
+
+ bitVector1 = ABC_ALLOC( int, Abc_NtkPiNum(pNtk1) );
+ bitVector2 = ABC_ALLOC( int, Abc_NtkPiNum(pNtk2) );
+
+ currInputs1 = Vec_IntAlloc(10);
+ currInputs2 = Vec_IntAlloc(10);
+
+ suppNum2 = ABC_ALLOC(int, Vec_IntSize(iMatch2[i])-idx+1);
+
+ for(m = 0; m < Abc_NtkPiNum(pNtk1); m++)
+ {
+ bitVector1[m] = 0;
+ bitVector2[m] = 0;
+ }
+
+ for(m = 0; m < Vec_IntSize(iMatch2[i])-idx+1; m++)
+ suppNum2[m]= 0;
+
+ // First of all set the value of the inputs that are already matched and are in mismatch
+ for(m = 0; m < Vec_IntSize(mismatch); m += 2)
+ {
+ int n = Vec_IntEntry(mismatch, m);
+
+ bitVector1[Vec_IntEntry(matchedInputs1, n)] = Vec_IntEntry(mismatch, m+1);
+ bitVector2[Vec_IntEntry(matchedInputs2, n)] = Vec_IntEntry(mismatch, m+1);
+
+ }
+
+ for(m = idx-1; m < Vec_IntSize(iMatch1[i]); m++)
+ {
+ Vec_IntPush(currInputs1, Vec_IntEntry(iMatch1[i], m));
+ Vec_IntPush(currInputs2, Vec_IntEntry(iMatch2[i], m));
+ }
+
+ // Then add all the inputs that are not yet matched to the currInputs
+ for(m = 0; m < Abc_NtkPiNum(pNtk1); m++)
+ {
+ if(Vec_IntFind( matchedInputs1, m ) == -1)
+ Vec_IntPushUnique(currInputs1, m);
+
+ if(Vec_IntFind( matchedInputs2, m ) == -1)
+ Vec_IntPushUnique(currInputs2, m);
+ }
+
+ FpNtk1 = computeCofactor(pNtk1, nodesInLevel1, bitVector1, currInputs1);
+ FpNtk2 = computeCofactor(pNtk2, nodesInLevel2, bitVector2, currInputs2);
+
+ Abc_NtkForEachPo( FpNtk1, pObj, m )
+ {
+ int n;
+ vSupp = Abc_NtkNodeSupport( FpNtk1, &pObj, 1 );
+
+ for(n = 0; n < vSupp->nSize; n++)
+ if( Abc_ObjId((Abc_Obj_t *)vSupp->pArray[n]) == 1 )
+ suppNum1 += Vec_IntFind( matchedOutputs1, m) + 1;
+
+ Vec_PtrFree( vSupp );
+ }
+
+ Abc_NtkForEachPo( FpNtk2, pObj, m )
+ {
+ int n;
+ vSupp = Abc_NtkNodeSupport( FpNtk2, &pObj, 1 );
+
+ for(n = 0; n < vSupp->nSize; n++)
+ if( Abc_ObjId((Abc_Obj_t *)vSupp->pArray[n])-1 < (unsigned)(Vec_IntSize(iMatch2[i]))-idx+1 &&
+ Abc_ObjId((Abc_Obj_t *)vSupp->pArray[n])-1 >= 0)
+ suppNum2[Abc_ObjId((Abc_Obj_t *)vSupp->pArray[n])-1] += Vec_IntFind( matchedOutputs2, m) + 1;
+
+ Vec_PtrFree( vSupp );
+ }
+
+ /*if(suppNum1 != 0)
+ printf("Ntk1 is trigged");
+
+ if(suppNum2[0] != 0)
+ printf("Ntk2 is trigged");*/
+
+ for(m = 0; m < Vec_IntSize(iMatch2[i])-idx+1; m++)
+ if(suppNum2[m] != suppNum1)
+ {
+ skipList[m+idx-1] = TRUE;
+ /*printf("input is skipped");*/
+ }
+
+ Abc_NtkDelete( FpNtk1 );
+ Abc_NtkDelete( FpNtk2 );
+ ABC_FREE( bitVector1 );
+ ABC_FREE( bitVector2 );
+ Vec_IntFree( currInputs1 );
+ Vec_IntFree( currInputs2 );
+ ABC_FREE( suppNum2 );
+ }
+
+ Vec_PtrClear(oMatchPairs);
+ Abc_NtkDelete( subNtk2 );
+ Vec_IntFree(mismatch);
+
+ //Vec_IntWriteEntry(iMatch2[i], j, tempJ);
+
+ if( MATCH_FOUND == FALSE )
+ Vec_IntPop(matchedInputs2);
+ }
+
+ if( MATCH_FOUND == FALSE )
+ {
+ Vec_IntPop(matchedInputs1);
+
+ if(idx == 1)
+ {
+ for(m = 0; m < Vec_IntSize(oNonSingleton); m++)
+ Vec_IntPop( oMatchedGroups );
+ }
+ }
+
+ Vec_IntFree( oNonSingleton );
+ Vec_PtrFree( oMatchPairs );
+ ABC_FREE( skipList );
+ Abc_NtkDelete( subNtk1 );
+
+ if(MATCH_FOUND && counter != 0)
+ {
+ /*printf("Number of INPUT SAT instances = %d\n", counter);*/
+
+ counter = 0;
+ }
+
+ return MATCH_FOUND;
+}
+
+float refineBySAT(Abc_Ntk_t * pNtk1, Vec_Int_t ** iMatch1, int * iGroup1, Vec_Int_t ** iDep1, int* iLastItem1, Vec_Int_t ** oMatch1, int * oGroup1, Vec_Int_t ** oDep1, int* oLastItem1, int * observability1,
+ Abc_Ntk_t * pNtk2, Vec_Int_t ** iMatch2, int * iGroup2, Vec_Int_t ** iDep2, int* iLastItem2, Vec_Int_t ** oMatch2, int * oGroup2, Vec_Int_t ** oDep2, int* oLastItem2, int * observability2)
+{
+ int i, j;
+ Abc_Obj_t * pObj;
+ Vec_Int_t * iNonSingleton;
+ Vec_Int_t * matchedInputs1, * matchedInputs2;
+ Vec_Int_t * matchedOutputs1, * matchedOutputs2;
+ Vec_Ptr_t ** nodesInLevel1, ** nodesInLevel2;
+ Vec_Int_t * oMatchedGroups;
+ FILE *result;
+ int matchFound;
+ int clk = clock();
+ float satTime = 0.0;
+
+ /*matchFile = fopen("satmatch.txt", "w");*/
+
+ iNonSingleton = Vec_IntAlloc(10);
+
+ matchedInputs1 = Vec_IntAlloc( Abc_NtkPiNum(pNtk1) );
+ matchedInputs2 = Vec_IntAlloc( Abc_NtkPiNum(pNtk2) );
+
+ matchedOutputs1 = Vec_IntAlloc( Abc_NtkPoNum(pNtk1) );
+ matchedOutputs2 = Vec_IntAlloc( Abc_NtkPoNum(pNtk2) );
+
+ nodesInLevel1 = ABC_ALLOC( Vec_Ptr_t *, Abc_AigLevel( pNtk1 ) + 1); // why numOfLevels+1? because the inputs are in level 0
+ for(i = 0; i <= Abc_AigLevel( pNtk1 ); i++)
+ nodesInLevel1[i] = Vec_PtrAlloc( 20 );
+
+ // bucket sort the objects based on their levels
+ Abc_AigForEachAnd( pNtk1, pObj, i )
+ Vec_PtrPush(nodesInLevel1[Abc_ObjLevel(pObj)], pObj);
+
+ nodesInLevel2 = ABC_ALLOC( Vec_Ptr_t *, Abc_AigLevel( pNtk2 ) + 1); // why numOfLevels+1? because the inputs are in level 0
+ for(i = 0; i <= Abc_AigLevel( pNtk2 ); i++)
+ nodesInLevel2[i] = Vec_PtrAlloc( 20 );
+
+ // bucket sort the objects based on their levels
+ Abc_AigForEachAnd( pNtk2, pObj, i )
+ Vec_PtrPush(nodesInLevel2[Abc_ObjLevel(pObj)], pObj);
+
+ oMatchedGroups = Vec_IntAlloc( 10 );
+
+ for(i = 0; i < *iLastItem1; i++)
+ {
+ if(Vec_IntSize(iMatch1[i]) == 1)
+ {
+ Vec_IntPush(matchedInputs1, Vec_IntEntryLast(iMatch1[i]));
+ Vec_IntPush(matchedInputs2, Vec_IntEntryLast(iMatch2[i]));
+ }
+ else
+ Vec_IntPush(iNonSingleton, i);
+ }
+
+ for(i = 0; i < *oLastItem1; i++)
+ {
+ if(Vec_IntSize(oMatch1[i]) == 1)
+ {
+ Vec_IntPush(matchedOutputs1, Vec_IntEntryLast(oMatch1[i]));
+ Vec_IntPush(matchedOutputs2, Vec_IntEntryLast(oMatch2[i]));
+ }
+ }
+
+ for(i = 0; i < Vec_IntSize(iNonSingleton) - 1; i++)
+ {
+ for(j = i + 1; j < Vec_IntSize(iNonSingleton); j++)
+ if( observability2[Vec_IntEntry(iMatch2[Vec_IntEntry(iNonSingleton, j)], 0)] >
+ observability2[Vec_IntEntry(iMatch2[Vec_IntEntry(iNonSingleton, i)], 0)] )
+ {
+ int temp = Vec_IntEntry(iNonSingleton, i);
+ Vec_IntWriteEntry( iNonSingleton, i, Vec_IntEntry(iNonSingleton, j) );
+ Vec_IntWriteEntry( iNonSingleton, j, temp );
+ }
+ else if( observability2[Vec_IntEntry(iMatch2[Vec_IntEntry(iNonSingleton, j)], 0)] ==
+ observability2[Vec_IntEntry(iMatch2[Vec_IntEntry(iNonSingleton, i)], 0)] )
+ {
+ if( Vec_IntSize(iMatch2[Vec_IntEntry(iNonSingleton, j)]) < Vec_IntSize(iMatch2[Vec_IntEntry(iNonSingleton, i)]) )
+ {
+ int temp = Vec_IntEntry(iNonSingleton, i);
+ Vec_IntWriteEntry( iNonSingleton, i, Vec_IntEntry(iNonSingleton, j) );
+ Vec_IntWriteEntry( iNonSingleton, j, temp );
+ }
+ }
+ }
+
+ /*for(i = 0; i < Vec_IntSize(iNonSingleton) - 1; i++)
+ {
+ for(j = i + 1; j < Vec_IntSize(iNonSingleton); j++)
+ if( Vec_IntSize(oDep2[oGroup2[Vec_IntEntryLast(iMatch2[Vec_IntEntry(iNonSingleton, j)])]]) >
+ Vec_IntSize(oDep2[oGroup2[Vec_IntEntryLast(iMatch2[Vec_IntEntry(iNonSingleton, i)])]]) )
+ {
+ int temp = Vec_IntEntry(iNonSingleton, i);
+ Vec_IntWriteEntry( iNonSingleton, i, Vec_IntEntry(iNonSingleton, j) );
+ Vec_IntWriteEntry( iNonSingleton, j, temp );
+ }
+ else if( Vec_IntSize(oDep2[oGroup2[Vec_IntEntryLast(iMatch2[Vec_IntEntry(iNonSingleton, j)])]]) ==
+ Vec_IntSize(oDep2[oGroup2[Vec_IntEntryLast(iMatch2[Vec_IntEntry(iNonSingleton, i)])]]) )
+ {
+ if( observability2[Vec_IntEntry(iMatch2[Vec_IntEntry(iNonSingleton, j)], 0)] >
+ observability2[Vec_IntEntry(iMatch2[Vec_IntEntry(iNonSingleton, i)], 0)] )
+ {
+ int temp = Vec_IntEntry(iNonSingleton, i);
+ Vec_IntWriteEntry( iNonSingleton, i, Vec_IntEntry(iNonSingleton, j) );
+ Vec_IntWriteEntry( iNonSingleton, j, temp );
+ }
+ }
+ }*/
+
+ matchFound = match1by1(pNtk1, nodesInLevel1, iMatch1, iDep1, matchedInputs1, iGroup1, oMatch1, oGroup1,
+ pNtk2, nodesInLevel2, iMatch2, iDep2, matchedInputs2, iGroup2, oMatch2, oGroup2,
+ matchedOutputs1, matchedOutputs2, oMatchedGroups, iNonSingleton, 0, 0);
+
+ if( matchFound && Vec_IntSize(matchedOutputs1) != Abc_NtkPoNum(pNtk1) )
+ {
+ Vec_Int_t * oNonSingleton;
+ Vec_Ptr_t * oMatchPairs;
+ Abc_Ntk_t * subNtk1, * subNtk2;
+
+ oNonSingleton = Vec_IntAlloc( 10 );
+
+ oMatchPairs = Vec_PtrAlloc(Abc_NtkPoNum(pNtk1) * 2);
+
+ for(i = 0; i < *oLastItem1; i++)
+ if( Vec_IntSize(oMatch1[i]) > 1 && Vec_IntFind( oMatchedGroups, i) == -1 )
+ Vec_IntPush(oNonSingleton, i);
+
+ subNtk1 = computeCofactor(pNtk1, nodesInLevel1, NULL, matchedInputs1);
+ subNtk2 = computeCofactor(pNtk2, nodesInLevel2, NULL, matchedInputs2);
+
+ matchFound = matchNonSingletonOutputs(pNtk1, nodesInLevel1, iMatch1, iDep1, matchedInputs1, iGroup1, oMatch1, oGroup1,
+ pNtk2, nodesInLevel2, iMatch2, iDep2, matchedInputs2, iGroup1, oMatch2, oGroup2,
+ matchedOutputs1, matchedOutputs2, oMatchedGroups, NULL,
+ subNtk1, subNtk2, oMatchPairs, oNonSingleton, 0, 0, 0, 0);
+
+ Vec_IntFree( oNonSingleton );
+ Vec_PtrFree( oMatchPairs );
+
+ Abc_NtkDelete(subNtk1);
+ Abc_NtkDelete(subNtk2);
+ }
+
+ satTime = (float)(clock() - clk)/(float)(CLOCKS_PER_SEC);
+
+ if( matchFound )
+ {
+ checkEquivalence( pNtk1, matchedInputs1, matchedOutputs1, pNtk2, matchedInputs2, matchedOutputs2);
+
+ result = fopen("IOmatch.txt", "w");
+
+ fprintf(result, "I/O = %d / %d \n\n", Abc_NtkPiNum(pNtk1), Abc_NtkPoNum(pNtk1));
+
+ for(i = 0; i < Vec_IntSize(matchedInputs1) ; i++)
+ fprintf(result, "{%s}\t{%s}\n", Abc_ObjName(Abc_NtkPi(pNtk1, Vec_IntEntry(matchedInputs1, i))), Abc_ObjName(Abc_NtkPi(pNtk2, Vec_IntEntry(matchedInputs2, i))) );
+
+ fprintf(result, "\n-----------------------------------------\n");
+
+ for(i = 0; i < Vec_IntSize(matchedOutputs1) ; i++)
+ fprintf(result, "{%s}\t{%s}\n", Abc_ObjName(Abc_NtkPo(pNtk1, Vec_IntEntry(matchedOutputs1, i))), Abc_ObjName(Abc_NtkPo(pNtk2, Vec_IntEntry(matchedOutputs2, i))) );
+
+ fclose( result );
+ }
+
+ Vec_IntFree( matchedInputs1 );
+ Vec_IntFree( matchedInputs2 );
+ Vec_IntFree( matchedOutputs1 );
+ Vec_IntFree( matchedOutputs2 );
+ Vec_IntFree( iNonSingleton );
+ Vec_IntFree( oMatchedGroups );
+
+ for(i = 0; i <= Abc_AigLevel( pNtk1 ); i++)
+ Vec_PtrFree( nodesInLevel1[i] );
+ for(i = 0; i <= Abc_AigLevel( pNtk2 ); i++)
+ Vec_PtrFree( nodesInLevel2[i] );
+
+
+ ABC_FREE( nodesInLevel1 );
+ ABC_FREE( nodesInLevel2 );
+ /*fclose(matchFile);*/
+
+ return satTime;
+}
+
+int checkListConsistency(Vec_Int_t ** iMatch1, Vec_Int_t ** oMatch1, Vec_Int_t ** iMatch2, Vec_Int_t ** oMatch2, int iLastItem1, int oLastItem1, int iLastItem2, int oLastItem2)
+{
+ //int i;
+
+ if(iLastItem1 != iLastItem2 || oLastItem1 != oLastItem2)
+ return FALSE;
+
+ /*for(i = 0; i < iLastItem1; i++) {
+ if(Vec_IntSize(iMatch1[i]) != Vec_IntSize(iMatch2[i]))
+ return FALSE;
+ }
+
+ for(i = 0; i < oLastItem1; i++) {
+ if(Vec_IntSize(oMatch1[i]) != Vec_IntSize(oMatch2[i]))
+ return FALSE;
+ }*/
+
+ return TRUE;
+}
+
+
+void bmGateWay( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int p_equivalence )
+{
+ Vec_Int_t ** iDep1, ** oDep1;
+ Vec_Int_t ** iDep2, ** oDep2;
+ Vec_Int_t ** iMatch1, ** oMatch1;
+ Vec_Int_t ** iMatch2, ** oMatch2;
+ int * iGroup1, * oGroup1;
+ int * iGroup2, * oGroup2;
+ int iLastItem1, oLastItem1;
+ int iLastItem2, oLastItem2;
+ int i, j;
+
+ char * vPiValues1, * vPiValues2;
+ int * observability1, * observability2;
+ int clk = clock();
+ float initTime;
+ float simulTime;
+ float satTime;
+ Vec_Ptr_t ** topOrder1 = NULL, ** topOrder2 = NULL;
+
+ extern void getDependencies(Abc_Ntk_t *pNtk, Vec_Int_t** iDep, Vec_Int_t** oDep);
+ extern void initMatchList(Abc_Ntk_t *pNtk, Vec_Int_t** iDep, Vec_Int_t** oDep, Vec_Int_t** iMatch, int* iLastItem, Vec_Int_t** oMatch, int* oLastItem, int* iGroup, int* oGroup, int p_equivalence);
+ extern void iSortDependencies(Abc_Ntk_t *pNtk, Vec_Int_t** iDep, int* oGroup);
+ extern void oSortDependencies(Abc_Ntk_t *pNtk, Vec_Int_t** oDep, int* iGroup);
+ extern int iSplitByDep(Abc_Ntk_t *pNtk, Vec_Int_t** iDep, Vec_Int_t** iMatch, int* iGroup, int* iLastItem, int* oGroup);
+ extern int oSplitByDep(Abc_Ntk_t *pNtk, Vec_Int_t** oDep, Vec_Int_t** oMatch, int* oGroup, int* oLastItem, int* iGroup);
+ extern Vec_Ptr_t ** findTopologicalOrder(Abc_Ntk_t * pNtk);
+ extern int refineIOBySimulation(Abc_Ntk_t *pNtk, Vec_Int_t** iMatch, int* iLastItem, int * iGroup, Vec_Int_t** iDep, Vec_Int_t** oMatch, int* oLastItem, int * oGroup, Vec_Int_t** oDep, char * vPiValues, int * observability, Vec_Ptr_t ** topOrder);
+ extern float refineBySAT(Abc_Ntk_t * pNtk1, Vec_Int_t ** iMatch1, int * iGroup1, Vec_Int_t ** iDep1, int* iLastItem1, Vec_Int_t ** oMatch1, int * oGroup1, Vec_Int_t ** oDep1, int* oLastItem1, int * observability1,
+ Abc_Ntk_t * pNtk2, Vec_Int_t ** iMatch2, int * iGroup2, Vec_Int_t ** iDep2, int* iLastItem2, Vec_Int_t ** oMatch2, int * oGroup2, Vec_Int_t ** oDep2, int* oLastItem2, int * observability2);
+ int checkListConsistency(Vec_Int_t ** iMatch1, Vec_Int_t ** oMatch1, Vec_Int_t ** iMatch2, Vec_Int_t ** oMatch2, int iLastItem1, int oLastItem1, int iLastItem2, int oLastItem2);
+
+ iDep1 = ABC_ALLOC( Vec_Int_t*, (unsigned)Abc_NtkPiNum(pNtk1) );
+ oDep1 = ABC_ALLOC( Vec_Int_t*, (unsigned)Abc_NtkPoNum(pNtk1) );
+
+ iDep2 = ABC_ALLOC( Vec_Int_t*, (unsigned)Abc_NtkPiNum(pNtk2) );
+ oDep2 = ABC_ALLOC( Vec_Int_t*, (unsigned)Abc_NtkPoNum(pNtk2) );
+
+ iMatch1 = ABC_ALLOC( Vec_Int_t*, (unsigned)Abc_NtkPiNum(pNtk1) );
+ oMatch1 = ABC_ALLOC( Vec_Int_t*, (unsigned)Abc_NtkPoNum(pNtk1) );
+
+ iMatch2 = ABC_ALLOC( Vec_Int_t*, (unsigned)Abc_NtkPiNum(pNtk2) );
+ oMatch2 = ABC_ALLOC( Vec_Int_t*, (unsigned)Abc_NtkPoNum(pNtk2) );
+
+ iGroup1 = ABC_ALLOC( int, Abc_NtkPiNum(pNtk1) );
+ oGroup1 = ABC_ALLOC( int, Abc_NtkPoNum(pNtk1) );
+
+ iGroup2 = ABC_ALLOC( int, Abc_NtkPiNum(pNtk2) );
+ oGroup2 = ABC_ALLOC( int, Abc_NtkPoNum(pNtk2) );
+
+ vPiValues1 = ABC_ALLOC( char, Abc_NtkPiNum(pNtk1) + 1);
+ vPiValues1[Abc_NtkPiNum(pNtk1)] = '\0';
+
+ vPiValues2 = ABC_ALLOC( char, Abc_NtkPiNum(pNtk2) + 1);
+ vPiValues2[Abc_NtkPiNum(pNtk2)] = '\0';
+
+ observability1 = ABC_ALLOC(int, (unsigned)Abc_NtkPiNum(pNtk1));
+ observability2 = ABC_ALLOC(int, (unsigned)Abc_NtkPiNum(pNtk2));
+
+ for(i = 0; i < Abc_NtkPiNum(pNtk1); i++)
+ {
+ iDep1[i] = Vec_IntAlloc( 1 );
+ iMatch1[i] = Vec_IntAlloc( 1 );
+
+ iDep2[i] = Vec_IntAlloc( 1 );
+ iMatch2[i] = Vec_IntAlloc( 1 );
+
+ vPiValues1[i] = '0';
+ vPiValues2[i] = '0';
+
+ observability1[i] = 0;
+ observability2[i] = 0;
+ }
+
+ for(i = 0; i < Abc_NtkPoNum(pNtk1); i++)
+ {
+ oDep1[i] = Vec_IntAlloc( 1 );
+ oMatch1[i] = Vec_IntAlloc( 1 );
+
+ oDep2[i] = Vec_IntAlloc( 1 );
+ oMatch2[i] = Vec_IntAlloc( 1 );
+ }
+
+ /************* Strashing ************/
+ pNtk1 = Abc_NtkStrash( pNtk1, 0, 0, 0 );
+ pNtk2 = Abc_NtkStrash( pNtk2, 0, 0, 0 );
+ printf("Network strashing is done!\n");
+ /************************************/
+
+ /******* Getting Dependencies *******/
+ getDependencies(pNtk1, iDep1, oDep1);
+ getDependencies(pNtk2, iDep2, oDep2);
+ printf("Getting dependencies is done!\n");
+ /************************************/
+
+ /***** Intializing match lists ******/
+ initMatchList(pNtk1, iDep1, oDep1, iMatch1, &iLastItem1, oMatch1, &oLastItem1, iGroup1, oGroup1, p_equivalence);
+ initMatchList(pNtk2, iDep2, oDep2, iMatch2, &iLastItem2, oMatch2, &oLastItem2, iGroup2, oGroup2, p_equivalence);
+ printf("Initializing match lists is done!\n");
+ /************************************/
+
+ if( !checkListConsistency(iMatch1, oMatch1, iMatch2, oMatch2, iLastItem1, oLastItem1, iLastItem2, oLastItem2) )
+ {
+ fprintf( stdout, "I/O dependencies of two circuits are different.\n");
+ goto freeAndExit;
+ }
+
+ printf("Refining IOs by dependencies ...");
+ // split match lists further by checking dependencies
+ do
+ {
+ int iNumOfItemsAdded = 1, oNumOfItemsAdded = 1;
+
+ do
+ {
+ if( oNumOfItemsAdded )
+ {
+ iSortDependencies(pNtk1, iDep1, oGroup1);
+ iSortDependencies(pNtk2, iDep2, oGroup2);
+ }
+
+ if( iNumOfItemsAdded )
+ {
+ oSortDependencies(pNtk1, oDep1, iGroup1);
+ oSortDependencies(pNtk2, oDep2, iGroup2);
+ }
+
+ if( iLastItem1 < Abc_NtkPiNum(pNtk1) )
+ {
+ iSplitByDep(pNtk1, iDep1, iMatch1, iGroup1, &iLastItem1, oGroup1);
+ if( oLastItem1 < Abc_NtkPoNum(pNtk1) )
+ oSplitByDep(pNtk1, oDep1, oMatch1, oGroup1, &oLastItem1, iGroup1);
+ }
+
+ if( iLastItem2 < Abc_NtkPiNum(pNtk2) )
+ {
+ iNumOfItemsAdded = iSplitByDep(pNtk2, iDep2, iMatch2, iGroup2, &iLastItem2, oGroup2);
+ if( oLastItem2 < Abc_NtkPoNum(pNtk2) )
+ oNumOfItemsAdded = oSplitByDep(pNtk2, oDep2, oMatch2, oGroup2, &oLastItem2, iGroup2);
+ else
+ oNumOfItemsAdded = 0;
+ }
+ else
+ iNumOfItemsAdded = 0;
+
+ if(!checkListConsistency(iMatch1, oMatch1, iMatch2, oMatch2, iLastItem1, oLastItem1, iLastItem2, oLastItem2))
+ {
+ fprintf( stdout, "I/O dependencies of two circuits are different.\n");
+ goto freeAndExit;
+ }
+ }while(iNumOfItemsAdded != 0 || oNumOfItemsAdded != 0);
+
+ }while(0);
+
+ printf(" done!\n");
+
+ initTime = ((float)(clock() - clk)/(float)(CLOCKS_PER_SEC));
+ clk = clock();
+
+ topOrder1 = findTopologicalOrder(pNtk1);
+ topOrder2 = findTopologicalOrder(pNtk2);
+
+ printf("Refining IOs by simulation ...");
+
+ do
+ {
+ int counter = 0;
+ int ioSuccess1, ioSuccess2;
+
+ do
+ {
+ for(i = 0; i < iLastItem1; i++)
+ {
+ int temp = (int)(SIM_RANDOM_UNSIGNED % 2);
+
+ if(Vec_IntSize(iMatch1[i]) != Vec_IntSize(iMatch2[i]))
+ {
+ fprintf( stdout, "Input refinement by simulation finds two circuits different.\n");
+ goto freeAndExit;
+ }
+
+ for(j = 0; j < Vec_IntSize(iMatch1[i]); j++)
+ {
+ vPiValues1[Vec_IntEntry(iMatch1[i], j)] = temp + '0';
+ vPiValues2[Vec_IntEntry(iMatch2[i], j)] = temp + '0';
+ }
+ }
+
+ ioSuccess1 = refineIOBySimulation(pNtk1, iMatch1, &iLastItem1, iGroup1, iDep1, oMatch1, &oLastItem1, oGroup1, oDep1, vPiValues1, observability1, topOrder1);
+ ioSuccess2 = refineIOBySimulation(pNtk2, iMatch2, &iLastItem2, iGroup2, iDep2, oMatch2, &oLastItem2, oGroup2, oDep2, vPiValues2, observability2, topOrder2);
+
+ if(ioSuccess1 && ioSuccess2)
+ counter = 0;
+ else
+ counter++;
+
+ if(ioSuccess1 != ioSuccess2 ||
+ !checkListConsistency(iMatch1, oMatch1, iMatch2, oMatch2, iLastItem1, oLastItem1, iLastItem2, oLastItem2))
+ {
+ fprintf( stdout, "Input refinement by simulation finds two circuits different.\n");
+ goto freeAndExit;
+ }
+ }while(counter <= 200);
+
+ }while(0);
+
+ printf(" done!\n");
+
+ simulTime = (float)(clock() - clk)/(float)(CLOCKS_PER_SEC);
+ printf("SAT-based search started ...\n");
+
+ satTime = refineBySAT(pNtk1, iMatch1, iGroup1, iDep1, &iLastItem1, oMatch1, oGroup1, oDep1, &oLastItem1, observability1,
+ pNtk2, iMatch2, iGroup2, iDep2, &iLastItem2, oMatch2, oGroup2, oDep2, &oLastItem2, observability2);
+
+ printf( "Init Time = %4.2f\n", initTime );
+ printf( "Simulation Time = %4.2f\n", simulTime );
+ printf( "SAT Time = %4.2f\n", satTime );
+ printf( "Overall Time = %4.2f\n", initTime + simulTime + satTime );
+
+freeAndExit:
+
+ for(i = 0; i < iLastItem1 ; i++)
+ {
+
+ Vec_IntFree( iMatch1[i] );
+ Vec_IntFree( iMatch2[i] );
+ }
+
+ for(i = 0; i < oLastItem1 ; i++)
+ {
+
+ Vec_IntFree( oMatch1[i] );
+ Vec_IntFree( oMatch2[i] );
+ }
+
+ for(i = 0; i < Abc_NtkPiNum(pNtk1); i++)
+ {
+ Vec_IntFree( iDep1[i] );
+ Vec_IntFree( iDep2[i] );
+ if(topOrder1 != NULL) {
+ Vec_PtrFree( topOrder1[i] );
+ Vec_PtrFree( topOrder2[i] );
+ }
+ }
+
+ for(i = 0; i < Abc_NtkPoNum(pNtk1); i++)
+ {
+ Vec_IntFree( oDep1[i] );
+ Vec_IntFree( oDep2[i] );
+ }
+
+ ABC_FREE( iMatch1 );
+ ABC_FREE( iMatch2 );
+ ABC_FREE( oMatch1 );
+ ABC_FREE( oMatch2 );
+ ABC_FREE( iDep1 );
+ ABC_FREE( iDep2 );
+ ABC_FREE( oDep1 );
+ ABC_FREE( oDep2 );
+ ABC_FREE( iGroup1 );
+ ABC_FREE( iGroup2 );
+ ABC_FREE( oGroup1 );
+ ABC_FREE( oGroup2 );
+ ABC_FREE( vPiValues1 );
+ ABC_FREE( vPiValues2 );
+ ABC_FREE( observability1 );
+ ABC_FREE( observability2 );
+ if(topOrder1 != NULL) {
+ ABC_FREE( topOrder1 );
+ ABC_FREE( topOrder2 );
+ }
+}ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcBmc.c b/src/base/abci/abcBmc.c
index 1512c76f..21f2d484 100644
--- a/src/base/abci/abcBmc.c
+++ b/src/base/abci/abcBmc.c
@@ -21,6 +21,9 @@
#include "abc.h"
#include "ivy.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -93,7 +96,7 @@ void Abc_NtkBmcReport( Ivy_Man_t * pMan, Ivy_Man_t * pFrames, Ivy_Man_t * pFraig
{
Ivy_ManForEachNode( pMan, pFirst1, i )
{
- pFirst2 = Ivy_Regular( Vec_PtrEntry(vMapping, f * nIdMax + pFirst1->Id) );
+ pFirst2 = Ivy_Regular( (Ivy_Obj_t *)Vec_PtrEntry(vMapping, f * nIdMax + pFirst1->Id) );
if ( Ivy_ObjIsConst1(pFirst2) || pFirst2->Type == 0 )
continue;
pFirst3 = Ivy_Regular( pFirst2->pEquiv );
@@ -115,3 +118,5 @@ void Abc_NtkBmcReport( Ivy_Man_t * pMan, Ivy_Man_t * pFrames, Ivy_Man_t * pFraig
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcCas.c b/src/base/abci/abcCas.c
index ff0d761e..76fe5e9f 100644
--- a/src/base/abci/abcCas.c
+++ b/src/base/abci/abcCas.c
@@ -20,6 +20,9 @@
#include "abc.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*
This LUT cascade synthesis algorithm is described in the paper:
A. Mishchenko and T. Sasao, "Encoding of Boolean functions and its
@@ -109,3 +112,5 @@ Abc_Ntk_t * Abc_NtkCascade( Abc_Ntk_t * pNtk, int nLutSize, int fCheck, int fVer
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcCascade.c b/src/base/abci/abcCascade.c
new file mode 100644
index 00000000..a2e6d234
--- /dev/null
+++ b/src/base/abci/abcCascade.c
@@ -0,0 +1,284 @@
+/**CFile****************************************************************
+
+ FileName [abcCascade.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Network and node package.]
+
+ Synopsis [Collapsing the network into two-levels.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: abcCollapse.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "abc.h"
+#include "reo.h"
+
+ABC_NAMESPACE_IMPL_START
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+#define BDD_FUNC_MAX 256
+
+//extern void Abc_NodeShowBddOne( DdManager * dd, DdNode * bFunc );
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Find the constant node corresponding to the encoded output value.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+DdNode * Abc_NtkBddFindAddConst( DdManager * dd, DdNode * bFunc, int nOuts )
+{
+ int i, TermMask = 0;
+ DdNode * bFunc0, * bFunc1, * bConst0, * bConst1;
+ bConst0 = Cudd_ReadLogicZero( dd );
+ bConst1 = Cudd_ReadOne( dd );
+ for ( i = 0; i < nOuts; i++ )
+ {
+ if ( Cudd_IsComplement(bFunc) )
+ {
+ bFunc0 = Cudd_Not(Cudd_E(bFunc));
+ bFunc1 = Cudd_Not(Cudd_T(bFunc));
+ }
+ else
+ {
+ bFunc0 = Cudd_E(bFunc);
+ bFunc1 = Cudd_T(bFunc);
+ }
+ assert( bFunc0 == bConst0 || bFunc1 == bConst0 );
+ if ( bFunc0 == bConst0 )
+ {
+ TermMask ^= (1 << i);
+ bFunc = bFunc1;
+ }
+ else
+ bFunc = bFunc0;
+ }
+ assert( bFunc == bConst1 );
+ return Cudd_addConst( dd, TermMask );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Recursively construct ADD for BDD.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+DdNode * Abc_NtkBddToAdd_rec( DdManager * dd, DdNode * bFunc, int nOuts, stmm_table * tTable, int fCompl )
+{
+ DdNode * aFunc0, * aFunc1, * aFunc;
+ DdNode ** ppSlot;
+ assert( !Cudd_IsComplement(bFunc) );
+ if ( stmm_find_or_add( tTable, (char *)bFunc, (char ***)&ppSlot ) )
+ return *ppSlot;
+ if ( (int)bFunc->index >= Cudd_ReadSize(dd) - nOuts )
+ {
+ assert( Cudd_ReadPerm(dd, bFunc->index) >= Cudd_ReadSize(dd) - nOuts );
+ aFunc = Abc_NtkBddFindAddConst( dd, Cudd_NotCond(bFunc, fCompl), nOuts ); Cudd_Ref( aFunc );
+ }
+ else
+ {
+ aFunc0 = Abc_NtkBddToAdd_rec( dd, Cudd_Regular(cuddE(bFunc)), nOuts, tTable, fCompl ^ Cudd_IsComplement(cuddE(bFunc)) );
+ aFunc1 = Abc_NtkBddToAdd_rec( dd, cuddT(bFunc), nOuts, tTable, fCompl );
+ aFunc = Cudd_addIte( dd, Cudd_addIthVar(dd, bFunc->index), aFunc1, aFunc0 ); Cudd_Ref( aFunc );
+ }
+ return (*ppSlot = aFunc);
+}
+
+/**Function*************************************************************
+
+ Synopsis [R]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+DdNode * Abc_NtkBddToAdd( DdManager * dd, DdNode * bFunc, int nOuts )
+{
+ DdNode * aFunc, * aTemp, * bTemp;
+ stmm_table * tTable;
+ stmm_generator * gen;
+ tTable = stmm_init_table( st_ptrcmp, st_ptrhash );
+ aFunc = Abc_NtkBddToAdd_rec( dd, Cudd_Regular(bFunc), nOuts, tTable, Cudd_IsComplement(bFunc) ); Cudd_Ref(aFunc);
+ stmm_foreach_item( tTable, gen, (char **)&bTemp, (char **)&aTemp )
+ Cudd_RecursiveDeref( dd, aFunc );
+ stmm_free_table( tTable );
+ Cudd_Deref( aFunc );
+ return aFunc;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes the characteristic function.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+DdNode * Abc_NtkBddDecCharFunc( DdManager * dd, DdNode ** pFuncs, int nOuts, int Mask, int nBits )
+{
+ DdNode * bFunc, * bTemp, * bExor, * bVar;
+ int i, Count = 0;
+ bFunc = Cudd_ReadOne( dd ); Cudd_Ref( bFunc );
+ for ( i = 0; i < nOuts; i++ )
+ {
+ if ( (Mask & (1 << i)) == 0 )
+ continue;
+ Count++;
+ bVar = Cudd_bddIthVar( dd, dd->size - nOuts + i );
+ bExor = Cudd_bddXor( dd, pFuncs[i], bVar ); Cudd_Ref( bExor );
+ bFunc = Cudd_bddAnd( dd, bTemp = bFunc, Cudd_Not(bExor) ); Cudd_Ref( bFunc );
+ Cudd_RecursiveDeref( dd, bTemp );
+ Cudd_RecursiveDeref( dd, bExor );
+ }
+ Cudd_Deref( bFunc );
+ assert( Count == nBits );
+ return bFunc;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Evaluate Sasao's decomposition.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Abc_NtkBddDecTry( reo_man * pReo, DdManager * dd, DdNode ** pFuncs, int nOuts, int Mask, int nBits )
+{
+ DdNode * bFunc, * aFunc, * aFuncNew;
+ // drive the characteristic function
+ bFunc = Abc_NtkBddDecCharFunc( dd, pFuncs, nOuts, Mask, nBits ); Cudd_Ref( bFunc );
+//Abc_NodeShowBddOne( dd, bFunc );
+ // transfer to ADD
+ aFunc = Abc_NtkBddToAdd( dd, bFunc, nOuts ); Cudd_Ref( aFunc );
+ Cudd_RecursiveDeref( dd, bFunc );
+//Abc_NodeShowBddOne( dd, aFunc );
+ // perform reordering for BDD width
+ aFuncNew = Extra_Reorder( pReo, dd, aFunc, NULL ); Cudd_Ref( aFuncNew );
+ Cudd_RecursiveDeref( dd, aFuncNew );
+ Cudd_RecursiveDeref( dd, aFunc );
+ // print the result
+ reoProfileWidthPrint( pReo );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Evaluate Sasao's decomposition.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Abc_NtkBddDecInt( reo_man * pReo, DdManager * dd, DdNode ** pFuncs, int nOuts )
+{
+/*
+ int i, k;
+ for ( i = 1; i <= nOuts; i++ )
+ {
+ for ( k = 0; k < (1<<nOuts); k++ )
+ if ( Extra_WordCountOnes(k) == i )
+ {
+ Extra_PrintBinary( stdout, (unsigned *)&k, nOuts );
+ Abc_NtkBddDecTry( pReo, dd, pFuncs, nOuts, k, i );
+ printf( "\n" );
+ }
+ }
+*/
+ Abc_NtkBddDecTry( pReo, dd, pFuncs, nOuts, ~(1<<(32-nOuts)), nOuts );
+
+}
+
+/**Function*************************************************************
+
+ Synopsis [Evaluate Sasao's decomposition.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Abc_NtkBddDec( Abc_Ntk_t * pNtk, int fVerbose )
+{
+ int nBddSizeMax = 1000000;
+ int fDropInternal = 0;
+ int fReorder = 1;
+ reo_man * pReo;
+ DdManager * dd;
+ DdNode * pFuncs[BDD_FUNC_MAX];
+ Abc_Obj_t * pNode;
+ int i;
+ assert( Abc_NtkIsStrash(pNtk) );
+ assert( Abc_NtkCoNum(pNtk) <= BDD_FUNC_MAX );
+ dd = Abc_NtkBuildGlobalBdds( pNtk, nBddSizeMax, fDropInternal, fReorder, fVerbose );
+ if ( dd == NULL )
+ {
+ Abc_Print( -1, "Construction of global BDDs has failed.\n" );
+ return;
+ }
+
+ assert( dd->size == Abc_NtkCiNum(pNtk) );
+ // create new variables at the bottom
+ for ( i = 0; i < Abc_NtkCoNum(pNtk); i++ )
+ Cudd_addNewVarAtLevel( dd, dd->size );
+ // create terminals of MTBDD
+// for ( i = 0; i < (1 << Abc_NtkCoNum(pNtk)); i++ )
+// Cudd_addConst( dd, i );
+ // collect global BDDs
+ Abc_NtkForEachCo( pNtk, pNode, i )
+ pFuncs[i] = Abc_ObjGlobalBdd(pNode);
+
+ pReo = Extra_ReorderInit( Abc_NtkCiNum(pNtk), 1000 );
+ Extra_ReorderSetMinimizationType( pReo, REO_MINIMIZE_WIDTH );
+
+ Abc_NtkBddDecInt( pReo, dd, pFuncs, Abc_NtkCoNum(pNtk) );
+ Extra_ReorderQuit( pReo );
+
+ Abc_NtkFreeGlobalBdds( pNtk, 1 );
+}
+
+ABC_NAMESPACE_IMPL_END
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
diff --git a/src/base/abci/abcClpBdd.c b/src/base/abci/abcCollapse.c
index 27cba249..1b7709c5 100644
--- a/src/base/abci/abcClpBdd.c
+++ b/src/base/abci/abcCollapse.c
@@ -21,6 +21,9 @@
#include "abc.h"
//#include "reo.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -120,7 +123,7 @@ Abc_Ntk_t * Abc_NtkFromGlobalBdds( Abc_Ntk_t * pNtk )
// start the new network
pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_BDD );
// make sure the new manager has the same number of inputs
- Cudd_bddIthVar( pNtkNew->pManFunc, dd->size-1 );
+ Cudd_bddIthVar( (DdManager *)pNtkNew->pManFunc, dd->size-1 );
// process the POs
pProgress = Extra_ProgressBarStart( stdout, Abc_NtkCoNum(pNtk) );
Abc_NtkForEachCo( pNtk, pNode, i )
@@ -169,7 +172,7 @@ Abc_Obj_t * Abc_NodeFromGlobalBdds( Abc_Ntk_t * pNtkNew, DdManager * dd, DdNode
Abc_NtkForEachCi( pNtkNew, pTemp, i )
Abc_ObjAddFanin( pNodeNew, Abc_NtkCi(pNtkNew, dd->invperm[i]) );
// transfer the function
- pNodeNew->pData = Extra_TransferLevelByLevel( dd, pNtkNew->pManFunc, bFunc ); Cudd_Ref( pNodeNew->pData );
+ pNodeNew->pData = Extra_TransferLevelByLevel( dd, (DdManager *)pNtkNew->pManFunc, bFunc ); Cudd_Ref( (DdNode *)pNodeNew->pData );
return pNodeNew;
}
@@ -179,3 +182,5 @@ Abc_Obj_t * Abc_NodeFromGlobalBdds( Abc_Ntk_t * pNtkNew, DdManager * dd, DdNode
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcCut.c b/src/base/abci/abcCut.c
index cc97796f..e80ddb92 100644
--- a/src/base/abci/abcCut.c
+++ b/src/base/abci/abcCut.c
@@ -21,6 +21,9 @@
#include "abc.h"
#include "cut.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -155,7 +158,7 @@ Cut_Man_t * Abc_NtkCuts( Abc_Ntk_t * pNtk, Cut_Params_t * pParams )
vNodes = Abc_AigDfs( pNtk, 0, 1 ); // collects POs
vChoices = Vec_IntAlloc( 100 );
pProgress = Extra_ProgressBarStart( stdout, Vec_PtrSize(vNodes) );
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
{
// when we reached a CO, it is time to deallocate the cuts
if ( Abc_ObjIsCo(pObj) )
@@ -180,7 +183,7 @@ Cut_Man_t * Abc_NtkCuts( Abc_Ntk_t * pNtk, Cut_Params_t * pParams )
if ( Abc_AigNodeIsChoice(pObj) )
{
Vec_IntClear( vChoices );
- for ( pNode = pObj; pNode; pNode = pNode->pData )
+ for ( pNode = pObj; pNode; pNode = (Abc_Obj_t *)pNode->pData )
Vec_IntPush( vChoices, pNode->Id );
Cut_NodeUnionCuts( p, vChoices );
}
@@ -233,7 +236,7 @@ void Abc_NtkCutsOracle( Abc_Ntk_t * pNtk, Cut_Oracle_t * p )
// compute cuts for internal nodes
vNodes = Abc_AigDfs( pNtk, 0, 1 ); // collects POs
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
{
// when we reached a CO, it is time to deallocate the cuts
if ( Abc_ObjIsCo(pObj) )
@@ -429,7 +432,7 @@ void * Abc_NodeGetCuts( void * p, Abc_Obj_t * pObj, int fDag, int fTree )
// check if the node is a DAG node
fDagNode = (Abc_ObjFanoutNum(pObj) > 1 && !Abc_NodeIsMuxControlType(pObj));
// increment the counter of DAG nodes
- if ( fDagNode ) Cut_ManIncrementDagNodes( p );
+ if ( fDagNode ) Cut_ManIncrementDagNodes( (Cut_Man_t *)p );
// add the trivial cut if the node is a DAG node, or if we compute all cuts
fTriv = fDagNode || !fDag;
// check if fanins are DAG nodes
@@ -444,12 +447,12 @@ void * Abc_NodeGetCuts( void * p, Abc_Obj_t * pObj, int fDag, int fTree )
// changes due to the global/local cut computation
{
- Cut_Params_t * pParams = Cut_ManReadParams(p);
+ Cut_Params_t * pParams = Cut_ManReadParams((Cut_Man_t *)p);
if ( pParams->fLocal )
{
- Vec_Int_t * vNodeAttrs = Cut_ManReadNodeAttrs(p);
+ Vec_Int_t * vNodeAttrs = Cut_ManReadNodeAttrs((Cut_Man_t *)p);
fDagNode = Vec_IntEntry( vNodeAttrs, pObj->Id );
- if ( fDagNode ) Cut_ManIncrementDagNodes( p );
+ if ( fDagNode ) Cut_ManIncrementDagNodes( (Cut_Man_t *)p );
// fTriv = fDagNode || !pParams->fGlobal;
fTriv = !Vec_IntEntry( vNodeAttrs, pObj->Id );
TreeCode = 0;
@@ -459,7 +462,7 @@ void * Abc_NodeGetCuts( void * p, Abc_Obj_t * pObj, int fDag, int fTree )
TreeCode |= (Vec_IntEntry( vNodeAttrs, pFanin->Id ) << 1);
}
}
- return Cut_NodeComputeCuts( p, pObj->Id, Abc_ObjFaninId0(pObj), Abc_ObjFaninId1(pObj),
+ return Cut_NodeComputeCuts( (Cut_Man_t *)p, pObj->Id, Abc_ObjFaninId0(pObj), Abc_ObjFaninId1(pObj),
Abc_ObjFaninC0(pObj), Abc_ObjFaninC1(pObj), fTriv, TreeCode );
}
@@ -500,7 +503,7 @@ void Abc_NodeGetCutsSeq( void * p, Abc_Obj_t * pObj, int fTriv )
***********************************************************************/
void * Abc_NodeReadCuts( void * p, Abc_Obj_t * pObj )
{
- return Cut_NodeReadCutsNew( p, pObj->Id );
+ return Cut_NodeReadCutsNew( (Cut_Man_t *)p, pObj->Id );
}
/**Function*************************************************************
@@ -516,7 +519,7 @@ void * Abc_NodeReadCuts( void * p, Abc_Obj_t * pObj )
***********************************************************************/
void Abc_NodeFreeCuts( void * p, Abc_Obj_t * pObj )
{
- Cut_NodeFreeCuts( p, pObj->Id );
+ Cut_NodeFreeCuts( (Cut_Man_t *)p, pObj->Id );
}
/**Function*************************************************************
@@ -538,7 +541,7 @@ void Abc_NtkPrintCuts( void * p, Abc_Ntk_t * pNtk, int fSeq )
printf( "Cuts of the network:\n" );
Abc_NtkForEachObj( pNtk, pObj, i )
{
- pList = Abc_NodeReadCuts( p, pObj );
+ pList = (Cut_Cut_t *)Abc_NodeReadCuts( (Cut_Man_t *)p, pObj );
printf( "Node %s:\n", Abc_ObjName(pObj) );
Cut_CutPrintList( pList, fSeq );
}
@@ -560,7 +563,7 @@ void Abc_NtkPrintCuts_( void * p, Abc_Ntk_t * pNtk, int fSeq )
Cut_Cut_t * pList;
Abc_Obj_t * pObj;
pObj = Abc_NtkObj( pNtk, 2 * Abc_NtkObjNum(pNtk) / 3 );
- pList = Abc_NodeReadCuts( p, pObj );
+ pList = (Cut_Cut_t *)Abc_NodeReadCuts( (Cut_Man_t *)p, pObj );
printf( "Node %s:\n", Abc_ObjName(pObj) );
Cut_CutPrintList( pList, fSeq );
}
@@ -616,7 +619,7 @@ Vec_Int_t * Abc_NtkGetNodeAttributes( Abc_Ntk_t * pNtk )
if ( Vec_IntEntry( vAttrs, pObj->Id ) )
{
vNodes = Abc_NodeMffcInsideCollect( pObj );
- Vec_PtrForEachEntry( vNodes, pTemp, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pTemp, k )
if ( pTemp != pObj )
Vec_IntWriteEntry( vAttrs, pTemp->Id, 0 );
Vec_PtrFree( vNodes );
@@ -689,3 +692,5 @@ Vec_Int_t * Abc_NtkGetNodeAttributes2( Abc_Ntk_t * pNtk )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcDar.c b/src/base/abci/abcDar.c
index dbe98631..31ef986c 100644
--- a/src/base/abci/abcDar.c
+++ b/src/base/abci/abcDar.c
@@ -19,6 +19,7 @@
***********************************************************************/
#include "abc.h"
+#include "main.h"
#include "giaAig.h"
#include "saig.h"
#include "dar.h"
@@ -29,11 +30,14 @@
#include "dch.h"
#include "ssw.h"
#include "cgt.h"
-//#include "fsim.h"
+#include "bbr.h"
#include "gia.h"
#include "cec.h"
+#include "csw.h"
#include "giaAbs.h"
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -100,6 +104,7 @@ Aig_Man_t * Abc_NtkToDar( Abc_Ntk_t * pNtk, int fExors, int fRegisters )
// create the manager
pMan = Aig_ManStart( Abc_NtkNodeNum(pNtk) + 100 );
pMan->fCatchExor = fExors;
+ pMan->nConstrs = pNtk->nConstrs;
pMan->pName = Extra_UtilStrsav( pNtk->pName );
// transfer the pointers to the basic nodes
@@ -174,6 +179,7 @@ Aig_Man_t * Abc_NtkToDarChoices( Abc_Ntk_t * pNtk )
// create the manager
pMan = Aig_ManStart( Abc_NtkNodeNum(pNtk) + 100 );
pMan->pName = Extra_UtilStrsav( pNtk->pName );
+ pMan->nConstrs = pNtk->nConstrs;
if ( Abc_NtkGetChoiceNum(pNtk) )
{
pMan->pEquivs = ABC_ALLOC( Aig_Obj_t *, Abc_NtkObjNum(pNtk) );
@@ -184,13 +190,13 @@ Aig_Man_t * Abc_NtkToDarChoices( Abc_Ntk_t * pNtk )
Abc_NtkForEachCi( pNtk, pObj, i )
pObj->pCopy = (Abc_Obj_t *)Aig_ObjCreatePi(pMan);
// perform the conversion of the internal nodes (assumes DFS ordering)
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
{
pObj->pCopy = (Abc_Obj_t *)Aig_And( pMan, (Aig_Obj_t *)Abc_ObjChild0Copy(pObj), (Aig_Obj_t *)Abc_ObjChild1Copy(pObj) );
// printf( "%d->%d ", pObj->Id, ((Aig_Obj_t *)pObj->pCopy)->Id );
if ( Abc_AigNodeIsChoice( pObj ) )
{
- for ( pPrev = pObj, pFanin = pObj->pData; pFanin; pPrev = pFanin, pFanin = pFanin->pData )
+ for ( pPrev = pObj, pFanin = (Abc_Obj_t *)pObj->pData; pFanin; pPrev = pFanin, pFanin = (Abc_Obj_t *)pFanin->pData )
Aig_ObjSetEquiv( pMan, (Aig_Obj_t *)pPrev->pCopy, (Aig_Obj_t *)pFanin->pCopy );
// Aig_ManCreateChoice( pIfMan, (Aig_Obj_t *)pNode->pCopy );
}
@@ -232,17 +238,18 @@ Abc_Ntk_t * Abc_NtkFromDar( Abc_Ntk_t * pNtkOld, Aig_Man_t * pMan )
// assert( Aig_ManRegNum(pMan) == Abc_NtkLatchNum(pNtkOld) );
// perform strashing
pNtkNew = Abc_NtkStartFrom( pNtkOld, ABC_NTK_STRASH, ABC_FUNC_AIG );
+ pNtkNew->nConstrs = pMan->nConstrs;
// transfer the pointers to the basic nodes
Aig_ManConst1(pMan)->pData = Abc_AigConst1(pNtkNew);
Aig_ManForEachPi( pMan, pObj, i )
pObj->pData = Abc_NtkCi(pNtkNew, i);
// rebuild the AIG
vNodes = Aig_ManDfs( pMan, 1 );
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
if ( Aig_ObjIsBuf(pObj) )
pObj->pData = (Abc_Obj_t *)Aig_ObjChild0Copy(pObj);
else
- pObj->pData = Abc_AigAnd( pNtkNew->pManFunc, (Abc_Obj_t *)Aig_ObjChild0Copy(pObj), (Abc_Obj_t *)Aig_ObjChild1Copy(pObj) );
+ pObj->pData = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, (Abc_Obj_t *)Aig_ObjChild0Copy(pObj), (Abc_Obj_t *)Aig_ObjChild1Copy(pObj) );
Vec_PtrFree( vNodes );
// connect the PO nodes
Aig_ManForEachPo( pMan, pObj, i )
@@ -287,6 +294,7 @@ Abc_Ntk_t * Abc_NtkFromDarSeqSweep( Abc_Ntk_t * pNtkOld, Aig_Man_t * pMan )
// assert( Aig_ManRegNum(pMan) != Abc_NtkLatchNum(pNtkOld) );
// perform strashing
pNtkNew = Abc_NtkStartFromNoLatches( pNtkOld, ABC_NTK_STRASH, ABC_FUNC_AIG );
+ pNtkNew->nConstrs = pMan->nConstrs;
// consider the case of target enlargement
if ( Abc_NtkCiNum(pNtkNew) < Aig_ManPiNum(pMan) - Aig_ManRegNum(pMan) )
{
@@ -309,17 +317,17 @@ Abc_Ntk_t * Abc_NtkFromDarSeqSweep( Abc_Ntk_t * pNtkOld, Aig_Man_t * pMan )
pObjNew = Abc_NtkCreateLatch( pNtkNew );
pObjLi->pData = Abc_NtkCreateBi( pNtkNew );
pObjLo->pData = Abc_NtkCreateBo( pNtkNew );
- Abc_ObjAddFanin( pObjNew, pObjLi->pData );
- Abc_ObjAddFanin( pObjLo->pData, pObjNew );
+ Abc_ObjAddFanin( pObjNew, (Abc_Obj_t *)pObjLi->pData );
+ Abc_ObjAddFanin( (Abc_Obj_t *)pObjLo->pData, pObjNew );
Abc_LatchSetInit0( pObjNew );
}
// rebuild the AIG
vNodes = Aig_ManDfs( pMan, 1 );
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
if ( Aig_ObjIsBuf(pObj) )
pObj->pData = (Abc_Obj_t *)Aig_ObjChild0Copy(pObj);
else
- pObj->pData = Abc_AigAnd( pNtkNew->pManFunc, (Abc_Obj_t *)Aig_ObjChild0Copy(pObj), (Abc_Obj_t *)Aig_ObjChild1Copy(pObj) );
+ pObj->pData = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, (Abc_Obj_t *)Aig_ObjChild0Copy(pObj), (Abc_Obj_t *)Aig_ObjChild1Copy(pObj) );
Vec_PtrFree( vNodes );
// connect the PO nodes
Aig_ManForEachPo( pMan, pObj, i )
@@ -412,6 +420,7 @@ Abc_Ntk_t * Abc_NtkFromAigPhase( Aig_Man_t * pMan )
assert( pMan->nAsserts == 0 );
// perform strashing
pNtkNew = Abc_NtkAlloc( ABC_NTK_STRASH, ABC_FUNC_AIG, 1 );
+ pNtkNew->nConstrs = pMan->nConstrs;
// duplicate the name and the spec
// pNtkNew->pName = Extra_UtilStrsav(pMan->pName);
// pNtkNew->pSpec = Extra_UtilStrsav(pMan->pSpec);
@@ -438,19 +447,19 @@ Abc_Ntk_t * Abc_NtkFromAigPhase( Aig_Man_t * pMan )
pObjNew = Abc_NtkCreateLatch( pNtkNew );
pObjLi->pData = Abc_NtkCreateBi( pNtkNew );
pObjLo->pData = Abc_NtkCreateBo( pNtkNew );
- Abc_ObjAddFanin( pObjNew, pObjLi->pData );
- Abc_ObjAddFanin( pObjLo->pData, pObjNew );
+ Abc_ObjAddFanin( pObjNew, (Abc_Obj_t *)pObjLi->pData );
+ Abc_ObjAddFanin( (Abc_Obj_t *)pObjLo->pData, pObjNew );
Abc_LatchSetInit0( pObjNew );
- Abc_ObjAssignName( pObjLi->pData, Abc_ObjName(pObjLi->pData), NULL );
- Abc_ObjAssignName( pObjLo->pData, Abc_ObjName(pObjLo->pData), NULL );
+ Abc_ObjAssignName( (Abc_Obj_t *)pObjLi->pData, Abc_ObjName((Abc_Obj_t *)pObjLi->pData), NULL );
+ Abc_ObjAssignName( (Abc_Obj_t *)pObjLo->pData, Abc_ObjName((Abc_Obj_t *)pObjLo->pData), NULL );
}
// rebuild the AIG
vNodes = Aig_ManDfs( pMan, 1 );
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
if ( Aig_ObjIsBuf(pObj) )
pObj->pData = (Abc_Obj_t *)Aig_ObjChild0Copy(pObj);
else
- pObj->pData = Abc_AigAnd( pNtkNew->pManFunc, (Abc_Obj_t *)Aig_ObjChild0Copy(pObj), (Abc_Obj_t *)Aig_ObjChild1Copy(pObj) );
+ pObj->pData = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, (Abc_Obj_t *)Aig_ObjChild0Copy(pObj), (Abc_Obj_t *)Aig_ObjChild1Copy(pObj) );
Vec_PtrFree( vNodes );
// connect the PO nodes
Aig_ManForEachPo( pMan, pObj, i )
@@ -490,6 +499,7 @@ Abc_Ntk_t * Abc_NtkAfterTrim( Aig_Man_t * pMan, Abc_Ntk_t * pNtkOld )
assert( pMan->vCiNumsOrig != NULL );
// perform strashing
pNtkNew = Abc_NtkAlloc( ABC_NTK_STRASH, ABC_FUNC_AIG, 1 );
+ pNtkNew->nConstrs = pMan->nConstrs;
// duplicate the name and the spec
// pNtkNew->pName = Extra_UtilStrsav(pMan->pName);
// pNtkNew->pSpec = Extra_UtilStrsav(pMan->pSpec);
@@ -520,23 +530,23 @@ Abc_Ntk_t * Abc_NtkAfterTrim( Aig_Man_t * pMan, Abc_Ntk_t * pNtkOld )
pObjNew = Abc_NtkCreateLatch( pNtkNew );
pObjLi->pData = Abc_NtkCreateBi( pNtkNew );
pObjLo->pData = Abc_NtkCreateBo( pNtkNew );
- Abc_ObjAddFanin( pObjNew, pObjLi->pData );
- Abc_ObjAddFanin( pObjLo->pData, pObjNew );
+ Abc_ObjAddFanin( pObjNew, (Abc_Obj_t *)pObjLi->pData );
+ Abc_ObjAddFanin( (Abc_Obj_t *)pObjLo->pData, pObjNew );
Abc_LatchSetInit0( pObjNew );
// find the name
pObjOld = Abc_NtkCi( pNtkOld, Vec_IntEntry(pMan->vCiNumsOrig, Saig_ManPiNum(pMan)+i) );
- Abc_ObjAssignName( pObjLo->pData, Abc_ObjName(pObjOld), NULL );
+ Abc_ObjAssignName( (Abc_Obj_t *)pObjLo->pData, Abc_ObjName(pObjOld), NULL );
// find the name
pObjOld = Abc_NtkCo( pNtkOld, Saig_ManPoNum(pMan)+i );
- Abc_ObjAssignName( pObjLi->pData, Abc_ObjName(pObjOld), NULL );
+ Abc_ObjAssignName( (Abc_Obj_t *)pObjLi->pData, Abc_ObjName(pObjOld), NULL );
}
// rebuild the AIG
vNodes = Aig_ManDfs( pMan, 1 );
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
if ( Aig_ObjIsBuf(pObj) )
pObj->pData = (Abc_Obj_t *)Aig_ObjChild0Copy(pObj);
else
- pObj->pData = Abc_AigAnd( pNtkNew->pManFunc, (Abc_Obj_t *)Aig_ObjChild0Copy(pObj), (Abc_Obj_t *)Aig_ObjChild1Copy(pObj) );
+ pObj->pData = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, (Abc_Obj_t *)Aig_ObjChild0Copy(pObj), (Abc_Obj_t *)Aig_ObjChild1Copy(pObj) );
Vec_PtrFree( vNodes );
// connect the PO nodes
Aig_ManForEachPo( pMan, pObj, i )
@@ -546,7 +556,7 @@ Abc_Ntk_t * Abc_NtkAfterTrim( Aig_Man_t * pMan, Abc_Ntk_t * pNtkOld )
}
// check the resulting AIG
if ( !Abc_NtkCheck( pNtkNew ) )
- fprintf( stdout, "Abc_NtkFromAigPhase(): Network check has failed.\n" );
+ fprintf( stdout, "Abc_NtkAfterTrim(): Network check has failed.\n" );
return pNtkNew;
}
@@ -571,6 +581,7 @@ Abc_Ntk_t * Abc_NtkFromDarChoices( Abc_Ntk_t * pNtkOld, Aig_Man_t * pMan )
assert( Aig_ManBufNum(pMan) == 0 );
// perform strashing
pNtkNew = Abc_NtkStartFrom( pNtkOld, ABC_NTK_STRASH, ABC_FUNC_AIG );
+ pNtkNew->nConstrs = pMan->nConstrs;
// transfer the pointers to the basic nodes
Aig_ManConst1(pMan)->pData = Abc_AigConst1(pNtkNew);
Aig_ManForEachPi( pMan, pObj, i )
@@ -578,15 +589,15 @@ Abc_Ntk_t * Abc_NtkFromDarChoices( Abc_Ntk_t * pNtkOld, Aig_Man_t * pMan )
// rebuild the AIG
vNodes = Aig_ManDfsChoices( pMan );
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, 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( (Abc_Aig_t *)pNtkNew->pManFunc, (Abc_Obj_t *)Aig_ObjChild0Copy(pObj), (Abc_Obj_t *)Aig_ObjChild1Copy(pObj) );
if ( (pTemp = Aig_ObjEquiv(pMan, pObj)) )
{
Abc_Obj_t * pAbcRepr, * pAbcObj;
assert( pTemp->pData != NULL );
- pAbcRepr = pObj->pData;
- pAbcObj = pTemp->pData;
+ pAbcRepr = (Abc_Obj_t *)pObj->pData;
+ pAbcObj = (Abc_Obj_t *)pTemp->pData;
pAbcObj->pData = pAbcRepr->pData;
pAbcRepr->pData = pAbcObj;
}
@@ -622,6 +633,7 @@ Abc_Ntk_t * Abc_NtkFromDarSeq( Abc_Ntk_t * pNtkOld, Aig_Man_t * pMan )
// assert( Aig_ManLatchNum(pMan) > 0 );
// perform strashing
pNtkNew = Abc_NtkStartFromNoLatches( pNtkOld, ABC_NTK_STRASH, ABC_FUNC_AIG );
+ pNtkNew->nConstrs = pMan->nConstrs;
// transfer the pointers to the basic nodes
Aig_ManConst1(pMan)->pData = Abc_AigConst1(pNtkNew);
Aig_ManForEachPi( pMan, pObj, i )
@@ -640,7 +652,7 @@ Abc_Ntk_t * Abc_NtkFromDarSeq( Abc_Ntk_t * pNtkOld, Aig_Man_t * pMan )
Abc_NtkAddDummyBoxNames( pNtkNew );
// rebuild the AIG
vNodes = Aig_ManDfs( pMan, 1 );
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
{
// add the first fanin
pObj->pData = pFaninNew0 = (Abc_Obj_t *)Aig_ObjChild0Copy(pObj);
@@ -650,9 +662,9 @@ Abc_Ntk_t * Abc_NtkFromDarSeq( Abc_Ntk_t * pNtkOld, Aig_Man_t * pMan )
pFaninNew1 = (Abc_Obj_t *)Aig_ObjChild1Copy(pObj);
// create the new node
if ( Aig_ObjIsExor(pObj) )
- pObj->pData = pObjNew = Abc_AigXor( pNtkNew->pManFunc, pFaninNew0, pFaninNew1 );
+ pObj->pData = pObjNew = Abc_AigXor( (Abc_Aig_t *)pNtkNew->pManFunc, pFaninNew0, pFaninNew1 );
else
- pObj->pData = pObjNew = Abc_AigAnd( pNtkNew->pManFunc, pFaninNew0, pFaninNew1 );
+ pObj->pData = pObjNew = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, pFaninNew0, pFaninNew1 );
}
Vec_PtrFree( vNodes );
// connect the PO nodes
@@ -665,7 +677,7 @@ Abc_Ntk_t * Abc_NtkFromDarSeq( Abc_Ntk_t * pNtkOld, Aig_Man_t * pMan )
Aig_ManForEachObj( pMan, pObj, i )
{
pFaninNew = (Abc_Obj_t *)Aig_ObjChild0Copy( pObj );
- Abc_ObjAddFanin( Abc_ObjFanin0(Abc_ObjFanin0(pObj->pData)), pFaninNew );
+ Abc_ObjAddFanin( Abc_ObjFanin0(Abc_ObjFanin0((Abc_Obj_t *)pObj->pData)), pFaninNew );
}
if ( !Abc_NtkCheck( pNtkNew ) )
fprintf( stdout, "Abc_NtkFromIvySeq(): Network check has failed.\n" );
@@ -860,7 +872,7 @@ Abc_Ntk_t * Abc_NtkDarFraigPart( Abc_Ntk_t * pNtk, int nPartSize, int nConfLimit
***********************************************************************/
Abc_Ntk_t * Abc_NtkCSweep( Abc_Ntk_t * pNtk, int nCutsMax, int nLeafMax, int fVerbose )
{
- extern Aig_Man_t * Csw_Sweep( Aig_Man_t * pAig, int nCutsMax, int nLeafMax, int fVerbose );
+// extern Aig_Man_t * Csw_Sweep( Aig_Man_t * pAig, int nCutsMax, int nLeafMax, int fVerbose );
Abc_Ntk_t * pNtkAig;
Aig_Man_t * pMan, * pTemp;
pMan = Abc_NtkToDar( pNtk, 0, 0 );
@@ -1026,7 +1038,7 @@ Abc_Ntk_t * Abc_NtkDChoice( Abc_Ntk_t * pNtk, int fBalance, int fUpdateLevel, in
***********************************************************************/
Abc_Ntk_t * Abc_NtkDch( Abc_Ntk_t * pNtk, Dch_Pars_t * pPars )
{
- extern Gia_Man_t * Dar_NewChoiceSynthesis( Aig_Man_t * pAig, int fBalance, int fUpdateLevel, int fPower, int fVerbose );
+ extern Gia_Man_t * Dar_NewChoiceSynthesis( Aig_Man_t * pAig, int fBalance, int fUpdateLevel, int fPower, int fLightSynth, int fVerbose );
extern Aig_Man_t * Cec_ComputeChoices( Gia_Man_t * pGia, Dch_Pars_t * pPars );
Aig_Man_t * pMan, * pTemp;
@@ -1039,7 +1051,7 @@ Abc_Ntk_t * Abc_NtkDch( Abc_Ntk_t * pNtk, Dch_Pars_t * pPars )
return NULL;
clk = clock();
if ( pPars->fSynthesis )
- pGia = Dar_NewChoiceSynthesis( pMan, 1, 1, pPars->fPower, 0 );
+ pGia = Dar_NewChoiceSynthesis( pMan, 1, 1, pPars->fPower, pPars->fLightSynth, pPars->fVerbose );
else
{
pGia = Gia_ManFromAig( pMan );
@@ -1121,23 +1133,23 @@ Abc_Ntk_t * Abc_NtkConstructFromCnf( Abc_Ntk_t * pNtk, Cnf_Man_t * p, Vec_Ptr_t
Aig_ManPi(p->pManAig, i)->pData = pNode->pCopy;
// process the nodes in topological order
vCover = Vec_IntAlloc( 1 << 16 );
- Vec_PtrForEachEntry( vMapped, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vMapped, pObj, i )
{
// create new node
pNodeNew = Abc_NtkCreateNode( pNtkNew );
// add fanins according to the cut
- pCut = pObj->pData;
+ pCut = (Cnf_Cut_t *)pObj->pData;
Cnf_CutForEachLeaf( p->pManAig, pCut, pLeaf, k )
- Abc_ObjAddFanin( pNodeNew, pLeaf->pData );
+ Abc_ObjAddFanin( pNodeNew, (Abc_Obj_t *)pLeaf->pData );
// add logic function
if ( pCut->nFanins < 5 )
{
uTruth = 0xFFFF & *Cnf_CutTruth(pCut);
Cnf_SopConvertToVector( p->pSops[uTruth], p->pSopSizes[uTruth], vCover );
- pNodeNew->pData = Abc_SopCreateFromIsop( pNtkNew->pManFunc, pCut->nFanins, vCover );
+ pNodeNew->pData = Abc_SopCreateFromIsop( (Extra_MmFlex_t *)pNtkNew->pManFunc, pCut->nFanins, vCover );
}
else
- pNodeNew->pData = Abc_SopCreateFromIsop( pNtkNew->pManFunc, pCut->nFanins, pCut->vIsop[1] );
+ pNodeNew->pData = Abc_SopCreateFromIsop( (Extra_MmFlex_t *)pNtkNew->pManFunc, pCut->nFanins, pCut->vIsop[1] );
// save the node
pObj->pData = pNodeNew;
}
@@ -1146,7 +1158,7 @@ Abc_Ntk_t * Abc_NtkConstructFromCnf( Abc_Ntk_t * pNtk, Cnf_Man_t * p, Vec_Ptr_t
Abc_NtkForEachCo( pNtk, pNode, i )
{
pObj = Aig_ManPo(p->pManAig, i);
- pNodeNew = Abc_ObjNotCond( Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0(pObj) );
+ pNodeNew = Abc_ObjNotCond( (Abc_Obj_t *)Aig_ObjFanin0(pObj)->pData, Aig_ObjFaninC0(pObj) );
Abc_ObjAddFanin( pNode->pCopy, pNodeNew );
}
@@ -1240,7 +1252,7 @@ int Abc_NtkDSat( Abc_Ntk_t * pNtk, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit
assert( Abc_NtkPoNum(pNtk) == 1 );
pMan = Abc_NtkToDar( pNtk, 0, 0 );
RetValue = Fra_FraigSat( pMan, nConfLimit, nInsLimit, fAlignPol, fAndOuts, fVerbose );
- pNtk->pModel = pMan->pData, pMan->pData = NULL;
+ pNtk->pModel = (int *)pMan->pData, pMan->pData = NULL;
Aig_ManStop( pMan );
return RetValue;
}
@@ -1265,7 +1277,7 @@ int Abc_NtkPartitionedSat( Abc_Ntk_t * pNtk, int nAlgo, int nPartSize, int nConf
assert( Abc_NtkLatchNum(pNtk) == 0 );
pMan = Abc_NtkToDar( pNtk, 0, 0 );
RetValue = Aig_ManPartitionedSat( pMan, nAlgo, nPartSize, nConfPart, nConfTotal, fAlignPol, fSynthesize, fVerbose );
- pNtk->pModel = pMan->pData, pMan->pData = NULL;
+ pNtk->pModel = (int *)pMan->pData, pMan->pData = NULL;
Aig_ManStop( pMan );
return RetValue;
}
@@ -1362,7 +1374,7 @@ int Abc_NtkDarCec( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nConfLimit, int fPa
RetValue = Fra_FraigCec( &pMan, 100000, fVerbose );
// transfer model if given
if ( pNtk2 == NULL )
- pNtk1->pModel = pMan->pData, pMan->pData = NULL;
+ pNtk1->pModel = (int *)pMan->pData, pMan->pData = NULL;
Aig_ManStop( pMan );
finish:
@@ -1458,10 +1470,10 @@ ABC_PRT( "Initial fraiging time", clock() - clk );
***********************************************************************/
void Abc_NtkPrintLatchEquivClasses( Abc_Ntk_t * pNtk, Aig_Man_t * pAig )
{
- bool header_dumped = false;
+ int header_dumped = 0;
int num_orig_latches = Abc_NtkLatchNum(pNtk);
char **pNames = ABC_ALLOC( char *, num_orig_latches );
- bool *p_irrelevant = ABC_ALLOC( bool, num_orig_latches );
+ int *p_irrelevant = ABC_ALLOC( int, num_orig_latches );
char * pFlopName, * pReprName;
Aig_Obj_t * pFlop, * pRepr;
Abc_Obj_t * pNtkFlop;
@@ -1560,7 +1572,7 @@ Abc_Ntk_t * Abc_NtkDarSeqSweep2( Abc_Ntk_t * pNtk, Ssw_Pars_t * pPars )
if ( pPars->fFlopVerbose )
Abc_NtkPrintLatchEquivClasses(pNtk, pTemp);
- Aig_ManStop( pTemp );
+ Aig_ManStop( pTemp );
if ( pMan == NULL )
return NULL;
@@ -1681,7 +1693,7 @@ static void sigfunc( int signo )
SeeAlso []
***********************************************************************/
-int Abc_NtkDarBmc( Abc_Ntk_t * pNtk, int nStart, int nFrames, int nSizeMax, int nNodeDelta, int nTimeOut, int nBTLimit, int nBTLimitAll, int fRewrite, int fNewAlgo, int nCofFanLit, int fVerbose )
+int Abc_NtkDarBmc( Abc_Ntk_t * pNtk, int nStart, int nFrames, int nSizeMax, int nNodeDelta, int nTimeOut, int nBTLimit, int nBTLimitAll, int fRewrite, int fNewAlgo, int nCofFanLit, int fVerbose, int * piFrames )
{
Aig_Man_t * pMan;
int status, RetValue = -1, clk = clock();
@@ -1711,25 +1723,31 @@ int Abc_NtkDarBmc( Abc_Ntk_t * pNtk, int nStart, int nFrames, int nSizeMax, int
{
int iFrame;
RetValue = Saig_ManBmcSimple( pMan, nFrames, nSizeMax, nBTLimit, fRewrite, fVerbose, &iFrame, nCofFanLit );
+ if ( piFrames )
+ *piFrames = iFrame;
ABC_FREE( pNtk->pModel );
ABC_FREE( pNtk->pSeqModel );
pNtk->pSeqModel = pMan->pSeqModel; pMan->pSeqModel = NULL;
if ( RetValue == 1 )
- printf( "No output was asserted in %d frames. ", iFrame );
+ {
+// printf( "No output was asserted in %d frames. ", iFrame );
+ printf( "Incorrect return value. " );
+ }
else if ( RetValue == -1 )
printf( "No output was asserted in %d frames. Reached conflict limit (%d). ", iFrame, nBTLimit );
else // if ( RetValue == 0 )
{
-// extern void Aig_ManCounterExampleValueTest( Aig_Man_t * pAig, Fra_Cex_t * pCex );
+// extern void Aig_ManCounterExampleValueTest( Aig_Man_t * pAig, Abc_Cex_t * pCex );
- Fra_Cex_t * pCex = pNtk->pSeqModel;
+ Abc_Cex_t * pCex = pNtk->pSeqModel;
printf( "Output %d was asserted in frame %d (use \"write_counter\" to dump a witness). ", pCex->iPo, pCex->iFrame );
// Aig_ManCounterExampleValueTest( pMan, pCex );
}
+ABC_PRT( "Time", clock() - clk );
}
else
- {
+ {
/*
Fra_BmcPerformSimple( pMan, nFrames, nBTLimit, fRewrite, fVerbose );
ABC_FREE( pNtk->pModel );
@@ -1737,7 +1755,7 @@ int Abc_NtkDarBmc( Abc_Ntk_t * pNtk, int nStart, int nFrames, int nSizeMax, int
pNtk->pSeqModel = pMan->pSeqModel; pMan->pSeqModel = NULL;
if ( pNtk->pSeqModel )
{
- Fra_Cex_t * pCex = pNtk->pSeqModel;
+ Abc_Cex_t * pCex = pNtk->pSeqModel;
printf( "Output %d was asserted in frame %d (use \"write_counter\" to dump a witness). ", pCex->iPo, pCex->iFrame );
RetValue = 0;
}
@@ -1759,16 +1777,15 @@ int Abc_NtkDarBmc( Abc_Ntk_t * pNtk, int nStart, int nFrames, int nSizeMax, int
printf( "No output was asserted in %d frames. Reached conflict limit (%d). ", iFrame, nBTLimit );
else // if ( RetValue == 0 )
{
- Fra_Cex_t * pCex = pNtk->pSeqModel;
+ Abc_Cex_t * pCex = pNtk->pSeqModel;
printf( "Output %d was asserted in frame %d (use \"write_counter\" to dump a witness). ", pCex->iPo, pCex->iFrame );
}
*/
- Saig_BmcPerform( pMan, nStart, nFrames, nNodeDelta, nTimeOut, nBTLimit, nBTLimitAll, fVerbose, 0 );
+ RetValue = Saig_BmcPerform( pMan, nStart, nFrames, nNodeDelta, nTimeOut, nBTLimit, nBTLimitAll, fVerbose, 0, piFrames );
ABC_FREE( pNtk->pModel );
ABC_FREE( pNtk->pSeqModel );
pNtk->pSeqModel = pMan->pSeqModel; pMan->pSeqModel = NULL;
}
-ABC_PRT( "Time", clock() - clk );
// verify counter-example
if ( pNtk->pSeqModel )
{
@@ -1782,6 +1799,73 @@ ABC_PRT( "Time", clock() - clk );
/**Function*************************************************************
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_NtkDarBmc3( Abc_Ntk_t * pNtk, Saig_ParBmc_t * pPars )
+{
+ Aig_Man_t * pMan;
+ int status, RetValue = -1, clk = clock();
+ pMan = Abc_NtkToDar( pNtk, 0, 1 );
+ if ( pMan == NULL )
+ {
+ printf( "Converting miter into AIG has failed.\n" );
+ return RetValue;
+ }
+ assert( pMan->nRegs > 0 );
+ RetValue = Saig_ManBmcScalable( pMan, pPars );
+ ABC_FREE( pNtk->pModel );
+ ABC_FREE( pNtk->pSeqModel );
+ pNtk->pSeqModel = pMan->pSeqModel; pMan->pSeqModel = NULL;
+ if ( RetValue == 1 )
+ {
+// printf( "No output was asserted in %d frames. ", pPars->iFrame );
+ printf( "Incorrect return value. " );
+ }
+ else if ( RetValue == -1 )
+ {
+ if ( pPars->nFailOuts == 0 )
+ printf( "No output was asserted in %d frames. Reached conflict limit (%d). ", pPars->iFrame, pPars->nConfLimit );
+ else
+ {
+ printf( "The total of %d outputs was asserted in %d frames. Reached conflict limit (%d). ", pPars->nFailOuts, pPars->iFrame, pPars->nConfLimit );
+ if ( pNtk->pSeqModelVec )
+ Vec_PtrFreeFree( pNtk->pSeqModelVec );
+ pNtk->pSeqModelVec = pMan->pSeqModelVec; pMan->pSeqModelVec = NULL;
+ }
+ }
+ else // if ( RetValue == 0 )
+ {
+ if ( !pPars->fSolveAll )
+ {
+ Abc_Cex_t * pCex = pNtk->pSeqModel;
+ printf( "Output %d was asserted in frame %d (use \"write_counter\" to dump a witness). ", pCex->iPo, pCex->iFrame );
+ }
+ else
+ {
+ printf( "Incorrect return value. " );
+// printf( "At least one output was asserted (out=%d, frame=%d). ", pCex->iPo, pCex->iFrame );
+ }
+ }
+ ABC_PRT( "Time", clock() - clk );
+ if ( pNtk->pSeqModel )
+ {
+ status = Ssw_SmlRunCounterExample( pMan, pNtk->pSeqModel );
+ if ( status == 0 )
+ printf( "Abc_NtkDarBmc3(): Counter-example verification has FAILED.\n" );
+ }
+ Aig_ManStop( pMan );
+ return RetValue;
+}
+
+/**Function*************************************************************
+
Synopsis [Gives the current ABC network to AIG manager for processing.]
Description []
@@ -1791,10 +1875,13 @@ ABC_PRT( "Time", clock() - clk );
SeeAlso []
***********************************************************************/
-int Abc_NtkDarBmcInter_int( Aig_Man_t * pMan, Inter_ManParams_t * pPars )
+int Abc_NtkDarBmcInter_int( Aig_Man_t * pMan, Inter_ManParams_t * pPars, Aig_Man_t ** ppNtkRes )
{
int RetValue, iFrame, clk = clock();
+ int nTotalProvedSat = 0;
assert( pMan->nRegs > 0 );
+ if ( ppNtkRes )
+ *ppNtkRes = NULL;
if ( pPars->fUseSeparate )
{
Aig_Man_t * pTemp, * pAux;
@@ -1804,17 +1891,39 @@ int Abc_NtkDarBmcInter_int( Aig_Man_t * pMan, Inter_ManParams_t * pPars )
{
if ( Aig_ObjFanin0(pObjPo) == Aig_ManConst1(pMan) )
continue;
+ if ( pPars->fVerbose )
+ printf( "Solving output %2d (out of %2d):\n", i, Saig_ManPoNum(pMan) );
pTemp = Aig_ManDupOneOutput( pMan, i, 1 );
pTemp = Aig_ManScl( pAux = pTemp, 1, 1, 0 );
Aig_ManStop( pAux );
- RetValue = Inter_ManPerformInterpolation( pTemp, pPars, &iFrame );
+ if ( Aig_ManRegNum(pTemp) == 0 )
+ {
+ pTemp->pSeqModel = NULL;
+ RetValue = Fra_FraigSat( pTemp, pPars->nBTLimit, 0, 0, 0, 0 );
+ if ( pTemp->pData )
+ pTemp->pSeqModel = Gia_ManCreateFromComb( Aig_ManRegNum(pMan), Saig_ManPiNum(pMan), i, (int *)pTemp->pData );
+// pNtk->pModel = pTemp->pData, pTemp->pData = NULL;
+ }
+ else
+ RetValue = Inter_ManPerformInterpolation( pTemp, pPars, &iFrame );
if ( pTemp->pSeqModel )
{
- Ssw_Cex_t * pCex;
- pCex = pMan->pSeqModel = pTemp->pSeqModel; pTemp->pSeqModel = NULL;
- pCex->iPo = i;
- Aig_ManStop( pTemp );
- break;
+ if ( pPars->fDropSatOuts )
+ {
+ printf( "Output %d proved SAT in frame %d (replacing by const 0 and continuing...)\n", i, pTemp->pSeqModel->iFrame );
+ Aig_ObjPatchFanin0( pMan, pObjPo, Aig_ManConst0(pMan) );
+ Aig_ManStop( pTemp );
+ nTotalProvedSat++;
+ continue;
+ }
+ else
+ {
+ Abc_Cex_t * pCex;
+ pCex = pMan->pSeqModel = pTemp->pSeqModel; pTemp->pSeqModel = NULL;
+ pCex->iPo = i;
+ Aig_ManStop( pTemp );
+ break;
+ }
}
// if solved, remove the output
if ( RetValue == 1 )
@@ -1838,17 +1947,19 @@ int Abc_NtkDarBmcInter_int( Aig_Man_t * pMan, Inter_ManParams_t * pPars )
if ( Counter )
RetValue = -1;
}
-/*
- pMan = Aig_ManDupUnsolvedOutputs( pTemp = pMan, 1 );
- Aig_ManStop( pTemp );
- pMan = Aig_ManScl( pTemp = pMan, 1, 1, 0 );
- Aig_ManStop( pTemp );
-*/
+ if ( ppNtkRes )
+ {
+ pTemp = Aig_ManDupUnsolvedOutputs( pMan, 1 );
+ *ppNtkRes = Aig_ManScl( pTemp, 1, 1, 0 );
+ Aig_ManStop( pTemp );
+ }
}
else
{
RetValue = Inter_ManPerformInterpolation( pMan, pPars, &iFrame );
}
+ if ( nTotalProvedSat )
+ printf( "The total of %d outputs proved SAT and replaced by const 0 in this run.\n", nTotalProvedSat );
if ( RetValue == 1 )
printf( "Property proved. " );
else if ( RetValue == 0 )
@@ -1872,21 +1983,34 @@ ABC_PRT( "Time", clock() - clk );
SeeAlso []
***********************************************************************/
-int Abc_NtkDarBmcInter( Abc_Ntk_t * pNtk, Inter_ManParams_t * pPars )
+int Abc_NtkDarBmcInter( Abc_Ntk_t * pNtk, Inter_ManParams_t * pPars, Abc_Ntk_t ** ppNtkRes )
{
Aig_Man_t * pMan;
+ int RetValue;
+ if ( ppNtkRes )
+ *ppNtkRes = NULL;
pMan = Abc_NtkToDar( pNtk, 0, 1 );
if ( pMan == NULL )
{
printf( "Converting miter into AIG has failed.\n" );
return -1;
}
- Abc_NtkDarBmcInter_int( pMan, pPars );
+ if ( pPars->fUseSeparate && ppNtkRes )
+ {
+ Aig_Man_t * pManNew;
+ RetValue = Abc_NtkDarBmcInter_int( pMan, pPars, &pManNew );
+ *ppNtkRes = Abc_NtkFromAigPhase( pManNew );
+ Aig_ManStop( pManNew );
+ }
+ else
+ {
+ RetValue = Abc_NtkDarBmcInter_int( pMan, pPars, NULL );
+ }
ABC_FREE( pNtk->pModel );
ABC_FREE( pNtk->pSeqModel );
pNtk->pSeqModel = pMan->pSeqModel; pMan->pSeqModel = NULL;
Aig_ManStop( pMan );
- return 1;
+ return RetValue;
}
/**Function*************************************************************
@@ -1945,7 +2069,7 @@ int Abc_NtkDarDemiter( Abc_Ntk_t * pNtk )
int Abc_NtkDarProve( Abc_Ntk_t * pNtk, Fra_Sec_t * pSecPar )
{
Aig_Man_t * pMan;
- int RetValue, clkTotal = clock();
+ int RetValue = -1, clkTotal = clock();
if ( pSecPar->fTryComb || Abc_NtkLatchNum(pNtk) == 0 )
{
Prove_Params_t Params, * pParams = &Params;
@@ -1990,7 +2114,7 @@ int Abc_NtkDarProve( Abc_Ntk_t * pNtk, Fra_Sec_t * pSecPar )
}
if ( pSecPar->fTryBmc )
{
- RetValue = Abc_NtkDarBmc( pNtk, 0, 20, 100000, -1, 0, 2000, -1, 0, 1, 0, 0 );
+ RetValue = Abc_NtkDarBmc( pNtk, 0, 20, 100000, -1, 0, 2000, -1, 0, 1, 0, 0, NULL );
if ( RetValue == 0 )
{
printf( "Networks are not equivalent.\n" );
@@ -2023,7 +2147,7 @@ int Abc_NtkDarProve( Abc_Ntk_t * pNtk, Fra_Sec_t * pSecPar )
pNtk->pSeqModel = pMan->pSeqModel; pMan->pSeqModel = NULL;
if ( pNtk->pSeqModel )
{
- Fra_Cex_t * pCex = pNtk->pSeqModel;
+ Abc_Cex_t * pCex = pNtk->pSeqModel;
printf( "Output %d was asserted in frame %d (use \"write_counter\" to dump a witness).\n", pCex->iPo, pCex->iFrame );
if ( !Ssw_SmlRunCounterExample( pMan, pNtk->pSeqModel ) )
printf( "Abc_NtkDarProve(): Counter-example verification has FAILED.\n" );
@@ -2065,7 +2189,7 @@ int Abc_NtkDarSec( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, Fra_Sec_t * pSecPar )
printf( "Networks are NOT EQUIVALENT after structural hashing.\n" );
// report the error
pMiter->pModel = Abc_NtkVerifyGetCleanModel( pMiter, pSecPar->nFramesMax );
- Abc_NtkVerifyReportErrorSeq( pNtk1, pNtk2, pMiter->pModel, pSecPar->nFramesMax );
+// Abc_NtkVerifyReportErrorSeq( pNtk1, pNtk2, pMiter->pModel, pSecPar->nFramesMax );
ABC_FREE( pMiter->pModel );
Abc_NtkDelete( pMiter );
return 0;
@@ -2272,7 +2396,7 @@ Abc_Ntk_t * Abc_NtkDarMatch( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nDist, in
SeeAlso []
***********************************************************************/
-Abc_Ntk_t * Abc_NtkDarLatchSweep( Abc_Ntk_t * pNtk, int fLatchConst, int fLatchEqual, int fVerbose )
+Abc_Ntk_t * Abc_NtkDarLatchSweep( Abc_Ntk_t * pNtk, int fLatchConst, int fLatchEqual, int fSaveNames, int fVerbose )
{
extern void Aig_ManPrintControlFanouts( Aig_Man_t * p );
Abc_Ntk_t * pNtkAig;
@@ -2280,17 +2404,23 @@ Abc_Ntk_t * Abc_NtkDarLatchSweep( Abc_Ntk_t * pNtk, int fLatchConst, int fLatchE
pMan = Abc_NtkToDar( pNtk, 0, 1 );
if ( pMan == NULL )
return NULL;
-// Aig_ManSeqCleanup( pMan );
-// if ( fLatchConst && pMan->nRegs )
-// pMan = Aig_ManConstReduce( pMan, fVerbose );
-// if ( fLatchEqual && pMan->nRegs )
-// pMan = Aig_ManReduceLaches( pMan, fVerbose );
- if ( pMan->vFlopNums )
- Vec_IntFree( pMan->vFlopNums );
- pMan->vFlopNums = NULL;
+ if ( fSaveNames )
+ {
+ Aig_ManSeqCleanup( pMan );
+ if ( fLatchConst && pMan->nRegs )
+ pMan = Aig_ManConstReduce( pMan, fVerbose );
+ if ( fLatchEqual && pMan->nRegs )
+ pMan = Aig_ManReduceLaches( pMan, fVerbose );
+ }
+ else
+ {
+ if ( pMan->vFlopNums )
+ Vec_IntFree( pMan->vFlopNums );
+ pMan->vFlopNums = NULL;
+ pMan = Aig_ManScl( pTemp = pMan, fLatchConst, fLatchEqual, fVerbose );
+ Aig_ManStop( pTemp );
+ }
- pMan = Aig_ManScl( pTemp = pMan, fLatchConst, fLatchEqual, fVerbose );
- Aig_ManStop( pTemp );
pNtkAig = Abc_NtkFromDarSeqSweep( pNtk, pMan );
//Aig_ManPrintControlFanouts( pMan );
Aig_ManStop( pMan );
@@ -2512,12 +2642,12 @@ int Abc_NtkDarSeqSim( Abc_Ntk_t * pNtk, int nFrames, int nWords, int TimeOut, in
extern int Cec_ManSimulate( Aig_Man_t * pAig, int nWords, int nIters, int TimeLimit, int fMiter, int fVerbose );
extern int Raig_ManSimulate( Aig_Man_t * pAig, int nWords, int nIters, int TimeLimit, int fMiter, int fVerbose );
Aig_Man_t * pMan;
- Fra_Cex_t * pCex;
- int status, RetValue, clk = clock();
+ Abc_Cex_t * pCex;
+ int status, RetValue = -1, clk = clock();
if ( Abc_NtkGetChoiceNum(pNtk) )
{
printf( "Removing %d choices from the AIG.\n", Abc_NtkGetChoiceNum(pNtk) );
- Abc_AigCleanup(pNtk->pManFunc);
+ Abc_AigCleanup((Abc_Aig_t *)pNtk->pManFunc);
}
pMan = Abc_NtkToDar( pNtk, 0, 1 );
if ( fComb || Abc_NtkLatchNum(pNtk) == 0 )
@@ -2530,7 +2660,7 @@ int Abc_NtkDarSeqSim( Abc_Ntk_t * pNtk, int nFrames, int nWords, int TimeOut, in
{
printf( "Simulation iterated %d times with %d words asserted output %d in frame %d. ",
nFrames, nWords, pCex->iPo, pCex->iFrame );
- status = Ssw_SmlRunCounterExample( pMan, (Ssw_Cex_t *)pCex );
+ status = Ssw_SmlRunCounterExample( pMan, pCex );
if ( status == 0 )
printf( "Abc_NtkDarSeqSim(): Counter-example verification has FAILED.\n" );
}
@@ -2557,7 +2687,7 @@ int Abc_NtkDarSeqSim( Abc_Ntk_t * pNtk, int nFrames, int nWords, int TimeOut, in
{
printf( "Simulation of %d frames with %d words asserted output %d in frame %d. ",
nFrames, nWords, pCex->iPo, pCex->iFrame );
- status = Ssw_SmlRunCounterExample( pMan, (Ssw_Cex_t *)pCex );
+ status = Ssw_SmlRunCounterExample( pMan, pCex );
if ( status == 0 )
printf( "Abc_NtkDarSeqSim(): Counter-example verification has FAILED.\n" );
}
@@ -2587,7 +2717,7 @@ int Abc_NtkDarSeqSim( Abc_Ntk_t * pNtk, int nFrames, int nWords, int TimeOut, in
{
printf( "Simulation of %d frames with %d words asserted output %d in frame %d. ",
nFrames, nWords, pCex->iPo, pCex->iFrame );
- status = Ssw_SmlRunCounterExample( pMan, (Ssw_Cex_t *)pCex );
+ status = Ssw_SmlRunCounterExample( pMan, pCex );
if ( status == 0 )
printf( "Abc_NtkDarSeqSim(): Counter-example verification has FAILED.\n" );
}
@@ -2614,22 +2744,21 @@ int Abc_NtkDarSeqSim( Abc_Ntk_t * pNtk, int nFrames, int nWords, int TimeOut, in
pGia = Gia_ManFromAig( pMan );
if ( Gia_ManSimSimulate( pGia, pPars ) )
{
- if ( (pCex = (Fra_Cex_t *)pGia->pCexSeq) )
+ if ( pGia->pCexSeq )
{
printf( "Simulation of %d frames with %d words asserted output %d in frame %d. ",
- nFrames, nWords, pCex->iPo, pCex->iFrame );
- status = Ssw_SmlRunCounterExample( pMan, (Ssw_Cex_t *)pCex );
+ nFrames, nWords, pGia->pCexSeq->iPo, pGia->pCexSeq->iFrame );
+ status = Ssw_SmlRunCounterExample( pMan, pGia->pCexSeq );
if ( status == 0 )
printf( "Abc_NtkDarSeqSim(): Counter-example verification has FAILED.\n" );
}
ABC_FREE( pNtk->pModel );
ABC_FREE( pNtk->pSeqModel );
- pNtk->pSeqModel = pCex; pMan->pSeqModel = NULL;
- RetValue = 1;
+ pNtk->pSeqModel = pGia->pCexSeq; pGia->pCexSeq = NULL;
+ RetValue = 0;
}
else
{
- RetValue = 0;
printf( "Simulation of %d frames with %d words did not assert the outputs. ",
nFrames, nWords );
}
@@ -2646,18 +2775,17 @@ int Abc_NtkDarSeqSim( Abc_Ntk_t * pNtk, int nFrames, int nWords, int TimeOut, in
{
printf( "Simulation of %d frames with %d words asserted output %d in frame %d. ",
nFrames, nWords, pCex->iPo, pCex->iFrame );
- status = Ssw_SmlRunCounterExample( pMan, (Ssw_Cex_t *)pCex );
+ status = Ssw_SmlRunCounterExample( pMan, pCex );
if ( status == 0 )
printf( "Abc_NtkDarSeqSim(): Counter-example verification has FAILED.\n" );
}
ABC_FREE( pNtk->pModel );
ABC_FREE( pNtk->pSeqModel );
pNtk->pSeqModel = pCex;
- RetValue = 1;
+ RetValue = 0;
}
else
{
- RetValue = 0;
printf( "Simulation of %d frames with %d words did not assert the outputs. ",
nFrames, nWords );
}
@@ -2669,7 +2797,7 @@ int Abc_NtkDarSeqSim( Abc_Ntk_t * pNtk, int nFrames, int nWords, int TimeOut, in
{
printf( "Simulation of %d frames with %d words asserted output %d in frame %d. ",
nFrames, nWords, pCex->iPo, pCex->iFrame );
- status = Ssw_SmlRunCounterExample( pMan, (Ssw_Cex_t *)pCex );
+ status = Ssw_SmlRunCounterExample( pMan, pCex );
if ( status == 0 )
printf( "Abc_NtkDarSeqSim(): Counter-example verification has FAILED.\n" );
}
@@ -2762,15 +2890,15 @@ Abc_Ntk_t * Abc_NtkDarEnlarge( Abc_Ntk_t * pNtk, int nFrames, int fVerbose )
SeeAlso []
***********************************************************************/
-void Abc_NtkDarInduction( Abc_Ntk_t * pNtk, int nFramesMax, int nConfMax, int fVerbose )
-{
+int Abc_NtkDarInduction( Abc_Ntk_t * pNtk, int nFramesMax, int nConfMax, int fUnique, int fUniqueAll, int fVerbose, int fVeryVerbose )
+{
Aig_Man_t * pMan, * pTemp;
int clkTotal = clock();
int RetValue;
pMan = Abc_NtkToDar( pNtk, 0, 1 );
if ( pMan == NULL )
- return;
- RetValue = Saig_ManInduction( pTemp = pMan, nFramesMax, nConfMax, fVerbose );
+ return -1;
+ RetValue = Saig_ManInduction( pTemp = pMan, nFramesMax, nConfMax, fUnique, fUniqueAll, fVerbose, fVeryVerbose );
Aig_ManStop( pTemp );
if ( RetValue == 1 )
{
@@ -2787,6 +2915,7 @@ ABC_PRT( "Time", clock() - clkTotal );
printf( "Networks are UNDECIDED. " );
ABC_PRT( "Time", clock() - clkTotal );
}
+ return RetValue;
}
@@ -2801,7 +2930,7 @@ ABC_PRT( "Time", clock() - clkTotal );
SeeAlso []
***********************************************************************/
-Abc_Ntk_t * Abc_NtkDarPBAbstraction( Abc_Ntk_t * pNtk, Gia_ParAbs_t * pPars )
+Abc_Ntk_t * Abc_NtkDarCegar( Abc_Ntk_t * pNtk, Gia_ParAbs_t * pPars )
{
Abc_Ntk_t * pNtkAig;
Aig_Man_t * pMan, * pTemp;
@@ -2810,8 +2939,29 @@ Abc_Ntk_t * Abc_NtkDarPBAbstraction( Abc_Ntk_t * pNtk, Gia_ParAbs_t * pPars )
if ( pMan == NULL )
return NULL;
- Aig_ManSetRegNum( pMan, pMan->nRegs );
- pMan = Saig_ManProofAbstraction( pTemp = pMan, pPars );
+ if ( pPars->fConstr )
+ {
+ printf( "This option is currently not implemented.\n" );
+ Aig_ManStop( pMan );
+ return NULL;
+ }
+ if ( pPars->fConstr )
+ {
+ if ( Saig_ManDetectConstrTest(pMan) )
+ {
+ printf( "Performing abstraction while dynamically adding constraints...\n" );
+ pMan = Saig_ManDupUnfoldConstrs( pTemp = pMan );
+ Aig_ManStop( pTemp );
+ pMan = Saig_ManConCexAbstraction( pTemp = pMan, pPars );
+ }
+ else
+ {
+ printf( "Constraints are not available. Performing abstraction w/o constraints.\n" );
+ pMan = Saig_ManCexAbstraction( pTemp = pMan, pPars );
+ }
+ }
+ else
+ pMan = Saig_ManCexAbstraction( pTemp = pMan, pPars );
if ( pTemp->pSeqModel )
{
ABC_FREE( pNtk->pModel );
@@ -3024,16 +3174,17 @@ void Abc_NtkPrintSccs( Abc_Ntk_t * pNtk, int fVerbose )
SeeAlso []
***********************************************************************/
-void Abc_NtkDarPrintCone( Abc_Ntk_t * pNtk )
+int Abc_NtkDarPrintCone( Abc_Ntk_t * pNtk )
{
extern void Saig_ManPrintCones( Aig_Man_t * pAig );
Aig_Man_t * pMan;
pMan = Abc_NtkToDar( pNtk, 0, 1 );
if ( pMan == NULL )
- return;
+ return 0;
assert( Aig_ManRegNum(pMan) > 0 );
Saig_ManPrintCones( pMan );
Aig_ManStop( pMan );
+ return 1;
}
/**Function*************************************************************
@@ -3114,6 +3265,33 @@ Abc_Ntk_t * Abc_NtkPhaseAbstract( Abc_Ntk_t * pNtk, int nFrames, int nPref, int
SeeAlso []
***********************************************************************/
+int Abc_NtkPhaseFrameNum( Abc_Ntk_t * pNtk )
+{
+ extern int Saig_ManPhaseFrameNum( Aig_Man_t * p, Vec_Int_t * vInits );
+ Vec_Int_t * vInits;
+ Aig_Man_t * pMan;
+ int nFrames;
+ pMan = Abc_NtkToDar( pNtk, 0, 1 );
+ if ( pMan == NULL )
+ return 1;
+ vInits = Abc_NtkGetLatchValues(pNtk);
+ nFrames = Saig_ManPhaseFrameNum( pMan, vInits );
+ Vec_IntFree( vInits );
+ Aig_ManStop( pMan );
+ return nFrames;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs phase abstraction.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
Abc_Ntk_t * Abc_NtkDarSynchOne( Abc_Ntk_t * pNtk, int nWords, int fVerbose )
{
extern Aig_Man_t * Saig_SynchSequenceApply( Aig_Man_t * pAig, int nWords, int fVerbose );
@@ -3406,23 +3584,29 @@ Abc_Ntk_t * Abc_NtkDarCleanupAig( Abc_Ntk_t * pNtk, int fCleanupPis, int fCleanu
SeeAlso []
***********************************************************************/
-void Abc_NtkDarReach( Abc_Ntk_t * pNtk, int nBddMax, int nIterMax, int fPartition, int fReorder, int fReorderImage, int fVerbose )
+int Abc_NtkDarReach( Abc_Ntk_t * pNtk, Saig_ParBbr_t * pPars )
{
- extern int Aig_ManVerifyUsingBdds( Aig_Man_t * p, int nBddMax, int nIterMax, int fPartition, int fReorder, int fReorderImage, int fVerbose, int fSilent );
Aig_Man_t * pMan;
+ int RetValue;
pMan = Abc_NtkToDar( pNtk, 0, 1 );
if ( pMan == NULL )
- return;
- Aig_ManVerifyUsingBdds( pMan, nBddMax, nIterMax, fPartition, fReorder, fReorderImage, fVerbose, 0 );
+ return -1;
+ RetValue = Aig_ManVerifyUsingBdds( pMan, pPars );
ABC_FREE( pNtk->pModel );
ABC_FREE( pNtk->pSeqModel );
pNtk->pSeqModel = pMan->pSeqModel; pMan->pSeqModel = NULL;
Aig_ManStop( pMan );
+ return RetValue;
}
+ABC_NAMESPACE_IMPL_END
+
#include "amap.h"
#include "mio.h"
+ABC_NAMESPACE_IMPL_START
+
+
/**Function*************************************************************
Synopsis []
@@ -3436,15 +3620,15 @@ void Abc_NtkDarReach( Abc_Ntk_t * pNtk, int nBddMax, int nIterMax, int fPartitio
***********************************************************************/
Abc_Ntk_t * Amap_ManProduceNetwork( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMapping )
{
- extern void * Abc_FrameReadLibGen();
- Mio_Library_t * pLib = Abc_FrameReadLibGen();
+// extern void * Abc_FrameReadLibGen();
+ Mio_Library_t * pLib = (Mio_Library_t *)Abc_FrameReadLibGen();
Amap_Out_t * pRes;
Vec_Ptr_t * vNodesNew;
Abc_Ntk_t * pNtkNew;
Abc_Obj_t * pNodeNew, * pFaninNew;
int i, k, iPis, iPos, nDupGates;
// make sure gates exist in the current library
- Vec_PtrForEachEntry( vMapping, pRes, i )
+ Vec_PtrForEachEntry( Amap_Out_t *, vMapping, pRes, i )
if ( pRes->pName && Mio_LibraryReadGateByName( pLib, pRes->pName ) == NULL )
{
printf( "Current library does not contain gate \"%s\".\n", pRes->pName );
@@ -3455,7 +3639,7 @@ Abc_Ntk_t * Amap_ManProduceNetwork( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMapping )
pNtkNew->pManFunc = pLib;
iPis = iPos = 0;
vNodesNew = Vec_PtrAlloc( Vec_PtrSize(vMapping) );
- Vec_PtrForEachEntry( vMapping, pRes, i )
+ Vec_PtrForEachEntry( Amap_Out_t *, vMapping, pRes, i )
{
if ( pRes->Type == -1 )
pNodeNew = Abc_NtkCi( pNtkNew, iPis++ );
@@ -3468,7 +3652,7 @@ Abc_Ntk_t * Amap_ManProduceNetwork( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMapping )
}
for ( k = 0; k < pRes->nFans; k++ )
{
- pFaninNew = Vec_PtrEntry( vNodesNew, pRes->pFans[k] );
+ pFaninNew = (Abc_Obj_t *)Vec_PtrEntry( vNodesNew, pRes->pFans[k] );
Abc_ObjAddFanin( pNodeNew, pFaninNew );
}
Vec_PtrPush( vNodesNew, pNodeNew );
@@ -3477,7 +3661,7 @@ Abc_Ntk_t * Amap_ManProduceNetwork( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMapping )
assert( iPis == Abc_NtkCiNum(pNtkNew) );
assert( iPos == Abc_NtkCoNum(pNtkNew) );
// decouple the PO driver nodes to reduce the number of levels
- nDupGates = Abc_NtkLogicMakeSimpleCos( pNtkNew, 1 );
+ nDupGates = Abc_NtkLogicMakeSimpleCos( pNtkNew, 0 );
// if ( nDupGates && Map_ManReadVerbose(pMan) )
// printf( "Duplicated %d gates to decouple the CO drivers.\n", nDupGates );
return pNtkNew;
@@ -3513,7 +3697,7 @@ Abc_Ntk_t * Abc_NtkDarAmap( Abc_Ntk_t * pNtk, Amap_Par_t * pPars )
Aig_ManStop( pMan );
if ( vMapping == NULL )
return NULL;
- pMem = Vec_PtrPop( vMapping );
+ pMem = (Aig_MmFlex_t *)Vec_PtrPop( vMapping );
pNtkAig = Amap_ManProduceNetwork( pNtk, vMapping );
Aig_MmFlexStop( pMem, 0 );
Vec_PtrFree( vMapping );
@@ -3539,8 +3723,149 @@ Abc_Ntk_t * Abc_NtkDarAmap( Abc_Ntk_t * pNtk, Amap_Par_t * pPars )
SeeAlso []
***********************************************************************/
+void Abc_NtkDarConstr( Abc_Ntk_t * pNtk, int nFrames, int nConfs, int nProps, int fStruct, int fOldAlgo, int fVerbose )
+{
+ Aig_Man_t * pMan;//, * pMan2;//, * pTemp;
+ assert( Abc_NtkIsStrash(pNtk) );
+ pMan = Abc_NtkToDar( pNtk, 0, 1 );
+ if ( pMan == NULL )
+ return;
+ if ( fStruct )
+ Saig_ManDetectConstrTest( pMan );
+ else
+ Saig_ManDetectConstrFuncTest( pMan, nFrames, nConfs, nProps, fOldAlgo, fVerbose );
+ Aig_ManStop( pMan );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs BDD-based reachability analysis.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Abc_Ntk_t * Abc_NtkDarUnfold( Abc_Ntk_t * pNtk, int nFrames, int nConfs, int nProps, int fStruct, int fOldAlgo, int fVerbose )
+{
+ Abc_Ntk_t * pNtkAig;
+ Aig_Man_t * pMan, * pTemp;
+ assert( Abc_NtkIsStrash(pNtk) );
+ pMan = Abc_NtkToDar( pNtk, 0, 1 );
+ if ( pMan == NULL )
+ return NULL;
+ if ( fStruct )
+ pMan = Saig_ManDupUnfoldConstrs( pTemp = pMan );
+ else
+ pMan = Saig_ManDupUnfoldConstrsFunc( pTemp = pMan, nFrames, nConfs, nProps, fOldAlgo, fVerbose );
+ Aig_ManStop( pTemp );
+ if ( pMan == NULL )
+ return NULL;
+ pNtkAig = Abc_NtkFromAigPhase( pMan );
+ pNtkAig->pName = Extra_UtilStrsav(pMan->pName);
+ pNtkAig->pSpec = Extra_UtilStrsav(pMan->pSpec);
+ Aig_ManStop( pMan );
+ return pNtkAig;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs BDD-based reachability analysis.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Abc_Ntk_t * Abc_NtkDarFold( Abc_Ntk_t * pNtk, int fCompl, int fVerbose )
+{
+ Abc_Ntk_t * pNtkAig;
+ Aig_Man_t * pMan, * pTemp;
+ assert( Abc_NtkIsStrash(pNtk) );
+ pMan = Abc_NtkToDar( pNtk, 0, 1 );
+ if ( pMan == NULL )
+ return NULL;
+ pMan = Saig_ManDupFoldConstrsFunc( pTemp = pMan, fCompl, fVerbose );
+ Aig_ManStop( pTemp );
+ pNtkAig = Abc_NtkFromAigPhase( pMan );
+ pNtkAig->pName = Extra_UtilStrsav(pMan->pName);
+ pNtkAig->pSpec = Extra_UtilStrsav(pMan->pSpec);
+ Aig_ManStop( pMan );
+ return pNtkAig;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs BDD-based reachability analysis.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Abc_NtkDarConstrProfile( Abc_Ntk_t * pNtk, int fVerbose )
+{
+ extern int Ssw_ManProfileConstraints( Aig_Man_t * p, int nWords, int nFrames, int fVerbose );
+ extern Vec_Int_t * Saig_ManComputeSwitchProbs( Aig_Man_t * p, int nFrames, int nPref, int fProbOne );
+ Aig_Man_t * pMan;
+// Vec_Int_t * vProbOne;
+// Aig_Obj_t * pObj;
+// int i, Entry;
+ assert( Abc_NtkIsStrash(pNtk) );
+ assert( Abc_NtkConstrNum(pNtk) );
+ pMan = Abc_NtkToDar( pNtk, 0, 1 );
+ if ( pMan == NULL )
+ return;
+ // value in the init state
+// Abc_AigSetNodePhases( pNtk );
+/*
+ // derive probabilities
+ vProbOne = Saig_ManComputeSwitchProbs( pMan, 48, 16, 1 );
+ // iterate over the constraint outputs
+ Saig_ManForEachPo( pMan, pObj, i )
+ {
+ Entry = Vec_IntEntry( vProbOne, Aig_ObjId(pObj) );
+ if ( i < Saig_ManPoNum(pMan) - Saig_ManConstrNum(pMan) )
+ printf( "Primary output : ", i );
+ else
+ printf( "Constraint %3d : ", i-(Saig_ManPoNum(pMan) - Saig_ManConstrNum(pMan)) );
+ printf( "ProbOne = %f ", Aig_Int2Float(Entry) );
+ printf( "AllZeroValue = %d ", Aig_ObjPhase(pObj) );
+ printf( "\n" );
+ }
+*/
+ // double-check
+ Ssw_ManProfileConstraints( pMan, 16, 64, 1 );
+ printf( "TwoFrameSatValue = %d.\n", Ssw_ManSetConstrPhases(pMan, 2, NULL) );
+ // clean up
+// Vec_IntFree( vProbOne );
+ Aig_ManStop( pMan );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs BDD-based reachability analysis.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
void Abc_NtkDarTest( Abc_Ntk_t * pNtk )
{
+// extern void Saig_ManDetectConstr( Aig_Man_t * p );
+// extern void Saig_ManDetectConstrFuncTest( Aig_Man_t * p );
+ extern void Saig_ManFoldConstrTest( Aig_Man_t * pAig );
+
+
// extern void Fsim_ManTest( Aig_Man_t * pAig );
extern Vec_Int_t * Saig_StrSimPerformMatching( Aig_Man_t * p0, Aig_Man_t * p1, int nDist, int fVerbose, Aig_Man_t ** ppMiter );
// Vec_Int_t * vPairs;
@@ -3571,8 +3896,24 @@ Aig_ManPrintStats( pMan );
Aig_ManStop( pMan );
Aig_ManStop( pMan2 );
*/
+// Ioa_WriteAigerBufferTest( pMan, "test.aig", 0, 0 );
+// Saig_ManFoldConstrTest( pMan );
+ {
+ extern void Saig_ManBmcSectionsTest( Aig_Man_t * p );
+ extern void Saig_ManBmcTerSimTest( Aig_Man_t * p );
+ extern void Saig_ManBmcSupergateTest( Aig_Man_t * p );
+ extern void Saig_ManBmcMappingTest( Aig_Man_t * p );
+// Saig_ManBmcSectionsTest( pMan );
+// Saig_ManBmcTerSimTest( pMan );
+// Saig_ManBmcSupergateTest( pMan );
+// Saig_ManBmcMappingTest( pMan );
+ }
+
+
// Saig_MvManSimulate( pMan, 1 );
+// Saig_ManDetectConstr( pMan );
+// Saig_ManDetectConstrFuncTest( pMan );
// Fsim_ManTest( pMan );
Aig_ManStop( pMan );
@@ -3624,7 +3965,7 @@ Abc_Ntk_t * Abc_NtkDarTestNtk( Abc_Ntk_t * pNtk )
return NULL;
/*
Aig_ManSetRegNum( pMan, pMan->nRegs );
- pMan = Saig_ManProofAbstraction( pTemp = pMan, 5, 10000, 0, 0, 0, -1, -1, 99, fUseBdds, fUseDprove, 0, 1 );
+ pMan = Saig_ManCexAbstraction( pTemp = pMan, 5, 10000, 0, 0, 0, -1, -1, 99, fUseBdds, fUseDprove, 0, 1 );
Aig_ManStop( pTemp );
if ( pMan == NULL )
return NULL;
@@ -3642,7 +3983,6 @@ Abc_Ntk_t * Abc_NtkDarTestNtk( Abc_Ntk_t * pNtk )
Aig_ManStop( pMan );
*/
-
pNtkAig = Abc_NtkFromDar( pNtk, pMan );
Aig_ManStop( pMan );
@@ -3655,3 +3995,5 @@ Abc_Ntk_t * Abc_NtkDarTestNtk( Abc_Ntk_t * pNtk )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcDebug.c b/src/base/abci/abcDebug.c
index 6d8d9bfa..43ceb63a 100644
--- a/src/base/abci/abcDebug.c
+++ b/src/base/abci/abcDebug.c
@@ -19,6 +19,10 @@
***********************************************************************/
#include "abc.h"
+#include "ioAbc.h"
+
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -27,8 +31,6 @@
static int Abc_NtkCountFaninsTotal( Abc_Ntk_t * pNtk );
static Abc_Ntk_t * Abc_NtkAutoDebugModify( Abc_Ntk_t * pNtk, int ObjNum, int fConst1 );
-extern void Io_WriteBlifLogic( Abc_Ntk_t * pNtk, char * FileName, int fWriteLatches );
-
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
@@ -206,3 +208,5 @@ Abc_Ntk_t * Abc_NtkAutoDebugModify( Abc_Ntk_t * pNtkInit, int Step, int fConst1
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcDprove2.c b/src/base/abci/abcDprove2.c
new file mode 100644
index 00000000..7d432612
--- /dev/null
+++ b/src/base/abci/abcDprove2.c
@@ -0,0 +1,405 @@
+/**CFile****************************************************************
+
+ FileName [abcDprove2.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Network and node package.]
+
+ Synopsis [Implementation of "dprove2".]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: abcDprove2.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "abc.h"
+#include "aig.h"
+#include "saig.h"
+#include "fra.h"
+#include "ssw.h"
+#include "gia.h"
+#include "giaAig.h"
+#include "cec.h"
+#include "int.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+extern int Abc_NtkDarBmcInter_int( Aig_Man_t * pMan, Inter_ManParams_t * pPars );
+
+extern Aig_Man_t * Abc_NtkToDar( Abc_Ntk_t * pNtk, int fExors, int fRegisters );
+extern Abc_Ntk_t * Abc_NtkFromDar( Abc_Ntk_t * pNtkOld, Aig_Man_t * pMan );
+extern Abc_Ntk_t * Abc_NtkFromAigPhase( Aig_Man_t * pMan );
+extern int Abc_NtkDarProve( Abc_Ntk_t * pNtk, Fra_Sec_t * pSecPar );
+
+extern void * Abc_FrameReadSave1();
+extern void * Abc_FrameReadSave2();
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Implements model checking based on abstraction and speculation.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_NtkDProve2( Abc_Ntk_t * pNtk, int nConfLast, int fSeparate, int fVeryVerbose, int fVerbose )
+{
+ Abc_Ntk_t * pNtk2;
+ Aig_Man_t * pMan, * pTemp;
+ Aig_Man_t * pSave1 = NULL;
+ Gia_Man_t * pGia, * pSrm;
+ int spectried = 0;
+ int absquit = 0;
+ int absfail = 0;
+ int RetValue = -1;
+ int clkTotal = clock();
+ // derive the AIG manager
+ ABC_FREE( pNtk->pModel );
+ ABC_FREE( pNtk->pSeqModel );
+ pMan = Abc_NtkToDar( pNtk, 0, 1 );
+ if ( pMan == NULL )
+ {
+ printf( "Converting miter into AIG has failed.\n" );
+ return RetValue;
+ }
+ assert( pMan->nRegs > 0 );
+
+ if ( fVerbose )
+ {
+ printf( "Starting BMC...\n" );
+ Aig_ManPrintStats( pMan );
+ }
+ // bmc2 -C 10000
+ {
+ int nFrames = 2000;
+ int nNodeDelta = 2000;
+ int nBTLimit = 10000; // different from default
+ int nBTLimitAll = 2000000;
+ Saig_BmcPerform( pMan, 0, nFrames, nNodeDelta, 0, nBTLimit, nBTLimitAll, fVeryVerbose, 0, NULL );
+ pNtk->pSeqModel = pMan->pSeqModel; pMan->pSeqModel = NULL;
+ if ( pNtk->pSeqModel )
+ goto finish;
+ }
+
+ if ( fVerbose )
+ {
+ printf( "Starting \"dprove\"...\n" );
+ Aig_ManPrintStats( pMan );
+ }
+ // dprove -r -F 8
+ {
+ Fra_Sec_t SecPar, * pSecPar = &SecPar;
+ Fra_SecSetDefaultParams( pSecPar );
+ pSecPar->fTryBmc ^= 1;
+ pSecPar->fRetimeFirst ^= 1;
+ pSecPar->nFramesMax = 8;
+ pSecPar->fInterSeparate = 0; //fSeparate;
+ pSecPar->fVerbose = fVeryVerbose;
+ RetValue = Abc_NtkDarProve( pNtk, pSecPar );
+ // analize the result
+ if ( RetValue != -1 )
+ goto finish;
+ }
+ Aig_ManStop( pMan );
+ pSave1 = (Aig_Man_t *)Abc_FrameReadSave1();
+ pMan = Aig_ManDupSimple( pSave1 );
+
+ // abstraction
+
+ if ( fVerbose )
+ {
+ printf( "Abstraction...\n" );
+ Aig_ManPrintStats( pMan );
+ }
+abstraction:
+ {
+ Gia_ParAbs_t Pars, * pPars = &Pars;
+ Gia_ManAbsSetDefaultParams( pPars );
+ pPars->nConfMaxBmc = 25000;
+ pPars->nRatio = 2;
+ pPars->fVerbose = fVeryVerbose;
+/*
+ int nFramesMax = 10;
+ int nConfMax = 10000;
+ int fDynamic = 1;
+ int fExtend = 0;
+ int fSkipProof = 0;
+ int nFramesBmc = 2000;
+ int nConfMaxBmc = 25000; // default 5000;
+ int nRatio = 2; // default 10;
+ int fUseBdds = 0;
+ int fUseDprove = 0;
+ int fVerbose = fVeryVerbose;
+ fExtend ^= 1;
+ fSkipProof ^= 1;
+*/
+ pMan = Saig_ManCexAbstraction( pTemp = pMan, pPars );
+ // if abstractin has solved the problem
+ if ( pTemp->pSeqModel )
+ {
+ pNtk->pSeqModel = pTemp->pSeqModel; pTemp->pSeqModel = NULL;
+ Aig_ManStop( pTemp );
+ goto finish;
+ }
+ Aig_ManStop( pTemp );
+ if ( pMan == NULL ) // abstraction quits
+ {
+ absquit = 1;
+ pMan = Aig_ManDupSimple( pSave1 );
+ goto speculation;
+ }
+ }
+ if ( fVerbose )
+ {
+ printf( "Problem before trimming...\n" );
+ Aig_ManPrintStats( pMan );
+ }
+ // trim off useless primary inputs
+ pMan = Aig_ManDupTrim( pTemp = pMan );
+ Aig_ManStop( pTemp );
+ if ( fVerbose )
+ {
+ printf( "\"dprove\" after abstraction...\n" );
+ Aig_ManPrintStats( pMan );
+ }
+ // dprove -r -F 8
+ {
+ Fra_Sec_t SecPar, * pSecPar = &SecPar;
+ Fra_SecSetDefaultParams( pSecPar );
+ pSecPar->fTryBmc ^= 1;
+ pSecPar->fRetimeFirst ^= 1;
+ pSecPar->nFramesMax = 8;
+ pSecPar->fInterSeparate = 0; //fSeparate;
+ pSecPar->fVerbose = fVeryVerbose;
+ // convert pMan into pNtk
+ pNtk2 = Abc_NtkFromAigPhase( pMan );
+ RetValue = Abc_NtkDarProve( pNtk2, pSecPar );
+ Abc_NtkDelete( pNtk2 );
+ // analize the result
+ if ( RetValue == 1 )
+ goto finish;
+ if ( RetValue == 0 )
+ {
+ // transfer the counter-example!!!
+ goto finish;
+ }
+ assert( RetValue == -1 );
+ Aig_ManStop( pMan );
+ pMan = (Aig_Man_t *)Abc_FrameReadSave1(); // save2
+ }
+
+speculation:
+ if ( spectried )
+ goto finalbmc;
+ spectried = 1;
+
+ if ( fVerbose )
+ {
+ printf( "Speculation...\n" );
+ Aig_ManPrintStats( pMan );
+ }
+ // convert AIG into GIA
+// pGia = Gia_ManFromAigSimple( pMan ); // DID NOT WORK!
+ pGia = Gia_ManFromAig( pMan );
+ Aig_ManStop( pMan );
+ // &get, eclass,
+ {
+ Cec_ParSim_t Pars, * pPars = &Pars;
+ Cec_ManSimSetDefaultParams( pPars );
+ pPars->fSeqSimulate ^= 1;
+ pPars->nWords = 255;
+ pPars->nFrames = 1000;
+ Cec_ManSimulation( pGia, pPars );
+ }
+ // (spech)* where spech = &srm; restore save3; bmc2 -F 100 -C 25000; &resim
+ while ( 1 )
+ {
+ // perform speculative reduction
+ pSrm = Gia_ManSpecReduce( pGia, 0, 0, fVeryVerbose ); // save3
+// Gia_ManPrintStats( pGia, 0 );
+// Gia_ManPrintStats( pSrm, 0 );
+ // bmc2 -F 100 -C 25000
+ {
+ Abc_Cex_t * pCex;
+ int nFrames = 100; // different from default
+ int nNodeDelta = 2000;
+ int nBTLimit = 25000; // different from default
+ int nBTLimitAll = 2000000;
+ pTemp = Gia_ManToAig( pSrm, 0 );
+// Aig_ManPrintStats( pTemp );
+ Gia_ManStop( pSrm );
+ Saig_BmcPerform( pTemp, 0, nFrames, nNodeDelta, 0, nBTLimit, nBTLimitAll, fVeryVerbose, 0, NULL );
+ pCex = pTemp->pSeqModel; pTemp->pSeqModel = NULL;
+ Aig_ManStop( pTemp );
+ if ( pCex == NULL )
+ break;
+ // perform simulation
+ {
+ Cec_ParSim_t Pars, * pPars = &Pars;
+ Cec_ManSimSetDefaultParams( pPars );
+ Cec_ManSeqResimulateCounter( pGia, pPars, pCex );
+ ABC_FREE( pCex );
+ }
+ }
+ }
+ Gia_ManStop( pGia );
+ // speculatively reduced model is available in pTemp
+ // trim off useless primary inputs
+ if ( fVerbose )
+ {
+ printf( "Problem before trimming...\n" );
+ Aig_ManPrintStats( pTemp );
+ }
+ pMan = Aig_ManDupTrim( pTemp );
+ Aig_ManStop( pTemp );
+ if ( fVerbose )
+ {
+ printf( "After speculation...\n" );
+ Aig_ManPrintStats( pMan );
+ }
+/*
+ // solve the speculatively reduced model
+ // dprove -r -F 8
+ {
+ Fra_Sec_t SecPar, * pSecPar = &SecPar;
+ Fra_SecSetDefaultParams( pSecPar );
+ pSecPar->fTryBmc ^= 1;
+ pSecPar->fRetimeFirst ^= 1;
+ pSecPar->nFramesMax = 8;
+ pSecPar->fVerbose = fVeryVerbose;
+ pSecPar->fInterSeparate = 0; //fSeparate;
+ // convert pMan into pNtk
+ pNtk2 = Abc_NtkFromAigPhase( pMan );
+ RetValue = Abc_NtkDarProve( pNtk2, pSecPar );
+ Abc_NtkDelete( pNtk2 );
+ // analize the result
+ if ( RetValue == 1 )
+ goto finish;
+ if ( RetValue == 0 )
+ goto finalbmc;
+ // could not solve
+ Aig_ManStop( pMan );
+ pMan = Abc_FrameReadSave1(); // save4
+ if ( absquit || absfail )
+ goto abstraction;
+ }
+*/
+ // scorr; dc2; orpos; int -r -C 25000
+ {
+ Ssw_Pars_t Pars, * pPars = &Pars;
+ Ssw_ManSetDefaultParams( pPars );
+ pMan = Ssw_SignalCorrespondence( pTemp = pMan, pPars );
+ Aig_ManStop( pTemp );
+ if ( fVerbose )
+ {
+ printf( "After \"scorr\"...\n" );
+ Aig_ManPrintStats( pMan );
+ }
+ pMan = Dar_ManCompress2( pTemp = pMan, 1, 0, 1, 0, 0 );
+ Aig_ManStop( pTemp );
+ if ( fVerbose )
+ {
+ printf( "After \"dc2\"...\n" );
+ Aig_ManPrintStats( pMan );
+ }
+ }
+ {
+ Inter_ManParams_t Pars, * pPars = &Pars;
+ Inter_ManSetDefaultParams( pPars );
+ pPars->fUseSeparate = fSeparate;
+ pPars->fRewrite = 1;
+ pPars->nBTLimit = 25000;
+ if ( Saig_ManPoNum(pMan) > 1 && !fSeparate )
+ {
+ Aig_Man_t * pAux = Aig_ManDupSimple(pMan);
+ pTemp = Aig_ManDupOrpos( pAux, 1 );
+ RetValue = Abc_NtkDarBmcInter_int( pTemp, pPars );
+ Aig_ManStop( pTemp );
+ Aig_ManStop( pAux );
+ }
+ else
+ RetValue = Abc_NtkDarBmcInter_int( pMan, pPars );
+ // analize the result
+ if ( RetValue == 1 )
+ goto finish;
+ if ( RetValue == 0 )
+ goto finalbmc;
+ // could not solve
+// Aig_ManStop( pMan );
+// pMan = Abc_FrameReadSave1(); // save4
+ if ( absquit || absfail )
+ goto abstraction;
+ }
+
+finalbmc:
+ Aig_ManStop( pMan );
+ pMan = pSave1; pSave1 = NULL;
+ if ( fVerbose )
+ {
+ printf( "Final BMC...\n" );
+ Aig_ManPrintStats( pMan );
+ }
+ // bmc2 unlimited
+ {
+ int nFrames = 2000;
+ int nNodeDelta = 2000;
+ int nBTLimit = nConfLast; // different from default
+ int nBTLimitAll = 2000000;
+ Saig_BmcPerform( pMan, 0, nFrames, nNodeDelta, 0, nBTLimit, nBTLimitAll, fVeryVerbose, 0, NULL );
+ ABC_FREE( pNtk->pModel );
+ ABC_FREE( pNtk->pSeqModel );
+ pNtk->pSeqModel = pMan->pSeqModel; pMan->pSeqModel = NULL;
+ if ( pNtk->pSeqModel )
+ goto finish;
+ }
+
+finish:
+ if ( RetValue == 1 )
+ printf( "Networks are equivalent. " );
+ if ( RetValue == 0 )
+ printf( "Networks are not equivalent. " );
+ if ( RetValue == -1 )
+ printf( "Networks are UNDECIDED. " );
+ ABC_PRT( "Time", clock() - clkTotal );
+ if ( pNtk->pSeqModel )
+ printf( "Output %d was asserted in frame %d (use \"write_counter\" to dump a witness).\n", pNtk->pSeqModel->iPo, pNtk->pSeqModel->iFrame );
+ // verify counter-example
+ if ( pNtk->pSeqModel )
+ {
+ int status = Ssw_SmlRunCounterExample( pMan, pNtk->pSeqModel );
+ if ( status == 0 )
+ printf( "Abc_NtkDarBmc(): Counter-example verification has FAILED.\n" );
+ }
+ if ( pSave1 )
+ Aig_ManStop( pSave1 );
+ Aig_ManStop( pMan );
+ return RetValue;
+}
+
+
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcDress.c b/src/base/abci/abcDress.c
index f262a5d0..c9c956e4 100644
--- a/src/base/abci/abcDress.c
+++ b/src/base/abci/abcDress.c
@@ -21,6 +21,9 @@
#include "abc.h"
#include "ioAbc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -207,3 +210,5 @@ void Abc_NtkDressTransferNames( Abc_Ntk_t * pNtk, stmm_table * tMapping, int fVe
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcDress2.c b/src/base/abci/abcDress2.c
new file mode 100644
index 00000000..039a4fed
--- /dev/null
+++ b/src/base/abci/abcDress2.c
@@ -0,0 +1,435 @@
+/**CFile****************************************************************
+
+ FileName [abcDressw.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Network and node package.]
+
+ Synopsis [Transfers names from one netlist to the other.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: abcDressw.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "abc.h"
+#include "aig.h"
+#include "dch.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+/*
+ Procedure Abc_NtkDressComputeEquivs() implemented in this file computes
+ equivalence classes of objects of the two networks (pNtk1 and pNtk2).
+
+ It is possible that pNtk1 is the network before synthesis and pNtk2 is the
+ network after synthesis. The equiv classes of nodes from these networks
+ can be used to transfer the names from pNtk1 to pNtk2, or vice versa.
+
+ The above procedure returns the array (Vec_Ptr_t) of integer arrays (Vec_Int_t).
+ Each of the integer arrays contains entries of one equivalence class.
+ Each entry (EquivId) contains the following information:
+ (1) object ID, which is a number 'num', such that 0 <= 'num' < MaxId
+ where MaxId is the largest ID of nodes in a network
+ (2) the polarity of the node, which is a binary number, 0 or 1, giving
+ the node's value when pattern (000...0) is applied to the inputs
+ (3) the number of the network, 0 or 1, which stands for pNtk1 and pNtk2, respectively
+ The first array in the array of arrays is empty, or contains nodes that
+ are equivalent to a constant (if such nodes appear in the network).
+
+ Given EquivID defined above, use the APIs below to get its components.
+*/
+
+// declarations to be added to the application code
+extern int Abc_ObjEquivId2ObjId( int EquivId );
+extern int Abc_ObjEquivId2Polar( int EquivId );
+extern int Abc_ObjEquivId2NtkId( int EquivId );
+
+// definition that may remain in this file
+int Abc_ObjEquivId2ObjId( int EquivId ) { return EquivId >> 2; }
+int Abc_ObjEquivId2Polar( int EquivId ) { return (EquivId >> 1) & 1; }
+int Abc_ObjEquivId2NtkId( int EquivId ) { return EquivId & 1; }
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+extern Aig_Man_t * Abc_NtkToDar( Abc_Ntk_t * pNtk, int fExors, int fRegisters );
+extern void Dch_ComputeEquivalences( Aig_Man_t * pAig, Dch_Pars_t * pPars );
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Creates the dual output miter.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Man_t * Aig_ManCreateDualOutputMiter( Aig_Man_t * p1, Aig_Man_t * p2 )
+{
+ Aig_Man_t * pNew;
+ Aig_Obj_t * pObj;
+ int i;
+ assert( Aig_ManPiNum(p1) == Aig_ManPiNum(p2) );
+ assert( Aig_ManPoNum(p1) == Aig_ManPoNum(p2) );
+ pNew = Aig_ManStart( Aig_ManObjNumMax(p1) + Aig_ManObjNumMax(p2) );
+ // add first AIG
+ Aig_ManConst1(p1)->pData = Aig_ManConst1(pNew);
+ Aig_ManForEachPi( p1, pObj, i )
+ pObj->pData = Aig_ObjCreatePi( pNew );
+ Aig_ManForEachNode( p1, pObj, i )
+ pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
+ // add second AIG
+ Aig_ManConst1(p2)->pData = Aig_ManConst1(pNew);
+ Aig_ManForEachPi( p2, pObj, i )
+ pObj->pData = Aig_ManPi( pNew, i );
+ Aig_ManForEachNode( p2, pObj, i )
+ pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
+ // add the outputs
+ for ( i = 0; i < Aig_ManPoNum(p1); i++ )
+ {
+ Aig_ObjCreatePo( pNew, Aig_ObjChild0Copy(Aig_ManPo(p1, i)) );
+ Aig_ObjCreatePo( pNew, Aig_ObjChild0Copy(Aig_ManPo(p2, i)) );
+ }
+ Aig_ManCleanup( pNew );
+ return pNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Sets polarity attribute of each object in the network.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Abc_NtkDressMapSetPolarity( Abc_Ntk_t * pNtk )
+{
+ Abc_Obj_t * pObj, * pAnd;
+ int i;
+ // each node refers to the the strash copy whose polarity is set
+ Abc_NtkForEachObj( pNtk, pObj, i )
+ {
+ if ( (pAnd = Abc_ObjRegular(pObj->pCopy)) && Abc_ObjType(pAnd) != ABC_OBJ_NONE ) // strashed object is present and legal
+ pObj->fPhase = pAnd->fPhase ^ Abc_ObjIsComplement(pObj->pCopy);
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Create mapping of node IDs of pNtk into equiv classes of pMiter.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Abc_NtkDressMapClasses( Aig_Man_t * pMiter, Abc_Ntk_t * pNtk )
+{
+ Vec_Int_t * vId2Lit;
+ Abc_Obj_t * pObj, * pAnd;
+ Aig_Obj_t * pObjMan, * pObjMiter, * pObjRepr;
+ int i;
+ vId2Lit = Vec_IntAlloc( 0 );
+ Vec_IntFill( vId2Lit, Abc_NtkObjNumMax(pNtk), -1 );
+ Abc_NtkForEachNode( pNtk, pObj, i )
+ {
+ // get the pointer to the miter node corresponding to pObj
+ if ( (pAnd = Abc_ObjRegular(pObj->pCopy)) && Abc_ObjType(pAnd) != ABC_OBJ_NONE && // strashed node is present and legal
+ (pObjMan = Aig_Regular((Aig_Obj_t *)pAnd->pCopy)) && Aig_ObjType(pObjMan) != AIG_OBJ_NONE && // AIG node is present and legal
+ (pObjMiter = Aig_Regular((Aig_Obj_t *)pObjMan->pData)) && Aig_ObjType(pObjMiter) != AIG_OBJ_NONE ) // miter node is present and legal
+ {
+ // get the representative of the miter node
+ pObjRepr = Aig_ObjRepr( pMiter, pObjMiter );
+ pObjRepr = pObjRepr? pObjRepr : pObjMiter;
+ // map pObj (whose ID is i) into the repr node ID (i.e. equiv class)
+ Vec_IntWriteEntry( vId2Lit, i, Aig_ObjId(pObjRepr) );
+ }
+ }
+ return vId2Lit;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the vector of given equivalence class of objects.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Abc_ObjDressClass( Vec_Ptr_t * vRes, Vec_Int_t * vClass2Num, int Class )
+{
+ int ClassNumber;
+ assert( Class > 0 );
+ ClassNumber = Vec_IntEntry( vClass2Num, Class );
+ assert( ClassNumber != 0 );
+ if ( ClassNumber > 0 )
+ return (Vec_Int_t *)Vec_PtrEntry( vRes, ClassNumber ); // previous class
+ // create new class
+ Vec_IntWriteEntry( vClass2Num, Class, Vec_PtrSize(vRes) );
+ Vec_PtrPush( vRes, Vec_IntAlloc(4) );
+ return (Vec_Int_t *)Vec_PtrEntryLast( vRes );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the ID of a node in an equivalence class.]
+
+ Description [The ID is composed of three parts: object ID, followed
+ by one bit telling the phase of this node, followed by one bit
+ telling the network to which this node belongs.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_ObjDressMakeId( Abc_Ntk_t * pNtk, int ObjId, int iNtk )
+{
+ return (ObjId << 2) | (Abc_NtkObj(pNtk,ObjId)->fPhase << 1) | iNtk;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes equivalence classes of objects in pNtk1 and pNtk2.]
+
+ Description [Internal procedure.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Ptr_t * Abc_NtkDressMapIds( Aig_Man_t * pMiter, Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2 )
+{
+ Vec_Ptr_t * vRes;
+ Vec_Int_t * vId2Lit1, * vId2Lit2, * vCounts0, * vCounts1, * vClassC, * vClass2Num;
+ int i, Class;
+ // start the classes
+ vRes = Vec_PtrAlloc( 1000 );
+ // set polarity of the nodes
+ Abc_NtkDressMapSetPolarity( pNtk1 );
+ Abc_NtkDressMapSetPolarity( pNtk2 );
+ // create mapping of node IDs of pNtk1/pNtk2 into the IDs of equiv classes of pMiter
+ vId2Lit1 = Abc_NtkDressMapClasses( pMiter, pNtk1 );
+ vId2Lit2 = Abc_NtkDressMapClasses( pMiter, pNtk2 );
+ // count the number of nodes in each equivalence class
+ vCounts0 = Vec_IntStart( Aig_ManObjNumMax(pMiter) );
+ Vec_IntForEachEntry( vId2Lit1, Class, i )
+ if ( Class >= 0 )
+ Vec_IntAddToEntry( vCounts0, Class, 1 );
+ vCounts1 = Vec_IntStart( Aig_ManObjNumMax(pMiter) );
+ Vec_IntForEachEntry( vId2Lit2, Class, i )
+ if ( Class >= 0 )
+ Vec_IntAddToEntry( vCounts1, Class, 1 );
+ // get the costant class
+ vClassC = Vec_IntAlloc( 100 );
+ Vec_IntForEachEntry( vId2Lit1, Class, i )
+ if ( Class == 0 )
+ Vec_IntPush( vClassC, Abc_ObjDressMakeId(pNtk1, i, 0) );
+ Vec_IntForEachEntry( vId2Lit2, Class, i )
+ if ( Class == 0 )
+ Vec_IntPush( vClassC, Abc_ObjDressMakeId(pNtk2, i, 1) );
+ Vec_PtrPush( vRes, vClassC );
+ // map repr node IDs into class numbers
+ vClass2Num = Vec_IntAlloc( 0 );
+ Vec_IntFill( vClass2Num, Aig_ManObjNumMax(pMiter), -1 );
+ // keep classes having at least one element from pNtk1 and one from pNtk2
+ Vec_IntForEachEntry( vId2Lit1, Class, i )
+ if ( Class > 0 && Vec_IntEntry(vCounts0, Class) && Vec_IntEntry(vCounts1, Class) )
+ Vec_IntPush( Abc_ObjDressClass(vRes, vClass2Num, Class), Abc_ObjDressMakeId(pNtk1, i, 0) );
+ Vec_IntForEachEntry( vId2Lit2, Class, i )
+ if ( Class > 0 && Vec_IntEntry(vCounts0, Class) && Vec_IntEntry(vCounts1, Class) )
+ Vec_IntPush( Abc_ObjDressClass(vRes, vClass2Num, Class), Abc_ObjDressMakeId(pNtk2, i, 1) );
+ // package them accordingly
+ Vec_IntFree( vClass2Num );
+ Vec_IntFree( vCounts0 );
+ Vec_IntFree( vCounts1 );
+ Vec_IntFree( vId2Lit1 );
+ Vec_IntFree( vId2Lit2 );
+ return vRes;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes equivalence classes of objects in pNtk1 and pNtk2.]
+
+ Description [Returns the array (Vec_Ptr_t) of integer arrays (Vec_Int_t).
+ Each of the integer arrays contains entries of one equivalence class.
+ Each entry contains the following information: the network number (0/1),
+ the polarity (0/1) and the object ID in the the network (0 <= num < MaxId)
+ where MaxId is the largest number of an ID of an object in that network.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Ptr_t * Abc_NtkDressComputeEquivs( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nConflictLimit, int fVerbose )
+{
+ Dch_Pars_t Pars, * pPars = &Pars;
+ Abc_Ntk_t * pAig1, * pAig2;
+ Aig_Man_t * pMan1, * pMan2, * pMiter;
+ Vec_Ptr_t * vRes;
+ assert( !Abc_NtkIsStrash(pNtk1) );
+ assert( !Abc_NtkIsStrash(pNtk2) );
+ // convert network into AIG
+ pAig1 = Abc_NtkStrash( pNtk1, 1, 1, 0 );
+ pAig2 = Abc_NtkStrash( pNtk2, 1, 1, 0 );
+ pMan1 = Abc_NtkToDar( pAig1, 0, 0 );
+ pMan2 = Abc_NtkToDar( pAig2, 0, 0 );
+ // derive the miter
+ pMiter = Aig_ManCreateDualOutputMiter( pMan1, pMan2 );
+ // set up parameters for SAT sweeping
+ Dch_ManSetDefaultParams( pPars );
+ pPars->nBTLimit = nConflictLimit;
+ pPars->fVerbose = fVerbose;
+ // perform SAT sweeping
+ Dch_ComputeEquivalences( pMiter, pPars );
+ // now, pMiter is annotated with the equivl class info
+ // convert this info into the resulting array
+ vRes = Abc_NtkDressMapIds( pMiter, pNtk1, pNtk2 );
+ Aig_ManStop( pMiter );
+ Aig_ManStop( pMan1 );
+ Aig_ManStop( pMan2 );
+ Abc_NtkDelete( pAig1 );
+ Abc_NtkDelete( pAig2 );
+ return vRes;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Prints information about node equivalences.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Abc_NtkDressPrintEquivs( Vec_Ptr_t * vRes )
+{
+ Vec_Int_t * vClass;
+ int i, k, Entry;
+ Vec_PtrForEachEntry( Vec_Int_t *, vRes, vClass, i )
+ {
+ printf( "Class %5d : ", i );
+ printf( "Num =%5d ", Vec_IntSize(vClass) );
+ Vec_IntForEachEntry( vClass, Entry, k )
+ printf( "%5d%c%d ",
+ Abc_ObjEquivId2ObjId(Entry),
+ Abc_ObjEquivId2Polar(Entry)? '-':'+',
+ Abc_ObjEquivId2NtkId(Entry) );
+ printf( "\n" );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Prints information about node equivalences.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Abc_NtkDressPrintStats( Vec_Ptr_t * vRes, int nNodes0, int nNodes1, int Time )
+{
+ Vec_Int_t * vClass;
+ int i, k, Entry;
+ int NegAll[2] = {0}, PosAll[2] = {0}, PairsAll = 0, PairsOne = 0;
+ int Pos[2], Neg[2];
+ // count the number of equivalences in each class
+ Vec_PtrForEachEntry( Vec_Int_t *, vRes, vClass, i )
+ {
+ Pos[0] = Pos[1] = 0;
+ Neg[0] = Neg[1] = 0;
+ Vec_IntForEachEntry( vClass, Entry, k )
+ {
+ if ( Abc_ObjEquivId2NtkId(Entry) )
+ {
+ if ( Abc_ObjEquivId2Polar(Entry) )
+ Neg[1]++; // negative polarity in network 1
+ else
+ Pos[1]++; // positive polarity in network 1
+ }
+ else
+ {
+ if ( Abc_ObjEquivId2Polar(Entry) )
+ Neg[0]++; // negative polarity in network 0
+ else
+ Pos[0]++; // positive polarity in network 0
+ }
+ }
+ PosAll[0] += Pos[0]; // total positive polarity in network 0
+ PosAll[1] += Pos[1]; // total positive polarity in network 1
+ NegAll[0] += Neg[0]; // total negative polarity in network 0
+ NegAll[1] += Neg[1]; // total negative polarity in network 1
+
+ // assuming that the name can be transferred to only one node
+ PairsAll += ABC_MIN(Neg[0] + Pos[0], Neg[1] + Pos[1]);
+ PairsOne += ABC_MIN(Neg[0], Neg[1]) + ABC_MIN(Pos[0], Pos[1]);
+ }
+ printf( "Total number of equiv classes = %7d.\n", Vec_PtrSize(vRes) );
+ printf( "Participating nodes from both networks = %7d.\n", NegAll[0]+PosAll[0]+NegAll[1]+PosAll[1] );
+ printf( "Participating nodes from the first network = %7d. (%7.2f %% of nodes)\n", NegAll[0]+PosAll[0], 100.0*(NegAll[0]+PosAll[0])/(nNodes0+1) );
+ printf( "Participating nodes from the second network = %7d. (%7.2f %% of nodes)\n", NegAll[1]+PosAll[1], 100.0*(NegAll[1]+PosAll[1])/(nNodes1+1) );
+ printf( "Node pairs (any polarity) = %7d. (%7.2f %% of names can be moved)\n", PairsAll, 100.0*PairsAll/(nNodes0+1) );
+ printf( "Node pairs (same polarity) = %7d. (%7.2f %% of names can be moved)\n", PairsOne, 100.0*PairsOne/(nNodes0+1) );
+ ABC_PRT( "Total runtime", Time );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Transfers names from pNtk1 to pNtk2.]
+
+ Description [Internally calls new procedure for mapping node IDs of
+ both networks into the shared equivalence classes.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Abc_NtkDress2( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nConflictLimit, int fVerbose )
+{
+ Vec_Ptr_t * vRes;
+ int clk = clock();
+ vRes = Abc_NtkDressComputeEquivs( pNtk1, pNtk2, nConflictLimit, fVerbose );
+// Abc_NtkDressPrintEquivs( vRes );
+ Abc_NtkDressPrintStats( vRes, Abc_NtkNodeNum(pNtk1), Abc_NtkNodeNum(pNtk1), clock() - clk );
+ Vec_VecFree( (Vec_Vec_t *)vRes );
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcDsd.c b/src/base/abci/abcDsd.c
index 796a51a4..0bfb4ec0 100644
--- a/src/base/abci/abcDsd.c
+++ b/src/base/abci/abcDsd.c
@@ -21,17 +21,20 @@
#include "abc.h"
#include "dsd.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
-static Abc_Ntk_t * Abc_NtkDsdInternal( Abc_Ntk_t * pNtk, bool fVerbose, bool fPrint, bool fShort );
+static Abc_Ntk_t * Abc_NtkDsdInternal( Abc_Ntk_t * pNtk, int fVerbose, int fPrint, int fShort );
static void Abc_NtkDsdConstruct( Dsd_Manager_t * pManDsd, Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew );
static Abc_Obj_t * Abc_NtkDsdConstructNode( Dsd_Manager_t * pManDsd, Dsd_Node_t * pNodeDsd, Abc_Ntk_t * pNtkNew, int * pCounters );
static Vec_Ptr_t * Abc_NtkCollectNodesForDsd( Abc_Ntk_t * pNtk );
-static void Abc_NodeDecompDsdAndMux( Abc_Obj_t * pNode, Vec_Ptr_t * vNodes, Dsd_Manager_t * pManDsd, bool fRecursive, int * pCounters );
-static bool Abc_NodeIsForDsd( Abc_Obj_t * pNode );
+static void Abc_NodeDecompDsdAndMux( Abc_Obj_t * pNode, Vec_Ptr_t * vNodes, Dsd_Manager_t * pManDsd, int fRecursive, int * pCounters );
+static int Abc_NodeIsForDsd( Abc_Obj_t * pNode );
static int Abc_NodeFindMuxVar( DdManager * dd, DdNode * bFunc, int nVars );
////////////////////////////////////////////////////////////////////////
@@ -53,7 +56,7 @@ static int Abc_NodeFindMuxVar( DdManager * dd, DdNode * bFunc, int n
SeeAlso []
***********************************************************************/
-Abc_Ntk_t * Abc_NtkDsdGlobal( Abc_Ntk_t * pNtk, bool fVerbose, bool fPrint, bool fShort )
+Abc_Ntk_t * Abc_NtkDsdGlobal( Abc_Ntk_t * pNtk, int fVerbose, int fPrint, int fShort )
{
DdManager * dd;
Abc_Ntk_t * pNtkNew;
@@ -91,7 +94,7 @@ Abc_Ntk_t * Abc_NtkDsdGlobal( Abc_Ntk_t * pNtk, bool fVerbose, bool fPrint, bool
SeeAlso []
***********************************************************************/
-Abc_Ntk_t * Abc_NtkDsdInternal( Abc_Ntk_t * pNtk, bool fVerbose, bool fPrint, bool fShort )
+Abc_Ntk_t * Abc_NtkDsdInternal( Abc_Ntk_t * pNtk, int fVerbose, int fPrint, int fShort )
{
char ** ppNamesCi, ** ppNamesCo;
Vec_Ptr_t * vFuncsGlob;
@@ -121,7 +124,7 @@ Abc_Ntk_t * Abc_NtkDsdInternal( Abc_Ntk_t * pNtk, bool fVerbose, bool fPrint, bo
// start the new network
pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_BDD );
// make sure the new manager has enough inputs
- Cudd_bddIthVar( pNtkNew->pManFunc, dd->size-1 );
+ Cudd_bddIthVar( (DdManager *)pNtkNew->pManFunc, dd->size-1 );
// put the results into the new network (save new CO drivers in old CO drivers)
Abc_NtkDsdConstruct( pManDsd, pNtk, pNtkNew );
// finalize the new network
@@ -204,7 +207,7 @@ void Abc_NtkDsdConstruct( Dsd_Manager_t * pManDsd, Abc_Ntk_t * pNtk, Abc_Ntk_t *
Abc_Obj_t * Abc_NtkDsdConstructNode( Dsd_Manager_t * pManDsd, Dsd_Node_t * pNodeDsd, Abc_Ntk_t * pNtkNew, int * pCounters )
{
DdManager * ddDsd = Dsd_ManagerReadDd( pManDsd );
- DdManager * ddNew = pNtkNew->pManFunc;
+ DdManager * ddNew = (DdManager *)pNtkNew->pManFunc;
Dsd_Node_t * pFaninDsd;
Abc_Obj_t * pNodeNew, * pFanin;
DdNode * bLocal, * bTemp, * bVar;
@@ -226,7 +229,7 @@ Abc_Obj_t * Abc_NtkDsdConstructNode( Dsd_Manager_t * pManDsd, Dsd_Node_t * pNode
}
// create the local function depending on the type of the node
- ddNew = pNtkNew->pManFunc;
+ ddNew = (DdManager *)pNtkNew->pManFunc;
switch ( Type )
{
case DSD_NODE_CONST1:
@@ -305,10 +308,10 @@ printf( "\n" );
SeeAlso []
***********************************************************************/
-int Abc_NtkDsdLocal( Abc_Ntk_t * pNtk, bool fVerbose, bool fRecursive )
+int Abc_NtkDsdLocal( Abc_Ntk_t * pNtk, int fVerbose, int fRecursive )
{
Dsd_Manager_t * pManDsd;
- DdManager * dd = pNtk->pManFunc;
+ DdManager * dd = (DdManager *)pNtk->pManFunc;
Vec_Ptr_t * vNodes;
int i;
int pCounters[11] = {0};
@@ -324,7 +327,7 @@ int Abc_NtkDsdLocal( Abc_Ntk_t * pNtk, bool fVerbose, bool fRecursive )
// collect nodes for decomposition
vNodes = Abc_NtkCollectNodesForDsd( pNtk );
for ( i = 0; i < vNodes->nSize; i++ )
- Abc_NodeDecompDsdAndMux( vNodes->pArray[i], vNodes, pManDsd, fRecursive, pCounters );
+ Abc_NodeDecompDsdAndMux( (Abc_Obj_t *)vNodes->pArray[i], vNodes, pManDsd, fRecursive, pCounters );
Vec_PtrFree( vNodes );
printf( "Number of non-decomposable functions:\n" );
@@ -381,15 +384,15 @@ Vec_Ptr_t * Abc_NtkCollectNodesForDsd( Abc_Ntk_t * pNtk )
SeeAlso []
***********************************************************************/
-void Abc_NodeDecompDsdAndMux( Abc_Obj_t * pNode, Vec_Ptr_t * vNodes, Dsd_Manager_t * pManDsd, bool fRecursive, int * pCounters )
+void Abc_NodeDecompDsdAndMux( Abc_Obj_t * pNode, Vec_Ptr_t * vNodes, Dsd_Manager_t * pManDsd, int fRecursive, int * pCounters )
{
- DdManager * dd = pNode->pNtk->pManFunc;
+ DdManager * dd = (DdManager *)pNode->pNtk->pManFunc;
Abc_Obj_t * pRoot = NULL, * pFanin, * pNode1, * pNode2, * pNodeC;
Dsd_Node_t ** ppNodesDsd, * pNodeDsd, * pFaninDsd;
int i, nNodesDsd, iVar, fCompl;
// try disjoint support decomposition
- pNodeDsd = Dsd_DecomposeOne( pManDsd, pNode->pData );
+ pNodeDsd = Dsd_DecomposeOne( pManDsd, (DdNode *)pNode->pData );
fCompl = Dsd_IsComplement( pNodeDsd );
pNodeDsd = Dsd_Regular( pNodeDsd );
@@ -420,25 +423,25 @@ void Abc_NodeDecompDsdAndMux( Abc_Obj_t * pNode, Vec_Ptr_t * vNodes, Dsd_Manager
// add fanin to the root
Abc_ObjAddFanin( pNode, pRoot );
// update the function to be that of buffer
- Cudd_RecursiveDeref( dd, pNode->pData );
- pNode->pData = Cudd_NotCond( dd->vars[0], fCompl ); Cudd_Ref( pNode->pData );
+ Cudd_RecursiveDeref( dd, (DdNode *)pNode->pData );
+ pNode->pData = Cudd_NotCond( (DdNode *)dd->vars[0], fCompl ); Cudd_Ref( (DdNode *)pNode->pData );
}
else // perform MUX-decomposition
{
// get the cofactoring variable
- iVar = Abc_NodeFindMuxVar( dd, pNode->pData, Abc_ObjFaninNum(pNode) );
+ iVar = Abc_NodeFindMuxVar( dd, (DdNode *)pNode->pData, Abc_ObjFaninNum(pNode) );
pNodeC = Abc_ObjFanin( pNode, iVar );
// get the negative cofactor
pNode1 = Abc_NtkCloneObj( pNode );
- pNode1->pData = Cudd_Cofactor( dd, pNode->pData, Cudd_Not(dd->vars[iVar]) ); Cudd_Ref( pNode1->pData );
+ pNode1->pData = Cudd_Cofactor( dd, (DdNode *)pNode->pData, Cudd_Not(dd->vars[iVar]) ); Cudd_Ref( (DdNode *)pNode1->pData );
Abc_NodeMinimumBase( pNode1 );
if ( Abc_NodeIsForDsd(pNode1) )
Vec_PtrPush( vNodes, pNode1 );
// get the positive cofactor
pNode2 = Abc_NtkCloneObj( pNode );
- pNode2->pData = Cudd_Cofactor( dd, pNode->pData, dd->vars[iVar] ); Cudd_Ref( pNode2->pData );
+ pNode2->pData = Cudd_Cofactor( dd, (DdNode *)pNode->pData, dd->vars[iVar] ); Cudd_Ref( (DdNode *)pNode2->pData );
Abc_NodeMinimumBase( pNode2 );
if ( Abc_NodeIsForDsd(pNode2) )
Vec_PtrPush( vNodes, pNode2 );
@@ -450,8 +453,8 @@ void Abc_NodeDecompDsdAndMux( Abc_Obj_t * pNode, Vec_Ptr_t * vNodes, Dsd_Manager
Abc_ObjAddFanin( pNode, pNode2 );
Abc_ObjAddFanin( pNode, pNode1 );
// update the function to be that of MUX
- Cudd_RecursiveDeref( dd, pNode->pData );
- pNode->pData = Cudd_bddIte( dd, dd->vars[0], dd->vars[1], dd->vars[2] ); Cudd_Ref( pNode->pData );
+ Cudd_RecursiveDeref( dd, (DdNode *)pNode->pData );
+ pNode->pData = Cudd_bddIte( dd, dd->vars[0], dd->vars[1], dd->vars[2] ); Cudd_Ref( (DdNode *)pNode->pData );
}
}
@@ -466,7 +469,7 @@ void Abc_NodeDecompDsdAndMux( Abc_Obj_t * pNode, Vec_Ptr_t * vNodes, Dsd_Manager
SeeAlso []
***********************************************************************/
-bool Abc_NodeIsForDsd( Abc_Obj_t * pNode )
+int Abc_NodeIsForDsd( Abc_Obj_t * pNode )
{
// DdManager * dd = pNode->pNtk->pManFunc;
// DdNode * bFunc, * bFunc0, * bFunc1;
@@ -551,3 +554,5 @@ int Abc_NodeFindMuxVar( DdManager * dd, DdNode * bFunc, int nVars )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcEspresso.c b/src/base/abci/abcEspresso.c
index 8f9c7277..c8c1d8e1 100644
--- a/src/base/abci/abcEspresso.c
+++ b/src/base/abci/abcEspresso.c
@@ -21,6 +21,9 @@
#include "abc.h"
#include "espresso.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -248,3 +251,5 @@ pset_family Abc_EspressoMinimize( pset_family pOnset, pset_family pDcset )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcExtract.c b/src/base/abci/abcExtract.c
index 52ea03a3..8eca34a6 100644
--- a/src/base/abci/abcExtract.c
+++ b/src/base/abci/abcExtract.c
@@ -20,6 +20,9 @@
#include "abc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -49,3 +52,5 @@ void Abc_MvCostTest( Abc_Ntk_t * pNtk )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcClpSop.c b/src/base/abci/abcFlop.c
index de92243f..a735f279 100644
--- a/src/base/abci/abcClpSop.c
+++ b/src/base/abci/abcFlop.c
@@ -1,12 +1,12 @@
/**CFile****************************************************************
- FileName [abcCollapse.c]
+ FileName [abcFlop.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Network and node package.]
- Synopsis [Collapsing the network into two-levels.]
+ Synopsis [Flop dependency visualization.]
Author [Alan Mishchenko]
@@ -14,12 +14,15 @@
Date [Ver. 1.0. Started - June 20, 2005.]
- Revision [$Id: abcCollapse.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+ Revision [$Id: abcFlop.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#include "abc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -28,26 +31,10 @@
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
-/**Function*************************************************************
-
- Synopsis [Collapses the network.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Abc_Ntk_t * Abc_NtkCollapseSop( Abc_Ntk_t * pNtk, int fVerbose )
-{
- Abc_Ntk_t * pNtkNew;
- pNtkNew = NULL;
- return pNtkNew;
-}
-
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcFpga.c b/src/base/abci/abcFpga.c
index b87edb6b..0c45c7d2 100644
--- a/src/base/abci/abcFpga.c
+++ b/src/base/abci/abcFpga.c
@@ -21,6 +21,9 @@
#include "abc.h"
#include "fpgaInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -57,7 +60,7 @@ Abc_Ntk_t * Abc_NtkFpga( Abc_Ntk_t * pNtk, float DelayTarget, int fRecovery, int
// print a warning about choice nodes
if ( (Num = Abc_NtkGetChoiceNum( pNtk )) )
- printf( "Performing LUT mapping with %d choices.\n", Num );
+ Abc_Print( 0, "Performing LUT mapping with %d choices.\n", Num );
// compute switching activity
fShowSwitching |= fSwitching;
@@ -156,7 +159,7 @@ Fpga_Man_t * Abc_NtkToFpga( Abc_Ntk_t * pNtk, int fRecovery, float * pSwitching,
// load the AIG into the mapper
vNodes = Abc_AigDfs( pNtk, 0, 0 );
pProgress = Extra_ProgressBarStart( stdout, vNodes->nSize );
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
{
Extra_ProgressBarUpdate( pProgress, i, NULL );
// add the node to the mapper
@@ -170,7 +173,7 @@ Fpga_Man_t * Abc_NtkToFpga( Abc_Ntk_t * pNtk, int fRecovery, float * pSwitching,
Fpga_NodeSetSwitching( pNodeFpga, pSwitching[pNode->Id] );
// set up the choice node
if ( Abc_AigNodeIsChoice( pNode ) )
- for ( pPrev = pNode, pFanin = pNode->pData; pFanin; pPrev = pFanin, pFanin = pFanin->pData )
+ for ( pPrev = pNode, pFanin = (Abc_Obj_t *)pNode->pData; pFanin; pPrev = pFanin, pFanin = (Abc_Obj_t *)pFanin->pData )
{
Fpga_NodeSetNextE( (Fpga_Node_t *)pPrev->pCopy, (Fpga_Node_t *)pFanin->pCopy );
Fpga_NodeSetRepr( (Fpga_Node_t *)pFanin->pCopy, (Fpga_Node_t *)pNode->pCopy );
@@ -267,7 +270,7 @@ Abc_Obj_t * Abc_NodeFromFpga_rec( Abc_Ntk_t * pNtkNew, Fpga_Node_t * pNodeFpga )
for ( i = 0; i < nLeaves; i++ )
Abc_ObjAddFanin( pNodeNew, Abc_NodeFromFpga_rec(pNtkNew, ppLeaves[i]) );
// derive the function of this node
- pNodeNew->pData = Fpga_TruthsCutBdd( pNtkNew->pManFunc, pCutBest ); Cudd_Ref( pNodeNew->pData );
+ pNodeNew->pData = Fpga_TruthsCutBdd( pNtkNew->pManFunc, pCutBest ); Cudd_Ref( (DdNode *)pNodeNew->pData );
Fpga_NodeSetData0( pNodeFpga, (char *)pNodeNew );
return pNodeNew;
}
@@ -277,3 +280,5 @@ Abc_Obj_t * Abc_NodeFromFpga_rec( Abc_Ntk_t * pNtkNew, Fpga_Node_t * pNodeFpga )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcFpgaFast.c b/src/base/abci/abcFpgaFast.c
index 356b855e..46572fa8 100644
--- a/src/base/abci/abcFpgaFast.c
+++ b/src/base/abci/abcFpgaFast.c
@@ -21,6 +21,9 @@
#include "abc.h"
#include "ivy.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -30,8 +33,8 @@ extern Ivy_Man_t * Abc_NtkIvyBefore( Abc_Ntk_t * pNtk, int fSeq, int fUseDc );
static Abc_Ntk_t * Ivy_ManFpgaToAbc( Abc_Ntk_t * pNtk, Ivy_Man_t * pMan );
static Abc_Obj_t * Ivy_ManToAbcFast_rec( Abc_Ntk_t * pNtkNew, Ivy_Man_t * pMan, Ivy_Obj_t * pObjIvy, Vec_Int_t * vNodes );
-static inline void Abc_ObjSetIvy2Abc( Ivy_Man_t * p, int IvyId, Abc_Obj_t * pObjAbc ) { assert(Vec_PtrEntry(p->pCopy, IvyId) == NULL); assert(!Abc_ObjIsComplement(pObjAbc)); Vec_PtrWriteEntry( p->pCopy, IvyId, pObjAbc ); }
-static inline Abc_Obj_t * Abc_ObjGetIvy2Abc( Ivy_Man_t * p, int IvyId ) { return Vec_PtrEntry( p->pCopy, IvyId ); }
+static inline void Abc_ObjSetIvy2Abc( Ivy_Man_t * p, int IvyId, Abc_Obj_t * pObjAbc ) { assert(Vec_PtrEntry((Vec_Ptr_t *)p->pCopy, IvyId) == NULL); assert(!Abc_ObjIsComplement(pObjAbc)); Vec_PtrWriteEntry( (Vec_Ptr_t *)p->pCopy, IvyId, pObjAbc ); }
+static inline Abc_Obj_t * Abc_ObjGetIvy2Abc( Ivy_Man_t * p, int IvyId ) { return (Abc_Obj_t *)Vec_PtrEntry( (Vec_Ptr_t *)p->pCopy, IvyId ); }
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
@@ -118,7 +121,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 = Hop_Not( pObjAbc->pData );
+ pObj->pData = Hop_Not( (Hop_Obj_t *)pObjAbc->pData );
// return the new node
pObjAbc = pObj;
}
@@ -126,7 +129,7 @@ Abc_Ntk_t * Ivy_ManFpgaToAbc( Abc_Ntk_t * pNtk, Ivy_Man_t * pMan )
Abc_ObjAddFanin( Abc_NtkCo(pNtkNew, i), pObjAbc );
}
Vec_IntFree( vNodes );
- Vec_PtrFree( pMan->pCopy );
+ Vec_PtrFree( (Vec_Ptr_t *)pMan->pCopy );
pMan->pCopy = NULL;
// remove dangling nodes
Abc_NtkCleanup( pNtkNew, 0 );
@@ -172,9 +175,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 *)Hop_IthVar( pNtkNew->pManFunc, i );
+ pNodeIvy->pEquiv = (Ivy_Obj_t *)Hop_IthVar( (Hop_Man_t *)pNtkNew->pManFunc, i );
else
- pNodeIvy->pEquiv = (Ivy_Obj_t *)Hop_And( pNtkNew->pManFunc, (Hop_Obj_t *)Ivy_ObjChild0Equiv(pNodeIvy), (Hop_Obj_t *)Ivy_ObjChild1Equiv(pNodeIvy) );
+ pNodeIvy->pEquiv = (Ivy_Obj_t *)Hop_And( (Hop_Man_t *)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;
@@ -188,3 +191,5 @@ Abc_Obj_t * Ivy_ManToAbcFast_rec( Abc_Ntk_t * pNtkNew, Ivy_Man_t * pMan, Ivy_Obj
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcFraig.c b/src/base/abci/abcFraig.c
index 1db939b2..1beab4f4 100644
--- a/src/base/abci/abcFraig.c
+++ b/src/base/abci/abcFraig.c
@@ -22,6 +22,9 @@
#include "fraig.h"
#include "main.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -54,14 +57,14 @@ static Abc_Obj_t * Abc_NodeFraigTrust( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNode
***********************************************************************/
Abc_Ntk_t * Abc_NtkFraig( Abc_Ntk_t * pNtk, void * pParams, int fAllNodes, int fExdc )
{
- Fraig_Params_t * pPars = pParams;
+ Fraig_Params_t * pPars = (Fraig_Params_t *)pParams;
Abc_Ntk_t * pNtkNew;
Fraig_Man_t * pMan;
// check if EXDC is present
if ( fExdc && pNtk->pExdc == NULL )
fExdc = 0, printf( "Warning: Networks has no EXDC.\n" );
// perform fraiging
- pMan = Abc_NtkToFraig( pNtk, pParams, fAllNodes, fExdc );
+ pMan = (Fraig_Man_t *)Abc_NtkToFraig( pNtk, pParams, fAllNodes, fExdc );
// add algebraic choices
// if ( pPars->fChoicing )
// Fraig_ManAddChoices( pMan, 0, 6 );
@@ -109,7 +112,7 @@ void * Abc_NtkToFraig( Abc_Ntk_t * pNtk, void * pParams, int fAllNodes, int fExd
assert( Abc_NtkIsStrash(pNtk) );
// create the FRAIG manager
- pMan = Fraig_ManCreate( pParams );
+ pMan = Fraig_ManCreate( (Fraig_Params_t *)pParams );
// map the constant node
Abc_NtkCleanCopy( pNtk );
@@ -122,22 +125,18 @@ void * Abc_NtkToFraig( Abc_Ntk_t * pNtk, void * pParams, int fAllNodes, int fExd
vNodes = Abc_AigDfs( pNtk, fAllNodes, 0 );
if ( !fInternal )
pProgress = Extra_ProgressBarStart( stdout, vNodes->nSize );
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
{
if ( Abc_ObjFaninNum(pNode) == 0 )
continue;
- if ( !fInternal ) {
- assert(pProgress);
+ if ( pProgress )
Extra_ProgressBarUpdate( pProgress, i, NULL );
- }
pNode->pCopy = (Abc_Obj_t *)Fraig_NodeAnd( pMan,
- Fraig_NotCond( Abc_ObjFanin0(pNode)->pCopy, Abc_ObjFaninC0(pNode) ),
- Fraig_NotCond( Abc_ObjFanin1(pNode)->pCopy, Abc_ObjFaninC1(pNode) ) );
+ Fraig_NotCond( Abc_ObjFanin0(pNode)->pCopy, (int)Abc_ObjFaninC0(pNode) ),
+ Fraig_NotCond( Abc_ObjFanin1(pNode)->pCopy, (int)Abc_ObjFaninC1(pNode) ) );
}
- if ( !fInternal ) {
- assert(pProgress);
+ if ( pProgress )
Extra_ProgressBarStop( pProgress );
- }
Vec_PtrFree( vNodes );
// use EXDC to change the mapping of nodes into FRAIG nodes
@@ -189,11 +188,11 @@ Fraig_Node_t * Abc_NtkToFraigExdc( Fraig_Man_t * pMan, Abc_Ntk_t * pNtkMain, Abc
// build FRAIG for each node
Abc_AigForEachAnd( pNtkStrash, pObj, i )
pObj->pCopy = (Abc_Obj_t *)Fraig_NodeAnd( pMan,
- Fraig_NotCond( Abc_ObjFanin0(pObj)->pCopy, Abc_ObjFaninC0(pObj) ),
- Fraig_NotCond( Abc_ObjFanin1(pObj)->pCopy, Abc_ObjFaninC1(pObj) ) );
+ Fraig_NotCond( Abc_ObjFanin0(pObj)->pCopy, (int)Abc_ObjFaninC0(pObj) ),
+ Fraig_NotCond( Abc_ObjFanin1(pObj)->pCopy, (int)Abc_ObjFaninC1(pObj) ) );
// get the EXDC to be returned
pObj = Abc_NtkPo( pNtkStrash, 0 );
- gResult = Fraig_NotCond( Abc_ObjFanin0(pObj)->pCopy, Abc_ObjFaninC0(pObj) );
+ gResult = Fraig_NotCond( Abc_ObjFanin0(pObj)->pCopy, (int)Abc_ObjFaninC0(pObj) );
Abc_NtkDelete( pNtkStrash );
return gResult;
}
@@ -262,7 +261,7 @@ void Abc_NtkFraigRemapUsingExdc( Fraig_Man_t * pMan, Abc_Ntk_t * pNtk )
// restore the next pointers
Abc_NtkCleanNext( pNtk );
Abc_NtkForEachNode( pNtk, pNode, i )
- pNode->pNext = Vec_PtrEntry( vNexts, pNode->Id );
+ pNode->pNext = (Abc_Obj_t *)Vec_PtrEntry( vNexts, pNode->Id );
Vec_PtrFree( vNexts );
}
@@ -326,7 +325,7 @@ Abc_Obj_t * Abc_NodeFromFraig_rec( Abc_Ntk_t * pNtkNew, Fraig_Node_t * pNodeFrai
pRes0 = Abc_NodeFromFraig_rec( pNtkNew, Fraig_NodeReadOne(pNodeFraigR) );
pRes1 = Abc_NodeFromFraig_rec( pNtkNew, Fraig_NodeReadTwo(pNodeFraigR) );
// derive the new node
- pRes = Abc_AigAnd( pNtkNew->pManFunc, pRes0, pRes1 );
+ pRes = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, pRes0, pRes1 );
pRes->fPhase = Fraig_NodeReadSimInv( pNodeFraigR );
// if the node has an equivalence class, find its representative
if ( Fraig_NodeReadRepr(pNodeFraigR) == NULL && Fraig_NodeReadNextE(pNodeFraigR) != NULL )
@@ -459,7 +458,7 @@ void Abc_NtkFromFraig2_rec( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNode, Vec_Ptr_t *
Abc_NodeSetTravIdCurrent( pNode );
assert( Abc_ObjIsNode( pNode ) );
// get the node's representative
- if ( (pRepr = Vec_PtrEntry(vNodeReprs, pNode->Id)) )
+ if ( (pRepr = (Abc_Obj_t *)Vec_PtrEntry(vNodeReprs, pNode->Id)) )
{
Abc_NtkFromFraig2_rec( pNtkNew, pRepr, vNodeReprs );
pNode->pCopy = Abc_ObjNotCond( pRepr->pCopy, pRepr->fPhase ^ pNode->fPhase );
@@ -467,7 +466,7 @@ void Abc_NtkFromFraig2_rec( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNode, Vec_Ptr_t *
}
Abc_NtkFromFraig2_rec( pNtkNew, Abc_ObjFanin0(pNode), vNodeReprs );
Abc_NtkFromFraig2_rec( pNtkNew, Abc_ObjFanin1(pNode), vNodeReprs );
- pNode->pCopy = Abc_AigAnd( pNtkNew->pManFunc, Abc_ObjChild0Copy(pNode), Abc_ObjChild1Copy(pNode) );
+ pNode->pCopy = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, Abc_ObjChild0Copy(pNode), Abc_ObjChild1Copy(pNode) );
}
@@ -538,9 +537,9 @@ int Abc_NtkFraigTrustCheck( Abc_Ntk_t * pNtk )
nFanins = Abc_ObjFaninNum(pNode);
if ( nFanins < 2 )
continue;
- if ( nFanins == 2 && Abc_SopIsAndType(pNode->pData) )
+ if ( nFanins == 2 && Abc_SopIsAndType((char *)pNode->pData) )
continue;
- if ( !Abc_SopIsOrType(pNode->pData) )
+ if ( !Abc_SopIsOrType((char *)pNode->pData) )
return 0;
}
return 1;
@@ -567,7 +566,7 @@ void Abc_NtkFraigTrustOne( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew )
// perform strashing
vNodes = Abc_NtkDfs( pNtk, 0 );
pProgress = Extra_ProgressBarStart( stdout, vNodes->nSize );
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
{
Extra_ProgressBarUpdate( pProgress, i, NULL );
// get the node
@@ -608,18 +607,18 @@ Abc_Obj_t * Abc_NodeFraigTrust( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNode )
assert( Abc_ObjIsNode(pNode) );
// get the number of node's fanins
nFanins = Abc_ObjFaninNum( pNode );
- assert( nFanins == Abc_SopGetVarNum(pNode->pData) );
+ assert( nFanins == Abc_SopGetVarNum((char *)pNode->pData) );
// check if it is a constant
if ( nFanins == 0 )
- return Abc_ObjNotCond( Abc_AigConst1(pNtkNew), Abc_SopIsConst0(pNode->pData) );
+ return Abc_ObjNotCond( Abc_AigConst1(pNtkNew), Abc_SopIsConst0((char *)pNode->pData) );
if ( nFanins == 1 )
- return Abc_ObjNotCond( Abc_ObjFanin0(pNode)->pCopy, Abc_SopIsInv(pNode->pData) );
- if ( nFanins == 2 && Abc_SopIsAndType(pNode->pData) )
- return Abc_AigAnd( pNtkNew->pManFunc,
- Abc_ObjNotCond( Abc_ObjFanin0(pNode)->pCopy, !Abc_SopGetIthCareLit(pNode->pData,0) ),
- Abc_ObjNotCond( Abc_ObjFanin1(pNode)->pCopy, !Abc_SopGetIthCareLit(pNode->pData,1) ) );
- assert( Abc_SopIsOrType(pNode->pData) );
- fCompl = Abc_SopGetIthCareLit(pNode->pData,0);
+ return Abc_ObjNotCond( Abc_ObjFanin0(pNode)->pCopy, Abc_SopIsInv((char *)pNode->pData) );
+ if ( nFanins == 2 && Abc_SopIsAndType((char *)pNode->pData) )
+ return Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc,
+ Abc_ObjNotCond( Abc_ObjFanin0(pNode)->pCopy, !Abc_SopGetIthCareLit((char *)pNode->pData,0) ),
+ Abc_ObjNotCond( Abc_ObjFanin1(pNode)->pCopy, !Abc_SopGetIthCareLit((char *)pNode->pData,1) ) );
+ assert( Abc_SopIsOrType((char *)pNode->pData) );
+ fCompl = Abc_SopGetIthCareLit((char *)pNode->pData,0);
// get the root of the choice node (the first fanin)
pSum = Abc_ObjFanin0(pNode)->pCopy;
// connect other fanins
@@ -631,7 +630,7 @@ Abc_Obj_t * Abc_NodeFraigTrust( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNode )
*ppTail = pFanin->pCopy;
ppTail = &pFanin->pCopy->pData;
// set the complemented bit of this cut
- if ( fCompl ^ Abc_SopGetIthCareLit(pNode->pData, i) )
+ if ( fCompl ^ Abc_SopGetIthCareLit((char *)pNode->pData, i) )
pFanin->pCopy->fPhase = 1;
}
assert( *ppTail == NULL );
@@ -669,7 +668,7 @@ int Abc_NtkFraigStore( Abc_Ntk_t * pNtkAdd )
{
// check that the networks have the same PIs
// reorder PIs of pNtk2 according to pNtk1
- if ( !Abc_NtkCompareSignals( pNtk, Vec_PtrEntry(vStore, 0), 1, 1 ) )
+ if ( !Abc_NtkCompareSignals( pNtk, (Abc_Ntk_t *)Vec_PtrEntry(vStore, 0), 1, 1 ) )
{
printf( "Trying to store the network with different primary inputs.\n" );
printf( "The previously stored networks are deleted and this one is added.\n" );
@@ -709,11 +708,11 @@ Abc_Ntk_t * Abc_NtkFraigRestore()
return NULL;
}
// printf( "Currently stored %d networks will be fraiged.\n", Vec_PtrSize(vStore) );
- pNtk = Vec_PtrEntry( vStore, 0 );
+ pNtk = (Abc_Ntk_t *)Vec_PtrEntry( vStore, 0 );
// swap the first and last network
// this should lead to the primary choice being "better" because of synthesis
- pNtk = Vec_PtrPop( vStore );
+ pNtk = (Abc_Ntk_t *)Vec_PtrPop( vStore );
Vec_PtrPush( vStore, Vec_PtrEntry(vStore,0) );
Vec_PtrWriteEntry( vStore, 0, pNtk );
@@ -763,7 +762,7 @@ void Abc_NtkFraigStoreClean()
Abc_Ntk_t * pNtk;
int i;
vStore = Abc_FrameReadStore();
- Vec_PtrForEachEntry( vStore, pNtk, i )
+ Vec_PtrForEachEntry( Abc_Ntk_t *, vStore, pNtk, i )
Abc_NtkDelete( pNtk );
Vec_PtrClear( vStore );
}
@@ -806,3 +805,5 @@ void Abc_NtkFraigStoreCheck( Abc_Ntk_t * pFraig )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcFxu.c b/src/base/abci/abcFxu.c
index 6109870e..bd030609 100644
--- a/src/base/abci/abcFxu.c
+++ b/src/base/abci/abcFxu.c
@@ -21,11 +21,14 @@
#include "abc.h"
#include "fxu.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
-static bool Abc_NtkFxuCheck( Abc_Ntk_t * pNtk );
+static int Abc_NtkFxuCheck( Abc_Ntk_t * pNtk );
static void Abc_NtkFxuCollectInfo( Abc_Ntk_t * pNtk, Fxu_Data_t * p );
static void Abc_NtkFxuReconstruct( Abc_Ntk_t * pNtk, Fxu_Data_t * p );
@@ -50,7 +53,7 @@ static void Abc_NtkFxuReconstruct( Abc_Ntk_t * pNtk, Fxu_Data_t * p );
SeeAlso []
***********************************************************************/
-bool Abc_NtkFastExtract( Abc_Ntk_t * pNtk, Fxu_Data_t * p )
+int Abc_NtkFastExtract( Abc_Ntk_t * pNtk, Fxu_Data_t * p )
{
assert( Abc_NtkIsLogic(pNtk) );
// if the network is already in the SOP form, it may come from BLIF file
@@ -103,7 +106,7 @@ bool Abc_NtkFastExtract( Abc_Ntk_t * pNtk, Fxu_Data_t * p )
SeeAlso []
***********************************************************************/
-bool Abc_NtkFxuCheck( Abc_Ntk_t * pNtk )
+int Abc_NtkFxuCheck( Abc_Ntk_t * pNtk )
{
Abc_Obj_t * pNode, * pFanin1, * pFanin2;
int n, i, k;
@@ -141,7 +144,7 @@ void Abc_NtkFxuCollectInfo( Abc_Ntk_t * pNtk, Fxu_Data_t * p )
Abc_Obj_t * pNode;
int i;
// add information to the manager
- p->pManSop = pNtk->pManFunc;
+ p->pManSop = (Extra_MmFlex_t *)pNtk->pManFunc;
p->vSops = Vec_PtrAlloc(0);
p->vFanins = Vec_PtrAlloc(0);
p->vSopsNew = Vec_PtrAlloc(0);
@@ -153,9 +156,9 @@ void Abc_NtkFxuCollectInfo( Abc_Ntk_t * pNtk, Fxu_Data_t * p )
// add SOPs and fanin array
Abc_NtkForEachNode( pNtk, pNode, i )
{
- if ( Abc_SopGetVarNum(pNode->pData) < 2 )
+ if ( Abc_SopGetVarNum((char *)pNode->pData) < 2 )
continue;
- if ( Abc_SopGetCubeNum(pNode->pData) < 1 )
+ if ( Abc_SopGetCubeNum((char *)pNode->pData) < 1 )
continue;
p->vSops->pArray[i] = pNode->pData;
p->vFanins->pArray[i] = &pNode->vFanins;
@@ -181,7 +184,7 @@ void Abc_NtkFxuFreeInfo( Fxu_Data_t * p )
if ( p->vFaninsNew )
for ( i = 0; i < p->vFaninsNew->nSize; i++ )
if ( p->vFaninsNew->pArray[i] )
- Vec_IntFree( p->vFaninsNew->pArray[i] );
+ Vec_IntFree( (Vec_Int_t *)p->vFaninsNew->pArray[i] );
// free the arrays
if ( p->vSops ) Vec_PtrFree( p->vSops );
if ( p->vSopsNew ) Vec_PtrFree( p->vSopsNew );
@@ -219,14 +222,14 @@ void Abc_NtkFxuReconstruct( Abc_Ntk_t * pNtk, Fxu_Data_t * p )
for ( i = 0; i < p->vFanins->nSize; i++ )
{
// the new array of fanins
- vFanins = p->vFaninsNew->pArray[i];
+ vFanins = (Vec_Int_t *)p->vFaninsNew->pArray[i];
if ( vFanins == NULL )
continue;
// remove old fanins
pNode = Abc_NtkObj( pNtk, i );
Abc_ObjRemoveFanins( pNode );
// add new fanins
- vFanins = p->vFaninsNew->pArray[i];
+ vFanins = (Vec_Int_t *)p->vFaninsNew->pArray[i];
for ( k = 0; k < vFanins->nSize; k++ )
{
pFanin = Abc_NtkObj( pNtk, vFanins->pArray[k] );
@@ -241,7 +244,7 @@ void Abc_NtkFxuReconstruct( Abc_Ntk_t * pNtk, Fxu_Data_t * p )
// get the new node
pNode = Abc_NtkObj( pNtk, i );
// add the fanins
- vFanins = p->vFaninsNew->pArray[i];
+ vFanins = (Vec_Int_t *)p->vFaninsNew->pArray[i];
for ( k = 0; k < vFanins->nSize; k++ )
{
pFanin = Abc_NtkObj( pNtk, vFanins->pArray[k] );
@@ -258,3 +261,5 @@ void Abc_NtkFxuReconstruct( Abc_Ntk_t * pNtk, Fxu_Data_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcGen.c b/src/base/abci/abcGen.c
index f6111dfd..dc376826 100644
--- a/src/base/abci/abcGen.c
+++ b/src/base/abci/abcGen.c
@@ -20,6 +20,8 @@
#include "abc.h"
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -565,7 +567,7 @@ void Abc_GenOneHotIntervals( char * pFileName, int nPis, int nRegs, Vec_Ptr_t *
fprintf( pFile, "# One-hotness with %d vars and %d regs generated by ABC on %s\n", nPis, nRegs, Extra_TimeStamp() );
fprintf( pFile, "# Used %d intervals of 1-hot registers: { ", Vec_PtrSize(vOnehots) );
Counter = 0;
- Vec_PtrForEachEntry( vOnehots, vLine, k )
+ Vec_PtrForEachEntry( Vec_Int_t *, vOnehots, vLine, k )
{
fprintf( pFile, "%d ", Vec_IntSize(vLine) );
Counter += Vec_IntSize(vLine) * (Vec_IntSize(vLine) - 1) / 2;
@@ -583,7 +585,7 @@ void Abc_GenOneHotIntervals( char * pFileName, int nPis, int nRegs, Vec_Ptr_t *
fprintf( pFile, " o%0*d", nDigitsOut, i );
fprintf( pFile, "\n" );
Counter2 = 0;
- Vec_PtrForEachEntry( vOnehots, vLine, k )
+ Vec_PtrForEachEntry( Vec_Int_t *, vOnehots, vLine, k )
{
Vec_IntForEachEntry( vLine, iReg1, i )
Vec_IntForEachEntryStart( vLine, iReg2, j, i+1 )
@@ -599,8 +601,13 @@ void Abc_GenOneHotIntervals( char * pFileName, int nPis, int nRegs, Vec_Ptr_t *
fclose( pFile );
}
+ABC_NAMESPACE_IMPL_END
+
#include "aig.h"
+ABC_NAMESPACE_IMPL_START
+
+
/**Function*************************************************************
Synopsis [Generates structure of L K-LUTs implementing an N-var function.]
@@ -655,3 +662,5 @@ void Abc_GenRandom( char * pFileName, int nPis )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcHaig.c b/src/base/abci/abcHaig.c
index 3f3fefcd..b102e04f 100644
--- a/src/base/abci/abcHaig.c
+++ b/src/base/abci/abcHaig.c
@@ -20,6 +20,9 @@
#include "abc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -169,7 +172,7 @@ Vec_Ptr_t * Abc_NtkHaigCollectMembers( Hop_Man_t * p )
Hop_Obj_t * pObj;
int i;
vObjs = Vec_PtrAlloc( 4098 );
- Vec_PtrForEachEntry( p->vObjs, pObj, i )
+ Vec_PtrForEachEntry( Hop_Obj_t *, p->vObjs, pObj, i )
{
if ( pObj->pData == NULL )
continue;
@@ -198,9 +201,9 @@ Vec_Ptr_t * Abc_NtkHaigCreateClasses( Vec_Ptr_t * vMembers )
// count classes
vClasses = Vec_PtrAlloc( 4098 );
- Vec_PtrForEachEntry( vMembers, pObj, i )
+ Vec_PtrForEachEntry( Hop_Obj_t *, vMembers, pObj, i )
{
- pRepr = pObj->pData;
+ pRepr = (Hop_Obj_t *)pObj->pData;
assert( pRepr->pData == NULL );
if ( pRepr->fMarkA == 0 ) // new
{
@@ -210,44 +213,44 @@ Vec_Ptr_t * Abc_NtkHaigCreateClasses( Vec_Ptr_t * vMembers )
}
// set representatives as representatives
- Vec_PtrForEachEntry( vClasses, pObj, i )
+ Vec_PtrForEachEntry( Hop_Obj_t *, vClasses, pObj, i )
{
pObj->fMarkA = 0;
pObj->pData = pObj;
}
// go through the members and update
- Vec_PtrForEachEntry( vMembers, pObj, i )
+ Vec_PtrForEachEntry( Hop_Obj_t *, vMembers, pObj, i )
{
- pRepr = pObj->pData;
+ pRepr = (Hop_Obj_t *)pObj->pData;
if ( ((Hop_Obj_t *)pRepr->pData)->Id > pObj->Id )
pRepr->pData = pObj;
}
// change representatives of the class
- Vec_PtrForEachEntry( vMembers, pObj, i )
+ Vec_PtrForEachEntry( Hop_Obj_t *, vMembers, pObj, i )
{
- pRepr = pObj->pData;
+ pRepr = (Hop_Obj_t *)pObj->pData;
pObj->pData = pRepr->pData;
assert( ((Hop_Obj_t *)pObj->pData)->Id <= pObj->Id );
}
// update classes
- Vec_PtrForEachEntry( vClasses, pObj, i )
+ Vec_PtrForEachEntry( Hop_Obj_t *, vClasses, pObj, i )
{
- pRepr = pObj->pData;
+ pRepr = (Hop_Obj_t *)pObj->pData;
assert( pRepr->pData == pRepr );
// pRepr->pData = NULL;
Vec_PtrWriteEntry( vClasses, i, pRepr );
Vec_PtrPush( vMembers, pObj );
}
- Vec_PtrForEachEntry( vMembers, pObj, i )
+ Vec_PtrForEachEntry( Hop_Obj_t *, vMembers, pObj, i )
if ( pObj->pData == pObj )
pObj->pData = NULL;
/*
- Vec_PtrForEachEntry( vMembers, pObj, i )
+ Vec_PtrForEachEntry( Hop_Obj_t *, vMembers, pObj, i )
{
printf( "ObjId = %4d : ", pObj->Id );
if ( pObj->pData == NULL )
@@ -280,7 +283,7 @@ int Abc_NtkHaigCountFans( Hop_Man_t * p )
{
Hop_Obj_t * pObj;
int i, Counter = 0;
- Vec_PtrForEachEntry( p->vObjs, pObj, i )
+ Vec_PtrForEachEntry( Hop_Obj_t *, p->vObjs, pObj, i )
{
if ( pObj->pData == NULL )
continue;
@@ -309,7 +312,7 @@ static inline Hop_Obj_t * Hop_ObjReprHop( Hop_Obj_t * pObj )
assert( pObj->pNext != NULL );
if ( pObj->pData == NULL )
return pObj->pNext;
- pRepr = pObj->pData;
+ pRepr = (Hop_Obj_t *)pObj->pData;
assert( pRepr->pData == pRepr );
return Hop_NotCond( pRepr->pNext, pObj->fPhase ^ pRepr->fPhase );
}
@@ -344,7 +347,7 @@ Hop_Man_t * Abc_NtkHaigReconstruct( Hop_Man_t * p )
Hop_Man_t * pNew;
Hop_Obj_t * pObj;
int i, Counter = 0;
- Vec_PtrForEachEntry( p->vObjs, pObj, i )
+ Vec_PtrForEachEntry( Hop_Obj_t *, p->vObjs, pObj, i )
pObj->pNext = NULL;
// start the HOP package
pNew = Hop_ManStart();
@@ -356,7 +359,7 @@ Hop_Man_t * Abc_NtkHaigReconstruct( Hop_Man_t * p )
Hop_ManForEachPi( p, pObj, i )
pObj->pNext = Hop_ObjCreatePi(pNew);
// map the internal nodes
- Vec_PtrForEachEntry( p->vObjs, pObj, i )
+ Vec_PtrForEachEntry( Hop_Obj_t *, p->vObjs, pObj, i )
{
if ( !Hop_ObjIsNode(pObj) )
continue;
@@ -414,7 +417,7 @@ int Abc_NtkHaigCheckTfi_rec( Abc_Obj_t * pNode, Abc_Obj_t * pOld )
if ( Abc_NtkHaigCheckTfi_rec( Abc_ObjFanin1(pNode), pOld ) )
return 1;
// check equivalent nodes
- return Abc_NtkHaigCheckTfi_rec( pNode->pData, pOld );
+ return Abc_NtkHaigCheckTfi_rec( (Abc_Obj_t *)pNode->pData, pOld );
}
/**Function*************************************************************
@@ -478,11 +481,11 @@ Abc_Ntk_t * Abc_NtkHaigRecreateAig( Abc_Ntk_t * pNtk, Hop_Man_t * p )
pObj->pNext = (Hop_Obj_t *)Abc_NtkCi( pNtkAig, i );
// construct new nodes
- Vec_PtrForEachEntry( p->vObjs, pObj, i )
+ Vec_PtrForEachEntry( Hop_Obj_t *, p->vObjs, pObj, i )
{
if ( !Hop_ObjIsNode(pObj) )
continue;
- pObj->pNext = (Hop_Obj_t *)Abc_AigAnd( pNtkAig->pManFunc, Hop_ObjChild0Next(pObj), Hop_ObjChild1Next(pObj) );
+ pObj->pNext = (Hop_Obj_t *)Abc_AigAnd( (Abc_Aig_t *)pNtkAig->pManFunc, Hop_ObjChild0Next(pObj), Hop_ObjChild1Next(pObj) );
assert( !Hop_IsComplement(pObj->pNext) );
}
@@ -491,7 +494,7 @@ Abc_Ntk_t * Abc_NtkHaigRecreateAig( Abc_Ntk_t * pNtk, Hop_Man_t * p )
Abc_ObjAddFanin( pObjOld->pCopy, Hop_ObjChild0Next(Hop_ManPo(p,i)) );
// construct choice nodes
- Vec_PtrForEachEntry( p->vObjs, pObj, i )
+ Vec_PtrForEachEntry( Hop_Obj_t *, p->vObjs, pObj, i )
{
// skip the node without choices
if ( pObj->pData == NULL )
@@ -500,7 +503,7 @@ Abc_Ntk_t * Abc_NtkHaigRecreateAig( Abc_Ntk_t * pNtk, Hop_Man_t * p )
if ( pObj->pData == pObj )
continue;
// do not create choices for constant 1 and PIs
- if ( !Hop_ObjIsNode(pObj->pData) )
+ if ( !Hop_ObjIsNode((Hop_Obj_t *)pObj->pData) )
continue;
// get the corresponding new nodes
pObjAbcThis = (Abc_Obj_t *)pObj->pNext;
@@ -516,7 +519,7 @@ Abc_Ntk_t * Abc_NtkHaigRecreateAig( Abc_Ntk_t * pNtk, Hop_Man_t * p )
{
// find the last node in the class
while ( pObjAbcRepr->pData )
- pObjAbcRepr = pObjAbcRepr->pData;
+ pObjAbcRepr = (Abc_Obj_t *)pObjAbcRepr->pData;
// add the new node at the end of the list
pObjAbcRepr->pData = pObjAbcThis;
}
@@ -579,10 +582,10 @@ int Abc_NtkHaigResetReprs( Hop_Man_t * p )
Hop_Obj_t * pObj, * pRepr;
int i, nClasses, nMembers, nFanouts, nNormals;
// clear self-classes
- Vec_PtrForEachEntry( p->vObjs, pObj, i )
+ Vec_PtrForEachEntry( Hop_Obj_t *, p->vObjs, pObj, i )
{
// fix the strange situation of double-loop
- pRepr = pObj->pData;
+ pRepr = (Hop_Obj_t *)pObj->pData;
if ( pRepr && pRepr->pData == pObj )
pRepr->pData = pRepr;
// remove self-loops
@@ -590,7 +593,7 @@ int Abc_NtkHaigResetReprs( Hop_Man_t * p )
pObj->pData = NULL;
}
// set representatives
- Vec_PtrForEachEntry( p->vObjs, pObj, i )
+ Vec_PtrForEachEntry( Hop_Obj_t *, p->vObjs, pObj, i )
{
if ( pObj->pData == NULL )
continue;
@@ -601,7 +604,7 @@ int Abc_NtkHaigResetReprs( Hop_Man_t * p )
pObj->pData = pRepr;
}
// make each class point to the smallest topological order
- Vec_PtrForEachEntry( p->vObjs, pObj, i )
+ Vec_PtrForEachEntry( Hop_Obj_t *, p->vObjs, pObj, i )
{
if ( pObj->pData == NULL )
continue;
@@ -616,7 +619,7 @@ int Abc_NtkHaigResetReprs( Hop_Man_t * p )
}
// count classes, members, and fanouts - and verify
nMembers = nClasses = nFanouts = nNormals = 0;
- Vec_PtrForEachEntry( p->vObjs, pObj, i )
+ Vec_PtrForEachEntry( Hop_Obj_t *, p->vObjs, pObj, i )
{
if ( pObj->pData == NULL )
continue;
@@ -731,3 +734,5 @@ Abc_Ntk_t * Abc_NtkHopRemoveLoops( Abc_Ntk_t * pNtk, Hop_Man_t * pMan )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcIf.c b/src/base/abci/abcIf.c
index facf06bc..82e968bd 100644
--- a/src/base/abci/abcIf.c
+++ b/src/base/abci/abcIf.c
@@ -23,6 +23,9 @@
#include "kit.h"
#include "aig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -64,14 +67,14 @@ void Abc_NtkIfComputeSwitching( Abc_Ntk_t * pNtk, If_Man_t * pIfMan )
int i, clk = clock();
// map IF objects into old network
Abc_NtkForEachObj( pNtk, pObjAbc, i )
- if ( (pObjIf = pObjAbc->pTemp) )
+ if ( (pObjIf = (If_Obj_t *)pObjAbc->pTemp) )
pObjIf->pCopy = pObjAbc;
// map network into an AIG
pAig = Abc_NtkToDar( pNtk, 0, 0 );
vSwitching = Saig_ManComputeSwitchProbs( pAig, 48, 16, 0 );
pSwitching = (float *)vSwitching->pArray;
Abc_NtkForEachObj( pNtk, pObjAbc, i )
- if ( (pObjAig = pObjAbc->pTemp) )
+ if ( (pObjAig = (Aig_Obj_t *)pObjAbc->pTemp) )
{
pObjAbc->dTemp = pSwitching[pObjAig->Id];
// J. Anderson and F. N. Najm, “Power-Aware Technology Mapping for LUT-Based FPGAs,”
@@ -85,7 +88,7 @@ void Abc_NtkIfComputeSwitching( Abc_Ntk_t * pNtk, If_Man_t * pIfMan )
pIfMan->vSwitching = Vec_IntStart( If_ManObjNum(pIfMan) );
pSwitching = (float *)pIfMan->vSwitching->pArray;
If_ManForEachObj( pIfMan, pObjIf, i )
- if ( (pObjAbc = pObjIf->pCopy) )
+ if ( (pObjAbc = (Abc_Obj_t *)pObjIf->pCopy) )
pSwitching[i] = pObjAbc->dTemp;
if ( pIfMan->pPars->fVerbose )
{
@@ -199,7 +202,7 @@ If_Man_t * Abc_NtkToIf( Abc_Ntk_t * pNtk, If_Par_t * pPars )
// load the AIG into the mapper
pProgress = Extra_ProgressBarStart( stdout, Abc_NtkObjNumMax(pNtk) );
// Abc_AigForEachAnd( pNtk, pNode, i )
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
{
Extra_ProgressBarUpdate( pProgress, i, "Initial" );
// add the node to the mapper
@@ -210,7 +213,7 @@ If_Man_t * Abc_NtkToIf( Abc_Ntk_t * pNtk, If_Par_t * pPars )
if ( Abc_AigNodeIsChoice( pNode ) )
{
pIfMan->nChoices++;
- for ( pPrev = pNode, pFanin = pNode->pData; pFanin; pPrev = pFanin, pFanin = pFanin->pData )
+ for ( pPrev = pNode, pFanin = (Abc_Obj_t *)pNode->pData; pFanin; pPrev = pFanin, pFanin = (Abc_Obj_t *)pFanin->pData )
If_ObjSetChoice( (If_Obj_t *)pPrev->pCopy, (If_Obj_t *)pFanin->pCopy );
If_ManCreateChoice( pIfMan, (If_Obj_t *)pNode->pCopy );
}
@@ -285,6 +288,71 @@ Abc_Ntk_t * Abc_NtkFromIf( If_Man_t * pIfMan, Abc_Ntk_t * pNtk )
return pNtkNew;
}
+
+/**Function*************************************************************
+
+ Synopsis [Inserts the entry while sorting them by delay.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Hop_Obj_t * Abc_NodeTruthToHopInt( Hop_Man_t * pMan, Vec_Wrd_t * vAnds, int nVars )
+{
+ Vec_Ptr_t * vResults;
+ Hop_Obj_t * pRes0, * pRes1, * pRes;
+ If_And_t This;
+ word Entry;
+ int i;
+ if ( Vec_WrdSize(vAnds) == 0 )
+ return Hop_ManConst0(pMan);
+ if ( Vec_WrdSize(vAnds) == 1 && Vec_WrdEntry(vAnds,0) == 0 )
+ return Hop_ManConst1(pMan);
+ vResults = Vec_PtrAlloc( Vec_WrdSize(vAnds) );
+ for ( i = 0; i < nVars; i++ )
+ Vec_PtrPush( vResults, Hop_IthVar(pMan, i) );
+ Vec_WrdForEachEntryStart( vAnds, Entry, i, nVars )
+ {
+ This = If_WrdToAnd( Entry );
+ pRes0 = Hop_NotCond( (Hop_Obj_t *)Vec_PtrEntry(vResults, This.iFan0), This.fCompl0 );
+ pRes1 = Hop_NotCond( (Hop_Obj_t *)Vec_PtrEntry(vResults, This.iFan1), This.fCompl1 );
+ pRes = Hop_And( pMan, pRes0, pRes1 );
+ Vec_PtrPush( vResults, pRes );
+/*
+ printf( "fan0 = %c%d fan1 = %c%d Del = %d\n",
+ This.fCompl0? '-':'+', This.iFan0,
+ This.fCompl1? '-':'+', This.iFan1,
+ This.Delay );
+*/
+ }
+ Vec_PtrFree( vResults );
+ return Hop_NotCond( pRes, This.fCompl );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates the mapped network.]
+
+ Description [Assuming the copy field of the mapped nodes are NULL.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Hop_Obj_t * Abc_NodeTruthToHop( Hop_Man_t * pMan, If_Man_t * p, If_Cut_t * pCut )
+{
+ Hop_Obj_t * pResult;
+ Vec_Wrd_t * vArray;
+ vArray = If_CutDelaySopArray( p, pCut );
+ pResult = Abc_NodeTruthToHopInt( pMan, vArray, If_CutLeaveNum(pCut) );
+ Vec_WrdFree( vArray );
+ return pResult;
+}
+
/**Function*************************************************************
Synopsis [Derive one node after FPGA mapping.]
@@ -311,8 +379,10 @@ Abc_Obj_t * Abc_NodeFromIf_rec( Abc_Ntk_t * pNtkNew, If_Man_t * pIfMan, If_Obj_t
// create a new node
pNodeNew = Abc_NtkCreateNode( pNtkNew );
pCutBest = If_ObjCutBest( pIfObj );
+// printf( "%d 0x%02X %d\n", pCutBest->nLeaves, 0xff & *If_CutTruth(pCutBest), pIfMan->pPars->pFuncCost(pCutBest) );
// if ( pIfMan->pPars->pLutLib && pIfMan->pPars->pLutLib->fVarPinDelays )
- If_CutRotatePins( pIfMan, pCutBest );
+ if ( !pIfMan->pPars->fDelayOpt )
+ If_CutRotatePins( pIfMan, pCutBest );
if ( pIfMan->pPars->fUseCnfs || pIfMan->pPars->fUseMv )
{
If_CutForEachLeafReverse( pIfMan, pCutBest, pIfLeaf, i )
@@ -331,12 +401,12 @@ Abc_Obj_t * Abc_NodeFromIf_rec( Abc_Ntk_t * pNtkNew, If_Man_t * pIfMan, If_Obj_t
if ( pIfMan->pPars->fUseBdds )
{
// transform truth table into the BDD
- pNodeNew->pData = Kit_TruthToBdd( pNtkNew->pManFunc, If_CutTruth(pCutBest), If_CutLeaveNum(pCutBest), 0 ); Cudd_Ref(pNodeNew->pData);
+ pNodeNew->pData = Kit_TruthToBdd( (DdManager *)pNtkNew->pManFunc, If_CutTruth(pCutBest), If_CutLeaveNum(pCutBest), 0 ); Cudd_Ref((DdNode *)pNodeNew->pData);
}
else if ( pIfMan->pPars->fUseCnfs || pIfMan->pPars->fUseMv )
{
// transform truth table into the BDD
- pNodeNew->pData = Kit_TruthToBdd( pNtkNew->pManFunc, If_CutTruth(pCutBest), If_CutLeaveNum(pCutBest), 1 ); Cudd_Ref(pNodeNew->pData);
+ pNodeNew->pData = Kit_TruthToBdd( (DdManager *)pNtkNew->pManFunc, If_CutTruth(pCutBest), If_CutLeaveNum(pCutBest), 1 ); Cudd_Ref((DdNode *)pNodeNew->pData);
}
else if ( pIfMan->pPars->fUseSops )
{
@@ -347,21 +417,26 @@ Abc_Obj_t * Abc_NodeFromIf_rec( Abc_Ntk_t * pNtkNew, If_Man_t * pIfMan, If_Obj_t
if ( Vec_IntSize(vCover) == 0 || (Vec_IntSize(vCover) == 1 && Vec_IntEntry(vCover,0) == 0) )
{
assert( RetValue == 0 );
- pNodeNew->pData = Abc_SopCreateAnd( pNtkNew->pManFunc, If_CutLeaveNum(pCutBest), NULL );
+ pNodeNew->pData = Abc_SopCreateAnd( (Extra_MmFlex_t *)pNtkNew->pManFunc, If_CutLeaveNum(pCutBest), NULL );
pNodeNew = (Vec_IntSize(vCover) == 0) ? Abc_NtkCreateNodeConst0(pNtkNew) : Abc_NtkCreateNodeConst1(pNtkNew);
}
else
{
// derive the AIG for that tree
- pNodeNew->pData = Abc_SopCreateFromIsop( pNtkNew->pManFunc, If_CutLeaveNum(pCutBest), vCover );
+ pNodeNew->pData = Abc_SopCreateFromIsop( (Extra_MmFlex_t *)pNtkNew->pManFunc, If_CutLeaveNum(pCutBest), vCover );
if ( RetValue )
- Abc_SopComplement( pNodeNew->pData );
+ Abc_SopComplement( (char *)pNodeNew->pData );
}
}
- else
+ else if ( pIfMan->pPars->fDelayOpt )
+ {
+ extern Hop_Obj_t * Abc_NodeTruthToHop( Hop_Man_t * pMan, If_Man_t * pIfMan, If_Cut_t * pCut );
+ pNodeNew->pData = Abc_NodeTruthToHop( (Hop_Man_t *)pNtkNew->pManFunc, pIfMan, pCutBest );
+ }
+ else
{
extern Hop_Obj_t * Kit_TruthToHop( Hop_Man_t * pMan, unsigned * pTruth, int nVars, Vec_Int_t * vMemory );
- pNodeNew->pData = Kit_TruthToHop( pNtkNew->pManFunc, If_CutTruth(pCutBest), If_CutLeaveNum(pCutBest), vCover );
+ pNodeNew->pData = Kit_TruthToHop( (Hop_Man_t *)pNtkNew->pManFunc, If_CutTruth(pCutBest), If_CutLeaveNum(pCutBest), vCover );
}
// complement the node if the cut was complemented
if ( pCutBest->fCompl )
@@ -369,9 +444,18 @@ Abc_Obj_t * Abc_NodeFromIf_rec( Abc_Ntk_t * pNtkNew, If_Man_t * pIfMan, If_Obj_t
}
else
{
- pNodeNew->pData = Abc_NodeIfToHop( pNtkNew->pManFunc, pIfMan, pIfObj );
+ pNodeNew->pData = Abc_NodeIfToHop( (Hop_Man_t *)pNtkNew->pManFunc, pIfMan, pIfObj );
}
If_ObjSetCopy( pIfObj, pNodeNew );
+/*
+printf( "%3d : Delay = %d Cutsize = %d\n", pNodeNew->Id, (int)pCutBest->Delay, pCutBest->nLeaves );
+{
+ Abc_Obj_t * pFanin;
+ int i;
+Abc_ObjForEachFanin( pNodeNew, pFanin, i )
+printf( "fanin%d = %2d\n", i, pFanin->Id );
+}
+*/
return pNodeNew;
}
@@ -394,7 +478,7 @@ Hop_Obj_t * Abc_NodeIfToHop_rec( Hop_Man_t * pHopMan, If_Man_t * pIfMan, If_Obj_
pCut = If_ObjCutBest(pIfObj);
// if the cut is visited, return the result
if ( If_CutData(pCut) )
- return If_CutData(pCut);
+ return (Hop_Obj_t *)If_CutData(pCut);
// compute the functions of the children
gFunc0 = Abc_NodeIfToHop_rec( pHopMan, pIfMan, pIfObj->pFanin0, vVisited );
gFunc1 = Abc_NodeIfToHop_rec( pHopMan, pIfMan, pIfObj->pFanin1, vVisited );
@@ -428,14 +512,14 @@ Hop_Obj_t * Abc_NodeIfToHop2_rec( Hop_Man_t * pHopMan, If_Man_t * pIfMan, If_Obj
pCut = If_ObjCutBest(pIfObj);
// if the cut is visited, return the result
if ( If_CutData(pCut) )
- return If_CutData(pCut);
+ return (Hop_Obj_t *)If_CutData(pCut);
// mark the node as visited
Vec_PtrPush( vVisited, pCut );
// insert the worst case
If_CutSetData( pCut, (void *)1 );
// skip in case of primary input
if ( If_ObjIsCi(pIfObj) )
- return If_CutData(pCut);
+ return (Hop_Obj_t *)If_CutData(pCut);
// compute the functions of the children
for ( pTemp = pIfObj; pTemp; pTemp = pTemp->pEquiv )
{
@@ -452,7 +536,7 @@ Hop_Obj_t * Abc_NodeIfToHop2_rec( Hop_Man_t * pHopMan, If_Man_t * pIfMan, If_Obj
If_CutSetData( pCut, gFunc );
break;
}
- return If_CutData(pCut);
+ return (Hop_Obj_t *)If_CutData(pCut);
}
/**Function*************************************************************
@@ -490,7 +574,7 @@ Hop_Obj_t * Abc_NodeIfToHop( Hop_Man_t * pHopMan, If_Man_t * pIfMan, If_Obj_t *
// clean the cuts
If_CutForEachLeaf( pIfMan, pCut, pLeaf, i )
If_CutSetData( If_ObjCutBest(pLeaf), NULL );
- Vec_PtrForEachEntry( pIfMan->vTemp, pCut, i )
+ Vec_PtrForEachEntry( If_Cut_t *, pIfMan->vTemp, pCut, i )
If_CutSetData( pCut, NULL );
return gFunc;
}
@@ -590,14 +674,14 @@ Vec_Ptr_t * Abc_NtkFindGoodOrder( Abc_Ntk_t * pNtk )
qsort( (Abc_Obj_t **)Vec_PtrArray(vCos), Abc_NtkCoNum(pNtk),
sizeof(Abc_Obj_t *), (int (*)(const void *, const void *))Abc_ObjCompareFlow );
// verify sorting
- pFanin0 = Vec_PtrEntry(vCos, 0);
- pFanin1 = Vec_PtrEntryLast(vCos);
+ pFanin0 = (Abc_Obj_t *)Vec_PtrEntry(vCos, 0);
+ pFanin1 = (Abc_Obj_t *)Vec_PtrEntryLast(vCos);
assert( Abc_Int2Float((int)(ABC_PTRINT_T)pFanin0->pCopy) >= Abc_Int2Float((int)(ABC_PTRINT_T)pFanin1->pCopy) );
// collect the nodes in the topological order from the new array
Abc_NtkIncrementTravId( pNtk );
vNodes = Vec_PtrAlloc( 100 );
- Vec_PtrForEachEntry( vCos, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vCos, pNode, i )
{
Abc_NtkFindGoodOrder_rec( Abc_ObjFanin0(pNode), vNodes );
// printf( "%.2f ", Abc_Int2Float((int)pNode->pCopy) );
@@ -613,3 +697,5 @@ Vec_Ptr_t * Abc_NtkFindGoodOrder( Abc_Ntk_t * pNtk )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcIfMux.c b/src/base/abci/abcIfMux.c
new file mode 100644
index 00000000..bf9d6cff
--- /dev/null
+++ b/src/base/abci/abcIfMux.c
@@ -0,0 +1,422 @@
+/**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"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Abc_NtkFuncCof0( int t, int v )
+{
+ static int s_Truth[3] = { 0xAA, 0xCC, 0xF0 };
+ return 0xff & ((t & ~s_Truth[v]) | ((t & ~s_Truth[v]) << (1<<v)));
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Abc_NtkFuncCof1( int t, int v )
+{
+ static int s_Truth[3] = { 0xAA, 0xCC, 0xF0 };
+ return 0xff & ((t & s_Truth[v]) | ((t & s_Truth[v]) >> (1<<v)));
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Abc_NtkFuncHasVar( int t, int v )
+{
+ static int s_Truth[3] = { 0xAA, 0xCC, 0xF0 };
+ return ((t & s_Truth[v]) >> (1<<v)) != (t & ~s_Truth[v]);
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Abc_NtkFuncSuppSize( int t )
+{
+ return Abc_NtkFuncHasVar(t, 0) + Abc_NtkFuncHasVar(t, 1) + Abc_NtkFuncHasVar(t, 2);
+}
+
+/**Function*************************************************************
+
+ Synopsis [Precomputes MUXes and functions of less than 3 inputs.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Abc_NtkCutCostMuxPrecompute()
+{
+ int i, Value;
+ int CounterM = 0;
+ for ( i = 0; i < 256; i++ )
+ {
+ Value = 0;
+ if ( Abc_NtkFuncSuppSize( i ) < 3 )
+ Value = 1;
+ else
+ {
+ if ( (Abc_NtkFuncSuppSize(Abc_NtkFuncCof0(i,0)) == 1 && Abc_NtkFuncSuppSize(Abc_NtkFuncCof1(i,0)) == 1) ||
+ (Abc_NtkFuncSuppSize(Abc_NtkFuncCof0(i,1)) == 1 && Abc_NtkFuncSuppSize(Abc_NtkFuncCof1(i,1)) == 1) ||
+ (Abc_NtkFuncSuppSize(Abc_NtkFuncCof0(i,2)) == 1 && Abc_NtkFuncSuppSize(Abc_NtkFuncCof1(i,2)) == 1) )
+ {
+ Value = 1;
+ CounterM++;
+ }
+ }
+ printf( "%d, // %3d 0x%02X\n", Value, i, i );
+ }
+ printf( "Total number of MUXes = %d.\n", CounterM );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Procedure returning the cost of the cut.]
+
+ Description [The number of MUXes needed to implement the function.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_NtkCutCostMux( If_Cut_t * pCut )
+{
+ static char uLookup[256] = {
+ 1, // 0 0x00
+ 0, // 1 0x01
+ 0, // 2 0x02
+ 1, // 3 0x03
+ 0, // 4 0x04
+ 1, // 5 0x05
+ 0, // 6 0x06
+ 0, // 7 0x07
+ 0, // 8 0x08
+ 0, // 9 0x09
+ 1, // 10 0x0A
+ 0, // 11 0x0B
+ 1, // 12 0x0C
+ 0, // 13 0x0D
+ 0, // 14 0x0E
+ 1, // 15 0x0F
+ 0, // 16 0x10
+ 1, // 17 0x11
+ 0, // 18 0x12
+ 0, // 19 0x13
+ 0, // 20 0x14
+ 0, // 21 0x15
+ 0, // 22 0x16
+ 0, // 23 0x17
+ 0, // 24 0x18
+ 0, // 25 0x19
+ 0, // 26 0x1A
+ 1, // 27 0x1B
+ 0, // 28 0x1C
+ 1, // 29 0x1D
+ 0, // 30 0x1E
+ 0, // 31 0x1F
+ 0, // 32 0x20
+ 0, // 33 0x21
+ 1, // 34 0x22
+ 0, // 35 0x23
+ 0, // 36 0x24
+ 0, // 37 0x25
+ 0, // 38 0x26
+ 1, // 39 0x27
+ 0, // 40 0x28
+ 0, // 41 0x29
+ 0, // 42 0x2A
+ 0, // 43 0x2B
+ 0, // 44 0x2C
+ 0, // 45 0x2D
+ 1, // 46 0x2E
+ 0, // 47 0x2F
+ 1, // 48 0x30
+ 0, // 49 0x31
+ 0, // 50 0x32
+ 1, // 51 0x33
+ 0, // 52 0x34
+ 1, // 53 0x35
+ 0, // 54 0x36
+ 0, // 55 0x37
+ 0, // 56 0x38
+ 0, // 57 0x39
+ 1, // 58 0x3A
+ 0, // 59 0x3B
+ 1, // 60 0x3C
+ 0, // 61 0x3D
+ 0, // 62 0x3E
+ 1, // 63 0x3F
+ 0, // 64 0x40
+ 0, // 65 0x41
+ 0, // 66 0x42
+ 0, // 67 0x43
+ 1, // 68 0x44
+ 0, // 69 0x45
+ 0, // 70 0x46
+ 1, // 71 0x47
+ 0, // 72 0x48
+ 0, // 73 0x49
+ 0, // 74 0x4A
+ 0, // 75 0x4B
+ 0, // 76 0x4C
+ 0, // 77 0x4D
+ 1, // 78 0x4E
+ 0, // 79 0x4F
+ 1, // 80 0x50
+ 0, // 81 0x51
+ 0, // 82 0x52
+ 1, // 83 0x53
+ 0, // 84 0x54
+ 1, // 85 0x55
+ 0, // 86 0x56
+ 0, // 87 0x57
+ 0, // 88 0x58
+ 0, // 89 0x59
+ 1, // 90 0x5A
+ 0, // 91 0x5B
+ 1, // 92 0x5C
+ 0, // 93 0x5D
+ 0, // 94 0x5E
+ 1, // 95 0x5F
+ 0, // 96 0x60
+ 0, // 97 0x61
+ 0, // 98 0x62
+ 0, // 99 0x63
+ 0, // 100 0x64
+ 0, // 101 0x65
+ 1, // 102 0x66
+ 0, // 103 0x67
+ 0, // 104 0x68
+ 0, // 105 0x69
+ 0, // 106 0x6A
+ 0, // 107 0x6B
+ 0, // 108 0x6C
+ 0, // 109 0x6D
+ 0, // 110 0x6E
+ 0, // 111 0x6F
+ 0, // 112 0x70
+ 0, // 113 0x71
+ 1, // 114 0x72
+ 0, // 115 0x73
+ 1, // 116 0x74
+ 0, // 117 0x75
+ 0, // 118 0x76
+ 1, // 119 0x77
+ 0, // 120 0x78
+ 0, // 121 0x79
+ 0, // 122 0x7A
+ 0, // 123 0x7B
+ 0, // 124 0x7C
+ 0, // 125 0x7D
+ 0, // 126 0x7E
+ 0, // 127 0x7F
+ 0, // 128 0x80
+ 0, // 129 0x81
+ 0, // 130 0x82
+ 0, // 131 0x83
+ 0, // 132 0x84
+ 0, // 133 0x85
+ 0, // 134 0x86
+ 0, // 135 0x87
+ 1, // 136 0x88
+ 0, // 137 0x89
+ 0, // 138 0x8A
+ 1, // 139 0x8B
+ 0, // 140 0x8C
+ 1, // 141 0x8D
+ 0, // 142 0x8E
+ 0, // 143 0x8F
+ 0, // 144 0x90
+ 0, // 145 0x91
+ 0, // 146 0x92
+ 0, // 147 0x93
+ 0, // 148 0x94
+ 0, // 149 0x95
+ 0, // 150 0x96
+ 0, // 151 0x97
+ 0, // 152 0x98
+ 1, // 153 0x99
+ 0, // 154 0x9A
+ 0, // 155 0x9B
+ 0, // 156 0x9C
+ 0, // 157 0x9D
+ 0, // 158 0x9E
+ 0, // 159 0x9F
+ 1, // 160 0xA0
+ 0, // 161 0xA1
+ 0, // 162 0xA2
+ 1, // 163 0xA3
+ 0, // 164 0xA4
+ 1, // 165 0xA5
+ 0, // 166 0xA6
+ 0, // 167 0xA7
+ 0, // 168 0xA8
+ 0, // 169 0xA9
+ 1, // 170 0xAA
+ 0, // 171 0xAB
+ 1, // 172 0xAC
+ 0, // 173 0xAD
+ 0, // 174 0xAE
+ 1, // 175 0xAF
+ 0, // 176 0xB0
+ 1, // 177 0xB1
+ 0, // 178 0xB2
+ 0, // 179 0xB3
+ 0, // 180 0xB4
+ 0, // 181 0xB5
+ 0, // 182 0xB6
+ 0, // 183 0xB7
+ 1, // 184 0xB8
+ 0, // 185 0xB9
+ 0, // 186 0xBA
+ 1, // 187 0xBB
+ 0, // 188 0xBC
+ 0, // 189 0xBD
+ 0, // 190 0xBE
+ 0, // 191 0xBF
+ 1, // 192 0xC0
+ 0, // 193 0xC1
+ 0, // 194 0xC2
+ 1, // 195 0xC3
+ 0, // 196 0xC4
+ 1, // 197 0xC5
+ 0, // 198 0xC6
+ 0, // 199 0xC7
+ 0, // 200 0xC8
+ 0, // 201 0xC9
+ 1, // 202 0xCA
+ 0, // 203 0xCB
+ 1, // 204 0xCC
+ 0, // 205 0xCD
+ 0, // 206 0xCE
+ 1, // 207 0xCF
+ 0, // 208 0xD0
+ 1, // 209 0xD1
+ 0, // 210 0xD2
+ 0, // 211 0xD3
+ 0, // 212 0xD4
+ 0, // 213 0xD5
+ 0, // 214 0xD6
+ 0, // 215 0xD7
+ 1, // 216 0xD8
+ 0, // 217 0xD9
+ 0, // 218 0xDA
+ 0, // 219 0xDB
+ 0, // 220 0xDC
+ 1, // 221 0xDD
+ 0, // 222 0xDE
+ 0, // 223 0xDF
+ 0, // 224 0xE0
+ 0, // 225 0xE1
+ 1, // 226 0xE2
+ 0, // 227 0xE3
+ 1, // 228 0xE4
+ 0, // 229 0xE5
+ 0, // 230 0xE6
+ 0, // 231 0xE7
+ 0, // 232 0xE8
+ 0, // 233 0xE9
+ 0, // 234 0xEA
+ 0, // 235 0xEB
+ 0, // 236 0xEC
+ 0, // 237 0xED
+ 1, // 238 0xEE
+ 0, // 239 0xEF
+ 1, // 240 0xF0
+ 0, // 241 0xF1
+ 0, // 242 0xF2
+ 1, // 243 0xF3
+ 0, // 244 0xF4
+ 1, // 245 0xF5
+ 0, // 246 0xF6
+ 0, // 247 0xF7
+ 0, // 248 0xF8
+ 0, // 249 0xF9
+ 1, // 250 0xFA
+ 0, // 251 0xFB
+ 1, // 252 0xFC
+ 0, // 253 0xFD
+ 0, // 254 0xFE
+ 1 // 255 0xFF
+ };
+ if ( pCut->nLeaves < 3 )
+ return 1;
+ if ( pCut->nLeaves == 3 && uLookup[0xff & *If_CutTruth(pCut)] )
+ return 1;
+ return (1 << pCut->nLeaves) - 1;
+}
+
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcIvy.c b/src/base/abci/abcIvy.c
index 904d612b..759c96a7 100644
--- a/src/base/abci/abcIvy.c
+++ b/src/base/abci/abcIvy.c
@@ -20,8 +20,19 @@
#include "abc.h"
#include "dec.h"
+#include "fra.h"
#include "ivy.h"
#include "fraig.h"
+#include "mio.h"
+#include "aig.h"
+
+ABC_NAMESPACE_IMPL_START
+
+extern Aig_Man_t * Abc_NtkToDar( Abc_Ntk_t * pNtk, int fExors, int fRegisters );
+extern void Aig_ManStop( Aig_Man_t * pMan );
+//extern int Fra_FraigSat( Aig_Man_t * pMan, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, int fFlipBits, int fAndOuts, int fVerbose );
+extern Ivy_Obj_t * Dec_GraphToNetworkIvy( Ivy_Man_t * pMan, Dec_Graph_t * pGraph );
+extern void Ivy_CutComputeAll( Ivy_Man_t * p, int nInputs );
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -36,7 +47,6 @@ static Ivy_Obj_t * Abc_NodeStrashAig( Ivy_Man_t * pMan, Abc_Obj_t * pNode );
static Ivy_Obj_t * Abc_NodeStrashAigSopAig( Ivy_Man_t * pMan, Abc_Obj_t * pNode, char * pSop );
static Ivy_Obj_t * Abc_NodeStrashAigExorAig( Ivy_Man_t * pMan, Abc_Obj_t * pNode, char * pSop );
static Ivy_Obj_t * Abc_NodeStrashAigFactorAig( Ivy_Man_t * pMan, Abc_Obj_t * pNode, char * pSop );
-extern char * Mio_GateReadSop( void * pGate );
typedef int Abc_Edge_t;
static inline Abc_Edge_t Abc_EdgeCreate( int Id, int fCompl ) { return (Id << 1) | fCompl; }
@@ -133,7 +143,7 @@ Abc_Ntk_t * Abc_NtkIvyAfter( Abc_Ntk_t * pNtk, Ivy_Man_t * pMan, int fSeq, int f
else
pNtkAig = Abc_NtkFromIvy( pNtk, pMan );
// report the cleanup results
- if ( !fHaig && fCleanup && (nNodes = Abc_AigCleanup(pNtkAig->pManFunc)) )
+ if ( !fHaig && fCleanup && (nNodes = Abc_AigCleanup((Abc_Aig_t *)pNtkAig->pManFunc)) )
printf( "Warning: AIG cleanup removed %d nodes (this is not a bug).\n", nNodes );
// duplicate EXDC
if ( pNtk->pExdc )
@@ -252,7 +262,6 @@ clk = clock();
***********************************************************************/
void Abc_NtkIvyCuts( Abc_Ntk_t * pNtk, int nInputs )
{
- extern void Ivy_CutComputeAll( Ivy_Man_t * p, int nInputs );
Ivy_Man_t * pMan;
pMan = Abc_NtkIvyBefore( pNtk, 1, 0 );
if ( pMan == NULL )
@@ -487,10 +496,12 @@ Abc_Ntk_t * Abc_NtkIvyFraig( Abc_Ntk_t * pNtk, int nConfLimit, int fDoSparse, in
***********************************************************************/
int Abc_NtkIvyProve( Abc_Ntk_t ** ppNtk, void * pPars )
{
- Prove_Params_t * pParams = pPars;
+
+ Prove_Params_t * pParams = (Prove_Params_t *)pPars;
Abc_Ntk_t * pNtk = *ppNtk, * pNtkTemp;
Abc_Obj_t * pObj, * pFanin;
Ivy_Man_t * pMan;
+ Aig_Man_t * pMan2;
int RetValue;
assert( Abc_NtkIsStrash(pNtk) || Abc_NtkIsLogic(pNtk) );
// experiment with various parameters settings
@@ -515,8 +526,18 @@ int Abc_NtkIvyProve( Abc_Ntk_t ** ppNtk, void * pPars )
return 0;
}
+ // changed in "src\sat\fraig\fraigMan.c"
+ // pParams->nMiteringLimitStart = 300; // starting mitering limit
+ // to be
+ // pParams->nMiteringLimitStart = 5000; // starting mitering limit
+
// if SAT only, solve without iteration
- RetValue = Abc_NtkMiterSat( pNtk, 2*(ABC_INT64_T)pParams->nMiteringLimitStart, (ABC_INT64_T)0, 0, NULL, NULL );
+// RetValue = Abc_NtkMiterSat( pNtk, 2*(ABC_INT64_T)pParams->nMiteringLimitStart, (ABC_INT64_T)0, 0, NULL, NULL );
+ pMan2 = Abc_NtkToDar( pNtk, 0, 0 );
+ RetValue = Fra_FraigSat( pMan2, (ABC_INT64_T)pParams->nMiteringLimitStart, (ABC_INT64_T)0, 1, 0, 0 );
+ pNtk->pModel = (int *)pMan2->pData, pMan2->pData = NULL;
+ Aig_ManStop( pMan2 );
+// pNtk->pModel = Aig_ManReleaseData( pMan2 );
if ( RetValue >= 0 )
return RetValue;
@@ -546,7 +567,7 @@ int Abc_NtkIvyProve( Abc_Ntk_t ** ppNtk, void * pPars )
pNtk = Abc_NtkIvyAfter( pNtkTemp = pNtk, pMan, 0, 0 );
Abc_NtkDelete( pNtkTemp );
// transfer model if given
- pNtk->pModel = pMan->pData; pMan->pData = NULL;
+ pNtk->pModel = (int *)pMan->pData; pMan->pData = NULL;
Ivy_ManStop( pMan );
// try to prove it using brute force SAT
@@ -561,7 +582,7 @@ int Abc_NtkIvyProve( Abc_Ntk_t ** ppNtk, void * pPars )
if ( pNtk )
{
Abc_NtkDelete( pNtkTemp );
- RetValue = ( (Abc_NtkNodeNum(pNtk) == 1) && (Abc_ObjFanin0(Abc_NtkPo(pNtk,0))->pData == Cudd_ReadLogicZero(pNtk->pManFunc)) );
+ RetValue = ( (Abc_NtkNodeNum(pNtk) == 1) && (Abc_ObjFanin0(Abc_NtkPo(pNtk,0))->pData == Cudd_ReadLogicZero((DdManager *)pNtk->pManFunc)) );
}
else
pNtk = pNtkTemp;
@@ -724,9 +745,9 @@ Abc_Ntk_t * Abc_NtkFromIvy( Abc_Ntk_t * pNtkOld, Ivy_Man_t * pMan )
pFaninNew1 = Abc_ObjFanin1Ivy( pNtk, pNode );
// create the new node
if ( Ivy_ObjIsExor(pNode) )
- pObjNew = Abc_AigXor( pNtk->pManFunc, pFaninNew0, pFaninNew1 );
+ pObjNew = Abc_AigXor( (Abc_Aig_t *)pNtk->pManFunc, pFaninNew0, pFaninNew1 );
else
- pObjNew = Abc_AigAnd( pNtk->pManFunc, pFaninNew0, pFaninNew1 );
+ pObjNew = Abc_AigAnd( (Abc_Aig_t *)pNtk->pManFunc, pFaninNew0, pFaninNew1 );
pNode->TravId = Abc_EdgeFromNode( pObjNew );
}
// connect the PO nodes
@@ -799,9 +820,9 @@ Abc_Ntk_t * Abc_NtkFromIvySeq( Abc_Ntk_t * pNtkOld, Ivy_Man_t * pMan, int fHaig
pFaninNew1 = Abc_ObjFanin1Ivy( pNtk, pNode );
// create the new node
if ( Ivy_ObjIsExor(pNode) )
- pObjNew = Abc_AigXor( pNtk->pManFunc, pFaninNew0, pFaninNew1 );
+ pObjNew = Abc_AigXor( (Abc_Aig_t *)pNtk->pManFunc, pFaninNew0, pFaninNew1 );
else
- pObjNew = Abc_AigAnd( pNtk->pManFunc, pFaninNew0, pFaninNew1 );
+ pObjNew = Abc_AigAnd( (Abc_Aig_t *)pNtk->pManFunc, pFaninNew0, pFaninNew1 );
pNode->TravId = Abc_EdgeFromNode( pObjNew );
// process the choice nodes
if ( fHaig && pNode->pEquiv && Ivy_ObjRefs(pNode) > 0 )
@@ -896,7 +917,7 @@ void Abc_NtkStrashPerformAig( Abc_Ntk_t * pNtk, Ivy_Man_t * pMan )
int i;
vNodes = Abc_NtkDfs( pNtk, 0 );
// pProgress = Extra_ProgressBarStart( stdout, vNodes->nSize );
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
{
// Extra_ProgressBarUpdate( pProgress, i, NULL );
pNode->pCopy = (Abc_Obj_t *)Abc_NodeStrashAig( pMan, pNode );
@@ -938,9 +959,9 @@ Ivy_Obj_t * Abc_NodeStrashAig( Ivy_Man_t * pMan, Abc_Obj_t * pNode )
// get the SOP of the node
if ( Abc_NtkHasMapping(pNode->pNtk) )
- pSop = Mio_GateReadSop(pNode->pData);
+ pSop = Mio_GateReadSop((Mio_Gate_t *)pNode->pData);
else
- pSop = pNode->pData;
+ pSop = (char *)pNode->pData;
// consider the constant node
if ( Abc_NodeIsConst(pNode) )
@@ -1049,7 +1070,6 @@ Ivy_Obj_t * Abc_NodeStrashAigFactorAig( Ivy_Man_t * pMan, Abc_Obj_t * pRoot, cha
int i;
// extern Ivy_Obj_t * Dec_GraphToNetworkAig( Ivy_Man_t * pMan, Dec_Graph_t * pGraph );
- extern Ivy_Obj_t * Dec_GraphToNetworkIvy( Ivy_Man_t * pMan, Dec_Graph_t * pGraph );
// assert( 0 );
@@ -1102,3 +1122,5 @@ Vec_Int_t * Abc_NtkCollectLatchValuesIvy( Abc_Ntk_t * pNtk, int fUseDcs )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcLog.c b/src/base/abci/abcLog.c
new file mode 100644
index 00000000..45dafb98
--- /dev/null
+++ b/src/base/abci/abcLog.c
@@ -0,0 +1,215 @@
+/**CFile****************************************************************
+
+ FileName [abcLog.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Network and node package.]
+
+ Synopsis [Log file printing.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: abcLog.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "abc.h"
+#include "gia.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/*
+ Log file format (Jiang, Mon, 28 Sep 2009)
+
+ <result> <cyc> <engine_name>
+ <TRACE> : default is "NULL"
+ <INIT_STATE> : default is "NULL"
+
+ <retult> is the following:
+ snl_SAT
+ snl_UNSAT
+ snl_UNK
+ snl_ABORT
+
+ <cyc> : # of cycles
+
+ <INIT_STATE> : initial state
+ <TRACE> : input vector
+
+ <INIT_STATE>and <TRACE> are strings of 0/1/- ( - means don't care). The length is equivalent to #input*#<cyc>.
+*/
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Abc_NtkWriteLogFile( char * pFileName, Abc_Cex_t * pCex, int Status, char * pCommand )
+{
+ FILE * pFile;
+ int i;
+ pFile = fopen( pFileName, "w" );
+ if ( pFile == NULL )
+ {
+ printf( "Cannot open log file for writing \"%s\".\n" , pFileName );
+ return;
+ }
+ // write <result>
+ if ( Status == 1 )
+ fprintf( pFile, "snl_UNSAT" );
+ else if ( Status == 0 )
+ fprintf( pFile, "snl_SAT" );
+ else if ( Status == -1 )
+ fprintf( pFile, "snl_UNK" );
+ else
+ printf( "Abc_NtkWriteLogFile(): Cannot recognize solving status.\n" );
+ fprintf( pFile, " " );
+ // write <cyc>
+ fprintf( pFile, "%d", pCex ? pCex->iFrame + 1 : -1 );
+ fprintf( pFile, " " );
+ // write <engine_name>
+ fprintf( pFile, "%s", pCommand ? pCommand : "unknown" );
+ fprintf( pFile, "\n" );
+ // write <INIT_STATE>
+ if ( pCex == NULL )
+ fprintf( pFile, "NULL" );
+ else
+ {
+ for ( i = 0; i < pCex->nRegs; i++ )
+ fprintf( pFile, "%d", Gia_InfoHasBit(pCex->pData,i) );
+ }
+ fprintf( pFile, "\n" );
+ // write <TRACE>
+ if ( pCex == NULL )
+ fprintf( pFile, "NULL" );
+ else
+ {
+ assert( pCex->nBits - pCex->nRegs == pCex->nPis * (pCex->iFrame + 1) );
+ for ( i = pCex->nRegs; i < pCex->nBits; i++ )
+ fprintf( pFile, "%d", Gia_InfoHasBit(pCex->pData,i) );
+ }
+ fprintf( pFile, "\n" );
+ fclose( pFile );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_NtkReadLogFile( char * pFileName, Abc_Cex_t ** ppCex )
+{
+ Abc_Cex_t * pCex;
+ Vec_Int_t * vNums;
+ char Buffer[1000];
+ FILE * pFile;
+ int c, nRegs = -1, nFrames = -1, Status = -1;
+ pFile = fopen( pFileName, "r" );
+ if ( pFile == NULL )
+ {
+ printf( "Cannot open log file for reading \"%s\".\n" , pFileName );
+ return -1;
+ }
+ fgets( Buffer, 1000, pFile );
+ if ( !strncmp( Buffer, "snl_UNSAT", strlen("snl_UNSAT") ) )
+ {
+ Status = 1;
+ nFrames = atoi( Buffer + strlen("snl_UNSAT") );
+ }
+ else if ( !strncmp( Buffer, "snl_SAT", strlen("snl_SAT") ) )
+ {
+ Status = 0;
+ nFrames = atoi( Buffer + strlen("snl_SAT") );
+ }
+ else if ( !strncmp( Buffer, "snl_UNK", strlen("snl_UNK") ) )
+ {
+ Status = -1;
+ nFrames = atoi( Buffer + strlen("snl_UNK") );
+ }
+ else
+ {
+ printf( "Unrecognized status.\n" );
+ }
+ // found regs till the new line
+ vNums = Vec_IntAlloc( 100 );
+ while ( (c = fgetc(pFile)) != EOF )
+ {
+ if ( c == '\n' )
+ break;
+ if ( c == '0' || c == '1' )
+ Vec_IntPush( vNums, c - '0' );
+ }
+ nRegs = Vec_IntSize(vNums);
+ // skip till the new line
+ while ( (c = fgetc(pFile)) != EOF )
+ {
+ if ( c == '0' || c == '1' )
+ Vec_IntPush( vNums, c - '0' );
+ }
+ fclose( pFile );
+ if ( Vec_IntSize(vNums) )
+ {
+ if ( nRegs == 0 )
+ {
+ printf( "Cannot read register number.\n" );
+ return -1;
+ }
+ if ( Vec_IntSize(vNums)-nRegs == 0 )
+ {
+ printf( "Cannot read counter example.\n" );
+ return -1;
+ }
+ if ( (Vec_IntSize(vNums)-nRegs) % nFrames != 0 )
+ {
+ printf( "Incorrect number of bits.\n" );
+ return -1;
+ }
+ pCex = Gia_ManAllocCounterExample( nRegs, (Vec_IntSize(vNums)-nRegs)/nFrames, nFrames );
+ pCex->iPo = 0;
+ pCex->iFrame = nFrames - 1;
+ assert( Vec_IntSize(vNums) == pCex->nBits );
+ for ( c = 0; c < pCex->nBits; c++ )
+ if ( Vec_IntEntry(vNums, c) )
+ Gia_InfoSetBit( pCex->pData, c );
+ Vec_IntFree( vNums );
+ if ( ppCex )
+ *ppCex = pCex;
+ else
+ ABC_FREE( pCex );
+ }
+ return Status;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcLut.c b/src/base/abci/abcLut.c
index 089f4107..a33cc7db 100644
--- a/src/base/abci/abcLut.c
+++ b/src/base/abci/abcLut.c
@@ -21,6 +21,8 @@
#include "abc.h"
#include "cut.h"
+ABC_NAMESPACE_IMPL_START
+
#define LARGE_LEVEL 1000000
////////////////////////////////////////////////////////////////////////
@@ -346,10 +348,10 @@ unsigned * Abc_NodeSuperChoiceTruth( Abc_ManScl_t * pManScl )
char * pSop;
int i, k;
// set elementary truth tables
- Vec_PtrForEachEntry( pManScl->vLeaves, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, pManScl->vLeaves, pObj, i )
pObj->pNext = (Abc_Obj_t *)pManScl->uVars[i];
// compute truth tables for internal nodes
- Vec_PtrForEachEntry( pManScl->vVolume, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, pManScl->vVolume, pObj, i )
{
// set storage for the node's simulation info
pObj->pNext = (Abc_Obj_t *)pManScl->uSims[i];
@@ -358,7 +360,7 @@ unsigned * Abc_NodeSuperChoiceTruth( Abc_ManScl_t * pManScl )
puData0 = (unsigned *)Abc_ObjFanin0(pObj)->pNext;
puData1 = (unsigned *)Abc_ObjFanin1(pObj)->pNext;
// simulate
- pSop = pObj->pData;
+ pSop = (char *)pObj->pData;
if ( pSop[0] == '0' && pSop[1] == '0' )
for ( k = 0; k < pManScl->nWords; k++ )
puData[k] = ~puData0[k] & ~puData1[k];
@@ -412,13 +414,13 @@ void Abc_NodeSuperChoiceCollect2( Abc_Obj_t * pRoot, Vec_Ptr_t * vLeaves, Vec_Pt
{
Abc_Obj_t * pObj;
int i;
- Vec_PtrForEachEntry( vLeaves, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pObj, i )
pObj->fMarkC = 1;
Vec_PtrClear( vVolume );
Abc_NodeSuperChoiceCollect2_rec( pRoot, vVolume );
- Vec_PtrForEachEntry( vLeaves, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pObj, i )
pObj->fMarkC = 0;
- Vec_PtrForEachEntry( vVolume, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vVolume, pObj, i )
pObj->fMarkC = 0;
}
@@ -465,15 +467,15 @@ void Abc_NodeSuperChoiceCollect( Abc_Obj_t * pRoot, Vec_Ptr_t * vLeaves, Vec_Ptr
Abc_Obj_t * pObj;
int i, nLeaves;
nLeaves = Vec_PtrSize(vLeaves);
- Vec_PtrForEachEntry( vLeaves, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pObj, i )
pObj->fMarkB = pObj->fMarkC = 1;
Vec_PtrClear( vVolume );
Vec_PtrClear( vLeaves );
Abc_NodeSuperChoiceCollect_rec( pRoot, vLeaves, vVolume );
assert( Vec_PtrSize(vLeaves) == nLeaves );
- Vec_PtrForEachEntry( vLeaves, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pObj, i )
pObj->fMarkC = 0;
- Vec_PtrForEachEntry( vVolume, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vVolume, pObj, i )
pObj->fMarkC = 0;
}
@@ -554,7 +556,7 @@ Abc_Obj_t * Abc_NodeSuperChoiceLut( Abc_ManScl_t * p, Abc_Obj_t * pObj )
if ( uSupport & (1 << i) )
break;
assert( i < nVars );
- pFanin = Vec_PtrEntry( p->vLeaves, i );
+ pFanin = (Abc_Obj_t *)Vec_PtrEntry( p->vLeaves, i );
pObj->Level = pFanin->Level;
return NULL;
}
@@ -570,17 +572,17 @@ Abc_Obj_t * Abc_NodeSuperChoiceLut( Abc_ManScl_t * p, Abc_Obj_t * pObj )
while ( Vec_PtrSize(p->vLeaves) > p->nLutSize )
if ( !Abc_NodeDecomposeStep( p ) )
{
- Vec_PtrForEachEntry( p->vLeaves, pFanin, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vLeaves, pFanin, i )
if ( Abc_ObjIsNode(pFanin) && Abc_ObjFanoutNum(pFanin) == 0 )
Abc_NtkDeleteObj_rec( pFanin, 1 );
return NULL;
}
// create the topmost node
pObjNew = Abc_NtkCreateNode( pObj->pNtk );
- Vec_PtrForEachEntry( p->vLeaves, pFanin, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vLeaves, pFanin, i )
Abc_ObjAddFanin( pObjNew, pFanin );
// create the function
- pObjNew->pData = Abc_SopCreateFromTruth( pObj->pNtk->pManFunc, Vec_PtrSize(p->vLeaves), p->uTruth ); // need ISOP
+ pObjNew->pData = Abc_SopCreateFromTruth( (Extra_MmFlex_t *)pObj->pNtk->pManFunc, Vec_PtrSize(p->vLeaves), p->uTruth ); // need ISOP
pObjNew->Level = Abc_NodeGetLevel( pObjNew );
return pObjNew;
}
@@ -599,8 +601,8 @@ Abc_Obj_t * Abc_NodeSuperChoiceLut( Abc_ManScl_t * p, Abc_Obj_t * pObj )
int Abc_NodeCompareLevelsInc( int * pp1, int * pp2 )
{
Abc_Obj_t * pNode1, * pNode2;
- pNode1 = Vec_PtrEntry(s_pLeaves, *pp1);
- pNode2 = Vec_PtrEntry(s_pLeaves, *pp2);
+ pNode1 = (Abc_Obj_t *)Vec_PtrEntry(s_pLeaves, *pp1);
+ pNode2 = (Abc_Obj_t *)Vec_PtrEntry(s_pLeaves, *pp2);
if ( pNode1->Level < pNode2->Level )
return -1;
if ( pNode1->Level > pNode2->Level )
@@ -757,11 +759,11 @@ int Abc_NodeDecomposeStep( Abc_ManScl_t * p )
pObjNew = Abc_NtkCreateNode( pNtk );
for ( i = 0; i < p->nLutSize; i++ )
{
- pFanin = Vec_PtrEntry( p->vLeaves, p->pBSet[i] );
+ pFanin = (Abc_Obj_t *)Vec_PtrEntry( p->vLeaves, p->pBSet[i] );
Abc_ObjAddFanin( pObjNew, pFanin );
}
// create the function
- pObjNew->pData = Abc_SopCreateFromTruth( pNtk->pManFunc, p->nLutSize, pTruth ); // need ISOP
+ pObjNew->pData = Abc_SopCreateFromTruth( (Extra_MmFlex_t *)pNtk->pManFunc, p->nLutSize, pTruth ); // need ISOP
pObjNew->Level = Abc_NodeGetLevel( pObjNew );
pNodesNew[v] = pObjNew;
}
@@ -785,4 +787,7 @@ int Abc_NodeDecomposeStep( Abc_ManScl_t * p )
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
+
diff --git a/src/base/abci/abcLutmin.c b/src/base/abci/abcLutmin.c
index 41ee25fe..71dea2e1 100644
--- a/src/base/abci/abcLutmin.c
+++ b/src/base/abci/abcLutmin.c
@@ -20,6 +20,9 @@
#include "abc.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*
Implememented here is the algorithm for minimal-LUT decomposition
described in the paper: T. Sasao et al. "On the number of LUTs
@@ -47,7 +50,7 @@
***********************************************************************/
Abc_Obj_t * Abc_NtkBddMux21( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pFanins[] )
{
- DdManager * dd = pNtkNew->pManFunc;
+ DdManager * dd = (DdManager *)pNtkNew->pManFunc;
Abc_Obj_t * pNode;
DdNode * bSpin, * bCof0, * bCof1;
pNode = Abc_NtkCreateNode( pNtkNew );
@@ -57,7 +60,7 @@ Abc_Obj_t * Abc_NtkBddMux21( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pFanins[] )
bSpin = Cudd_bddIthVar(dd, 0);
bCof0 = Cudd_bddIthVar(dd, 1);
bCof1 = Cudd_bddIthVar(dd, 2);
- pNode->pData = Cudd_bddIte( dd, bSpin, bCof1, bCof0 ); Cudd_Ref( pNode->pData );
+ pNode->pData = Cudd_bddIte( dd, bSpin, bCof1, bCof0 ); Cudd_Ref( (DdNode *)pNode->pData );
return pNode;
}
@@ -74,7 +77,7 @@ Abc_Obj_t * Abc_NtkBddMux21( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pFanins[] )
***********************************************************************/
Abc_Obj_t * Abc_NtkBddMux411( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pFanins[] )
{
- DdManager * dd = pNtkNew->pManFunc;
+ DdManager * dd = (DdManager *)pNtkNew->pManFunc;
Abc_Obj_t * pNode;
DdNode * bSpin, * bCof0, * bCof1;
pNode = Abc_NtkCreateNode( pNtkNew );
@@ -88,7 +91,7 @@ Abc_Obj_t * Abc_NtkBddMux411( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pFanins[] )
bCof0 = Cudd_bddIte( dd, bSpin, Cudd_bddIthVar(dd, 3), Cudd_bddIthVar(dd, 2) ); Cudd_Ref( bCof0 );
bCof1 = Cudd_bddIte( dd, bSpin, Cudd_bddIthVar(dd, 5), Cudd_bddIthVar(dd, 4) ); Cudd_Ref( bCof1 );
bSpin = Cudd_bddIthVar(dd, 0);
- pNode->pData = Cudd_bddIte( dd, bSpin, bCof1, bCof0 ); Cudd_Ref( pNode->pData );
+ pNode->pData = Cudd_bddIte( dd, bSpin, bCof1, bCof0 ); Cudd_Ref( (DdNode *)pNode->pData );
Cudd_RecursiveDeref( dd, bCof0 );
Cudd_RecursiveDeref( dd, bCof1 );
return pNode;
@@ -107,7 +110,7 @@ Abc_Obj_t * Abc_NtkBddMux411( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pFanins[] )
***********************************************************************/
Abc_Obj_t * Abc_NtkBddMux412( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pFanins[] )
{
- DdManager * dd = pNtkNew->pManFunc;
+ DdManager * dd = (DdManager *)pNtkNew->pManFunc;
Abc_Obj_t * pNodeBot, * pNodeTop;
DdNode * bSpin, * bCof0, * bCof1;
// bottom node
@@ -119,7 +122,7 @@ Abc_Obj_t * Abc_NtkBddMux412( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pFanins[] )
bSpin = Cudd_bddIthVar(dd, 0);
bCof0 = Cudd_bddIte( dd, Cudd_bddIthVar(dd, 1), Cudd_bddIthVar(dd, 3), Cudd_bddIthVar(dd, 2) ); Cudd_Ref( bCof0 );
bCof1 = Cudd_bddIthVar(dd, 1);
- pNodeBot->pData = Cudd_bddIte( dd, bSpin, bCof1, bCof0 ); Cudd_Ref( pNodeBot->pData );
+ pNodeBot->pData = Cudd_bddIte( dd, bSpin, bCof1, bCof0 ); Cudd_Ref( (DdNode *)pNodeBot->pData );
Cudd_RecursiveDeref( dd, bCof0 );
// top node
pNodeTop = Abc_NtkCreateNode( pNtkNew );
@@ -130,7 +133,7 @@ Abc_Obj_t * Abc_NtkBddMux412( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pFanins[] )
bSpin = Cudd_bddIthVar(dd, 0);
bCof0 = Cudd_bddIthVar(dd, 1);
bCof1 = Cudd_bddIte( dd, Cudd_bddIthVar(dd, 1), Cudd_bddIthVar(dd, 3), Cudd_bddIthVar(dd, 2) ); Cudd_Ref( bCof1 );
- pNodeTop->pData = Cudd_bddIte( dd, bSpin, bCof1, bCof0 ); Cudd_Ref( pNodeTop->pData );
+ pNodeTop->pData = Cudd_bddIte( dd, bSpin, bCof1, bCof0 ); Cudd_Ref( (DdNode *)pNodeTop->pData );
Cudd_RecursiveDeref( dd, bCof1 );
return pNodeTop;
}
@@ -148,7 +151,7 @@ Abc_Obj_t * Abc_NtkBddMux412( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pFanins[] )
***********************************************************************/
Abc_Obj_t * Abc_NtkBddMux412a( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pFanins[] )
{
- DdManager * dd = pNtkNew->pManFunc;
+ DdManager * dd = (DdManager *)pNtkNew->pManFunc;
Abc_Obj_t * pNodeBot, * pNodeTop;
DdNode * bSpin, * bCof0, * bCof1;
// bottom node
@@ -159,7 +162,7 @@ Abc_Obj_t * Abc_NtkBddMux412a( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pFanins[] )
bSpin = Cudd_bddIthVar(dd, 0);
bCof0 = Cudd_bddIthVar(dd, 1);
bCof1 = Cudd_bddIthVar(dd, 2);
- pNodeBot->pData = Cudd_bddIte( dd, bSpin, bCof1, bCof0 ); Cudd_Ref( pNodeBot->pData );
+ pNodeBot->pData = Cudd_bddIte( dd, bSpin, bCof1, bCof0 ); Cudd_Ref( (DdNode *)pNodeBot->pData );
// top node
pNodeTop = Abc_NtkCreateNode( pNtkNew );
Abc_ObjAddFanin( pNodeTop, pFanins[0] );
@@ -170,7 +173,7 @@ Abc_Obj_t * Abc_NtkBddMux412a( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pFanins[] )
bSpin = Cudd_bddIthVar(dd, 0);
bCof0 = Cudd_bddIthVar(dd, 2);
bCof1 = Cudd_bddIte( dd, Cudd_bddIthVar(dd, 1), Cudd_bddIthVar(dd, 4), Cudd_bddIthVar(dd, 3) ); Cudd_Ref( bCof1 );
- pNodeTop->pData = Cudd_bddIte( dd, bSpin, bCof1, bCof0 ); Cudd_Ref( pNodeTop->pData );
+ pNodeTop->pData = Cudd_bddIte( dd, bSpin, bCof1, bCof0 ); Cudd_Ref( (DdNode *)pNodeTop->pData );
Cudd_RecursiveDeref( dd, bCof1 );
return pNodeTop;
}
@@ -319,7 +322,7 @@ Extra_bddPrint( dd, bFuncNew );
printf( "\n" );
printf( "\n" );
}
- pNodeNew->pData = Extra_TransferLevelByLevel( dd, pNtkNew->pManFunc, bFuncNew ); Cudd_Ref( pNodeNew->pData );
+ pNodeNew->pData = Extra_TransferLevelByLevel( dd, (DdManager *)pNtkNew->pManFunc, bFuncNew ); Cudd_Ref( (DdNode *)pNodeNew->pData );
//Extra_bddPrint( pNtkNew->pManFunc, pNodeNew->pData );
//printf( "\n" );
//printf( "\n" );
@@ -340,8 +343,8 @@ printf( "\n" );
***********************************************************************/
Abc_Obj_t * Abc_NtkBddCurtis( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNode, Vec_Ptr_t * vCofs, Vec_Ptr_t * vUniq )
{
- DdManager * ddOld = pNode->pNtk->pManFunc;
- DdManager * ddNew = pNtkNew->pManFunc;
+ DdManager * ddOld = (DdManager *)pNode->pNtk->pManFunc;
+ DdManager * ddNew = (DdManager *)pNtkNew->pManFunc;
DdNode * bCof, * bUniq, * bMint, * bTemp, * bFunc, * bBits[10], ** pbCodeVars;
Abc_Obj_t * pNodeNew = NULL, * pNodeBS[10];
int nLutSize = Extra_Base2Log( Vec_PtrSize(vCofs) );
@@ -353,9 +356,9 @@ Abc_Obj_t * Abc_NtkBddCurtis( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNode, Vec_Ptr_t
for ( b = 0; b < nBits; b++ )
bBits[b] = Cudd_ReadLogicZero(ddNew), Cudd_Ref( bBits[b] );
// add each bound set minterm to one of the blccks
- Vec_PtrForEachEntry( vCofs, bCof, c )
+ Vec_PtrForEachEntry( DdNode *, vCofs, bCof, c )
{
- Vec_PtrForEachEntry( vUniq, bUniq, u )
+ Vec_PtrForEachEntry( DdNode *, vUniq, bUniq, u )
if ( bUniq == bCof )
break;
assert( u < Vec_PtrSize(vUniq) );
@@ -388,7 +391,7 @@ Abc_Obj_t * Abc_NtkBddCurtis( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNode, Vec_Ptr_t
// derive function of the composition node
bFunc = Cudd_ReadLogicZero(ddNew); Cudd_Ref( bFunc );
pbCodeVars = ddNew->vars + Abc_ObjFaninNum(pNode) - nLutSize;
- Vec_PtrForEachEntry( vUniq, bUniq, u )
+ Vec_PtrForEachEntry( DdNode *, vUniq, bUniq, u )
{
bUniq = Extra_bddMove( ddOld, bUniq, -nLutSize ); Cudd_Ref( bUniq );
bUniq = Extra_TransferLevelByLevel( ddOld, ddNew, bTemp = bUniq ); Cudd_Ref( bUniq );
@@ -421,8 +424,8 @@ Abc_Obj_t * Abc_NtkBddCurtis( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNode, Vec_Ptr_t
Abc_Obj_t * Abc_NtkBddFindCofactor( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNode, int nLutSize )
{
Abc_Obj_t * pNodeBot, * pNodeTop;
- DdManager * ddOld = pNode->pNtk->pManFunc;
- DdManager * ddNew = pNtkNew->pManFunc;
+ DdManager * ddOld = (DdManager *)pNode->pNtk->pManFunc;
+ DdManager * ddNew = (DdManager *)pNtkNew->pManFunc;
DdNode * bCof0, * bCof1, * bSupp, * bTemp, * bVar;
DdNode * bCof0n, * bCof1n;
int i, iCof, iFreeVar, fCof1Smaller = -1;
@@ -430,8 +433,8 @@ Abc_Obj_t * Abc_NtkBddFindCofactor( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNode, int
for ( iCof = 0; iCof < Abc_ObjFaninNum(pNode); iCof++ )
{
bVar = Cudd_bddIthVar( ddOld, iCof );
- bCof0 = Cudd_Cofactor( ddOld, pNode->pData, Cudd_Not(bVar) ); Cudd_Ref( bCof0 );
- bCof1 = Cudd_Cofactor( ddOld, pNode->pData, bVar ); Cudd_Ref( bCof1 );
+ bCof0 = Cudd_Cofactor( ddOld, (DdNode *)pNode->pData, Cudd_Not(bVar) ); Cudd_Ref( bCof0 );
+ bCof1 = Cudd_Cofactor( ddOld, (DdNode *)pNode->pData, bVar ); Cudd_Ref( bCof1 );
if ( Cudd_SupportSize( ddOld, bCof0 ) <= nLutSize - 2 )
{
fCof1Smaller = 0;
@@ -488,7 +491,7 @@ Abc_Obj_t * Abc_NtkBddFindCofactor( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNode, int
Cudd_bddIthVar(ddNew, iCof),
fCof1Smaller? bCof1n : Cudd_bddIthVar(ddNew, iFreeVar),
fCof1Smaller? Cudd_bddIthVar(ddNew, iFreeVar) : bCof0n );
- Cudd_Ref( pNodeTop->pData );
+ Cudd_Ref( (DdNode *)pNodeTop->pData );
Cudd_RecursiveDeref( ddNew, fCof1Smaller? bCof1n : bCof0n );
return pNodeTop;
}
@@ -507,7 +510,7 @@ Abc_Obj_t * Abc_NtkBddFindCofactor( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNode, int
Abc_Obj_t * Abc_NtkBddDecompose( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNode, int nLutSize, int fVerbose )
{
Vec_Ptr_t * vCofs, * vUniq;
- DdManager * dd = pNode->pNtk->pManFunc;
+ DdManager * dd = (DdManager *)pNode->pNtk->pManFunc;
DdNode * bCof;
Abc_Obj_t * pNodeNew = NULL;
Abc_Obj_t * pCofs[20];
@@ -528,21 +531,21 @@ Abc_Obj_t * Abc_NtkBddDecompose( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNode, int nLu
}
// cofactor w.r.t. the bound set variables
- vCofs = Abc_NtkBddCofactors( dd, pNode->pData, nLutSize );
+ vCofs = Abc_NtkBddCofactors( dd, (DdNode *)pNode->pData, nLutSize );
vUniq = Vec_PtrDup( vCofs );
Vec_PtrUniqify( vUniq, (int (*)())Vec_PtrSortCompare );
// only perform decomposition with it is support reduring with two less vars
if( Vec_PtrSize(vUniq) > (1 << (nLutSize-2)) )
{
Vec_PtrFree( vCofs );
- vCofs = Abc_NtkBddCofactors( dd, pNode->pData, 2 );
+ vCofs = Abc_NtkBddCofactors( dd, (DdNode *)pNode->pData, 2 );
if ( fVerbose )
printf( "Decomposing %d-input node %d using cofactoring with %d cofactors.\n",
Abc_ObjFaninNum(pNode), Abc_ObjId(pNode), Vec_PtrSize(vCofs) );
// implement the cofactors
pCofs[0] = Abc_ObjFanin(pNode, 0)->pCopy;
pCofs[1] = Abc_ObjFanin(pNode, 1)->pCopy;
- Vec_PtrForEachEntry( vCofs, bCof, i )
+ Vec_PtrForEachEntry( DdNode *, vCofs, bCof, i )
pCofs[2+i] = Abc_NtkCreateCofLut( pNtkNew, dd, bCof, pNode, 2 );
if ( nLutSize == 4 )
pNodeNew = Abc_NtkBddMux412( pNtkNew, pCofs );
@@ -582,7 +585,7 @@ void Abc_NtkLutminConstruct( Abc_Ntk_t * pNtkClp, Abc_Ntk_t * pNtkDec, int nLutS
Abc_Obj_t * pNode, * pFanin;
int i, k;
vNodes = Abc_NtkDfs( pNtkClp, 0 );
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
{
if ( Abc_ObjFaninNum(pNode) <= nLutSize )
{
@@ -617,7 +620,7 @@ Abc_Ntk_t * Abc_NtkLutminInt( Abc_Ntk_t * pNtk, int nLutSize, int fVerbose )
// decompose one output at a time
pNtkDec = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_BDD );
// make sure the new manager has enough inputs
- Cudd_bddIthVar( pNtkDec->pManFunc, Abc_NtkGetFaninMax(pNtk) );
+ Cudd_bddIthVar( (DdManager *)pNtkDec->pManFunc, Abc_NtkGetFaninMax(pNtk) );
// put the results into the new network (save new CO drivers in old CO drivers)
Abc_NtkLutminConstruct( pNtk, pNtkDec, nLutSize, fVerbose );
// finalize the new network
@@ -640,7 +643,7 @@ Abc_Ntk_t * Abc_NtkLutminInt( Abc_Ntk_t * pNtk, int nLutSize, int fVerbose )
***********************************************************************/
Abc_Ntk_t * Abc_NtkLutmin( Abc_Ntk_t * pNtkInit, int nLutSize, int fVerbose )
{
- extern bool Abc_NtkFraigSweep( Abc_Ntk_t * pNtk, int fUseInv, int fExdc, int fVerbose, int fVeryVerbose );
+ extern int Abc_NtkFraigSweep( Abc_Ntk_t * pNtk, int fUseInv, int fExdc, int fVerbose, int fVeryVerbose );
Abc_Ntk_t * pNtkNew, * pTemp;
int i;
if ( nLutSize < 4 )
@@ -695,3 +698,5 @@ Abc_Ntk_t * Abc_NtkLutmin( Abc_Ntk_t * pNtkInit, int nLutSize, int fVerbose )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcMap.c b/src/base/abci/abcMap.c
index 0b0294d5..543df7b0 100644
--- a/src/base/abci/abcMap.c
+++ b/src/base/abci/abcMap.c
@@ -23,6 +23,9 @@
#include "mio.h"
#include "mapper.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -76,8 +79,8 @@ Abc_Ntk_t * Abc_NtkMap( Abc_Ntk_t * pNtk, double DelayTarget, int fRecovery, int
if ( Abc_FrameReadLibSuper() == NULL && Abc_FrameReadLibGen() )
{
printf( "A simple supergate library is derived from gate library \"%s\".\n",
- Mio_LibraryReadName(Abc_FrameReadLibGen()) );
- Map_SuperLibDeriveFromGenlib( Abc_FrameReadLibGen() );
+ Mio_LibraryReadName((Mio_Library_t *)Abc_FrameReadLibGen()) );
+ Map_SuperLibDeriveFromGenlib( (Mio_Library_t *)Abc_FrameReadLibGen() );
}
// print a warning about choice nodes
@@ -175,13 +178,13 @@ Map_Man_t * Abc_NtkToMap( Abc_Ntk_t * pNtk, double DelayTarget, int fRecovery, f
// load the AIG into the mapper
vNodes = Abc_AigDfs( pNtk, 0, 0 );
pProgress = Extra_ProgressBarStart( stdout, vNodes->nSize );
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
{
Extra_ProgressBarUpdate( pProgress, i, NULL );
// add the node to the mapper
pNodeMap = Map_NodeAnd( pMan,
- Map_NotCond( Abc_ObjFanin0(pNode)->pCopy, Abc_ObjFaninC0(pNode) ),
- Map_NotCond( Abc_ObjFanin1(pNode)->pCopy, Abc_ObjFaninC1(pNode) ) );
+ Map_NotCond( Abc_ObjFanin0(pNode)->pCopy, (int)Abc_ObjFaninC0(pNode) ),
+ Map_NotCond( Abc_ObjFanin1(pNode)->pCopy, (int)Abc_ObjFaninC1(pNode) ) );
assert( pNode->pCopy == NULL );
// remember the node
pNode->pCopy = (Abc_Obj_t *)pNodeMap;
@@ -189,7 +192,7 @@ Map_Man_t * Abc_NtkToMap( Abc_Ntk_t * pNtk, double DelayTarget, int fRecovery, f
Map_NodeSetSwitching( pNodeMap, pSwitching[pNode->Id] );
// set up the choice node
if ( Abc_AigNodeIsChoice( pNode ) )
- for ( pPrev = pNode, pFanin = pNode->pData; pFanin; pPrev = pFanin, pFanin = pFanin->pData )
+ for ( pPrev = pNode, pFanin = (Abc_Obj_t *)pNode->pData; pFanin; pPrev = pFanin, pFanin = (Abc_Obj_t *)pFanin->pData )
{
Map_NodeSetNextE( (Map_Node_t *)pPrev->pCopy, (Map_Node_t *)pFanin->pCopy );
Map_NodeSetRepr( (Map_Node_t *)pFanin->pCopy, (Map_Node_t *)pNode->pCopy );
@@ -200,7 +203,7 @@ Map_Man_t * Abc_NtkToMap( Abc_Ntk_t * pNtk, double DelayTarget, int fRecovery, f
// set the primary outputs in the required phase
Abc_NtkForEachCo( pNtk, pNode, i )
- Map_ManReadOutputs(pMan)[i] = Map_NotCond( (Map_Node_t *)Abc_ObjFanin0(pNode)->pCopy, Abc_ObjFaninC0(pNode) );
+ Map_ManReadOutputs(pMan)[i] = Map_NotCond( (Map_Node_t *)Abc_ObjFanin0(pNode)->pCopy, (int)Abc_ObjFaninC0(pNode) );
return pMan;
}
@@ -430,8 +433,8 @@ Abc_Ntk_t * Abc_NtkSuperChoice( Abc_Ntk_t * pNtk )
if ( Abc_FrameReadLibSuper() == NULL && Abc_FrameReadLibGen() )
{
printf( "A simple supergate library is derived from gate library \"%s\".\n",
- Mio_LibraryReadName(Abc_FrameReadLibGen()) );
- Map_SuperLibDeriveFromGenlib( Abc_FrameReadLibGen() );
+ Mio_LibraryReadName((Mio_Library_t *)Abc_FrameReadLibGen()) );
+ Map_SuperLibDeriveFromGenlib( (Mio_Library_t *)Abc_FrameReadLibGen() );
}
// print a warning about choice nodes
@@ -654,7 +657,7 @@ Abc_Obj_t * Abc_NodeFromMapSuperChoice_rec( Abc_Ntk_t * pNtkNew, Map_Super_t * p
pNodeFanin = Abc_NodeFromMapSuperChoice_rec( pNtkNew, ppFanins[i], pNodePis, nNodePis );
Abc_ObjAddFanin( pNodeNew, pNodeFanin );
}
- pNodeNew->pData = Abc_SopRegister( pNtkNew->pManFunc, Mio_GateReadSop(pRoot) );
+ pNodeNew->pData = Abc_SopRegister( (Extra_MmFlex_t *)pNtkNew->pManFunc, Mio_GateReadSop(pRoot) );
return pNodeNew;
}
@@ -664,3 +667,5 @@ Abc_Obj_t * Abc_NodeFromMapSuperChoice_rec( Abc_Ntk_t * pNtkNew, Map_Super_t * p
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcMeasure.c b/src/base/abci/abcMeasure.c
index 00d5d971..5352084f 100644
--- a/src/base/abci/abcMeasure.c
+++ b/src/base/abci/abcMeasure.c
@@ -21,6 +21,9 @@
#include "abc.h"
#include "kit.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -143,7 +146,7 @@ unsigned Abc_Ntk4VarObj( Vec_Ptr_t * vNodes )
Abc_Obj_t * pObj;
unsigned uTruth0, uTruth1;
int i;
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
{
uTruth0 = (unsigned)(Abc_ObjFanin0(pObj)->pCopy);
uTruth1 = (unsigned)(Abc_ObjFanin1(pObj)->pCopy);
@@ -151,7 +154,7 @@ unsigned Abc_Ntk4VarObj( Vec_Ptr_t * vNodes )
uTruth0 = ~uTruth0;
if ( Abc_ObjFaninC1(pObj) )
uTruth1 = ~uTruth1;
- pObj->pCopy = (void *)(uTruth0 & uTruth1);
+ pObj->pCopy = (Abc_Obj_t *)(uTruth0 & uTruth1);
}
return uTruth0 & uTruth1;
}
@@ -207,9 +210,9 @@ void Abc_Ntk4VarTable( Abc_Ntk_t * pNtk )
// set elementary truth tables
assert( Abc_NtkPiNum(pNtk) == 4 );
- Abc_AigConst1(pNtk)->pCopy = (void *)0xFFFFFFFF;
+ Abc_AigConst1(pNtk)->pCopy = (Abc_Obj_t *)0xFFFFFFFF;
Abc_NtkForEachPi( pNtk, pObj, i )
- pObj->pCopy = (void *)u4VarTruths[i];
+ pObj->pCopy = (Abc_Obj_t *)u4VarTruths[i];
// create truth tables
Abc_NtkForEachPo( pNtk, pObj, i )
@@ -476,3 +479,5 @@ void Abc_NtkPrintOneDec( unsigned * pTruth, int nVars )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcMerge.c b/src/base/abci/abcMerge.c
index 4997af48..d7abece8 100644
--- a/src/base/abci/abcMerge.c
+++ b/src/base/abci/abcMerge.c
@@ -22,6 +22,9 @@
#include "aig.h"
#include "nwkMerge.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -100,7 +103,7 @@ void Abc_NtkCollectCircle( Vec_Ptr_t * vStart, Vec_Ptr_t * vNext, int nFanMax )
Abc_Obj_t * pObj, * pNext;
int i, k;
Vec_PtrClear( vNext );
- Vec_PtrForEachEntry( vStart, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vStart, pObj, i )
{
Abc_ObjForEachFanin( pObj, pNext, k )
{
@@ -158,7 +161,7 @@ void Abc_NtkCollectNonOverlapCands( Abc_Obj_t * pLut, Vec_Ptr_t * vStart, Vec_Pt
vStart = vNext;
vNext = vTemp;
// collect the nodes in vStart
- Vec_PtrForEachEntry( vStart, pObj, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vStart, pObj, k )
Vec_PtrPush( vCands, pObj );
}
@@ -180,7 +183,7 @@ void Abc_NtkCollectNonOverlapCands( Abc_Obj_t * pLut, Vec_Ptr_t * vStart, Vec_Pt
// - they have no more than the given number of fanins
// - they have no more than the given diff in delay
k = 0;
- Vec_PtrForEachEntry( vCands, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vCands, pObj, i )
{
if ( Abc_NodeIsTravIdCurrent(pObj) )
continue;
@@ -305,9 +308,9 @@ Vec_Int_t * Abc_NtkLutMerge( Abc_Ntk_t * pNtk, Nwk_LMPars_t * pPars )
continue;
nCands += Vec_PtrSize(vCands1) + Vec_PtrSize(vCands2);
// save candidates
- Vec_PtrForEachEntry( vCands1, pCand, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vCands1, pCand, k )
Nwk_ManGraphHashEdge( p, Abc_ObjId(pLut), Abc_ObjId(pCand) );
- Vec_PtrForEachEntry( vCands2, pCand, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vCands2, pCand, k )
Nwk_ManGraphHashEdge( p, Abc_ObjId(pLut), Abc_ObjId(pCand) );
// print statistics about this node
if ( pPars->fVeryVerbose )
@@ -350,3 +353,5 @@ Vec_Int_t * Abc_NtkLutMerge( Abc_Ntk_t * pNtk, Nwk_LMPars_t * pPars )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcMini.c b/src/base/abci/abcMini.c
index 92985423..429c40c6 100644
--- a/src/base/abci/abcMini.c
+++ b/src/base/abci/abcMini.c
@@ -20,6 +20,9 @@
#include "abc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -135,8 +138,8 @@ Abc_Ntk_t * Abc_NtkFromMini( Abc_Ntk_t * pNtk, Hop_Man_t * pMan )
pObj->pData = Abc_NtkCi(pNtkNew, i);
// rebuild the AIG
vNodes = Hop_ManDfs( pMan );
- Vec_PtrForEachEntry( vNodes, pObj, i )
- pObj->pData = Abc_AigAnd( pNtkNew->pManFunc, (Abc_Obj_t *)Hop_ObjChild0Copy(pObj), (Abc_Obj_t *)Hop_ObjChild1Copy(pObj) );
+ Vec_PtrForEachEntry( Hop_Obj_t *, vNodes, pObj, i )
+ pObj->pData = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, (Abc_Obj_t *)Hop_ObjChild0Copy(pObj), (Abc_Obj_t *)Hop_ObjChild1Copy(pObj) );
Vec_PtrFree( vNodes );
// connect the PO nodes
Hop_ManForEachPo( pMan, pObj, i )
@@ -151,3 +154,5 @@ Abc_Ntk_t * Abc_NtkFromMini( Abc_Ntk_t * pNtk, Hop_Man_t * pMan )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcMiter.c b/src/base/abci/abcMiter.c
index 34270fab..dbb27e91 100644
--- a/src/base/abci/abcMiter.c
+++ b/src/base/abci/abcMiter.c
@@ -20,6 +20,9 @@
#include "abc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -98,7 +101,7 @@ Abc_Ntk_t * Abc_NtkMiterInt( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fComb, in
Abc_NtkMiterAddOne( pNtk1, pNtkMiter );
Abc_NtkMiterAddOne( pNtk2, pNtkMiter );
Abc_NtkMiterFinalize( pNtk1, pNtk2, pNtkMiter, fComb, nPartSize, fImplic, fMulti );
- Abc_AigCleanup(pNtkMiter->pManFunc);
+ Abc_AigCleanup((Abc_Aig_t *)pNtkMiter->pManFunc);
// make sure that everything is okay
if ( !Abc_NtkCheck( pNtkMiter ) )
@@ -231,7 +234,7 @@ void Abc_NtkMiterAddOne( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkMiter )
int i;
assert( Abc_NtkIsDfsOrdered(pNtk) );
Abc_AigForEachAnd( pNtk, pNode, i )
- pNode->pCopy = Abc_AigAnd( pNtkMiter->pManFunc, Abc_ObjChild0Copy(pNode), Abc_ObjChild1Copy(pNode) );
+ pNode->pCopy = Abc_AigAnd( (Abc_Aig_t *)pNtkMiter->pManFunc, Abc_ObjChild0Copy(pNode), Abc_ObjChild1Copy(pNode) );
}
/**Function*************************************************************
@@ -254,9 +257,9 @@ void Abc_NtkMiterAddCone( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkMiter, Abc_Obj_t * p
Abc_AigConst1(pNtk)->pCopy = Abc_AigConst1(pNtkMiter);
// perform strashing
vNodes = Abc_NtkDfsNodes( pNtk, &pRoot, 1 );
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
if ( Abc_AigNodeIsAnd(pNode) )
- pNode->pCopy = Abc_AigAnd( pNtkMiter->pManFunc, Abc_ObjChild0Copy(pNode), Abc_ObjChild1Copy(pNode) );
+ pNode->pCopy = Abc_AigAnd( (Abc_Aig_t *)pNtkMiter->pManFunc, Abc_ObjChild0Copy(pNode), Abc_ObjChild1Copy(pNode) );
Vec_PtrFree( vNodes );
}
@@ -287,7 +290,7 @@ void Abc_NtkMiterFinalize( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, Abc_Ntk_t * pNt
{
if ( fMulti )
{
- pMiter = Abc_AigXor( pNtkMiter->pManFunc, Abc_ObjChild0Copy(pNode), Abc_ObjChild0Copy(Abc_NtkCo(pNtk2, i)) );
+ pMiter = Abc_AigXor( (Abc_Aig_t *)pNtkMiter->pManFunc, Abc_ObjChild0Copy(pNode), Abc_ObjChild0Copy(Abc_NtkCo(pNtk2, i)) );
Abc_ObjAddFanin( Abc_NtkPo(pNtkMiter,i), pMiter );
}
else
@@ -305,7 +308,7 @@ void Abc_NtkMiterFinalize( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, Abc_Ntk_t * pNt
{
if ( fMulti )
{
- pMiter = Abc_AigXor( pNtkMiter->pManFunc, Abc_ObjChild0Copy(pNode), Abc_ObjChild0Copy(Abc_NtkCo(pNtk2, i)) );
+ pMiter = Abc_AigXor( (Abc_Aig_t *)pNtkMiter->pManFunc, Abc_ObjChild0Copy(pNode), Abc_ObjChild0Copy(Abc_NtkCo(pNtk2, i)) );
Abc_ObjAddFanin( Abc_NtkPo(pNtkMiter,i), pMiter );
}
else
@@ -326,7 +329,7 @@ void Abc_NtkMiterFinalize( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, Abc_Ntk_t * pNt
{
if ( !fMulti )
{
- pMiter = Abc_AigMiter( pNtkMiter->pManFunc, vPairs, fImplic );
+ pMiter = Abc_AigMiter( (Abc_Aig_t *)pNtkMiter->pManFunc, vPairs, fImplic );
Abc_ObjAddFanin( Abc_NtkPo(pNtkMiter,0), pMiter );
}
}
@@ -350,7 +353,7 @@ void Abc_NtkMiterFinalize( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, Abc_Ntk_t * pNt
Vec_PtrPush( vPairsPart, Vec_PtrEntry(vPairs, 2*iCur ) );
Vec_PtrPush( vPairsPart, Vec_PtrEntry(vPairs, 2*iCur+1) );
}
- pMiter = Abc_AigMiter( pNtkMiter->pManFunc, vPairsPart, fImplic );
+ pMiter = Abc_AigMiter( (Abc_Aig_t *)pNtkMiter->pManFunc, vPairsPart, fImplic );
pNode = Abc_NtkCreatePo( pNtkMiter );
Abc_ObjAddFanin( pNode, pMiter );
// assign the name to the node
@@ -409,13 +412,13 @@ Abc_Ntk_t * Abc_NtkMiterAnd( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fOr, int
pRoot1 = Abc_NtkPo(pNtk1,0);
pRoot2 = Abc_NtkPo(pNtk2,0);
pOutput1 = Abc_ObjNotCond( Abc_ObjFanin0(pRoot1)->pCopy, Abc_ObjFaninC0(pRoot1) );
- pOutput2 = Abc_ObjNotCond( Abc_ObjFanin0(pRoot2)->pCopy, Abc_ObjFaninC0(pRoot2) ^ fCompl2 );
+ pOutput2 = Abc_ObjNotCond( Abc_ObjFanin0(pRoot2)->pCopy, (int)Abc_ObjFaninC0(pRoot2) ^ fCompl2 );
// create the miter of the two outputs
if ( fOr )
- pMiter = Abc_AigOr( pNtkMiter->pManFunc, pOutput1, pOutput2 );
+ pMiter = Abc_AigOr( (Abc_Aig_t *)pNtkMiter->pManFunc, pOutput1, pOutput2 );
else
- pMiter = Abc_AigAnd( pNtkMiter->pManFunc, pOutput1, pOutput2 );
+ pMiter = Abc_AigAnd( (Abc_Aig_t *)pNtkMiter->pManFunc, pOutput1, pOutput2 );
Abc_ObjAddFanin( Abc_NtkPo(pNtkMiter,0), pMiter );
// make sure that everything is okay
@@ -551,7 +554,7 @@ Abc_Ntk_t * Abc_NtkMiterForCofactors( Abc_Ntk_t * pNtk, int Out, int In1, int In
pOutput2 = Abc_ObjFanin0(pRoot)->pCopy;
// create the miter of the two outputs
- pMiter = Abc_AigXor( pNtkMiter->pManFunc, pOutput1, pOutput2 );
+ pMiter = Abc_AigXor( (Abc_Aig_t *)pNtkMiter->pManFunc, pOutput1, pOutput2 );
Abc_ObjAddFanin( Abc_NtkPo(pNtkMiter,0), pMiter );
// make sure that everything is okay
@@ -613,9 +616,9 @@ Abc_Ntk_t * Abc_NtkMiterQuantify( Abc_Ntk_t * pNtk, int In, int fExist )
// create the miter of the two outputs
if ( fExist )
- pMiter = Abc_AigOr( pNtkMiter->pManFunc, pOutput1, pOutput2 );
+ pMiter = Abc_AigOr( (Abc_Aig_t *)pNtkMiter->pManFunc, pOutput1, pOutput2 );
else
- pMiter = Abc_AigAnd( pNtkMiter->pManFunc, pOutput1, pOutput2 );
+ pMiter = Abc_AigAnd( (Abc_Aig_t *)pNtkMiter->pManFunc, pOutput1, pOutput2 );
Abc_ObjAddFanin( Abc_NtkPo(pNtkMiter,0), pMiter );
// make sure that everything is okay
@@ -805,7 +808,7 @@ Abc_Ntk_t * Abc_NtkFrames( Abc_Ntk_t * pNtk, int nFrames, int fInitial, int fVer
pLatchOut->pCopy = Abc_ObjNotCond( Abc_AigConst1(pNtkFrames), Abc_LatchIsInit0(pLatch) );
}
if ( Counter )
- printf( "Warning: %d uninitialized latches are replaced by ABC_FREE PI variables.\n", Counter );
+ printf( "Warning: %d uninitialized latches are replaced by free PI variables.\n", Counter );
}
// create the timeframes
@@ -826,7 +829,7 @@ Abc_Ntk_t * Abc_NtkFrames( Abc_Ntk_t * pNtk, int nFrames, int fInitial, int fVer
}
// remove dangling nodes
- Abc_AigCleanup( pNtkFrames->pManFunc );
+ Abc_AigCleanup( (Abc_Aig_t *)pNtkFrames->pManFunc );
// reorder the latches
Abc_NtkOrderCisCos( pNtkFrames );
// make sure that everything is okay
@@ -865,19 +868,13 @@ void Abc_NtkAddFrame( Abc_Ntk_t * pNtkFrames, Abc_Ntk_t * pNtk, int iFrame )
Abc_ObjAssignName( Abc_NtkDupObj(pNtkFrames, pNode, 0), Abc_ObjName(pNode), Buffer );
// add the internal nodes
Abc_AigForEachAnd( pNtk, pNode, i )
- pNode->pCopy = Abc_AigAnd( pNtkFrames->pManFunc, Abc_ObjChild0Copy(pNode), Abc_ObjChild1Copy(pNode) );
+ pNode->pCopy = Abc_AigAnd( (Abc_Aig_t *)pNtkFrames->pManFunc, Abc_ObjChild0Copy(pNode), Abc_ObjChild1Copy(pNode) );
// add the new POs
Abc_NtkForEachPo( pNtk, pNode, i )
{
Abc_ObjAssignName( Abc_NtkDupObj(pNtkFrames, pNode, 0), Abc_ObjName(pNode), Buffer );
Abc_ObjAddFanin( pNode->pCopy, Abc_ObjChild0Copy(pNode) );
}
- // add the new asserts
- Abc_NtkForEachAssert( pNtk, pNode, i )
- {
- Abc_ObjAssignName( Abc_NtkDupObj(pNtkFrames, pNode, 0), Abc_ObjName(pNode), Buffer );
- Abc_ObjAddFanin( pNode->pCopy, Abc_ObjChild0Copy(pNode) );
- }
// transfer the implementation of the latch inputs to the latch outputs
Abc_NtkForEachLatch( pNtk, pLatch, i )
pLatch->pCopy = Abc_ObjChild0Copy(Abc_ObjFanin0(pLatch));
@@ -939,7 +936,7 @@ Abc_Ntk_t * Abc_NtkFrames2( Abc_Ntk_t * pNtk, int nFrames, int fInitial, AddFram
if (addFrameMapping) addFrameMapping(pLatch->pCopy, pLatch, 0, arg);
}
if ( Counter )
- printf( "Warning: %d uninitialized latches are replaced by ABC_FREE PI variables.\n", Counter );
+ printf( "Warning: %d uninitialized latches are replaced by free PI variables.\n", Counter );
}
// create the timeframes
@@ -1018,7 +1015,7 @@ void Abc_NtkAddFrame2( Abc_Ntk_t * pNtkFrames, Abc_Ntk_t * pNtk, int iFrame, Vec
if (addFrameMapping) addFrameMapping(pNodeNew, pNode, iFrame, arg);
}
// add the internal nodes
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
{
if ( pNode == pConst1 )
pNodeNew = pConst1New;
@@ -1113,12 +1110,12 @@ int Abc_NtkDemiter( Abc_Ntk_t * pNtk )
vNodes1 = Abc_NtkDfsNodes( pNtk, &pNodeC, 1 );
vNodes2 = Abc_NtkDfsNodes( pNtk, &pNodeB, 1 );
- Vec_PtrForEachEntry( vNodes1, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes1, pNode, i )
pNode->fMarkA = 1;
nCommon = 0;
- Vec_PtrForEachEntry( vNodes2, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes2, pNode, i )
nCommon += pNode->fMarkA;
- Vec_PtrForEachEntry( vNodes1, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes1, pNode, i )
pNode->fMarkA = 0;
printf( "First cone = %6d. Second cone = %6d. Common = %6d.\n", vNodes1->nSize, vNodes2->nSize, nCommon );
@@ -1160,9 +1157,9 @@ int Abc_NtkCombinePos( Abc_Ntk_t * pNtk, int fAnd )
// perform operations on the POs
Abc_NtkForEachPo( pNtk, pNode, i )
if ( fAnd )
- pMiter = Abc_AigAnd( pNtk->pManFunc, pMiter, Abc_ObjChild0(pNode) );
+ pMiter = Abc_AigAnd( (Abc_Aig_t *)pNtk->pManFunc, pMiter, Abc_ObjChild0(pNode) );
else
- pMiter = Abc_AigOr( pNtk->pManFunc, pMiter, Abc_ObjChild0(pNode) );
+ pMiter = Abc_AigOr( (Abc_Aig_t *)pNtk->pManFunc, pMiter, Abc_ObjChild0(pNode) );
// remove the POs and their names
for ( i = Abc_NtkPoNum(pNtk) - 1; i >= 0; i-- )
Abc_NtkDeleteObj( Abc_NtkPo(pNtk, i) );
@@ -1186,3 +1183,5 @@ int Abc_NtkCombinePos( Abc_Ntk_t * pNtk, int fAnd )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcMulti.c b/src/base/abci/abcMulti.c
index e93360a0..4e962cff 100644
--- a/src/base/abci/abcMulti.c
+++ b/src/base/abci/abcMulti.c
@@ -20,6 +20,9 @@
#include "abc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -129,7 +132,7 @@ void Abc_NtkMultiInt( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew )
if ( Abc_ObjFanoutNum(pConst1) > 0 )
{
pNodeNew = Abc_NtkCreateNode( pNtkNew );
- pNodeNew->pData = Cudd_ReadOne( pNtkNew->pManFunc ); Cudd_Ref( pNodeNew->pData );
+ pNodeNew->pData = Cudd_ReadOne( (DdManager *)pNtkNew->pManFunc ); Cudd_Ref( (DdNode *)pNodeNew->pData );
pConst1->pCopy = pNodeNew;
}
@@ -186,11 +189,11 @@ Abc_Obj_t * Abc_NtkMulti_rec( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNodeOld )
// create a new node
pNodeNew = Abc_NtkCreateNode( pNtkNew );
for ( i = 0; i < vCone->nSize; i++ )
- Abc_ObjAddFanin( pNodeNew, Abc_NtkMulti_rec(pNtkNew, vCone->pArray[i]) );
+ Abc_ObjAddFanin( pNodeNew, Abc_NtkMulti_rec(pNtkNew, (Abc_Obj_t *)vCone->pArray[i]) );
// derive the function of this node
- pNodeNew->pData = Abc_NtkMultiDeriveBdd( pNtkNew->pManFunc, pNodeOld, vCone );
- Cudd_Ref( pNodeNew->pData );
+ pNodeNew->pData = Abc_NtkMultiDeriveBdd( (DdManager *)pNtkNew->pManFunc, pNodeOld, vCone );
+ Cudd_Ref( (DdNode *)pNodeNew->pData );
Vec_PtrFree( vCone );
// remember the node
@@ -220,8 +223,8 @@ DdNode * Abc_NtkMultiDeriveBdd( DdManager * dd, Abc_Obj_t * pNodeOld, Vec_Ptr_t
// set the elementary BDD variables for the input nodes
for ( i = 0; i < vFaninsOld->nSize; i++ )
{
- pFaninOld = vFaninsOld->pArray[i];
- pFaninOld->pData = Cudd_bddIthVar( dd, i ); Cudd_Ref( pFaninOld->pData );
+ pFaninOld = (Abc_Obj_t *)vFaninsOld->pArray[i];
+ pFaninOld->pData = Cudd_bddIthVar( dd, i ); Cudd_Ref( (DdNode *)pFaninOld->pData );
pFaninOld->fMarkC = 1;
}
// call the recursive BDD computation
@@ -229,8 +232,8 @@ DdNode * Abc_NtkMultiDeriveBdd( DdManager * dd, Abc_Obj_t * pNodeOld, Vec_Ptr_t
// dereference the intermediate nodes
for ( i = 0; i < vFaninsOld->nSize; i++ )
{
- pFaninOld = vFaninsOld->pArray[i];
- Cudd_RecursiveDeref( dd, pFaninOld->pData );
+ pFaninOld = (Abc_Obj_t *)vFaninsOld->pArray[i];
+ Cudd_RecursiveDeref( dd, (DdNode *)pFaninOld->pData );
pFaninOld->fMarkC = 0;
}
Cudd_Deref( bFunc );
@@ -256,7 +259,7 @@ DdNode * Abc_NtkMultiDeriveBdd_rec( DdManager * dd, Abc_Obj_t * pNode, Vec_Ptr_t
if ( pNode->fMarkC )
{
assert( pNode->pData ); // network has a cycle
- return pNode->pData;
+ return (DdNode *)pNode->pData;
}
// mark the node as visited
pNode->fMarkC = 1;
@@ -264,8 +267,8 @@ DdNode * Abc_NtkMultiDeriveBdd_rec( DdManager * dd, Abc_Obj_t * pNode, Vec_Ptr_t
// compute the result for both branches
bFunc0 = Abc_NtkMultiDeriveBdd_rec( dd, Abc_ObjFanin(pNode,0), vFanins ); Cudd_Ref( bFunc0 );
bFunc1 = Abc_NtkMultiDeriveBdd_rec( dd, Abc_ObjFanin(pNode,1), vFanins ); Cudd_Ref( bFunc1 );
- bFunc0 = Cudd_NotCond( bFunc0, Abc_ObjFaninC0(pNode) );
- bFunc1 = Cudd_NotCond( bFunc1, Abc_ObjFaninC1(pNode) );
+ bFunc0 = Cudd_NotCond( bFunc0, (long)Abc_ObjFaninC0(pNode) );
+ bFunc1 = Cudd_NotCond( bFunc1, (long)Abc_ObjFaninC1(pNode) );
// get the final result
bFunc = Cudd_bddAnd( dd, bFunc0, bFunc1 ); Cudd_Ref( bFunc );
Cudd_RecursiveDeref( dd, bFunc0 );
@@ -641,3 +644,5 @@ void Abc_NtkMultiCone( Abc_Obj_t * pNode, Vec_Ptr_t * vCone )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcMv.c b/src/base/abci/abcMv.c
index 8ea3697f..4bfb1a02 100644
--- a/src/base/abci/abcMv.c
+++ b/src/base/abci/abcMv.c
@@ -20,6 +20,9 @@
#include "abc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -367,3 +370,5 @@ void Abc_MvDecompose( Mv_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcNtbdd.c b/src/base/abci/abcNtbdd.c
index 62256997..d27eab82 100644
--- a/src/base/abci/abcNtbdd.c
+++ b/src/base/abci/abcNtbdd.c
@@ -20,6 +20,9 @@
#include "abc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -81,13 +84,13 @@ Abc_Ntk_t * Abc_NtkDeriveFromBdd( DdManager * dd, DdNode * bFunc, char * pNamePo
pNtk = Abc_NtkAlloc( ABC_NTK_LOGIC, ABC_FUNC_BDD, 1 );
pNtk->pName = Extra_UtilStrsav(pNamePo);
// make sure the new manager has enough inputs
- Cudd_bddIthVar( pNtk->pManFunc, Vec_PtrSize(vNamesPi) );
+ Cudd_bddIthVar( (DdManager *)pNtk->pManFunc, Vec_PtrSize(vNamesPi) );
// add the PIs corresponding to the names
- Vec_PtrForEachEntry( vNamesPi, pName, i )
+ Vec_PtrForEachEntry( char *, vNamesPi, pName, i )
Abc_ObjAssignName( Abc_NtkCreatePi(pNtk), pName, NULL );
// create the node
pNode = Abc_NtkCreateNode( pNtk );
- pNode->pData = Cudd_bddTransfer( dd, pNtk->pManFunc, bFunc ); Cudd_Ref(pNode->pData);
+ pNode->pData = (DdNode *)Cudd_bddTransfer( dd, (DdManager *)pNtk->pManFunc, bFunc ); Cudd_Ref((DdNode *)pNode->pData);
Abc_NtkForEachPi( pNtk, pNodePi, i )
Abc_ObjAddFanin( pNode, pNodePi );
// create the only PO
@@ -154,7 +157,7 @@ void Abc_NtkBddToMuxesPerform( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew )
// perform conversion in the topological order
vNodes = Abc_NtkDfs( pNtk, 0 );
pProgress = Extra_ProgressBarStart( stdout, vNodes->nSize );
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
{
Extra_ProgressBarUpdate( pProgress, i, NULL );
// convert one node
@@ -181,8 +184,8 @@ void Abc_NtkBddToMuxesPerform( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew )
***********************************************************************/
Abc_Obj_t * Abc_NodeBddToMuxes( Abc_Obj_t * pNodeOld, Abc_Ntk_t * pNtkNew )
{
- DdManager * dd = pNodeOld->pNtk->pManFunc;
- DdNode * bFunc = pNodeOld->pData;
+ DdManager * dd = (DdManager *)pNodeOld->pNtk->pManFunc;
+ DdNode * bFunc = (DdNode *)pNodeOld->pData;
Abc_Obj_t * pFaninOld, * pNodeNew;
st_table * tBdd2Node;
int i;
@@ -253,7 +256,7 @@ DdManager * Abc_NtkBuildGlobalBdds( Abc_Ntk_t * pNtk, int nBddSizeMax, int fDrop
int i, k, Counter;
// remove dangling nodes
- Abc_AigCleanup( pNtk->pManFunc );
+ Abc_AigCleanup( (Abc_Aig_t *)pNtk->pManFunc );
// start the manager
assert( Abc_NtkGlobalBdd(pNtk) == NULL );
@@ -305,7 +308,7 @@ DdManager * Abc_NtkBuildGlobalBdds( Abc_Ntk_t * pNtk, int nBddSizeMax, int fDrop
pFanin->vFanouts.nSize++;
return NULL;
}
- bFunc = Cudd_NotCond( bFunc, Abc_ObjFaninC0(pObj) ); Cudd_Ref( bFunc );
+ bFunc = Cudd_NotCond( bFunc, (int)Abc_ObjFaninC0(pObj) ); Cudd_Ref( bFunc );
Abc_ObjSetGlobalBdd( pObj, bFunc );
}
Extra_ProgressBarStop( pProgress );
@@ -409,8 +412,8 @@ DdNode * Abc_NodeGlobalBdds_rec( DdManager * dd, Abc_Obj_t * pNode, int nBddSize
Cudd_Ref( bFunc1 );
// complement the branch BDDs
- bFunc0 = Cudd_NotCond( bFunc0, Abc_ObjIsComplement(pNode0) );
- bFunc1 = Cudd_NotCond( bFunc1, Abc_ObjIsComplement(pNode1) );
+ bFunc0 = Cudd_NotCond( bFunc0, (int)Abc_ObjIsComplement(pNode0) );
+ bFunc1 = Cudd_NotCond( bFunc1, (int)Abc_ObjIsComplement(pNode1) );
// get the final result
bFunc = Cudd_bddIte( dd, bFuncC, bFunc1, bFunc0 ); Cudd_Ref( bFunc );
Cudd_RecursiveDeref( dd, bFunc0 );
@@ -430,8 +433,8 @@ DdNode * Abc_NodeGlobalBdds_rec( DdManager * dd, Abc_Obj_t * pNode, int nBddSize
if ( bFunc1 == NULL )
return NULL;
Cudd_Ref( bFunc1 );
- bFunc0 = Cudd_NotCond( bFunc0, Abc_ObjFaninC0(pNode) );
- bFunc1 = Cudd_NotCond( bFunc1, Abc_ObjFaninC1(pNode) );
+ bFunc0 = Cudd_NotCond( bFunc0, (int)Abc_ObjFaninC0(pNode) );
+ bFunc1 = Cudd_NotCond( bFunc1, (int)Abc_ObjFaninC1(pNode) );
// get the final result
bFunc = Cudd_bddAnd( dd, bFunc0, bFunc1 ); Cudd_Ref( bFunc );
Cudd_RecursiveDeref( dd, bFunc0 );
@@ -470,7 +473,7 @@ DdNode * Abc_NodeGlobalBdds_rec( DdManager * dd, Abc_Obj_t * pNode, int nBddSize
***********************************************************************/
DdManager * Abc_NtkFreeGlobalBdds( Abc_Ntk_t * pNtk, int fFreeMan )
{
- return Abc_NtkAttrFree( pNtk, VEC_ATTR_GLOBAL_BDD, fFreeMan );
+ return (DdManager *)Abc_NtkAttrFree( pNtk, VEC_ATTR_GLOBAL_BDD, fFreeMan );
}
/**Function*************************************************************
@@ -527,7 +530,7 @@ double Abc_NtkSpacePercentage( Abc_Obj_t * pNode )
dd = Cudd_Init( Vec_PtrSize(vNodes), 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 );
Cudd_AutodynEnable( dd, CUDD_REORDER_SYMM_SIFT );
// assign elementary BDDs for the CIs
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
pObj->pCopy = (Abc_Obj_t *)dd->vars[i];
// build the BDD of the cone
bFunc = Abc_NodeGlobalBdds_rec( dd, pNodeR, 10000000, 1, NULL, NULL, 1 ); Cudd_Ref( bFunc );
@@ -592,3 +595,5 @@ ABC_PRT( "Time", clock() - clk );
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcOdc.c b/src/base/abci/abcOdc.c
index 67b243b9..5db556b8 100644
--- a/src/base/abci/abcOdc.c
+++ b/src/base/abci/abcOdc.c
@@ -20,6 +20,9 @@
#include "abc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -39,7 +42,6 @@ struct Odc_Obj_t_
unsigned uMask; // the variable mask
};
-typedef struct Odc_Man_t_ Odc_Man_t;
struct Odc_Man_t_
{
// dont'-care parameters
@@ -132,7 +134,7 @@ static inline void Odc_ObjSetTravIdCurrent( Odc_Man_t * p, Odc_Obj_t *
static inline int Odc_ObjIsTravIdCurrent( Odc_Man_t * p, Odc_Obj_t * pObj ) { return (int )((int)pObj->TravId == p->nTravIds); }
// truth tables
-static inline unsigned * Odc_ObjTruth( Odc_Man_t * p, Odc_Lit_t Lit ) { assert( !(Lit & 1) ); return Vec_PtrEntry(p->vTruths, Lit >> 1); }
+static inline unsigned * Odc_ObjTruth( Odc_Man_t * p, Odc_Lit_t Lit ) { assert( !(Lit & 1) ); return (unsigned *) Vec_PtrEntry(p->vTruths, Lit >> 1); }
// iterators
#define Odc_ForEachPi( p, Lit, i ) \
@@ -140,12 +142,6 @@ static inline unsigned * Odc_ObjTruth( Odc_Man_t * p, Odc_Lit_t Lit ) { ass
#define Odc_ForEachAnd( p, pObj, i ) \
for ( i = 1 + Odc_CiNum(p); (i < Odc_ObjNum(p)) && ((pObj) = (p)->pObjs + i); i++ )
-
-// exported functions
-extern Odc_Man_t * Abc_NtkDontCareAlloc( int nVarsMax, int nLevels, int fVerbose, int fVeryVerbose );
-extern void Abc_NtkDontCareClear( Odc_Man_t * p );
-extern void Abc_NtkDontCareFree( Odc_Man_t * p );
-extern int Abc_NtkDontCareCompute( Odc_Man_t * p, Abc_Obj_t * pNode, Vec_Ptr_t * vLeaves, unsigned * puTruth );
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
@@ -209,11 +205,11 @@ Odc_Man_t * Abc_NtkDontCareAlloc( int nVarsMax, int nLevels, int fVerbose, int f
p->vTruthsElem = Vec_PtrAllocSimInfo( p->nVarsMax, p->nWords );
// set elementary truth tables
- Abc_InfoFill( Vec_PtrEntry(p->vTruths, 0), p->nWords );
+ Abc_InfoFill( (unsigned *)Vec_PtrEntry(p->vTruths, 0), p->nWords );
for ( k = 0; k < p->nVarsMax; k++ )
{
// pData = Odc_ObjTruth( p, Odc_Var(p, k) );
- pData = Vec_PtrEntry( p->vTruthsElem, k );
+ pData = (unsigned *)Vec_PtrEntry( p->vTruthsElem, k );
Abc_InfoClear( pData, p->nWords );
for ( i = 0; i < p->nBits; i++ )
if ( i & (1 << k) )
@@ -350,7 +346,7 @@ void Abc_NtkDontCareWinSweepLeafTfo( Odc_Man_t * p )
Abc_Obj_t * pObj;
int i;
Abc_NtkIncrementTravId( p->pNode->pNtk );
- Vec_PtrForEachEntry( p->vLeaves, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vLeaves, pObj, i )
Abc_NtkDontCareWinSweepLeafTfo_rec( pObj, p->pNode->Level + p->nLevels, p->pNode );
}
@@ -457,11 +453,11 @@ int Abc_NtkDontCareWinAddMissing( Odc_Man_t * p )
int i;
// set the leaves
Abc_NtkIncrementTravId( p->pNode->pNtk );
- Vec_PtrForEachEntry( p->vLeaves, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vLeaves, pObj, i )
Abc_NodeSetTravIdCurrent( pObj );
// explore from the roots
Vec_PtrClear( p->vBranches );
- Vec_PtrForEachEntry( p->vRoots, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vRoots, pObj, i )
if ( !Abc_NtkDontCareWinAddMissing_rec( p, pObj ) )
return 0;
return 1;
@@ -662,7 +658,7 @@ void * Abc_NtkDontCareTransfer_rec( Odc_Man_t * p, Abc_Obj_t * pNode, Abc_Obj_t
assert( Abc_ObjIsNode(pNode) );
// consider the case when the node is the pivot
if ( pNode == pPivot )
- return pNode->pCopy = (void *)(ABC_PTRUINT_T)((Odc_Const1() << 16) | Odc_Const0());
+ return pNode->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)((Odc_Const1() << 16) | Odc_Const0());
// compute the cofactors
uData0 = (unsigned)(ABC_PTRUINT_T)Abc_NtkDontCareTransfer_rec( p, Abc_ObjFanin0(pNode), pPivot );
uData1 = (unsigned)(ABC_PTRUINT_T)Abc_NtkDontCareTransfer_rec( p, Abc_ObjFanin1(pNode), pPivot );
@@ -675,7 +671,7 @@ void * Abc_NtkDontCareTransfer_rec( Odc_Man_t * p, Abc_Obj_t * pNode, Abc_Obj_t
uLit1 = Odc_NotCond( (Odc_Lit_t)(uData1 >> 16), Abc_ObjFaninC1(pNode) );
uRes1 = Odc_And( p, uLit0, uLit1 );
// find the result
- return pNode->pCopy = (void *)(ABC_PTRUINT_T)((uRes1 << 16) | uRes0);
+ return pNode->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)((uRes1 << 16) | uRes0);
}
/**Function*************************************************************
@@ -698,22 +694,22 @@ int Abc_NtkDontCareTransfer( Odc_Man_t * p )
int i;
Abc_NtkIncrementTravId( p->pNode->pNtk );
// set elementary variables at the leaves
- Vec_PtrForEachEntry( p->vLeaves, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vLeaves, pObj, i )
{
uLit = Odc_Var( p, i );
- pObj->pCopy = (void *)(ABC_PTRUINT_T)((uLit << 16) | uLit);
+ pObj->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)((uLit << 16) | uLit);
Abc_NodeSetTravIdCurrent(pObj);
}
// set elementary variables at the branched
- Vec_PtrForEachEntry( p->vBranches, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vBranches, pObj, i )
{
uLit = Odc_Var( p, i+p->nVarsMax );
- pObj->pCopy = (void *)(ABC_PTRUINT_T)((uLit << 16) | uLit);
+ pObj->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)((uLit << 16) | uLit);
Abc_NodeSetTravIdCurrent(pObj);
}
// compute the AIG for the window
p->iRoot = Odc_Const0();
- Vec_PtrForEachEntry( p->vRoots, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vRoots, pObj, i )
{
uData = (unsigned)(ABC_PTRUINT_T)Abc_NtkDontCareTransfer_rec( p, pObj, p->pNode );
// get the cofactors
@@ -851,7 +847,7 @@ void Abc_NtkDontCareSimulateSetElem( Odc_Man_t * p )
for ( k = 0; k < p->nVarsMax; k++ )
{
pData = Odc_ObjTruth( p, Odc_Var(p, k) );
- pData2 = Vec_PtrEntry( p->vTruthsElem, k );
+ pData2 = (unsigned *)Vec_PtrEntry( p->vTruthsElem, k );
Abc_InfoCopy( pData, pData2, p->nWords );
}
}
@@ -1132,3 +1128,5 @@ p->timeTotal += clock() - clkTotal;
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcOrder.c b/src/base/abci/abcOrder.c
index 04417f77..c306d01d 100644
--- a/src/base/abci/abcOrder.c
+++ b/src/base/abci/abcOrder.c
@@ -20,6 +20,9 @@
#include "abc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -109,10 +112,10 @@ void Abc_NtkChangeCiOrder( Abc_Ntk_t * pNtk, Vec_Ptr_t * vSupp, int fReverse )
assert( Vec_PtrSize(vSupp) == Abc_NtkCiNum(pNtk) );
// order CIs using the array
if ( fReverse )
- Vec_PtrForEachEntry( vSupp, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vSupp, pObj, i )
Vec_PtrWriteEntry( pNtk->vCis, Vec_PtrSize(vSupp)-1-i, pObj );
else
- Vec_PtrForEachEntry( vSupp, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vSupp, pObj, i )
Vec_PtrWriteEntry( pNtk->vCis, i, pObj );
// order PIs accordingly
Vec_PtrClear( pNtk->vPis );
@@ -129,3 +132,5 @@ void Abc_NtkChangeCiOrder( Abc_Ntk_t * pNtk, Vec_Ptr_t * vSupp, int fReverse )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcPart.c b/src/base/abci/abcPart.c
index 4c348b16..5df5af62 100644
--- a/src/base/abci/abcPart.c
+++ b/src/base/abci/abcPart.c
@@ -19,6 +19,11 @@
***********************************************************************/
#include "abc.h"
+#include "main.h"
+#include "cmd.h"
+
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -29,10 +34,10 @@ struct Supp_Man_t_
{
int nChunkSize; // the size of one chunk of memory (~1 Mb)
int nStepSize; // the step size in saving memory (~64 bytes)
- char * pFreeBuf; // the pointer to ABC_FREE memory
- int nFreeSize; // the size of remaining ABC_FREE memory
+ char * pFreeBuf; // the pointer to free memory
+ int nFreeSize; // the size of remaining free memory
Vec_Ptr_t * vMemory; // the memory allocated
- Vec_Ptr_t * vFree; // the vector of ABC_FREE pieces of memory
+ Vec_Ptr_t * vFree; // the vector of free pieces of memory
};
typedef struct Supp_One_t_ Supp_One_t;
@@ -90,7 +95,7 @@ void Supp_ManStop( Supp_Man_t * p )
{
void * pMemory;
int i;
- Vec_PtrForEachEntry( p->vMemory, pMemory, i )
+ Vec_PtrForEachEntry( void *, p->vMemory, pMemory, i )
ABC_FREE( pMemory );
Vec_PtrFree( p->vMemory );
Vec_PtrFree( p->vFree );
@@ -115,7 +120,7 @@ char * Supp_ManFetch( Supp_Man_t * p, int nSize )
assert( nSize > 0 );
Type = Supp_SizeType( nSize, p->nStepSize );
Vec_PtrFillExtra( p->vFree, Type + 1, NULL );
- if ( (pMemory = Vec_PtrEntry( p->vFree, Type )) )
+ if ( (pMemory = (char *)Vec_PtrEntry( p->vFree, Type )) )
{
Vec_PtrWriteEntry( p->vFree, Type, Supp_OneNext(pMemory) );
return pMemory;
@@ -150,7 +155,7 @@ void Supp_ManRecycle( Supp_Man_t * p, char * pMemory, int nSize )
int Type;
Type = Supp_SizeType( nSize, p->nStepSize );
Vec_PtrFillExtra( p->vFree, Type + 1, NULL );
- Supp_OneSetNext( pMemory, Vec_PtrEntry(p->vFree, Type) );
+ Supp_OneSetNext( pMemory, (char *)Vec_PtrEntry(p->vFree, Type) );
Vec_PtrWriteEntry( p->vFree, Type, pMemory );
}
@@ -331,7 +336,7 @@ Vec_Ptr_t * Abc_NtkComputeSupportsSmart( Abc_Ntk_t * pNtk )
Abc_NtkCleanCopy(pNtk);
// order the nodes so that the PIs and POs follow naturally
vNodes = Abc_NtkDfsNatural( pNtk );
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
{
if ( Abc_ObjIsNode(pObj) )
{
@@ -390,7 +395,7 @@ Vec_Ptr_t * Abc_NtkComputeSupportsSmart( Abc_Ntk_t * pNtk )
Abc_NtkForEachCo( pNtk, pObj, i )
pObj->pNext = NULL;
/*
- Vec_PtrForEachEntry( vSupports, vSupp, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vSupports, vSupp, i )
printf( "%d ", Vec_IntSize(vSupp) );
printf( "\n" );
*/
@@ -417,7 +422,7 @@ Vec_Ptr_t * Abc_NtkComputeSupportsNaive( Abc_Ntk_t * pNtk )
int i, k;
// set the PI numbers
Abc_NtkForEachCi( pNtk, pObj, i )
- pObj->pNext = (void *)(ABC_PTRINT_T)i;
+ pObj->pNext = (Abc_Obj_t *)(ABC_PTRINT_T)i;
// save the CI numbers
vSupports = Vec_PtrAlloc( Abc_NtkCoNum(pNtk) );
Abc_NtkForEachCo( pNtk, pObj, i )
@@ -426,7 +431,7 @@ Vec_Ptr_t * Abc_NtkComputeSupportsNaive( Abc_Ntk_t * pNtk )
continue;
vSupp = Abc_NtkNodeSupport( pNtk, &pObj, 1 );
vSuppI = (Vec_Int_t *)vSupp;
- Vec_PtrForEachEntry( vSupp, pTemp, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vSupp, pTemp, k )
Vec_IntWriteEntry( vSuppI, k, (int)(ABC_PTRINT_T)pTemp->pNext );
Vec_IntSort( vSuppI, 0 );
// append the number of this output
@@ -440,7 +445,7 @@ Vec_Ptr_t * Abc_NtkComputeSupportsNaive( Abc_Ntk_t * pNtk )
// sort supports by size
Vec_VecSort( (Vec_Vec_t *)vSupports, 1 );
/*
- Vec_PtrForEachEntry( vSupports, vSuppI, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vSupports, vSuppI, i )
printf( "%d ", Vec_IntSize(vSuppI) );
printf( "\n" );
*/
@@ -532,7 +537,7 @@ int Abc_NtkPartitionSmartFindPart( Vec_Ptr_t * vPartSuppsAll, Vec_Ptr_t * vParts
int i, nCommon, iBest;
iBest = -1;
CostBest = 0.0;
- Vec_PtrForEachEntry( vPartSuppsAll, vPartSupp, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vPartSuppsAll, vPartSupp, i )
{
vPart = Vec_PtrEntry( vPartsAll, i );
if ( nPartSizeLimit > 0 && Vec_IntSize(vPart) >= nPartSizeLimit )
@@ -565,7 +570,7 @@ int Abc_NtkPartitionSmartFindPart( Vec_Ptr_t * vPartSuppsAll, Vec_Ptr_t * vParts
// int nCommon2;
iBest = -1;
ValueBest = 0;
- Vec_PtrForEachEntry( vPartSuppsAll, vPartSupp, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vPartSuppsAll, vPartSupp, i )
{
// skip partitions with too many outputs
// vPart = Vec_PtrEntry( vPartsAll, i );
@@ -573,7 +578,7 @@ int Abc_NtkPartitionSmartFindPart( Vec_Ptr_t * vPartSuppsAll, Vec_Ptr_t * vParts
// continue;
// find the number of common variables between this output and the partitions
// nCommon2 = Vec_IntTwoCountCommon( vPartSupp, vOne );
- nCommon = Abc_NtkSuppCharCommon( Vec_PtrEntry(vPartSuppsChar, i), vOne );
+ nCommon = Abc_NtkSuppCharCommon( (unsigned *)Vec_PtrEntry(vPartSuppsChar, i), vOne );
// assert( nCommon2 == nCommon );
// if no common variables, continue searching
if ( nCommon == 0 )
@@ -619,9 +624,9 @@ void Abc_NtkPartitionPrint( Abc_Ntk_t * pNtk, Vec_Ptr_t * vPartsAll, Vec_Ptr_t *
int i, nOutputs, Counter;
Counter = 0;
- Vec_PtrForEachEntry( vPartSuppsAll, vOne, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vPartSuppsAll, vOne, i )
{
- nOutputs = Vec_IntSize(Vec_PtrEntry(vPartsAll, i));
+ nOutputs = Vec_IntSize((Vec_Int_t *)Vec_PtrEntry(vPartsAll, i));
printf( "%d=(%d,%d) ", i, Vec_IntSize(vOne), nOutputs );
Counter += nOutputs;
if ( i == Vec_PtrSize(vPartsAll) - 1 )
@@ -653,7 +658,7 @@ void Abc_NtkPartitionCompact( Vec_Ptr_t * vPartsAll, Vec_Ptr_t * vPartSuppsAll,
// pack smaller partitions into larger blocks
iPart = 0;
vPart = vPartSupp = NULL;
- Vec_PtrForEachEntry( vPartSuppsAll, vOne, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vPartSuppsAll, vOne, i )
{
if ( Vec_IntSize(vOne) < nSuppSizeLimit )
{
@@ -661,27 +666,27 @@ void Abc_NtkPartitionCompact( Vec_Ptr_t * vPartsAll, Vec_Ptr_t * vPartSuppsAll,
{
assert( vPart == NULL );
vPartSupp = Vec_IntDup(vOne);
- vPart = Vec_PtrEntry(vPartsAll, i);
+ vPart = (Vec_Int_t *)Vec_PtrEntry(vPartsAll, i);
}
else
{
vPartSupp = Vec_IntTwoMerge( vTemp = vPartSupp, vOne );
Vec_IntFree( vTemp );
- vPart = Vec_IntTwoMerge( vTemp = vPart, Vec_PtrEntry(vPartsAll, i) );
+ vPart = Vec_IntTwoMerge( vTemp = vPart, (Vec_Int_t *)Vec_PtrEntry(vPartsAll, i) );
Vec_IntFree( vTemp );
- Vec_IntFree( Vec_PtrEntry(vPartsAll, i) );
+ Vec_IntFree( (Vec_Int_t *)Vec_PtrEntry(vPartsAll, i) );
}
if ( Vec_IntSize(vPartSupp) < nSuppSizeLimit )
continue;
}
else
- vPart = Vec_PtrEntry(vPartsAll, i);
+ vPart = (Vec_Int_t *)Vec_PtrEntry(vPartsAll, i);
// add the partition
Vec_PtrWriteEntry( vPartsAll, iPart, vPart );
vPart = NULL;
if ( vPartSupp )
{
- Vec_IntFree( Vec_PtrEntry(vPartSuppsAll, iPart) );
+ Vec_IntFree( (Vec_Int_t *)Vec_PtrEntry(vPartSuppsAll, iPart) );
Vec_PtrWriteEntry( vPartSuppsAll, iPart, vPartSupp );
vPartSupp = NULL;
}
@@ -694,7 +699,7 @@ void Abc_NtkPartitionCompact( Vec_Ptr_t * vPartsAll, Vec_Ptr_t * vPartSuppsAll,
vPart = NULL;
assert( vPartSupp != NULL );
- Vec_IntFree( Vec_PtrEntry(vPartSuppsAll, iPart) );
+ Vec_IntFree( (Vec_Int_t *)Vec_PtrEntry(vPartSuppsAll, iPart) );
Vec_PtrWriteEntry( vPartSuppsAll, iPart, vPartSupp );
vPartSupp = NULL;
iPart++;
@@ -738,7 +743,7 @@ clk = clock();
vPartsAll = Vec_PtrAlloc( 256 );
vPartSuppsAll = Vec_PtrAlloc( 256 );
pProgress = Extra_ProgressBarStart( stdout, Vec_PtrSize(vSupps) );
- Vec_PtrForEachEntry( vSupps, vOne, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vSupps, vOne, i )
{
Extra_ProgressBarUpdate( pProgress, i, NULL );
// if ( i % 1000 == 0 )
@@ -766,22 +771,22 @@ timeFind += clock() - clk2;
else
{
// add output to this partition
- vPart = Vec_PtrEntry( vPartsAll, iPart );
+ vPart = (Vec_Int_t *)Vec_PtrEntry( vPartsAll, iPart );
Vec_IntPush( vPart, iOut );
// merge supports
- vPartSupp = Vec_PtrEntry( vPartSuppsAll, iPart );
+ vPartSupp = (Vec_Int_t *)Vec_PtrEntry( vPartSuppsAll, iPart );
vPartSupp = Vec_IntTwoMerge( vTemp = vPartSupp, vOne );
Vec_IntFree( vTemp );
// reinsert new support
Vec_PtrWriteEntry( vPartSuppsAll, iPart, vPartSupp );
- Abc_NtkSuppCharAdd( Vec_PtrEntry(vPartSuppsChar, iPart), vOne, Abc_NtkCiNum(pNtk) );
+ Abc_NtkSuppCharAdd( (unsigned *)Vec_PtrEntry(vPartSuppsChar, iPart), vOne, Abc_NtkCiNum(pNtk) );
}
}
Extra_ProgressBarStop( pProgress );
// stop char-based support representation
- Vec_PtrForEachEntry( vPartSuppsChar, vTemp, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vPartSuppsChar, vTemp, i )
ABC_FREE( vTemp );
Vec_PtrFree( vPartSuppsChar );
@@ -794,13 +799,13 @@ ABC_PRT( "Parts", clock() - clk );
clk = clock();
// remember number of supports
- Vec_PtrForEachEntry( vPartSuppsAll, vOne, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vPartSuppsAll, vOne, i )
Vec_IntPush( vOne, i );
// sort the supports in the decreasing order
Vec_VecSort( (Vec_Vec_t *)vPartSuppsAll, 1 );
// reproduce partitions
vPartsAll2 = Vec_PtrAlloc( 256 );
- Vec_PtrForEachEntry( vPartSuppsAll, vOne, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vPartSuppsAll, vOne, i )
Vec_PtrPush( vPartsAll2, Vec_PtrEntry(vPartsAll, Vec_IntPop(vOne)) );
Vec_PtrFree( vPartsAll );
vPartsAll = vPartsAll2;
@@ -822,7 +827,7 @@ ABC_PRT( "Comps", clock() - clk );
Vec_VecFree( (Vec_Vec_t *)vPartSuppsAll );
/*
// converts from intergers to nodes
- Vec_PtrForEachEntry( vPartsAll, vPart, iPart )
+ Vec_PtrForEachEntry( Vec_Int_t *, vPartsAll, vPart, iPart )
{
vPartPtr = Vec_PtrAlloc( Vec_IntSize(vPart) );
Vec_IntForEachEntry( vPart, iOut, i )
@@ -853,7 +858,7 @@ Vec_Ptr_t * Abc_NtkPartitionNaive( Abc_Ntk_t * pNtk, int nPartSize )
nParts = (Abc_NtkCoNum(pNtk) / nPartSize) + ((Abc_NtkCoNum(pNtk) % nPartSize) > 0);
vParts = (Vec_Ptr_t *)Vec_VecStart( nParts );
Abc_NtkForEachCo( pNtk, pObj, i )
- Vec_IntPush( Vec_PtrEntry(vParts, i / nPartSize), i );
+ Vec_IntPush( (Vec_Int_t *)Vec_PtrEntry(vParts, i / nPartSize), i );
return vParts;
}
@@ -890,7 +895,7 @@ void Abc_NtkConvertCos( Abc_Ntk_t * pNtk, Vec_Int_t * vOuts, Vec_Ptr_t * vOutsPt
Abc_Obj_t * Abc_NtkPartStitchFindRepr_rec( Vec_Ptr_t * vEquiv, Abc_Obj_t * pObj )
{
Abc_Obj_t * pRepr;
- pRepr = Vec_PtrEntry( vEquiv, pObj->Id );
+ pRepr = (Abc_Obj_t *)Vec_PtrEntry( vEquiv, pObj->Id );
if ( pRepr == NULL || pRepr == pObj )
return pObj;
return Abc_NtkPartStitchFindRepr_rec( vEquiv, pRepr );
@@ -911,13 +916,13 @@ static inline Abc_Obj_t * Abc_NtkPartStitchCopy0( Vec_Ptr_t * vEquiv, Abc_Obj_t
{
Abc_Obj_t * pFan = Abc_ObjFanin0( pObj );
Abc_Obj_t * pRepr = Abc_NtkPartStitchFindRepr_rec( vEquiv, pFan );
- return Abc_ObjNotCond( pRepr->pCopy, pRepr->fPhase ^ pFan->fPhase ^ Abc_ObjFaninC1(pObj) );
+ return Abc_ObjNotCond( pRepr->pCopy, pRepr->fPhase ^ pFan->fPhase ^ (int)Abc_ObjFaninC1(pObj) );
}
static inline Abc_Obj_t * Abc_NtkPartStitchCopy1( Vec_Ptr_t * vEquiv, Abc_Obj_t * pObj )
{
Abc_Obj_t * pFan = Abc_ObjFanin1( pObj );
Abc_Obj_t * pRepr = Abc_NtkPartStitchFindRepr_rec( vEquiv, pFan );
- return Abc_ObjNotCond( pRepr->pCopy, pRepr->fPhase ^ pFan->fPhase ^ Abc_ObjFaninC1(pObj) );
+ return Abc_ObjNotCond( pRepr->pCopy, pRepr->fPhase ^ pFan->fPhase ^ (int)Abc_ObjFaninC1(pObj) );
}
/**Function*************************************************************
@@ -1006,7 +1011,7 @@ Abc_Ntk_t * Abc_NtkPartStitchChoices( Abc_Ntk_t * pNtk, Vec_Ptr_t * vParts )
pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_STRASH, ABC_FUNC_AIG );
// annotate parts to point to the new network
- Vec_PtrForEachEntry( vParts, pNtkTemp, i )
+ Vec_PtrForEachEntry( Abc_Ntk_t *, vParts, pNtkTemp, i )
{
assert( Abc_NtkIsStrash(pNtkTemp) );
Abc_NtkCleanCopy( pNtkTemp );
@@ -1026,12 +1031,12 @@ Abc_Ntk_t * Abc_NtkPartStitchChoices( Abc_Ntk_t * pNtk, Vec_Ptr_t * vParts )
// add the internal nodes while saving representatives
vNodes = Abc_AigDfs( pNtkTemp, 1, 0 );
- Vec_PtrForEachEntry( vNodes, pObj, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, k )
{
- pObj->pCopy = Abc_AigAnd( pNtkNew->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
+ pObj->pCopy = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
assert( !Abc_ObjIsComplement(pObj->pCopy) );
if ( Abc_AigNodeIsChoice(pObj) )
- for ( pFanin = pObj->pData; pFanin; pFanin = pFanin->pData )
+ for ( pFanin = (Abc_Obj_t *)pObj->pData; pFanin; pFanin = (Abc_Obj_t *)pFanin->pData )
pFanin->pCopy->pCopy = pObj->pCopy;
}
Vec_PtrFree( vNodes );
@@ -1092,16 +1097,13 @@ Abc_Ntk_t * Abc_NtkPartStitchChoices( Abc_Ntk_t * pNtk, Vec_Ptr_t * vParts )
***********************************************************************/
Abc_Ntk_t * Abc_NtkFraigPartitioned( Vec_Ptr_t * vStore, void * pParams )
{
- extern int Cmd_CommandExecute( void * pAbc, char * sCommand );
- extern void * Abc_FrameGetGlobalFrame();
-
Vec_Ptr_t * vParts, * vFraigs, * vOnePtr;
Vec_Int_t * vOne;
Abc_Ntk_t * pNtk, * pNtk2, * pNtkAig, * pNtkFraig;
int i, k;
// perform partitioning
- pNtk = Vec_PtrEntry( vStore, 0 );
+ pNtk = (Abc_Ntk_t *)Vec_PtrEntry( vStore, 0 );
assert( Abc_NtkIsStrash(pNtk) );
// vParts = Abc_NtkPartitionNaive( pNtk, 20 );
vParts = Abc_NtkPartitionSmart( pNtk, 300, 0 );
@@ -1111,13 +1113,13 @@ Abc_Ntk_t * Abc_NtkFraigPartitioned( Vec_Ptr_t * vStore, void * pParams )
// fraig each partition
vOnePtr = Vec_PtrAlloc( 1000 );
vFraigs = Vec_PtrAlloc( Vec_PtrSize(vParts) );
- Vec_PtrForEachEntry( vParts, vOne, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vParts, vOne, i )
{
// start the partition
Abc_NtkConvertCos( pNtk, vOne, vOnePtr );
pNtkAig = Abc_NtkCreateConeArray( pNtk, vOnePtr, 0 );
// add nodes to the partition
- Vec_PtrForEachEntryStart( vStore, pNtk2, k, 1 )
+ Vec_PtrForEachEntryStart( Abc_Ntk_t *, vStore, pNtk2, k, 1 )
{
Abc_NtkConvertCos( pNtk2, vOne, vOnePtr );
Abc_NtkAppendToCone( pNtkAig, pNtk2, vOnePtr );
@@ -1137,7 +1139,7 @@ Abc_Ntk_t * Abc_NtkFraigPartitioned( Vec_Ptr_t * vStore, void * pParams )
// derive the final network
pNtkFraig = Abc_NtkPartStitchChoices( pNtk, vFraigs );
- Vec_PtrForEachEntry( vFraigs, pNtkAig, i )
+ Vec_PtrForEachEntry( Abc_Ntk_t *, vFraigs, pNtkAig, i )
Abc_NtkDelete( pNtkAig );
Vec_PtrFree( vFraigs );
Vec_PtrFree( vOnePtr );
@@ -1157,9 +1159,6 @@ Abc_Ntk_t * Abc_NtkFraigPartitioned( Vec_Ptr_t * vStore, void * pParams )
***********************************************************************/
void Abc_NtkFraigPartitionedTime( Abc_Ntk_t * pNtk, void * pParams )
{
- extern int Cmd_CommandExecute( void * pAbc, char * sCommand );
- extern void * Abc_FrameGetGlobalFrame();
-
Vec_Ptr_t * vParts, * vFraigs, * vOnePtr;
Vec_Int_t * vOne;
Abc_Ntk_t * pNtkAig, * pNtkFraig;
@@ -1176,7 +1175,7 @@ void Abc_NtkFraigPartitionedTime( Abc_Ntk_t * pNtk, void * pParams )
// fraig each partition
vOnePtr = Vec_PtrAlloc( 1000 );
vFraigs = Vec_PtrAlloc( Vec_PtrSize(vParts) );
- Vec_PtrForEachEntry( vParts, vOne, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vParts, vOne, i )
{
Abc_NtkConvertCos( pNtk, vOne, vOnePtr );
pNtkAig = Abc_NtkCreateConeArray( pNtk, vOnePtr, 0 );
@@ -1191,7 +1190,7 @@ void Abc_NtkFraigPartitionedTime( Abc_Ntk_t * pNtk, void * pParams )
Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "set progressbar" );
// derive the final network
- Vec_PtrForEachEntry( vFraigs, pNtkAig, i )
+ Vec_PtrForEachEntry( Abc_Ntk_t *, vFraigs, pNtkAig, i )
Abc_NtkDelete( pNtkAig );
Vec_PtrFree( vFraigs );
Vec_PtrFree( vOnePtr );
@@ -1203,3 +1202,5 @@ void Abc_NtkFraigPartitionedTime( Abc_Ntk_t * pNtk, void * pParams )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcPlace.c b/src/base/abci/abcPlace.c
index 87c99e99..06c23e65 100644
--- a/src/base/abci/abcPlace.c
+++ b/src/base/abci/abcPlace.c
@@ -23,6 +23,9 @@
// placement includes
#include "place_base.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -102,7 +105,7 @@ float Abc_PlaceEvaluateCut( Abc_Obj_t * pRoot, Vec_Ptr_t * vFanins )
Abc_Obj_t * pObj;
// double x, y;
int i;
- Vec_PtrForEachEntry( vFanins, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vFanins, pObj, i )
{
// pObj->Id
}
@@ -131,7 +134,7 @@ void Abc_PlaceUpdate( Vec_Ptr_t * vAddedCells, Vec_Ptr_t * vUpdatedNets )
vNets = Vec_PtrAlloc( 32 );
// go through the new nodes
- Vec_PtrForEachEntry( vAddedCells, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vAddedCells, pObj, i )
{
assert( !Abc_ObjIsComplement(pObj) );
Abc_PlaceCreateCell( pObj, 1 );
@@ -144,7 +147,7 @@ void Abc_PlaceUpdate( Vec_Ptr_t * vAddedCells, Vec_Ptr_t * vUpdatedNets )
}
// go through the modified nets
- Vec_PtrForEachEntry( vUpdatedNets, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vUpdatedNets, pObj, i )
{
assert( !Abc_ObjIsComplement(pObj) );
if ( Abc_ObjType(pObj) == ABC_OBJ_NONE ) // dead node
@@ -253,3 +256,5 @@ void Abc_PlaceEnd( Abc_Ntk_t * pNtk )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcPrint.c b/src/base/abci/abcPrint.c
index c9fb2834..9f52d71f 100644
--- a/src/base/abci/abcPrint.c
+++ b/src/base/abci/abcPrint.c
@@ -18,12 +18,16 @@
***********************************************************************/
+#include <math.h>
#include "abc.h"
#include "dec.h"
#include "main.h"
#include "mio.h"
#include "aig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -126,7 +130,7 @@ float Abc_NtkMfsTotalSwitching( Abc_Ntk_t * pNtk )
// strash the network
pNtkStr = Abc_NtkStrash( pNtk, 0, 1, 0 );
Abc_NtkForEachObj( pNtk, pObjAbc, i )
- if ( Abc_ObjRegular(pObjAbc->pTemp)->Type == ABC_FUNC_NONE )
+ if ( Abc_ObjRegular((Abc_Obj_t *)pObjAbc->pTemp)->Type == ABC_FUNC_NONE )
pObjAbc->pTemp = NULL;
// map network into an AIG
pAig = Abc_NtkToDar( pNtkStr, 0, (int)(Abc_NtkLatchNum(pNtk) > 0) );
@@ -134,7 +138,7 @@ float Abc_NtkMfsTotalSwitching( Abc_Ntk_t * pNtk )
pSwitching = (float *)vSwitching->pArray;
Abc_NtkForEachObj( pNtk, pObjAbc, i )
{
- if ( (pObjAbc2 = Abc_ObjRegular(pObjAbc->pTemp)) && (pObjAig = Aig_Regular(pObjAbc2->pTemp)) )
+ if ( (pObjAbc2 = Abc_ObjRegular((Abc_Obj_t *)pObjAbc->pTemp)) && (pObjAig = Aig_Regular((Aig_Obj_t *)pObjAbc2->pTemp)) )
{
Result += Abc_ObjFanoutNum(pObjAbc) * pSwitching[pObjAig->Id];
// printf( "%d = %.2f\n", i, Abc_ObjFanoutNum(pObjAbc) * pSwitching[pObjAig->Id] );
@@ -157,15 +161,16 @@ float Abc_NtkMfsTotalSwitching( Abc_Ntk_t * pNtk )
SeeAlso []
***********************************************************************/
-void Abc_NtkPrintStats( FILE * pFile, Abc_Ntk_t * pNtk, int fFactored, int fSaveBest, int fDumpResult, int fUseLutLib, int fPrintMuxes, int fPower, int fGlitch )
+void Abc_NtkPrintStats( Abc_Ntk_t * pNtk, int fFactored, int fSaveBest, int fDumpResult, int fUseLutLib, int fPrintMuxes, int fPower, int fGlitch )
{
+ FILE * pFile = stdout;
int Num;
if ( fSaveBest )
Abc_NtkCompareAndSaveBest( pNtk );
if ( fDumpResult )
{
char Buffer[1000] = {0};
- char * pNameGen = pNtk->pSpec? Extra_FileNameGeneric( pNtk->pSpec ) : "nameless_";
+ const char * pNameGen = pNtk->pSpec? Extra_FileNameGeneric( pNtk->pSpec ) : "nameless_";
sprintf( Buffer, "%s_dump.blif", pNameGen );
Io_Write( pNtk, Buffer, IO_FILE_BLIF );
if ( pNtk->pSpec ) ABC_FREE( pNameGen );
@@ -175,10 +180,9 @@ void Abc_NtkPrintStats( FILE * pFile, Abc_Ntk_t * pNtk, int fFactored, int fSave
// Abc_AigCountNext( pNtk->pManFunc );
fprintf( pFile, "%-13s:", pNtk->pName );
- if ( Abc_NtkAssertNum(pNtk) )
- fprintf( pFile, " i/o/a =%5d/%5d/%5d", Abc_NtkPiNum(pNtk), Abc_NtkPoNum(pNtk), Abc_NtkAssertNum(pNtk) );
- else
- fprintf( pFile, " i/o =%5d/%5d", Abc_NtkPiNum(pNtk), Abc_NtkPoNum(pNtk) );
+ fprintf( pFile, " i/o =%5d/%5d", Abc_NtkPiNum(pNtk), Abc_NtkPoNum(pNtk) );
+ if ( Abc_NtkConstrNum(pNtk) )
+ fprintf( pFile, "(c=%d)", Abc_NtkConstrNum(pNtk) );
fprintf( pFile, " lat =%5d", Abc_NtkLatchNum(pNtk) );
if ( Abc_NtkIsNetlist(pNtk) )
{
@@ -282,10 +286,12 @@ void Abc_NtkPrintStats( FILE * pFile, Abc_Ntk_t * pNtk, int fFactored, int fSave
// print the statistic into a file
{
FILE * pTable;
- pTable = fopen( "stats.txt", "a+" );
- fprintf( pTable, "%s ", pNtk->pSpec );
- fprintf( pTable, "%.0f ", Abc_NtkGetMappedArea(pNtk) );
- fprintf( pTable, "%.2f ", Abc_NtkDelayTrace(pNtk) );
+ pTable = fopen( "ucsb/stats.txt", "a+" );
+// fprintf( pTable, "%s ", pNtk->pSpec );
+ fprintf( pTable, "%d ", Abc_NtkNodeNum(pNtk) );
+// fprintf( pTable, "%d ", Abc_NtkLevel(pNtk) );
+// fprintf( pTable, "%.0f ", Abc_NtkGetMappedArea(pNtk) );
+// fprintf( pTable, "%.2f ", Abc_NtkDelayTrace(pNtk) );
fprintf( pTable, "\n" );
fclose( pTable );
}
@@ -320,25 +326,6 @@ void Abc_NtkPrintStats( FILE * pFile, Abc_Ntk_t * pNtk, int fFactored, int fSave
extern int timeRetime;
FILE * pTable;
Counter++;
- 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_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) );
@@ -349,7 +336,7 @@ void Abc_NtkPrintStats( FILE * pFile, Abc_Ntk_t * pNtk, int fFactored, int fSave
fprintf( pTable, "\n" );
fclose( pTable );
}
-*/
+
/*
s_TotalNodes += Abc_NtkNodeNum(pNtk);
@@ -628,7 +615,7 @@ void Abc_NtkPrintFanioNew( FILE * pFile, Abc_Ntk_t * pNtk )
fprintf( pFile, "%15d : ", k );
else
{
- sprintf( Buffer, "%d - %d", (int)pow(10, k/10) * (k%10), (int)pow(10, k/10) * (k%10+1) - 1 );
+ sprintf( Buffer, "%d - %d", (int)pow((double)10, k/10) * (k%10), (int)pow((double)10, k/10) * (k%10+1) - 1 );
fprintf( pFile, "%15s : ", Buffer );
}
if ( vFanins->pArray[k] == 0 )
@@ -757,7 +744,7 @@ void Abc_NodePrintFactor( FILE * pFile, Abc_Obj_t * pNode, int fUseRealNames )
return;
}
assert( Abc_ObjIsNode(pNode) );
- pGraph = Dec_Factor( pNode->pData );
+ pGraph = Dec_Factor( (char *)pNode->pData );
if ( fUseRealNames )
{
vNamesIn = Abc_NodeGetFaninNames(pNode);
@@ -941,12 +928,12 @@ void Abc_NodePrintKMap( Abc_Obj_t * pNode, int fUseRealNames )
if ( fUseRealNames )
{
vNamesIn = Abc_NodeGetFaninNames(pNode);
- Extra_PrintKMap( stdout, pNode->pNtk->pManFunc, pNode->pData, Cudd_Not(pNode->pData),
+ Extra_PrintKMap( stdout, (DdManager *)pNode->pNtk->pManFunc, (DdNode *)pNode->pData, Cudd_Not(pNode->pData),
Abc_ObjFaninNum(pNode), NULL, 0, (char **)vNamesIn->pArray );
Abc_NodeFreeNames( vNamesIn );
}
else
- Extra_PrintKMap( stdout, pNode->pNtk->pManFunc, pNode->pData, Cudd_Not(pNode->pData),
+ Extra_PrintKMap( stdout, (DdManager *)pNode->pNtk->pManFunc, (DdNode *)pNode->pData, Cudd_Not(pNode->pData),
Abc_ObjFaninNum(pNode), NULL, 0, NULL );
}
@@ -976,8 +963,8 @@ void Abc_NtkPrintGates( Abc_Ntk_t * pNtk, int fUseLibrary )
int Counter, nGates, i;
// clean value of all gates
- nGates = Mio_LibraryReadGateNum( pNtk->pManFunc );
- ppGates = Mio_LibraryReadGatesByName( pNtk->pManFunc );
+ nGates = Mio_LibraryReadGateNum( (Mio_Library_t *)pNtk->pManFunc );
+ ppGates = Mio_LibraryReadGatesByName( (Mio_Library_t *)pNtk->pManFunc );
for ( i = 0; i < nGates; i++ )
Mio_GateSetValue( ppGates[i], 0 );
@@ -986,7 +973,7 @@ void Abc_NtkPrintGates( Abc_Ntk_t * pNtk, int fUseLibrary )
Abc_NtkForEachNode( pNtk, pObj, i )
{
if ( i == 0 ) continue;
- Mio_GateSetValue( pObj->pData, 1 + Mio_GateReadValue(pObj->pData) );
+ Mio_GateSetValue( (Mio_Gate_t *)pObj->pData, 1 + Mio_GateReadValue((Mio_Gate_t *)pObj->pData) );
CounterTotal++;
}
// print the gates
@@ -1026,9 +1013,9 @@ void Abc_NtkPrintGates( Abc_Ntk_t * pNtk, int fUseLibrary )
{
if ( i == 0 ) continue;
if ( Abc_NtkHasMapping(pNtk) )
- pSop = Mio_GateReadSop(pObj->pData);
+ pSop = Mio_GateReadSop((Mio_Gate_t *)pObj->pData);
else
- pSop = pObj->pData;
+ pSop = (char *)pObj->pData;
// collect the stats
if ( Abc_SopIsConst0(pSop) || Abc_SopIsConst1(pSop) )
CountConst++;
@@ -1084,7 +1071,7 @@ void Abc_NtkPrintSharing( Abc_Ntk_t * pNtk )
{
vNodes1 = Abc_NtkDfsNodes( pNtk, &pObj1, 1 );
// mark the nodes
- Vec_PtrForEachEntry( vNodes1, pNode1, m )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes1, pNode1, m )
pNode1->fMarkA = 1;
// go through the second COs
Abc_NtkForEachCo( pNtk, pObj2, k )
@@ -1094,14 +1081,14 @@ void Abc_NtkPrintSharing( Abc_Ntk_t * pNtk )
vNodes2 = Abc_NtkDfsNodes( pNtk, &pObj2, 1 );
// count the number of marked
Counter = 0;
- Vec_PtrForEachEntry( vNodes2, pNode2, n )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes2, pNode2, n )
Counter += pNode2->fMarkA;
// print
printf( "(%d,%d)=%d ", i, k, Counter );
Vec_PtrFree( vNodes2 );
}
// unmark the nodes
- Vec_PtrForEachEntry( vNodes1, pNode1, m )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes1, pNode1, m )
pNode1->fMarkA = 0;
Vec_PtrFree( vNodes1 );
}
@@ -1332,12 +1319,12 @@ float Abc_NtkMfsTotalGlitching( Abc_Ntk_t * pNtk )
pObj->iTemp = -1;
Abc_NtkForEachCi( pNtk, pObj, i )
pObj->iTemp = Gli_ManCreateCi( p, Abc_ObjFanoutNum(pObj) );
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
{
Vec_IntClear( vFanins );
Abc_ObjForEachFanin( pObj, pFanin, k )
Vec_IntPush( vFanins, pFanin->iTemp );
- puTruth = Hop_ManConvertAigToTruth( pNtk->pManFunc, pObj->pData, Abc_ObjFaninNum(pObj), vTruth, 0 );
+ puTruth = Hop_ManConvertAigToTruth( (Hop_Man_t *)pNtk->pManFunc, (Hop_Obj_t *)pObj->pData, Abc_ObjFaninNum(pObj), vTruth, 0 );
pObj->iTemp = Gli_ManCreateNode( p, vFanins, Abc_ObjFanoutNum(pObj), puTruth );
}
Abc_NtkForEachCo( pNtk, pObj, i )
@@ -1367,3 +1354,5 @@ float Abc_NtkMfsTotalGlitching( Abc_Ntk_t * pNtk )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcProve.c b/src/base/abci/abcProve.c
index 5a546ab1..35c1ee29 100644
--- a/src/base/abci/abcProve.c
+++ b/src/base/abci/abcProve.c
@@ -22,11 +22,14 @@
#include "fraig.h"
#include "math.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
-extern int Abc_NtkRefactor( Abc_Ntk_t * pNtk, int nNodeSizeMax, int nConeSizeMax, bool fUpdateLevel, bool fUseZeros, bool fUseDcs, bool fVerbose );
+extern int Abc_NtkRefactor( Abc_Ntk_t * pNtk, int nNodeSizeMax, int nConeSizeMax, int fUpdateLevel, int fUseZeros, int fUseDcs, int fVerbose );
extern Abc_Ntk_t * Abc_NtkFromFraig( Fraig_Man_t * pMan, Abc_Ntk_t * pNtk );
static Abc_Ntk_t * Abc_NtkMiterFraig( Abc_Ntk_t * pNtk, int nBTLimit, ABC_INT64_T nInspLimit, int * pRetValue, int * pNumFails, ABC_INT64_T * pNumConfs, ABC_INT64_T * pNumInspects );
@@ -53,7 +56,7 @@ static void Abc_NtkMiterPrint( Abc_Ntk_t * pNtk, char * pString, int clk, int fV
***********************************************************************/
int Abc_NtkMiterProve( Abc_Ntk_t ** ppNtk, void * pPars )
{
- Prove_Params_t * pParams = pPars;
+ Prove_Params_t * pParams = (Prove_Params_t *)pPars;
Abc_Ntk_t * pNtk, * pNtkTemp;
int RetValue = -1, nIter, nSatFails, Counter, clk; //, timeStart = clock();
ABC_INT64_T nSatConfs, nSatInspects, nInspectLimit;
@@ -195,7 +198,7 @@ int Abc_NtkMiterProve( Abc_Ntk_t ** ppNtk, void * pPars )
if ( pNtk )
{
Abc_NtkDelete( pNtkTemp );
- RetValue = ( (Abc_NtkNodeNum(pNtk) == 1) && (Abc_ObjFanin0(Abc_NtkPo(pNtk,0))->pData == Cudd_ReadLogicZero(pNtk->pManFunc)) );
+ RetValue = ( (Abc_NtkNodeNum(pNtk) == 1) && (Abc_ObjFanin0(Abc_NtkPo(pNtk,0))->pData == Cudd_ReadLogicZero((DdManager *)pNtk->pManFunc)) );
}
else
pNtk = pNtkTemp;
@@ -264,7 +267,7 @@ Abc_Ntk_t * Abc_NtkMiterFraig( Abc_Ntk_t * pNtk, int nBTLimit, ABC_INT64_T nInsp
pParams->nInspLimit = nInspLimit;
// transform the target into a fraig
- pMan = Abc_NtkToFraig( pNtk, pParams, 0, 0 );
+ pMan = (Fraig_Man_t *)Abc_NtkToFraig( pNtk, pParams, 0, 0 );
Fraig_ManProveMiter( pMan );
RetValue = Fraig_ManCheckMiter( pMan );
@@ -339,3 +342,5 @@ Abc_Ntk_t * Abc_NtkMiterRwsat( Abc_Ntk_t * pNtk )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcQbf.c b/src/base/abci/abcQbf.c
index fe6ef895..d246f039 100644
--- a/src/base/abci/abcQbf.c
+++ b/src/base/abci/abcQbf.c
@@ -20,6 +20,9 @@
#include "abc.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*
Implementation of a simple QBF solver along the lines of
A. Solar-Lezama, L. Tancau, R. Bodik, V. Saraswat, and S. Seshia,
@@ -258,3 +261,5 @@ void Abc_NtkVectorPrintVars( Abc_Ntk_t * pNtk, Vec_Int_t * vPiValues, int nPars
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcQuant.c b/src/base/abci/abcQuant.c
index 6d973a85..957d99b5 100644
--- a/src/base/abci/abcQuant.c
+++ b/src/base/abci/abcQuant.c
@@ -20,6 +20,9 @@
#include "abc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -94,18 +97,24 @@ int Abc_NtkQuantify( Abc_Ntk_t * pNtk, int fUniv, int iVar, int fVerbose )
pObj->pData = Abc_AigConst1(pNtk);
// quantify the nodes
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
{
for ( pNext = pObj? pObj->pCopy : pObj; pObj; pObj = pNext, pNext = pObj? pObj->pCopy : pObj )
{
pFanin = Abc_ObjFanin0(pObj);
if ( !Abc_NodeIsTravIdCurrent(pFanin) )
- pFanin->pCopy = pFanin->pData = pFanin;
+ {
+ pFanin->pCopy = pFanin;
+ pFanin->pData = pFanin;
+ }
pFanin = Abc_ObjFanin1(pObj);
if ( !Abc_NodeIsTravIdCurrent(pFanin) )
- pFanin->pCopy = pFanin->pData = pFanin;
- pObj->pCopy = Abc_AigAnd( pNtk->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
- pObj->pData = Abc_AigAnd( pNtk->pManFunc, Abc_ObjChild0Data(pObj), Abc_ObjChild1Data(pObj) );
+ {
+ pFanin->pCopy = pFanin;
+ pFanin->pData = pFanin;
+ }
+ pObj->pCopy = Abc_AigAnd( (Abc_Aig_t *)pNtk->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
+ pObj->pData = Abc_AigAnd( (Abc_Aig_t *)pNtk->pManFunc, Abc_ObjChild0Data(pObj), Abc_ObjChild1Data(pObj) );
}
}
Vec_PtrFree( vNodes );
@@ -118,9 +127,9 @@ int Abc_NtkQuantify( Abc_Ntk_t * pNtk, int fUniv, int iVar, int fVerbose )
pFanin = Abc_ObjFanin0(pObj);
// get the result of quantification
if ( fUniv )
- pNext = Abc_AigAnd( pNtk->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild0Data(pObj) );
+ pNext = Abc_AigAnd( (Abc_Aig_t *)pNtk->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild0Data(pObj) );
else
- pNext = Abc_AigOr( pNtk->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild0Data(pObj) );
+ pNext = Abc_AigOr( (Abc_Aig_t *)pNtk->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild0Data(pObj) );
pNext = Abc_ObjNotCond( pNext, Abc_ObjFaninC0(pObj) );
if ( Abc_ObjRegular(pNext) == pFanin )
continue;
@@ -183,7 +192,7 @@ Abc_Ntk_t * Abc_NtkTransRel( Abc_Ntk_t * pNtk, int fInputs, int fVerbose )
// restrash the nodes (assuming a topological order of the old network)
Abc_AigConst1(pNtk)->pCopy = Abc_AigConst1(pNtkNew);
Abc_NtkForEachNode( pNtk, pObj, i )
- pObj->pCopy = Abc_AigAnd( pNtkNew->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
+ pObj->pCopy = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
// create the function of the primary output
assert( Abc_NtkBoxNum(pNtk) == Abc_NtkLatchNum(pNtk) );
vPairs = Vec_PtrAlloc( 2*nLatches );
@@ -192,7 +201,7 @@ Abc_Ntk_t * Abc_NtkTransRel( Abc_Ntk_t * pNtk, int fInputs, int fVerbose )
Vec_PtrPush( vPairs, Abc_ObjChild0Copy(pObj) );
Vec_PtrPush( vPairs, Abc_NtkPi(pNtkNew, i+nLatches) );
}
- pMiter = Abc_AigMiter( pNtkNew->pManFunc, vPairs, 0 );
+ pMiter = Abc_AigMiter( (Abc_Aig_t *)pNtkNew->pManFunc, vPairs, 0 );
Vec_PtrFree( vPairs );
// add the primary output
Abc_ObjAddFanin( Abc_NtkPo(pNtkNew,0), Abc_ObjNot(pMiter) );
@@ -210,7 +219,7 @@ Abc_Ntk_t * Abc_NtkTransRel( Abc_Ntk_t * pNtk, int fInputs, int fVerbose )
if ( fSynthesis )
{
Abc_NtkCleanData( pNtkNew );
- Abc_AigCleanup( pNtkNew->pManFunc );
+ Abc_AigCleanup( (Abc_Aig_t *)pNtkNew->pManFunc );
Abc_NtkSynthesize( &pNtkNew, 1 );
}
// printf( "Var = %3d. Nodes = %6d. ", Abc_NtkPiNum(pNtkNew) - 1 - i, Abc_NtkNodeNum(pNtkNew) );
@@ -218,7 +227,7 @@ Abc_Ntk_t * Abc_NtkTransRel( Abc_Ntk_t * pNtk, int fInputs, int fVerbose )
}
// printf( "\n" );
Abc_NtkCleanData( pNtkNew );
- Abc_AigCleanup( pNtkNew->pManFunc );
+ Abc_AigCleanup( (Abc_Aig_t *)pNtkNew->pManFunc );
for ( i = Abc_NtkPiNum(pNtkNew) - 1; i >= 2*nLatches; i-- )
{
pObj = Abc_NtkPi( pNtkNew, i );
@@ -260,7 +269,7 @@ Abc_Ntk_t * Abc_NtkInitialState( Abc_Ntk_t * pNtk )
// compute the all-zero state in terms of the CS variables
pMiter = Abc_AigConst1(pNtkNew);
for ( i = 0; i < nVars; i++ )
- pMiter = Abc_AigAnd( pNtkNew->pManFunc, pMiter, Abc_ObjNot( Abc_NtkPi(pNtkNew, i) ) );
+ pMiter = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, pMiter, Abc_ObjNot( Abc_NtkPi(pNtkNew, i) ) );
// add the PO
Abc_ObjAddFanin( Abc_NtkPo(pNtkNew,0), pMiter );
return pNtkNew;
@@ -296,7 +305,7 @@ Abc_Ntk_t * Abc_NtkSwapVariables( Abc_Ntk_t * pNtk )
}
// restrash
Abc_NtkForEachNode( pNtk, pObj, i )
- pObj->pCopy = Abc_AigAnd( pNtkNew->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
+ pObj->pCopy = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
// add the PO
pMiter = Abc_ObjChild0Copy( Abc_NtkPo(pNtk,0) );
Abc_ObjAddFanin( Abc_NtkPo(pNtkNew,0), pMiter );
@@ -351,12 +360,12 @@ Abc_Ntk_t * Abc_NtkReachability( Abc_Ntk_t * pNtkRel, int nIters, int fVerbose )
if ( fSynthesis && (v % 3 == 2) )
{
Abc_NtkCleanData( pNtkNext );
- Abc_AigCleanup( pNtkNext->pManFunc );
+ Abc_AigCleanup( (Abc_Aig_t *)pNtkNext->pManFunc );
Abc_NtkSynthesize( &pNtkNext, fMoreEffort );
}
}
Abc_NtkCleanData( pNtkNext );
- Abc_AigCleanup( pNtkNext->pManFunc );
+ Abc_AigCleanup( (Abc_Aig_t *)pNtkNext->pManFunc );
if ( fSynthesis )
Abc_NtkSynthesize( &pNtkNext, 1 );
// map the next states into the current states
@@ -422,3 +431,5 @@ Abc_Ntk_t * Abc_NtkReachability( Abc_Ntk_t * pNtkRel, int nIters, int fVerbose )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcReach.c b/src/base/abci/abcReach.c
index e25be81a..6eb7fb06 100644
--- a/src/base/abci/abcReach.c
+++ b/src/base/abci/abcReach.c
@@ -20,6 +20,9 @@
#include "abc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -312,3 +315,5 @@ void Abc_NtkVerifyUsingBdds( Abc_Ntk_t * pNtk, int nBddMax, int nIterMax, int fP
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcRec.c b/src/base/abci/abcRec.c
index d8884147..47380da1 100644
--- a/src/base/abci/abcRec.c
+++ b/src/base/abci/abcRec.c
@@ -22,6 +22,9 @@
#include "if.h"
#include "kit.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -613,13 +616,13 @@ int Abc_NtkRecCollectNodes( If_Man_t * pIfMan, If_Obj_t * pRoot, If_Cut_t * pCut
}
// clean the mark
- Vec_PtrForEachEntry( vNodes, pLeaf, i )
+ Vec_PtrForEachEntry( If_Obj_t *, vNodes, pLeaf, i )
pLeaf->fMark = 0;
/*
if ( pRoot->Id == 2639 )
{
// print the cut
- Vec_PtrForEachEntry( vNodes, pLeaf, i )
+ Vec_PtrForEachEntry( If_Obj_t *, vNodes, pLeaf, i )
{
if ( If_ObjIsAnd(pLeaf) )
printf( "%4d = %c%4d & %c%4d\n", pLeaf->Id,
@@ -657,7 +660,7 @@ int Abc_NtkRecCutTruth( Vec_Ptr_t * vNodes, int nLeaves, Vec_Ptr_t * vTtTemps, V
assert( Vec_PtrSize(vNodes) > nLeaves );
// set the elementary truth tables and compute the truth tables of the nodes
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( If_Obj_t *, vNodes, pObj, i )
{
pObj->pCopy = Vec_PtrEntry(vTtTemps, i);
pSims = (unsigned *)pObj->pCopy;
@@ -683,12 +686,12 @@ int Abc_NtkRecCutTruth( Vec_Ptr_t * vNodes, int nLeaves, Vec_Ptr_t * vTtTemps, V
// make sure none of the nodes has the same simulation info as the output
// check pairwise comparisons
nLimit = Vec_PtrSize(vNodes) - 1;
- Vec_PtrForEachEntryStop( vNodes, pObj, i, nLimit )
+ Vec_PtrForEachEntryStop( If_Obj_t *, vNodes, pObj, i, nLimit )
{
pSims0 = (unsigned *)pObj->pCopy;
if ( Kit_TruthIsEqualWithPhase(pSims, pSims0, nInputs) )
return 0;
- Vec_PtrForEachEntryStop( vNodes, pObj2, k, i )
+ Vec_PtrForEachEntryStop( If_Obj_t *, vNodes, pObj2, k, i )
{
if ( (If_ObjFanin0(pRoot) == pObj && If_ObjFanin1(pRoot) == pObj2) ||
(If_ObjFanin1(pRoot) == pObj && If_ObjFanin0(pRoot) == pObj2) )
@@ -861,7 +864,7 @@ s_pMan->timeCanon += clock() - clk;
// build the node and compute its truth table
nNodesBeg = Abc_NtkObjNumMax( pAig );
- Vec_PtrForEachEntryStart( vNodes, pIfObj, i, nLeaves )
+ Vec_PtrForEachEntryStart( If_Obj_t *, vNodes, pIfObj, i, nLeaves )
{
pFanin0 = Abc_ObjNotCond( If_ObjFanin0(pIfObj)->pCopy, If_ObjFaninC0(pIfObj) );
pFanin1 = Abc_ObjNotCond( If_ObjFanin1(pIfObj)->pCopy, If_ObjFaninC1(pIfObj) );
@@ -1163,3 +1166,5 @@ int Abc_NtkRecStrashNode( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pObj, unsigned * pTru
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcReconv.c b/src/base/abci/abcReconv.c
index 1c086fb0..434577ec 100644
--- a/src/base/abci/abcReconv.c
+++ b/src/base/abci/abcReconv.c
@@ -20,6 +20,9 @@
#include "abc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -62,7 +65,7 @@ static inline void Abc_NodesMark( Vec_Ptr_t * vVisited )
{
Abc_Obj_t * pNode;
int i;
- Vec_PtrForEachEntry( vVisited, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vVisited, pNode, i )
pNode->fMarkA = 1;
}
@@ -81,7 +84,7 @@ static inline void Abc_NodesUnmark( Vec_Ptr_t * vVisited )
{
Abc_Obj_t * pNode;
int i;
- Vec_PtrForEachEntry( vVisited, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vVisited, pNode, i )
pNode->fMarkA = 0;
}
@@ -100,7 +103,7 @@ static inline void Abc_NodesUnmarkB( Vec_Ptr_t * vVisited )
{
Abc_Obj_t * pNode;
int i;
- Vec_PtrForEachEntry( vVisited, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vVisited, pNode, i )
pNode->fMarkB = 0;
}
@@ -246,7 +249,7 @@ static inline int Abc_NodeGetLeafCostTwo( Abc_Obj_t * pNode, int nFaninLimit,
SeeAlso []
***********************************************************************/
-Vec_Ptr_t * Abc_NodeFindCut( Abc_ManCut_t * p, Abc_Obj_t * pRoot, bool fContain )
+Vec_Ptr_t * Abc_NodeFindCut( Abc_ManCut_t * p, Abc_Obj_t * pRoot, int fContain )
{
Abc_Obj_t * pNode;
int i;
@@ -285,7 +288,7 @@ Vec_Ptr_t * Abc_NodeFindCut( Abc_ManCut_t * p, Abc_Obj_t * pRoot, bool fContain
assert( p->nNodeSizeMax < p->nConeSizeMax );
// copy the current boundary
Vec_PtrClear( p->vConeLeaves );
- Vec_PtrForEachEntry( p->vNodeLeaves, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vNodeLeaves, pNode, i )
Vec_PtrPush( p->vConeLeaves, pNode );
// compute the containing cut
while ( Abc_NodeBuildCutLevelOne_int( p->vVisited, p->vConeLeaves, p->nConeSizeMax, p->nConeFanStop ) );
@@ -317,7 +320,7 @@ int Abc_NodeBuildCutLevelOne_int( Vec_Ptr_t * vVisited, Vec_Ptr_t * vLeaves, int
CostBest = 100;
pFaninBest = NULL;
//printf( "Evaluating fanins of the cut:\n" );
- Vec_PtrForEachEntry( vLeaves, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pNode, i )
{
CostCur = Abc_NodeGetLeafCostOne( pNode, nFaninLimit );
//printf( " Fanin %s has cost %d.\n", Abc_ObjName(pNode), CostCur );
@@ -387,7 +390,7 @@ int Abc_NodeBuildCutLevelTwo_int( Vec_Ptr_t * vVisited, Vec_Ptr_t * vLeaves, int
Abc_Obj_t * pNode = NULL, * pLeafToAdd, * pNodeToMark1, * pNodeToMark2;
int CostCur = 0, i;
// find the best fanin
- Vec_PtrForEachEntry( vLeaves, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pNode, i )
{
CostCur = Abc_NodeGetLeafCostTwo( pNode, nFaninLimit, &pLeafToAdd, &pNodeToMark1, &pNodeToMark2 );
if ( CostCur < 2 )
@@ -444,7 +447,7 @@ void Abc_NodeConeCollect( Abc_Obj_t ** ppRoots, int nRoots, Vec_Ptr_t * vLeaves,
Vec_PtrClear( vVisited );
// add the fanins
if ( fIncludeFanins )
- Vec_PtrForEachEntry( vLeaves, pTemp, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pTemp, i )
Vec_PtrPush( vVisited, pTemp );
// add other nodes
for ( i = 0; i < nRoots; i++ )
@@ -499,21 +502,21 @@ DdNode * Abc_NodeConeBdd( DdManager * dd, DdNode ** pbVars, Abc_Obj_t * pRoot, V
// get the nodes in the cut without fanins in the DFS order
Abc_NodeConeCollect( &pRoot, 1, vLeaves, vVisited, 0 );
// set the elementary BDDs
- Vec_PtrForEachEntry( vLeaves, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pNode, i )
pNode->pCopy = (Abc_Obj_t *)pbVars[i];
// compute the BDDs for the collected nodes
- Vec_PtrForEachEntry( vVisited, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vVisited, pNode, i )
{
assert( !Abc_ObjIsPi(pNode) );
- bFunc0 = Cudd_NotCond( Abc_ObjFanin0(pNode)->pCopy, Abc_ObjFaninC0(pNode) );
- bFunc1 = Cudd_NotCond( Abc_ObjFanin1(pNode)->pCopy, Abc_ObjFaninC1(pNode) );
+ bFunc0 = Cudd_NotCond( Abc_ObjFanin0(pNode)->pCopy, (int)Abc_ObjFaninC0(pNode) );
+ bFunc1 = Cudd_NotCond( Abc_ObjFanin1(pNode)->pCopy, (int)Abc_ObjFaninC1(pNode) );
bFunc = Cudd_bddAnd( dd, bFunc0, bFunc1 ); Cudd_Ref( bFunc );
pNode->pCopy = (Abc_Obj_t *)bFunc;
}
assert(bFunc);
Cudd_Ref( bFunc );
// dereference the intermediate ones
- Vec_PtrForEachEntry( vVisited, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vVisited, pNode, i )
Cudd_RecursiveDeref( dd, (DdNode *)pNode->pCopy );
Cudd_Deref( bFunc );
return bFunc;
@@ -538,19 +541,19 @@ DdNode * Abc_NodeConeDcs( DdManager * dd, DdNode ** pbVarsX, DdNode ** pbVarsY,
// get the nodes in the cut without fanins in the DFS order
Abc_NodeConeCollect( (Abc_Obj_t **)vRoots->pArray, vRoots->nSize, vLeaves, vVisited, 0 );
// set the elementary BDDs
- Vec_PtrForEachEntry( vLeaves, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pNode, i )
pNode->pCopy = (Abc_Obj_t *)pbVarsX[i];
// compute the BDDs for the collected nodes
- Vec_PtrForEachEntry( vVisited, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vVisited, pNode, i )
{
- bFunc0 = Cudd_NotCond( Abc_ObjFanin0(pNode)->pCopy, Abc_ObjFaninC0(pNode) );
- bFunc1 = Cudd_NotCond( Abc_ObjFanin1(pNode)->pCopy, Abc_ObjFaninC1(pNode) );
+ bFunc0 = Cudd_NotCond( Abc_ObjFanin0(pNode)->pCopy, (int)Abc_ObjFaninC0(pNode) );
+ bFunc1 = Cudd_NotCond( Abc_ObjFanin1(pNode)->pCopy, (int)Abc_ObjFaninC1(pNode) );
bFunc = Cudd_bddAnd( dd, bFunc0, bFunc1 ); Cudd_Ref( bFunc );
pNode->pCopy = (Abc_Obj_t *)bFunc;
}
// compute the transition relation of the cone
bTrans = b1; Cudd_Ref( bTrans );
- Vec_PtrForEachEntry( vRoots, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vRoots, pNode, i )
{
bFunc = Cudd_bddXnor( dd, (DdNode *)pNode->pCopy, pbVarsY[i] ); Cudd_Ref( bFunc );
bTrans = Cudd_bddAnd( dd, bTemp = bTrans, bFunc ); Cudd_Ref( bTrans );
@@ -558,7 +561,7 @@ DdNode * Abc_NodeConeDcs( DdManager * dd, DdNode ** pbVarsX, DdNode ** pbVarsY,
Cudd_RecursiveDeref( dd, bFunc );
}
// dereference the intermediate ones
- Vec_PtrForEachEntry( vVisited, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vVisited, pNode, i )
Cudd_RecursiveDeref( dd, (DdNode *)pNode->pCopy );
// compute don't-cares
bCube = Extra_bddComputeRangeCube( dd, vRoots->nSize, vRoots->nSize + vLeaves->nSize ); Cudd_Ref( bCube );
@@ -700,7 +703,7 @@ Vec_Ptr_t * Abc_NodeCollectTfoCands( Abc_ManCut_t * p, Abc_Obj_t * pRoot, Vec_Pt
// put fanins into the structure while labeling them
Abc_NtkIncrementTravId( pNtk );
LevelMin = -1;
- Vec_PtrForEachEntry( vLeaves, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pNode, i )
{
if ( pNode->Level > (unsigned)LevelMax )
continue;
@@ -717,7 +720,7 @@ Vec_Ptr_t * Abc_NodeCollectTfoCands( Abc_ManCut_t * p, Abc_Obj_t * pRoot, Vec_Pt
// go through the levels up
Vec_PtrClear( p->vNodesTfo );
- Vec_VecForEachEntryStart( p->vLevels, pNode, i, k, LevelMin )
+ Vec_VecForEachEntryStart( Abc_Obj_t *, p->vLevels, pNode, i, k, LevelMin )
{
if ( i > LevelMax )
break;
@@ -761,3 +764,5 @@ Vec_Ptr_t * Abc_NodeCollectTfoCands( Abc_ManCut_t * p, Abc_Obj_t * pRoot, Vec_Pt
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcRefactor.c b/src/base/abci/abcRefactor.c
index 5245bd23..4e922ebd 100644
--- a/src/base/abci/abcRefactor.c
+++ b/src/base/abci/abcRefactor.c
@@ -21,6 +21,9 @@
#include "abc.h"
#include "dec.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -58,9 +61,9 @@ struct Abc_ManRef_t_
};
static void Abc_NtkManRefPrintStats( Abc_ManRef_t * p );
-static Abc_ManRef_t * Abc_NtkManRefStart( int nNodeSizeMax, int nConeSizeMax, bool fUseDcs, bool fVerbose );
+static Abc_ManRef_t * Abc_NtkManRefStart( int nNodeSizeMax, int nConeSizeMax, int fUseDcs, int fVerbose );
static void Abc_NtkManRefStop( Abc_ManRef_t * p );
-static Dec_Graph_t * Abc_NodeRefactor( Abc_ManRef_t * p, Abc_Obj_t * pNode, Vec_Ptr_t * vFanins, bool fUpdateLevel, bool fUseZeros, bool fUseDcs, bool fVerbose );
+static Dec_Graph_t * Abc_NodeRefactor( Abc_ManRef_t * p, Abc_Obj_t * pNode, Vec_Ptr_t * vFanins, int fUpdateLevel, int fUseZeros, int fUseDcs, int fVerbose );
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
@@ -82,9 +85,9 @@ static Dec_Graph_t * Abc_NodeRefactor( Abc_ManRef_t * p, Abc_Obj_t * pNode, Vec
SeeAlso []
***********************************************************************/
-int Abc_NtkRefactor( Abc_Ntk_t * pNtk, int nNodeSizeMax, int nConeSizeMax, bool fUpdateLevel, bool fUseZeros, bool fUseDcs, bool fVerbose )
+int Abc_NtkRefactor( Abc_Ntk_t * pNtk, int nNodeSizeMax, int nConeSizeMax, int fUpdateLevel, int fUseZeros, int fUseDcs, int fVerbose )
{
- extern void Dec_GraphUpdateNetwork( Abc_Obj_t * pRoot, Dec_Graph_t * pGraph, bool fUpdateLevel, int nGain );
+ extern void Dec_GraphUpdateNetwork( Abc_Obj_t * pRoot, Dec_Graph_t * pGraph, int fUpdateLevel, int nGain );
ProgressBar * pProgress;
Abc_ManRef_t * pManRef;
Abc_ManCut_t * pManCut;
@@ -96,7 +99,7 @@ int Abc_NtkRefactor( Abc_Ntk_t * pNtk, int nNodeSizeMax, int nConeSizeMax, bool
assert( Abc_NtkIsStrash(pNtk) );
// cleanup the AIG
- Abc_AigCleanup(pNtk->pManFunc);
+ Abc_AigCleanup((Abc_Aig_t *)pNtk->pManFunc);
// start the managers
pManCut = Abc_NtkManCutStart( nNodeSizeMax, nConeSizeMax, 2, 1000 );
pManRef = Abc_NtkManRefStart( nNodeSizeMax, nConeSizeMax, fUseDcs, fVerbose );
@@ -182,7 +185,7 @@ pManRef->timeTotal = clock() - clkStart;
SeeAlso []
***********************************************************************/
-Dec_Graph_t * Abc_NodeRefactor( Abc_ManRef_t * p, Abc_Obj_t * pNode, Vec_Ptr_t * vFanins, bool fUpdateLevel, bool fUseZeros, bool fUseDcs, bool fVerbose )
+Dec_Graph_t * Abc_NodeRefactor( Abc_ManRef_t * p, Abc_Obj_t * pNode, Vec_Ptr_t * vFanins, int fUpdateLevel, int fUseZeros, int fUseDcs, int fVerbose )
{
extern int Dec_GraphToNetworkCount( Abc_Obj_t * pRoot, Dec_Graph_t * pGraph, int NodeMax, int LevelMax );
int fVeryVerbose = 0;
@@ -250,13 +253,13 @@ p->timeFact += clock() - clk;
// mark the fanin boundary
// (can mark only essential fanins, belonging to bNodeFunc!)
- Vec_PtrForEachEntry( vFanins, pFanin, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vFanins, pFanin, i )
pFanin->vFanouts.nSize++;
// label MFFC with current traversal ID
Abc_NtkIncrementTravId( pNode->pNtk );
nNodesSaved = Abc_NodeMffcLabelAig( pNode );
// unmark the fanin boundary and set the fanins as leaves in the form
- Vec_PtrForEachEntry( vFanins, pFanin, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vFanins, pFanin, i )
{
pFanin->vFanouts.nSize--;
Dec_GraphNode(pFForm, i)->pFunc = pFanin;
@@ -307,7 +310,7 @@ p->timeEval += clock() - clk;
SeeAlso []
***********************************************************************/
-Abc_ManRef_t * Abc_NtkManRefStart( int nNodeSizeMax, int nConeSizeMax, bool fUseDcs, bool fVerbose )
+Abc_ManRef_t * Abc_NtkManRefStart( int nNodeSizeMax, int nConeSizeMax, int fUseDcs, int fVerbose )
{
Abc_ManRef_t * p;
p = ABC_ALLOC( Abc_ManRef_t, 1 );
@@ -379,3 +382,5 @@ void Abc_NtkManRefPrintStats( Abc_ManRef_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcRenode.c b/src/base/abci/abcRenode.c
index f2861204..848021a0 100644
--- a/src/base/abci/abcRenode.c
+++ b/src/base/abci/abcRenode.c
@@ -23,6 +23,9 @@
#include "if.h"
#include "kit.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -310,3 +313,5 @@ int Abc_NtkRenodeEvalMv( If_Cut_t * pCut )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcReorder.c b/src/base/abci/abcReorder.c
index 340e3d17..d2e7dcea 100644
--- a/src/base/abci/abcReorder.c
+++ b/src/base/abci/abcReorder.c
@@ -21,6 +21,8 @@
#include "abc.h"
#include "reo.h"
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -50,8 +52,8 @@ void Abc_NodeBddReorder( reo_man * p, Abc_Obj_t * pNode )
for ( i = 0; i < Abc_ObjFaninNum(pNode); i++ )
pOrder[i] = -1;
// reorder the BDD
- bFunc = Extra_Reorder( p, pNode->pNtk->pManFunc, pNode->pData, pOrder ); Cudd_Ref( bFunc );
- Cudd_RecursiveDeref( pNode->pNtk->pManFunc, pNode->pData );
+ bFunc = Extra_Reorder( p, (DdManager *)pNode->pNtk->pManFunc, (DdNode *)pNode->pData, pOrder ); Cudd_Ref( bFunc );
+ Cudd_RecursiveDeref( (DdManager *)pNode->pNtk->pManFunc, (DdNode *)pNode->pData );
pNode->pData = bFunc;
// update the fanin order
Abc_ObjForEachFanin( pNode, pFanin, i )
@@ -87,10 +89,10 @@ void Abc_NtkBddReorder( Abc_Ntk_t * pNtk, int fVerbose )
if ( fVerbose )
fprintf( stdout, "%10s: ", Abc_ObjName(pNode) );
if ( fVerbose )
- fprintf( stdout, "Before = %5d BDD nodes. ", Cudd_DagSize(pNode->pData) );
+ fprintf( stdout, "Before = %5d BDD nodes. ", Cudd_DagSize((DdNode *)pNode->pData) );
Abc_NodeBddReorder( p, pNode );
if ( fVerbose )
- fprintf( stdout, "After = %5d BDD nodes.\n", Cudd_DagSize(pNode->pData) );
+ fprintf( stdout, "After = %5d BDD nodes.\n", Cudd_DagSize((DdNode *)pNode->pData) );
}
Extra_ReorderQuit( p );
}
@@ -100,3 +102,5 @@ void Abc_NtkBddReorder( Abc_Ntk_t * pNtk, int fVerbose )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcRestruct.c b/src/base/abci/abcRestruct.c
index 26774620..4a63db67 100644
--- a/src/base/abci/abcRestruct.c
+++ b/src/base/abci/abcRestruct.c
@@ -23,6 +23,9 @@
#include "dsd.h"
#include "cut.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -75,7 +78,7 @@ static Dec_Graph_t * Abc_NodeRestructureCut( Abc_ManRst_t * p, Abc_Obj_t * pNode
static Dec_Graph_t * Abc_NodeEvaluateDsd( Abc_ManRst_t * pManRst, Dsd_Node_t * pNodeDsd, Abc_Obj_t * pRoot, int Required, int nNodesSaved, int * pnNodesAdded );
static Cut_Man_t * Abc_NtkStartCutManForRestruct( Abc_Ntk_t * pNtk, int nCutMax, int fDag );
-static Abc_ManRst_t * Abc_NtkManRstStart( int nCutMax, bool fUpdateLevel, bool fUseZeros, bool fVerbose );
+static Abc_ManRst_t * Abc_NtkManRstStart( int nCutMax, int fUpdateLevel, int fUseZeros, int fVerbose );
static void Abc_NtkManRstStop( Abc_ManRst_t * p );
static void Abc_NtkManRstPrintStats( Abc_ManRst_t * p );
@@ -94,9 +97,9 @@ static void Abc_NtkManRstPrintStats( Abc_ManRst_t * p );
SeeAlso []
***********************************************************************/
-int Abc_NtkRestructure( Abc_Ntk_t * pNtk, int nCutMax, bool fUpdateLevel, bool fUseZeros, bool fVerbose )
+int Abc_NtkRestructure( Abc_Ntk_t * pNtk, int nCutMax, int fUpdateLevel, int fUseZeros, int fVerbose )
{
- extern void Dec_GraphUpdateNetwork( Abc_Obj_t * pRoot, Dec_Graph_t * pGraph, bool fUpdateLevel, int nGain );
+ extern void Dec_GraphUpdateNetwork( Abc_Obj_t * pRoot, Dec_Graph_t * pGraph, int fUpdateLevel, int nGain );
ProgressBar * pProgress;
Abc_ManRst_t * pManRst;
Cut_Man_t * pManCut;
@@ -110,7 +113,7 @@ int Abc_NtkRestructure( Abc_Ntk_t * pNtk, int nCutMax, bool fUpdateLevel, bool f
assert( Abc_NtkIsStrash(pNtk) );
// cleanup the AIG
- Abc_AigCleanup(pNtk->pManFunc);
+ Abc_AigCleanup((Abc_Aig_t *)pNtk->pManFunc);
Abc_NtkCleanCopy(pNtk);
// compute the reverse levels if level update is requested
@@ -149,7 +152,7 @@ pManRst->timeCut += clock() - clk;
break;
// get the cuts for the given node
clk = clock();
- pCutList = Abc_NodeGetCutsRecursive( pManCut, pNode, fMulti, 0 );
+ pCutList = (Cut_Cut_t *)Abc_NodeGetCutsRecursive( pManCut, pNode, fMulti, 0 );
pManRst->timeCut += clock() - clk;
// perform restructuring
@@ -211,14 +214,14 @@ void Abc_RestructNodeDivisors( Abc_ManRst_t * p, Abc_Obj_t * pRoot, int nNodesSa
int i, k;
// start with the leaves
Vec_PtrClear( p->vDecs );
- Vec_PtrForEachEntry( p->vLeaves, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vLeaves, pNode, i )
{
Vec_PtrPush( p->vDecs, pNode );
assert( pNode->fMarkC == 0 );
pNode->fMarkC = 1;
}
// explore the fanouts
- Vec_PtrForEachEntry( p->vDecs, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vDecs, pNode, i )
{
// if the fanout has both fanins in the set, add it
Abc_ObjForEachFanout( pNode, pFanout, k )
@@ -233,15 +236,15 @@ void Abc_RestructNodeDivisors( Abc_ManRst_t * p, Abc_Obj_t * pRoot, int nNodesSa
}
}
// unmark the nodes
- Vec_PtrForEachEntry( p->vDecs, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vDecs, pNode, i )
pNode->fMarkC = 0;
/*
// print the nodes
- Vec_PtrForEachEntryStart( p->vDecs, pNode, i, Vec_PtrSize(p->vLeaves) )
+ Vec_PtrForEachEntryStart( Abc_Obj_t *, p->vDecs, pNode, i, Vec_PtrSize(p->vLeaves) )
{
printf( "%2d %s = ", i, Abc_NodeIsTravIdCurrent(pNode)? "*" : " " );
// find the first fanin
- Vec_PtrForEachEntry( p->vDecs, pFanin, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vDecs, pFanin, k )
if ( Abc_ObjFanin0(pNode) == pFanin )
break;
if ( k < Vec_PtrSize(p->vLeaves) )
@@ -250,7 +253,7 @@ void Abc_RestructNodeDivisors( Abc_ManRst_t * p, Abc_Obj_t * pRoot, int nNodesSa
printf( "%d", k );
printf( "%s ", Abc_ObjFaninC0(pNode)? "\'" : "" );
// find the second fanin
- Vec_PtrForEachEntry( p->vDecs, pFanin, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vDecs, pFanin, k )
if ( Abc_ObjFanin1(pNode) == pFanin )
break;
if ( k < Vec_PtrSize(p->vLeaves) )
@@ -383,13 +386,13 @@ p->timeDsd += clock() - clk;
// mark the fanin boundary
// (can mark only essential fanins, belonging to bNodeFunc!)
- Vec_PtrForEachEntry( p->vLeaves, pLeaf, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vLeaves, pLeaf, i )
pLeaf->vFanouts.nSize++;
// label MFFC with current traversal ID
Abc_NtkIncrementTravId( pRoot->pNtk );
nNodesSaved = Abc_NodeMffcLabelAig( pRoot );
// unmark the fanin boundary and set the fanins as leaves in the form
- Vec_PtrForEachEntry( p->vLeaves, pLeaf, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vLeaves, pLeaf, i )
pLeaf->vFanouts.nSize--;
/*
if ( nNodesSaved < 3 )
@@ -488,8 +491,8 @@ void Abc_NodeEdgeDsdPermute( Dec_Graph_t * pGraph, Abc_ManRst_t * pManRst, Vec_I
// get the two last nodes
eNode1 = Dec_IntToEdge( Vec_IntEntry(vEdges, RightBound + 1) );
eNode2 = Dec_IntToEdge( Vec_IntEntry(vEdges, RightBound ) );
- pNode1 = Dec_GraphNode( pGraph, eNode1.Node )->pFunc;
- pNode2 = Dec_GraphNode( pGraph, eNode2.Node )->pFunc;
+ pNode1 = (Abc_Obj_t *)Dec_GraphNode( pGraph, eNode1.Node )->pFunc;
+ pNode2 = (Abc_Obj_t *)Dec_GraphNode( pGraph, eNode2.Node )->pFunc;
pNode1 = !pNode1? NULL : Abc_ObjNotCond( pNode1, eNode1.fCompl );
pNode2 = !pNode2? NULL : Abc_ObjNotCond( pNode2, eNode2.fCompl );
// quit if the last node does not exist
@@ -500,7 +503,7 @@ void Abc_NodeEdgeDsdPermute( Dec_Graph_t * pGraph, Abc_ManRst_t * pManRst, Vec_I
{
// get the third node
eNode3 = Dec_IntToEdge( Vec_IntEntry(vEdges, i) );
- pNode3 = Dec_GraphNode( pGraph, eNode3.Node )->pFunc;
+ pNode3 = (Abc_Obj_t *)Dec_GraphNode( pGraph, eNode3.Node )->pFunc;
pNode3 = !pNode3? NULL : Abc_ObjNotCond( pNode3, eNode3.fCompl );
if ( pNode3 == NULL )
continue;
@@ -509,7 +512,7 @@ void Abc_NodeEdgeDsdPermute( Dec_Graph_t * pGraph, Abc_ManRst_t * pManRst, Vec_I
{
if ( pNode1 && pNode3 )
{
- pTemp = Abc_AigXorLookup( pManRst->pNtk->pManFunc, pNode1, pNode3, NULL );
+ pTemp = Abc_AigXorLookup( (Abc_Aig_t *)pManRst->pNtk->pManFunc, pNode1, pNode3, NULL );
if ( !pTemp || Abc_NodeIsTravIdCurrent(Abc_ObjRegular(pTemp)) )
continue;
@@ -524,7 +527,7 @@ void Abc_NodeEdgeDsdPermute( Dec_Graph_t * pGraph, Abc_ManRst_t * pManRst, Vec_I
{
if ( pNode1 && pNode3 )
{
- pTemp = Abc_AigAndLookup( pManRst->pNtk->pManFunc, Abc_ObjNot(pNode1), Abc_ObjNot(pNode3) );
+ pTemp = Abc_AigAndLookup( (Abc_Aig_t *)pManRst->pNtk->pManFunc, Abc_ObjNot(pNode1), Abc_ObjNot(pNode3) );
if ( !pTemp || Abc_NodeIsTravIdCurrent(Abc_ObjRegular(pTemp)) )
continue;
@@ -634,15 +637,15 @@ Dec_Edge_t Abc_NodeEvaluateDsd_rec( Dec_Graph_t * pGraph, Abc_ManRst_t * pManRst
// get the two last nodes
eNode1 = Dec_IntToEdge( Vec_IntPop(vEdges) );
eNode2 = Dec_IntToEdge( Vec_IntPop(vEdges) );
- pNode1 = Dec_GraphNode( pGraph, eNode1.Node )->pFunc;
- pNode2 = Dec_GraphNode( pGraph, eNode2.Node )->pFunc;
+ pNode1 = (Abc_Obj_t *)Dec_GraphNode( pGraph, eNode1.Node )->pFunc;
+ pNode2 = (Abc_Obj_t *)Dec_GraphNode( pGraph, eNode2.Node )->pFunc;
pNode1 = !pNode1? NULL : Abc_ObjNotCond( pNode1, eNode1.fCompl );
pNode2 = !pNode2? NULL : Abc_ObjNotCond( pNode2, eNode2.fCompl );
// check if the new node exists
pNode3 = NULL;
if ( pNode1 && pNode2 )
{
- pNode3 = Abc_AigAndLookup( pManRst->pNtk->pManFunc, Abc_ObjNot(pNode1), Abc_ObjNot(pNode2) );
+ pNode3 = Abc_AigAndLookup( (Abc_Aig_t *)pManRst->pNtk->pManFunc, Abc_ObjNot(pNode1), Abc_ObjNot(pNode2) );
pNode3 = !pNode3? NULL : Abc_ObjNot(pNode3);
}
// create the new node
@@ -689,15 +692,15 @@ Dec_Edge_t Abc_NodeEvaluateDsd_rec( Dec_Graph_t * pGraph, Abc_ManRst_t * pManRst
// get the two last nodes
eNode1 = Dec_IntToEdge( Vec_IntPop(vEdges) );
eNode2 = Dec_IntToEdge( Vec_IntPop(vEdges) );
- pNode1 = Dec_GraphNode( pGraph, eNode1.Node )->pFunc;
- pNode2 = Dec_GraphNode( pGraph, eNode2.Node )->pFunc;
+ pNode1 = (Abc_Obj_t *)Dec_GraphNode( pGraph, eNode1.Node )->pFunc;
+ pNode2 = (Abc_Obj_t *)Dec_GraphNode( pGraph, eNode2.Node )->pFunc;
pNode1 = !pNode1? NULL : Abc_ObjNotCond( pNode1, eNode1.fCompl );
pNode2 = !pNode2? NULL : Abc_ObjNotCond( pNode2, eNode2.fCompl );
// check if the new node exists
Type = 0;
pNode3 = NULL;
if ( pNode1 && pNode2 )
- pNode3 = Abc_AigXorLookup( pManRst->pNtk->pManFunc, pNode1, pNode2, &Type );
+ pNode3 = Abc_AigXorLookup( (Abc_Aig_t *)pManRst->pNtk->pManFunc, pNode1, pNode2, &Type );
// create the new node
eNode3 = Dec_GraphAddNodeXor( pGraph, eNode1, eNode2, Type ); // should have the same structure as in AIG
// set level
@@ -718,19 +721,19 @@ Dec_Edge_t Abc_NodeEvaluateDsd_rec( Dec_Graph_t * pGraph, Abc_ManRst_t * pManRst
(*pnNodesAdded) += 2;
else if ( Type == 0 )
{
- pTemp = Abc_AigAndLookup( pManRst->pNtk->pManFunc, pNode1, Abc_ObjNot(pNode2) );
+ pTemp = Abc_AigAndLookup( (Abc_Aig_t *)pManRst->pNtk->pManFunc, pNode1, Abc_ObjNot(pNode2) );
if ( !pTemp || Abc_NodeIsTravIdCurrent(Abc_ObjRegular(pTemp)) )
(*pnNodesAdded)++;
- pTemp = Abc_AigAndLookup( pManRst->pNtk->pManFunc, Abc_ObjNot(pNode1), pNode2 );
+ pTemp = Abc_AigAndLookup( (Abc_Aig_t *)pManRst->pNtk->pManFunc, Abc_ObjNot(pNode1), pNode2 );
if ( !pTemp || Abc_NodeIsTravIdCurrent(Abc_ObjRegular(pTemp)) )
(*pnNodesAdded)++;
}
else
{
- pTemp = Abc_AigAndLookup( pManRst->pNtk->pManFunc, Abc_ObjNot(pNode1), Abc_ObjNot(pNode2) );
+ pTemp = Abc_AigAndLookup( (Abc_Aig_t *)pManRst->pNtk->pManFunc, Abc_ObjNot(pNode1), Abc_ObjNot(pNode2) );
if ( !pTemp || Abc_NodeIsTravIdCurrent(Abc_ObjRegular(pTemp)) )
(*pnNodesAdded)++;
- pTemp = Abc_AigAndLookup( pManRst->pNtk->pManFunc, pNode1, pNode2 );
+ pTemp = Abc_AigAndLookup( (Abc_Aig_t *)pManRst->pNtk->pManFunc, pNode1, pNode2 );
if ( !pTemp || Abc_NodeIsTravIdCurrent(Abc_ObjRegular(pTemp)) )
(*pnNodesAdded)++;
}
@@ -799,9 +802,9 @@ Dec_Edge_t Abc_NodeEvaluateDsd_rec( Dec_Graph_t * pGraph, Abc_ManRst_t * pManRst
Cudd_RecursiveDeref( pManRst->dd, bCofT );
// find the ABC nodes
- pNode1 = Dec_GraphNode( pGraph, eNode1.Node )->pFunc;
- pNode2 = Dec_GraphNode( pGraph, eNode2.Node )->pFunc;
- pNode3 = Dec_GraphNode( pGraph, eNode3.Node )->pFunc;
+ pNode1 = (Abc_Obj_t *)Dec_GraphNode( pGraph, eNode1.Node )->pFunc;
+ pNode2 = (Abc_Obj_t *)Dec_GraphNode( pGraph, eNode2.Node )->pFunc;
+ pNode3 = (Abc_Obj_t *)Dec_GraphNode( pGraph, eNode3.Node )->pFunc;
pNode1 = !pNode1? NULL : Abc_ObjNotCond( pNode1, eNode1.fCompl );
pNode2 = !pNode2? NULL : Abc_ObjNotCond( pNode2, eNode2.fCompl );
pNode3 = !pNode3? NULL : Abc_ObjNotCond( pNode3, eNode3.fCompl );
@@ -810,7 +813,7 @@ Dec_Edge_t Abc_NodeEvaluateDsd_rec( Dec_Graph_t * pGraph, Abc_ManRst_t * pManRst
Type = 0;
pNode4 = NULL;
if ( pNode1 && pNode2 && pNode3 )
- pNode4 = Abc_AigMuxLookup( pManRst->pNtk->pManFunc, pNode1, pNode2, pNode3, &Type );
+ pNode4 = Abc_AigMuxLookup( (Abc_Aig_t *)pManRst->pNtk->pManFunc, pNode1, pNode2, pNode3, &Type );
// create the new node
eResult = Dec_GraphAddNodeMux( pGraph, eNode1, eNode2, eNode3, Type ); // should have the same structure as AIG
@@ -836,7 +839,7 @@ Dec_Edge_t Abc_NodeEvaluateDsd_rec( Dec_Graph_t * pGraph, Abc_ManRst_t * pManRst
(*pnNodesAdded)++;
else
{
- pTemp = Abc_AigAndLookup( pManRst->pNtk->pManFunc, pNode1, pNode2 );
+ pTemp = Abc_AigAndLookup( (Abc_Aig_t *)pManRst->pNtk->pManFunc, pNode1, pNode2 );
if ( !pTemp || Abc_NodeIsTravIdCurrent(Abc_ObjRegular(pTemp)) )
(*pnNodesAdded)++;
}
@@ -844,7 +847,7 @@ Dec_Edge_t Abc_NodeEvaluateDsd_rec( Dec_Graph_t * pGraph, Abc_ManRst_t * pManRst
(*pnNodesAdded)++;
else
{
- pTemp = Abc_AigAndLookup( pManRst->pNtk->pManFunc, Abc_ObjNot(pNode1), pNode3 );
+ pTemp = Abc_AigAndLookup( (Abc_Aig_t *)pManRst->pNtk->pManFunc, Abc_ObjNot(pNode1), pNode3 );
if ( !pTemp || Abc_NodeIsTravIdCurrent(Abc_ObjRegular(pTemp)) )
(*pnNodesAdded)++;
}
@@ -855,7 +858,7 @@ Dec_Edge_t Abc_NodeEvaluateDsd_rec( Dec_Graph_t * pGraph, Abc_ManRst_t * pManRst
(*pnNodesAdded)++;
else
{
- pTemp = Abc_AigAndLookup( pManRst->pNtk->pManFunc, pNode1, Abc_ObjNot(pNode2) );
+ pTemp = Abc_AigAndLookup( (Abc_Aig_t *)pManRst->pNtk->pManFunc, pNode1, Abc_ObjNot(pNode2) );
if ( !pTemp || Abc_NodeIsTravIdCurrent(Abc_ObjRegular(pTemp)) )
(*pnNodesAdded)++;
}
@@ -863,7 +866,7 @@ Dec_Edge_t Abc_NodeEvaluateDsd_rec( Dec_Graph_t * pGraph, Abc_ManRst_t * pManRst
(*pnNodesAdded)++;
else
{
- pTemp = Abc_AigAndLookup( pManRst->pNtk->pManFunc, Abc_ObjNot(pNode1), Abc_ObjNot(pNode3) );
+ pTemp = Abc_AigAndLookup( (Abc_Aig_t *)pManRst->pNtk->pManFunc, Abc_ObjNot(pNode1), Abc_ObjNot(pNode3) );
if ( !pTemp || Abc_NodeIsTravIdCurrent(Abc_ObjRegular(pTemp)) )
(*pnNodesAdded)++;
}
@@ -907,7 +910,7 @@ Dec_Graph_t * Abc_NodeEvaluateDsd( Abc_ManRst_t * pManRst, Dsd_Node_t * pNodeDsd
pGraph = Dec_GraphCreate( Vec_PtrSize(pManRst->vLeaves) );
Dec_GraphForEachLeaf( pGraph, pNode, i )
{
- pLeaf = Vec_PtrEntry( pManRst->vLeaves, i );
+ pLeaf = (Abc_Obj_t *)Vec_PtrEntry( pManRst->vLeaves, i );
pNode->pFunc = pLeaf;
pNode->Level = pLeaf->Level;
}
@@ -923,7 +926,7 @@ Dec_Graph_t * Abc_NodeEvaluateDsd( Abc_ManRst_t * pManRst, Dsd_Node_t * pNodeDsd
}
// quit if the root node is the same
- pLeaf = Dec_GraphNode( pGraph, gEdge.Node )->pFunc;
+ pLeaf = (Abc_Obj_t *)Dec_GraphNode( pGraph, gEdge.Node )->pFunc;
if ( Abc_ObjRegular(pLeaf) == pRoot )
{
*pnNodesAdded = -1;
@@ -987,7 +990,7 @@ Cut_Man_t * Abc_NtkStartCutManForRestruct( Abc_Ntk_t * pNtk, int nCutMax, int fD
SeeAlso []
***********************************************************************/
-Abc_ManRst_t * Abc_NtkManRstStart( int nCutMax, bool fUpdateLevel, bool fUseZeros, bool fVerbose )
+Abc_ManRst_t * Abc_NtkManRstStart( int nCutMax, int fUpdateLevel, int fUseZeros, int fVerbose )
{
Abc_ManRst_t * p;
p = ABC_ALLOC( Abc_ManRst_t, 1 );
@@ -1104,7 +1107,7 @@ int Abc_Abc_NodeResubCollectDivs( Abc_ManRst_t * p, Abc_Obj_t * pRoot, Cut_Cut_t
Abc_NodeSetTravIdCurrent( pNode );
}
// explore the fanouts
- Vec_PtrForEachEntry( p->vDecs, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vDecs, pNode, i )
{
// if the fanout has both fanins in the set, add it
Abc_ObjForEachFanout( pNode, pFanout, k )
@@ -1159,7 +1162,7 @@ int Abc_NodeResubMffc( Abc_ManRst_t * p, Vec_Ptr_t * vDecs, int nLeaves, Abc_Obj
// increment the traversal ID for the leaves
Abc_NtkIncrementTravId( pRoot->pNtk );
// label the leaves
- Vec_PtrForEachEntryStop( vDecs, pObj, i, nLeaves )
+ Vec_PtrForEachEntryStop( Abc_Obj_t *, vDecs, pObj, i, nLeaves )
Abc_NodeSetTravIdCurrent( pObj );
// make sure the node is in the cone and is no one of the leaves
assert( Abc_NodeIsTravIdPrevious(pRoot) );
@@ -1167,13 +1170,13 @@ int Abc_NodeResubMffc( Abc_ManRst_t * p, Vec_Ptr_t * vDecs, int nLeaves, Abc_Obj
// move the labeled nodes to the end
Vec_PtrClear( p->vTemp );
k = 0;
- Vec_PtrForEachEntryStart( vDecs, pObj, i, nLeaves )
+ Vec_PtrForEachEntryStart( Abc_Obj_t *, vDecs, pObj, i, nLeaves )
if ( Abc_NodeIsTravIdCurrent(pObj) )
Vec_PtrPush( p->vTemp, pObj );
else
Vec_PtrWriteEntry( vDecs, k++, pObj );
// add the labeled nodes
- Vec_PtrForEachEntry( p->vTemp, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vTemp, pObj, i )
Vec_PtrWriteEntry( vDecs, k++, pObj );
assert( k == Vec_PtrSize(p->vDecs) );
assert( pRoot == Vec_PtrEntryLast(p->vDecs) );
@@ -1198,14 +1201,14 @@ void Abc_NodeMffcSimulate( Vec_Ptr_t * vDecs, int nLeaves, Vec_Int_t * vRands, V
int i;
// initialize random simulation data
Vec_IntClear( vSims );
- Vec_PtrForEachEntryStop( vDecs, pObj, i, nLeaves )
+ Vec_PtrForEachEntryStop( Abc_Obj_t *, vDecs, pObj, i, nLeaves )
{
uData = (unsigned)Vec_IntEntry( vRands, i );
pObj->pData = (void *)(ABC_PTRUINT_T)uData;
Vec_IntPush( vSims, uData );
}
// simulate
- Vec_PtrForEachEntryStart( vDecs, pObj, i, nLeaves )
+ Vec_PtrForEachEntryStart( Abc_Obj_t *, vDecs, pObj, i, nLeaves )
{
uData0 = (unsigned)(ABC_PTRUINT_T)Abc_ObjFanin0(pObj)->pData;
uData1 = (unsigned)(ABC_PTRUINT_T)Abc_ObjFanin1(pObj)->pData;
@@ -1491,3 +1494,5 @@ Dec_Graph_t * Abc_NodeResubstitute( Abc_ManRst_t * p, Abc_Obj_t * pNode, Cut_Cut
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcResub.c b/src/base/abci/abcResub.c
index 655f158e..a0a1af91 100644
--- a/src/base/abci/abcResub.c
+++ b/src/base/abci/abcResub.c
@@ -20,6 +20,9 @@
#include "abc.h"
#include "dec.h"
+
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -93,7 +96,7 @@ struct Abc_ManRes_t_
// external procedures
static Abc_ManRes_t* Abc_ManResubStart( int nLeavesMax, int nDivsMax );
static void Abc_ManResubStop( Abc_ManRes_t * p );
-static Dec_Graph_t * Abc_ManResubEval( Abc_ManRes_t * p, Abc_Obj_t * pRoot, Vec_Ptr_t * vLeaves, int nSteps, bool fUpdateLevel, int fVerbose );
+static Dec_Graph_t * Abc_ManResubEval( Abc_ManRes_t * p, Abc_Obj_t * pRoot, Vec_Ptr_t * vLeaves, int nSteps, int fUpdateLevel, int fVerbose );
static void Abc_ManResubCleanup( Abc_ManRes_t * p );
static void Abc_ManResubPrint( Abc_ManRes_t * p );
@@ -114,12 +117,6 @@ static Dec_Graph_t * Abc_ManResubDivs3( Abc_ManRes_t * p, int Required );
static Vec_Ptr_t * Abc_CutFactorLarge( Abc_Obj_t * pNode, int nLeavesMax );
static int Abc_CutVolumeCheck( Abc_Obj_t * pNode, Vec_Ptr_t * vLeaves );
-// don't-care manager
-extern void * Abc_NtkDontCareAlloc( int nVarsMax, int nLevels, int fVerbose, int fVeryVerbose );
-extern void Abc_NtkDontCareClear( void * p );
-extern void Abc_NtkDontCareFree( void * p );
-extern int Abc_NtkDontCareCompute( void * p, Abc_Obj_t * pNode, Vec_Ptr_t * vLeaves, unsigned * puTruth );
-
extern int s_ResubTime;
////////////////////////////////////////////////////////////////////////
@@ -137,13 +134,13 @@ extern int s_ResubTime;
SeeAlso []
***********************************************************************/
-int Abc_NtkResubstitute( Abc_Ntk_t * pNtk, int nCutMax, int nStepsMax, int nLevelsOdc, bool fUpdateLevel, bool fVerbose, bool fVeryVerbose )
+int Abc_NtkResubstitute( Abc_Ntk_t * pNtk, int nCutMax, int nStepsMax, int nLevelsOdc, int fUpdateLevel, int fVerbose, int fVeryVerbose )
{
- extern void Dec_GraphUpdateNetwork( Abc_Obj_t * pRoot, Dec_Graph_t * pGraph, bool fUpdateLevel, int nGain );
+ extern void Dec_GraphUpdateNetwork( Abc_Obj_t * pRoot, Dec_Graph_t * pGraph, int fUpdateLevel, int nGain );
ProgressBar * pProgress;
Abc_ManRes_t * pManRes;
Abc_ManCut_t * pManCut;
- void * pManOdc = NULL;
+ Odc_Man_t * pManOdc = NULL;
Dec_Graph_t * pFForm;
Vec_Ptr_t * vLeaves;
Abc_Obj_t * pNode;
@@ -153,7 +150,7 @@ int Abc_NtkResubstitute( Abc_Ntk_t * pNtk, int nCutMax, int nStepsMax, int nLeve
assert( Abc_NtkIsStrash(pNtk) );
// cleanup the AIG
- Abc_AigCleanup(pNtk->pManFunc);
+ Abc_AigCleanup((Abc_Aig_t *)pNtk->pManFunc);
// start the managers
pManCut = Abc_NtkManCutStart( nCutMax, 100000, 100000, 100000 );
pManRes = Abc_ManResubStart( nCutMax, ABC_RS_DIV1_MAX );
@@ -166,7 +163,7 @@ int Abc_NtkResubstitute( Abc_Ntk_t * pNtk, int nCutMax, int nStepsMax, int nLeve
if ( Abc_NtkLatchNum(pNtk) ) {
Abc_NtkForEachLatch(pNtk, pNode, i)
- pNode->pNext = pNode->pData;
+ pNode->pNext = (Abc_Obj_t *)pNode->pData;
}
// resynthesize each node once
@@ -312,7 +309,7 @@ Abc_ManRes_t * Abc_ManResubStart( int nLeavesMax, int nDivsMax )
// set elementary truth tables
for ( k = 0; k < p->nLeavesMax; k++ )
{
- pData = p->vSims->pArray[k];
+ pData = (unsigned *)p->vSims->pArray[k];
for ( i = 0; i < p->nBits; i++ )
if ( i & (1 << k) )
pData[i>>5] |= (1 << (i&31));
@@ -445,19 +442,19 @@ int Abc_ManResubCollectDivs( Abc_ManRes_t * p, Abc_Obj_t * pRoot, Vec_Ptr_t * vL
// add the leaves of the cuts to the divisors
Vec_PtrClear( p->vDivs );
Abc_NtkIncrementTravId( pRoot->pNtk );
- Vec_PtrForEachEntry( vLeaves, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pNode, i )
{
Vec_PtrPush( p->vDivs, pNode );
Abc_NodeSetTravIdCurrent( pNode );
}
// mark nodes in the MFFC
- Vec_PtrForEachEntry( p->vTemp, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vTemp, pNode, i )
pNode->fMarkA = 1;
// collect the cone (without MFFC)
Abc_ManResubCollectDivs_rec( pRoot, p->vDivs );
// unmark the current MFFC
- Vec_PtrForEachEntry( p->vTemp, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vTemp, pNode, i )
pNode->fMarkA = 0;
// check if the number of divisors is not exceeded
@@ -469,7 +466,7 @@ int Abc_ManResubCollectDivs( Abc_ManRes_t * p, Abc_Obj_t * pRoot, Vec_Ptr_t * vL
// explore the fanouts, which are not in the MFFC
Counter = 0;
- Vec_PtrForEachEntry( p->vDivs, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vDivs, pNode, i )
{
if ( Abc_ObjFanoutNum(pNode) > 100 )
{
@@ -499,7 +496,7 @@ Quits :
p->nDivs = Vec_PtrSize(p->vDivs);
// add the nodes in the MFFC
- Vec_PtrForEachEntry( p->vTemp, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vTemp, pNode, i )
Vec_PtrPush( p->vDivs, pNode );
assert( pRoot == Vec_PtrEntryLast(p->vDivs) );
@@ -523,7 +520,7 @@ void Abc_ManResubPrintDivs( Abc_ManRes_t * p, Abc_Obj_t * pRoot, Vec_Ptr_t * vLe
Abc_Obj_t * pFanin, * pNode;
int i, k;
// print the nodes
- Vec_PtrForEachEntry( p->vDivs, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vDivs, pNode, i )
{
if ( i < Vec_PtrSize(vLeaves) )
{
@@ -532,7 +529,7 @@ void Abc_ManResubPrintDivs( Abc_ManRes_t * p, Abc_Obj_t * pRoot, Vec_Ptr_t * vLe
}
printf( "%6d : %2d = ", pNode->Id, i );
// find the first fanin
- Vec_PtrForEachEntry( p->vDivs, pFanin, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vDivs, pFanin, k )
if ( Abc_ObjFanin0(pNode) == pFanin )
break;
if ( k < Vec_PtrSize(vLeaves) )
@@ -541,7 +538,7 @@ void Abc_ManResubPrintDivs( Abc_ManRes_t * p, Abc_Obj_t * pRoot, Vec_Ptr_t * vLe
printf( "%d", k );
printf( "%s ", Abc_ObjFaninC0(pNode)? "\'" : "" );
// find the second fanin
- Vec_PtrForEachEntry( p->vDivs, pFanin, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vDivs, pFanin, k )
if ( Abc_ObjFanin1(pNode) == pFanin )
break;
if ( k < Vec_PtrSize(vLeaves) )
@@ -575,7 +572,7 @@ void Abc_ManResubSimulate( Vec_Ptr_t * vDivs, int nLeaves, Vec_Ptr_t * vSims, in
int i, k;
assert( Vec_PtrSize(vDivs) - nLeaves <= Vec_PtrSize(vSims) - nLeavesMax );
// simulate
- Vec_PtrForEachEntry( vDivs, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vDivs, pObj, i )
{
if ( i < nLeaves )
{ // initialize the leaf
@@ -585,9 +582,9 @@ void Abc_ManResubSimulate( Vec_Ptr_t * vDivs, int nLeaves, Vec_Ptr_t * vSims, in
// set storage for the node's simulation info
pObj->pData = Vec_PtrEntry( vSims, i - nLeaves + nLeavesMax );
// get pointer to the simulation info
- puData = pObj->pData;
- puData0 = Abc_ObjFanin0(pObj)->pData;
- puData1 = Abc_ObjFanin1(pObj)->pData;
+ puData = (unsigned *)pObj->pData;
+ puData0 = (unsigned *)Abc_ObjFanin0(pObj)->pData;
+ puData1 = (unsigned *)Abc_ObjFanin1(pObj)->pData;
// simulate
if ( Abc_ObjFaninC0(pObj) && Abc_ObjFaninC1(pObj) )
for ( k = 0; k < nWords; k++ )
@@ -603,9 +600,9 @@ void Abc_ManResubSimulate( Vec_Ptr_t * vDivs, int nLeaves, Vec_Ptr_t * vSims, in
puData[k] = puData0[k] & puData1[k];
}
// normalize
- Vec_PtrForEachEntry( vDivs, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vDivs, pObj, i )
{
- puData = pObj->pData;
+ puData = (unsigned *)pObj->pData;
pObj->fPhase = (puData[0] & 1);
if ( pObj->fPhase )
for ( k = 0; k < nWords; k++ )
@@ -849,13 +846,13 @@ void Abc_ManResubDivsS( Abc_ManRes_t * p, int Required )
Vec_PtrClear( p->vDivs1UP );
Vec_PtrClear( p->vDivs1UN );
Vec_PtrClear( p->vDivs1B );
- puDataR = p->pRoot->pData;
- Vec_PtrForEachEntryStop( p->vDivs, pObj, i, p->nDivs )
+ puDataR = (unsigned *)p->pRoot->pData;
+ Vec_PtrForEachEntryStop( Abc_Obj_t *, p->vDivs, pObj, i, p->nDivs )
{
if ( (int)pObj->Level > Required - 1 )
continue;
- puData = pObj->pData;
+ puData = (unsigned *)pObj->pData;
// check positive containment
for ( w = 0; w < p->nWords; w++ )
// if ( puData[w] & ~puDataR[w] )
@@ -901,19 +898,19 @@ void Abc_ManResubDivsD( Abc_ManRes_t * p, int Required )
Vec_PtrClear( p->vDivs2UP1 );
Vec_PtrClear( p->vDivs2UN0 );
Vec_PtrClear( p->vDivs2UN1 );
- puDataR = p->pRoot->pData;
- Vec_PtrForEachEntry( p->vDivs1B, pObj0, i )
+ puDataR = (unsigned *)p->pRoot->pData;
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vDivs1B, pObj0, i )
{
if ( (int)pObj0->Level > Required - 2 )
continue;
- puData0 = pObj0->pData;
- Vec_PtrForEachEntryStart( p->vDivs1B, pObj1, k, i + 1 )
+ puData0 = (unsigned *)pObj0->pData;
+ Vec_PtrForEachEntryStart( Abc_Obj_t *, p->vDivs1B, pObj1, k, i + 1 )
{
if ( (int)pObj1->Level > Required - 2 )
continue;
- puData1 = pObj1->pData;
+ puData1 = (unsigned *)pObj1->pData;
if ( Vec_PtrSize(p->vDivs2UP0) < ABC_RS_DIV2_MAX )
{
@@ -1019,7 +1016,7 @@ Dec_Graph_t * Abc_ManResubQuit( Abc_ManRes_t * p )
Dec_Graph_t * pGraph;
unsigned * upData;
int w;
- upData = p->pRoot->pData;
+ upData = (unsigned *)p->pRoot->pData;
for ( w = 0; w < p->nWords; w++ )
// if ( upData[w] )
if ( upData[w] & p->pCareSet[w] ) // care set
@@ -1050,10 +1047,10 @@ Dec_Graph_t * Abc_ManResubDivs0( Abc_ManRes_t * p )
Abc_Obj_t * pObj;
unsigned * puData, * puDataR;
int i, w;
- puDataR = p->pRoot->pData;
- Vec_PtrForEachEntryStop( p->vDivs, pObj, i, p->nDivs )
+ puDataR = (unsigned *)p->pRoot->pData;
+ Vec_PtrForEachEntryStop( Abc_Obj_t *, p->vDivs, pObj, i, p->nDivs )
{
- puData = pObj->pData;
+ puData = (unsigned *)pObj->pData;
for ( w = 0; w < p->nWords; w++ )
// if ( puData[w] != puDataR[w] )
if ( (puData[w] ^ puDataR[w]) & p->pCareSet[w] ) // care set
@@ -1080,14 +1077,14 @@ Dec_Graph_t * Abc_ManResubDivs1( Abc_ManRes_t * p, int Required )
Abc_Obj_t * pObj0, * pObj1;
unsigned * puData0, * puData1, * puDataR;
int i, k, w;
- puDataR = p->pRoot->pData;
+ puDataR = (unsigned *)p->pRoot->pData;
// check positive unate divisors
- Vec_PtrForEachEntry( p->vDivs1UP, pObj0, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vDivs1UP, pObj0, i )
{
- puData0 = pObj0->pData;
- Vec_PtrForEachEntryStart( p->vDivs1UP, pObj1, k, i + 1 )
+ puData0 = (unsigned *)pObj0->pData;
+ Vec_PtrForEachEntryStart( Abc_Obj_t *, p->vDivs1UP, pObj1, k, i + 1 )
{
- puData1 = pObj1->pData;
+ puData1 = (unsigned *)pObj1->pData;
for ( w = 0; w < p->nWords; w++ )
// if ( (puData0[w] | puData1[w]) != puDataR[w] )
if ( ((puData0[w] | puData1[w]) ^ puDataR[w]) & p->pCareSet[w] ) // care set
@@ -1100,12 +1097,12 @@ Dec_Graph_t * Abc_ManResubDivs1( Abc_ManRes_t * p, int Required )
}
}
// check negative unate divisors
- Vec_PtrForEachEntry( p->vDivs1UN, pObj0, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vDivs1UN, pObj0, i )
{
- puData0 = pObj0->pData;
- Vec_PtrForEachEntryStart( p->vDivs1UN, pObj1, k, i + 1 )
+ puData0 = (unsigned *)pObj0->pData;
+ Vec_PtrForEachEntryStart( Abc_Obj_t *, p->vDivs1UN, pObj1, k, i + 1 )
{
- puData1 = pObj1->pData;
+ puData1 = (unsigned *)pObj1->pData;
for ( w = 0; w < p->nWords; w++ )
// if ( (puData0[w] & puData1[w]) != puDataR[w] )
if ( ((puData0[w] & puData1[w]) ^ puDataR[w]) & p->pCareSet[w] ) // care set
@@ -1136,17 +1133,17 @@ Dec_Graph_t * Abc_ManResubDivs12( Abc_ManRes_t * p, int Required )
Abc_Obj_t * pObj0, * pObj1, * pObj2, * pObjMax, * pObjMin0 = NULL, * pObjMin1 = NULL;
unsigned * puData0, * puData1, * puData2, * puDataR;
int i, k, j, w, LevelMax;
- puDataR = p->pRoot->pData;
+ puDataR = (unsigned *)p->pRoot->pData;
// check positive unate divisors
- Vec_PtrForEachEntry( p->vDivs1UP, pObj0, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vDivs1UP, pObj0, i )
{
- puData0 = pObj0->pData;
- Vec_PtrForEachEntryStart( p->vDivs1UP, pObj1, k, i + 1 )
+ puData0 = (unsigned *)pObj0->pData;
+ Vec_PtrForEachEntryStart( Abc_Obj_t *, p->vDivs1UP, pObj1, k, i + 1 )
{
- puData1 = pObj1->pData;
- Vec_PtrForEachEntryStart( p->vDivs1UP, pObj2, j, k + 1 )
+ puData1 = (unsigned *)pObj1->pData;
+ Vec_PtrForEachEntryStart( Abc_Obj_t *, p->vDivs1UP, pObj2, j, k + 1 )
{
- puData2 = pObj2->pData;
+ puData2 = (unsigned *)pObj2->pData;
for ( w = 0; w < p->nWords; w++ )
// if ( (puData0[w] | puData1[w] | puData2[w]) != puDataR[w] )
if ( ((puData0[w] | puData1[w] | puData2[w]) ^ puDataR[w]) & p->pCareSet[w] ) // care set
@@ -1179,15 +1176,15 @@ Dec_Graph_t * Abc_ManResubDivs12( Abc_ManRes_t * p, int Required )
}
}
// check negative unate divisors
- Vec_PtrForEachEntry( p->vDivs1UN, pObj0, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vDivs1UN, pObj0, i )
{
- puData0 = pObj0->pData;
- Vec_PtrForEachEntryStart( p->vDivs1UN, pObj1, k, i + 1 )
+ puData0 = (unsigned *)pObj0->pData;
+ Vec_PtrForEachEntryStart( Abc_Obj_t *, p->vDivs1UN, pObj1, k, i + 1 )
{
- puData1 = pObj1->pData;
- Vec_PtrForEachEntryStart( p->vDivs1UN, pObj2, j, k + 1 )
+ puData1 = (unsigned *)pObj1->pData;
+ Vec_PtrForEachEntryStart( Abc_Obj_t *, p->vDivs1UN, pObj2, j, k + 1 )
{
- puData2 = pObj2->pData;
+ puData2 = (unsigned *)pObj2->pData;
for ( w = 0; w < p->nWords; w++ )
// if ( (puData0[w] & puData1[w] & puData2[w]) != puDataR[w] )
if ( ((puData0[w] & puData1[w] & puData2[w]) ^ puDataR[w]) & p->pCareSet[w] ) // care set
@@ -1238,17 +1235,17 @@ Dec_Graph_t * Abc_ManResubDivs2( Abc_ManRes_t * p, int Required )
Abc_Obj_t * pObj0, * pObj1, * pObj2;
unsigned * puData0, * puData1, * puData2, * puDataR;
int i, k, w;
- puDataR = p->pRoot->pData;
+ puDataR = (unsigned *)p->pRoot->pData;
// check positive unate divisors
- Vec_PtrForEachEntry( p->vDivs1UP, pObj0, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vDivs1UP, pObj0, i )
{
- puData0 = pObj0->pData;
- Vec_PtrForEachEntry( p->vDivs2UP0, pObj1, k )
+ puData0 = (unsigned *)pObj0->pData;
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vDivs2UP0, pObj1, k )
{
- pObj2 = Vec_PtrEntry( p->vDivs2UP1, k );
+ pObj2 = (Abc_Obj_t *)Vec_PtrEntry( p->vDivs2UP1, k );
- puData1 = Abc_ObjRegular(pObj1)->pData;
- puData2 = Abc_ObjRegular(pObj2)->pData;
+ puData1 = (unsigned *)Abc_ObjRegular(pObj1)->pData;
+ puData2 = (unsigned *)Abc_ObjRegular(pObj2)->pData;
if ( Abc_ObjIsComplement(pObj1) && Abc_ObjIsComplement(pObj2) )
{
for ( w = 0; w < p->nWords; w++ )
@@ -1285,15 +1282,15 @@ Dec_Graph_t * Abc_ManResubDivs2( Abc_ManRes_t * p, int Required )
}
}
// check negative unate divisors
- Vec_PtrForEachEntry( p->vDivs1UN, pObj0, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vDivs1UN, pObj0, i )
{
- puData0 = pObj0->pData;
- Vec_PtrForEachEntry( p->vDivs2UN0, pObj1, k )
+ puData0 = (unsigned *)pObj0->pData;
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vDivs2UN0, pObj1, k )
{
- pObj2 = Vec_PtrEntry( p->vDivs2UN1, k );
+ pObj2 = (Abc_Obj_t *)Vec_PtrEntry( p->vDivs2UN1, k );
- puData1 = Abc_ObjRegular(pObj1)->pData;
- puData2 = Abc_ObjRegular(pObj2)->pData;
+ puData1 = (unsigned *)Abc_ObjRegular(pObj1)->pData;
+ puData2 = (unsigned *)Abc_ObjRegular(pObj2)->pData;
if ( Abc_ObjIsComplement(pObj1) && Abc_ObjIsComplement(pObj2) )
{
for ( w = 0; w < p->nWords; w++ )
@@ -1348,22 +1345,22 @@ Dec_Graph_t * Abc_ManResubDivs3( Abc_ManRes_t * p, int Required )
Abc_Obj_t * pObj0, * pObj1, * pObj2, * pObj3;
unsigned * puData0, * puData1, * puData2, * puData3, * puDataR;
int i, k, w = 0, Flag;
- puDataR = p->pRoot->pData;
+ puDataR = (unsigned *)p->pRoot->pData;
// check positive unate divisors
- Vec_PtrForEachEntry( p->vDivs2UP0, pObj0, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vDivs2UP0, pObj0, i )
{
- pObj1 = Vec_PtrEntry( p->vDivs2UP1, i );
- puData0 = Abc_ObjRegular(pObj0)->pData;
- puData1 = Abc_ObjRegular(pObj1)->pData;
+ pObj1 = (Abc_Obj_t *)Vec_PtrEntry( p->vDivs2UP1, i );
+ puData0 = (unsigned *)Abc_ObjRegular(pObj0)->pData;
+ puData1 = (unsigned *)Abc_ObjRegular(pObj1)->pData;
Flag = (Abc_ObjIsComplement(pObj0) << 3) | (Abc_ObjIsComplement(pObj1) << 2);
- Vec_PtrForEachEntryStart( p->vDivs2UP0, pObj2, k, i + 1 )
+ Vec_PtrForEachEntryStart( Abc_Obj_t *, p->vDivs2UP0, pObj2, k, i + 1 )
{
- pObj3 = Vec_PtrEntry( p->vDivs2UP1, k );
- puData2 = Abc_ObjRegular(pObj2)->pData;
- puData3 = Abc_ObjRegular(pObj3)->pData;
+ pObj3 = (Abc_Obj_t *)Vec_PtrEntry( p->vDivs2UP1, k );
+ puData2 = (unsigned *)Abc_ObjRegular(pObj2)->pData;
+ puData3 = (unsigned *)Abc_ObjRegular(pObj3)->pData;
- Flag = (Flag & 12) | (Abc_ObjIsComplement(pObj2) << 1) | Abc_ObjIsComplement(pObj3);
+ Flag = (Flag & 12) | ((int)Abc_ObjIsComplement(pObj2) << 1) | (int)Abc_ObjIsComplement(pObj3);
assert( Flag < 16 );
switch( Flag )
{
@@ -1477,14 +1474,14 @@ Dec_Graph_t * Abc_ManResubDivs3( Abc_ManRes_t * p, int Required )
}
/*
// check negative unate divisors
- Vec_PtrForEachEntry( p->vDivs2UN0, pObj0, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vDivs2UN0, pObj0, i )
{
pObj1 = Vec_PtrEntry( p->vDivs2UN1, i );
puData0 = Abc_ObjRegular(pObj0)->pData;
puData1 = Abc_ObjRegular(pObj1)->pData;
Flag = (Abc_ObjIsComplement(pObj0) << 3) | (Abc_ObjIsComplement(pObj1) << 2);
- Vec_PtrForEachEntryStart( p->vDivs2UN0, pObj2, k, i + 1 )
+ Vec_PtrForEachEntryStart( Abc_Obj_t *, p->vDivs2UN0, pObj2, k, i + 1 )
{
pObj3 = Vec_PtrEntry( p->vDivs2UN1, k );
puData2 = Abc_ObjRegular(pObj2)->pData;
@@ -1605,7 +1602,7 @@ void Abc_ManResubCleanup( Abc_ManRes_t * p )
{
Abc_Obj_t * pObj;
int i;
- Vec_PtrForEachEntry( p->vDivs, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vDivs, pObj, i )
pObj->pData = NULL;
Vec_PtrClear( p->vDivs );
p->pRoot = NULL;
@@ -1622,7 +1619,7 @@ void Abc_ManResubCleanup( Abc_ManRes_t * p )
SeeAlso []
***********************************************************************/
-Dec_Graph_t * Abc_ManResubEval( Abc_ManRes_t * p, Abc_Obj_t * pRoot, Vec_Ptr_t * vLeaves, int nSteps, bool fUpdateLevel, bool fVerbose )
+Dec_Graph_t * Abc_ManResubEval( Abc_ManRes_t * p, Abc_Obj_t * pRoot, Vec_Ptr_t * vLeaves, int nSteps, int fUpdateLevel, int fVerbose )
{
extern int Abc_NodeMffcInside( Abc_Obj_t * pNode, Vec_Ptr_t * vLeaves, Vec_Ptr_t * vInside );
Dec_Graph_t * pGraph;
@@ -1780,7 +1777,7 @@ int Abc_CutVolumeCheck( Abc_Obj_t * pNode, Vec_Ptr_t * vLeaves )
int i;
// mark the leaves
Abc_NtkIncrementTravId( pNode->pNtk );
- Vec_PtrForEachEntry( vLeaves, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pObj, i )
Abc_NodeSetTravIdCurrent( pObj );
// traverse the nodes starting from the given one and count them
return Abc_CutVolumeCheck_rec( pNode );
@@ -1833,7 +1830,7 @@ Vec_Ptr_t * Abc_CutFactor( Abc_Obj_t * pNode )
vLeaves = Vec_PtrAlloc( 10 );
Abc_CutFactor_rec( Abc_ObjFanin0(pNode), vLeaves );
Abc_CutFactor_rec( Abc_ObjFanin1(pNode), vLeaves );
- Vec_PtrForEachEntry( vLeaves, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pObj, i )
pObj->fMarkA = 0;
return vLeaves;
}
@@ -1874,7 +1871,7 @@ Vec_Ptr_t * Abc_CutFactorLarge( Abc_Obj_t * pNode, int nLeavesMax )
// initialize the factor cuts for the leaves
vFactors = Vec_PtrAlloc( nLeavesMax );
Abc_NtkIncrementTravId( pNode->pNtk );
- Vec_PtrForEachEntry( vLeaves, pLeaf, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pLeaf, i )
{
Abc_NodeSetTravIdCurrent( pLeaf );
if ( Abc_ObjIsCi(pLeaf) )
@@ -1889,13 +1886,13 @@ Vec_Ptr_t * Abc_CutFactorLarge( Abc_Obj_t * pNode, int nLeavesMax )
BestCut = -1, BestShare = -1;
// find the next feasible cut to add
Vec_IntClear( vFeasible );
- Vec_PtrForEachEntry( vFactors, vFact, i )
+ Vec_PtrForEachEntry( Vec_Ptr_t *, vFactors, vFact, i )
{
if ( vFact == NULL )
continue;
// count the number of unmarked leaves of this factor cut
Counter = 0;
- Vec_PtrForEachEntry( vFact, pTemp, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vFact, pTemp, k )
Counter += !Abc_NodeIsTravIdCurrent(pTemp);
// if the number of new leaves is smaller than the diff, it is feasible
if ( Counter <= nLeavesMax - Vec_PtrSize(vLeaves) + 1 )
@@ -1913,8 +1910,8 @@ Vec_Ptr_t * Abc_CutFactorLarge( Abc_Obj_t * pNode, int nLeavesMax )
// choose the cut that has most sharing with the other cuts
RandLeaf = BestCut;
- pLeaf = Vec_PtrEntry( vLeaves, RandLeaf );
- vNext = Vec_PtrEntry( vFactors, RandLeaf );
+ pLeaf = (Abc_Obj_t *)Vec_PtrEntry( vLeaves, RandLeaf );
+ vNext = (Vec_Ptr_t *)Vec_PtrEntry( vFactors, RandLeaf );
// unmark this leaf
Abc_NodeSetTravIdPrevious( pLeaf );
// remove this cut from the leaves and factor cuts
@@ -1926,7 +1923,7 @@ Vec_Ptr_t * Abc_CutFactorLarge( Abc_Obj_t * pNode, int nLeavesMax )
Vec_PtrShrink( vLeaves, Vec_PtrSize(vLeaves) -1 );
Vec_PtrShrink( vFactors, Vec_PtrSize(vFactors)-1 );
// add new leaves, compute their factor cuts
- Vec_PtrForEachEntry( vNext, pLeaf, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNext, pLeaf, i )
{
if ( Abc_NodeIsTravIdCurrent(pLeaf) )
continue;
@@ -1944,7 +1941,7 @@ Vec_Ptr_t * Abc_CutFactorLarge( Abc_Obj_t * pNode, int nLeavesMax )
}
// remove temporary storage
- Vec_PtrForEachEntry( vFactors, vFact, i )
+ Vec_PtrForEachEntry( Vec_Ptr_t *, vFactors, vFact, i )
if ( vFact ) Vec_PtrFree( vFact );
Vec_PtrFree( vFactors );
Vec_IntFree( vFeasible );
@@ -1956,3 +1953,5 @@ Vec_Ptr_t * Abc_CutFactorLarge( Abc_Obj_t * pNode, int nLeavesMax )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcRewrite.c b/src/base/abci/abcRewrite.c
index a119ccd2..f36600fa 100644
--- a/src/base/abci/abcRewrite.c
+++ b/src/base/abci/abcRewrite.c
@@ -22,6 +22,9 @@
#include "rwr.h"
#include "dec.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*
The ideas realized in this package are inspired by the paper:
Per Bjesse, Arne Boralv, "DAG-aware circuit compression for
@@ -57,7 +60,7 @@ extern void Abc_PlaceUpdate( Vec_Ptr_t * vAddedCells, Vec_Ptr_t * vUpdatedNets
***********************************************************************/
int Abc_NtkRewrite( Abc_Ntk_t * pNtk, int fUpdateLevel, int fUseZeros, int fVerbose, int fVeryVerbose, int fPlaceEnable )
{
- extern void Dec_GraphUpdateNetwork( Abc_Obj_t * pRoot, Dec_Graph_t * pGraph, bool fUpdateLevel, int nGain );
+ extern void Dec_GraphUpdateNetwork( Abc_Obj_t * pRoot, Dec_Graph_t * pGraph, int fUpdateLevel, int nGain );
ProgressBar * pProgress;
Cut_Man_t * pManCut;
Rwr_Man_t * pManRwr;
@@ -69,7 +72,7 @@ int Abc_NtkRewrite( Abc_Ntk_t * pNtk, int fUpdateLevel, int fUseZeros, int fVerb
assert( Abc_NtkIsStrash(pNtk) );
// cleanup the AIG
- Abc_AigCleanup(pNtk->pManFunc);
+ Abc_AigCleanup((Abc_Aig_t *)pNtk->pManFunc);
/*
{
Vec_Vec_t * vParts;
@@ -125,12 +128,12 @@ Rwr_ManAddTimeCuts( pManRwr, clock() - clk );
// if we end up here, a rewriting step is accepted
// get hold of the new subgraph to be added to the AIG
- pGraph = Rwr_ManReadDecs(pManRwr);
+ pGraph = (Dec_Graph_t *)Rwr_ManReadDecs(pManRwr);
fCompl = Rwr_ManReadCompl(pManRwr);
// reset the array of the changed nodes
if ( fPlaceEnable )
- Abc_AigUpdateReset( pNtk->pManFunc );
+ Abc_AigUpdateReset( (Abc_Aig_t *)pNtk->pManFunc );
// complement the FF if needed
if ( fCompl ) Dec_GraphComplement( pGraph );
@@ -242,7 +245,7 @@ void Abc_NodePrintCuts( Abc_Obj_t * pNode )
printf( "\nNode %s\n", Abc_ObjName(pNode) );
vCuts = (Vec_Ptr_t *)pNode->pCopy;
- Vec_PtrForEachEntry( vCuts, pCut, k )
+ Vec_PtrForEachEntry( Cut_Cut_t *, vCuts, pCut, k )
{
Extra_PrintBinary( stdout, (unsigned *)&pCut->uSign, 16 );
printf( " " );
@@ -267,9 +270,9 @@ void Abc_ManRewritePrintDivs( Vec_Ptr_t * vDivs, int nLeaves )
{
Abc_Obj_t * pFanin, * pNode, * pRoot;
int i, k;
- pRoot = Vec_PtrEntryLast(vDivs);
+ pRoot = (Abc_Obj_t *)Vec_PtrEntryLast(vDivs);
// print the nodes
- Vec_PtrForEachEntry( vDivs, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vDivs, pNode, i )
{
if ( i < nLeaves )
{
@@ -278,7 +281,7 @@ void Abc_ManRewritePrintDivs( Vec_Ptr_t * vDivs, int nLeaves )
}
printf( "%6d : %2d = ", pNode->Id, i );
// find the first fanin
- Vec_PtrForEachEntry( vDivs, pFanin, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vDivs, pFanin, k )
if ( Abc_ObjFanin0(pNode) == pFanin )
break;
if ( k < nLeaves )
@@ -287,7 +290,7 @@ void Abc_ManRewritePrintDivs( Vec_Ptr_t * vDivs, int nLeaves )
printf( "%d", k );
printf( "%s ", Abc_ObjFaninC0(pNode)? "\'" : "" );
// find the second fanin
- Vec_PtrForEachEntry( vDivs, pFanin, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vDivs, pFanin, k )
if ( Abc_ObjFanin1(pNode) == pFanin )
break;
if ( k < nLeaves )
@@ -342,7 +345,7 @@ void Abc_ManShowCutCone( Abc_Obj_t * pNode, Vec_Ptr_t * vLeaves )
int i;
vDivs = Vec_PtrAlloc( 100 );
Abc_NtkIncrementTravId( pNtk );
- Vec_PtrForEachEntry( vLeaves, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pObj, i )
{
Abc_NodeSetTravIdCurrent( Abc_ObjRegular(pObj) );
Vec_PtrPush( vDivs, Abc_ObjRegular(pObj) );
@@ -397,7 +400,7 @@ void Abc_RwrExpWithCut( Abc_Obj_t * pNode, Vec_Ptr_t * vLeaves )
Abc_RwrExpWithCut_rec( Abc_ObjFanin0(pNode), vLeaves, 1 );
Abc_RwrExpWithCut_rec( Abc_ObjFanin1(pNode), vLeaves, 0 );
CountA = CountB = 0;
- Vec_PtrForEachEntry( vLeaves, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pObj, i )
{
CountA += Abc_ObjRegular(pObj)->fMarkA;
CountB += Abc_ObjRegular(pObj)->fMarkB;
@@ -413,3 +416,5 @@ void Abc_RwrExpWithCut( Abc_Obj_t * pNode, Vec_Ptr_t * vLeaves )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcRr.c b/src/base/abci/abcRr.c
index 9fbad080..12e94478 100644
--- a/src/base/abci/abcRr.c
+++ b/src/base/abci/abcRr.c
@@ -22,6 +22,9 @@
#include "fraig.h"
#include "sim.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -99,7 +102,7 @@ int Abc_NtkRR( Abc_Ntk_t * pNtk, int nFaninLevels, int nFanoutLevels, int fUseFa
Abc_Obj_t * pNode, * pFanin, * pFanout;
int i, k, m, nNodes, RetValue, clk, clkTotal = clock();
// start the manager
- p = Abc_RRManStart( nFaninLevels, nFanoutLevels );
+ p = Abc_RRManStart();
p->pNtk = pNtk;
p->nFaninLevels = nFaninLevels;
p->nFanoutLevels = nFanoutLevels;
@@ -393,17 +396,17 @@ int Abc_NtkRRUpdate( Abc_Ntk_t * pNtk, Abc_Obj_t * pNode, Abc_Obj_t * pFanin, Ab
// replace
if ( pFanout == NULL )
{
- Abc_AigReplace( pNtk->pManFunc, pNode, pNodeNew, 1 );
+ Abc_AigReplace( (Abc_Aig_t *)pNtk->pManFunc, pNode, pNodeNew, 1 );
return 1;
}
// find the fanout after redundancy removal
if ( pNode == Abc_ObjFanin0(pFanout) )
- pFanoutNew = Abc_AigAnd( pNtk->pManFunc, Abc_ObjNotCond(pNodeNew,Abc_ObjFaninC0(pFanout)), Abc_ObjChild1(pFanout) );
+ pFanoutNew = Abc_AigAnd( (Abc_Aig_t *)pNtk->pManFunc, Abc_ObjNotCond(pNodeNew,Abc_ObjFaninC0(pFanout)), Abc_ObjChild1(pFanout) );
else if ( pNode == Abc_ObjFanin1(pFanout) )
- pFanoutNew = Abc_AigAnd( pNtk->pManFunc, Abc_ObjNotCond(pNodeNew,Abc_ObjFaninC1(pFanout)), Abc_ObjChild0(pFanout) );
+ pFanoutNew = Abc_AigAnd( (Abc_Aig_t *)pNtk->pManFunc, Abc_ObjNotCond(pNodeNew,Abc_ObjFaninC1(pFanout)), Abc_ObjChild0(pFanout) );
else assert( 0 );
// replace
- Abc_AigReplace( pNtk->pManFunc, pFanout, pFanoutNew, 1 );
+ Abc_AigReplace( (Abc_Aig_t *)pNtk->pManFunc, pFanout, pFanoutNew, 1 );
return 1;
}
@@ -442,7 +445,7 @@ int Abc_NtkRRWindow( Abc_RRMan_t * p )
// mark the leaves with the new TravId
Abc_NtkIncrementTravId( p->pNtk );
- Vec_PtrForEachEntry( p->vFaninLeaves, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vFaninLeaves, pObj, i )
Abc_NodeSetTravIdCurrent( pObj );
// traverse the TFO cone of the leaves (while skipping the edge)
// (a) mark the nodes in the cone using the current TravId
@@ -450,12 +453,12 @@ int Abc_NtkRRWindow( Abc_RRMan_t * p )
while ( Abc_NtkRRTfo_int(p->vFaninLeaves, p->vFanoutRoots, LevelMax, pEdgeFanin, pEdgeFanout) );
// mark the fanout roots
- Vec_PtrForEachEntry( p->vFanoutRoots, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vFanoutRoots, pObj, i )
pObj->fMarkA = 1;
// collect roots reachable from the fanout (p->vRoots)
RetValue = Abc_NtkRRTfo_rec( pEdgeFanout, p->vRoots, LevelMax + 1 );
// unmark the fanout roots
- Vec_PtrForEachEntry( p->vFanoutRoots, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vFanoutRoots, pObj, i )
pObj->fMarkA = 0;
// return if the window is infeasible
@@ -465,7 +468,7 @@ int Abc_NtkRRWindow( Abc_RRMan_t * p )
// collect the DFS-ordered new cone (p->vCone) and new leaves (p->vLeaves)
// using the previous marks coming from the TFO cone
Abc_NtkIncrementTravId( p->pNtk );
- Vec_PtrForEachEntry( p->vRoots, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vRoots, pObj, i )
Abc_NtkRRTfi_rec( pObj, p->vLeaves, p->vCone, LevelMin );
// create a new network
@@ -491,7 +494,7 @@ int Abc_NtkRRTfi_int( Vec_Ptr_t * vLeaves, int LevelLimit )
assert( LevelLimit >= 0 );
// find the maximum level of leaves
LevelMax = 0;
- Vec_PtrForEachEntry( vLeaves, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pObj, i )
if ( LevelMax < (int)pObj->Level )
LevelMax = pObj->Level;
// if the nodes are all PIs, LevelMax == 0
@@ -499,7 +502,7 @@ int Abc_NtkRRTfi_int( Vec_Ptr_t * vLeaves, int LevelLimit )
return 0;
// expand the nodes with the minimum level
nSize = Vec_PtrSize(vLeaves);
- Vec_PtrForEachEntryStop( vLeaves, pObj, i, nSize )
+ Vec_PtrForEachEntryStop( Abc_Obj_t *, vLeaves, pObj, i, nSize )
{
if ( LevelMax != (int)pObj->Level )
continue;
@@ -513,7 +516,7 @@ int Abc_NtkRRTfi_int( Vec_Ptr_t * vLeaves, int LevelLimit )
}
// remove old nodes (cannot remove a PI)
k = 0;
- Vec_PtrForEachEntry( vLeaves, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pObj, i )
{
if ( LevelMax == (int)pObj->Level )
continue;
@@ -542,7 +545,7 @@ int Abc_NtkRRTfo_int( Vec_Ptr_t * vLeaves, Vec_Ptr_t * vRoots, int LevelLimit, A
int i, k, LevelMin, nSize, fObjIsRoot;
// find the minimum level of leaves
LevelMin = ABC_INFINITY;
- Vec_PtrForEachEntry( vLeaves, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pObj, i )
if ( LevelMin > (int)pObj->Level )
LevelMin = pObj->Level;
// if the minimum level exceed the limit, we are done
@@ -550,7 +553,7 @@ int Abc_NtkRRTfo_int( Vec_Ptr_t * vLeaves, Vec_Ptr_t * vRoots, int LevelLimit, A
return 0;
// expand the nodes with the minimum level
nSize = Vec_PtrSize(vLeaves);
- Vec_PtrForEachEntryStop( vLeaves, pObj, i, nSize )
+ Vec_PtrForEachEntryStop( Abc_Obj_t *, vLeaves, pObj, i, nSize )
{
if ( LevelMin != (int)pObj->Level )
continue;
@@ -577,7 +580,7 @@ int Abc_NtkRRTfo_int( Vec_Ptr_t * vLeaves, Vec_Ptr_t * vRoots, int LevelLimit, A
}
// remove old nodes
k = 0;
- Vec_PtrForEachEntry( vLeaves, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pObj, i )
{
if ( LevelMin == (int)pObj->Level )
continue;
@@ -682,17 +685,17 @@ Abc_Ntk_t * Abc_NtkWindow( Abc_Ntk_t * pNtk, Vec_Ptr_t * vLeaves, Vec_Ptr_t * vC
// map the constant nodes
Abc_AigConst1(pNtk)->pCopy = Abc_AigConst1(pNtkNew);
// create and map the PIs
- Vec_PtrForEachEntry( vLeaves, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pObj, i )
pObj->pCopy = Abc_NtkCreatePi(pNtkNew);
// copy the AND gates
- Vec_PtrForEachEntry( vCone, pObj, i )
- pObj->pCopy = Abc_AigAnd( pNtkNew->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
+ Vec_PtrForEachEntry( Abc_Obj_t *, vCone, pObj, i )
+ pObj->pCopy = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
// compare the number of nodes before and after
if ( Vec_PtrSize(vCone) != Abc_NtkNodeNum(pNtkNew) )
printf( "Warning: Structural hashing during windowing reduced %d nodes (this is a bug).\n",
Vec_PtrSize(vCone) - Abc_NtkNodeNum(pNtkNew) );
// create the POs
- Vec_PtrForEachEntry( vRoots, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vRoots, pObj, i )
{
assert( !Abc_ObjIsComplement(pObj->pCopy) );
Abc_ObjAddFanin( Abc_NtkCreatePo(pNtkNew), pObj->pCopy );
@@ -700,7 +703,6 @@ Abc_Ntk_t * Abc_NtkWindow( Abc_Ntk_t * pNtk, Vec_Ptr_t * vLeaves, Vec_Ptr_t * vC
// add the PI/PO names
Abc_NtkAddDummyPiNames( pNtkNew );
Abc_NtkAddDummyPoNames( pNtkNew );
- Abc_NtkAddDummyAssertNames( pNtkNew );
// check
if ( fCheck && !Abc_NtkCheck( pNtkNew ) )
{
@@ -928,19 +930,19 @@ void Sim_SimulateCollected( Vec_Str_t * vTargets, Vec_Ptr_t * vNodes, Vec_Ptr_t
// get simulation info
vSims = Sim_UtilInfoAlloc( Vec_PtrSize(vField), Vec_PtrSize(vNodes), 0 );
// simulate the nodes
- Vec_PtrForEachEntry( vField, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vField, pObj, i )
{
if ( Abc_ObjIsCi(pObj) )
{
- pUnsigned = Vec_PtrEntry( vSims, i );
+ pUnsigned = (unsigned *)Vec_PtrEntry( vSims, i );
for ( k = 0; k < Vec_PtrSize(vNodes); k++ )
pUnsigned[k] = (unsigned)(ABC_PTRUINT_T)pObj->pCopy;
continue;
}
if ( Abc_ObjIsCo(pObj) )
{
- pUnsigned = Vec_PtrEntry( vSims, i );
- pUnsignedF = Vec_PtrEntry( vSims, (int)(ABC_PTRUINT_T)Abc_ObjFanin0(pObj)->pData );
+ pUnsigned = (unsigned *)Vec_PtrEntry( vSims, i );
+ pUnsignedF = (unsigned *)Vec_PtrEntry( vSims, (int)(ABC_PTRUINT_T)Abc_ObjFanin0(pObj)->pData );
if ( Abc_ObjFaninC0(pObj) )
for ( k = 0; k < Vec_PtrSize(vNodes); k++ )
pUnsigned[k] = ~pUnsignedF[k];
@@ -952,7 +954,7 @@ void Sim_SimulateCollected( Vec_Str_t * vTargets, Vec_Ptr_t * vNodes, Vec_Ptr_t
{
if ( pUnsigned[k] == (unsigned)(ABC_PTRUINT_T)pObj->pData )
continue;
- pDisproved = Vec_PtrEntry( vNodes, k );
+ pDisproved = (Abc_Obj_t *)Vec_PtrEntry( vNodes, k );
fCompl = Abc_ObjIsComplement(pDisproved);
pDisproved = Abc_ObjRegular(pDisproved);
Phase = Vec_StrEntry( vTargets, pDisproved->Id );
@@ -997,3 +999,5 @@ void Sim_SimulateCollected( Vec_Str_t * vTargets, Vec_Ptr_t * vNodes, Vec_Ptr_t
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcSat.c b/src/base/abci/abcSat.c
index 5e14116c..30c77e59 100644
--- a/src/base/abci/abcSat.c
+++ b/src/base/abci/abcSat.c
@@ -19,8 +19,13 @@
***********************************************************************/
#include "abc.h"
+#include "main.h"
+#include "cmd.h"
#include "satSolver.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -62,7 +67,7 @@ int Abc_NtkMiterSat( Abc_Ntk_t * pNtk, ABC_INT64_T nConfLimit, ABC_INT64_T nInsL
// load clauses into the sat_solver
clk = clock();
- pSat = Abc_NtkMiterSatCreate( pNtk, 0 );
+ pSat = (sat_solver *)Abc_NtkMiterSatCreate( pNtk, 0 );
if ( pSat == NULL )
return 1;
//printf( "%d \n", pSat->clauses.size );
@@ -194,7 +199,7 @@ int Abc_NtkClauseTop( sat_solver * pSat, Vec_Ptr_t * vNodes, Vec_Int_t * vVars )
int i;
//printf( "Adding triv %d. %d\n", Abc_ObjRegular(pNode)->Id, (int)pSat->sat_solver_stats.clauses );
vVars->nSize = 0;
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
Vec_IntPush( vVars, toLitCond( (int)(ABC_PTRINT_T)Abc_ObjRegular(pNode)->pCopy, Abc_ObjIsComplement(pNode) ) );
// Vec_IntPush( vVars, toLitCond( (int)Abc_ObjRegular(pNode)->Id, Abc_ObjIsComplement(pNode) ) );
return sat_solver_addclause( pSat, vVars->pArray, vVars->pArray + vVars->nSize );
@@ -228,9 +233,9 @@ int Abc_NtkClauseAnd( sat_solver * pSat, Abc_Obj_t * pNode, Vec_Ptr_t * vSuper,
{
// get the predecessor nodes
// get the complemented attributes of the nodes
- fComp1 = Abc_ObjIsComplement(vSuper->pArray[i]);
+ fComp1 = Abc_ObjIsComplement((Abc_Obj_t *)vSuper->pArray[i]);
// determine the variable numbers
- Var1 = (int)(ABC_PTRINT_T)Abc_ObjRegular(vSuper->pArray[i])->pCopy;
+ Var1 = (int)(ABC_PTRINT_T)Abc_ObjRegular((Abc_Obj_t *)vSuper->pArray[i])->pCopy;
// Var1 = (int)Abc_ObjRegular(vSuper->pArray[i])->Id;
// check that the variables are in the SAT manager
@@ -253,9 +258,9 @@ int Abc_NtkClauseAnd( sat_solver * pSat, Abc_Obj_t * pNode, Vec_Ptr_t * vSuper,
{
// get the predecessor nodes
// get the complemented attributes of the nodes
- fComp1 = Abc_ObjIsComplement(vSuper->pArray[i]);
+ fComp1 = Abc_ObjIsComplement((Abc_Obj_t *)vSuper->pArray[i]);
// determine the variable numbers
- Var1 = (int)(ABC_PTRINT_T)Abc_ObjRegular(vSuper->pArray[i])->pCopy;
+ Var1 = (int)(ABC_PTRINT_T)Abc_ObjRegular((Abc_Obj_t *)vSuper->pArray[i])->pCopy;
// Var1 = (int)Abc_ObjRegular(vSuper->pArray[i])->Id;
// add this variable to the array
Vec_IntPush( vVars, toLitCond(Var1, !fComp1) );
@@ -512,7 +517,7 @@ int Abc_NtkMiterSatCreateInt( sat_solver * pSat, Abc_Ntk_t * pNtk )
// add the clauses
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
{
assert( !Abc_ObjIsComplement(pNode) );
if ( !Abc_AigNodeIsAnd(pNode) )
@@ -530,7 +535,7 @@ int Abc_NtkMiterSatCreateInt( sat_solver * pSat, Abc_Ntk_t * pNtk )
Vec_PtrPush( vSuper, pNodeT );
Vec_PtrPush( vSuper, pNodeE );
// add the fanin nodes to explore
- Vec_PtrForEachEntry( vSuper, pFanin, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vSuper, pFanin, k )
{
pFanin = Abc_ObjRegular(pFanin);
if ( pFanin->fMarkA == 0 )
@@ -549,7 +554,7 @@ int Abc_NtkMiterSatCreateInt( sat_solver * pSat, Abc_Ntk_t * pNtk )
// get the supergate
Abc_NtkCollectSupergate( pNode, fUseMuxes, vSuper );
// add the fanin nodes to explore
- Vec_PtrForEachEntry( vSuper, pFanin, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vSuper, pFanin, k )
{
pFanin = Abc_ObjRegular(pFanin);
if ( pFanin->fMarkA == 0 )
@@ -673,7 +678,7 @@ int Abc_NodeAddClauses( sat_solver * pSat, char * pSop0, char * pSop1, Abc_Obj_t
assert( nFanins == Abc_SopGetVarNum( pSop0 ) );
// if ( nFanins == 0 )
- if ( Cudd_Regular(pNode->pData) == Cudd_ReadOne(pNode->pNtk->pManFunc) )
+ if ( Cudd_Regular((Abc_Obj_t *)pNode->pData) == Cudd_ReadOne((DdManager *)pNode->pNtk->pManFunc) )
{
vVars->nSize = 0;
// if ( Abc_SopIsConst1(pSop1) )
@@ -840,7 +845,7 @@ sat_solver * Abc_NtkMiterSatCreateLogic( Abc_Ntk_t * pNtk, int fAllPrimes )
// transfer the IDs to the copy field
Abc_NtkForEachPi( pNtk, pNode, i )
- pNode->pCopy = (void *)(ABC_PTRINT_T)pNode->Id;
+ pNode->pCopy = (Abc_Obj_t *)(ABC_PTRINT_T)pNode->Id;
// start the data structures
pSat = sat_solver_new();
@@ -897,10 +902,6 @@ finish:
***********************************************************************/
void Abc_NtkWriteSorterCnf( char * pFileName, int nVars, int nQueens )
{
- extern int Cmd_CommandExecute( void * pAbc, char * sCommand );
- extern void * Abc_FrameGetGlobalFrame();
- extern Abc_Ntk_t * Abc_FrameReadNtk( void * p );
-
char Command[100];
void * pAbc;
Abc_Ntk_t * pNtk;
@@ -918,21 +919,21 @@ void Abc_NtkWriteSorterCnf( char * pFileName, int nVars, int nQueens )
pAbc = Abc_FrameGetGlobalFrame();
// generate sorter
sprintf( Command, "gen -s -N %d sorter%d.blif", nVars, nVars );
- if ( Cmd_CommandExecute( pAbc, Command ) )
+ if ( Cmd_CommandExecute( (Abc_Frame_t *)pAbc, Command ) )
{
fprintf( stdout, "Cannot execute command \"%s\".\n", Command );
return;
}
// read the file
sprintf( Command, "read sorter%d.blif; strash", nVars );
- if ( Cmd_CommandExecute( pAbc, Command ) )
+ if ( Cmd_CommandExecute( (Abc_Frame_t *)pAbc, Command ) )
{
fprintf( stdout, "Cannot execute command \"%s\".\n", Command );
return;
}
// get the current network
- pNtk = Abc_FrameReadNtk(pAbc);
+ pNtk = Abc_FrameReadNtk((Abc_Frame_t *)pAbc);
// collect the nodes for the given two primary outputs
ppNodes[0] = Abc_NtkPo( pNtk, nVars - nQueens - 1 );
ppNodes[1] = Abc_NtkPo( pNtk, nVars - nQueens );
@@ -943,11 +944,11 @@ void Abc_NtkWriteSorterCnf( char * pFileName, int nVars, int nQueens )
// assign CNF variables
Counter = 0;
Abc_NtkForEachObj( pNtk, pObj, i )
- pObj->pCopy = (void *)~0;
+ pObj->pCopy = (Abc_Obj_t *)~0;
Abc_NtkForEachPi( pNtk, pObj, i )
- pObj->pCopy = (void *)(ABC_PTRINT_T)Counter++;
- Vec_PtrForEachEntry( vNodes, pObj, i )
- pObj->pCopy = (void *)(ABC_PTRINT_T)Counter++;
+ pObj->pCopy = (Abc_Obj_t *)(ABC_PTRINT_T)Counter++;
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
+ pObj->pCopy = (Abc_Obj_t *)(ABC_PTRINT_T)Counter++;
/*
OutVar = pCnf->pVarNums[ pObj->Id ];
@@ -972,7 +973,7 @@ void Abc_NtkWriteSorterCnf( char * pFileName, int nVars, int nQueens )
pFile = fopen( pFileName, "w" );
fprintf( pFile, "c CNF for %d-bit sorter with %d bits set to 1 generated by ABC.\n", nVars, nQueens );
fprintf( pFile, "p cnf %d %d\n", Counter, 3 * Vec_PtrSize(vNodes) + 2 );
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
{
// positive phase
fprintf( pFile, "%d %s%d %s%d 0\n", 1+(int)(ABC_PTRINT_T)pObj->pCopy,
@@ -1005,3 +1006,5 @@ void Abc_NtkWriteSorterCnf( char * pFileName, int nVars, int nQueens )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcScorr.c b/src/base/abci/abcScorr.c
new file mode 100644
index 00000000..07e52fa4
--- /dev/null
+++ b/src/base/abci/abcScorr.c
@@ -0,0 +1,454 @@
+/**CFile****************************************************************
+
+ FileName [abcScorr.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Network and node package.]
+
+ Synopsis [Signal correspondence testing procedures.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: abcScorr.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "abc.h"
+#include "ioAbc.h"
+#include "saig.h"
+#include "ssw.h"
+#include "gia.h"
+#include "cec.h"
+#include "giaAig.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+typedef struct Tst_Dat_t_ Tst_Dat_t;
+struct Tst_Dat_t_
+{
+ Abc_Ntk_t * pNetlist;
+ Aig_Man_t * pAig;
+ Gia_Man_t * pGia;
+ Vec_Int_t * vId2Name;
+ char * pFileNameOut;
+ int fFlopOnly;
+ int fFfNdOnly;
+ int fDumpBmc;
+};
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Abc_NtkMapGiaIntoNameId( Abc_Ntk_t * pNetlist, Aig_Man_t * pAig, Gia_Man_t * pGia )
+{
+ Vec_Int_t * vId2Name;
+ Abc_Obj_t * pNet, * pNode, * pAnd;
+ Aig_Obj_t * pObjAig;
+ int i;
+ vId2Name = Vec_IntStart( 0 );
+ Vec_IntFill( vId2Name, pGia ? Gia_ManObjNum(pGia) : Aig_ManObjNumMax(pAig), ~0 );
+ // copy all names
+ Abc_NtkForEachNet( pNetlist, pNet, i )
+ {
+ pNode = Abc_ObjFanin0(pNet)->pCopy;
+ if ( pNode && (pAnd = Abc_ObjRegular(pNode->pCopy)) &&
+ (pObjAig = (Aig_Obj_t *)Abc_ObjRegular(pAnd->pCopy)) &&
+ Aig_ObjType(pObjAig) != AIG_OBJ_NONE )
+ {
+ if ( pGia == NULL )
+ Vec_IntWriteEntry( vId2Name, Aig_ObjId(pObjAig), Abc_ObjId(pNet) );
+ else
+ Vec_IntWriteEntry( vId2Name, Gia_Lit2Var(pObjAig->iData), Abc_ObjId(pNet) );
+ }
+ }
+ // overwrite CO names
+ Abc_NtkForEachCo( pNetlist, pNode, i )
+ {
+ pNet = Abc_ObjFanin0(pNode);
+ pNode = pNode->pCopy;
+ if ( pNode && (pAnd = Abc_ObjRegular(pNode->pCopy)) &&
+ (pObjAig = (Aig_Obj_t *)Abc_ObjRegular(pAnd->pCopy)) &&
+ Aig_ObjType(pObjAig) != AIG_OBJ_NONE )
+ {
+ if ( pGia == NULL )
+ Vec_IntWriteEntry( vId2Name, Aig_ObjId(pObjAig), Abc_ObjId(pNet) );
+ else
+ Vec_IntWriteEntry( vId2Name, Gia_Lit2Var(pObjAig->iData), Abc_ObjId(pNet) );
+ }
+ }
+ // overwrite CI names
+ Abc_NtkForEachCi( pNetlist, pNode, i )
+ {
+ pNet = Abc_ObjFanout0(pNode);
+ pNode = pNode->pCopy;
+ if ( pNode && (pAnd = Abc_ObjRegular(pNode->pCopy)) &&
+ (pObjAig = (Aig_Obj_t *)Abc_ObjRegular(pAnd->pCopy)) &&
+ Aig_ObjType(pObjAig) != AIG_OBJ_NONE )
+ {
+ if ( pGia == NULL )
+ Vec_IntWriteEntry( vId2Name, Aig_ObjId(pObjAig), Abc_ObjId(pNet) );
+ else
+ Vec_IntWriteEntry( vId2Name, Gia_Lit2Var(pObjAig->iData), Abc_ObjId(pNet) );
+ }
+ }
+ return vId2Name;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+char * Abc_NtkTestScorrGetName( Abc_Ntk_t * pNetlist, Vec_Int_t * vId2Name, int Id )
+{
+// Abc_Obj_t * pObj;
+//printf( "trying to get name for %d\n", Id );
+ if ( Vec_IntEntry(vId2Name, Id) == ~0 )
+ return NULL;
+// pObj = Abc_NtkObj( pNetlist, Vec_IntEntry(vId2Name, Id) );
+// pObj = Abc_ObjFanin0(pObj);
+// assert( Abc_ObjIsCi(pObj) );
+ return Nm_ManFindNameById( pNetlist->pManName, Vec_IntEntry(vId2Name, Id) );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_NtkTestScorrWriteEquivPair( Abc_Ntk_t * pNetlist, Vec_Int_t * vId2Name, int Id1, int Id2, FILE * pFile, int fPol )
+{
+ char * pName1 = Abc_NtkTestScorrGetName( pNetlist, vId2Name, Id1 );
+ char * pName2 = Abc_NtkTestScorrGetName( pNetlist, vId2Name, Id2 );
+ if ( pName1 == NULL || pName2 == NULL )
+ return 0;
+ fprintf( pFile, "%s=%s%s\n", pName1, fPol? "~": "", pName2 );
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_NtkTestScorrWriteEquivConst( Abc_Ntk_t * pNetlist, Vec_Int_t * vId2Name, int Id1, FILE * pFile, int fPol )
+{
+ char * pName1 = Abc_NtkTestScorrGetName( pNetlist, vId2Name, Id1 );
+ if ( pName1 == NULL )
+ return 0;
+ fprintf( pFile, "%s=%s%s\n", pName1, fPol? "~": "", "const0" );
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+char * Abc_NtkBmcFileName( char * pName )
+{
+ static char Buffer[1000];
+ char * pNameGeneric = Extra_FileNameGeneric( pName );
+ sprintf( Buffer, "%s_bmc%s", pNameGeneric, pName + strlen(pNameGeneric) );
+ ABC_FREE( pNameGeneric );
+ return Buffer;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_NtkTestScorrWriteEquivGia( Tst_Dat_t * pData )
+{
+ Abc_Ntk_t * pNetlist = pData->pNetlist;
+ Vec_Int_t * vId2Name = pData->vId2Name;
+ Gia_Man_t * pGia = pData->pGia;
+ char * pFileNameOut = pData->pFileNameOut;
+ FILE * pFile;
+ Gia_Obj_t * pObj, * pRepr;
+ int i, Counter = 0;
+ if ( pData->fDumpBmc )
+ {
+ pData->fDumpBmc = 0;
+ pFileNameOut = Abc_NtkBmcFileName( pFileNameOut );
+ }
+ pFile = fopen( pFileNameOut, "wb" );
+ Gia_ManSetPhase( pGia );
+ Gia_ManForEachObj( pGia, pObj, i )
+ {
+ if ( !Gia_ObjHasRepr(pGia, i) )
+ continue;
+ pRepr = Gia_ManObj( pGia,Gia_ObjRepr(pGia, i) );
+ if ( pData->fFlopOnly )
+ {
+ if ( !Gia_ObjIsRo(pGia, pObj) || !(Gia_ObjIsRo(pGia, pRepr)||Gia_ObjIsConst0(pRepr)) )
+ continue;
+ }
+ else if ( pData->fFfNdOnly )
+ {
+ if ( !Gia_ObjIsRo(pGia, pObj) && !(Gia_ObjIsRo(pGia, pRepr)||Gia_ObjIsConst0(pRepr)) )
+ continue;
+ }
+ if ( Gia_ObjRepr(pGia, i) == 0 )
+ Counter += Abc_NtkTestScorrWriteEquivConst( pNetlist, vId2Name, i, pFile, Gia_ObjPhase(pObj) );
+ else
+ Counter += Abc_NtkTestScorrWriteEquivPair( pNetlist, vId2Name, Gia_ObjRepr(pGia, i), i, pFile,
+ Gia_ObjPhase(pRepr) ^ Gia_ObjPhase(pObj) );
+ }
+ fclose( pFile );
+ printf( "%d pairs of sequentially equivalent nodes are written into file \"%s\".\n", Counter, pFileNameOut );
+ return Counter;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_NtkTestScorrWriteEquivAig( Tst_Dat_t * pData )
+{
+ Abc_Ntk_t * pNetlist = pData->pNetlist;
+ Vec_Int_t * vId2Name = pData->vId2Name;
+ Aig_Man_t * pAig = pData->pAig;
+ char * pFileNameOut = pData->pFileNameOut;
+ FILE * pFile;
+ Aig_Obj_t * pObj, * pRepr;
+ int i, Counter = 0;
+ if ( pData->fDumpBmc )
+ {
+ pData->fDumpBmc = 0;
+ pFileNameOut = Abc_NtkBmcFileName( pFileNameOut );
+ }
+ pFile = fopen( pFileNameOut, "wb" );
+ Aig_ManForEachObj( pAig, pObj, i )
+ {
+ if ( (pRepr = Aig_ObjRepr(pAig, pObj)) == NULL )
+ continue;
+ if ( pData->fFlopOnly )
+ {
+ if ( !Saig_ObjIsLo(pAig, pObj) || !(Saig_ObjIsLo(pAig, pRepr)||pRepr==Aig_ManConst1(pAig)) )
+ continue;
+ }
+ else if ( pData->fFfNdOnly )
+ {
+ if ( !Saig_ObjIsLo(pAig, pObj) && !(Saig_ObjIsLo(pAig, pRepr)||pRepr==Aig_ManConst1(pAig)) )
+ continue;
+ }
+ if ( pRepr == Aig_ManConst1(pAig) )
+ Counter += Abc_NtkTestScorrWriteEquivConst( pNetlist, vId2Name, Aig_ObjId(pObj), pFile, Aig_ObjPhase(pObj) );
+ else
+ Counter += Abc_NtkTestScorrWriteEquivPair( pNetlist, vId2Name, Aig_ObjId(pRepr), Aig_ObjId(pObj), pFile,
+ Aig_ObjPhase(pRepr) ^ Aig_ObjPhase(pObj) );
+ }
+ fclose( pFile );
+ printf( "%d pairs of sequentially equivalent nodes are written into file \"%s\".\n", Counter, pFileNameOut );
+ return Counter;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Abc_Ntk_t * Abc_NtkTestScorr( char * pFileNameIn, char * pFileNameOut, int nStepsMax, int nBTLimit, int fNewAlgo, int fFlopOnly, int fFfNdOnly, int fVerbose )
+{
+ extern Aig_Man_t * Abc_NtkToDar( Abc_Ntk_t * pNtk, int fExors, int fRegisters );
+ extern Abc_Ntk_t * Abc_NtkFromDarSeqSweep( Abc_Ntk_t * pNtkOld, Aig_Man_t * pMan );
+
+ FILE * pFile;
+ Tst_Dat_t Data, * pData = &Data;
+ Vec_Int_t * vId2Name;
+ Abc_Ntk_t * pNetlist, * pLogic, * pStrash, * pResult;
+ Aig_Man_t * pAig, * pTempAig;
+ Gia_Man_t * pGia, * pTempGia;
+ int Counter = 0;
+ // check the files
+ pFile = fopen( pFileNameIn, "rb" );
+ if ( pFile == NULL )
+ {
+ printf( "Input file \"%s\" cannot be opened.\n", pFileNameIn );
+ return NULL;
+ }
+ fclose( pFile );
+ // check the files
+ pFile = fopen( pFileNameOut, "wb" );
+ if ( pFile == NULL )
+ {
+ printf( "Output file \"%s\" cannot be opened.\n", pFileNameOut );
+ return NULL;
+ }
+ fclose( pFile );
+ // derive AIG for signal correspondence
+ pNetlist = Io_ReadNetlist( pFileNameIn, Io_ReadFileType(pFileNameIn), 1 );
+ if ( pNetlist == NULL )
+ {
+ printf( "Reading input file \"%s\" has failed.\n", pFileNameIn );
+ return NULL;
+ }
+ pLogic = Abc_NtkToLogic( pNetlist );
+ if ( pLogic == NULL )
+ {
+ Abc_NtkDelete( pNetlist );
+ printf( "Deriving logic network from input file %s has failed.\n", pFileNameIn );
+ return NULL;
+ }
+ if ( Extra_FileIsType( pFileNameIn, ".bench", ".BENCH", NULL ) )
+ {
+ // get the init file name
+ char * pFileNameInit = Extra_FileNameGenericAppend( pLogic->pSpec, ".init" );
+ pFile = fopen( pFileNameInit, "rb" );
+ if ( pFile == NULL )
+ {
+ printf( "Init file \"%s\" cannot be opened.\n", pFileNameInit );
+ return NULL;
+ }
+ Io_ReadBenchInit( pLogic, pFileNameInit );
+ Abc_NtkConvertDcLatches( pLogic );
+ if ( fVerbose )
+ printf( "Initial state was derived from file \"%s\".\n", pFileNameInit );
+ }
+ pStrash = Abc_NtkStrash( pLogic, 0, 1, 0 );
+ if ( pStrash == NULL )
+ {
+ Abc_NtkDelete( pLogic );
+ Abc_NtkDelete( pNetlist );
+ printf( "Deriving strashed network from input file %s has failed.\n", pFileNameIn );
+ return NULL;
+ }
+ pAig = Abc_NtkToDar( pStrash, 0, 1 ); // performs "zero" internally
+ // the newer computation (&scorr)
+ if ( fNewAlgo )
+ {
+ Cec_ParCor_t CorPars, * pCorPars = &CorPars;
+ Cec_ManCorSetDefaultParams( pCorPars );
+ pCorPars->nBTLimit = nBTLimit;
+ pCorPars->nStepsMax = nStepsMax;
+ pCorPars->fVerbose = fVerbose;
+ pCorPars->fUseCSat = 1;
+ pGia = Gia_ManFromAig( pAig );
+ // prepare the data-structure
+ memset( pData, 0, sizeof(Tst_Dat_t) );
+ pData->pNetlist = pNetlist;
+ pData->pAig = NULL;
+ pData->pGia = pGia;
+ pData->vId2Name = vId2Name = Abc_NtkMapGiaIntoNameId( pNetlist, pAig, pGia );
+ pData->pFileNameOut = pFileNameOut;
+ pData->fFlopOnly = fFlopOnly;
+ pData->fFfNdOnly = fFfNdOnly;
+ pData->fDumpBmc = 1;
+ pCorPars->pData = pData;
+ pCorPars->pFunc = (void *)Abc_NtkTestScorrWriteEquivGia;
+ // call signal correspondence
+ pTempGia = Cec_ManLSCorrespondence( pGia, pCorPars );
+ pTempAig = Gia_ManToAigSimple( pTempGia );
+ Gia_ManStop( pTempGia );
+ Gia_ManStop( pGia );
+ }
+ // the older computation (scorr)
+ else
+ {
+ Ssw_Pars_t SswPars, * pSswPars = &SswPars;
+ Ssw_ManSetDefaultParams( pSswPars );
+ pSswPars->nBTLimit = nBTLimit;
+ pSswPars->nStepsMax = nStepsMax;
+ pSswPars->fVerbose = fVerbose;
+ // preSswPare the data-structure
+ memset( pData, 0, sizeof(Tst_Dat_t) );
+ pData->pNetlist = pNetlist;
+ pData->pAig = pAig;
+ pData->pGia = NULL;
+ pData->vId2Name = vId2Name = Abc_NtkMapGiaIntoNameId( pNetlist, pAig, NULL );
+ pData->pFileNameOut = pFileNameOut;
+ pData->fFlopOnly = fFlopOnly;
+ pData->fFfNdOnly = fFfNdOnly;
+ pData->fDumpBmc = 1;
+ pSswPars->pData = pData;
+ pSswPars->pFunc = (void *)Abc_NtkTestScorrWriteEquivAig;
+ // call signal correspondence
+ pTempAig = Ssw_SignalCorrespondence( pAig, pSswPars );
+ }
+ // create the resulting AIG
+ pResult = Abc_NtkFromDarSeqSweep( pStrash, pTempAig );
+ // cleanup
+ Vec_IntFree( vId2Name );
+ Aig_ManStop( pAig );
+ Aig_ManStop( pTempAig );
+ Abc_NtkDelete( pStrash );
+ Abc_NtkDelete( pLogic );
+ Abc_NtkDelete( pNetlist );
+ return pResult;
+}
+
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcSense.c b/src/base/abci/abcSense.c
index 3e68f0fd..cfecfaf3 100644
--- a/src/base/abci/abcSense.c
+++ b/src/base/abci/abcSense.c
@@ -21,6 +21,9 @@
#include "abc.h"
#include "fraig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -47,7 +50,7 @@ Abc_Obj_t * Abc_NtkSensitivityMiter_rec( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNode
return pNode->pCopy;
Abc_NtkSensitivityMiter_rec( pNtkNew, Abc_ObjFanin0(pNode) );
Abc_NtkSensitivityMiter_rec( pNtkNew, Abc_ObjFanin1(pNode) );
- return pNode->pCopy = Abc_AigAnd( pNtkNew->pManFunc, Abc_ObjChild0Copy(pNode), Abc_ObjChild1Copy(pNode) );
+ return pNode->pCopy = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, Abc_ObjChild0Copy(pNode), Abc_ObjChild1Copy(pNode) );
}
/**Function*************************************************************
@@ -80,7 +83,10 @@ Abc_Ntk_t * Abc_NtkSensitivityMiter( Abc_Ntk_t * pNtk, int iVar )
Abc_AigConst1(pNtk)->pCopy = Abc_AigConst1(pMiter);
Abc_AigConst1(pNtk)->pData = Abc_AigConst1(pMiter);
Abc_NtkForEachCi( pNtk, pObj, i )
- pObj->pCopy = pObj->pData = Abc_NtkCreatePi( pMiter );
+ {
+ pObj->pCopy = Abc_NtkCreatePi( pMiter );
+ pObj->pData = pObj->pCopy;
+ }
Abc_NtkAddDummyPiNames( pMiter );
// assign the cofactors of the CI node to be constants
@@ -90,7 +96,7 @@ Abc_Ntk_t * Abc_NtkSensitivityMiter( Abc_Ntk_t * pNtk, int iVar )
// collect the internal nodes
vNodes = Abc_NtkDfsReverseNodes( pNtk, &pObj, 1 );
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
{
for ( pNext = pObj? pObj->pCopy : pObj; pObj; pObj = pNext, pNext = pObj? pObj->pCopy : pObj )
{
@@ -100,8 +106,8 @@ Abc_Ntk_t * Abc_NtkSensitivityMiter( Abc_Ntk_t * pNtk, int iVar )
pFanin = Abc_ObjFanin1(pObj);
if ( !Abc_NodeIsTravIdCurrent(pFanin) )
pFanin->pData = Abc_NtkSensitivityMiter_rec( pMiter, pFanin );
- pObj->pCopy = Abc_AigAnd( pMiter->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
- pObj->pData = Abc_AigAnd( pMiter->pManFunc, Abc_ObjChild0Data(pObj), Abc_ObjChild1Data(pObj) );
+ pObj->pCopy = Abc_AigAnd( (Abc_Aig_t *)pMiter->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
+ pObj->pData = Abc_AigAnd( (Abc_Aig_t *)pMiter->pManFunc, Abc_ObjChild0Data(pObj), Abc_ObjChild1Data(pObj) );
}
}
Vec_PtrFree( vNodes );
@@ -115,13 +121,13 @@ Abc_Ntk_t * Abc_NtkSensitivityMiter( Abc_Ntk_t * pNtk, int iVar )
// get the result of quantification
if ( i == Abc_NtkCoNum(pNtk) - 1 )
{
- pOutput = Abc_AigAnd( pMiter->pManFunc, pOutput, Abc_ObjChild0Data(pObj) );
- pOutput = Abc_AigAnd( pMiter->pManFunc, pOutput, Abc_ObjChild0Copy(pObj) );
+ pOutput = Abc_AigAnd( (Abc_Aig_t *)pMiter->pManFunc, pOutput, Abc_ObjChild0Data(pObj) );
+ pOutput = Abc_AigAnd( (Abc_Aig_t *)pMiter->pManFunc, pOutput, Abc_ObjChild0Copy(pObj) );
}
else
{
- pNext = Abc_AigXor( pMiter->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild0Data(pObj) );
- pOutput = Abc_AigOr( pMiter->pManFunc, pOutput, pNext );
+ pNext = Abc_AigXor( (Abc_Aig_t *)pMiter->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild0Data(pObj) );
+ pOutput = Abc_AigOr( (Abc_Aig_t *)pMiter->pManFunc, pOutput, pNext );
}
}
// add the PO node and name
@@ -206,3 +212,5 @@ Vec_Int_t * Abc_NtkSensitivity( Abc_Ntk_t * pNtk, int nConfLim, int fVerbose )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcDelay.c b/src/base/abci/abcSpeedup.c
index 203b076f..779fde62 100644
--- a/src/base/abci/abcDelay.c
+++ b/src/base/abci/abcSpeedup.c
@@ -1,6 +1,6 @@
/**CFile****************************************************************
- FileName [abcDelay.c]
+ FileName [abcSpeedup.c]
SystemName [ABC: Logic synthesis and verification system.]
@@ -14,14 +14,18 @@
Date [Ver. 1.0. Started - June 20, 2005.]
- Revision [$Id: abcDelay.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+ Revision [$Id: abcSpeedup.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#include "abc.h"
+#include "main.h"
#include "if.h"
#include "aig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -34,8 +38,6 @@ static inline void Abc_ObjSetArrival( Abc_Obj_t * pNode, float Time ) { pNode-
static inline void Abc_ObjSetRequired( Abc_Obj_t * pNode, float Time ) { pNode->pNtk->pLutTimes[3*pNode->Id+1] = Time; }
static inline void Abc_ObjSetSlack( Abc_Obj_t * pNode, float Time ) { pNode->pNtk->pLutTimes[3*pNode->Id+2] = Time; }
-extern void * Abc_FrameReadLibLut();
-
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
@@ -108,7 +110,7 @@ float Abc_NtkDelayTraceLut( Abc_Ntk_t * pNtk, int fUseLutLib )
assert( Abc_NtkIsLogic(pNtk) );
// get the library
- pLutLib = fUseLutLib? Abc_FrameReadLibLut() : NULL;
+ pLutLib = fUseLutLib? (If_Lib_t *)Abc_FrameReadLibLut() : NULL;
if ( pLutLib && pLutLib->LutMax < Abc_NtkGetFaninMax(pNtk) )
{
printf( "The max LUT size (%d) is less than the max fanin count (%d).\n",
@@ -127,7 +129,7 @@ float Abc_NtkDelayTraceLut( Abc_Ntk_t * pNtk, int fUseLutLib )
// propagate arrival times
vNodes = Abc_NtkDfs( pNtk, 1 );
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
{
tArrival = -ABC_INFINITY;
if ( pLutLib == NULL )
@@ -179,7 +181,7 @@ float Abc_NtkDelayTraceLut( Abc_Ntk_t * pNtk, int fUseLutLib )
// propagate the required times
vNodes = Abc_NtkDfsReverse( pNtk );
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
{
if ( pLutLib == NULL )
{
@@ -246,7 +248,7 @@ void Abc_NtkDelayTracePrint( Abc_Ntk_t * pNtk, int fUseLutLib, int fVerbose )
int i, Nodes, * pCounters;
float tArrival, tDelta, nSteps, Num;
// get the library
- pLutLib = fUseLutLib? Abc_FrameReadLibLut() : NULL;
+ pLutLib = fUseLutLib? (If_Lib_t *)Abc_FrameReadLibLut() : NULL;
if ( pLutLib && pLutLib->LutMax < Abc_NtkGetFaninMax(pNtk) )
{
printf( "The max LUT size (%d) is less than the max fanin count (%d).\n",
@@ -311,7 +313,7 @@ int Abc_AigCheckTfi_rec( Abc_Obj_t * pNode, Abc_Obj_t * pOld )
if ( Abc_AigCheckTfi_rec( Abc_ObjFanin1(pNode), pOld ) )
return 1;
// check equivalent nodes
- return Abc_AigCheckTfi_rec( pNode->pData, pOld );
+ return Abc_AigCheckTfi_rec( (Abc_Obj_t *)pNode->pData, pOld );
}
/**Function*************************************************************
@@ -379,8 +381,8 @@ void Abc_NtkSpeedupNode( Abc_Ntk_t * pNtk, Abc_Ntk_t * pAig, Abc_Obj_t * pNode,
int nCofs, i, k, nSkip;
// quit of regulars are the same
- Vec_PtrForEachEntry( vLeaves, pObj, i )
- Vec_PtrForEachEntry( vLeaves, pObj2, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pObj2, k )
if ( i != k && Abc_ObjRegular(pObj->pCopy) == Abc_ObjRegular(pObj2->pCopy) )
{
// printf( "Identical after structural hashing!!!\n" );
@@ -391,7 +393,7 @@ void Abc_NtkSpeedupNode( Abc_Ntk_t * pNtk, Abc_Ntk_t * pAig, Abc_Obj_t * pNode,
vNodes = Vec_PtrAlloc( 100 );
Abc_NtkIncrementTravId( pAig );
Abc_NodeSetTravIdCurrent( Abc_AigConst1(pAig) );
- Vec_PtrForEachEntry( vLeaves, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pObj, i )
{
pAnd = pObj->pCopy;
Abc_NodeSetTravIdCurrent( Abc_ObjRegular(pAnd) );
@@ -409,18 +411,18 @@ void Abc_NtkSpeedupNode( Abc_Ntk_t * pNtk, Abc_Ntk_t * pAig, Abc_Obj_t * pNode,
nCofs = (1 << Vec_PtrSize(vTimes));
for ( i = 0; i < nCofs; i++ )
{
- Vec_PtrForEachEntry( vLeaves, pObj, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pObj, k )
{
pAnd = pObj->pCopy;
Abc_ObjRegular(pAnd)->pCopy = Abc_ObjRegular(pAnd);
}
- Vec_PtrForEachEntry( vTimes, pObj, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vTimes, pObj, k )
{
pAnd = pObj->pCopy;
Abc_ObjRegular(pAnd)->pCopy = Abc_ObjNotCond( Abc_AigConst1(pAig), ((i & (1<<k)) == 0) );
}
- Vec_PtrForEachEntry( vNodes, pObj, k )
- pObj->pCopy = Abc_AigAnd( pAig->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, k )
+ pObj->pCopy = Abc_AigAnd( (Abc_Aig_t *)pAig->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
// save the result
pAnd = pNode->pCopy;
ppCofs[i] = Abc_ObjNotCond( Abc_ObjRegular(pAnd)->pCopy, Abc_ObjIsComplement(pAnd) );
@@ -431,11 +433,11 @@ void Abc_NtkSpeedupNode( Abc_Ntk_t * pNtk, Abc_Ntk_t * pAig, Abc_Obj_t * pNode,
//Abc_ObjAddFanin( Abc_NtkCreatePo(pAig), ppCofs[1] );
// collect the resulting tree
- Vec_PtrForEachEntry( vTimes, pObj, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vTimes, pObj, k )
for ( nSkip = (1<<k), i = 0; i < nCofs; i += 2*nSkip )
{
pAnd = pObj->pCopy;
- ppCofs[i] = Abc_AigMux( pAig->pManFunc, Abc_ObjRegular(pAnd), ppCofs[i+nSkip], ppCofs[i] );
+ ppCofs[i] = Abc_AigMux( (Abc_Aig_t *)pAig->pManFunc, Abc_ObjRegular(pAnd), ppCofs[i+nSkip], ppCofs[i] );
}
//Abc_ObjAddFanin( Abc_NtkCreatePo(pAig), ppCofs[0] );
@@ -470,7 +472,7 @@ unsigned Abc_NtkDelayTraceTCEdges( Abc_Ntk_t * pNtk, Abc_Obj_t * pNode, float tD
unsigned uResult = 0;
float tRequired, * pDelays;
int k;
- pLutLib = fUseLutLib? Abc_FrameReadLibLut() : NULL;
+ pLutLib = fUseLutLib? (If_Lib_t *)Abc_FrameReadLibLut() : NULL;
tRequired = Abc_ObjRequired(pNode);
if ( pLutLib == NULL )
{
@@ -606,8 +608,8 @@ Abc_Ntk_t * Abc_NtkSpeedup( Abc_Ntk_t * pNtk, int fUseLutLib, int Percentage, in
// order the fanins in the increasing order of criticalily
if ( Vec_PtrSize(vTimeCries) > 1 )
{
- pFanin = Vec_PtrEntry( vTimeCries, 0 );
- pFanin2 = Vec_PtrEntry( vTimeCries, 1 );
+ pFanin = (Abc_Obj_t *)Vec_PtrEntry( vTimeCries, 0 );
+ pFanin2 = (Abc_Obj_t *)Vec_PtrEntry( vTimeCries, 1 );
if ( Abc_ObjSlack(pFanin) < Abc_ObjSlack(pFanin2) )
{
Vec_PtrWriteEntry( vTimeCries, 0, pFanin2 );
@@ -616,15 +618,15 @@ Abc_Ntk_t * Abc_NtkSpeedup( Abc_Ntk_t * pNtk, int fUseLutLib, int Percentage, in
}
if ( Vec_PtrSize(vTimeCries) > 2 )
{
- pFanin = Vec_PtrEntry( vTimeCries, 1 );
- pFanin2 = Vec_PtrEntry( vTimeCries, 2 );
+ pFanin = (Abc_Obj_t *)Vec_PtrEntry( vTimeCries, 1 );
+ pFanin2 = (Abc_Obj_t *)Vec_PtrEntry( vTimeCries, 2 );
if ( Abc_ObjSlack(pFanin) < Abc_ObjSlack(pFanin2) )
{
Vec_PtrWriteEntry( vTimeCries, 1, pFanin2 );
Vec_PtrWriteEntry( vTimeCries, 2, pFanin );
}
- pFanin = Vec_PtrEntry( vTimeCries, 0 );
- pFanin2 = Vec_PtrEntry( vTimeCries, 1 );
+ pFanin = (Abc_Obj_t *)Vec_PtrEntry( vTimeCries, 0 );
+ pFanin2 = (Abc_Obj_t *)Vec_PtrEntry( vTimeCries, 1 );
if ( Abc_ObjSlack(pFanin) < Abc_ObjSlack(pFanin2) )
{
Vec_PtrWriteEntry( vTimeCries, 0, pFanin2 );
@@ -645,7 +647,7 @@ Abc_Ntk_t * Abc_NtkSpeedup( Abc_Ntk_t * pNtk, int fUseLutLib, int Percentage, in
Abc_AigForEachAnd( pNtkNew, pNode, i )
if ( pNode->pData )
{
- if ( Abc_ObjFanoutNum(pNode->pData) > 0 )
+ if ( Abc_ObjFanoutNum((Abc_Obj_t *)pNode->pData) > 0 )
pNode->pData = NULL;
}
@@ -683,7 +685,7 @@ Vec_Int_t * Abc_NtkPowerEstimate( Abc_Ntk_t * pNtk, int fProbOne )
// strash the network
pNtkStr = Abc_NtkStrash( pNtk, 0, 1, 0 );
Abc_NtkForEachObj( pNtk, pObjAbc, i )
- if ( Abc_ObjRegular(pObjAbc->pTemp)->Type == ABC_FUNC_NONE )
+ if ( Abc_ObjRegular((Abc_Obj_t *)pObjAbc->pTemp)->Type == ABC_FUNC_NONE )
pObjAbc->pTemp = NULL;
// map network into an AIG
pAig = Abc_NtkToDar( pNtkStr, 0, (int)(Abc_NtkLatchNum(pNtk) > 0) );
@@ -691,7 +693,7 @@ Vec_Int_t * Abc_NtkPowerEstimate( Abc_Ntk_t * pNtk, int fProbOne )
pSwitching = (float *)vSwitching->pArray;
Abc_NtkForEachObj( pNtk, pObjAbc, i )
{
- if ( (pObjAbc2 = Abc_ObjRegular(pObjAbc->pTemp)) && (pObjAig = Aig_Regular(pObjAbc2->pTemp)) )
+ if ( (pObjAbc2 = Abc_ObjRegular((Abc_Obj_t *)pObjAbc->pTemp)) && (pObjAig = Aig_Regular((Aig_Obj_t *)pObjAbc2->pTemp)) )
pProbability[pObjAbc->Id] = pSwitching[pObjAig->Id];
}
Vec_IntFree( vSwitching );
@@ -903,8 +905,8 @@ Abc_Ntk_t * Abc_NtkPowerdown( Abc_Ntk_t * pNtk, int fUseLutLib, int Percentage,
// order the fanins in the increasing order of criticalily
if ( Vec_PtrSize(vTimeCries) > 1 )
{
- pFanin = Vec_PtrEntry( vTimeCries, 0 );
- pFanin2 = Vec_PtrEntry( vTimeCries, 1 );
+ pFanin = (Abc_Obj_t *)Vec_PtrEntry( vTimeCries, 0 );
+ pFanin2 = (Abc_Obj_t *)Vec_PtrEntry( vTimeCries, 1 );
// if ( Abc_ObjSlack(pFanin) < Abc_ObjSlack(pFanin2) )
if ( pProb[pFanin->Id] > pProb[pFanin2->Id] )
{
@@ -914,16 +916,16 @@ Abc_Ntk_t * Abc_NtkPowerdown( Abc_Ntk_t * pNtk, int fUseLutLib, int Percentage,
}
if ( Vec_PtrSize(vTimeCries) > 2 )
{
- pFanin = Vec_PtrEntry( vTimeCries, 1 );
- pFanin2 = Vec_PtrEntry( vTimeCries, 2 );
+ pFanin = (Abc_Obj_t *)Vec_PtrEntry( vTimeCries, 1 );
+ pFanin2 = (Abc_Obj_t *)Vec_PtrEntry( vTimeCries, 2 );
// if ( Abc_ObjSlack(pFanin) < Abc_ObjSlack(pFanin2) )
if ( pProb[pFanin->Id] > pProb[pFanin2->Id] )
{
Vec_PtrWriteEntry( vTimeCries, 1, pFanin2 );
Vec_PtrWriteEntry( vTimeCries, 2, pFanin );
}
- pFanin = Vec_PtrEntry( vTimeCries, 0 );
- pFanin2 = Vec_PtrEntry( vTimeCries, 1 );
+ pFanin = (Abc_Obj_t *)Vec_PtrEntry( vTimeCries, 0 );
+ pFanin2 = (Abc_Obj_t *)Vec_PtrEntry( vTimeCries, 1 );
// if ( Abc_ObjSlack(pFanin) < Abc_ObjSlack(pFanin2) )
if ( pProb[pFanin->Id] > pProb[pFanin2->Id] )
{
@@ -945,7 +947,7 @@ Abc_Ntk_t * Abc_NtkPowerdown( Abc_Ntk_t * pNtk, int fUseLutLib, int Percentage,
Abc_AigForEachAnd( pNtkNew, pNode, i )
if ( pNode->pData )
{
- if ( Abc_ObjFanoutNum(pNode->pData) > 0 )
+ if ( Abc_ObjFanoutNum((Abc_Obj_t *)pNode->pData) > 0 )
pNode->pData = NULL;
}
@@ -959,3 +961,5 @@ Abc_Ntk_t * Abc_NtkPowerdown( Abc_Ntk_t * pNtk, int fUseLutLib, int Percentage,
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcStrash.c b/src/base/abci/abcStrash.c
index bf082456..e08def57 100644
--- a/src/base/abci/abcStrash.c
+++ b/src/base/abci/abcStrash.c
@@ -22,6 +22,9 @@
#include "extra.h"
#include "dec.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -44,7 +47,7 @@ static void Abc_NtkStrashPerform( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew, int fAl
SeeAlso []
***********************************************************************/
-Abc_Ntk_t * Abc_NtkRestrash( Abc_Ntk_t * pNtk, bool fCleanup )
+Abc_Ntk_t * Abc_NtkRestrash( Abc_Ntk_t * pNtk, int fCleanup )
{
// extern int timeRetime;
Abc_Ntk_t * pNtkAig;
@@ -59,14 +62,14 @@ Abc_Ntk_t * Abc_NtkRestrash( Abc_Ntk_t * pNtk, bool fCleanup )
pNtkAig = Abc_NtkStartFrom( pNtk, ABC_NTK_STRASH, ABC_FUNC_AIG );
// 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) );
+ pObj->pCopy = Abc_AigAnd( (Abc_Aig_t *)pNtkAig->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
// finalize the network
Abc_NtkFinalize( pNtk, pNtkAig );
// print warning about self-feed latches
// if ( Abc_NtkCountSelfFeedLatches(pNtkAig) )
// printf( "Warning: The network has %d self-feeding latches.\n", Abc_NtkCountSelfFeedLatches(pNtkAig) );
// perform cleanup if requested
- if ( fCleanup && (nNodes = Abc_AigCleanup(pNtkAig->pManFunc)) )
+ if ( fCleanup && (nNodes = Abc_AigCleanup((Abc_Aig_t *)pNtkAig->pManFunc)) )
printf( "Abc_NtkRestrash(): AIG cleanup removed %d nodes (this is a bug).\n", nNodes );
// duplicate EXDC
if ( pNtk->pExdc )
@@ -97,7 +100,7 @@ Abc_Ntk_t * Abc_NtkRestrash( Abc_Ntk_t * pNtk, bool fCleanup )
SeeAlso []
***********************************************************************/
-Abc_Ntk_t * Abc_NtkRestrashZero( Abc_Ntk_t * pNtk, bool fCleanup )
+Abc_Ntk_t * Abc_NtkRestrashZero( Abc_Ntk_t * pNtk, int fCleanup )
{
// extern int timeRetime;
Abc_Ntk_t * pNtkAig;
@@ -123,7 +126,7 @@ Abc_Ntk_t * Abc_NtkRestrashZero( Abc_Ntk_t * pNtk, bool fCleanup )
printf( "Converting %d flops from don't-care to zero initial value.\n", Counter );
// 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) );
+ pObj->pCopy = Abc_AigAnd( (Abc_Aig_t *)pNtkAig->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
// finalize the network
Abc_NtkFinalize( pNtk, pNtkAig );
// complement the 1-valued registers
@@ -146,7 +149,7 @@ Abc_Ntk_t * Abc_NtkRestrashZero( Abc_Ntk_t * pNtk, bool fCleanup )
// if ( Abc_NtkCountSelfFeedLatches(pNtkAig) )
// printf( "Warning: The network has %d self-feeding latches.\n", Abc_NtkCountSelfFeedLatches(pNtkAig) );
// perform cleanup if requested
- if ( fCleanup && (nNodes = Abc_AigCleanup(pNtkAig->pManFunc)) )
+ if ( fCleanup && (nNodes = Abc_AigCleanup((Abc_Aig_t *)pNtkAig->pManFunc)) )
printf( "Abc_NtkRestrash(): AIG cleanup removed %d nodes (this is a bug).\n", nNodes );
// duplicate EXDC
if ( pNtk->pExdc )
@@ -199,7 +202,7 @@ Abc_Ntk_t * Abc_NtkStrash( Abc_Ntk_t * pNtk, int fAllNodes, int fCleanup, int fR
// if ( Abc_NtkCountSelfFeedLatches(pNtkAig) )
// printf( "Warning: The network has %d self-feeding latches.\n", Abc_NtkCountSelfFeedLatches(pNtkAig) );
// perform cleanup if requested
- nNodes = fCleanup? Abc_AigCleanup(pNtkAig->pManFunc) : 0;
+ nNodes = fCleanup? Abc_AigCleanup((Abc_Aig_t *)pNtkAig->pManFunc) : 0;
// if ( nNodes )
// printf( "Warning: AIG cleanup removed %d nodes (this is not a bug).\n", nNodes );
// duplicate EXDC
@@ -267,7 +270,7 @@ int Abc_NtkAppend( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fAddPos )
Abc_NtkStrashPerform( pNtk2, pNtk1, 1, 0 );
else
Abc_NtkForEachNode( pNtk2, pObj, i )
- pObj->pCopy = Abc_AigAnd( pNtk1->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
+ pObj->pCopy = Abc_AigAnd( (Abc_Aig_t *)pNtk1->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
// add the COs of the second network
if ( fAddPos )
{
@@ -293,7 +296,7 @@ int Abc_NtkAppend( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int fAddPos )
// derive the new driver
pDriverOld = Abc_ObjChild0( pObjOld );
pDriverNew = Abc_ObjChild0Copy( pObj );
- pDriverNew = Abc_AigOr( pNtk1->pManFunc, pDriverOld, pDriverNew );
+ pDriverNew = Abc_AigOr( (Abc_Aig_t *)pNtk1->pManFunc, pDriverOld, pDriverNew );
if ( Abc_ObjRegular(pDriverOld) == Abc_ObjRegular(pDriverNew) )
continue;
// replace the old driver by the new driver
@@ -334,7 +337,7 @@ void Abc_NtkStrashPerform( Abc_Ntk_t * pNtkOld, Abc_Ntk_t * pNtkNew, int fAllNod
//printf( "Nodes = %d. ", Vec_PtrSize(vNodes) );
//ABC_PRT( "Time", clock() - clk );
// pProgress = Extra_ProgressBarStart( stdout, vNodes->nSize );
- Vec_PtrForEachEntry( vNodes, pNodeOld, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNodeOld, i )
{
// Extra_ProgressBarUpdate( pProgress, i, NULL );
pNodeOld->pCopy = Abc_NodeStrash( pNtkNew, pNodeOld, fRecord );
@@ -386,8 +389,8 @@ Abc_Obj_t * Abc_NodeStrash( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNodeOld, int fReco
assert( Abc_ObjIsNode(pNodeOld) );
assert( Abc_NtkHasAig(pNodeOld->pNtk) && !Abc_NtkIsStrash(pNodeOld->pNtk) );
// get the local AIG manager and the local root node
- pMan = pNodeOld->pNtk->pManFunc;
- pRoot = pNodeOld->pData;
+ pMan = (Hop_Man_t *)pNodeOld->pNtk->pManFunc;
+ pRoot = (Hop_Obj_t *)pNodeOld->pData;
// check the constant case
if ( Abc_NodeIsConst(pNodeOld) || Hop_Regular(pRoot) == Hop_ManConst1(pMan) )
return Abc_ObjNotCond( Abc_AigConst1(pNtkNew), Hop_IsComplement(pRoot) );
@@ -411,10 +414,10 @@ Abc_Obj_t * Abc_NodeStrash( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNodeOld, int fReco
Abc_ObjForEachFanin( pNodeOld, pFanin, i )
Hop_IthVar(pMan, i)->pData = pFanin->pCopy;
// strash the AIG of this node
- Abc_NodeStrash_rec( pNtkNew->pManFunc, Hop_Regular(pRoot) );
+ Abc_NodeStrash_rec( (Abc_Aig_t *)pNtkNew->pManFunc, Hop_Regular(pRoot) );
Hop_ConeUnmark_rec( Hop_Regular(pRoot) );
// return the final node
- return Abc_ObjNotCond( Hop_Regular(pRoot)->pData, Hop_IsComplement(pRoot) );
+ return Abc_ObjNotCond( (Abc_Obj_t *)Hop_Regular(pRoot)->pData, Hop_IsComplement(pRoot) );
}
@@ -443,7 +446,7 @@ Abc_Obj_t * Abc_NtkTopmost_rec( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNode, int Leve
return pNode->pCopy = Abc_NtkCreatePi( pNtkNew );
Abc_NtkTopmost_rec( pNtkNew, Abc_ObjFanin0(pNode), LevelCut );
Abc_NtkTopmost_rec( pNtkNew, Abc_ObjFanin1(pNode), LevelCut );
- return pNode->pCopy = Abc_AigAnd( pNtkNew->pManFunc, Abc_ObjChild0Copy(pNode), Abc_ObjChild1Copy(pNode) );
+ return pNode->pCopy = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, Abc_ObjChild0Copy(pNode), Abc_ObjChild1Copy(pNode) );
}
/**Function*************************************************************
@@ -532,7 +535,7 @@ Vec_Ptr_t * Abc_NodeGetSuper( Abc_Obj_t * pNode )
// explore the frontier
vFront = Vec_PtrAlloc( 100 );
Vec_PtrPush( vFront, pNode );
- Vec_PtrForEachEntry( vFront, pAnd, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vFront, pAnd, i )
{
pFanin = Abc_ObjChild0(pAnd);
if ( Abc_ObjIsNode(pFanin) && !Abc_ObjIsComplement(pFanin) && Abc_ObjFanoutNum(pFanin) == 1 )
@@ -549,12 +552,12 @@ Vec_Ptr_t * Abc_NodeGetSuper( Abc_Obj_t * pNode )
Vec_PtrFree( vFront );
// reverse the array of pointers to start with lower IDs
vFront = Vec_PtrAlloc( Vec_PtrSize(vSuper) );
- Vec_PtrForEachEntryReverse( vSuper, pNode, i )
+ Vec_PtrForEachEntryReverse( Abc_Obj_t *, vSuper, pNode, i )
Vec_PtrPush( vFront, pNode );
Vec_PtrFree( vSuper );
vSuper = vFront;
// uniquify and return the frontier
- Vec_PtrUniqify( vSuper, Vec_CompareNodeIds );
+ Vec_PtrUniqify( vSuper, (int (*)())Vec_CompareNodeIds );
return vSuper;
}
@@ -590,11 +593,11 @@ Abc_Ntk_t * Abc_NtkTopAnd( Abc_Ntk_t * pNtk )
Abc_NtkDupObj( pNtkAig, pObj, 1 );
// restrash the nodes reachable from the roots
vOrder = Abc_NtkDfsIterNodes( pNtk, vNodes );
- Vec_PtrForEachEntry( vOrder, pObj, i )
- pObj->pCopy = Abc_AigAnd( pNtkAig->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
+ Vec_PtrForEachEntry( Abc_Obj_t *, vOrder, pObj, i )
+ pObj->pCopy = Abc_AigAnd( (Abc_Aig_t *)pNtkAig->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
Vec_PtrFree( vOrder );
// finalize the network
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
{
pObjPo = Abc_NtkCreatePo(pNtkAig);
pDriver = Abc_ObjNotCond(Abc_ObjRegular(pObj)->pCopy, Abc_ObjIsComplement(pObj));
@@ -603,7 +606,7 @@ Abc_Ntk_t * Abc_NtkTopAnd( Abc_Ntk_t * pNtk )
}
Vec_PtrFree( vNodes );
// perform cleanup if requested
- if ( (nNodes = Abc_AigCleanup(pNtkAig->pManFunc)) )
+ if ( (nNodes = Abc_AigCleanup((Abc_Aig_t *)pNtkAig->pManFunc)) )
printf( "Abc_NtkTopAnd(): AIG cleanup removed %d nodes (this is a bug).\n", nNodes );
// make sure everything is okay
if ( !Abc_NtkCheck( pNtkAig ) )
@@ -615,8 +618,85 @@ Abc_Ntk_t * Abc_NtkTopAnd( Abc_Ntk_t * pNtk )
return pNtkAig;
}
+/**Function*************************************************************
+
+ Synopsis [Writes the AIG into a file for parsing.]
+
+ Description [Ordering: c0, pis, ands, pos. ]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Abc_NtkWriteAig( Abc_Ntk_t * pNtk, char * pFileName )
+{
+ FILE * pFile;
+ Vec_Int_t * vId2Num;
+ Abc_Obj_t * pObj;
+ int i, iLit;
+ assert( Abc_NtkIsStrash(pNtk) );
+ assert( Abc_NtkLatchNum(pNtk) == 0 );
+ if ( pFileName == NULL )
+ pFile = stdout;
+ else
+ pFile = fopen( pFileName, "w" );
+ if ( pFile == NULL )
+ {
+ printf( "Cannot open output file.\n" );
+ return;
+ }
+ vId2Num = Vec_IntAlloc( 2*Abc_NtkObjNumMax(pNtk) );
+ Vec_IntFill( vId2Num, 2*Abc_NtkObjNumMax(pNtk), -1 );
+
+ iLit = 0;
+ Vec_IntWriteEntry( vId2Num, 2*Abc_ObjId(Abc_AigConst1(pNtk))+1, iLit++ );
+ Vec_IntWriteEntry( vId2Num, 2*Abc_ObjId(Abc_AigConst1(pNtk))+0, iLit++ );
+ Abc_NtkForEachPi( pNtk, pObj, i )
+ {
+ Vec_IntWriteEntry( vId2Num, 2*Abc_ObjId(pObj)+0, iLit++ );
+ Vec_IntWriteEntry( vId2Num, 2*Abc_ObjId(pObj)+1, iLit++ );
+ }
+ Abc_AigForEachAnd( pNtk, pObj, i )
+ {
+ Vec_IntWriteEntry( vId2Num, 2*Abc_ObjId(pObj)+0, iLit++ );
+ Vec_IntWriteEntry( vId2Num, 2*Abc_ObjId(pObj)+1, iLit++ );
+ }
+ fprintf( pFile, "{\n" );
+ fprintf( pFile, " \"%s\", ", Abc_NtkName(pNtk) );
+ fprintf( pFile, "// pi=%d po=%d and=%d", Abc_NtkPiNum(pNtk), Abc_NtkPoNum(pNtk), Abc_NtkNodeNum(pNtk) );
+ fprintf( pFile, "\n" );
+ fprintf( pFile, " { " );
+ Abc_NtkForEachPi( pNtk, pObj, i )
+ fprintf( pFile, "\"%s\",", Abc_ObjName(pObj) );
+ fprintf( pFile, "NULL },\n" );
+ fprintf( pFile, " { " );
+ Abc_NtkForEachPo( pNtk, pObj, i )
+ fprintf( pFile, "\"%s\",", Abc_ObjName(pObj) );
+ fprintf( pFile, "NULL },\n" );
+ fprintf( pFile, " { " );
+ Abc_AigForEachAnd( pNtk, pObj, i )
+ fprintf( pFile, "%d,", Vec_IntEntry(vId2Num, 2*Abc_ObjFaninId0(pObj) + Abc_ObjFaninC0(pObj)) );
+ fprintf( pFile, "0 },\n" );
+ fprintf( pFile, " { " );
+ Abc_AigForEachAnd( pNtk, pObj, i )
+ fprintf( pFile, "%d,", Vec_IntEntry(vId2Num, 2*Abc_ObjFaninId1(pObj) + Abc_ObjFaninC1(pObj)) );
+ fprintf( pFile, "0 },\n" );
+ fprintf( pFile, " { " );
+ Abc_NtkForEachPo( pNtk, pObj, i )
+ fprintf( pFile, "%d,", Vec_IntEntry(vId2Num, 2*Abc_ObjFaninId0(pObj) + Abc_ObjFaninC0(pObj)) );
+ fprintf( pFile, "0 },\n" );
+ fprintf( pFile, "},\n" );
+ if ( pFile != stdout )
+ fclose( pFile );
+ Vec_IntFree( vId2Num );
+}
+
+
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcSweep.c b/src/base/abci/abcSweep.c
index dfb8137c..57706af0 100644
--- a/src/base/abci/abcSweep.c
+++ b/src/base/abci/abcSweep.c
@@ -19,22 +19,26 @@
***********************************************************************/
#include "abc.h"
+#include "main.h"
#include "fraig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
static void Abc_NtkFraigSweepUsingExdc( Fraig_Man_t * pMan, Abc_Ntk_t * pNtk );
static stmm_table * Abc_NtkFraigEquiv( Abc_Ntk_t * pNtk, int fUseInv, int fVerbose, int fVeryVerbose );
-static void Abc_NtkFraigTransform( Abc_Ntk_t * pNtk, stmm_table * tEquiv, int fUseInv, bool fVerbose );
+static void Abc_NtkFraigTransform( Abc_Ntk_t * pNtk, stmm_table * tEquiv, int fUseInv, int fVerbose );
static void Abc_NtkFraigMergeClassMapped( Abc_Ntk_t * pNtk, Abc_Obj_t * pChain, int fUseInv, int fVerbose );
static void Abc_NtkFraigMergeClass( Abc_Ntk_t * pNtk, Abc_Obj_t * pChain, int fUseInv, int fVerbose );
static int Abc_NodeDroppingCost( Abc_Obj_t * pNode );
static int Abc_NtkReduceNodes( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes );
static void Abc_NodeSweep( Abc_Obj_t * pNode, int fVerbose );
-static void Abc_NodeConstantInput( Abc_Obj_t * pNode, Abc_Obj_t * pFanin, bool fConst0 );
+static void Abc_NodeConstantInput( Abc_Obj_t * pNode, Abc_Obj_t * pFanin, int fConst0 );
static void Abc_NodeComplementInput( Abc_Obj_t * pNode, Abc_Obj_t * pFanin );
////////////////////////////////////////////////////////////////////////
@@ -54,7 +58,7 @@ static void Abc_NodeComplementInput( Abc_Obj_t * pNode, Abc_Obj_t * pF
SeeAlso []
***********************************************************************/
-bool Abc_NtkFraigSweep( Abc_Ntk_t * pNtk, int fUseInv, int fExdc, int fVerbose, int fVeryVerbose )
+int Abc_NtkFraigSweep( Abc_Ntk_t * pNtk, int fUseInv, int fExdc, int fVerbose, int fVeryVerbose )
{
Fraig_Params_t Params;
Abc_Ntk_t * pNtkAig;
@@ -71,15 +75,15 @@ bool Abc_NtkFraigSweep( Abc_Ntk_t * pNtk, int fUseInv, int fExdc, int fVerbose,
{
fUseTrick = 1;
Abc_NtkForEachNode( pNtk, pObj, i )
- pObj->pNext = pObj->pData;
+ pObj->pNext = (Abc_Obj_t *)pObj->pData;
}
// derive the AIG
pNtkAig = Abc_NtkStrash( pNtk, 0, 1, 0 );
// reconstruct gate assignments
if ( fUseTrick )
{
- extern void * Abc_FrameReadLibGen();
- Hop_ManStop( pNtk->pManFunc );
+// extern void * Abc_FrameReadLibGen();
+ Hop_ManStop( (Hop_Man_t *)pNtk->pManFunc );
pNtk->pManFunc = Abc_FrameReadLibGen();
pNtk->ntkFunc = ABC_FUNC_MAP;
Abc_NtkForEachNode( pNtk, pObj, i )
@@ -89,7 +93,7 @@ bool Abc_NtkFraigSweep( Abc_Ntk_t * pNtk, int fUseInv, int fExdc, int fVerbose,
// perform fraiging of the AIG
Fraig_ParamsSetDefault( &Params );
Params.fInternal = 1;
- pMan = Abc_NtkToFraig( pNtkAig, &Params, 0, 0 );
+ pMan = (Fraig_Man_t *)Abc_NtkToFraig( pNtkAig, &Params, 0, 0 );
// cannot use EXDC with FRAIG because it can create classes of equivalent FRAIG nodes
// with representative nodes that do not correspond to the nodes with the current network
@@ -163,11 +167,11 @@ void Abc_NtkFraigSweepUsingExdc( Fraig_Man_t * pMan, Abc_Ntk_t * pNtk )
if ( pNodeAig == NULL )
continue;
// get the FRAIG node
- gNode = Fraig_NotCond( Abc_ObjRegular(pNodeAig)->pCopy, Abc_ObjIsComplement(pNodeAig) );
+ gNode = Fraig_NotCond( Abc_ObjRegular(pNodeAig)->pCopy, (int)Abc_ObjIsComplement(pNodeAig) );
// perform ANDing with EXDC
gNodeRes = Fraig_NodeAnd( pMan, gNode, Fraig_Not(gNodeExdc) );
// write the node back
- Abc_ObjRegular(pNodeAig)->pCopy = (Abc_Obj_t *)Fraig_NotCond( gNodeRes, Abc_ObjIsComplement(pNodeAig) );
+ Abc_ObjRegular(pNodeAig)->pCopy = (Abc_Obj_t *)Fraig_NotCond( gNodeRes, (int)Abc_ObjIsComplement(pNodeAig) );
}
}
@@ -208,7 +212,7 @@ stmm_table * Abc_NtkFraigEquiv( Abc_Ntk_t * pNtk, int fUseInv, int fVerbose, int
if ( Abc_NodeFindCoFanout(pNode) )
continue;
// get the FRAIG node
- gNode = Fraig_NotCond( Abc_ObjRegular(pNodeAig)->pCopy, Abc_ObjIsComplement(pNodeAig) );
+ gNode = Fraig_NotCond( Abc_ObjRegular(pNodeAig)->pCopy, (int)Abc_ObjIsComplement(pNodeAig) );
if ( !stmm_find_or_add( tStrash2Net, (char *)Fraig_Regular(gNode), (char ***)&ppSlot ) )
*ppSlot = NULL;
// add the node to the list
@@ -269,7 +273,7 @@ stmm_table * Abc_NtkFraigEquiv( Abc_Ntk_t * pNtk, int fUseInv, int fVerbose, int
SeeAlso []
***********************************************************************/
-void Abc_NtkFraigTransform( Abc_Ntk_t * pNtk, stmm_table * tEquiv, int fUseInv, bool fVerbose )
+void Abc_NtkFraigTransform( Abc_Ntk_t * pNtk, stmm_table * tEquiv, int fUseInv, int fVerbose )
{
stmm_generator * gen;
Abc_Obj_t * pList;
@@ -501,7 +505,7 @@ int Abc_NtkReduceNodes( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes )
int i, Counter;
assert( Abc_NtkIsLogic(pNtk) );
// mark the nodes reachable from the POs
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
pNode->fMarkA = 1;
// remove the non-marked nodes
Counter = 0;
@@ -512,7 +516,7 @@ int Abc_NtkReduceNodes( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes )
Counter++;
}
// unmark the remaining nodes
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
pNode->fMarkA = 0;
// check
if ( !Abc_NtkCheck( pNtk ) )
@@ -561,7 +565,7 @@ int Abc_NtkSweep( Abc_Ntk_t * pNtk, int fVerbose )
while ( Vec_PtrSize(vNodes) > 0 )
{
// get any sweepable node
- pNode = Vec_PtrPop(vNodes);
+ pNode = (Abc_Obj_t *)Vec_PtrPop(vNodes);
if ( !Abc_ObjIsNode(pNode) )
continue;
// get any non-CO fanout of this node
@@ -629,9 +633,9 @@ int Abc_NtkSweep( Abc_Ntk_t * pNtk, int fVerbose )
SeeAlso []
***********************************************************************/
-void Abc_NodeConstantInput( Abc_Obj_t * pNode, Abc_Obj_t * pFanin, bool fConst0 )
+void Abc_NodeConstantInput( Abc_Obj_t * pNode, Abc_Obj_t * pFanin, int fConst0 )
{
- DdManager * dd = pNode->pNtk->pManFunc;
+ DdManager * dd = (DdManager *)pNode->pNtk->pManFunc;
DdNode * bVar, * bTemp;
int iFanin;
assert( Abc_NtkIsBddLogic(pNode->pNtk) );
@@ -642,7 +646,7 @@ void Abc_NodeConstantInput( Abc_Obj_t * pNode, Abc_Obj_t * pFanin, bool fConst0
return;
}
bVar = Cudd_NotCond( Cudd_bddIthVar(dd, iFanin), fConst0 );
- pNode->pData = Cudd_Cofactor( dd, bTemp = pNode->pData, bVar ); Cudd_Ref( pNode->pData );
+ pNode->pData = Cudd_Cofactor( dd, bTemp = (DdNode *)pNode->pData, bVar ); Cudd_Ref( (DdNode *)pNode->pData );
Cudd_RecursiveDeref( dd, bTemp );
}
@@ -659,7 +663,7 @@ void Abc_NodeConstantInput( Abc_Obj_t * pNode, Abc_Obj_t * pFanin, bool fConst0
***********************************************************************/
void Abc_NodeComplementInput( Abc_Obj_t * pNode, Abc_Obj_t * pFanin )
{
- DdManager * dd = pNode->pNtk->pManFunc;
+ DdManager * dd = (DdManager *)pNode->pNtk->pManFunc;
DdNode * bVar, * bCof0, * bCof1;
int iFanin;
assert( Abc_NtkIsBddLogic(pNode->pNtk) );
@@ -670,10 +674,10 @@ void Abc_NodeComplementInput( Abc_Obj_t * pNode, Abc_Obj_t * pFanin )
return;
}
bVar = Cudd_bddIthVar( dd, iFanin );
- bCof0 = Cudd_Cofactor( dd, pNode->pData, Cudd_Not(bVar) ); Cudd_Ref( bCof0 );
- bCof1 = Cudd_Cofactor( dd, pNode->pData, bVar ); Cudd_Ref( bCof1 );
- Cudd_RecursiveDeref( dd, pNode->pData );
- pNode->pData = Cudd_bddIte( dd, bVar, bCof0, bCof1 ); Cudd_Ref( pNode->pData );
+ bCof0 = Cudd_Cofactor( dd, (DdNode *)pNode->pData, Cudd_Not(bVar) ); Cudd_Ref( bCof0 );
+ bCof1 = Cudd_Cofactor( dd, (DdNode *)pNode->pData, bVar ); Cudd_Ref( bCof1 );
+ Cudd_RecursiveDeref( dd, (DdNode *)pNode->pData );
+ pNode->pData = Cudd_bddIte( dd, bVar, bCof0, bCof1 ); Cudd_Ref( (DdNode *)pNode->pData );
Cudd_RecursiveDeref( dd, bCof0 );
Cudd_RecursiveDeref( dd, bCof1 );
}
@@ -835,7 +839,7 @@ int Abc_NtkLatchSweep( Abc_Ntk_t * pNtk )
/**Function*************************************************************
- Synopsis [Replaces autonumnous logic by ABC_FREE inputs.]
+ Synopsis [Replaces autonumnous logic by free inputs.]
Description [Assumes that non-autonomous logic is marked with
the current ID.]
@@ -874,9 +878,9 @@ int Abc_NtkReplaceAutonomousLogic( Abc_Ntk_t * pNtk )
Vec_PtrPush( vNodes, pFanin );
}
}
- Vec_PtrUniqify( vNodes, Abc_ObjPointerCompare );
+ Vec_PtrUniqify( vNodes, (int (*)(void))Abc_ObjPointerCompare );
// replace these nodes by the PIs
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
{
pFanin = Abc_NtkCreatePi(pNtk);
Abc_ObjAssignName( pFanin, Abc_ObjName(pFanin), NULL );
@@ -947,3 +951,5 @@ int Abc_NtkCleanupSeq( Abc_Ntk_t * pNtk, int fLatchSweep, int fAutoSweep, int fV
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcSymm.c b/src/base/abci/abcSymm.c
index 73f238f9..4e0a7373 100644
--- a/src/base/abci/abcSymm.c
+++ b/src/base/abci/abcSymm.c
@@ -19,6 +19,10 @@
***********************************************************************/
#include "abc.h"
+#include "sim.h"
+
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -65,7 +69,7 @@ void Abc_NtkSymmetries( Abc_Ntk_t * pNtk, int fUseBdds, int fNaive, int fReorder
***********************************************************************/
void Abc_NtkSymmetriesUsingSandS( Abc_Ntk_t * pNtk, int fVerbose )
{
- extern int Sim_ComputeTwoVarSymms( Abc_Ntk_t * pNtk, int fVerbose );
+// extern int Sim_ComputeTwoVarSymms( Abc_Ntk_t * pNtk, int fVerbose );
int nSymms = Sim_ComputeTwoVarSymms( pNtk, fVerbose );
printf( "The total number of symmetries is %d.\n", nSymms );
}
@@ -227,3 +231,5 @@ void Ntk_NetworkSymmsPrint( Abc_Ntk_t * pNtk, Extra_SymmInfo_t * pSymms )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcTiming.c b/src/base/abci/abcTiming.c
index 95c7103a..79768645 100644
--- a/src/base/abci/abcTiming.c
+++ b/src/base/abci/abcTiming.c
@@ -22,6 +22,9 @@
#include "main.h"
#include "mio.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -42,8 +45,8 @@ void Abc_NtkTimePrepare( Abc_Ntk_t * pNtk );
void Abc_NodeDelayTraceArrival( Abc_Obj_t * pNode );
// accessing the arrival and required times of a node
-static inline Abc_Time_t * Abc_NodeArrival( Abc_Obj_t * pNode ) { return pNode->pNtk->pManTime->vArrs->pArray[pNode->Id]; }
-static inline Abc_Time_t * Abc_NodeRequired( Abc_Obj_t * pNode ) { return pNode->pNtk->pManTime->vReqs->pArray[pNode->Id]; }
+static inline Abc_Time_t * Abc_NodeArrival( Abc_Obj_t * pNode ) { return (Abc_Time_t *)pNode->pNtk->pManTime->vArrs->pArray[pNode->Id]; }
+static inline Abc_Time_t * Abc_NodeRequired( Abc_Obj_t * pNode ) { return (Abc_Time_t *)pNode->pNtk->pManTime->vReqs->pArray[pNode->Id]; }
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
@@ -183,7 +186,7 @@ void Abc_NtkTimeSetArrival( Abc_Ntk_t * pNtk, int ObjId, float Rise, float Fall
Abc_ManTimeExpand( pNtk->pManTime, ObjId + 1, 1 );
// set the arrival time
vTimes = pNtk->pManTime->vArrs;
- pTime = vTimes->pArray[ObjId];
+ pTime = (Abc_Time_t *)vTimes->pArray[ObjId];
pTime->Rise = Rise;
pTime->Fall = Fall;
pTime->Worst = ABC_MAX( Rise, Fall );
@@ -211,7 +214,7 @@ void Abc_NtkTimeSetRequired( Abc_Ntk_t * pNtk, int ObjId, float Rise, float Fall
Abc_ManTimeExpand( pNtk->pManTime, ObjId + 1, 1 );
// set the required time
vTimes = pNtk->pManTime->vReqs;
- pTime = vTimes->pArray[ObjId];
+ pTime = (Abc_Time_t *)vTimes->pArray[ObjId];
pTime->Rise = Rise;
pTime->Fall = Fall;
pTime->Worst = ABC_MAX( Rise, Fall );
@@ -419,13 +422,13 @@ void Abc_ManTimeExpand( Abc_ManTime_t * p, int nSize, int fProgressive )
vTimes = p->vArrs;
Vec_PtrGrow( vTimes, nSizeNew );
vTimes->nSize = nSizeNew;
- ppTimesOld = ( nSizeOld == 0 )? NULL : vTimes->pArray[0];
+ ppTimesOld = ( nSizeOld == 0 )? NULL : (Abc_Time_t *)vTimes->pArray[0];
ppTimes = ABC_REALLOC( Abc_Time_t, ppTimesOld, nSizeNew );
for ( i = 0; i < nSizeNew; i++ )
vTimes->pArray[i] = ppTimes + i;
for ( i = nSizeOld; i < nSizeNew; i++ )
{
- pTime = vTimes->pArray[i];
+ pTime = (Abc_Time_t *)vTimes->pArray[i];
pTime->Rise = -ABC_INFINITY;
pTime->Fall = -ABC_INFINITY;
pTime->Worst = -ABC_INFINITY;
@@ -434,13 +437,13 @@ void Abc_ManTimeExpand( Abc_ManTime_t * p, int nSize, int fProgressive )
vTimes = p->vReqs;
Vec_PtrGrow( vTimes, nSizeNew );
vTimes->nSize = nSizeNew;
- ppTimesOld = ( nSizeOld == 0 )? NULL : vTimes->pArray[0];
+ ppTimesOld = ( nSizeOld == 0 )? NULL : (Abc_Time_t *)vTimes->pArray[0];
ppTimes = ABC_REALLOC( Abc_Time_t, ppTimesOld, nSizeNew );
for ( i = 0; i < nSizeNew; i++ )
vTimes->pArray[i] = ppTimes + i;
for ( i = nSizeOld; i < nSizeNew; i++ )
{
- pTime = vTimes->pArray[i];
+ pTime = (Abc_Time_t *)vTimes->pArray[i];
pTime->Rise = -ABC_INFINITY;
pTime->Fall = -ABC_INFINITY;
pTime->Worst = -ABC_INFINITY;
@@ -470,9 +473,9 @@ void Abc_NtkSetNodeLevelsArrival( Abc_Ntk_t * pNtkOld )
int i;
if ( pNtkOld->pManTime == NULL )
return;
- if ( Mio_LibraryReadNand2(Abc_FrameReadLibGen()) == NULL )
+ if ( Mio_LibraryReadNand2((Mio_Library_t *)Abc_FrameReadLibGen()) == NULL )
return;
- tAndDelay = Mio_LibraryReadDelayNand2Max(Abc_FrameReadLibGen());
+ tAndDelay = Mio_LibraryReadDelayNand2Max((Mio_Library_t *)Abc_FrameReadLibGen());
Abc_NtkForEachPi( pNtkOld, pNodeOld, i )
{
pNodeNew = pNodeOld->pCopy;
@@ -558,7 +561,7 @@ float Abc_NtkDelayTrace( Abc_Ntk_t * pNtk )
Abc_NtkTimePrepare( pNtk );
vNodes = Abc_NtkDfs( pNtk, 1 );
for ( i = 0; i < vNodes->nSize; i++ )
- Abc_NodeDelayTraceArrival( vNodes->pArray[i] );
+ Abc_NodeDelayTraceArrival( (Abc_Obj_t *)vNodes->pArray[i] );
Vec_PtrFree( vNodes );
// get the latest arrival times
@@ -597,7 +600,7 @@ void Abc_NodeDelayTraceArrival( Abc_Obj_t * pNode )
pTimeOut = Abc_NodeArrival(pNode);
pTimeOut->Rise = pTimeOut->Fall = -ABC_INFINITY;
// go through the pins of the gate
- pPin = Mio_GateReadPins(pNode->pData);
+ pPin = Mio_GateReadPins((Mio_Gate_t *)pNode->pData);
Abc_ObjForEachFanin( pNode, pFanin, i )
{
pTimeIn = Abc_NodeArrival(pFanin);
@@ -755,7 +758,7 @@ void Abc_NtkStartReverseLevels( Abc_Ntk_t * pNtk, int nMaxLevelIncrease )
Vec_IntFill( pNtk->vLevelsR, 1 + Abc_NtkObjNumMax(pNtk), 0 );
// compute levels in reverse topological order
vNodes = Abc_NtkDfsReverse( pNtk );
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
Abc_ObjSetReverseLevel( pObj, Abc_ObjReverseLevelNew(pObj) );
Vec_PtrFree( vNodes );
}
@@ -807,7 +810,7 @@ void Abc_NtkUpdateLevel( Abc_Obj_t * pObjNew, Vec_Vec_t * vLevels )
Vec_VecPush( vLevels, LevelOld, pObjNew );
pObjNew->fMarkA = 1;
// recursively update level
- Vec_VecForEachEntryStart( vLevels, pTemp, Lev, k, LevelOld )
+ Vec_VecForEachEntryStart( Abc_Obj_t *, vLevels, pTemp, Lev, k, LevelOld )
{
// Counter--;
pTemp->fMarkA = 0;
@@ -858,7 +861,7 @@ void Abc_NtkUpdateReverseLevel( Abc_Obj_t * pObjNew, Vec_Vec_t * vLevels )
Vec_VecPush( vLevels, LevelOld, pObjNew );
pObjNew->fMarkA = 1;
// recursively update level
- Vec_VecForEachEntryStart( vLevels, pTemp, Lev, k, LevelOld )
+ Vec_VecForEachEntryStart( Abc_Obj_t *, vLevels, pTemp, Lev, k, LevelOld )
{
pTemp->fMarkA = 0;
LevelOld = Abc_ObjReverseLevel(pTemp);
@@ -908,3 +911,5 @@ void Abc_NtkUpdate( Abc_Obj_t * pObj, Abc_Obj_t * pObjNew, Vec_Vec_t * vLevels )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcUnate.c b/src/base/abci/abcUnate.c
index f6ee57ca..b77eec63 100644
--- a/src/base/abci/abcUnate.c
+++ b/src/base/abci/abcUnate.c
@@ -20,6 +20,9 @@
#include "abc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -153,3 +156,5 @@ void Abc_NtkPrintUnateSat( Abc_Ntk_t * pNtk, int fVerbose )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcUnreach.c b/src/base/abci/abcUnreach.c
index 251d3953..ae7fbd02 100644
--- a/src/base/abci/abcUnreach.c
+++ b/src/base/abci/abcUnreach.c
@@ -20,13 +20,16 @@
#include "abc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
static DdNode * Abc_NtkTransitionRelation( DdManager * dd, Abc_Ntk_t * pNtk, int fVerbose );
static DdNode * Abc_NtkInitStateAndVarMap( DdManager * dd, Abc_Ntk_t * pNtk, int fVerbose );
-static DdNode * Abc_NtkComputeUnreachable( DdManager * dd, Abc_Ntk_t * pNtk, DdNode * bRelation, DdNode * bInitial, bool fVerbose );
+static DdNode * Abc_NtkComputeUnreachable( DdManager * dd, Abc_Ntk_t * pNtk, DdNode * bRelation, DdNode * bInitial, int fVerbose );
static Abc_Ntk_t * Abc_NtkConstructExdc ( DdManager * dd, Abc_Ntk_t * pNtk, DdNode * bUnreach );
////////////////////////////////////////////////////////////////////////
@@ -44,7 +47,7 @@ static Abc_Ntk_t * Abc_NtkConstructExdc ( DdManager * dd, Abc_Ntk_t * pNtk,
SeeAlso []
***********************************************************************/
-int Abc_NtkExtractSequentialDcs( Abc_Ntk_t * pNtk, bool fVerbose )
+int Abc_NtkExtractSequentialDcs( Abc_Ntk_t * pNtk, int fVerbose )
{
int fReorder = 1;
DdManager * dd;
@@ -217,7 +220,7 @@ DdNode * Abc_NtkInitStateAndVarMap( DdManager * dd, Abc_Ntk_t * pNtk, int fVerbo
SeeAlso []
***********************************************************************/
-DdNode * Abc_NtkComputeUnreachable( DdManager * dd, Abc_Ntk_t * pNtk, DdNode * bTrans, DdNode * bInitial, bool fVerbose )
+DdNode * Abc_NtkComputeUnreachable( DdManager * dd, Abc_Ntk_t * pNtk, DdNode * bTrans, DdNode * bInitial, int fVerbose )
{
DdNode * bRelation, * bReached, * bCubeCs;
DdNode * bCurrent, * bNext, * bTemp;
@@ -308,7 +311,7 @@ Abc_Ntk_t * Abc_NtkConstructExdc( DdManager * dd, Abc_Ntk_t * pNtk, DdNode * bUn
Abc_NtkForEachLatch( pNtk, pNode, i )
pPermute[Abc_NtkPiNum(pNtk) + i] = i;
// remap the functions
- pNodeNew->pData = Extra_TransferPermute( dd, pNtkNew->pManFunc, bUnreach, pPermute ); Cudd_Ref( pNodeNew->pData );
+ pNodeNew->pData = Extra_TransferPermute( dd, (DdManager *)pNtkNew->pManFunc, bUnreach, pPermute ); Cudd_Ref( (DdNode *)pNodeNew->pData );
ABC_FREE( pPermute );
Abc_NodeMinimumBase( pNodeNew );
@@ -327,7 +330,7 @@ Abc_Ntk_t * Abc_NtkConstructExdc( DdManager * dd, Abc_Ntk_t * pNtk, DdNode * bUn
Abc_ObjAddFanin( pNode->pCopy, pNodeNew );
// remove the extra nodes
- Abc_AigCleanup( pNtkNew->pManFunc );
+ Abc_AigCleanup( (Abc_Aig_t *)pNtkNew->pManFunc );
// fix the problem with complemented and duplicated CO edges
Abc_NtkLogicMakeSimpleCos( pNtkNew, 0 );
@@ -347,3 +350,5 @@ Abc_Ntk_t * Abc_NtkConstructExdc( DdManager * dd, Abc_Ntk_t * pNtk, DdNode * bUn
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcVerify.c b/src/base/abci/abcVerify.c
index 424c26ec..58b8fbb8 100644
--- a/src/base/abci/abcVerify.c
+++ b/src/base/abci/abcVerify.c
@@ -19,8 +19,16 @@
***********************************************************************/
#include "abc.h"
+#include "main.h"
+#include "cmd.h"
#include "fraig.h"
#include "sim.h"
+#include "aig.h"
+#include "gia.h"
+#include "ssw.h"
+
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -151,7 +159,7 @@ void Abc_NtkCecFraig( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nSeconds, int fV
// Params.fFuncRed = 0;
// Params.nPatsRand = 0;
// Params.nPatsDyna = 0;
- pMan = Abc_NtkToFraig( pMiter, &Params, 0, 0 );
+ pMan = (Fraig_Man_t *)Abc_NtkToFraig( pMiter, &Params, 0, 0 );
Fraig_ManProveMiter( pMan );
// analyze the result
@@ -209,9 +217,6 @@ void Abc_NtkCecFraig( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nSeconds, int fV
***********************************************************************/
void Abc_NtkCecFraigPart( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nSeconds, int nPartSize, int fVerbose )
{
- extern int Cmd_CommandExecute( void * pAbc, char * sCommand );
- extern void * Abc_FrameGetGlobalFrame();
-
Prove_Params_t Params, * pParams = &Params;
Abc_Ntk_t * pMiter, * pMiterPart;
Abc_Obj_t * pObj;
@@ -327,8 +332,6 @@ void Abc_NtkCecFraigPartAuto( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nSeconds
extern int Abc_NtkCombinePos( Abc_Ntk_t * pNtk, int fAnd );
extern Vec_Ptr_t * Abc_NtkPartitionSmart( Abc_Ntk_t * pNtk, int nPartSizeLimit, int fVerbose );
extern void Abc_NtkConvertCos( Abc_Ntk_t * pNtk, Vec_Int_t * vOuts, Vec_Ptr_t * vOnePtr );
- extern int Cmd_CommandExecute( void * pAbc, char * sCommand );
- extern void * Abc_FrameGetGlobalFrame();
Vec_Ptr_t * vParts, * vOnePtr;
Vec_Int_t * vOne;
@@ -375,7 +378,7 @@ void Abc_NtkCecFraigPartAuto( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nSeconds
Status = 1;
nOutputs = 0;
vOnePtr = Vec_PtrAlloc( 1000 );
- Vec_PtrForEachEntry( vParts, vOne, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vParts, vOne, i )
{
// get this part of the miter
Abc_NtkConvertCos( pMiter, vOne, vOnePtr );
@@ -596,7 +599,7 @@ int Abc_NtkSecFraig( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nSeconds, int nFr
// Params.fFuncRed = 0;
// Params.nPatsRand = 0;
// Params.nPatsDyna = 0;
- pMan = Abc_NtkToFraig( pFrames, &Params, 0, 0 );
+ pMan = (Fraig_Man_t *)Abc_NtkToFraig( pFrames, &Params, 0, 0 );
Fraig_ManProveMiter( pMan );
// analyze the result
@@ -667,20 +670,20 @@ int * Abc_NtkVerifySimulatePattern( Abc_Ntk_t * pNtk, int * pModel )
// increment the trav ID
Abc_NtkIncrementTravId( pNtk );
// set the CI values
- Abc_AigConst1(pNtk)->pCopy = (void *)1;
+ Abc_AigConst1(pNtk)->pCopy = (Abc_Obj_t *)1;
Abc_NtkForEachCi( pNtk, pNode, i )
- pNode->pCopy = (void *)(ABC_PTRINT_T)pModel[i];
+ pNode->pCopy = (Abc_Obj_t *)(ABC_PTRINT_T)pModel[i];
// simulate in the topological order
Abc_NtkForEachNode( pNtk, pNode, i )
{
- Value0 = ((int)(ABC_PTRINT_T)Abc_ObjFanin0(pNode)->pCopy) ^ Abc_ObjFaninC0(pNode);
- Value1 = ((int)(ABC_PTRINT_T)Abc_ObjFanin1(pNode)->pCopy) ^ Abc_ObjFaninC1(pNode);
- pNode->pCopy = (void *)(ABC_PTRINT_T)(Value0 & Value1);
+ Value0 = ((int)(ABC_PTRINT_T)Abc_ObjFanin0(pNode)->pCopy) ^ (int)Abc_ObjFaninC0(pNode);
+ Value1 = ((int)(ABC_PTRINT_T)Abc_ObjFanin1(pNode)->pCopy) ^ (int)Abc_ObjFaninC1(pNode);
+ pNode->pCopy = (Abc_Obj_t *)(ABC_PTRINT_T)(Value0 & Value1);
}
// fill the output values
pValues = ABC_ALLOC( int, Abc_NtkCoNum(pNtk) );
Abc_NtkForEachCo( pNtk, pNode, i )
- pValues[i] = ((int)(ABC_PTRINT_T)Abc_ObjFanin0(pNode)->pCopy) ^ Abc_ObjFaninC0(pNode);
+ pValues[i] = ((int)(ABC_PTRINT_T)Abc_ObjFanin0(pNode)->pCopy) ^ (int)Abc_ObjFaninC0(pNode);
if ( fStrashed )
Abc_NtkDelete( pNtk );
return pValues;
@@ -740,12 +743,12 @@ void Abc_NtkVerifyReportError( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int * pMode
vNodes = Abc_NtkNodeSupport( pNtk1, &pNode, 1 );
// set the PI numbers
Abc_NtkForEachCi( pNtk1, pNode, i )
- pNode->pCopy = (void*)(ABC_PTRINT_T)i;
+ pNode->pCopy = (Abc_Obj_t *)(ABC_PTRINT_T)i;
// print the model
- pNode = Vec_PtrEntry( vNodes, 0 );
+ pNode = (Abc_Obj_t *)Vec_PtrEntry( vNodes, 0 );
if ( Abc_ObjIsCi(pNode) )
{
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
{
assert( Abc_ObjIsCi(pNode) );
printf( " %s=%d", Abc_ObjName(pNode), pModel[(int)(ABC_PTRINT_T)pNode->pCopy] );
@@ -787,18 +790,18 @@ void Abc_NtkGetSeqPoSupp( Abc_Ntk_t * pNtk, int iFrame, int iNumPo )
// mark the support of the frames
Abc_NtkForEachCi( pFrames, pObj, i )
pObj->pCopy = NULL;
- Vec_PtrForEachEntry( vSupp, pObj, i )
- pObj->pCopy = (void *)1;
+ Vec_PtrForEachEntry( Abc_Obj_t *, vSupp, pObj, i )
+ pObj->pCopy = (Abc_Obj_t *)1;
// mark the support of the network if the support of the timeframes is marked
Abc_NtkForEachCi( pNtk, pObj, i )
pObj->pCopy = NULL;
Abc_NtkForEachLatch( pNtk, pObj, i )
if ( Abc_NtkBox(pFrames, i)->pCopy )
- pObj->pCopy = (void *)1;
+ pObj->pCopy = (Abc_Obj_t *)1;
Abc_NtkForEachPi( pNtk, pObj, i )
for ( k = 0; k <= iFrame; k++ )
if ( Abc_NtkPi(pFrames, k*Abc_NtkPiNum(pNtk) + i)->pCopy )
- pObj->pCopy = (void *)1;
+ pObj->pCopy = (Abc_Obj_t *)1;
// free stuff
Vec_PtrFree( vSupp );
Abc_NtkDelete( pFrames );
@@ -1012,8 +1015,60 @@ void Abc_NtkSimulteBuggyMiter( Abc_Ntk_t * pNtk )
}
+/**Function*************************************************************
+
+ Synopsis [Returns the PO values under the given input pattern.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_NtkIsTrueCex( Abc_Ntk_t * pNtk, Abc_Cex_t * pCex )
+{
+ extern Aig_Man_t * Abc_NtkToDar( Abc_Ntk_t * pNtk, int fExors, int fRegisters );
+// extern int Ssw_SmlRunCounterExample( Aig_Man_t * pAig, Abc_Cex_t * p );
+ Aig_Man_t * pMan;
+ int status, fStrashed = 0;
+ if ( !Abc_NtkIsStrash(pNtk) )
+ {
+ pNtk = Abc_NtkStrash(pNtk, 0, 0, 0);
+ fStrashed = 1;
+ }
+ pMan = Abc_NtkToDar( pNtk, 0, 1 );
+ if ( pMan )
+ {
+ status = Ssw_SmlRunCounterExample( pMan, pCex );
+ Aig_ManStop( pMan );
+ }
+ if ( fStrashed )
+ Abc_NtkDelete( pNtk );
+ return status;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns 1 if the number of PIs matches.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_NtkIsValidCex( Abc_Ntk_t * pNtk, Abc_Cex_t * pCex )
+{
+ return Abc_NtkPiNum(pNtk) == pCex->nPis;
+}
+
+
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/abcXsim.c b/src/base/abci/abcXsim.c
index b77f9d77..12ad0e68 100644
--- a/src/base/abci/abcXsim.c
+++ b/src/base/abci/abcXsim.c
@@ -19,8 +19,9 @@
***********************************************************************/
#include "abc.h"
+#include "gia.h"
-extern unsigned Gia_ManRandom( int fReset );
+ABC_NAMESPACE_IMPL_START
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -30,8 +31,8 @@ extern unsigned Gia_ManRandom( int fReset );
#define XVS1 ABC_INIT_ONE
#define XVSX ABC_INIT_DC
-static inline void Abc_ObjSetXsim( Abc_Obj_t * pObj, int Value ) { pObj->pCopy = (void *)(ABC_PTRINT_T)Value; }
-static inline int Abc_ObjGetXsim( Abc_Obj_t * pObj ) { return (int)(ABC_PTRINT_T)pObj->pCopy; }
+static inline void Abc_ObjSetXsim( Abc_Obj_t * pObj, int Value ) { pObj->pCopy = (Abc_Obj_t *)(ABC_PTRINT_T)Value; }
+static inline int Abc_ObjGetXsim( Abc_Obj_t * pObj ) { return (int)(ABC_PTRINT_T)pObj->pCopy; }
static inline int Abc_XsimInv( int Value )
{
if ( Value == XVS0 )
@@ -158,12 +159,6 @@ void Abc_NtkXValueSimulate( Abc_Ntk_t * pNtk, int nFrames, int fXInputs, int fXS
fprintf( stdout, " : " );
Abc_NtkForEachPo( pNtk, pObj, i )
Abc_XsimPrint( stdout, Abc_ObjGetXsim(pObj) );
- if ( Abc_NtkAssertNum(pNtk) )
- {
- fprintf( stdout, " : " );
- Abc_NtkForEachAssert( pNtk, pObj, i )
- Abc_XsimPrint( stdout, Abc_ObjGetXsim(pObj) );
- }
fprintf( stdout, "\n" );
// assign input values
if ( fXInputs )
@@ -232,3 +227,5 @@ void Abc_NtkCycleInitState( Abc_Ntk_t * pNtk, int nFrames, int fUseXval, int fVe
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/fahout cut.c b/src/base/abci/fahout cut.c
new file mode 100644
index 00000000..980b0047
--- /dev/null
+++ b/src/base/abci/fahout cut.c
@@ -0,0 +1,357 @@
+/**CFile****************************************************************
+
+ FileName [abcMerge.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Network and node package.]
+
+ Synopsis [LUT merging algorithm.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: abcMerge.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "abc.h"
+#include "aig.h"
+#include "nwkMerge.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Marks the fanins of the node with the current trav ID.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Abc_NtkMarkFanins_rec( Abc_Obj_t * pLut, int nLevMin )
+{
+ Abc_Obj_t * pNext;
+ int i;
+ if ( !Abc_ObjIsNode(pLut) )
+ return;
+ if ( Abc_NodeIsTravIdCurrent( pLut ) )
+ return;
+ Abc_NodeSetTravIdCurrent( pLut );
+ if ( Abc_ObjLevel(pLut) < nLevMin )
+ return;
+ Abc_ObjForEachFanin( pLut, pNext, i )
+ Abc_NtkMarkFanins_rec( pNext, nLevMin );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Marks the fanouts of the node with the current trav ID.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Abc_NtkMarkFanouts_rec( Abc_Obj_t * pLut, int nLevMax, int nFanMax )
+{
+ Abc_Obj_t * pNext;
+ int i;
+ if ( !Abc_ObjIsNode(pLut) )
+ return;
+ if ( Abc_NodeIsTravIdCurrent( pLut ) )
+ return;
+ Abc_NodeSetTravIdCurrent( pLut );
+ if ( Abc_ObjLevel(pLut) > nLevMax )
+ return;
+ if ( Abc_ObjFanoutNum(pLut) > nFanMax )
+ return;
+ Abc_ObjForEachFanout( pLut, pNext, i )
+ Abc_NtkMarkFanouts_rec( pNext, nLevMax, nFanMax );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Collects the circle of nodes around the given set.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Abc_NtkCollectCircle( Vec_Ptr_t * vStart, Vec_Ptr_t * vNext, int nFanMax )
+{
+ Abc_Obj_t * pObj, * pNext;
+ int i, k;
+ Vec_PtrClear( vNext );
+ Vec_PtrForEachEntry( Vec_Int_t *, vStart, pObj, i )
+ {
+ Abc_ObjForEachFanin( pObj, pNext, k )
+ {
+ if ( !Abc_ObjIsNode(pNext) )
+ continue;
+ if ( Abc_NodeIsTravIdCurrent( pNext ) )
+ continue;
+ Abc_NodeSetTravIdCurrent( pNext );
+ Vec_PtrPush( vNext, pNext );
+ }
+ Abc_ObjForEachFanout( pObj, pNext, k )
+ {
+ if ( !Abc_ObjIsNode(pNext) )
+ continue;
+ if ( Abc_NodeIsTravIdCurrent( pNext ) )
+ continue;
+ Abc_NodeSetTravIdCurrent( pNext );
+ if ( Abc_ObjFanoutNum(pNext) > nFanMax )
+ continue;
+ Vec_PtrPush( vNext, pNext );
+ }
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Collects the circle of nodes removes from the given one.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Abc_NtkCollectNonOverlapCands( Abc_Obj_t * pLut, Vec_Ptr_t * vStart, Vec_Ptr_t * vNext, Vec_Ptr_t * vCands, Nwk_LMPars_t * pPars )
+{
+ Vec_Ptr_t * vTemp;
+ Abc_Obj_t * pObj;
+ int i, k;
+ Vec_PtrClear( vCands );
+ if ( pPars->nMaxSuppSize - Abc_ObjFaninNum(pLut) <= 1 )
+ return;
+
+ // collect nodes removed by this distance
+ assert( pPars->nMaxDistance > 0 );
+ Vec_PtrClear( vStart );
+ Vec_PtrPush( vStart, pLut );
+ Abc_NtkIncrementTravId( pLut->pNtk );
+ Abc_NodeSetTravIdCurrent( pLut );
+ for ( i = 1; i <= pPars->nMaxDistance; i++ )
+ {
+ Abc_NtkCollectCircle( vStart, vNext, pPars->nMaxFanout );
+ vTemp = vStart;
+ vStart = vNext;
+ vNext = vTemp;
+ // collect the nodes in vStart
+ Vec_PtrForEachEntry( Vec_Int_t *, vStart, pObj, k )
+ Vec_PtrPush( vCands, pObj );
+ }
+
+ // mark the TFI/TFO nodes
+ Abc_NtkIncrementTravId( pLut->pNtk );
+ if ( pPars->fUseTfiTfo )
+ Abc_NodeSetTravIdCurrent( pLut );
+ else
+ {
+ Abc_NodeSetTravIdPrevious( pLut );
+ Abc_NtkMarkFanins_rec( pLut, Abc_ObjLevel(pLut) - pPars->nMaxDistance );
+ Abc_NodeSetTravIdPrevious( pLut );
+ Abc_NtkMarkFanouts_rec( pLut, Abc_ObjLevel(pLut) + pPars->nMaxDistance, pPars->nMaxFanout );
+ }
+
+ // collect nodes satisfying the following conditions:
+ // - they are close enough in terms of distance
+ // - they are not in the TFI/TFO of the LUT
+ // - they have no more than the given number of fanins
+ // - they have no more than the given diff in delay
+ k = 0;
+ Vec_PtrForEachEntry( Vec_Int_t *, vCands, pObj, i )
+ {
+ if ( Abc_NodeIsTravIdCurrent(pObj) )
+ continue;
+ if ( Abc_ObjFaninNum(pLut) + Abc_ObjFaninNum(pObj) > pPars->nMaxSuppSize )
+ continue;
+ if ( Abc_ObjLevel(pLut) - Abc_ObjLevel(pObj) > pPars->nMaxLevelDiff ||
+ Abc_ObjLevel(pObj) - Abc_ObjLevel(pLut) > pPars->nMaxLevelDiff )
+ continue;
+ Vec_PtrWriteEntry( vCands, k++, pObj );
+ }
+ Vec_PtrShrink( vCands, k );
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Count the total number of fanins.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_NtkCountTotalFanins( Abc_Obj_t * pLut, Abc_Obj_t * pCand )
+{
+ Abc_Obj_t * pFanin;
+ int i, nCounter = Abc_ObjFaninNum(pLut);
+ Abc_ObjForEachFanin( pCand, pFanin, i )
+ nCounter += !pFanin->fMarkC;
+ return nCounter;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Collects overlapping candidates.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Abc_NtkCollectOverlapCands( Abc_Obj_t * pLut, Vec_Ptr_t * vCands, Nwk_LMPars_t * pPars )
+{
+ Abc_Obj_t * pFanin, * pObj;
+ int i, k;
+ // mark fanins of pLut
+ Abc_ObjForEachFanin( pLut, pFanin, i )
+ pFanin->fMarkC = 1;
+ // collect the matching fanouts of each fanin of the node
+ Vec_PtrClear( vCands );
+ Abc_NtkIncrementTravId( pLut->pNtk );
+ Abc_NodeSetTravIdCurrent( pLut );
+ Abc_ObjForEachFanin( pLut, pFanin, i )
+ {
+ if ( !Abc_ObjIsNode(pFanin) )
+ continue;
+ if ( Abc_ObjFanoutNum(pFanin) > pPars->nMaxFanout )
+ continue;
+ Abc_ObjForEachFanout( pFanin, pObj, k )
+ {
+ if ( !Abc_ObjIsNode(pObj) )
+ continue;
+ if ( Abc_NodeIsTravIdCurrent( pObj ) )
+ continue;
+ Abc_NodeSetTravIdCurrent( pObj );
+ // check the difference in delay
+ if ( Abc_ObjLevel(pLut) - Abc_ObjLevel(pObj) > pPars->nMaxLevelDiff ||
+ Abc_ObjLevel(pObj) - Abc_ObjLevel(pLut) > pPars->nMaxLevelDiff )
+ continue;
+ // check the total number of fanins of the node
+ if ( Abc_NtkCountTotalFanins(pLut, pObj) > pPars->nMaxSuppSize )
+ continue;
+ Vec_PtrPush( vCands, pObj );
+ }
+ }
+ // unmark fanins of pLut
+ Abc_ObjForEachFanin( pLut, pFanin, i )
+ pFanin->fMarkC = 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Performs LUT merging with parameters.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Abc_NtkLutMerge( Abc_Ntk_t * pNtk, Nwk_LMPars_t * pPars )
+{
+ Nwk_Grf_t * p;
+ Vec_Int_t * vResult;
+ Vec_Ptr_t * vStart, * vNext, * vCands1, * vCands2;
+ Abc_Obj_t * pLut, * pCand;
+ int i, k, nVertsMax, nCands, clk = clock();
+ // count the number of vertices
+ nVertsMax = 0;
+ Abc_NtkForEachNode( pNtk, pLut, i )
+ nVertsMax += (int)(Abc_ObjFaninNum(pLut) <= pPars->nMaxLutSize);
+ p = Nwk_ManGraphAlloc( nVertsMax );
+ // create graph
+ vStart = Vec_PtrAlloc( 1000 );
+ vNext = Vec_PtrAlloc( 1000 );
+ vCands1 = Vec_PtrAlloc( 1000 );
+ vCands2 = Vec_PtrAlloc( 1000 );
+ nCands = 0;
+ Abc_NtkForEachNode( pNtk, pLut, i )
+ {
+ if ( Abc_ObjFaninNum(pLut) > pPars->nMaxLutSize )
+ continue;
+ Abc_NtkCollectOverlapCands( pLut, vCands1, pPars );
+ if ( pPars->fUseDiffSupp )
+ Abc_NtkCollectNonOverlapCands( pLut, vStart, vNext, vCands2, pPars );
+ if ( Vec_PtrSize(vCands1) == 0 && Vec_PtrSize(vCands2) == 0 )
+ continue;
+ nCands += Vec_PtrSize(vCands1) + Vec_PtrSize(vCands2);
+ // save candidates
+ Vec_PtrForEachEntry( Vec_Int_t *, vCands1, pCand, k )
+ Nwk_ManGraphHashEdge( p, Abc_ObjId(pLut), Abc_ObjId(pCand) );
+ Vec_PtrForEachEntry( Vec_Int_t *, vCands2, pCand, k )
+ Nwk_ManGraphHashEdge( p, Abc_ObjId(pLut), Abc_ObjId(pCand) );
+ // print statistics about this node
+ if ( pPars->fVeryVerbose )
+ printf( "Node %6d : Fanins = %d. Fanouts = %3d. Cand1 = %3d. Cand2 = %3d.\n",
+ Abc_ObjId(pLut), Abc_ObjFaninNum(pLut), Abc_ObjFaninNum(pLut),
+ Vec_PtrSize(vCands1), Vec_PtrSize(vCands2) );
+ }
+ Vec_PtrFree( vStart );
+ Vec_PtrFree( vNext );
+ Vec_PtrFree( vCands1 );
+ Vec_PtrFree( vCands2 );
+ if ( pPars->fVerbose )
+ {
+ printf( "Mergable LUTs = %6d. Total cands = %6d. ", p->nVertsMax, nCands );
+ ABC_PRT( "Deriving graph", clock() - clk );
+ }
+ // solve the graph problem
+ clk = clock();
+ Nwk_ManGraphSolve( p );
+ if ( pPars->fVerbose )
+ {
+ printf( "GRAPH: Nodes = %6d. Edges = %6d. Pairs = %6d. ",
+ p->nVerts, p->nEdges, Vec_IntSize(p->vPairs)/2 );
+ ABC_PRT( "Solving", clock() - clk );
+ Nwk_ManGraphReportMemoryUsage( p );
+ }
+ vResult = p->vPairs; p->vPairs = NULL;
+/*
+ for ( i = 0; i < vResult->nSize; i += 2 )
+ printf( "(%d,%d) ", vResult->pArray[i], vResult->pArray[i+1] );
+ printf( "\n" );
+*/
+ Nwk_ManGraphFree( p );
+ return vResult;
+}
+
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/abci/module.make b/src/base/abci/module.make
index aaea7312..b9342881 100644
--- a/src/base/abci/module.make
+++ b/src/base/abci/module.make
@@ -4,16 +4,16 @@ SRC += src/base/abci/abc.c \
src/base/abci/abcAuto.c \
src/base/abci/abcBalance.c \
src/base/abci/abcBidec.c \
+ src/base/abci/abcBm.c \
src/base/abci/abcBmc.c \
src/base/abci/abcCas.c \
- src/base/abci/abcClpBdd.c \
- src/base/abci/abcClpSop.c \
+ src/base/abci/abcCascade.c \
+ src/base/abci/abcCollapse.c \
src/base/abci/abcCut.c \
src/base/abci/abcDar.c \
src/base/abci/abcDebug.c \
- src/base/abci/abcDelay.c \
- src/base/abci/abcDprove2.c \
src/base/abci/abcDress.c \
+ src/base/abci/abcDress2.c \
src/base/abci/abcDsd.c \
src/base/abci/abcExtract.c \
src/base/abci/abcFpga.c \
@@ -23,7 +23,9 @@ SRC += src/base/abci/abc.c \
src/base/abci/abcGen.c \
src/base/abci/abcHaig.c \
src/base/abci/abcIf.c \
+ src/base/abci/abcIfMux.c \
src/base/abci/abcIvy.c \
+ src/base/abci/abcLog.c \
src/base/abci/abcLut.c \
src/base/abci/abcLutmin.c \
src/base/abci/abcMap.c \
@@ -49,7 +51,9 @@ SRC += src/base/abci/abc.c \
src/base/abci/abcRewrite.c \
src/base/abci/abcRr.c \
src/base/abci/abcSat.c \
+ src/base/abci/abcScorr.c \
src/base/abci/abcSense.c \
+ src/base/abci/abcSpeedup.c \
src/base/abci/abcStrash.c \
src/base/abci/abcSweep.c \
src/base/abci/abcSymm.c \
diff --git a/src/base/cmd/cmd.c b/src/base/cmd/cmd.c
index 398415ae..47b031bc 100644
--- a/src/base/cmd/cmd.c
+++ b/src/base/cmd/cmd.c
@@ -24,9 +24,11 @@
#include <unistd.h>
#endif
+#include "abc.h"
#include "mainInt.h"
#include "cmdInt.h"
-#include "abc.h"
+
+ABC_NAMESPACE_IMPL_START
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -46,7 +48,7 @@ static int CmdCommandUnsetVariable ( Abc_Frame_t * pAbc, int argc, char ** argv
static int CmdCommandUndo ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int CmdCommandRecall ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int CmdCommandEmpty ( Abc_Frame_t * pAbc, int argc, char ** argv );
-#ifdef WIN32
+#if defined(WIN32) && !defined(__cplusplus)
static int CmdCommandLs ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int CmdCommandScrGen ( Abc_Frame_t * pAbc, int argc, char ** argv );
#endif
@@ -55,6 +57,8 @@ static int CmdCommandSis ( Abc_Frame_t * pAbc, int argc, char ** argv
static int CmdCommandMvsis ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int CmdCommandCapo ( Abc_Frame_t * pAbc, int argc, char ** argv );
+extern int Cmd_CommandAbcLoadPlugIn( Abc_Frame_t * pAbc, int argc, char ** argv );
+
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
@@ -75,28 +79,30 @@ void Cmd_Init( Abc_Frame_t * pAbc )
pAbc->tFlags = st_init_table(strcmp, st_strhash);
pAbc->aHistory = Vec_PtrAlloc( 100 );
- Cmd_CommandAdd( pAbc, "Basic", "time", CmdCommandTime, 0);
- Cmd_CommandAdd( pAbc, "Basic", "echo", CmdCommandEcho, 0);
- Cmd_CommandAdd( pAbc, "Basic", "quit", CmdCommandQuit, 0);
- Cmd_CommandAdd( pAbc, "Basic", "history", CmdCommandHistory, 0);
- Cmd_CommandAdd( pAbc, "Basic", "alias", CmdCommandAlias, 0);
- Cmd_CommandAdd( pAbc, "Basic", "unalias", CmdCommandUnalias, 0);
- Cmd_CommandAdd( pAbc, "Basic", "help", CmdCommandHelp, 0);
- Cmd_CommandAdd( pAbc, "Basic", "source", CmdCommandSource, 0);
- Cmd_CommandAdd( pAbc, "Basic", "set", CmdCommandSetVariable, 0);
- Cmd_CommandAdd( pAbc, "Basic", "unset", CmdCommandUnsetVariable, 0);
- Cmd_CommandAdd( pAbc, "Basic", "undo", CmdCommandUndo, 0);
- Cmd_CommandAdd( pAbc, "Basic", "recall", CmdCommandRecall, 0);
- Cmd_CommandAdd( pAbc, "Basic", "empty", CmdCommandEmpty, 0);
-#ifdef WIN32
- Cmd_CommandAdd( pAbc, "Basic", "ls", CmdCommandLs, 0 );
- Cmd_CommandAdd( pAbc, "Basic", "scrgen", CmdCommandScrGen, 0 );
+ Cmd_CommandAdd( pAbc, "Basic", "time", CmdCommandTime, 0 );
+ Cmd_CommandAdd( pAbc, "Basic", "echo", CmdCommandEcho, 0 );
+ Cmd_CommandAdd( pAbc, "Basic", "quit", CmdCommandQuit, 0 );
+ Cmd_CommandAdd( pAbc, "Basic", "history", CmdCommandHistory, 0 );
+ Cmd_CommandAdd( pAbc, "Basic", "alias", CmdCommandAlias, 0 );
+ Cmd_CommandAdd( pAbc, "Basic", "unalias", CmdCommandUnalias, 0 );
+ Cmd_CommandAdd( pAbc, "Basic", "help", CmdCommandHelp, 0 );
+ Cmd_CommandAdd( pAbc, "Basic", "source", CmdCommandSource, 0 );
+ Cmd_CommandAdd( pAbc, "Basic", "set", CmdCommandSetVariable, 0 );
+ Cmd_CommandAdd( pAbc, "Basic", "unset", CmdCommandUnsetVariable, 0 );
+ Cmd_CommandAdd( pAbc, "Basic", "undo", CmdCommandUndo, 0 );
+ Cmd_CommandAdd( pAbc, "Basic", "recall", CmdCommandRecall, 0 );
+ Cmd_CommandAdd( pAbc, "Basic", "empty", CmdCommandEmpty, 0 );
+#if defined(WIN32) && !defined(__cplusplus)
+ Cmd_CommandAdd( pAbc, "Basic", "ls", CmdCommandLs, 0 );
+ Cmd_CommandAdd( pAbc, "Basic", "scrgen", CmdCommandScrGen, 0 );
#endif
- Cmd_CommandAdd( pAbc, "Basic", "version", CmdCommandVersion, 0);
+ Cmd_CommandAdd( pAbc, "Basic", "version", CmdCommandVersion, 0 );
+
+ Cmd_CommandAdd( pAbc, "Various", "sis", CmdCommandSis, 1 );
+ Cmd_CommandAdd( pAbc, "Various", "mvsis", CmdCommandMvsis, 1 );
+ Cmd_CommandAdd( pAbc, "Various", "capo", CmdCommandCapo, 0 );
- Cmd_CommandAdd( pAbc, "Various", "sis", CmdCommandSis, 1);
- Cmd_CommandAdd( pAbc, "Various", "mvsis", CmdCommandMvsis, 1);
- Cmd_CommandAdd( pAbc, "Various", "capo", CmdCommandCapo, 0);
+ Cmd_CommandAdd( pAbc, "Various", "load_plugin", Cmd_CommandAbcLoadPlugIn, 0 );
}
/**Function********************************************************************
@@ -118,17 +124,17 @@ void Cmd_End( Abc_Frame_t * pAbc )
// st_free_table( pAbc->tCommands, (void (*)()) 0, CmdCommandFree );
// st_free_table( pAbc->tAliases, (void (*)()) 0, CmdCommandAliasFree );
-// st_free_table( pAbc->tFlags, ABC_FREE, ABC_FREE );
+// st_free_table( pAbc->tFlags, free, free );
- st_foreach_item( pAbc->tCommands, gen, (char **)&pKey, (char **)&pValue )
+ st_foreach_item( pAbc->tCommands, gen, (const char **)&pKey, (char **)&pValue )
CmdCommandFree( (Abc_Command *)pValue );
st_free_table( pAbc->tCommands );
- st_foreach_item( pAbc->tAliases, gen, (char **)&pKey, (char **)&pValue )
+ st_foreach_item( pAbc->tAliases, gen, (const char **)&pKey, (char **)&pValue )
CmdCommandAliasFree( (Abc_Alias *)pValue );
st_free_table( pAbc->tAliases );
- st_foreach_item( pAbc->tFlags, gen, (char **)&pKey, (char **)&pValue )
+ st_foreach_item( pAbc->tFlags, gen, (const char **)&pKey, (char **)&pValue )
ABC_FREE( pKey ), ABC_FREE( pValue );
st_free_table( pAbc->tFlags );
@@ -374,7 +380,8 @@ usage:
******************************************************************************/
int CmdCommandAlias( Abc_Frame_t * pAbc, int argc, char **argv )
{
- char *key, *value;
+ const char *key;
+ char *value;
int c;
Extra_UtilGetoptReset();
@@ -431,7 +438,8 @@ usage:
int CmdCommandUnalias( Abc_Frame_t * pAbc, int argc, char **argv )
{
int i;
- char *key, *value;
+ const char *key;
+ char *value;
int c;
Extra_UtilGetoptReset();
@@ -481,7 +489,7 @@ int CmdCommandUnalias( Abc_Frame_t * pAbc, int argc, char **argv )
******************************************************************************/
int CmdCommandHelp( Abc_Frame_t * pAbc, int argc, char **argv )
{
- bool fPrintAll;
+ int fPrintAll;
int c;
fPrintAll = 0;
@@ -714,7 +722,8 @@ int CmdCommandSource( Abc_Frame_t * pAbc, int argc, char **argv )
******************************************************************************/
int CmdCommandSetVariable( Abc_Frame_t * pAbc, int argc, char **argv )
{
- char *flag_value, *key, *value;
+ char *flag_value, *value;
+ const char* key;
int c;
Extra_UtilGetoptReset();
@@ -814,7 +823,8 @@ int CmdCommandSetVariable( Abc_Frame_t * pAbc, int argc, char **argv )
int CmdCommandUnsetVariable( Abc_Frame_t * pAbc, int argc, char **argv )
{
int i;
- char *key, *value;
+ const char *key;
+ char *value;
int c;
Extra_UtilGetoptReset();
@@ -1097,7 +1107,7 @@ usage:
#endif
-#ifdef WIN32
+#if defined(WIN32) && !defined(__cplusplus)
#include <direct.h>
// these structures are defined in <io.h> but are for some reason invisible
@@ -1117,7 +1127,7 @@ extern int _findnext( long handle, struct _finddata_t *fileinfo );
extern int _findclose( long handle );
//extern char * _getcwd( char * buffer, int maxlen );
-extern int _chdir( const char *dirname );
+//extern int _chdir( const char *dirname );
/**Function*************************************************************
@@ -1529,7 +1539,7 @@ int CmdCommandSis( Abc_Frame_t * pAbc, int argc, char **argv )
fprintf( pErr, "Cannot produce the intermediate network.\n" );
goto usage;
}
- Io_WriteBlif( pNetlist, "_sis_in.blif", 1 );
+ Io_WriteBlif( pNetlist, "_sis_in.blif", 1, 0, 0 );
Abc_NtkDelete( pNetlist );
// create the file for sis
@@ -1672,7 +1682,7 @@ int CmdCommandMvsis( Abc_Frame_t * pAbc, int argc, char **argv )
fprintf( pErr, "Cannot produce the intermediate network.\n" );
goto usage;
}
- Io_WriteBlif( pNetlist, "_mvsis_in.blif", 1 );
+ Io_WriteBlif( pNetlist, "_mvsis_in.blif", 1, 0, 0 );
Abc_NtkDelete( pNetlist );
// create the file for MVSIS
@@ -1767,10 +1777,10 @@ void Gia_ManGnuplotShow( char * pPlotFileName )
pAbc = Abc_FrameGetGlobalFrame();
// get the names from the plotting software
- if ( Cmd_FlagReadByName(pAbc, "gnuplotwin") )
- pProgNameGnuplotWin = Cmd_FlagReadByName(pAbc, "gnuplotwin");
- if ( Cmd_FlagReadByName(pAbc, "gnuplotunix") )
- pProgNameGnuplotUnix = Cmd_FlagReadByName(pAbc, "gnuplotunix");
+ if ( Cmd_FlagReadByName((Abc_Frame_t *)pAbc, "gnuplotwin") )
+ pProgNameGnuplotWin = Cmd_FlagReadByName((Abc_Frame_t *)pAbc, "gnuplotwin");
+ if ( Cmd_FlagReadByName((Abc_Frame_t *)pAbc, "gnuplotunix") )
+ pProgNameGnuplotUnix = Cmd_FlagReadByName((Abc_Frame_t *)pAbc, "gnuplotunix");
// check if Gnuplot is available
if ( (pFile = fopen( pProgNameGnuplotWin, "r" )) )
@@ -1887,7 +1897,7 @@ int CmdCommandCapo( Abc_Frame_t * pAbc, int argc, char **argv )
fprintf( pErr, "Cannot produce the intermediate network.\n" );
goto usage;
}
- Io_WriteBlif( pNetlist, "_capo_in.blif", 1 );
+ Io_WriteBlif( pNetlist, "_capo_in.blif", 1, 0, 0 );
Abc_NtkDelete( pNetlist );
// create the file for Capo
@@ -2011,3 +2021,5 @@ int CmdCommandVersion( Abc_Frame_t * pAbc, int argc, char **argv )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/cmd/cmd.h b/src/base/cmd/cmd.h
index 61c7264b..787e52b9 100644
--- a/src/base/cmd/cmd.h
+++ b/src/base/cmd/cmd.h
@@ -21,18 +21,17 @@
#ifndef __CMD_H__
#define __CMD_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
-
////////////////////////////////////////////////////////////////////////
/// STRUCTURE DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
@@ -49,21 +48,24 @@ typedef struct MvAlias Abc_Alias; // one alias
////////////////////////////////////////////////////////////////////////
/*=== cmd.c ===========================================================*/
-extern void Cmd_Init();
-extern void Cmd_End();
+extern void Cmd_Init( Abc_Frame_t * pAbc );
+extern void Cmd_End( Abc_Frame_t * pAbc );
/*=== cmdApi.c ========================================================*/
-extern void Cmd_CommandAdd( Abc_Frame_t * pAbc, char * sGroup, char * sName, void * pFunc, int fChanges );
-extern ABC_DLL int Cmd_CommandExecute( Abc_Frame_t * pAbc, char * sCommand );
+typedef int (*Cmd_CommandFuncType)(Abc_Frame_t*, int, char**);
+extern void Cmd_CommandAdd( Abc_Frame_t * pAbc, const char * sGroup, const char * sName, Cmd_CommandFuncType pFunc, int fChanges );
+extern ABC_DLL int Cmd_CommandExecute( Abc_Frame_t * pAbc, const char * sCommand );
/*=== cmdFlag.c ========================================================*/
extern char * Cmd_FlagReadByName( Abc_Frame_t * pAbc, char * flag );
-extern void Cmd_FlagDeleteByName( Abc_Frame_t * pAbc, char * key );
-extern void Cmd_FlagUpdateValue( Abc_Frame_t * pAbc, char * key, char * value );
+extern void Cmd_FlagDeleteByName( Abc_Frame_t * pAbc, const char * key );
+extern void Cmd_FlagUpdateValue( Abc_Frame_t * pAbc, const char * key, char * value );
/*=== cmdHist.c ========================================================*/
-extern void Cmd_HistoryAddCommand( Abc_Frame_t * pAbc, char * command );
+extern void Cmd_HistoryAddCommand( Abc_Frame_t * pAbc, const char * command );
+
+
+
+ABC_NAMESPACE_HEADER_END
+
-#ifdef __cplusplus
-}
-#endif
#endif
diff --git a/src/base/cmd/cmdAlias.c b/src/base/cmd/cmdAlias.c
index 20ee0694..6078927d 100644
--- a/src/base/cmd/cmdAlias.c
+++ b/src/base/cmd/cmdAlias.c
@@ -18,8 +18,12 @@
***********************************************************************/
+#include "abc.h"
#include "cmdInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -118,3 +122,5 @@ void CmdCommandAliasFree( Abc_Alias * pAlias )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/cmd/cmdApi.c b/src/base/cmd/cmdApi.c
index ae1949a6..40c1dbf9 100644
--- a/src/base/cmd/cmdApi.c
+++ b/src/base/cmd/cmdApi.c
@@ -18,9 +18,12 @@
***********************************************************************/
+#include "abc.h"
#include "mainInt.h"
#include "cmdInt.h"
-#include "abc.h"
+
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -41,9 +44,10 @@
SeeAlso []
***********************************************************************/
-void Cmd_CommandAdd( Abc_Frame_t * pAbc, char * sGroup, char * sName, void * pFunc, int fChanges )
+void Cmd_CommandAdd( Abc_Frame_t * pAbc, const char * sGroup, const char * sName, Cmd_CommandFuncType pFunc, int fChanges )
{
- char * key, * value;
+ const char * key;
+ char * value;
Abc_Command * pCommand;
int fStatus;
@@ -61,7 +65,7 @@ void Cmd_CommandAdd( Abc_Frame_t * pAbc, char * sGroup, char * sName, void * pFu
pCommand->sGroup = Extra_UtilStrsav( sGroup );
pCommand->pFunc = pFunc;
pCommand->fChange = fChanges;
- fStatus = st_insert( pAbc->tCommands, sName, (char *)pCommand );
+ fStatus = st_insert( pAbc->tCommands, pCommand->sName, (char *)pCommand );
assert( !fStatus ); // the command should not be in the table
}
@@ -76,10 +80,11 @@ void Cmd_CommandAdd( Abc_Frame_t * pAbc, char * sGroup, char * sName, void * pFu
SeeAlso []
***********************************************************************/
-int Cmd_CommandExecute( Abc_Frame_t * pAbc, char * sCommand )
+int Cmd_CommandExecute( Abc_Frame_t * pAbc, const char * sCommand )
{
int fStatus = 0, argc, loop;
- char * sCommandNext, **argv;
+ const char * sCommandNext;
+ char **argv;
if ( !pAbc->fAutoexac )
Cmd_HistoryAddCommand(pAbc, sCommand);
@@ -102,3 +107,5 @@ int Cmd_CommandExecute( Abc_Frame_t * pAbc, char * sCommand )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/cmd/cmdFlag.c b/src/base/cmd/cmdFlag.c
index d25861c0..a220042b 100644
--- a/src/base/cmd/cmdFlag.c
+++ b/src/base/cmd/cmdFlag.c
@@ -18,8 +18,12 @@
***********************************************************************/
+#include "abc.h"
#include "mainInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -58,7 +62,7 @@ char * Cmd_FlagReadByName( Abc_Frame_t * pAbc, char * flag )
SideEffects []
******************************************************************************/
-void Cmd_FlagUpdateValue( Abc_Frame_t * pAbc, char * key, char * value )
+void Cmd_FlagUpdateValue( Abc_Frame_t * pAbc, const char * key, char * value )
{
char * oldValue, * newValue;
if ( !key )
@@ -83,7 +87,7 @@ void Cmd_FlagUpdateValue( Abc_Frame_t * pAbc, char * key, char * value )
SideEffects []
******************************************************************************/
-void Cmd_FlagDeleteByName( Abc_Frame_t * pAbc, char * key )
+void Cmd_FlagDeleteByName( Abc_Frame_t * pAbc, const char * key )
{
char *value;
if ( !key )
@@ -102,3 +106,5 @@ void Cmd_FlagDeleteByName( Abc_Frame_t * pAbc, char * key )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/cmd/cmdHist.c b/src/base/cmd/cmdHist.c
index fae9382d..a2f64027 100644
--- a/src/base/cmd/cmdHist.c
+++ b/src/base/cmd/cmdHist.c
@@ -18,10 +18,14 @@
***********************************************************************/
+#include "abc.h"
#include "mainInt.h"
#include "cmd.h"
#include "cmdInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -41,7 +45,7 @@
SeeAlso []
***********************************************************************/
-void Cmd_HistoryAddCommand( Abc_Frame_t * p, char * command )
+void Cmd_HistoryAddCommand( Abc_Frame_t * p, const char * command )
{
static char Buffer[MAX_STR];
strcpy( Buffer, command );
@@ -53,3 +57,5 @@ void Cmd_HistoryAddCommand( Abc_Frame_t * p, char * command )
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/cmd/cmdInt.h b/src/base/cmd/cmdInt.h
index 3a6a2803..0ea9b364 100644
--- a/src/base/cmd/cmdInt.h
+++ b/src/base/cmd/cmdInt.h
@@ -21,6 +21,7 @@
#ifndef __CMD_INT_H__
#define __CMD_INT_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -28,6 +29,9 @@
#include "mainInt.h"
#include "cmd.h"
+ABC_NAMESPACE_HEADER_START
+
+
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
@@ -40,7 +44,7 @@ struct MvCommand
{
char * sName; // the command name
char * sGroup; // the group name
- void * pFunc; // the function to execute the command
+ Cmd_CommandFuncType pFunc; // the function to execute the command
int fChange; // set to 1 to mark that the network is changed
};
@@ -66,19 +70,23 @@ extern char * CmdCommandAliasLookup( Abc_Frame_t * pAbc, char * sCommand );
extern void CmdCommandAliasFree( Abc_Alias * p );
/*=== cmdUtils.c =======================================================*/
extern int CmdCommandDispatch( Abc_Frame_t * pAbc, int * argc, char *** argv );
-extern char * CmdSplitLine( Abc_Frame_t * pAbc, char * sCommand, int * argc, char *** argv );
+extern const char * CmdSplitLine( Abc_Frame_t * pAbc, const char * sCommand, int * argc, char *** argv );
extern int CmdApplyAlias( Abc_Frame_t * pAbc, int * argc, char *** argv, int * loop );
extern char * CmdHistorySubstitution( Abc_Frame_t * pAbc, char * line, int * changed );
extern FILE * CmdFileOpen( Abc_Frame_t * pAbc, char * sFileName, char * sMode, char ** pFileNameReal, int silent );
extern void CmdFreeArgv( int argc, char ** argv );
extern char ** CmdAddToArgv( int argc, char ** argv );
extern void CmdCommandFree( Abc_Command * pCommand );
-extern void CmdCommandPrint( Abc_Frame_t * pAbc, bool fPrintAll );
+extern void CmdCommandPrint( Abc_Frame_t * pAbc, int fPrintAll );
extern void CmdPrintTable( st_table * tTable, int fAliases );
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif
diff --git a/src/base/cmd/cmdLoad.c b/src/base/cmd/cmdLoad.c
new file mode 100644
index 00000000..7a83385c
--- /dev/null
+++ b/src/base/cmd/cmdLoad.c
@@ -0,0 +1,226 @@
+/**CFile****************************************************************
+
+ FileName [cmdApi.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Command processing package.]
+
+ Synopsis [External procedures of the command package.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: cmdApi.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "abc.h"
+#include "mainInt.h"
+#include "cmd.h"
+#include "cmdInt.h"
+
+ABC_NAMESPACE_IMPL_START
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+static int CmdCommandLoad ( Abc_Frame_t * pAbc, int argc, char ** argv );
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function********************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+******************************************************************************/
+int CmdCommandLoad( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ Vec_Str_t * vCommand;
+ FILE * pFile;
+ int i;
+ vCommand = Vec_StrAlloc( 100 );
+ Vec_StrAppend( vCommand, "abccmd_" );
+ Vec_StrAppend( vCommand, argv[0] );
+ Vec_StrAppend( vCommand, ".exe" );
+ Vec_StrPush( vCommand, 0 );
+ // check if there is the binary
+ if ( (pFile = fopen( Vec_StrArray(vCommand), "r" )) == NULL )
+ {
+ Abc_Print( -1, "Cannot run the binary \"%s\".\n\n", Vec_StrArray(vCommand) );
+ return 1;
+ }
+ fclose( pFile );
+ Vec_StrPop( vCommand );
+ // add other arguments
+ for ( i = 1; i < argc; i++ )
+ {
+ Vec_StrAppend( vCommand, " " );
+ Vec_StrAppend( vCommand, argv[i] );
+ }
+ Vec_StrPush( vCommand, 0 );
+ // run the command line
+ if ( system( Vec_StrArray(vCommand) ) )
+ {
+ Abc_Print( -1, "The following command has returned non-zero exit status:\n" );
+ Abc_Print( -1, "\"%s\"\n", Vec_StrArray(vCommand) );
+ return 1;
+ }
+ return 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+#if defined(WIN32) && !defined(__cplusplus)
+
+#include <direct.h>
+
+
+// these structures are defined in <io.h> but are for some reason invisible
+typedef unsigned long _fsize_t; // Could be 64 bits for Win32
+
+struct _finddata_t {
+ unsigned attrib;
+ time_t time_create; // -1 for FAT file systems
+ time_t time_access; // -1 for FAT file systems
+ time_t time_write;
+ _fsize_t size;
+ char name[260];
+};
+
+extern long _findfirst( char *filespec, struct _finddata_t *fileinfo );
+extern int _findnext( long handle, struct _finddata_t *fileinfo );
+extern int _findclose( long handle );
+
+//extern char * _getcwd( char * buffer, int maxlen );
+//extern int _chdir( const char *dirname );
+
+/**Function*************************************************************
+
+ Synopsis [Collect file names ending with .exe]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Ptr_t * CmdCollectFileNames()
+{
+ Vec_Ptr_t * vFileNames;
+ struct _finddata_t c_file;
+ long hFile;
+ if( (hFile = _findfirst( "*.exe", &c_file )) == -1L )
+ {
+// Abc_Print( 0, "No files with extention \"%s\" in the current directory.\n", "exe" );
+ return NULL;
+ }
+ vFileNames = Vec_PtrAlloc( 100 );
+ do {
+ Vec_PtrPush( vFileNames, Extra_UtilStrsav( c_file.name ) );
+ } while( _findnext( hFile, &c_file ) == 0 );
+ _findclose( hFile );
+ return vFileNames;
+}
+
+#else
+
+/**Function*************************************************************
+
+ Synopsis [Collect file names ending with .exe]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Ptr_t * CmdCollectFileNames()
+{
+ return NULL;
+}
+
+#endif
+
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Load_Init( Abc_Frame_t * pAbc )
+{
+ Vec_Ptr_t * vFileNames;
+ char * pName, * pStop;
+ int i;
+ vFileNames = CmdCollectFileNames();
+ if ( vFileNames == NULL )
+ return;
+ Vec_PtrForEachEntry( char *, vFileNames, pName, i )
+ {
+ if ( strncmp( pName, "abccmd_", 7 ) )
+ continue;
+ // get the command name
+// pName[6] = '!';
+ pStop = strstr( pName + 7, "." );
+ if ( pStop )
+ *pStop = 0;
+ // add the command
+ Cmd_CommandAdd( pAbc, "ZZ", pName+7, CmdCommandLoad, 0 );
+// printf( "Loaded command \"%s\"\n", pName+7 );
+ }
+ Vec_PtrFreeFree( vFileNames );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Load_End( Abc_Frame_t * pAbc )
+{
+}
+
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/cmd/cmdPlugin.c b/src/base/cmd/cmdPlugin.c
new file mode 100644
index 00000000..be7a9245
--- /dev/null
+++ b/src/base/cmd/cmdPlugin.c
@@ -0,0 +1,629 @@
+/**CFile****************************************************************
+
+ FileName [cmdPlugin.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Command processing package.]
+
+ Synopsis [Integrating external binary.]
+
+ Author [Alan Mishchenko, Niklas Een]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - September 29, 2010.]
+
+ Revision [$Id: cmdPlugin.c,v 1.00 2010/09/29 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#ifdef WIN32
+#include <io.h>
+#include <process.h>
+#else
+#include <unistd.h>
+#endif
+
+#include "abc.h"
+#include "mainInt.h"
+#include "cmd.h"
+#include "cmdInt.h"
+
+ABC_NAMESPACE_IMPL_START
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/*
+
+-------- Original Message --------
+Subject: ABC/ZZ integration
+Date: Wed, 29 Sep 2010 00:34:32 -0700
+From: Niklas Een <niklas@een.se>
+To: Alan Mishchenko <alanmi@EECS.Berkeley.EDU>
+
+Hi Alan,
+
+Since the interface is file-based, it is important that we generate
+good, unique filenames (we may run multiple instances of ABC in the
+same directory), so I have attached some portable code for doing that
+(tmpFile.c). You can integrate it appropriately.
+
+This is how my interface is meant to work:
+
+(1) As part of your call to Bip, give it first argument "-abc".
+ This will alter Bip's behavior slightly.
+
+(2) To list the commands, call 'bip -list-commands'.
+ My commands begin with a comma (so that's my prefix).
+
+(3) All commands expect an input file and an output file.
+ The input file should be in AIGER format.
+ The output will be a text file.
+ Example:
+ bip -input=tmp.aig -output=tmp.out ,pdr -check -prop=5
+
+ So you just auto-generate the two temporary files (output file is
+ closed and left empty) and stitch the ABC command line at the end.
+ All you need to check for is if the ABC line begins with a comma.
+
+(4) The result written to the output file will contain a number
+ of object. Each object is on a separate line of the form:
+
+ <object name>: <object data>
+
+That is: name, colon, space, data, newline. If you see a name you don't
+recognize, just skip that line (so you will ignore future extensions by me).
+I currently define the following objects:
+
+ result:
+ counter-example:
+ proof-invariant:
+ bug-free-depth:
+ abstraction:
+
+"result:" is one of "proved", "failed", "undetermined" (=reached resource limit), "error"
+(only used by the abstraction command, and only if resource limit was so tight that the
+abstraction was still empty -- no abstraction is returned in this special case).
+
+"counter-example:" -- same format as before
+
+"proof-invariant:" contains an text-encoded single-output AIG. If you want
+you can parse it and validate the invariant.
+
+"bug-free-depth:" the depth up to which the procedure has checked for counter-example.
+Starts at -1 (not even the initial states have been verified).
+
+"abstraction:" -- same format as before
+
+(5) I propose that you add a command "load_plugin <path/binary>". That way Bob can put
+Bip where ever he likes and just modify his abc_rc file.
+
+The intention is that ABC can read this file and act on it without knowing what
+particular command was used. If there is an abstraction, you will always apply it.
+If there is a "bug-free-depth" you will store that data somewhere so that Bob can query
+it through the Python interface, and so on. If we need different actions for different
+command, then we add a new object for the new action.
+
+// N.
+
+*/
+
+extern int tmpFile(const char* prefix, const char* suffix, char** out_name);
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+char * Abc_GetBinaryName( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ char * pTemp;
+ int i;
+ Vec_PtrForEachEntry( char *, pAbc->vPlugInComBinPairs, pTemp, i )
+ {
+ i++;
+ if ( strcmp( pTemp, argv[0] ) == 0 )
+ return Vec_PtrEntry( pAbc->vPlugInComBinPairs, i );
+ }
+ assert( 0 );
+ return NULL;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Read flop map.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Str_t * Abc_ManReadFile( char * pFileName )
+{
+ FILE * pFile;
+ Vec_Str_t * vStr;
+ int c;
+ pFile = fopen( pFileName, "r" );
+ if ( pFile == NULL )
+ {
+ printf( "Cannot open file \"%s\".\n", pFileName );
+ return NULL;
+ }
+ vStr = Vec_StrAlloc( 100 );
+ while ( (c = fgetc(pFile)) != EOF )
+ Vec_StrPush( vStr, (char)c );
+ Vec_StrPush( vStr, '\0' );
+ fclose( pFile );
+ return vStr;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Read flop map.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Abc_ManReadBinary( char * pFileName, char * pToken )
+{
+ Vec_Int_t * vMap = NULL;
+ Vec_Str_t * vStr;
+ char * pStr;
+ int i, Length;
+ vStr = Abc_ManReadFile( pFileName );
+ if ( vStr == NULL )
+ return NULL;
+ pStr = Vec_StrArray( vStr );
+ pStr = strstr( pStr, pToken );
+ if ( pStr != NULL )
+ {
+ pStr += strlen( pToken );
+ vMap = Vec_IntAlloc( 100 );
+ Length = strlen( pStr );
+ for ( i = 0; i < Length; i++ )
+ {
+ if ( pStr[i] == '0' || pStr[i] == '?' )
+ Vec_IntPush( vMap, 0 );
+ else if ( pStr[i] == '1' )
+ Vec_IntPush( vMap, 1 );
+ if ( ('a' <= pStr[i] && pStr[i] <= 'z') ||
+ ('A' <= pStr[i] && pStr[i] <= 'Z') )
+ break;
+ }
+ }
+ Vec_StrFree( vStr );
+ return vMap;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Read flop map.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_ManReadInteger( char * pFileName, char * pToken )
+{
+ int Result = -1;
+ Vec_Str_t * vStr;
+ char * pStr;
+ vStr = Abc_ManReadFile( pFileName );
+ if ( vStr == NULL )
+ return -1;
+ pStr = Vec_StrArray( vStr );
+ pStr = strstr( pStr, pToken );
+ if ( pStr != NULL )
+ Result = atoi( pStr + strlen(pToken) );
+ Vec_StrFree( vStr );
+ return Result;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Read flop map.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_ManReadStatus( char * pFileName, char * pToken )
+{
+ int Result = -1;
+ Vec_Str_t * vStr;
+ char * pStr;
+ vStr = Abc_ManReadFile( pFileName );
+ if ( vStr == NULL )
+ return -1;
+ pStr = Vec_StrArray( vStr );
+ pStr = strstr( pStr, pToken );
+ if ( pStr != NULL )
+ {
+ if ( strncmp(pStr+8, "proved", 6) == 0 )
+ Result = 1;
+ else if ( strncmp(pStr+8, "failed", 6) == 0 )
+ Result = 0;
+ }
+ Vec_StrFree( vStr );
+ return Result;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Work-around to insert 0s for PIs without fanout.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Int_t * Abc_ManExpandCex( Gia_Man_t * pGia, Vec_Int_t * vCex )
+{
+ Vec_Int_t * vCexNew;
+ Gia_Obj_t * pObj;
+ int i, k;
+
+ // start with register outputs
+ vCexNew = Vec_IntAlloc( Vec_IntSize(vCex) );
+ Gia_ManForEachRo( pGia, pObj, i )
+ Vec_IntPush( vCexNew, 0 );
+
+ ABC_FREE( pGia->pRefs );
+ Gia_ManCreateRefs( pGia );
+ k = Gia_ManRegNum( pGia );
+ while ( 1 )
+ {
+ Gia_ManForEachPi( pGia, pObj, i )
+ {
+ if ( Gia_ObjRefs(pGia, pObj) == 0 )
+ Vec_IntPush( vCexNew, 0 );
+ else
+ {
+ if ( k == Vec_IntSize(vCex) )
+ break;
+ Vec_IntPush( vCexNew, Vec_IntEntry(vCex, k++) );
+ }
+ }
+ if ( k == Vec_IntSize(vCex) )
+ break;
+ }
+ return vCexNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Cmd_CommandAbcPlugIn( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ char * pFileIn, * pFileOut;
+ char * pFileNameBinary;
+ Vec_Str_t * vCommand;
+ Vec_Int_t * vCex;
+ FILE * pFile;
+ int i, fd, clk;
+ int fLeaveFiles;
+/*
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+ if ( pNtk == NULL )
+ {
+ Abc_Print( -1, "Current network does not exist\n" );
+ return 1;
+ }
+ if ( !Abc_NtkIsStrash( pNtk) )
+ {
+ Abc_Print( -1, "The current network is not an AIG. Cannot continue.\n" );
+ return 1;
+ }
+*/
+ if ( pAbc->pGia == NULL )
+ {
+ Abc_Print( -1, "Current AIG does not exist (try command &ps).\n" );
+ return 1;
+ }
+
+ // check if there is the binary
+ pFileNameBinary = Abc_GetBinaryName( pAbc, argc, argv );
+ if ( (pFile = fopen( pFileNameBinary, "r" )) == NULL )
+ {
+ Abc_Print( -1, "Cannot run the binary \"%s\".\n\n", pFileNameBinary );
+ return 1;
+ }
+ fclose( pFile );
+
+ // create temp file
+ fd = tmpFile( "__abctmp_", ".aig", &pFileIn );
+ if ( fd == -1 )
+ {
+ Abc_Print( -1, "Cannot create a temporary file.\n" );
+ return 1;
+ }
+#ifdef WIN32
+ _close( fd );
+#else
+ close( fd );
+#endif
+
+ // create temp file
+ fd = tmpFile( "__abctmp_", ".out", &pFileOut );
+ if ( fd == -1 )
+ {
+ ABC_FREE( pFileIn );
+ Abc_Print( -1, "Cannot create a temporary file.\n" );
+ return 1;
+ }
+#ifdef WIN32
+ _close( fd );
+#else
+ close( fd );
+#endif
+
+
+ // write current network into a file
+/*
+ {
+ extern Aig_Man_t * Abc_NtkToDar( Abc_Ntk_t * pNtk, int fExors, int fRegisters );
+ Aig_Man_t * pAig;
+ pAig = Abc_NtkToDar( pNtk, 0, 1 );
+ Ioa_WriteAiger( pAig, pFileIn, 0, 0 );
+ Aig_ManStop( pAig );
+ }
+*/
+ // check what to do with the files
+ fLeaveFiles = 0;
+ if ( strcmp( argv[argc-1], "!" ) == 0 )
+ {
+ Abc_Print( 0, "Input file \"%s\" and output file \"%s\" are not deleted.\n", pFileIn, pFileOut );
+ fLeaveFiles = 1;
+ argc--;
+ }
+
+ // create input file
+ Gia_WriteAiger( pAbc->pGia, pFileIn, 0, 0 );
+
+ // create command line
+ vCommand = Vec_StrAlloc( 100 );
+ Vec_StrAppend( vCommand, pFileNameBinary );
+ // add input/output file
+ Vec_StrAppend( vCommand, " -abc" );
+// Vec_StrAppend( vCommand, " -input=C:/_projects/abc/_TEST/hwmcc/139442p0.aig" );
+ Vec_StrAppend( vCommand, " -input=" );
+ Vec_StrAppend( vCommand, pFileIn );
+ Vec_StrAppend( vCommand, " -output=" );
+ Vec_StrAppend( vCommand, pFileOut );
+ // add other arguments
+ for ( i = 0; i < argc; i++ )
+ {
+ Vec_StrAppend( vCommand, " " );
+ Vec_StrAppend( vCommand, argv[i] );
+ }
+ Vec_StrPush( vCommand, 0 );
+
+ // run the command line
+//printf( "Running command line: %s\n", Vec_StrArray(vCommand) );
+
+ clk = clock();
+ if ( system( Vec_StrArray(vCommand) ) )
+ {
+ Abc_Print( -1, "The following command has returned non-zero exit status:\n" );
+ Abc_Print( -1, "\"%s\"\n", Vec_StrArray(vCommand) );
+ return 1;
+ }
+ clk = clock() - clk;
+ Vec_StrFree( vCommand );
+
+ // check if the output file exists
+ if ( (pFile = fopen( pFileOut, "r" )) == NULL )
+ {
+ Abc_Print( -1, "There is no output file \"%s\".\n", pFileOut );
+ return 1;
+ }
+ fclose( pFile );
+
+ // process the output
+ if ( Extra_FileSize(pFileOut) > 0 )
+ {
+ // read program arguments
+ pAbc->Status = Abc_ManReadStatus( pFileOut, "result:" );
+ pAbc->nFrames = Abc_ManReadInteger( pFileOut, "bug-free-depth:" );
+ if ( pAbc->nFrames == -1 )
+ printf( "Gia_ManCexAbstractionStartNew(): Cannot read the number of frames covered by BMC.\n" );
+ pAbc->pGia->vFlopClasses = Abc_ManReadBinary( pFileOut, "abstraction:" );
+ vCex = Abc_ManReadBinary( pFileOut, "counter-example:" );
+ if ( vCex )
+ {
+ int nFrames, nRemain;
+
+ nFrames = (Vec_IntSize(vCex) - Gia_ManRegNum(pAbc->pGia)) / Gia_ManPiNum(pAbc->pGia);
+ nRemain = (Vec_IntSize(vCex) - Gia_ManRegNum(pAbc->pGia)) % Gia_ManPiNum(pAbc->pGia);
+ if ( nRemain != 0 )
+ {
+ Vec_Int_t * vTemp;
+ Abc_Print( 1, "Adjusting counter-example by adding zeros for PIs without fanout.\n" );
+ // expand the counter-example to include PIs without fanout
+ vCex = Abc_ManExpandCex( pAbc->pGia, vTemp = vCex );
+ Vec_IntFree( vTemp );
+ }
+
+ nFrames = (Vec_IntSize(vCex) - Gia_ManRegNum(pAbc->pGia)) / Gia_ManPiNum(pAbc->pGia);
+ nRemain = (Vec_IntSize(vCex) - Gia_ManRegNum(pAbc->pGia)) % Gia_ManPiNum(pAbc->pGia);
+ if ( nRemain != 0 )
+ Abc_Print( 1, "Counter example has a wrong length.\n" );
+ else
+ {
+ extern int Gia_ManVerifyCounterExampleAllOuts( Gia_Man_t * pAig, Abc_Cex_t * p );
+
+ Abc_Print( 1, "Problem is satisfiable. Found counter-example in frame %d. ", nFrames-1 );
+ Abc_PrintTime( 1, "Time", clk );
+ ABC_FREE( pAbc->pCex );
+ pAbc->pCex = Gia_ManDeriveCexFromArray( pAbc->pGia, vCex, 0, nFrames-1 );
+
+// Gia_ManPrintCex( pAbc->pCex );
+
+// if ( !Gia_ManVerifyCounterExample( pAbc->pGia, pAbc->pCex, 0 ) )
+// Abc_Print( 1, "Generated counter-example is INVALID.\n" );
+
+ // remporary work-around to detect the output number - October 18, 2010
+ pAbc->pCex->iPo = Gia_ManVerifyCounterExampleAllOuts( pAbc->pGia, pAbc->pCex );
+ if ( pAbc->pCex->iPo == -1 )
+ {
+ Abc_Print( 1, "Generated counter-example is INVALID.\n" );
+ ABC_FREE( pAbc->pCex );
+ }
+ else
+ {
+ Abc_Print( 1, "Returned counter-example successfully verified in ABC.\n" );
+ }
+ }
+ Vec_IntFreeP( &vCex );
+ }
+ }
+
+
+
+ // clean up
+ if ( !fLeaveFiles )
+ {
+ remove( pFileIn );
+ remove( pFileOut );
+ }
+ ABC_FREE( pFileIn );
+ ABC_FREE( pFileOut );
+ return 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Cmd_CommandAbcLoadPlugIn( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ FILE * pFile;
+ char pBuffer[1000];
+ char * pCommandLine;
+ char * pTempFile;
+ char * pStrDirBin, * pStrSection;
+ int fd, RetValue;
+
+ if ( argc != 3 )
+ {
+ Abc_Print( -1, "Wrong number of arguments.\n" );
+ goto usage;
+ }
+ // collect arguments
+ pStrDirBin = argv[argc-2];
+ pStrSection = argv[argc-1];
+
+ // check if the file exists
+ if ( (pFile = fopen( pStrDirBin, "r" )) == NULL )
+ {
+// Abc_Print( -1, "Cannot run the binary \"%s\".\n", pStrDirBin );
+// goto usage;
+ return 0;
+ }
+ fclose( pFile );
+
+ // create temp file
+ fd = tmpFile( "__abctmp_", ".txt", &pTempFile );
+ if ( fd == -1 )
+ {
+ Abc_Print( -1, "Cannot create a temporary file.\n" );
+ goto usage;
+ }
+#ifdef WIN32
+ _close( fd );
+#else
+ close( fd );
+#endif
+
+ // get command list
+ pCommandLine = ABC_ALLOC( char, 100 + strlen(pStrDirBin) + strlen(pTempFile) );
+// sprintf( pCommandLine, "%s -abc -list-commands > %s", pStrDirBin, pTempFile );
+ sprintf( pCommandLine, "%s -abc -list-commands > %s", pStrDirBin, pTempFile );
+ RetValue = system( pCommandLine );
+ if ( RetValue == -1 )
+ {
+ Abc_Print( -1, "Command \"%s\" did not succeed.\n", pCommandLine );
+ ABC_FREE( pCommandLine );
+ ABC_FREE( pTempFile );
+ goto usage;
+ }
+ ABC_FREE( pCommandLine );
+
+ // create commands
+ pFile = fopen( pTempFile, "r" );
+ if ( pFile == NULL )
+ {
+ Abc_Print( -1, "Cannot open file with the list of commands.\n" );
+ ABC_FREE( pTempFile );
+ goto usage;
+ }
+ while ( fgets( pBuffer, 1000, pFile ) != NULL )
+ {
+ if ( pBuffer[strlen(pBuffer)-1] == '\n' )
+ pBuffer[strlen(pBuffer)-1] = 0;
+ Cmd_CommandAdd( pAbc, pStrSection, pBuffer, Cmd_CommandAbcPlugIn, 1 );
+// plugin_commands.push(Pair(cmd_name, binary_name));
+ Vec_PtrPush( pAbc->vPlugInComBinPairs, strdup(pBuffer) );
+ Vec_PtrPush( pAbc->vPlugInComBinPairs, strdup(pStrDirBin) );
+ printf( "Creating command %s with binary %s\n", pBuffer, pStrDirBin );
+ }
+ fclose( pFile );
+ remove( pTempFile );
+ ABC_FREE( pTempFile );
+ return 0;
+usage:
+ Abc_Print( -2, "usage: load_plugin <plugin_dir\\binary_name> <section_name>\n" );
+ Abc_Print( -2, "\t loads external binary as a plugin\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ return 1;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/cmd/cmdUtils.c b/src/base/cmd/cmdUtils.c
index 1e4c7700..5fc663fc 100644
--- a/src/base/cmd/cmdUtils.c
+++ b/src/base/cmd/cmdUtils.c
@@ -18,10 +18,13 @@
***********************************************************************/
-#include "mainInt.h"
#include "abc.h"
+#include "mainInt.h"
#include "cmdInt.h"
-#include <ctype.h> // proper declaration of isspace
+#include <ctype.h>
+
+ABC_NAMESPACE_IMPL_START
+ // proper declaration of isspace
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -107,17 +110,24 @@ int CmdCommandDispatch( Abc_Frame_t * pAbc, int * pargc, char *** pargv )
// get the command
if ( !st_lookup( pAbc->tCommands, argv[0], (char **)&pCommand ) )
{ // the command is not in the table
-// fprintf( pAbc->Err, "** cmd error: unknown command '%s'\n", argv[0] );
-// return 1;
- // add command 'read' assuming that this is the file name
- argv2 = CmdAddToArgv( argc, argv );
- CmdFreeArgv( argc, argv );
- argc = argc+1;
- argv = argv2;
- *pargc = argc;
- *pargv = argv;
- if ( !st_lookup( pAbc->tCommands, argv[0], (char **)&pCommand ) )
- assert( 0 );
+ // if there is only one word with an extension, assume this is file to be read
+ if ( argc == 1 && strstr( argv[0], "." ) )
+ {
+ // add command 'read' assuming that this is the file name
+ argv2 = CmdAddToArgv( argc, argv );
+ CmdFreeArgv( argc, argv );
+ argc = argc+1;
+ argv = argv2;
+ *pargc = argc;
+ *pargv = argv;
+ if ( !st_lookup( pAbc->tCommands, argv[0], (char **)&pCommand ) )
+ assert( 0 );
+ }
+ else
+ {
+ fprintf( pAbc->Err, "** cmd error: unknown command '%s'\n", argv[0] );
+ return 1;
+ }
}
// get the backup network if the command is going to change the network
@@ -164,9 +174,10 @@ int CmdCommandDispatch( Abc_Frame_t * pAbc, int * pargc, char *** pargv )
SeeAlso []
***********************************************************************/
-char * CmdSplitLine( Abc_Frame_t * pAbc, char *sCommand, int *argc, char ***argv )
+const char * CmdSplitLine( Abc_Frame_t * pAbc, const char *sCommand, int *argc, char ***argv )
{
- char *p, *start, c;
+ const char *p, *start;
+ char c;
int i, j;
char *new_arg;
Vec_Ptr_t * vArgs;
@@ -252,7 +263,8 @@ char * CmdSplitLine( Abc_Frame_t * pAbc, char *sCommand, int *argc, char ***argv
int CmdApplyAlias( Abc_Frame_t * pAbc, int *argcp, char ***argvp, int *loop )
{
int i, argc, stopit, added, offset, did_subst, subst, fError, newc, j;
- char *arg, **argv, **newv;
+ const char *arg;
+ char **argv, **newv;
Abc_Alias *alias;
argc = *argcp;
@@ -519,9 +531,10 @@ void CmdCommandFree( Abc_Command * pCommand )
SeeAlso []
***********************************************************************/
-void CmdCommandPrint( Abc_Frame_t * pAbc, bool fPrintAll )
+void CmdCommandPrint( Abc_Frame_t * pAbc, int fPrintAll )
{
- char *key, *value;
+ const char *key;
+ char *value;
st_generator * gen;
Abc_Command ** ppCommands;
Abc_Command * pCommands;
@@ -555,7 +568,7 @@ void CmdCommandPrint( Abc_Frame_t * pAbc, bool fPrintAll )
nColumns = 79 / (LenghtMax + 2);
// print the starting message
- fprintf( pAbc->Out, " Welcome to ABC!" );
+ fprintf( pAbc->Out, " Welcome to ABC compiled on %s %s!", __DATE__, __TIME__ );
// print the command by group
sGroupCur = NULL;
@@ -654,12 +667,13 @@ int CmdNamePrintCompare( char ** ppC1, char ** ppC2 )
void CmdPrintTable( st_table * tTable, int fAliases )
{
st_generator * gen;
- char ** ppNames;
- char * key, * value;
+ const char ** ppNames;
+ const char * key;
+ char* value;
int nNames, i;
// collect keys in the array
- ppNames = ABC_ALLOC( char *, st_count(tTable) );
+ ppNames = ABC_ALLOC( const char *, st_count(tTable) );
nNames = 0;
st_foreach_item( tTable, gen, &key, &value )
ppNames[nNames++] = key;
@@ -683,3 +697,5 @@ void CmdPrintTable( st_table * tTable, int fAliases )
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/cmd/module.make b/src/base/cmd/module.make
index 1eca3f65..0277c760 100644
--- a/src/base/cmd/module.make
+++ b/src/base/cmd/module.make
@@ -3,4 +3,6 @@ SRC += src/base/cmd/cmd.c \
src/base/cmd/cmdApi.c \
src/base/cmd/cmdFlag.c \
src/base/cmd/cmdHist.c \
+ src/base/cmd/cmdLoad.c \
+ src/base/cmd/cmdPlugin.c \
src/base/cmd/cmdUtils.c
diff --git a/src/base/io/io.c b/src/base/io/io.c
index ecc6302f..eab865d8 100644
--- a/src/base/io/io.c
+++ b/src/base/io/io.c
@@ -21,6 +21,8 @@
#include "ioAbc.h"
#include "mainInt.h"
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -41,6 +43,7 @@ static int IoCommandReadTruth ( Abc_Frame_t * pAbc, int argc, char **argv );
static int IoCommandReadVerilog ( Abc_Frame_t * pAbc, int argc, char **argv );
static int IoCommandReadVer ( Abc_Frame_t * pAbc, int argc, char **argv );
static int IoCommandReadVerLib ( Abc_Frame_t * pAbc, int argc, char **argv );
+static int IoCommandReadStatus ( Abc_Frame_t * pAbc, int argc, char **argv );
static int IoCommandWrite ( Abc_Frame_t * pAbc, int argc, char **argv );
static int IoCommandWriteHie ( Abc_Frame_t * pAbc, int argc, char **argv );
@@ -63,6 +66,10 @@ static int IoCommandWriteVerilog( Abc_Frame_t * pAbc, int argc, char **argv );
static int IoCommandWriteVerLib ( Abc_Frame_t * pAbc, int argc, char **argv );
static int IoCommandWriteSortCnf( Abc_Frame_t * pAbc, int argc, char **argv );
static int IoCommandWriteTruth ( Abc_Frame_t * pAbc, int argc, char **argv );
+static int IoCommandWriteStatus ( Abc_Frame_t * pAbc, int argc, char **argv );
+static int IoCommandWriteSmv ( Abc_Frame_t * pAbc, int argc, char **argv );
+
+extern void Abc_FrameCopyLTLDataBase( Abc_Frame_t *pAbc, Abc_Ntk_t * pNtk );
extern int glo_fMapped;
@@ -99,6 +106,7 @@ void Io_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "I/O", "read_verilog", IoCommandReadVerilog, 1 );
// Cmd_CommandAdd( pAbc, "I/O", "read_ver", IoCommandReadVer, 1 );
// Cmd_CommandAdd( pAbc, "I/O", "read_verlib", IoCommandReadVerLib, 0 );
+ Cmd_CommandAdd( pAbc, "I/O", "read_status", IoCommandReadStatus, 0 );
Cmd_CommandAdd( pAbc, "I/O", "write", IoCommandWrite, 0 );
Cmd_CommandAdd( pAbc, "I/O", "write_hie", IoCommandWriteHie, 0 );
@@ -121,6 +129,8 @@ void Io_Init( Abc_Frame_t * pAbc )
// Cmd_CommandAdd( pAbc, "I/O", "write_verlib", IoCommandWriteVerLib, 0 );
Cmd_CommandAdd( pAbc, "I/O", "write_sorter_cnf", IoCommandWriteSortCnf, 0 );
Cmd_CommandAdd( pAbc, "I/O", "write_truth", IoCommandWriteTruth, 0 );
+ Cmd_CommandAdd( pAbc, "I/O", "write_status", IoCommandWriteStatus, 0 );
+ Cmd_CommandAdd( pAbc, "I/O", "write_smv", IoCommandWriteSmv, 0 );
}
/**Function*************************************************************
@@ -134,7 +144,7 @@ void Io_Init( Abc_Frame_t * pAbc )
SeeAlso []
***********************************************************************/
-void Io_End()
+void Io_End( Abc_Frame_t * pAbc )
{
}
@@ -189,6 +199,8 @@ int IoCommandRead( Abc_Frame_t * pAbc, int argc, char ** argv )
return 1;
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
+ Abc_FrameCopyLTLDataBase( pAbc, pNtk );
+ Abc_FrameClearVerifStatus( pAbc );
return 0;
usage:
@@ -246,11 +258,12 @@ int IoCommandReadAiger( Abc_Frame_t * pAbc, int argc, char ** argv )
return 1;
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
+ Abc_FrameClearVerifStatus( pAbc );
return 0;
usage:
fprintf( pAbc->Err, "usage: read_aiger [-ch] <file>\n" );
- fprintf( pAbc->Err, "\t read the network in the AIGER format (http://fmv.jku.at/aiger)\n" );
+ fprintf( pAbc->Err, "\t reads the network in the AIGER format (http://fmv.jku.at/aiger)\n" );
fprintf( pAbc->Err, "\t-c : toggle network check after reading [default = %s]\n", fCheck? "yes":"no" );
fprintf( pAbc->Err, "\t-h : prints the command summary\n" );
fprintf( pAbc->Err, "\tfile : the name of a file to read\n" );
@@ -300,11 +313,12 @@ int IoCommandReadBaf( Abc_Frame_t * pAbc, int argc, char ** argv )
return 1;
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
+ Abc_FrameClearVerifStatus( pAbc );
return 0;
usage:
fprintf( pAbc->Err, "usage: read_baf [-ch] <file>\n" );
- fprintf( pAbc->Err, "\t read the network in Binary Aig Format (BAF)\n" );
+ fprintf( pAbc->Err, "\t reads the network in Binary Aig Format (BAF)\n" );
fprintf( pAbc->Err, "\t-c : toggle network check after reading [default = %s]\n", fCheck? "yes":"no" );
fprintf( pAbc->Err, "\t-h : prints the command summary\n" );
fprintf( pAbc->Err, "\tfile : the name of a file to read\n" );
@@ -354,11 +368,12 @@ int IoCommandReadBblif( Abc_Frame_t * pAbc, int argc, char ** argv )
return 1;
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
+ Abc_FrameClearVerifStatus( pAbc );
return 0;
usage:
fprintf( pAbc->Err, "usage: read_bblif [-ch] <file>\n" );
- fprintf( pAbc->Err, "\t read the network in a binary BLIF format\n" );
+ fprintf( pAbc->Err, "\t reads the network in a binary BLIF format\n" );
fprintf( pAbc->Err, "\t-c : toggle network check after reading [default = %s]\n", fCheck? "yes":"no" );
fprintf( pAbc->Err, "\t-h : prints the command summary\n" );
fprintf( pAbc->Err, "\tfile : the name of a file to read\n" );
@@ -382,16 +397,21 @@ int IoCommandReadBlif( Abc_Frame_t * pAbc, int argc, char ** argv )
char * pFileName;
int fReadAsAig;
int fCheck;
+ int fUseNewParser;
int c;
extern Abc_Ntk_t * Io_ReadBlifAsAig( char * pFileName, int fCheck );
fCheck = 1;
fReadAsAig = 0;
+ fUseNewParser = 1;
Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "ach" ) ) != EOF )
+ while ( ( c = Extra_UtilGetopt( argc, argv, "nach" ) ) != EOF )
{
switch ( c )
{
+ case 'n':
+ fUseNewParser ^= 1;
+ break;
case 'a':
fReadAsAig ^= 1;
break;
@@ -411,8 +431,9 @@ int IoCommandReadBlif( Abc_Frame_t * pAbc, int argc, char ** argv )
// read the file using the corresponding file reader
if ( fReadAsAig )
pNtk = Io_ReadBlifAsAig( pFileName, fCheck );
+ else if ( fUseNewParser )
+ pNtk = Io_Read( pFileName, IO_FILE_BLIF, fCheck );
else
-// pNtk = Io_Read( pFileName, IO_FILE_BLIF, fCheck );
{
Abc_Ntk_t * pTemp;
pNtk = Io_ReadBlif( pFileName, fCheck );
@@ -426,11 +447,14 @@ int IoCommandReadBlif( Abc_Frame_t * pAbc, int argc, char ** argv )
return 1;
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
+ Abc_FrameClearVerifStatus( pAbc );
return 0;
usage:
- fprintf( pAbc->Err, "usage: read_blif [-ach] <file>\n" );
- fprintf( pAbc->Err, "\t read the network in binary BLIF format\n" );
+ fprintf( pAbc->Err, "usage: read_blif [-nach] <file>\n" );
+ fprintf( pAbc->Err, "\t reads the network in binary BLIF format\n" );
+ fprintf( pAbc->Err, "\t (if this command does not work, try \"read\")\n" );
+ fprintf( pAbc->Err, "\t-n : toggle using old BLIF parser without hierarchy support [default = %s]\n", !fUseNewParser? "yes":"no" );
fprintf( pAbc->Err, "\t-a : toggle creating AIG while reading the file [default = %s]\n", fReadAsAig? "yes":"no" );
fprintf( pAbc->Err, "\t-c : toggle network check after reading [default = %s]\n", fCheck? "yes":"no" );
fprintf( pAbc->Err, "\t-h : prints the command summary\n" );
@@ -481,11 +505,13 @@ int IoCommandReadBlifMv( Abc_Frame_t * pAbc, int argc, char ** argv )
return 1;
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
+ Abc_FrameClearVerifStatus( pAbc );
return 0;
usage:
fprintf( pAbc->Err, "usage: read_blif_mv [-ch] <file>\n" );
- fprintf( pAbc->Err, "\t read the network in BLIF-MV format\n" );
+ fprintf( pAbc->Err, "\t reads the network in BLIF-MV format\n" );
+ fprintf( pAbc->Err, "\t (if this command does not work, try \"read\")\n" );
fprintf( pAbc->Err, "\t-c : toggle network check after reading [default = %s]\n", fCheck? "yes":"no" );
fprintf( pAbc->Err, "\t-h : prints the command summary\n" );
fprintf( pAbc->Err, "\tfile : the name of a file to read\n" );
@@ -535,11 +561,12 @@ int IoCommandReadBench( Abc_Frame_t * pAbc, int argc, char ** argv )
return 1;
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
+ Abc_FrameClearVerifStatus( pAbc );
return 0;
usage:
fprintf( pAbc->Err, "usage: read_bench [-ch] <file>\n" );
- fprintf( pAbc->Err, "\t read the network in BENCH format\n" );
+ fprintf( pAbc->Err, "\t reads the network in BENCH format\n" );
fprintf( pAbc->Err, "\t-c : toggle network check after reading [default = %s]\n", fCheck? "yes":"no" );
fprintf( pAbc->Err, "\t-h : prints the command summary\n" );
fprintf( pAbc->Err, "\tfile : the name of a file to read\n" );
@@ -590,6 +617,7 @@ int IoCommandReadDsd( Abc_Frame_t * pAbc, int argc, char ** argv )
return 1;
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
+ Abc_FrameClearVerifStatus( pAbc );
return 0;
usage:
@@ -650,11 +678,12 @@ int IoCommandReadEdif( Abc_Frame_t * pAbc, int argc, char ** argv )
return 1;
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
+ Abc_FrameClearVerifStatus( pAbc );
return 0;
usage:
fprintf( pAbc->Err, "usage: read_edif [-ch] <file>\n" );
- fprintf( pAbc->Err, "\t read the network in EDIF (works only for ISCAS benchmarks)\n" );
+ fprintf( pAbc->Err, "\t reads the network in EDIF (works only for ISCAS benchmarks)\n" );
fprintf( pAbc->Err, "\t-c : toggle network check after reading [default = %s]\n", fCheck? "yes":"no" );
fprintf( pAbc->Err, "\t-h : prints the command summary\n" );
fprintf( pAbc->Err, "\tfile : the name of a file to read\n" );
@@ -704,11 +733,12 @@ int IoCommandReadEqn( Abc_Frame_t * pAbc, int argc, char ** argv )
return 1;
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
+ Abc_FrameClearVerifStatus( pAbc );
return 0;
usage:
fprintf( pAbc->Err, "usage: read_eqn [-ch] <file>\n" );
- fprintf( pAbc->Err, "\t read the network in equation format\n" );
+ fprintf( pAbc->Err, "\t reads the network in equation format\n" );
fprintf( pAbc->Err, "\t-c : toggle network check after reading [default = %s]\n", fCheck? "yes":"no" );
fprintf( pAbc->Err, "\t-h : prints the command summary\n" );
fprintf( pAbc->Err, "\tfile : the name of a file to read\n" );
@@ -732,7 +762,6 @@ int IoCommandReadInit( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Ntk_t * pNtk;
char * pFileName;
int c;
- extern void Io_ReadBenchInit( Abc_Ntk_t * pNtk, char * pFileName );
pNtk = Abc_FrameReadNtk(pAbc);
pOut = Abc_FrameReadOut(pAbc);
@@ -773,6 +802,7 @@ int IoCommandReadInit( Abc_Frame_t * pAbc, int argc, char ** argv )
Io_ReadBenchInit( pNtk, pFileName );
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
+ Abc_FrameClearVerifStatus( pAbc );
return 0;
usage:
@@ -844,11 +874,12 @@ int IoCommandReadPla( Abc_Frame_t * pAbc, int argc, char ** argv )
return 1;
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
+ Abc_FrameClearVerifStatus( pAbc );
return 0;
usage:
fprintf( pAbc->Err, "usage: read_pla [-zch] <file>\n" );
- fprintf( pAbc->Err, "\t read the network in PLA\n" );
+ fprintf( pAbc->Err, "\t reads the network in PLA\n" );
fprintf( pAbc->Err, "\t-z : toggle reading on-set and off-set [default = %s]\n", fZeros? "off-set":"on-set" );
fprintf( pAbc->Err, "\t-c : toggle network check after reading [default = %s]\n", fCheck? "yes":"no" );
fprintf( pAbc->Err, "\t-h : prints the command summary\n" );
@@ -915,6 +946,7 @@ int IoCommandReadTruth( Abc_Frame_t * pAbc, int argc, char ** argv )
}
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
+ Abc_FrameClearVerifStatus( pAbc );
return 0;
usage:
@@ -973,11 +1005,12 @@ int IoCommandReadVerilog( Abc_Frame_t * pAbc, int argc, char ** argv )
return 1;
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
+ Abc_FrameClearVerifStatus( pAbc );
return 0;
usage:
fprintf( pAbc->Err, "usage: read_verilog [-mch] <file>\n" );
- fprintf( pAbc->Err, "\t read the network in Verilog (IWLS 2002/2005 subset)\n" );
+ fprintf( pAbc->Err, "\t reads the network in Verilog (IWLS 2002/2005 subset)\n" );
fprintf( pAbc->Err, "\t-m : toggle reading mapped Verilog [default = %s]\n", glo_fMapped? "yes":"no" );
fprintf( pAbc->Err, "\t-c : toggle network check after reading [default = %s]\n", fCheck? "yes":"no" );
fprintf( pAbc->Err, "\t-h : prints the command summary\n" );
@@ -1044,7 +1077,7 @@ int IoCommandReadVer( Abc_Frame_t * pAbc, int argc, char ** argv )
fclose( pFile );
// set the new network
- pDesign = Ver_ParseFile( pFileName, Abc_FrameReadLibVer(), fCheck, 1 );
+ pDesign = Ver_ParseFile( pFileName, (Abc_Lib_t *)Abc_FrameReadLibVer(), fCheck, 1 );
if ( pDesign == NULL )
{
fprintf( pAbc->Err, "Reading network from the verilog file has failed.\n" );
@@ -1061,7 +1094,7 @@ int IoCommandReadVer( Abc_Frame_t * pAbc, int argc, char ** argv )
}
// derive the AIG network from this design
- pNtkNew = Abc_LibDeriveAig( pNtk, Abc_FrameReadLibVer() );
+ pNtkNew = Abc_LibDeriveAig( pNtk, (Abc_Lib_t *)Abc_FrameReadLibVer() );
Abc_NtkDelete( pNtk );
if ( pNtkNew == NULL )
{
@@ -1070,11 +1103,12 @@ int IoCommandReadVer( Abc_Frame_t * pAbc, int argc, char ** argv )
}
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtkNew );
+ Abc_FrameClearVerifStatus( pAbc );
return 0;
usage:
fprintf( pAbc->Err, "usage: read_ver [-ch] <file>\n" );
- fprintf( pAbc->Err, "\t read a network in structural verilog (using current library)\n" );
+ fprintf( pAbc->Err, "\t reads a network in structural verilog (using current library)\n" );
fprintf( pAbc->Err, "\t-c : toggle network check after reading [default = %s]\n", fCheck? "yes":"no" );
fprintf( pAbc->Err, "\t-h : prints the command summary\n" );
fprintf( pAbc->Err, "\tfile : the name of a file to read\n" );
@@ -1144,14 +1178,15 @@ int IoCommandReadVerLib( Abc_Frame_t * pAbc, int argc, char ** argv )
printf( "The library contains %d gates.\n", st_count(pLibrary->tModules) );
// free old library
if ( Abc_FrameReadLibVer() )
- Abc_LibFree( Abc_FrameReadLibVer(), NULL );
+ Abc_LibFree( (Abc_Lib_t *)Abc_FrameReadLibVer(), NULL );
// read new library
Abc_FrameSetLibVer( pLibrary );
+ Abc_FrameClearVerifStatus( pAbc );
return 0;
usage:
fprintf( pAbc->Err, "usage: read_verlib [-ch] <file>\n" );
- fprintf( pAbc->Err, "\t read a gate library in structural verilog\n" );
+ fprintf( pAbc->Err, "\t reads a gate library in structural verilog\n" );
fprintf( pAbc->Err, "\t-c : toggle network check after reading [default = %s]\n", fCheck? "yes":"no" );
fprintf( pAbc->Err, "\t-h : prints the command summary\n" );
fprintf( pAbc->Err, "\tfile : the name of a file to read\n" );
@@ -1170,6 +1205,65 @@ usage:
SeeAlso []
***********************************************************************/
+int IoCommandReadStatus( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ char * pFileName;
+ FILE * pFile;
+ int c;
+ extern int Abc_NtkReadLogFile( char * pFileName, Abc_Cex_t ** ppCex );
+
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+ {
+ switch ( c )
+ {
+ case 'h':
+ goto usage;
+ default:
+ goto usage;
+ }
+ }
+ if ( argc != globalUtilOptind + 1 )
+ {
+ goto usage;
+ }
+
+ // get the input file name
+ pFileName = argv[globalUtilOptind];
+ if ( (pFile = fopen( pFileName, "r" )) == NULL )
+ {
+ fprintf( pAbc->Err, "Cannot open input file \"%s\". \n", pFileName );
+ return 1;
+ }
+ fclose( pFile );
+
+ // set the new network
+ Abc_FrameClearVerifStatus( pAbc );
+ pAbc->Status = Abc_NtkReadLogFile( pFileName, &pAbc->pCex );
+ if ( pAbc->pCex )
+ pAbc->nFrames = pAbc->pCex->iFrame;
+ return 0;
+
+usage:
+ fprintf( pAbc->Err, "usage: read_status [-ch] <file>\n" );
+ fprintf( pAbc->Err, "\t reads verification log file\n" );
+ fprintf( pAbc->Err, "\t-h : prints the command summary\n" );
+ fprintf( pAbc->Err, "\tfile : the name of a file to read\n" );
+ return 1;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
int IoCommandWrite( Abc_Frame_t * pAbc, int argc, char **argv )
{
char * pFileName;
@@ -1322,7 +1416,7 @@ int IoCommandWriteAiger( Abc_Frame_t * pAbc, int argc, char **argv )
usage:
fprintf( pAbc->Err, "usage: write_aiger [-sch] <file>\n" );
- fprintf( pAbc->Err, "\t write the network in the AIGER format (http://fmv.jku.at/aiger)\n" );
+ fprintf( pAbc->Err, "\t writes the network in the AIGER format (http://fmv.jku.at/aiger)\n" );
fprintf( pAbc->Err, "\t-s : toggle saving I/O names [default = %s]\n", fWriteSymbols? "yes" : "no" );
fprintf( pAbc->Err, "\t-c : toggle writing more compactly [default = %s]\n", fCompact? "yes" : "no" );
fprintf( pAbc->Err, "\t-h : print the help massage\n" );
@@ -1372,7 +1466,7 @@ int IoCommandWriteBaf( Abc_Frame_t * pAbc, int argc, char **argv )
usage:
fprintf( pAbc->Err, "usage: write_baf [-h] <file>\n" );
- fprintf( pAbc->Err, "\t write the network into a BLIF file\n" );
+ fprintf( pAbc->Err, "\t writes the network into a BLIF file\n" );
fprintf( pAbc->Err, "\t-h : print the help massage\n" );
fprintf( pAbc->Err, "\tfile : the name of the file to write (extension .baf)\n" );
return 1;
@@ -1420,7 +1514,7 @@ int IoCommandWriteBblif( Abc_Frame_t * pAbc, int argc, char **argv )
usage:
fprintf( pAbc->Err, "usage: write_bblif [-h] <file>\n" );
- fprintf( pAbc->Err, "\t write the network into a binary BLIF file\n" );
+ fprintf( pAbc->Err, "\t writes the network into a binary BLIF file\n" );
fprintf( pAbc->Err, "\t-h : print the help massage\n" );
fprintf( pAbc->Err, "\tfile : the name of the file to write (extension .bblif)\n" );
return 1;
@@ -1468,7 +1562,7 @@ int IoCommandWriteBlif( Abc_Frame_t * pAbc, int argc, char **argv )
usage:
fprintf( pAbc->Err, "usage: write_blif [-h] <file>\n" );
- fprintf( pAbc->Err, "\t write the network into a BLIF file\n" );
+ fprintf( pAbc->Err, "\t writes the network into a BLIF file\n" );
fprintf( pAbc->Err, "\t-h : print the help massage\n" );
fprintf( pAbc->Err, "\tfile : the name of the file to write (extension .blif)\n" );
return 1;
@@ -1516,7 +1610,7 @@ int IoCommandWriteBlifMv( Abc_Frame_t * pAbc, int argc, char **argv )
usage:
fprintf( pAbc->Err, "usage: write_blif_mv [-h] <file>\n" );
- fprintf( pAbc->Err, "\t write the network into a BLIF-MV file\n" );
+ fprintf( pAbc->Err, "\t writes the network into a BLIF-MV file\n" );
fprintf( pAbc->Err, "\t-h : print the help massage\n" );
fprintf( pAbc->Err, "\tfile : the name of the file to write (extension .mv)\n" );
return 1;
@@ -1580,7 +1674,7 @@ int IoCommandWriteBench( Abc_Frame_t * pAbc, int argc, char **argv )
usage:
fprintf( pAbc->Err, "usage: write_bench [-lh] <file>\n" );
- fprintf( pAbc->Err, "\t write the network in BENCH format\n" );
+ fprintf( pAbc->Err, "\t writes the network in BENCH format\n" );
fprintf( pAbc->Err, "\t-l : toggle using LUTs in the output [default = %s]\n", fUseLuts? "yes" : "no" );
fprintf( pAbc->Err, "\t-h : print the help massage\n" );
fprintf( pAbc->Err, "\tfile : the name of the file to write (extension .bench)\n" );
@@ -1623,7 +1717,7 @@ int IoCommandWriteBook( Abc_Frame_t * pAbc, int argc, char **argv )
usage:
fprintf( pAbc->Err, "usage: write_book [-h] <file> [-options]\n" );
- fprintf( pAbc->Err, "\t-h : print the help massage\n" );
+ fprintf( pAbc->Err, "\t-h : prints the help massage\n" );
fprintf( pAbc->Err, "\tfile : the name of the file to write (extension .aux, .nodes, .nets)\n" );
fprintf( pAbc->Err, "\t\n" );
fprintf( pAbc->Err, "\tThis command is developed by Myungchul Kim (University of Michigan).\n" );
@@ -1680,7 +1774,7 @@ int IoCommandWriteCellNet( Abc_Frame_t * pAbc, int argc, char **argv )
usage:
fprintf( pAbc->Err, "usage: write_cellnet [-h] <file>\n" );
- fprintf( pAbc->Err, "\t write the network is the cellnet format\n" );
+ fprintf( pAbc->Err, "\t writes the network is the cellnet format\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;
@@ -1750,7 +1844,7 @@ int IoCommandWriteCnf( Abc_Frame_t * pAbc, int argc, char **argv )
usage:
fprintf( pAbc->Err, "usage: write_cnf [-nph] <file>\n" );
- fprintf( pAbc->Err, "\t write the miter cone into a CNF file\n" );
+ fprintf( pAbc->Err, "\t writes the miter cone into a CNF file\n" );
fprintf( pAbc->Err, "\t-n : toggle using new algorithm [default = %s]\n", fNewAlgo? "yes" : "no" );
fprintf( pAbc->Err, "\t-p : toggle using all primes to enhance implicativity [default = %s]\n", fAllPrimes? "yes" : "no" );
fprintf( pAbc->Err, "\t-h : print the help massage\n" );
@@ -1800,14 +1894,19 @@ int IoCommandWriteDot( Abc_Frame_t * pAbc, int argc, char **argv )
usage:
fprintf( pAbc->Err, "usage: write_dot [-h] <file>\n" );
- fprintf( pAbc->Err, "\t write the current network into a DOT file\n" );
+ fprintf( pAbc->Err, "\t writes 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;
}
+ABC_NAMESPACE_IMPL_END
+
#include "fra.h"
+ABC_NAMESPACE_IMPL_START
+
+
/**Function*************************************************************
Synopsis []
@@ -1862,16 +1961,16 @@ int IoCommandWriteCounter( Abc_Frame_t * pAbc, int argc, char **argv )
// get the input file name
pFileName = argv[globalUtilOptind];
- if ( pNtk->pModel == NULL && pNtk->pSeqModel == NULL )
+ if ( pNtk->pModel == NULL && pAbc->pCex == NULL )
{
fprintf( pAbc->Out, "Counter-example is not available.\n" );
return 0;
}
// write the counter-example into the file
- if ( pNtk->pSeqModel )
+ if ( pAbc->pCex )
{
- Fra_Cex_t * pCex = pNtk->pSeqModel;
+ Abc_Cex_t * pCex = pAbc->pCex;
Abc_Obj_t * pObj;
FILE * pFile;
int i, f;
@@ -1919,7 +2018,7 @@ int IoCommandWriteCounter( Abc_Frame_t * pAbc, int argc, char **argv )
}
if ( fNames )
{
- char *cycle_ctr = forceSeq?"@0":"";
+ const char *cycle_ctr = forceSeq?"@0":"";
Abc_NtkForEachPi( pNtk, pObj, i )
// fprintf( pFile, "%s=%c\n", Abc_ObjName(pObj), '0'+(pNtk->pModel[i]==1) );
fprintf( pFile, "%s%s=%c\n", Abc_ObjName(pObj), cycle_ctr, '0'+(pNtk->pModel[i]==1) );
@@ -1989,7 +2088,7 @@ int IoCommandWriteEqn( Abc_Frame_t * pAbc, int argc, char **argv )
usage:
fprintf( pAbc->Err, "usage: write_eqn [-h] <file>\n" );
- fprintf( pAbc->Err, "\t write the current network in the equation format\n" );
+ fprintf( pAbc->Err, "\t writes the current network in the equation format\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;
@@ -2037,7 +2136,7 @@ int IoCommandWriteGml( Abc_Frame_t * pAbc, int argc, char **argv )
usage:
fprintf( pAbc->Err, "usage: write_gml [-h] <file>\n" );
- fprintf( pAbc->Err, "\t write network using graph representation formal GML\n" );
+ fprintf( pAbc->Err, "\t writes network using graph representation formal GML\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;
@@ -2100,7 +2199,7 @@ int IoCommandWriteList( Abc_Frame_t * pAbc, int argc, char **argv )
usage:
fprintf( pAbc->Err, "usage: write_list [-nh] <file>\n" );
- fprintf( pAbc->Err, "\t write network using graph representation formal GML\n" );
+ fprintf( pAbc->Err, "\t writes network using graph representation formal GML\n" );
fprintf( pAbc->Err, "\t-n : toggle writing host node [default = %s]\n", fUseHost? "yes":"no" );
fprintf( pAbc->Err, "\t-h : print the help massage\n" );
fprintf( pAbc->Err, "\tfile : the name of the file to write\n" );
@@ -2149,7 +2248,7 @@ int IoCommandWritePla( Abc_Frame_t * pAbc, int argc, char **argv )
usage:
fprintf( pAbc->Err, "usage: write_pla [-h] <file>\n" );
- fprintf( pAbc->Err, "\t write the collapsed network into a PLA file\n" );
+ fprintf( pAbc->Err, "\t writes the collapsed network into a PLA 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;
@@ -2197,7 +2296,7 @@ int IoCommandWriteVerilog( Abc_Frame_t * pAbc, int argc, char **argv )
usage:
fprintf( pAbc->Err, "usage: write_verilog [-h] <file>\n" );
- fprintf( pAbc->Err, "\t write the current network in Verilog format\n" );
+ fprintf( pAbc->Err, "\t writes the current network in Verilog format\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;
@@ -2237,7 +2336,7 @@ int IoCommandWriteVerLib( Abc_Frame_t * pAbc, int argc, char **argv )
// get the input file name
pFileName = argv[globalUtilOptind];
// derive the netlist
- pLibrary = Abc_FrameReadLibVer();
+ pLibrary = (Abc_Lib_t *)Abc_FrameReadLibVer();
if ( pLibrary == NULL )
{
fprintf( pAbc->Out, "Verilog library is not specified.\n" );
@@ -2248,7 +2347,7 @@ int IoCommandWriteVerLib( Abc_Frame_t * pAbc, int argc, char **argv )
usage:
fprintf( pAbc->Err, "usage: write_verlib [-h] <file>\n" );
- fprintf( pAbc->Err, "\t write the current verilog library\n" );
+ fprintf( pAbc->Err, "\t writes the current verilog library\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;
@@ -2316,7 +2415,7 @@ int IoCommandWriteSortCnf( Abc_Frame_t * pAbc, int argc, char **argv )
usage:
fprintf( pAbc->Err, "usage: write_sorter_cnf [-N <num>] [-Q <num>] <file>\n" );
- fprintf( pAbc->Err, "\t write CNF for the sorter\n" );
+ fprintf( pAbc->Err, "\t writes CNF for the sorter\n" );
fprintf( pAbc->Err, "\t-N num : the number of sorter bits [default = %d]\n", nVars );
fprintf( pAbc->Err, "\t-Q num : the number of bits to be asserted to 1 [default = %d]\n", nQueens );
fprintf( pAbc->Err, "\t-h : print the help massage\n" );
@@ -2398,7 +2497,7 @@ int IoCommandWriteTruth( Abc_Frame_t * pAbc, int argc, char **argv )
// convert to logic
Abc_NtkToAig( pNtk );
vTruth = Vec_IntAlloc( 0 );
- pTruth = Hop_ManConvertAigToTruth( pNtk->pManFunc, pNode->pData, Abc_ObjFaninNum(pNode), vTruth, fReverse );
+ pTruth = Hop_ManConvertAigToTruth( (Hop_Man_t *)pNtk->pManFunc, (Hop_Obj_t *)pNode->pData, Abc_ObjFaninNum(pNode), vTruth, fReverse );
pFile = fopen( pFileName, "w" );
if ( pFile == NULL )
{
@@ -2420,8 +2519,102 @@ usage:
return 1;
}
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int IoCommandWriteStatus( Abc_Frame_t * pAbc, int argc, char **argv )
+{
+ char * pFileName;
+ int c;
+ extern void Abc_NtkWriteLogFile( char * pFileName, Abc_Cex_t * pCex, int Status, char * pCommand );
+
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+ {
+ switch ( c )
+ {
+ case 'h':
+ goto usage;
+ default:
+ goto usage;
+ }
+ }
+ if ( argc != globalUtilOptind + 1 )
+ goto usage;
+ // get the input file name
+ pFileName = argv[globalUtilOptind];
+ Abc_NtkWriteLogFile( pFileName, pAbc->pCex, pAbc->Status, NULL );
+ return 0;
+
+usage:
+ fprintf( pAbc->Err, "usage: write_status [-h] <file>\n" );
+ fprintf( pAbc->Err, "\t writes verification log 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;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int IoCommandWriteSmv( Abc_Frame_t * pAbc, int argc, char **argv )
+{
+ char * pFileName;
+ int fUseLuts;
+ int c;
+
+ fUseLuts = 0;
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+ {
+ switch ( c )
+ {
+ case 'h':
+ goto usage;
+ default:
+ goto usage;
+ }
+ }
+ if ( pAbc->pNtkCur == NULL )
+ {
+ fprintf( pAbc->Out, "Empty network.\n" );
+ return 0;
+ }
+ if ( argc != globalUtilOptind + 1 )
+ goto usage;
+ // get the output file name
+ pFileName = argv[globalUtilOptind];
+ // call the corresponding file writer
+ Io_Write( pAbc->pNtkCur, pFileName, IO_FILE_SMV );
+ return 0;
+
+usage:
+ fprintf( pAbc->Err, "usage: write_smv [-h] <file>\n" );
+ fprintf( pAbc->Err, "\t write the network in SMV format\n" );
+ fprintf( pAbc->Err, "\t-h : print the help message\n" );
+ fprintf( pAbc->Err, "\tfile : the name of the file to write (extension .smv)\n" );
+ return 1;
+}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/io/ioAbc.h b/src/base/io/ioAbc.h
index bade17df..b1835dbf 100644
--- a/src/base/io/ioAbc.h
+++ b/src/base/io/ioAbc.h
@@ -21,6 +21,7 @@
#ifndef __IO_H__
#define __IO_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -31,9 +32,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -56,6 +58,7 @@ typedef enum {
IO_FILE_GML,
IO_FILE_LIST,
IO_FILE_PLA,
+ IO_FILE_SMV,
IO_FILE_VERILOG,
IO_FILE_UNKNOWN
} Io_FileType_t;
@@ -82,6 +85,7 @@ extern Abc_Ntk_t * Io_ReadBlif( char * pFileName, int fCheck );
extern Abc_Ntk_t * Io_ReadBlifMv( char * pFileName, int fBlifMv, int fCheck );
/*=== abcReadBench.c ==========================================================*/
extern Abc_Ntk_t * Io_ReadBench( char * pFileName, int fCheck );
+extern void Io_ReadBenchInit( Abc_Ntk_t * pNtk, char * pFileName );
/*=== abcReadEdif.c ===========================================================*/
extern Abc_Ntk_t * Io_ReadEdif( char * pFileName, int fCheck );
/*=== abcReadEqn.c ============================================================*/
@@ -98,12 +102,12 @@ extern void Io_WriteBaf( Abc_Ntk_t * pNtk, char * pFileName );
extern void Io_WriteBblif( Abc_Ntk_t * pNtk, char * pFileName );
/*=== abcWriteBlif.c ==========================================================*/
extern void Io_WriteBlifLogic( Abc_Ntk_t * pNtk, char * pFileName, int fWriteLatches );
-extern void Io_WriteBlif( Abc_Ntk_t * pNtk, char * pFileName, int fWriteLatches );
+extern void Io_WriteBlif( Abc_Ntk_t * pNtk, char * pFileName, int fWriteLatches, int fBb2Wb, int fSeq );
extern void Io_WriteTimingInfo( FILE * pFile, Abc_Ntk_t * pNtk );
/*=== abcWriteBlifMv.c ==========================================================*/
extern void Io_WriteBlifMv( Abc_Ntk_t * pNtk, char * FileName );
/*=== abcWriteBench.c =========================================================*/
-extern int Io_WriteBench( Abc_Ntk_t * pNtk, char * FileName );
+extern int Io_WriteBench( Abc_Ntk_t * pNtk, const char * FileName );
extern int Io_WriteBenchLut( Abc_Ntk_t * pNtk, char * FileName );
/*=== abcWriteBook.c =========================================================*/
extern void Io_WriteBook( Abc_Ntk_t * pNtk, char * FileName );
@@ -121,6 +125,8 @@ extern void Io_WriteGml( Abc_Ntk_t * pNtk, char * pFileName );
extern void Io_WriteList( Abc_Ntk_t * pNtk, char * pFileName, int fUseHost );
/*=== abcWritePla.c ===========================================================*/
extern int Io_WritePla( Abc_Ntk_t * pNtk, char * FileName );
+/*=== abcWriteSmv.c ===========================================================*/
+extern int Io_WriteSmv( Abc_Ntk_t * pNtk, char * FileName );
/*=== abcWriteVerilog.c =======================================================*/
extern void Io_WriteVerilog( Abc_Ntk_t * pNtk, char * FileName );
/*=== abcUtil.c ===============================================================*/
@@ -136,15 +142,17 @@ extern Abc_Obj_t * Io_ReadCreateLatch( Abc_Ntk_t * pNtk, char * pNetLI, c
extern Abc_Obj_t * Io_ReadCreateResetLatch( Abc_Ntk_t * pNtk, int fBlifMv );
extern Abc_Obj_t * Io_ReadCreateResetMux( Abc_Ntk_t * pNtk, char * pResetLO, char * pDataLI, int fBlifMv );
extern Abc_Obj_t * Io_ReadCreateNode( Abc_Ntk_t * pNtk, char * pNameOut, char * pNamesIn[], int nInputs );
-extern Abc_Obj_t * Io_ReadCreateConst( Abc_Ntk_t * pNtk, char * pName, bool fConst1 );
+extern Abc_Obj_t * Io_ReadCreateConst( Abc_Ntk_t * pNtk, char * pName, int fConst1 );
extern Abc_Obj_t * Io_ReadCreateInv( Abc_Ntk_t * pNtk, char * pNameIn, char * pNameOut );
extern Abc_Obj_t * Io_ReadCreateBuf( Abc_Ntk_t * pNtk, char * pNameIn, char * pNameOut );
extern FILE * Io_FileOpen( const char * FileName, const char * PathVar, const char * Mode, int fVerbose );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/base/io/ioInt.h b/src/base/io/ioInt.h
index 3daf3c75..9ded63e4 100644
--- a/src/base/io/ioInt.h
+++ b/src/base/io/ioInt.h
@@ -21,6 +21,10 @@
#ifndef __IO_INT_H__
#define __IO_INT_H__
+
+ABC_NAMESPACE_HEADER_START
+
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -41,6 +45,10 @@
/// FUNCTION DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif
////////////////////////////////////////////////////////////////////////
diff --git a/src/base/io/ioReadAiger.c b/src/base/io/ioReadAiger.c
index 85475204..61d2967b 100644
--- a/src/base/io/ioReadAiger.c
+++ b/src/base/io/ioReadAiger.c
@@ -21,10 +21,13 @@
// The code in this file is developed in collaboration with Mark Jarvin of Toronto.
-#include "ioAbc.h"
#include "bzlib.h"
+#include "ioAbc.h"
#include "zlib.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -190,7 +193,7 @@ static char * Ioa_ReadLoadFileBz2Aig( char * pFileName, int * pFileSize )
static char * Ioa_ReadLoadFileGzAig( char * pFileName, int * pFileSize )
{
const int READ_BLOCK_SIZE = 100000;
- FILE * pFile;
+ gzFile pFile;
char * pContents;
int amtRead, readBlock, nFileSize = READ_BLOCK_SIZE;
pFile = gzopen( pFileName, "rb" ); // if pFileName doesn't end in ".gz" then this acts as a passthrough to fopen
@@ -340,10 +343,10 @@ Abc_Ntk_t * Io_ReadAiger( char * pFileName, int fCheck )
uLit1 = uLit - Io_ReadAigerDecode( &pCur );
uLit0 = uLit1 - Io_ReadAigerDecode( &pCur );
// assert( uLit1 > uLit0 );
- pNode0 = Abc_ObjNotCond( Vec_PtrEntry(vNodes, uLit0 >> 1), uLit0 & 1 );
- pNode1 = Abc_ObjNotCond( Vec_PtrEntry(vNodes, uLit1 >> 1), uLit1 & 1 );
+ pNode0 = Abc_ObjNotCond( (Abc_Obj_t *)Vec_PtrEntry(vNodes, uLit0 >> 1), uLit0 & 1 );
+ pNode1 = Abc_ObjNotCond( (Abc_Obj_t *)Vec_PtrEntry(vNodes, uLit1 >> 1), uLit1 & 1 );
assert( Vec_PtrSize(vNodes) == i + 1 + nInputs + nLatches );
- Vec_PtrPush( vNodes, Abc_AigAnd(pNtkNew->pManFunc, pNode0, pNode1) );
+ Vec_PtrPush( vNodes, Abc_AigAnd((Abc_Aig_t *)pNtkNew->pManFunc, pNode0, pNode1) );
}
Extra_ProgressBarStop( pProgress );
@@ -357,14 +360,14 @@ Abc_Ntk_t * Io_ReadAiger( char * pFileName, int fCheck )
Abc_NtkForEachLatchInput( pNtkNew, pObj, i )
{
uLit0 = atoi( pCur ); while ( *pCur++ != '\n' );
- pNode0 = Abc_ObjNotCond( Vec_PtrEntry(vNodes, uLit0 >> 1), (uLit0 & 1) );//^ (uLit0 < 2) );
+ pNode0 = Abc_ObjNotCond( (Abc_Obj_t *)Vec_PtrEntry(vNodes, uLit0 >> 1), (uLit0 & 1) );//^ (uLit0 < 2) );
Abc_ObjAddFanin( pObj, pNode0 );
}
// read the PO driver literals
Abc_NtkForEachPo( pNtkNew, pObj, i )
{
uLit0 = atoi( pCur ); while ( *pCur++ != '\n' );
- pNode0 = Abc_ObjNotCond( Vec_PtrEntry(vNodes, uLit0 >> 1), (uLit0 & 1) );//^ (uLit0 < 2) );
+ pNode0 = Abc_ObjNotCond( (Abc_Obj_t *)Vec_PtrEntry(vNodes, uLit0 >> 1), (uLit0 & 1) );//^ (uLit0 < 2) );
Abc_ObjAddFanin( pObj, pNode0 );
}
}
@@ -374,14 +377,14 @@ Abc_Ntk_t * Io_ReadAiger( char * pFileName, int fCheck )
Abc_NtkForEachLatchInput( pNtkNew, pObj, i )
{
uLit0 = Vec_IntEntry( vLits, i );
- pNode0 = Abc_ObjNotCond( Vec_PtrEntry(vNodes, uLit0 >> 1), (uLit0 & 1) );
+ pNode0 = Abc_ObjNotCond( (Abc_Obj_t *)Vec_PtrEntry(vNodes, uLit0 >> 1), (uLit0 & 1) );
Abc_ObjAddFanin( pObj, pNode0 );
}
// read the PO driver literals
Abc_NtkForEachPo( pNtkNew, pObj, i )
{
uLit0 = Vec_IntEntry( vLits, i+Abc_NtkLatchNum(pNtkNew) );
- pNode0 = Abc_ObjNotCond( Vec_PtrEntry(vNodes, uLit0 >> 1), (uLit0 & 1) );
+ pNode0 = Abc_ObjNotCond( (Abc_Obj_t *)Vec_PtrEntry(vNodes, uLit0 >> 1), (uLit0 & 1) );
Abc_ObjAddFanin( pObj, pNode0 );
}
Vec_IntFree( vLits );
@@ -415,7 +418,7 @@ Abc_Ntk_t * Io_ReadAiger( char * pFileName, int fCheck )
fprintf( stdout, "The number of terminal is out of bound.\n" );
return NULL;
}
- pObj = Vec_PtrEntry( vTerms, iTerm );
+ pObj = (Abc_Obj_t *)Vec_PtrEntry( vTerms, iTerm );
if ( *pType == 'l' )
pObj = Abc_ObjFanout0(pObj);
// assign the name
@@ -481,7 +484,7 @@ Abc_Ntk_t * Io_ReadAiger( char * pFileName, int fCheck )
Vec_PtrFree( vNodes );
// remove the extra nodes
- Abc_AigCleanup( pNtkNew->pManFunc );
+ Abc_AigCleanup( (Abc_Aig_t *)pNtkNew->pManFunc );
// check the result
if ( fCheck && !Abc_NtkCheckRead( pNtkNew ) )
@@ -500,3 +503,5 @@ Abc_Ntk_t * Io_ReadAiger( char * pFileName, int fCheck )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/io/ioReadBaf.c b/src/base/io/ioReadBaf.c
index 495f122b..95c63539 100644
--- a/src/base/io/ioReadBaf.c
+++ b/src/base/io/ioReadBaf.c
@@ -20,6 +20,9 @@
#include "ioAbc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -128,9 +131,9 @@ Abc_Ntk_t * Io_ReadBaf( char * pFileName, int fCheck )
for ( i = 0; i < nAnds; i++ )
{
Extra_ProgressBarUpdate( pProgress, i, NULL );
- pNode0 = Abc_ObjNotCond( Vec_PtrEntry(vNodes, pBufferNode[2*i+0] >> 1), pBufferNode[2*i+0] & 1 );
- pNode1 = Abc_ObjNotCond( Vec_PtrEntry(vNodes, pBufferNode[2*i+1] >> 1), pBufferNode[2*i+1] & 1 );
- Vec_PtrPush( vNodes, Abc_AigAnd(pNtkNew->pManFunc, pNode0, pNode1) );
+ pNode0 = Abc_ObjNotCond( (Abc_Obj_t *)Vec_PtrEntry(vNodes, pBufferNode[2*i+0] >> 1), pBufferNode[2*i+0] & 1 );
+ pNode1 = Abc_ObjNotCond( (Abc_Obj_t *)Vec_PtrEntry(vNodes, pBufferNode[2*i+1] >> 1), pBufferNode[2*i+1] & 1 );
+ Vec_PtrPush( vNodes, Abc_AigAnd((Abc_Aig_t *)pNtkNew->pManFunc, pNode0, pNode1) );
}
Extra_ProgressBarStop( pProgress );
@@ -143,14 +146,14 @@ Abc_Ntk_t * Io_ReadBaf( char * pFileName, int fCheck )
Abc_ObjSetData( Abc_ObjFanout0(pObj), (void *)(ABC_PTRINT_T)(Num & 3) );
Num >>= 2;
}
- pNode0 = Abc_ObjNotCond( Vec_PtrEntry(vNodes, Num >> 1), Num & 1 );
+ pNode0 = Abc_ObjNotCond( (Abc_Obj_t *)Vec_PtrEntry(vNodes, Num >> 1), Num & 1 );
Abc_ObjAddFanin( pObj, pNode0 );
}
ABC_FREE( pContents );
Vec_PtrFree( vNodes );
// remove the extra nodes
-// Abc_AigCleanup( pNtkNew->pManFunc );
+// Abc_AigCleanup( (Abc_Aig_t *)pNtkNew->pManFunc );
// check the result
if ( fCheck && !Abc_NtkCheckRead( pNtkNew ) )
@@ -169,3 +172,5 @@ Abc_Ntk_t * Io_ReadBaf( char * pFileName, int fCheck )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/io/ioReadBblif.c b/src/base/io/ioReadBblif.c
index 84ef1e29..e2fcca43 100644
--- a/src/base/io/ioReadBblif.c
+++ b/src/base/io/ioReadBblif.c
@@ -22,6 +22,9 @@
#include "dec.h"
#include "bblif.h"
+ABC_NAMESPACE_IMPL_START
+
+
// For description of Binary BLIF format, refer to "abc/src/aig/bbl/bblif.h"
////////////////////////////////////////////////////////////////////////
@@ -70,13 +73,13 @@ Abc_Ntk_t * Bbl_ManToAbc( Bbl_Man_t * p )
pObjNew = Abc_NtkCreateNode( pNtk );
else assert( 0 );
if ( Bbl_ObjIsLut(pObj) )
- pObjNew->pData = Abc_SopRegister( pNtk->pManFunc, Bbl_ObjSop(p, pObj) );
+ pObjNew->pData = Abc_SopRegister( (Extra_MmFlex_t *)pNtk->pManFunc, Bbl_ObjSop(p, pObj) );
Vec_PtrSetEntry( vCopy, Bbl_ObjId(pObj), pObjNew );
}
// connect objects
Bbl_ManForEachObj( p, pObj )
Bbl_ObjForEachFanin( pObj, pFanin )
- Abc_ObjAddFanin( Vec_PtrEntry(vCopy, Bbl_ObjId(pObj)), Vec_PtrEntry(vCopy, Bbl_ObjId(pFanin)) );
+ Abc_ObjAddFanin( (Abc_Obj_t *)Vec_PtrEntry(vCopy, Bbl_ObjId(pObj)), (Abc_Obj_t *)Vec_PtrEntry(vCopy, Bbl_ObjId(pFanin)) );
// finalize
Vec_PtrFree( vCopy );
Abc_NtkAddDummyPiNames( pNtk );
@@ -185,7 +188,7 @@ clk = clock();
// create internal nodes
vNodes = Bbl_ManDfs( p );
vFaninAigs = Vec_PtrAlloc( 100 );
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Bbl_Obj_t *, vNodes, pObj, i )
{
// collect fanin AIGs
Vec_PtrClear( vFaninAigs );
@@ -204,10 +207,10 @@ ABC_PRT( "AIG", clock() - clk );
{
if ( !Bbl_ObjIsOutput(pObj) )
continue;
- pObjNew = Vec_PtrEntry( vCopy, Bbl_ObjId(Bbl_ObjFaninFirst(pObj)) );
+ pObjNew = (Abc_Obj_t *)Vec_PtrEntry( vCopy, Bbl_ObjId(Bbl_ObjFaninFirst(pObj)) );
Abc_ObjAddFanin( Abc_NtkCreatePo(pNtk), pObjNew );
}
- Abc_AigCleanup( pNtk->pManFunc );
+ Abc_AigCleanup( (Abc_Aig_t *)pNtk->pManFunc );
// clear factored forms
for ( i = Bbl_ManFncSize(p) - 1; i >= 0; i-- )
if ( pFForms[i] )
@@ -340,3 +343,5 @@ Abc_Ntk_t * Io_ReadBblif( char * pFileName, int fCheck )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/io/ioReadBench.c b/src/base/io/ioReadBench.c
index e7a2d2fe..681a4e36 100644
--- a/src/base/io/ioReadBench.c
+++ b/src/base/io/ioReadBench.c
@@ -20,6 +20,9 @@
#include "ioAbc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -95,7 +98,7 @@ Abc_Ntk_t * Io_ReadBenchNetwork( Extra_FileReader_t * p )
// go through the lines of the file
vString = Vec_StrAlloc( 100 );
pProgress = Extra_ProgressBarStart( stdout, Extra_FileReaderGetFileSize(p) );
- for ( iLine = 0; (vTokens = Extra_FileReaderGetTokens(p)); iLine++ )
+ for ( iLine = 0; (vTokens = (Vec_Ptr_t *)Extra_FileReaderGetTokens(p)); iLine++ )
{
Extra_ProgressBarUpdate( pProgress, Extra_FileReaderGetCurPosition(p), NULL );
@@ -108,17 +111,17 @@ Abc_Ntk_t * Io_ReadBenchNetwork( Extra_FileReader_t * p )
}
// get the type of the line
- if ( strncmp( vTokens->pArray[0], "INPUT", 5 ) == 0 )
- Io_ReadCreatePi( pNtk, vTokens->pArray[1] );
- else if ( strncmp( vTokens->pArray[0], "OUTPUT", 5 ) == 0 )
- Io_ReadCreatePo( pNtk, vTokens->pArray[1] );
+ if ( strncmp( (char *)vTokens->pArray[0], "INPUT", 5 ) == 0 )
+ Io_ReadCreatePi( pNtk, (char *)vTokens->pArray[1] );
+ else if ( strncmp( (char *)vTokens->pArray[0], "OUTPUT", 5 ) == 0 )
+ Io_ReadCreatePo( pNtk, (char *)vTokens->pArray[1] );
else
{
// get the node name and the node type
- pType = vTokens->pArray[1];
+ pType = (char *)vTokens->pArray[1];
if ( strncmp(pType, "DFF", 3) == 0 ) // works for both DFF and DFFRSE
{
- pNode = Io_ReadCreateLatch( pNtk, vTokens->pArray[2], vTokens->pArray[0] );
+ pNode = Io_ReadCreateLatch( pNtk, (char *)vTokens->pArray[2], (char *)vTokens->pArray[0] );
// Abc_LatchSetInit0( pNode );
if ( pType[3] == '0' )
Abc_LatchSetInit0( pNode );
@@ -141,7 +144,7 @@ Abc_Ntk_t * Io_ReadBenchNetwork( Extra_FileReader_t * p )
return NULL;
}
// get the hex string
- pString = vTokens->pArray[2];
+ pString = (char *)vTokens->pArray[2];
if ( strncmp( pString, "0x", 2 ) )
{
printf( "%s: The LUT signature (%s) does not look like a hexadecimal beginning with \"0x\".\n", Extra_FileReaderGetFileName(p), pString );
@@ -172,25 +175,25 @@ Abc_Ntk_t * Io_ReadBenchNetwork( Extra_FileReader_t * p )
// check if the node is a constant node
if ( Extra_TruthIsConst0(uTruth, nNames) )
{
- pNode = Io_ReadCreateNode( pNtk, vTokens->pArray[0], ppNames, 0 );
- Abc_ObjSetData( pNode, Abc_SopRegister( pNtk->pManFunc, " 0\n" ) );
+ pNode = Io_ReadCreateNode( pNtk, (char *)vTokens->pArray[0], ppNames, 0 );
+ Abc_ObjSetData( pNode, Abc_SopRegister( (Extra_MmFlex_t *)pNtk->pManFunc, " 0\n" ) );
}
else if ( Extra_TruthIsConst1(uTruth, nNames) )
{
- pNode = Io_ReadCreateNode( pNtk, vTokens->pArray[0], ppNames, 0 );
- Abc_ObjSetData( pNode, Abc_SopRegister( pNtk->pManFunc, " 1\n" ) );
+ pNode = Io_ReadCreateNode( pNtk, (char *)vTokens->pArray[0], ppNames, 0 );
+ Abc_ObjSetData( pNode, Abc_SopRegister( (Extra_MmFlex_t *)pNtk->pManFunc, " 1\n" ) );
}
else
{
// create the node
- pNode = Io_ReadCreateNode( pNtk, vTokens->pArray[0], ppNames, nNames );
+ pNode = Io_ReadCreateNode( pNtk, (char *)vTokens->pArray[0], ppNames, nNames );
assert( nNames > 0 );
if ( nNames > 1 )
- Abc_ObjSetData( pNode, Abc_SopCreateFromTruth(pNtk->pManFunc, nNames, uTruth) );
+ Abc_ObjSetData( pNode, Abc_SopCreateFromTruth((Extra_MmFlex_t *)pNtk->pManFunc, nNames, uTruth) );
else if ( pString[0] == '2' )
- Abc_ObjSetData( pNode, Abc_SopCreateBuf(pNtk->pManFunc) );
+ Abc_ObjSetData( pNode, Abc_SopCreateBuf((Extra_MmFlex_t *)pNtk->pManFunc) );
else if ( pString[0] == '1' )
- Abc_ObjSetData( pNode, Abc_SopCreateInv(pNtk->pManFunc) );
+ Abc_ObjSetData( pNode, Abc_SopCreateInv((Extra_MmFlex_t *)pNtk->pManFunc) );
else
{
printf( "%s: Reading truth table (%s) of single-input node has failed.\n", Extra_FileReaderGetFileName(p), pString );
@@ -205,31 +208,31 @@ Abc_Ntk_t * Io_ReadBenchNetwork( Extra_FileReader_t * p )
// create a new node and add it to the network
ppNames = (char **)vTokens->pArray + 2;
nNames = vTokens->nSize - 2;
- pNode = Io_ReadCreateNode( pNtk, vTokens->pArray[0], ppNames, nNames );
+ pNode = Io_ReadCreateNode( pNtk, (char *)vTokens->pArray[0], ppNames, nNames );
// assign the cover
if ( strcmp(pType, "AND") == 0 )
- Abc_ObjSetData( pNode, Abc_SopCreateAnd(pNtk->pManFunc, nNames, NULL) );
+ Abc_ObjSetData( pNode, Abc_SopCreateAnd((Extra_MmFlex_t *)pNtk->pManFunc, nNames, NULL) );
else if ( strcmp(pType, "OR") == 0 )
- Abc_ObjSetData( pNode, Abc_SopCreateOr(pNtk->pManFunc, nNames, NULL) );
+ Abc_ObjSetData( pNode, Abc_SopCreateOr((Extra_MmFlex_t *)pNtk->pManFunc, nNames, NULL) );
else if ( strcmp(pType, "NAND") == 0 )
- Abc_ObjSetData( pNode, Abc_SopCreateNand(pNtk->pManFunc, nNames) );
+ Abc_ObjSetData( pNode, Abc_SopCreateNand((Extra_MmFlex_t *)pNtk->pManFunc, nNames) );
else if ( strcmp(pType, "NOR") == 0 )
- Abc_ObjSetData( pNode, Abc_SopCreateNor(pNtk->pManFunc, nNames) );
+ Abc_ObjSetData( pNode, Abc_SopCreateNor((Extra_MmFlex_t *)pNtk->pManFunc, nNames) );
else if ( strcmp(pType, "XOR") == 0 )
- Abc_ObjSetData( pNode, Abc_SopCreateXor(pNtk->pManFunc, nNames) );
+ Abc_ObjSetData( pNode, Abc_SopCreateXor((Extra_MmFlex_t *)pNtk->pManFunc, nNames) );
else if ( strcmp(pType, "NXOR") == 0 || strcmp(pType, "XNOR") == 0 )
- Abc_ObjSetData( pNode, Abc_SopCreateNxor(pNtk->pManFunc, nNames) );
+ Abc_ObjSetData( pNode, Abc_SopCreateNxor((Extra_MmFlex_t *)pNtk->pManFunc, nNames) );
else if ( strncmp(pType, "BUF", 3) == 0 )
- Abc_ObjSetData( pNode, Abc_SopCreateBuf(pNtk->pManFunc) );
+ Abc_ObjSetData( pNode, Abc_SopCreateBuf((Extra_MmFlex_t *)pNtk->pManFunc) );
else if ( strcmp(pType, "NOT") == 0 )
- Abc_ObjSetData( pNode, Abc_SopCreateInv(pNtk->pManFunc) );
+ Abc_ObjSetData( pNode, Abc_SopCreateInv((Extra_MmFlex_t *)pNtk->pManFunc) );
else if ( strncmp(pType, "MUX", 3) == 0 )
// Abc_ObjSetData( pNode, Abc_SopRegister(pNtk->pManFunc, "1-0 1\n-11 1\n") );
- Abc_ObjSetData( pNode, Abc_SopRegister(pNtk->pManFunc, "0-1 1\n11- 1\n") );
+ Abc_ObjSetData( pNode, Abc_SopRegister((Extra_MmFlex_t *)pNtk->pManFunc, "0-1 1\n11- 1\n") );
else if ( strncmp(pType, "gnd", 3) == 0 )
- Abc_ObjSetData( pNode, Abc_SopRegister( pNtk->pManFunc, " 0\n" ) );
+ Abc_ObjSetData( pNode, Abc_SopRegister( (Extra_MmFlex_t *)pNtk->pManFunc, " 0\n" ) );
else if ( strncmp(pType, "vdd", 3) == 0 )
- Abc_ObjSetData( pNode, Abc_SopRegister( pNtk->pManFunc, " 1\n" ) );
+ Abc_ObjSetData( pNode, Abc_SopRegister( (Extra_MmFlex_t *)pNtk->pManFunc, " 1\n" ) );
else
{
printf( "Io_ReadBenchNetwork(): Cannot determine gate type \"%s\" in line %d.\n", pType, Extra_FileReaderGetLineNumber(p, 0) );
@@ -359,3 +362,5 @@ void Io_ReadBenchInit( Abc_Ntk_t * pNtk, char * pFileName )
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/io/ioReadBlif.c b/src/base/io/ioReadBlif.c
index f2c3e8c2..06920afe 100644
--- a/src/base/io/ioReadBlif.c
+++ b/src/base/io/ioReadBlif.c
@@ -22,6 +22,9 @@
#include "main.h"
#include "mio.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -128,7 +131,7 @@ Abc_Ntk_t * Io_ReadBlifNetwork( Io_ReadBlif_t * p )
// read the name of the master network
p->vTokens = Io_ReadBlifGetTokens(p);
- if ( p->vTokens == NULL || strcmp( p->vTokens->pArray[0], ".model" ) )
+ if ( p->vTokens == NULL || strcmp( (char *)p->vTokens->pArray[0], ".model" ) )
{
p->LineCur = 0;
sprintf( p->sError, "Wrong input file format." );
@@ -144,7 +147,7 @@ Abc_Ntk_t * Io_ReadBlifNetwork( Io_ReadBlif_t * p )
pNtk = Io_ReadBlifNetworkOne( p );
if ( pNtk == NULL )
break;
- if ( p->vTokens && strcmp(p->vTokens->pArray[0], ".exdc") == 0 )
+ if ( p->vTokens && strcmp((char *)p->vTokens->pArray[0], ".exdc") == 0 )
{
pNtk->pExdc = Io_ReadBlifNetworkOne( p );
Abc_NtkFinalizeRead( pNtk->pExdc );
@@ -171,7 +174,7 @@ Abc_Ntk_t * Io_ReadBlifNetwork( Io_ReadBlif_t * p )
}
// add the network to the hierarchy
if ( pNtkMaster->tName2Model == NULL )
- pNtkMaster->tName2Model = stmm_init_table(strcmp, stmm_strhash);
+ pNtkMaster->tName2Model = stmm_init_table((int (*)(void))strcmp, (int (*)(void))stmm_strhash);
stmm_insert( pNtkMaster->tName2Model, pNtk->pName, (char *)pNtk );
*/
}
@@ -217,7 +220,7 @@ Abc_Ntk_t * Io_ReadBlifNetworkOne( Io_ReadBlif_t * p )
// create the new network
p->pNtkCur = pNtk = Abc_NtkAlloc( ABC_NTK_NETLIST, ABC_FUNC_SOP, 1 );
// read the model name
- if ( strcmp( p->vTokens->pArray[0], ".model" ) == 0 )
+ if ( strcmp( (char *)p->vTokens->pArray[0], ".model" ) == 0 )
{
char * pToken, * pPivot;
if ( Vec_PtrSize(p->vTokens) != 2 )
@@ -227,12 +230,12 @@ Abc_Ntk_t * Io_ReadBlifNetworkOne( Io_ReadBlif_t * p )
Io_ReadBlifPrintErrorMessage( p );
return NULL;
}
- for ( pPivot = pToken = Vec_PtrEntry(p->vTokens, 1); *pToken; pToken++ )
+ for ( pPivot = pToken = (char *)Vec_PtrEntry(p->vTokens, 1); *pToken; pToken++ )
if ( *pToken == '/' || *pToken == '\\' )
pPivot = pToken+1;
pNtk->pName = Extra_UtilStrsav( pPivot );
}
- else if ( strcmp( p->vTokens->pArray[0], ".exdc" ) != 0 )
+ else if ( strcmp( (char *)p->vTokens->pArray[0], ".exdc" ) != 0 )
{
printf( "%s: File parsing skipped after line %d (\"%s\").\n", p->pFileName,
Extra_FileReaderGetLineNumber(p->pReader, 0), (char*)p->vTokens->pArray[0] );
@@ -252,7 +255,7 @@ Abc_Ntk_t * Io_ReadBlifNetworkOne( Io_ReadBlif_t * p )
// consider different line types
fTokensReady = 0;
- pDirective = p->vTokens->pArray[0];
+ pDirective = (char *)p->vTokens->pArray[0];
if ( !strcmp( pDirective, ".names" ) )
{ fStatus = Io_ReadBlifNetworkNames( p, &p->vTokens ); fTokensReady = 1; }
else if ( !strcmp( pDirective, ".gate" ) )
@@ -282,7 +285,7 @@ Abc_Ntk_t * Io_ReadBlifNetworkOne( Io_ReadBlif_t * p )
{
pNtk->ntkType = ABC_NTK_NETLIST;
pNtk->ntkFunc = ABC_FUNC_BLACKBOX;
- Extra_MmFlexStop( pNtk->pManFunc );
+ Extra_MmFlexStop( (Extra_MmFlex_t *)pNtk->pManFunc );
pNtk->pManFunc = NULL;
}
else
@@ -317,7 +320,7 @@ int Io_ReadBlifNetworkInputs( Io_ReadBlif_t * p, Vec_Ptr_t * vTokens )
{
int i;
for ( i = 1; i < vTokens->nSize; i++ )
- Io_ReadCreatePi( p->pNtkCur, vTokens->pArray[i] );
+ Io_ReadCreatePi( p->pNtkCur, (char *)vTokens->pArray[i] );
return 0;
}
@@ -336,7 +339,7 @@ int Io_ReadBlifNetworkOutputs( Io_ReadBlif_t * p, Vec_Ptr_t * vTokens )
{
int i;
for ( i = 1; i < vTokens->nSize; i++ )
- Io_ReadCreatePo( p->pNtkCur, vTokens->pArray[i] );
+ Io_ReadCreatePo( p->pNtkCur, (char *)vTokens->pArray[i] );
return 0;
}
@@ -355,7 +358,7 @@ int Io_ReadBlifNetworkAsserts( Io_ReadBlif_t * p, Vec_Ptr_t * vTokens )
{
int i;
for ( i = 1; i < vTokens->nSize; i++ )
- Io_ReadCreateAssert( p->pNtkCur, vTokens->pArray[i] );
+ Io_ReadCreateAssert( p->pNtkCur, (char *)vTokens->pArray[i] );
return 0;
}
@@ -383,13 +386,13 @@ int Io_ReadBlifNetworkLatch( Io_ReadBlif_t * p, Vec_Ptr_t * vTokens )
return 1;
}
// create the latch
- pLatch = Io_ReadCreateLatch( pNtk, vTokens->pArray[1], vTokens->pArray[2] );
+ pLatch = Io_ReadCreateLatch( pNtk, (char *)vTokens->pArray[1], (char *)vTokens->pArray[2] );
// get the latch reset value
if ( vTokens->nSize == 3 )
Abc_LatchSetInitDc( pLatch );
else
{
- ResetValue = atoi(vTokens->pArray[vTokens->nSize-1]);
+ ResetValue = atoi((char *)vTokens->pArray[vTokens->nSize-1]);
if ( ResetValue != 0 && ResetValue != 1 && ResetValue != 2 )
{
p->LineCur = Extra_FileReaderGetLineNumber(p->pReader, 0);
@@ -447,7 +450,7 @@ int Io_ReadBlifNetworkNames( Io_ReadBlif_t * p, Vec_Ptr_t ** pvTokens )
{
while ( (vTokens = Io_ReadBlifGetTokens(p)) )
{
- pToken = vTokens->pArray[0];
+ pToken = (char *)vTokens->pArray[0];
if ( pToken[0] == '.' )
break;
// read the cube
@@ -469,7 +472,7 @@ int Io_ReadBlifNetworkNames( Io_ReadBlif_t * p, Vec_Ptr_t ** pvTokens )
{
while ( (vTokens = Io_ReadBlifGetTokens(p)) )
{
- pToken = vTokens->pArray[0];
+ pToken = (char *)vTokens->pArray[0];
if ( pToken[0] == '.' )
break;
// read the cube
@@ -481,7 +484,7 @@ int Io_ReadBlifNetworkNames( Io_ReadBlif_t * p, Vec_Ptr_t ** pvTokens )
return 1;
}
// create the cube
- Vec_StrAppend( p->vCubes, vTokens->pArray[0] );
+ Vec_StrPrintStr( p->vCubes, (char *)vTokens->pArray[0] );
// check the char
Char = ((char *)vTokens->pArray[1])[0];
if ( Char != '0' && Char != '1' && Char != 'x' && Char != 'n' )
@@ -507,14 +510,14 @@ int Io_ReadBlifNetworkNames( Io_ReadBlif_t * p, Vec_Ptr_t ** pvTokens )
Vec_StrPush( p->vCubes, 0 );
// set the pointer to the functionality of the node
- Abc_ObjSetData( pNode, Abc_SopRegister(pNtk->pManFunc, p->vCubes->pArray) );
+ Abc_ObjSetData( pNode, Abc_SopRegister((Extra_MmFlex_t *)pNtk->pManFunc, p->vCubes->pArray) );
// check the size
- if ( Abc_ObjFaninNum(pNode) != Abc_SopGetVarNum(Abc_ObjData(pNode)) )
+ if ( Abc_ObjFaninNum(pNode) != Abc_SopGetVarNum((char *)Abc_ObjData(pNode)) )
{
p->LineCur = Extra_FileReaderGetLineNumber(p->pReader, 0);
sprintf( p->sError, "The number of fanins (%d) of node %s is different from SOP size (%d).",
- Abc_ObjFaninNum(pNode), Abc_ObjName(Abc_ObjFanout(pNode,0)), Abc_SopGetVarNum(Abc_ObjData(pNode)) );
+ Abc_ObjFaninNum(pNode), Abc_ObjName(Abc_ObjFanout(pNode,0)), Abc_SopGetVarNum((char *)Abc_ObjData(pNode)) );
Io_ReadBlifPrintErrorMessage( p );
return 1;
}
@@ -548,7 +551,7 @@ int Io_ReadBlifReorderFormalNames( Vec_Ptr_t * vTokens, Mio_Gate_t * pGate )
{
pNamePin = Mio_PinReadName(pGatePin);
Length = strlen(pNamePin);
- pName = Vec_PtrEntry(vTokens, i+2);
+ pName = (char *)Vec_PtrEntry(vTokens, i+2);
if ( !strncmp( pNamePin, pName, Length ) && pName[Length] == '=' )
continue;
break;
@@ -562,7 +565,7 @@ int Io_ReadBlifReorderFormalNames( Vec_Ptr_t * vTokens, Mio_Gate_t * pGate )
Length = strlen(pNamePin);
for ( k = 2; k < nSize; k++ )
{
- pName = Vec_PtrEntry(vTokens, k);
+ pName = (char *)Vec_PtrEntry(vTokens, k);
if ( !strncmp( pNamePin, pName, Length ) && pName[Length] == '=' )
{
Vec_PtrPush( vTokens, pName );
@@ -574,7 +577,7 @@ int Io_ReadBlifReorderFormalNames( Vec_Ptr_t * vTokens, Mio_Gate_t * pGate )
Length = strlen(pNamePin);
for ( k = 2; k < nSize; k++ )
{
- pName = Vec_PtrEntry(vTokens, k);
+ pName = (char *)Vec_PtrEntry(vTokens, k);
if ( !strncmp( pNamePin, pName, Length ) && pName[Length] == '=' )
{
Vec_PtrPush( vTokens, pName );
@@ -583,7 +586,7 @@ int Io_ReadBlifReorderFormalNames( Vec_Ptr_t * vTokens, Mio_Gate_t * pGate )
}
if ( Vec_PtrSize(vTokens) - nSize != nSize - 2 )
return 0;
- Vec_PtrForEachEntryStart( vTokens, pName, k, nSize )
+ Vec_PtrForEachEntryStart( char *, vTokens, pName, k, nSize )
Vec_PtrWriteEntry( vTokens, k - nSize + 2, pName );
Vec_PtrShrink( vTokens, nSize );
return 1;
@@ -609,7 +612,7 @@ int Io_ReadBlifNetworkGate( Io_ReadBlif_t * p, Vec_Ptr_t * vTokens )
int i, nNames;
// check that the library is available
- pGenlib = Abc_FrameReadLibGen();
+ pGenlib = (Mio_Library_t *)Abc_FrameReadLibGen();
if ( pGenlib == NULL )
{
p->LineCur = Extra_FileReaderGetLineNumber(p->pReader, 0);
@@ -628,7 +631,7 @@ int Io_ReadBlifNetworkGate( Io_ReadBlif_t * p, Vec_Ptr_t * vTokens )
}
// get the gate
- pGate = Mio_LibraryReadGateByName( pGenlib, vTokens->pArray[1] );
+ pGate = Mio_LibraryReadGateByName( pGenlib, (char *)vTokens->pArray[1] );
if ( pGate == NULL )
{
p->LineCur = Extra_FileReaderGetLineNumber(p->pReader, 0);
@@ -642,7 +645,7 @@ int Io_ReadBlifNetworkGate( Io_ReadBlif_t * p, Vec_Ptr_t * vTokens )
{
assert( p->pNtkCur->ntkFunc == ABC_FUNC_SOP );
p->pNtkCur->ntkFunc = ABC_FUNC_MAP;
- Extra_MmFlexStop( p->pNtkCur->pManFunc );
+ Extra_MmFlexStop( (Extra_MmFlex_t *)p->pNtkCur->pManFunc );
p->pNtkCur->pManFunc = pGenlib;
}
@@ -659,7 +662,7 @@ int Io_ReadBlifNetworkGate( Io_ReadBlif_t * p, Vec_Ptr_t * vTokens )
// remove the formal parameter names
for ( i = 2; i < vTokens->nSize; i++ )
{
- vTokens->pArray[i] = Io_ReadBlifCleanName( vTokens->pArray[i] );
+ vTokens->pArray[i] = Io_ReadBlifCleanName( (char *)vTokens->pArray[i] );
if ( vTokens->pArray[i] == NULL )
{
p->LineCur = Extra_FileReaderGetLineNumber(p->pReader, 0);
@@ -708,7 +711,7 @@ int Io_ReadBlifNetworkSubcircuit( Io_ReadBlif_t * p, Vec_Ptr_t * vTokens )
// store the names of formal/actual inputs/outputs of the box
vNames = Vec_PtrAlloc( 10 );
- Vec_PtrForEachEntryStart( vTokens, pName, i, 1 )
+ Vec_PtrForEachEntryStart( char *, vTokens, pName, i, 1 )
// Vec_PtrPush( vNames, Abc_NtkRegisterName(p->pNtkCur, pName) );
Vec_PtrPush( vNames, Extra_UtilStrsav(pName) ); // memory leak!!!
@@ -717,7 +720,7 @@ int Io_ReadBlifNetworkSubcircuit( Io_ReadBlif_t * p, Vec_Ptr_t * vTokens )
// set the pointer to the node names
Abc_ObjSetData( pBox, vNames );
// remember the line of the file
- pBox->pCopy = (void *)(ABC_PTRINT_T)Extra_FileReaderGetLineNumber(p->pReader, 0);
+ pBox->pCopy = (Abc_Obj_t *)(ABC_PTRINT_T)Extra_FileReaderGetLineNumber(p->pReader, 0);
return 0;
}
@@ -758,9 +761,9 @@ int Io_ReadBlifNetworkInputArrival( Io_ReadBlif_t * p, Vec_Ptr_t * vTokens )
Abc_Obj_t * pNet;
char * pFoo1, * pFoo2;
double TimeRise, TimeFall;
-
+
// make sure this is indeed the .inputs line
- assert( strncmp( vTokens->pArray[0], ".input_arrival", 14 ) == 0 );
+ assert( strncmp( (char *)vTokens->pArray[0], ".input_arrival", 14 ) == 0 );
if ( vTokens->nSize != 4 )
{
p->LineCur = Extra_FileReaderGetLineNumber(p->pReader, 0);
@@ -768,7 +771,7 @@ int Io_ReadBlifNetworkInputArrival( Io_ReadBlif_t * p, Vec_Ptr_t * vTokens )
Io_ReadBlifPrintErrorMessage( p );
return 1;
}
- pNet = Abc_NtkFindNet( p->pNtkCur, vTokens->pArray[1] );
+ pNet = Abc_NtkFindNet( p->pNtkCur, (char *)vTokens->pArray[1] );
if ( pNet == NULL )
{
p->LineCur = Extra_FileReaderGetLineNumber(p->pReader, 0);
@@ -776,8 +779,8 @@ int Io_ReadBlifNetworkInputArrival( Io_ReadBlif_t * p, Vec_Ptr_t * vTokens )
Io_ReadBlifPrintErrorMessage( p );
return 1;
}
- TimeRise = strtod( vTokens->pArray[2], &pFoo1 );
- TimeFall = strtod( vTokens->pArray[3], &pFoo2 );
+ TimeRise = strtod( (char *)vTokens->pArray[2], &pFoo1 );
+ TimeFall = strtod( (char *)vTokens->pArray[3], &pFoo2 );
if ( *pFoo1 != '\0' || *pFoo2 != '\0' )
{
p->LineCur = Extra_FileReaderGetLineNumber(p->pReader, 0);
@@ -807,7 +810,7 @@ int Io_ReadBlifNetworkDefaultInputArrival( Io_ReadBlif_t * p, Vec_Ptr_t * vToken
double TimeRise, TimeFall;
// make sure this is indeed the .inputs line
- assert( strncmp( vTokens->pArray[0], ".default_input_arrival", 23 ) == 0 );
+ assert( strncmp( (char *)vTokens->pArray[0], ".default_input_arrival", 23 ) == 0 );
if ( vTokens->nSize != 3 )
{
p->LineCur = Extra_FileReaderGetLineNumber(p->pReader, 0);
@@ -815,8 +818,8 @@ int Io_ReadBlifNetworkDefaultInputArrival( Io_ReadBlif_t * p, Vec_Ptr_t * vToken
Io_ReadBlifPrintErrorMessage( p );
return 1;
}
- TimeRise = strtod( vTokens->pArray[1], &pFoo1 );
- TimeFall = strtod( vTokens->pArray[2], &pFoo2 );
+ TimeRise = strtod( (char *)vTokens->pArray[1], &pFoo1 );
+ TimeFall = strtod( (char *)vTokens->pArray[2], &pFoo2 );
if ( *pFoo1 != '\0' || *pFoo2 != '\0' )
{
p->LineCur = Extra_FileReaderGetLineNumber(p->pReader, 0);
@@ -875,12 +878,12 @@ Vec_Ptr_t * Io_ReadBlifGetTokens( Io_ReadBlif_t * p )
}
// get the new tokens
- vTokens = Extra_FileReaderGetTokens(p->pReader);
+ vTokens = (Vec_Ptr_t *)Extra_FileReaderGetTokens(p->pReader);
if ( vTokens == NULL )
return vTokens;
// check if there is a transfer to another line
- pLastToken = vTokens->pArray[vTokens->nSize - 1];
+ pLastToken = (char *)vTokens->pArray[vTokens->nSize - 1];
if ( pLastToken[ strlen(pLastToken)-1 ] != '\\' )
return vTokens;
@@ -890,17 +893,17 @@ Vec_Ptr_t * Io_ReadBlifGetTokens( Io_ReadBlif_t * p )
vTokens->nSize--;
// load them into the new array
for ( i = 0; i < vTokens->nSize; i++ )
- Vec_PtrPush( p->vNewTokens, Extra_UtilStrsav(vTokens->pArray[i]) );
+ Vec_PtrPush( p->vNewTokens, Extra_UtilStrsav((char *)vTokens->pArray[i]) );
// load as long as there is the line break
while ( 1 )
{
// get the new tokens
- vTokens = Extra_FileReaderGetTokens(p->pReader);
+ vTokens = (Vec_Ptr_t *)Extra_FileReaderGetTokens(p->pReader);
if ( vTokens->nSize == 0 )
return p->vNewTokens;
// check if there is a transfer to another line
- pLastToken = vTokens->pArray[vTokens->nSize - 1];
+ pLastToken = (char *)vTokens->pArray[vTokens->nSize - 1];
if ( pLastToken[ strlen(pLastToken)-1 ] == '\\' )
{
// remove the slash
@@ -909,12 +912,12 @@ Vec_Ptr_t * Io_ReadBlifGetTokens( Io_ReadBlif_t * p )
vTokens->nSize--;
// load them into the new array
for ( i = 0; i < vTokens->nSize; i++ )
- Vec_PtrPush( p->vNewTokens, Extra_UtilStrsav(vTokens->pArray[i]) );
+ Vec_PtrPush( p->vNewTokens, Extra_UtilStrsav((char *)vTokens->pArray[i]) );
continue;
}
// otherwise, load them and break
for ( i = 0; i < vTokens->nSize; i++ )
- Vec_PtrPush( p->vNewTokens, Extra_UtilStrsav(vTokens->pArray[i]) );
+ Vec_PtrPush( p->vNewTokens, Extra_UtilStrsav((char *)vTokens->pArray[i]) );
break;
}
return p->vNewTokens;
@@ -993,8 +996,8 @@ int Io_ReadBlifNetworkConnectBoxesOneBox( Io_ReadBlif_t * p, Abc_Obj_t * pBox, s
int i, Length, Start = -1;
// get the model for this box
- pNames = pBox->pData;
- if ( !stmm_lookup( tName2Model, Vec_PtrEntry(pNames, 0), (char **)&pNtkModel ) )
+ pNames = (Vec_Ptr_t *)pBox->pData;
+ if ( !stmm_lookup( tName2Model, (char *)Vec_PtrEntry(pNames, 0), (char **)&pNtkModel ) )
{
p->LineCur = (int)(ABC_PTRINT_T)pBox->pCopy;
sprintf( p->sError, "Cannot find the model for subcircuit %s.", (char*)Vec_PtrEntry(pNames, 0) );
@@ -1009,7 +1012,7 @@ int Io_ReadBlifNetworkConnectBoxesOneBox( Io_ReadBlif_t * p, Abc_Obj_t * pBox, s
Start = 1;
else
{
- Vec_PtrForEachEntryStart( pNames, pName, i, 1 )
+ Vec_PtrForEachEntryStart( char *, pNames, pName, i, 1 )
{
pActual = Io_ReadBlifCleanName(pName);
if ( pActual == NULL )
@@ -1047,7 +1050,7 @@ int Io_ReadBlifNetworkConnectBoxesOneBox( Io_ReadBlif_t * p, Abc_Obj_t * pBox, s
Io_ReadBlifPrintErrorMessage( p );
return 1;
}
- pObj->pCopy = (void *)pActual;
+ pObj->pCopy = (Abc_Obj_t *)pActual;
// quit if we processed all PIs
if ( i == Abc_NtkPiNum(pNtkModel) )
{
@@ -1059,7 +1062,7 @@ int Io_ReadBlifNetworkConnectBoxesOneBox( Io_ReadBlif_t * p, Abc_Obj_t * pBox, s
// create the fanins of the box
Abc_NtkForEachPi( pNtkModel, pObj, i )
{
- pActual = (void *)pObj->pCopy;
+ pActual = (char *)pObj->pCopy;
if ( pActual == NULL )
{
p->LineCur = (int)(ABC_PTRINT_T)pBox->pCopy;
@@ -1076,7 +1079,7 @@ int Io_ReadBlifNetworkConnectBoxesOneBox( Io_ReadBlif_t * p, Abc_Obj_t * pBox, s
// create the fanouts of the box
Abc_NtkForEachPo( pNtkModel, pObj, i )
pObj->pCopy = NULL;
- Vec_PtrForEachEntryStart( pNames, pName, i, Start )
+ Vec_PtrForEachEntryStart( char *, pNames, pName, i, Start )
{
pActual = Io_ReadBlifCleanName(pName);
if ( pActual == NULL )
@@ -1106,12 +1109,12 @@ int Io_ReadBlifNetworkConnectBoxesOneBox( Io_ReadBlif_t * p, Abc_Obj_t * pBox, s
Io_ReadBlifPrintErrorMessage( p );
return 1;
}
- pObj->pCopy = (void *)pActual;
+ pObj->pCopy = (Abc_Obj_t *)pActual;
}
// create the fanouts of the box
Abc_NtkForEachPo( pNtkModel, pObj, i )
{
- pActual = (void *)pObj->pCopy;
+ pActual = (char *)pObj->pCopy;
if ( pActual == NULL )
{
p->LineCur = (int)(ABC_PTRINT_T)pBox->pCopy;
@@ -1126,9 +1129,9 @@ int Io_ReadBlifNetworkConnectBoxesOneBox( Io_ReadBlif_t * p, Abc_Obj_t * pBox, s
pObj->pCopy = NULL;
// remove the array of names, assign the pointer to the model
- Vec_PtrForEachEntry( pBox->pData, pName, i )
+ Vec_PtrForEachEntry( char *, (Vec_Ptr_t *)pBox->pData, pName, i )
ABC_FREE( pName );
- Vec_PtrFree( pBox->pData );
+ Vec_PtrFree( (Vec_Ptr_t *)pBox->pData );
pBox->pData = pNtkModel;
return 0;
}
@@ -1191,3 +1194,5 @@ int Io_ReadBlifNetworkConnectBoxes( Io_ReadBlif_t * p, Abc_Ntk_t * pNtkMaster )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/io/ioReadBlifAig.c b/src/base/io/ioReadBlifAig.c
index 8d4c77d4..caa776f9 100644
--- a/src/base/io/ioReadBlifAig.c
+++ b/src/base/io/ioReadBlifAig.c
@@ -22,6 +22,9 @@
#include "extra.h"
#include "vecPtr.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -60,7 +63,7 @@ struct Io_BlifMan_t_
// temporary objects
Io_BlifObj_t * pObjects; // the storage for objects
int nObjects; // the number of objects allocated
- int iObjNext; // the next ABC_FREE object
+ int iObjNext; // the next free object
// file lines
char * pModel; // .model line
Vec_Ptr_t * vInputs; // .inputs lines
@@ -347,7 +350,7 @@ static int Io_BlifGetLine( Io_BlifMan_t * p, char * pToken )
{
char * pLine;
int i;
- Vec_PtrForEachEntry( p->vLines, pLine, i )
+ Vec_PtrForEachEntry( char *, p->vLines, pLine, i )
if ( pToken < pLine )
return i;
return -1;
@@ -369,7 +372,7 @@ static int Io_BlifEstimatePiNum( Io_BlifMan_t * p )
char * pCur;
int i, fSpaces;
int Counter = 0;
- Vec_PtrForEachEntry( p->vInputs, pCur, i )
+ Vec_PtrForEachEntry( char *, p->vInputs, pCur, i )
for ( fSpaces = 0; *pCur; pCur++ )
{
if ( Io_BlifCharIsSpace(*pCur) )
@@ -493,7 +496,7 @@ static void Io_BlifReadPreparse( Io_BlifMan_t * p )
}
// unfold the line extensions and sort lines by directive
- Vec_PtrForEachEntry( p->vLines, pCur, i )
+ Vec_PtrForEachEntry( char *, p->vLines, pCur, i )
{
if ( *pCur == 0 )
continue;
@@ -569,19 +572,19 @@ static Abc_Ntk_t * Io_BlifParse( Io_BlifMan_t * p )
if ( !Io_BlifParseModel( p, p->pModel ) )
return NULL;
// parse the inputs
- Vec_PtrForEachEntry( p->vInputs, pLine, i )
+ Vec_PtrForEachEntry( char *, p->vInputs, pLine, i )
if ( !Io_BlifParseInputs( p, pLine ) )
return NULL;
// parse the outputs
- Vec_PtrForEachEntry( p->vOutputs, pLine, i )
+ Vec_PtrForEachEntry( char *, p->vOutputs, pLine, i )
if ( !Io_BlifParseOutputs( p, pLine ) )
return NULL;
// parse the latches
- Vec_PtrForEachEntry( p->vLatches, pLine, i )
+ Vec_PtrForEachEntry( char *, p->vLatches, pLine, i )
if ( !Io_BlifParseLatch( p, pLine ) )
return NULL;
// parse the nodes
- Vec_PtrForEachEntry( p->vNames, pLine, i )
+ Vec_PtrForEachEntry( char *, p->vNames, pLine, i )
if ( !Io_BlifParseNames( p, pLine ) )
return NULL;
// reconstruct the network from the parsed data
@@ -608,14 +611,14 @@ static int Io_BlifParseModel( Io_BlifMan_t * p, char * pLine )
{
char * pToken;
Io_BlifSplitIntoTokens( p->vTokens, pLine, '\0' );
- pToken = Vec_PtrEntry( p->vTokens, 0 );
+ pToken = (char *)Vec_PtrEntry( p->vTokens, 0 );
assert( !strcmp(pToken, "model") );
if ( Vec_PtrSize(p->vTokens) != 2 )
{
sprintf( p->sError, "Line %d: Model line has %d entries while it should have 2.", Io_BlifGetLine(p, pToken), Vec_PtrSize(p->vTokens) );
return 0;
}
- p->pModel = Vec_PtrEntry( p->vTokens, 1 );
+ p->pModel = (char *)Vec_PtrEntry( p->vTokens, 1 );
return 1;
}
@@ -636,9 +639,9 @@ static int Io_BlifParseInputs( Io_BlifMan_t * p, char * pLine )
char * pToken;
int i;
Io_BlifSplitIntoTokens( p->vTokens, pLine, '\0' );
- pToken = Vec_PtrEntry(p->vTokens, 0);
+ pToken = (char *)Vec_PtrEntry(p->vTokens, 0);
assert( !strcmp(pToken, "inputs") );
- Vec_PtrForEachEntryStart( p->vTokens, pToken, i, 1 )
+ Vec_PtrForEachEntryStart( char *, p->vTokens, pToken, i, 1 )
{
pObj = Io_BlifHashFindOrAdd( p, pToken );
if ( pObj->fPi )
@@ -669,9 +672,9 @@ static int Io_BlifParseOutputs( Io_BlifMan_t * p, char * pLine )
char * pToken;
int i;
Io_BlifSplitIntoTokens( p->vTokens, pLine, '\0' );
- pToken = Vec_PtrEntry(p->vTokens, 0);
+ pToken = (char *)Vec_PtrEntry(p->vTokens, 0);
assert( !strcmp(pToken, "outputs") );
- Vec_PtrForEachEntryStart( p->vTokens, pToken, i, 1 )
+ Vec_PtrForEachEntryStart( char *, p->vTokens, pToken, i, 1 )
{
pObj = Io_BlifHashFindOrAdd( p, pToken );
if ( pObj->fPo )
@@ -699,7 +702,7 @@ static int Io_BlifParseLatch( Io_BlifMan_t * p, char * pLine )
char * pToken;
int Init;
Io_BlifSplitIntoTokens( p->vTokens, pLine, '\0' );
- pToken = Vec_PtrEntry(p->vTokens,0);
+ pToken = (char *)Vec_PtrEntry(p->vTokens,0);
assert( !strcmp(pToken, "latch") );
if ( Vec_PtrSize(p->vTokens) < 3 )
{
@@ -708,7 +711,7 @@ static int Io_BlifParseLatch( Io_BlifMan_t * p, char * pLine )
}
// get initial value
if ( Vec_PtrSize(p->vTokens) > 3 )
- Init = atoi( Vec_PtrEntry(p->vTokens,3) );
+ Init = atoi( (char *)Vec_PtrEntry(p->vTokens,3) );
else
Init = 2;
if ( Init < 0 || Init > 2 )
@@ -723,12 +726,12 @@ static int Io_BlifParseLatch( Io_BlifMan_t * p, char * pLine )
else // if ( Init == 2 )
Init = IO_BLIF_INIT_DC;
// get latch input
- pObj = Io_BlifHashFindOrAdd( p, Vec_PtrEntry(p->vTokens,1) );
+ pObj = Io_BlifHashFindOrAdd( p, (char *)Vec_PtrEntry(p->vTokens,1) );
pObj->fLi = 1;
Vec_PtrPush( p->vLis, pObj );
pObj->Init = Init;
// get latch output
- pObj = Io_BlifHashFindOrAdd( p, Vec_PtrEntry(p->vTokens,2) );
+ pObj = Io_BlifHashFindOrAdd( p, (char *)Vec_PtrEntry(p->vTokens,2) );
if ( pObj->fPi )
{
sprintf( p->sError, "Line %d: Primary input (%s) is also defined latch output.", Io_BlifGetLine(p, pToken), (char*)Vec_PtrEntry(p->vTokens,2) );
@@ -761,8 +764,8 @@ static int Io_BlifParseNames( Io_BlifMan_t * p, char * pLine )
Io_BlifObj_t * pObj;
char * pName;
Io_BlifSplitIntoTokens( p->vTokens, pLine, '\0' );
- assert( !strcmp(Vec_PtrEntry(p->vTokens,0), "names") );
- pName = Vec_PtrEntryLast( p->vTokens );
+ assert( !strcmp((char *)Vec_PtrEntry(p->vTokens,0), "names") );
+ pName = (char *)Vec_PtrEntryLast( p->vTokens );
pObj = Io_BlifHashFindOrAdd( p, pName );
if ( pObj->fPi )
{
@@ -811,7 +814,7 @@ static Abc_Obj_t * Io_BlifParseTable( Io_BlifMan_t * p, char * pTable, Vec_Ptr_t
return Abc_ObjNot( Abc_AigConst1(p->pAig) );
if ( Vec_PtrSize(p->vTokens) == 1 )
{
- pOutput = Vec_PtrEntry( p->vTokens, 0 );
+ pOutput = (char *)Vec_PtrEntry( p->vTokens, 0 );
if ( ((pOutput[0] - '0') & 0x8E) || pOutput[1] )
{
sprintf( p->sError, "Line %d: Constant table has wrong output value (%s).", Io_BlifGetLine(p, pOutput), pOutput );
@@ -819,7 +822,7 @@ static Abc_Obj_t * Io_BlifParseTable( Io_BlifMan_t * p, char * pTable, Vec_Ptr_t
}
return Abc_ObjNotCond( Abc_AigConst1(p->pAig), pOutput[0] == '0' );
}
- pProduct = Vec_PtrEntry( p->vTokens, 0 );
+ pProduct = (char *)Vec_PtrEntry( p->vTokens, 0 );
if ( Vec_PtrSize(p->vTokens) % 2 == 1 )
{
sprintf( p->sError, "Line %d: Table has odd number of tokens (%d).", Io_BlifGetLine(p, pProduct), Vec_PtrSize(p->vTokens) );
@@ -829,8 +832,8 @@ static Abc_Obj_t * Io_BlifParseTable( Io_BlifMan_t * p, char * pTable, Vec_Ptr_t
pRes = Abc_ObjNot( Abc_AigConst1(p->pAig) );
for ( i = 0; i < Vec_PtrSize(p->vTokens)/2; i++ )
{
- pProduct = Vec_PtrEntry( p->vTokens, 2*i + 0 );
- pOutput = Vec_PtrEntry( p->vTokens, 2*i + 1 );
+ pProduct = (char *)Vec_PtrEntry( p->vTokens, 2*i + 0 );
+ pOutput = (char *)Vec_PtrEntry( p->vTokens, 2*i + 1 );
if ( strlen(pProduct) != (unsigned)Vec_PtrSize(vFanins) )
{
sprintf( p->sError, "Line %d: Cube (%s) has size different from the fanin count (%d).", Io_BlifGetLine(p, pProduct), pProduct, Vec_PtrSize(vFanins) );
@@ -853,16 +856,16 @@ static Abc_Obj_t * Io_BlifParseTable( Io_BlifMan_t * p, char * pTable, Vec_Ptr_t
for ( k = 0; pProduct[k]; k++ )
{
if ( pProduct[k] == '0' )
- pCube = Abc_AigAnd( p->pAig->pManFunc, pCube, Abc_ObjNot(Vec_PtrEntry(vFanins,k)) );
+ pCube = Abc_AigAnd( (Abc_Aig_t *)p->pAig->pManFunc, pCube, Abc_ObjNot((Abc_Obj_t *)Vec_PtrEntry(vFanins,k)) );
else if ( pProduct[k] == '1' )
- pCube = Abc_AigAnd( p->pAig->pManFunc, pCube, Vec_PtrEntry(vFanins,k) );
+ pCube = Abc_AigAnd( (Abc_Aig_t *)p->pAig->pManFunc, pCube, (Abc_Obj_t *)Vec_PtrEntry(vFanins,k) );
else if ( pProduct[k] != '-' )
{
sprintf( p->sError, "Line %d: Product term (%s) contains character (%c).", Io_BlifGetLine(p, pProduct), pProduct, pProduct[k] );
return NULL;
}
}
- pRes = Abc_AigOr( p->pAig->pManFunc, pRes, pCube );
+ pRes = Abc_AigOr( (Abc_Aig_t *)p->pAig->pManFunc, pRes, pCube );
}
pRes = Abc_ObjNotCond( pRes, Polarity == 0 );
return pRes;
@@ -901,13 +904,13 @@ static Abc_Obj_t * Io_BlifParseConstruct_rec( Io_BlifMan_t * p, char * pName )
}
// check if the AIG is already constructed
if ( pObjIo->pEquiv )
- return pObjIo->pEquiv;
+ return (Abc_Obj_t *)pObjIo->pEquiv;
// mark this node on the path
pObjIo->fLoop = 1;
// construct the AIGs for the fanins
vFanins = Vec_PtrAlloc( 8 );
Io_BlifCollectTokens( vFanins, pObjIo->pName - pObjIo->Offset, pObjIo->pName );
- Vec_PtrForEachEntry( vFanins, pNameFanin, i )
+ Vec_PtrForEachEntry( char *, vFanins, pNameFanin, i )
{
pFaninAbc = Io_BlifParseConstruct_rec( p, pNameFanin );
if ( pFaninAbc == NULL )
@@ -923,7 +926,7 @@ static Abc_Obj_t * Io_BlifParseConstruct_rec( Io_BlifMan_t * p, char * pName )
// unmark this node on the path
pObjIo->fLoop = 0;
// remember the new node
- return pObjIo->pEquiv;
+ return (Abc_Obj_t *)pObjIo->pEquiv;
}
/**Function*************************************************************
@@ -948,24 +951,24 @@ static int Io_BlifParseConstruct( Io_BlifMan_t * p )
pAig->pName = Extra_UtilStrsav( p->pModel );
pAig->pSpec = Extra_UtilStrsav( p->pFileName );
// create PIs
- Vec_PtrForEachEntry( p->vPis, pObjIo, i )
+ Vec_PtrForEachEntry( Io_BlifObj_t *, p->vPis, pObjIo, i )
{
pObj = Abc_NtkCreatePi( pAig );
Abc_ObjAssignName( pObj, pObjIo->pName, NULL );
pObjIo->pEquiv = pObj;
}
// create POs
- Vec_PtrForEachEntry( p->vPos, pObjIo, i )
+ Vec_PtrForEachEntry( Io_BlifObj_t *, p->vPos, pObjIo, i )
{
pObj = Abc_NtkCreatePo( pAig );
Abc_ObjAssignName( pObj, pObjIo->pName, NULL );
}
// create latches
- Vec_PtrForEachEntry( p->vLos, pObjIo, i )
+ Vec_PtrForEachEntry( Io_BlifObj_t *, p->vLos, pObjIo, i )
{
// add the latch input terminal
pObj = Abc_NtkCreateBi( pAig );
- pObjIoInput = Vec_PtrEntry( p->vLis, i );
+ pObjIoInput = (Io_BlifObj_t *)Vec_PtrEntry( p->vLis, i );
Abc_ObjAssignName( pObj, pObjIoInput->pName, NULL );
// add the latch box
@@ -983,7 +986,7 @@ static int Io_BlifParseConstruct( Io_BlifMan_t * p )
pObjIo->pEquiv = pObj;
}
// traverse the nodes from the POs
- Vec_PtrForEachEntry( p->vPos, pObjIo, i )
+ Vec_PtrForEachEntry( Io_BlifObj_t *, p->vPos, pObjIo, i )
{
pObj = Io_BlifParseConstruct_rec( p, pObjIo->pName );
if ( pObj == NULL )
@@ -991,7 +994,7 @@ static int Io_BlifParseConstruct( Io_BlifMan_t * p )
Abc_ObjAddFanin( Abc_NtkPo(p->pAig, i), pObj );
}
// traverse the nodes from the latch inputs
- Vec_PtrForEachEntry( p->vLis, pObjIo, i )
+ Vec_PtrForEachEntry( Io_BlifObj_t *, p->vLis, pObjIo, i )
{
pObj = Io_BlifParseConstruct_rec( p, pObjIo->pName );
if ( pObj == NULL )
@@ -1011,3 +1014,5 @@ static int Io_BlifParseConstruct( Io_BlifMan_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/io/ioReadBlifMv.c b/src/base/io/ioReadBlifMv.c
index 2e2388d3..c73f8d92 100644
--- a/src/base/io/ioReadBlifMv.c
+++ b/src/base/io/ioReadBlifMv.c
@@ -23,6 +23,8 @@
#include "vecPtr.h"
#include "ioAbc.h"
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -33,6 +35,8 @@ typedef struct Io_MvVar_t_ Io_MvVar_t; // parsing var
typedef struct Io_MvMod_t_ Io_MvMod_t; // parsing model
typedef struct Io_MvMan_t_ Io_MvMan_t; // parsing manager
+Vec_Ptr_t *vGlobalLtlArray;
+
struct Io_MvVar_t_
{
int nValues; // the number of values
@@ -46,12 +50,15 @@ struct Io_MvMod_t_
Vec_Ptr_t * vInputs; // .inputs lines
Vec_Ptr_t * vOutputs; // .outputs lines
Vec_Ptr_t * vLatches; // .latch lines
+ Vec_Ptr_t * vFlops; // .flop lines
Vec_Ptr_t * vResets; // .reset lines
Vec_Ptr_t * vNames; // .names lines
Vec_Ptr_t * vSubckts; // .subckt lines
Vec_Ptr_t * vShorts; // .short lines
Vec_Ptr_t * vOnehots; // .onehot lines
Vec_Ptr_t * vMvs; // .mv lines
+ Vec_Ptr_t * vConstrs; // .constraint lines
+ Vec_Ptr_t * vLtlProperties;
int fBlackBox; // indicates blackbox model
// the resulting network
Abc_Ntk_t * pNtk;
@@ -97,13 +104,16 @@ static Abc_Lib_t * Io_MvParse( Io_MvMan_t * p );
static int Io_MvParseLineModel( Io_MvMod_t * p, char * pLine );
static int Io_MvParseLineInputs( Io_MvMod_t * p, char * pLine );
static int Io_MvParseLineOutputs( Io_MvMod_t * p, char * pLine );
+static int Io_MvParseLineConstrs( Io_MvMod_t * p, char * pLine );
static int Io_MvParseLineLatch( Io_MvMod_t * p, char * pLine );
+static int Io_MvParseLineFlop( Io_MvMod_t * p, char * pLine );
static int Io_MvParseLineSubckt( Io_MvMod_t * p, char * pLine );
static Vec_Int_t * Io_MvParseLineOnehot( Io_MvMod_t * p, char * pLine );
static int Io_MvParseLineMv( Io_MvMod_t * p, char * pLine );
static int Io_MvParseLineNamesMv( Io_MvMod_t * p, char * pLine, int fReset );
static int Io_MvParseLineNamesBlif( Io_MvMod_t * p, char * pLine );
static int Io_MvParseLineShortBlif( Io_MvMod_t * p, char * pLine );
+static int Io_MvParseLineLtlProperty( Io_MvMod_t * p, char * pLine );
static int Io_MvParseLineGateBlif( Io_MvMod_t * p, Vec_Ptr_t * vTokens );
static Io_MvVar_t * Abc_NtkMvVarDup( Abc_Ntk_t * pNtk, Io_MvVar_t * pVar );
@@ -135,6 +145,7 @@ Abc_Ntk_t * Io_ReadBlifMv( char * pFileName, int fBlifMv, int fCheck )
Abc_Lib_t * pDesign = NULL;
char * pDesignName;
int RetValue, i;
+ char * pLtlProp;
// check that the file is available
pFile = fopen( pFileName, "rb" );
@@ -161,10 +172,11 @@ Abc_Ntk_t * Io_ReadBlifMv( char * pFileName, int fBlifMv, int fCheck )
p->pDesign = Abc_LibCreate( pDesignName );
ABC_FREE( pDesignName );
// free the HOP manager
- Hop_ManStop( p->pDesign->pManFunc );
+ Hop_ManStop( (Hop_Man_t *)p->pDesign->pManFunc );
p->pDesign->pManFunc = NULL;
// prepare the file for parsing
Io_MvReadPreparse( p );
+ vGlobalLtlArray = Vec_PtrAlloc( 100 );
// parse interfaces of each network and construct the network
if ( Io_MvReadInterfaces( p ) )
pDesign = Io_MvParse( p );
@@ -178,7 +190,7 @@ Abc_Ntk_t * Io_ReadBlifMv( char * pFileName, int fBlifMv, int fCheck )
// make sure that everything is okay with the network structure
if ( fCheck )
{
- Vec_PtrForEachEntry( pDesign->vModules, pNtk, i )
+ Vec_PtrForEachEntry( Abc_Ntk_t *, pDesign->vModules, pNtk, i )
{
if ( !Abc_NtkCheckRead( pNtk ) )
{
@@ -193,7 +205,7 @@ Abc_Ntk_t * Io_ReadBlifMv( char * pFileName, int fBlifMv, int fCheck )
// detect top-level model
RetValue = Abc_LibFindTopLevelModels( pDesign );
- pNtk = Vec_PtrEntry( pDesign->vTops, 0 );
+ pNtk = (Abc_Ntk_t *)Vec_PtrEntry( pDesign->vTops, 0 );
if ( RetValue > 1 )
printf( "Warning: The design has %d root-level modules. The first one (%s) will be used.\n",
Vec_PtrSize(pDesign->vTops), pNtk->pName );
@@ -217,6 +229,9 @@ Abc_Ntk_t * Io_ReadBlifMv( char * pFileName, int fBlifMv, int fCheck )
//Io_WriteBlifMv( pNtk, "_temp_.mv" );
if ( pNtk->pSpec == NULL )
pNtk->pSpec = Extra_UtilStrsav( pFileName );
+
+ Vec_PtrForEachEntry( char *, vGlobalLtlArray, pLtlProp, i )
+ Vec_PtrPush( pNtk->vLtlProperties, pLtlProp );
return pNtk;
}
@@ -267,7 +282,7 @@ static void Io_MvFree( Io_MvMan_t * p )
Vec_PtrFree( p->vLines );
if ( p->vModels )
{
- Vec_PtrForEachEntry( p->vModels, pMod, i )
+ Vec_PtrForEachEntry( Io_MvMod_t *, p->vModels, pMod, i )
Io_MvModFree( pMod );
Vec_PtrFree( p->vModels );
}
@@ -296,12 +311,15 @@ static Io_MvMod_t * Io_MvModAlloc()
p->vInputs = Vec_PtrAlloc( 512 );
p->vOutputs = Vec_PtrAlloc( 512 );
p->vLatches = Vec_PtrAlloc( 512 );
+ p->vFlops = Vec_PtrAlloc( 512 );
p->vResets = Vec_PtrAlloc( 512 );
p->vNames = Vec_PtrAlloc( 512 );
p->vSubckts = Vec_PtrAlloc( 512 );
p->vShorts = Vec_PtrAlloc( 512 );
p->vOnehots = Vec_PtrAlloc( 512 );
p->vMvs = Vec_PtrAlloc( 512 );
+ p->vConstrs = Vec_PtrAlloc( 512 );
+ p->vLtlProperties = Vec_PtrAlloc( 512 );
return p;
}
@@ -323,12 +341,14 @@ static void Io_MvModFree( Io_MvMod_t * p )
Vec_PtrFree( p->vInputs );
Vec_PtrFree( p->vOutputs );
Vec_PtrFree( p->vLatches );
+ Vec_PtrFree( p->vFlops );
Vec_PtrFree( p->vResets );
Vec_PtrFree( p->vNames );
Vec_PtrFree( p->vSubckts );
Vec_PtrFree( p->vShorts );
Vec_PtrFree( p->vOnehots );
Vec_PtrFree( p->vMvs );
+ Vec_PtrFree( p->vConstrs );
ABC_FREE( p );
}
@@ -484,7 +504,7 @@ static int Io_MvGetLine( Io_MvMan_t * p, char * pToken )
{
char * pLine;
int i;
- Vec_PtrForEachEntry( p->vLines, pLine, i )
+ Vec_PtrForEachEntry( char *, p->vLines, pLine, i )
if ( pToken < pLine )
return i;
return -1;
@@ -570,7 +590,7 @@ static void Io_MvReadPreparse( Io_MvMan_t * p )
}
// unfold the line extensions and sort lines by directive
- Vec_PtrForEachEntry( p->vLines, pCur, i )
+ Vec_PtrForEachEntry( char *, p->vLines, pCur, i )
{
if ( *pCur == 0 )
continue;
@@ -579,7 +599,7 @@ static void Io_MvReadPreparse( Io_MvMan_t * p )
if ( !Io_MvCharIsSpace(*pPrev) )
break;
// if it is the line extender, overwrite it with spaces
- if ( *pPrev == '\\' )
+ if ( pPrev >= p->pBuffer && *pPrev == '\\' )
{
for ( ; *pPrev; pPrev++ )
*pPrev = ' ';
@@ -595,8 +615,12 @@ static void Io_MvReadPreparse( Io_MvMan_t * p )
Vec_PtrPush( p->pLatest->vNames, pCur );
else if ( p->fBlifMv && (!strncmp(pCur, "def ", 4) || !strncmp(pCur, "default ", 8)) )
continue;
+ else if ( !strncmp( pCur, "ltlformula", 10 ) )
+ Vec_PtrPush( p->pLatest->vLtlProperties, pCur );
else if ( !strncmp(pCur, "latch", 5) )
Vec_PtrPush( p->pLatest->vLatches, pCur );
+ else if ( !strncmp(pCur, "flop", 4) )
+ Vec_PtrPush( p->pLatest->vFlops, pCur );
else if ( !strncmp(pCur, "r ", 2) || !strncmp(pCur, "reset ", 6) )
Vec_PtrPush( p->pLatest->vResets, pCur );
else if ( !strncmp(pCur, "inputs", 6) )
@@ -611,6 +635,8 @@ static void Io_MvReadPreparse( Io_MvMan_t * p )
Vec_PtrPush( p->pLatest->vOnehots, pCur );
else if ( p->fBlifMv && !strncmp(pCur, "mv", 2) )
Vec_PtrPush( p->pLatest->vMvs, pCur );
+ else if ( !strncmp(pCur, "constraint", 10) )
+ Vec_PtrPush( p->pLatest->vConstrs, pCur );
else if ( !strncmp(pCur, "blackbox", 8) )
p->pLatest->fBlackBox = 1;
else if ( !strncmp(pCur, "model", 5) )
@@ -628,7 +654,10 @@ static void Io_MvReadPreparse( Io_MvMan_t * p )
else if ( !strncmp(pCur, "exdc", 4) )
{
fprintf( stdout, "Line %d: Skipping EXDC network.\n", Io_MvGetLine(p, pCur) );
- break;
+// break;
+ if ( p->pLatest )
+ Vec_PtrPush( p->vModels, p->pLatest );
+ p->pLatest = NULL;
}
else if ( !strncmp(pCur, "attrib", 6) )
{}
@@ -640,6 +669,8 @@ static void Io_MvReadPreparse( Io_MvMan_t * p )
{}
else if ( !strncmp(pCur, "no_merge", 8) )
{}
+ else if ( !strncmp(pCur, "wd", 2) )
+ {}
// else if ( !strncmp(pCur, "inouts", 6) )
// {}
else
@@ -667,9 +698,9 @@ static int Io_MvReadInterfaces( Io_MvMan_t * p )
{
Io_MvMod_t * pMod;
char * pLine;
- int i, k;
+ int i, k, nOutsOld;
// iterate through the models
- Vec_PtrForEachEntry( p->vModels, pMod, i )
+ Vec_PtrForEachEntry( Io_MvMod_t *, p->vModels, pMod, i )
{
// parse the model
if ( !Io_MvParseLineModel( pMod, pMod->pName ) )
@@ -681,13 +712,22 @@ static int Io_MvReadInterfaces( Io_MvMan_t * p )
return 0;
}
// parse the inputs
- Vec_PtrForEachEntry( pMod->vInputs, pLine, k )
+ Vec_PtrForEachEntry( char *, pMod->vInputs, pLine, k )
if ( !Io_MvParseLineInputs( pMod, pLine ) )
return 0;
// parse the outputs
- Vec_PtrForEachEntry( pMod->vOutputs, pLine, k )
+ Vec_PtrForEachEntry( char *, pMod->vOutputs, pLine, k )
if ( !Io_MvParseLineOutputs( pMod, pLine ) )
return 0;
+ // parse the constraints
+ nOutsOld = Abc_NtkPoNum(pMod->pNtk);
+ Vec_PtrForEachEntry( char *, pMod->vConstrs, pLine, k )
+ if ( !Io_MvParseLineConstrs( pMod, pLine ) )
+ return 0;
+ pMod->pNtk->nConstrs = Abc_NtkPoNum(pMod->pNtk) - nOutsOld;
+ Vec_PtrForEachEntry( char *, pMod->vLtlProperties, pLine, k )
+ if ( !Io_MvParseLineLtlProperty( pMod, pLine ) )
+ return 0;
}
return 1;
}
@@ -711,13 +751,13 @@ static Abc_Lib_t * Io_MvParse( Io_MvMan_t * p )
char * pLine;
int i, k;
// iterate through the models
- Vec_PtrForEachEntry( p->vModels, pMod, i )
+ Vec_PtrForEachEntry( Io_MvMod_t *, p->vModels, pMod, i )
{
// check if there any MV lines
if ( Vec_PtrSize(pMod->vMvs) > 0 )
Abc_NtkStartMvVars( pMod->pNtk );
// parse the mv lines
- Vec_PtrForEachEntry( pMod->vMvs, pLine, k )
+ Vec_PtrForEachEntry( char *, pMod->vMvs, pLine, k )
if ( !Io_MvParseLineMv( pMod, pLine ) )
return NULL;
// if reset lines are used there should be the same number of them as latches
@@ -733,33 +773,37 @@ static Abc_Lib_t * Io_MvParse( Io_MvMan_t * p )
if ( p->fUseReset )
pMod->pResetLatch = Io_ReadCreateResetLatch( pMod->pNtk, p->fBlifMv );
}
+ // parse the flops
+ Vec_PtrForEachEntry( char *, pMod->vFlops, pLine, k )
+ if ( !Io_MvParseLineFlop( pMod, pLine ) )
+ return NULL;
// parse the latches
- Vec_PtrForEachEntry( pMod->vLatches, pLine, k )
+ Vec_PtrForEachEntry( char *, pMod->vLatches, pLine, k )
if ( !Io_MvParseLineLatch( pMod, pLine ) )
return NULL;
// parse the reset lines
if ( p->fUseReset )
- Vec_PtrForEachEntry( pMod->vResets, pLine, k )
+ Vec_PtrForEachEntry( char *, pMod->vResets, pLine, k )
if ( !Io_MvParseLineNamesMv( pMod, pLine, 1 ) )
return NULL;
// parse the nodes
if ( p->fBlifMv )
{
- Vec_PtrForEachEntry( pMod->vNames, pLine, k )
+ Vec_PtrForEachEntry( char *, pMod->vNames, pLine, k )
if ( !Io_MvParseLineNamesMv( pMod, pLine, 0 ) )
return NULL;
}
else
{
- Vec_PtrForEachEntry( pMod->vNames, pLine, k )
+ Vec_PtrForEachEntry( char *, pMod->vNames, pLine, k )
if ( !Io_MvParseLineNamesBlif( pMod, pLine ) )
return NULL;
- Vec_PtrForEachEntry( pMod->vShorts, pLine, k )
+ Vec_PtrForEachEntry( char *, pMod->vShorts, pLine, k )
if ( !Io_MvParseLineShortBlif( pMod, pLine ) )
return NULL;
}
// parse the subcircuits
- Vec_PtrForEachEntry( pMod->vSubckts, pLine, k )
+ Vec_PtrForEachEntry( char *, pMod->vSubckts, pLine, k )
if ( !Io_MvParseLineSubckt( pMod, pLine ) )
return NULL;
@@ -768,7 +812,7 @@ static Abc_Lib_t * Io_MvParse( Io_MvMan_t * p )
{
if ( pMod->pNtk->ntkFunc == ABC_FUNC_SOP )
{
- Extra_MmFlexStop( pMod->pNtk->pManFunc );
+ Extra_MmFlexStop( (Extra_MmFlex_t *)pMod->pNtk->pManFunc );
pMod->pNtk->pManFunc = NULL;
pMod->pNtk->ntkFunc = ABC_FUNC_BLACKBOX;
}
@@ -786,7 +830,7 @@ static Abc_Lib_t * Io_MvParse( Io_MvMan_t * p )
pObj->pNext = (Abc_Obj_t *)(ABC_PTRINT_T)k;
// derive register
pMod->pNtk->vOnehots = Vec_PtrAlloc( Vec_PtrSize(pMod->vOnehots) );
- Vec_PtrForEachEntry( pMod->vOnehots, pLine, k )
+ Vec_PtrForEachEntry( char *, pMod->vOnehots, pLine, k )
{
vLine = Io_MvParseLineOnehot( pMod, pLine );
if ( vLine == NULL )
@@ -799,7 +843,7 @@ static Abc_Lib_t * Io_MvParse( Io_MvMan_t * p )
pObj->pNext = NULL;
// print the result
printf( "Parsed %d groups of 1-hot registers: { ", Vec_PtrSize(pMod->pNtk->vOnehots) );
- Vec_PtrForEachEntry( pMod->pNtk->vOnehots, vLine, k )
+ Vec_PtrForEachEntry( Vec_Int_t *, pMod->pNtk->vOnehots, vLine, k )
printf( "%d ", Vec_IntSize(vLine) );
printf( "}\n" );
printf( "The total number of 1-hot registers = %d. (%.2f %%)\n",
@@ -812,6 +856,12 @@ static Abc_Lib_t * Io_MvParse( Io_MvMan_t * p )
printf( "One-hotness condition is written into file \"%s\".\n", pFileName );
}
}
+ if ( Vec_PtrSize(pMod->vFlops) )
+ {
+ printf( "Warning: The parser converted %d .flop lines into .latch lines\n", Vec_PtrSize(pMod->vFlops) );
+ printf( "(information about set, reset, enable of the flops may be lost).\n" );
+ }
+
}
if ( p->nNDnodes )
// printf( "Warning: The parser added %d PIs to replace non-deterministic nodes.\n", p->nNDnodes );
@@ -838,7 +888,7 @@ static int Io_MvParseLineModel( Io_MvMod_t * p, char * pLine )
Vec_Ptr_t * vTokens = p->pMan->vTokens;
char * pToken, * pPivot;
Io_MvSplitIntoTokens( vTokens, pLine, '\0' );
- pToken = Vec_PtrEntry( vTokens, 0 );
+ pToken = (char *)Vec_PtrEntry( vTokens, 0 );
assert( !strcmp(pToken, "model") );
if ( Vec_PtrSize(vTokens) != 2 )
{
@@ -854,7 +904,7 @@ static int Io_MvParseLineModel( Io_MvMod_t * p, char * pLine )
// for ( pPivot = pToken = Vec_PtrEntry(vTokens, 1); *pToken; pToken++ )
// if ( *pToken == '/' || *pToken == '\\' )
// pPivot = pToken+1;
- pPivot = pToken = Vec_PtrEntry(vTokens, 1);
+ pPivot = pToken = (char *)Vec_PtrEntry(vTokens, 1);
p->pNtk->pName = Extra_UtilStrsav( pPivot );
return 1;
}
@@ -876,9 +926,9 @@ static int Io_MvParseLineInputs( Io_MvMod_t * p, char * pLine )
char * pToken;
int i;
Io_MvSplitIntoTokens( vTokens, pLine, '\0' );
- pToken = Vec_PtrEntry(vTokens, 0);
+ pToken = (char *)Vec_PtrEntry(vTokens, 0);
assert( !strcmp(pToken, "inputs") );
- Vec_PtrForEachEntryStart( vTokens, pToken, i, 1 )
+ Vec_PtrForEachEntryStart( char *, vTokens, pToken, i, 1 )
Io_ReadCreatePi( p->pNtk, pToken );
return 1;
}
@@ -900,15 +950,82 @@ static int Io_MvParseLineOutputs( Io_MvMod_t * p, char * pLine )
char * pToken;
int i;
Io_MvSplitIntoTokens( vTokens, pLine, '\0' );
- pToken = Vec_PtrEntry(vTokens, 0);
+ pToken = (char *)Vec_PtrEntry(vTokens, 0);
assert( !strcmp(pToken, "outputs") );
- Vec_PtrForEachEntryStart( vTokens, pToken, i, 1 )
+ Vec_PtrForEachEntryStart( char *, vTokens, pToken, i, 1 )
Io_ReadCreatePo( p->pNtk, pToken );
return 1;
}
/**Function*************************************************************
+ Synopsis [Parses the outputs line.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static int Io_MvParseLineConstrs( Io_MvMod_t * p, char * pLine )
+{
+ Vec_Ptr_t * vTokens = p->pMan->vTokens;
+ char * pToken;
+ int i;
+ Io_MvSplitIntoTokens( vTokens, pLine, '\0' );
+ pToken = (char *)Vec_PtrEntry(vTokens, 0);
+ assert( !strcmp(pToken, "constraint") );
+ Vec_PtrForEachEntryStart( char *, vTokens, pToken, i, 1 )
+ Io_ReadCreatePo( p->pNtk, pToken );
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Parses the LTL property line.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static int Io_MvParseLineLtlProperty( Io_MvMod_t * p, char * pLine )
+{
+ int i, j;
+ int quoteBegin, quoteEnd;
+ char keyWordLtlFormula[11];
+ char *actualLtlFormula;
+
+ //checking if the line begins with the keyword "ltlformula" and
+ //progressing the pointer forword
+ for( i=0; i<10; i++ )
+ keyWordLtlFormula[i] = pLine[i];
+ quoteBegin = i;
+ keyWordLtlFormula[10] = '\0';
+ assert( strcmp( "ltlformula", keyWordLtlFormula ) == 0 );
+ while( pLine[i] != '"' )
+ i++;
+ quoteBegin = i;
+ i = strlen( pLine );
+ while( pLine[i] != '"' )
+ i--;
+ quoteEnd = i;
+ actualLtlFormula = (char *)malloc( sizeof(char) * (quoteEnd - quoteBegin) );
+ //printf("\nThe input ltl formula = ");
+ for( i = quoteBegin + 1, j = 0; i<quoteEnd; i++, j++ )
+ //printf("%c", pLine[i] );
+ actualLtlFormula[j] = pLine[i];
+ actualLtlFormula[j] = '\0';
+ Vec_PtrPush( vGlobalLtlArray, actualLtlFormula );
+ return 1;
+}
+
+
+/**Function*************************************************************
+
Synopsis [Parses the latches line.]
Description []
@@ -925,7 +1042,7 @@ static int Io_MvParseLineLatch( Io_MvMod_t * p, char * pLine )
char * pToken;
int Init;
Io_MvSplitIntoTokens( vTokens, pLine, '\0' );
- pToken = Vec_PtrEntry(vTokens,0);
+ pToken = (char *)Vec_PtrEntry(vTokens,0);
assert( !strcmp(pToken, "latch") );
if ( Vec_PtrSize(vTokens) < 3 )
{
@@ -935,7 +1052,7 @@ static int Io_MvParseLineLatch( Io_MvMod_t * p, char * pLine )
// create latch
if ( p->pResetLatch == NULL )
{
- pObj = Io_ReadCreateLatch( p->pNtk, Vec_PtrEntry(vTokens,1), Vec_PtrEntry(vTokens,2) );
+ pObj = Io_ReadCreateLatch( p->pNtk, (char *)Vec_PtrEntry(vTokens,1), (char *)Vec_PtrEntry(vTokens,2) );
// get initial value
if ( p->pMan->fBlifMv )
Abc_LatchSetInit0( pObj );
@@ -945,7 +1062,7 @@ static int Io_MvParseLineLatch( Io_MvMod_t * p, char * pLine )
printf( "Warning: Line %d has .latch directive with unrecognized entries (the total of %d entries).\n",
Io_MvGetLine(p->pMan, pToken), Vec_PtrSize(vTokens) );
if ( Vec_PtrSize(vTokens) > 3 )
- Init = atoi( Vec_PtrEntryLast(vTokens) );
+ Init = atoi( (char *)Vec_PtrEntryLast(vTokens) );
else
Init = 2;
if ( Init < 0 || Init > 2 )
@@ -964,11 +1081,11 @@ static int Io_MvParseLineLatch( Io_MvMod_t * p, char * pLine )
else
{
// get the net corresponding to the output of the latch
- pNet = Abc_NtkFindOrCreateNet( p->pNtk, Vec_PtrEntry(vTokens,2) );
+ pNet = Abc_NtkFindOrCreateNet( p->pNtk, (char *)Vec_PtrEntry(vTokens,2) );
// get the net corresponding to the latch output (feeding into reset MUX)
pNet = Abc_NtkFindOrCreateNet( p->pNtk, Abc_ObjNameSuffix(pNet, "_out") );
// create latch
- pObj = Io_ReadCreateLatch( p->pNtk, Vec_PtrEntry(vTokens,1), Abc_ObjName(pNet) );
+ pObj = Io_ReadCreateLatch( p->pNtk, (char *)Vec_PtrEntry(vTokens,1), Abc_ObjName(pNet) );
// Abc_LatchSetInit0( pObj );
Abc_LatchSetInit0( pObj );
}
@@ -977,6 +1094,81 @@ static int Io_MvParseLineLatch( Io_MvMod_t * p, char * pLine )
/**Function*************************************************************
+ Synopsis [Parses the latches line.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static int Io_MvParseLineFlop( Io_MvMod_t * p, char * pLine )
+{
+ Vec_Ptr_t * vTokens = p->pMan->vTokens;
+ Abc_Obj_t * pObj;
+ char * pToken, * pOutput, * pInput;
+ int i, Init = 2;
+ assert( !p->pMan->fBlifMv );
+ Io_MvSplitIntoTokens( vTokens, pLine, '\0' );
+ pToken = (char *)Vec_PtrEntry(vTokens,0);
+ assert( !strcmp(pToken, "flop") );
+ // get flop output
+ Vec_PtrForEachEntry( char *, vTokens, pToken, i )
+ if ( pToken[0] == 'Q' && pToken[1] == '=' )
+ break;
+ if ( i == Vec_PtrSize(vTokens) )
+ {
+ sprintf( p->pMan->sError, "Line %d: Cannot find flop output.", Io_MvGetLine(p->pMan, (char *)Vec_PtrEntry(vTokens,0)) );
+ return 0;
+ }
+ pOutput = pToken+2;
+ // get flop input
+ Vec_PtrForEachEntry( char *, vTokens, pToken, i )
+ if ( pToken[0] == 'D' && pToken[1] == '=' )
+ break;
+ if ( i == Vec_PtrSize(vTokens) )
+ {
+ sprintf( p->pMan->sError, "Line %d: Cannot find flop input.", Io_MvGetLine(p->pMan, (char *)Vec_PtrEntry(vTokens,0)) );
+ return 0;
+ }
+ pInput = pToken+2;
+ // create latch
+ pObj = Io_ReadCreateLatch( p->pNtk, pInput, pOutput );
+ // get the init value
+ Vec_PtrForEachEntry( char *, vTokens, pToken, i )
+ {
+ if ( !strncmp( pToken, "init=", 5 ) )
+ {
+ Init = 0;
+ if ( pToken[5] == '1' )
+ Init = 1;
+ else if ( pToken[5] == '2' )
+ Init = 2;
+ else if ( pToken[5] != '0' )
+ {
+ sprintf( p->pMan->sError, "Line %d: Cannot read flop init value %s.", Io_MvGetLine(p->pMan, pToken), pToken );
+ return 0;
+ }
+ break;
+ }
+ }
+ if ( Init < 0 || Init > 2 )
+ {
+ sprintf( p->pMan->sError, "Line %d: Initial state of the flop is incorrect \"%s\".", Io_MvGetLine(p->pMan, pToken), (char*)Vec_PtrEntry(vTokens,3) );
+ return 0;
+ }
+ if ( Init == 0 )
+ Abc_LatchSetInit0( pObj );
+ else if ( Init == 1 )
+ Abc_LatchSetInit1( pObj );
+ else // if ( Init == 2 )
+ Abc_LatchSetInitDc( pObj );
+ return 1;
+}
+
+/**Function*************************************************************
+
Synopsis [Parses the subckt line.]
Description []
@@ -997,11 +1189,19 @@ static int Io_MvParseLineSubckt( Io_MvMod_t * p, char * pLine )
// split the line into tokens
nEquals = Io_MvCountChars( pLine, '=' );
Io_MvSplitIntoTokensAndClear( vTokens, pLine, '\0', '=' );
- pToken = Vec_PtrEntry(vTokens,0);
+ pToken = (char *)Vec_PtrEntry(vTokens,0);
assert( !strcmp(pToken, "subckt") );
// get the model for this box
- pName = Vec_PtrEntry(vTokens,1);
+ pName = (char *)Vec_PtrEntry(vTokens,1);
+ // skip instance name for now
+ for ( pToken = pName; *pToken; pToken++ )
+ if ( *pToken == '|' )
+ {
+ *pToken = 0;
+ break;
+ }
+ // find the model
pModel = Abc_LibFindModelByName( p->pMan->pDesign, pName );
if ( pModel == NULL )
{
@@ -1027,7 +1227,7 @@ static int Io_MvParseLineSubckt( Io_MvMod_t * p, char * pLine )
pBox = Abc_NtkCreateWhitebox( p->pNtk );
pBox->pData = pModel;
if ( p->pMan->fBlifMv )
- Abc_ObjAssignName( pBox, Vec_PtrEntry(vTokens,2), NULL );
+ Abc_ObjAssignName( pBox, (char *)Vec_PtrEntry(vTokens,2), NULL );
// go through formal inputs
Abc_NtkForEachPi( pModel, pTerm, i )
{
@@ -1047,7 +1247,7 @@ static int Io_MvParseLineSubckt( Io_MvMod_t * p, char * pLine )
if ( k == nEquals )
{
Abc_Obj_t * pNode = Abc_NtkCreateNode( p->pNtk );
- pNode->pData = Abc_SopRegister( p->pNtk->pManFunc, " 0\n" );
+ pNode->pData = Abc_SopRegister( (Extra_MmFlex_t *)p->pNtk->pManFunc, " 0\n" );
pNet = Abc_NtkFindOrCreateNet( p->pNtk, Abc_ObjNameSuffix(pNode, "abc") );
Abc_ObjAddFanin( pNet, pNode );
pTerm = Abc_NtkCreateBi( p->pNtk );
@@ -1110,13 +1310,13 @@ static Vec_Int_t * Io_MvParseLineOnehot( Io_MvMod_t * p, char * pLine )
// split the line into tokens
nEquals = Io_MvCountChars( pLine, '=' );
Io_MvSplitIntoTokensAndClear( vTokens, pLine, '\0', '=' );
- pToken = Vec_PtrEntry(vTokens,0);
+ pToken = (char *)Vec_PtrEntry(vTokens,0);
assert( !strcmp(pToken, "onehot") );
// iterate through the register names
// vResult = Vec_PtrAlloc( Vec_PtrSize(vTokens) );
vResult = Vec_IntAlloc( Vec_PtrSize(vTokens) );
- Vec_PtrForEachEntryStart( vTokens, pToken, i, 1 )
+ Vec_PtrForEachEntryStart( char *, vTokens, pToken, i, 1 )
{
// check if this register exists
pNet = Abc_NtkFindNet( p->pNtk, pToken );
@@ -1167,7 +1367,7 @@ static int Io_MvParseLineMv( Io_MvMod_t * p, char * pLine )
// count commas and get the tokens
nCommas = Io_MvCountChars( pLine, ',' );
Io_MvSplitIntoTokensAndClear( vTokens, pLine, '\0', ',' );
- pName = Vec_PtrEntry(vTokens,0);
+ pName = (char *)Vec_PtrEntry(vTokens,0);
assert( !strcmp(pName, "mv") );
// get the number of values
if ( Vec_PtrSize(vTokens) <= nCommas + 2 )
@@ -1175,7 +1375,7 @@ static int Io_MvParseLineMv( Io_MvMod_t * p, char * pLine )
sprintf( p->pMan->sError, "Line %d: The number of values in not specified in .mv line.", Io_MvGetLine(p->pMan, pName) );
return 0;
}
- nValues = atoi( Vec_PtrEntry(vTokens,nCommas+2) );
+ nValues = atoi( (char *)Vec_PtrEntry(vTokens,nCommas+2) );
if ( nValues < 2 || nValues > IO_BLIFMV_MAXVALUES )
{
sprintf( p->pMan->sError, "Line %d: The number of values (%d) is incorrect (should be >= 2 and <= %d).",
@@ -1192,10 +1392,10 @@ static int Io_MvParseLineMv( Io_MvMod_t * p, char * pLine )
return 0;
}
// go through variables
- pFlex = Abc_NtkMvVarMan( p->pNtk );
+ pFlex = (Extra_MmFlex_t *)Abc_NtkMvVarMan( p->pNtk );
for ( i = 0; i <= nCommas; i++ )
{
- pName = Vec_PtrEntry( vTokens, i+1 );
+ pName = (char *)Vec_PtrEntry( vTokens, i+1 );
pObj = Abc_NtkFindOrCreateNet( p->pNtk, pName );
// allocate variable
pVar = (Io_MvVar_t *)Extra_MmFlexEntryFetch( pFlex, sizeof(Io_MvVar_t) );
@@ -1205,7 +1405,7 @@ static int Io_MvParseLineMv( Io_MvMod_t * p, char * pLine )
if ( Vec_PtrSize(vTokens) > nCommas + 3 )
{
pVar->pNames = (char **)Extra_MmFlexEntryFetch( pFlex, sizeof(char *) * nValues );
- Vec_PtrForEachEntryStart( vTokens, pName, k, nCommas + 3 )
+ Vec_PtrForEachEntryStart( char *, vTokens, pName, k, nCommas + 3 )
{
pVar->pNames[k-(nCommas + 3)] = (char *)Extra_MmFlexEntryFetch( pFlex, strlen(pName) + 1 );
strcpy( pVar->pNames[k-(nCommas + 3)], pName );
@@ -1222,7 +1422,7 @@ static int Io_MvParseLineMv( Io_MvMod_t * p, char * pLine )
for ( k = i+1; k < nValues; k++ )
if ( !strcmp(pVar->pNames[i], pVar->pNames[k]) )
{
- pName = Vec_PtrEntry(vTokens,0);
+ pName = (char *)Vec_PtrEntry(vTokens,0);
sprintf( p->pMan->sError, "Line %d: Symbolic value name \"%s\" is repeated in .mv line.",
Io_MvGetLine(p->pMan, pName), pVar->pNames[i] );
return 0;
@@ -1251,12 +1451,12 @@ static int Io_MvWriteValues( Abc_Obj_t * pNode, Vec_Str_t * vFunc )
Abc_ObjForEachFanin( pNode, pFanin, i )
{
sprintf( Buffer, "%d", Abc_ObjMvVarNum(pFanin) );
- Vec_StrAppend( vFunc, Buffer );
+ Vec_StrPrintStr( vFunc, Buffer );
Vec_StrPush( vFunc, ' ' );
}
// add the node number of values
sprintf( Buffer, "%d", Abc_ObjMvVarNum(Abc_ObjFanout0(pNode)) );
- Vec_StrAppend( vFunc, Buffer );
+ Vec_StrPrintStr( vFunc, Buffer );
Vec_StrPush( vFunc, '\n' );
return 1;
}
@@ -1294,18 +1494,18 @@ static int Io_MvParseLiteralMv( Io_MvMod_t * p, Abc_Obj_t * pNode, char * pToken
}
Vec_StrPush( vFunc, '=' );
sprintf( Buffer, "%d", i );
- Vec_StrAppend( vFunc, Buffer );
+ Vec_StrPrintStr( vFunc, Buffer );
Vec_StrPush( vFunc, (char)((iLit == -1)? '\n' : ' ') );
return 1;
}
// consider regular literal
assert( iLit < Abc_ObjFaninNum(pNode) );
pNet = iLit >= 0 ? Abc_ObjFanin(pNode, iLit) : Abc_ObjFanout0(pNode);
- pVar = Abc_ObjMvVar( pNet );
+ pVar = (Io_MvVar_t *)Abc_ObjMvVar( pNet );
// if the var is absent or has no symbolic values quit
if ( pVar == NULL || pVar->pNames == NULL )
{
- Vec_StrAppend( vFunc, pToken );
+ Vec_StrPrintStr( vFunc, pToken );
Vec_StrPush( vFunc, (char)((iLit == -1)? '\n' : ' ') );
return 1;
}
@@ -1334,7 +1534,7 @@ static int Io_MvParseLiteralMv( Io_MvMod_t * p, Abc_Obj_t * pNode, char * pToken
}
// value name is found
sprintf( Buffer, "%d", i );
- Vec_StrAppend( vFunc, Buffer );
+ Vec_StrPrintStr( vFunc, Buffer );
// update the pointer
pCur = pNext - 1;
}
@@ -1363,12 +1563,12 @@ static char * Io_MvParseTableMv( Io_MvMod_t * p, Abc_Obj_t * pNode, Vec_Ptr_t *
// write the number of values
// Io_MvWriteValues( pNode, vFunc );
// get the first token
- pFirst = Vec_PtrEntry( vTokens2, 0 );
+ pFirst = (char *)Vec_PtrEntry( vTokens2, 0 );
if ( pFirst[0] == '.' )
{
// write the default literal
Vec_StrPush( vFunc, 'd' );
- pToken = Vec_PtrEntry(vTokens2, 1 + iOut);
+ pToken = (char *)Vec_PtrEntry(vTokens2, 1 + iOut);
if ( !Io_MvParseLiteralMv( p, pNode, pToken, vFunc, -1 ) )
return NULL;
iStart = 1 + nOutputs;
@@ -1381,12 +1581,12 @@ static char * Io_MvParseTableMv( Io_MvMod_t * p, Abc_Obj_t * pNode, Vec_Ptr_t *
// input literals
for ( i = 0; i < nInputs; i++ )
{
- pToken = Vec_PtrEntry( vTokens2, iStart + i );
+ pToken = (char *)Vec_PtrEntry( vTokens2, iStart + i );
if ( !Io_MvParseLiteralMv( p, pNode, pToken, vFunc, i ) )
return NULL;
}
// output literal
- pToken = Vec_PtrEntry( vTokens2, iStart + nInputs + iOut );
+ pToken = (char *)Vec_PtrEntry( vTokens2, iStart + nInputs + iOut );
if ( !Io_MvParseLiteralMv( p, pNode, pToken, vFunc, -1 ) )
return NULL;
// update the counter
@@ -1424,7 +1624,7 @@ static Abc_Obj_t * Io_MvParseAddResetCircuit( Io_MvMod_t * p, char * pName )
// duplicate MV variables
if ( Abc_NtkMvVar(p->pNtk) )
{
- pVar = Abc_ObjMvVar( pOutNet );
+ pVar = (Io_MvVar_t *)Abc_ObjMvVar( pOutNet );
Abc_ObjSetMvVar( pData0Net, Abc_NtkMvVarDup(p->pNtk, pVar) );
Abc_ObjSetMvVar( pData1Net, Abc_NtkMvVarDup(p->pNtk, pVar) );
}
@@ -1439,10 +1639,10 @@ static Abc_Obj_t * Io_MvParseAddResetCircuit( Io_MvMod_t * p, char * pName )
// int nValues = Abc_ObjMvVarNum(pOutNet);
// sprintf( Buffer, "2 %d %d %d\n1 - - =1\n0 - - =2\n", nValues, nValues, nValues );
sprintf( Buffer, "1 - - =1\n0 - - =2\n" );
- pNode->pData = Abc_SopRegister( p->pNtk->pManFunc, Buffer );
+ pNode->pData = Abc_SopRegister( (Extra_MmFlex_t *)p->pNtk->pManFunc, Buffer );
}
else
- pNode->pData = Abc_SopCreateMux( p->pNtk->pManFunc );
+ pNode->pData = Abc_SopCreateMux( (Extra_MmFlex_t *)p->pNtk->pManFunc );
// add nets
Abc_ObjAddFanin( pNode, pResetLONet );
Abc_ObjAddFanin( pNode, pData1Net );
@@ -1466,7 +1666,7 @@ static int Io_MvParseLineNamesMvOne( Io_MvMod_t * p, Vec_Ptr_t * vTokens, Vec_Pt
Abc_Obj_t * pNet, * pNode;
char * pName;
// get the output name
- pName = Vec_PtrEntry( vTokens, Vec_PtrSize(vTokens) - nOutputs + iOut );
+ pName = (char *)Vec_PtrEntry( vTokens, Vec_PtrSize(vTokens) - nOutputs + iOut );
// create the node
if ( fReset )
{
@@ -1503,7 +1703,7 @@ static int Io_MvParseLineNamesMvOne( Io_MvMod_t * p, Vec_Ptr_t * vTokens, Vec_Pt
pNode->pData = Io_MvParseTableMv( p, pNode, vTokens2, nInputs, nOutputs, iOut );
if ( pNode->pData == NULL )
return 0;
- pNode->pData = Abc_SopRegister( p->pNtk->pManFunc, pNode->pData );
+ pNode->pData = Abc_SopRegister( (Extra_MmFlex_t *)p->pNtk->pManFunc, (char *)pNode->pData );
//printf( "Finished parsing node \"%s\" with table:\n%s\n", pName, pNode->pData );
return 1;
}
@@ -1537,9 +1737,9 @@ static int Io_MvParseLineNamesMv( Io_MvMod_t * p, char * pLine, int fReset )
// split names line into tokens
Io_MvSplitIntoTokens( vTokens, pLine, '\0' );
if ( fReset )
- assert( !strcmp(Vec_PtrEntry(vTokens,0), "r") || !strcmp(Vec_PtrEntry(vTokens,0), "reset") );
+ assert( !strcmp((char *)Vec_PtrEntry(vTokens,0), "r") || !strcmp((char *)Vec_PtrEntry(vTokens,0), "reset") );
else
- assert( !strcmp(Vec_PtrEntry(vTokens,0), "names") || !strcmp(Vec_PtrEntry(vTokens,0), "table") );
+ assert( !strcmp((char *)Vec_PtrEntry(vTokens,0), "names") || !strcmp((char *)Vec_PtrEntry(vTokens,0), "table") );
// find the number of inputs and outputs
nInputs = Vec_PtrSize(vTokens) - 2;
nOutputs = 1;
@@ -1553,9 +1753,9 @@ static int Io_MvParseLineNamesMv( Io_MvMod_t * p, char * pLine, int fReset )
}
}
// split table into tokens
- pName = Vec_PtrEntryLast( vTokens );
+ pName = (char *)Vec_PtrEntryLast( vTokens );
Io_MvSplitIntoTokensMv( vTokens2, pName + strlen(pName) );
- pFirst = Vec_PtrEntry( vTokens2, 0 );
+ pFirst = (char *)Vec_PtrEntry( vTokens2, 0 );
if ( pFirst[0] == '.' )
{
assert( pFirst[1] == 'd' );
@@ -1576,7 +1776,7 @@ static int Io_MvParseLineNamesMv( Io_MvMod_t * p, char * pLine, int fReset )
// add the outputs to the PIs
for ( i = 0; i < nOutputs; i++ )
{
- pName = Vec_PtrEntry( vTokens, Vec_PtrSize(vTokens) - nOutputs + i );
+ pName = (char *)Vec_PtrEntry( vTokens, Vec_PtrSize(vTokens) - nOutputs + i );
// get the net corresponding to this node
pNet = Abc_NtkFindOrCreateNet(p->pNtk, pName);
if ( fReset )
@@ -1625,19 +1825,19 @@ static char * Io_MvParseTableBlif( Io_MvMod_t * p, char * pTable, int nFanins )
// get the tokens
Io_MvSplitIntoTokens( vTokens, pTable, '.' );
if ( Vec_PtrSize(vTokens) == 0 )
- return Abc_SopCreateConst0( p->pNtk->pManFunc );
+ return Abc_SopCreateConst0( (Extra_MmFlex_t *)p->pNtk->pManFunc );
if ( Vec_PtrSize(vTokens) == 1 )
{
- pOutput = Vec_PtrEntry( vTokens, 0 );
+ pOutput = (char *)Vec_PtrEntry( vTokens, 0 );
c = pOutput[0];
if ( (c!='0'&&c!='1'&&c!='x'&&c!='n') || pOutput[1] )
{
sprintf( p->pMan->sError, "Line %d: Constant table has wrong output value \"%s\".", Io_MvGetLine(p->pMan, pOutput), pOutput );
return NULL;
}
- return pOutput[0] == '0' ? Abc_SopCreateConst0(p->pNtk->pManFunc) : Abc_SopCreateConst1(p->pNtk->pManFunc);
+ return pOutput[0] == '0' ? Abc_SopCreateConst0((Extra_MmFlex_t *)p->pNtk->pManFunc) : Abc_SopCreateConst1((Extra_MmFlex_t *)p->pNtk->pManFunc);
}
- pProduct = Vec_PtrEntry( vTokens, 0 );
+ pProduct = (char *)Vec_PtrEntry( vTokens, 0 );
if ( Vec_PtrSize(vTokens) % 2 == 1 )
{
sprintf( p->pMan->sError, "Line %d: Table has odd number of tokens (%d).", Io_MvGetLine(p->pMan, pProduct), Vec_PtrSize(vTokens) );
@@ -1647,8 +1847,8 @@ static char * Io_MvParseTableBlif( Io_MvMod_t * p, char * pTable, int nFanins )
Vec_StrClear( vFunc );
for ( i = 0; i < Vec_PtrSize(vTokens)/2; i++ )
{
- pProduct = Vec_PtrEntry( vTokens, 2*i + 0 );
- pOutput = Vec_PtrEntry( vTokens, 2*i + 1 );
+ pProduct = (char *)Vec_PtrEntry( vTokens, 2*i + 0 );
+ pOutput = (char *)Vec_PtrEntry( vTokens, 2*i + 1 );
if ( strlen(pProduct) != (unsigned)nFanins )
{
sprintf( p->pMan->sError, "Line %d: Cube \"%s\" has size different from the fanin count (%d).", Io_MvGetLine(p->pMan, pProduct), pProduct, nFanins );
@@ -1668,7 +1868,7 @@ static char * Io_MvParseTableBlif( Io_MvMod_t * p, char * pTable, int nFanins )
return NULL;
}
// parse one product
- Vec_StrAppend( vFunc, pProduct );
+ Vec_StrPrintStr( vFunc, pProduct );
Vec_StrPush( vFunc, ' ' );
Vec_StrPush( vFunc, pOutput[0] );
Vec_StrPush( vFunc, '\n' );
@@ -1696,11 +1896,11 @@ static int Io_MvParseLineNamesBlif( Io_MvMod_t * p, char * pLine )
assert( !p->pMan->fBlifMv );
Io_MvSplitIntoTokens( vTokens, pLine, '\0' );
// parse the mapped node
- if ( !strcmp(Vec_PtrEntry(vTokens,0), "gate") )
+ if ( !strcmp((char *)Vec_PtrEntry(vTokens,0), "gate") )
return Io_MvParseLineGateBlif( p, vTokens );
// parse the regular name line
- assert( !strcmp(Vec_PtrEntry(vTokens,0), "names") );
- pName = Vec_PtrEntryLast( vTokens );
+ assert( !strcmp((char *)Vec_PtrEntry(vTokens,0), "names") );
+ pName = (char *)Vec_PtrEntryLast( vTokens );
pNet = Abc_NtkFindOrCreateNet( p->pNtk, pName );
if ( Abc_ObjFaninNum(pNet) > 0 )
{
@@ -1713,7 +1913,7 @@ static int Io_MvParseLineNamesBlif( Io_MvMod_t * p, char * pLine )
pNode->pData = Io_MvParseTableBlif( p, pName + strlen(pName), Abc_ObjFaninNum(pNode) );
if ( pNode->pData == NULL )
return 0;
- pNode->pData = Abc_SopRegister( p->pNtk->pManFunc, pNode->pData );
+ pNode->pData = Abc_SopRegister( (Extra_MmFlex_t *)p->pNtk->pManFunc, (char *)pNode->pData );
return 1;
}
@@ -1737,12 +1937,12 @@ static int Io_MvParseLineShortBlif( Io_MvMod_t * p, char * pLine )
Io_MvSplitIntoTokens( vTokens, pLine, '\0' );
if ( Vec_PtrSize(vTokens) != 3 )
{
- sprintf( p->pMan->sError, "Line %d: Expecting three entries in the .short line.", Io_MvGetLine(p->pMan, Vec_PtrEntry(vTokens,0)) );
+ sprintf( p->pMan->sError, "Line %d: Expecting three entries in the .short line.", Io_MvGetLine(p->pMan, (char *)Vec_PtrEntry(vTokens,0)) );
return 0;
}
// parse the regular name line
- assert( !strcmp(Vec_PtrEntry(vTokens,0), "short") );
- pName = Vec_PtrEntryLast( vTokens );
+ assert( !strcmp((char *)Vec_PtrEntry(vTokens,0), "short") );
+ pName = (char *)Vec_PtrEntryLast( vTokens );
pNet = Abc_NtkFindOrCreateNet( p->pNtk, pName );
if ( Abc_ObjFaninNum(pNet) > 0 )
{
@@ -1752,7 +1952,7 @@ static int Io_MvParseLineShortBlif( Io_MvMod_t * p, char * pLine )
// create fanins
pNode = Io_ReadCreateNode( p->pNtk, pName, (char **)(vTokens->pArray + 1), 1 );
// parse the table of this node
- pNode->pData = Abc_SopRegister( p->pNtk->pManFunc, "1 1\n" );
+ pNode->pData = Abc_SopRegister( (Extra_MmFlex_t *)p->pNtk->pManFunc, "1 1\n" );
return 1;
}
@@ -1774,7 +1974,7 @@ Io_MvVar_t * Abc_NtkMvVarDup( Abc_Ntk_t * pNtk, Io_MvVar_t * pVar )
int i;
if ( pVar == NULL )
return NULL;
- pFlex = Abc_NtkMvVarMan( pNtk );
+ pFlex = (Extra_MmFlex_t *)Abc_NtkMvVarMan( pNtk );
assert( pFlex != NULL );
pVarDup = (Io_MvVar_t *)Extra_MmFlexEntryFetch( pFlex, sizeof(Io_MvVar_t) );
pVarDup->nValues = pVar->nValues;
@@ -1790,10 +1990,14 @@ Io_MvVar_t * Abc_NtkMvVarDup( Abc_Ntk_t * pNtk, Io_MvVar_t * pVar )
return pVarDup;
}
+ABC_NAMESPACE_IMPL_END
#include "mio.h"
#include "main.h"
+ABC_NAMESPACE_IMPL_START
+
+
/**Function*************************************************************
Synopsis []
@@ -1835,10 +2039,10 @@ static int Io_MvParseLineGateBlif( Io_MvMod_t * p, Vec_Ptr_t * vTokens )
char ** ppNames, * pName;
int i, nNames;
- pName = vTokens->pArray[0];
+ pName = (char *)vTokens->pArray[0];
// check that the library is available
- pGenlib = Abc_FrameReadLibGen();
+ pGenlib = (Mio_Library_t *)Abc_FrameReadLibGen();
if ( pGenlib == NULL )
{
sprintf( p->pMan->sError, "Line %d: The current library is not available.", Io_MvGetLine(p->pMan, pName) );
@@ -1853,7 +2057,7 @@ static int Io_MvParseLineGateBlif( Io_MvMod_t * p, Vec_Ptr_t * vTokens )
}
// get the gate
- pGate = Mio_LibraryReadGateByName( pGenlib, vTokens->pArray[1] );
+ pGate = Mio_LibraryReadGateByName( pGenlib, (char *)vTokens->pArray[1] );
if ( pGate == NULL )
{
sprintf( p->pMan->sError, "Line %d: Cannot find gate \"%s\" in the library.", Io_MvGetLine(p->pMan, pName), (char*)vTokens->pArray[1] );
@@ -1865,7 +2069,7 @@ static int Io_MvParseLineGateBlif( Io_MvMod_t * p, Vec_Ptr_t * vTokens )
{
assert( p->pNtk->ntkFunc == ABC_FUNC_SOP );
p->pNtk->ntkFunc = ABC_FUNC_MAP;
- Extra_MmFlexStop( p->pNtk->pManFunc );
+ Extra_MmFlexStop( (Extra_MmFlex_t *)p->pNtk->pManFunc );
p->pNtk->pManFunc = pGenlib;
}
@@ -1879,7 +2083,7 @@ static int Io_MvParseLineGateBlif( Io_MvMod_t * p, Vec_Ptr_t * vTokens )
// remove the formal parameter names
for ( i = 2; i < vTokens->nSize; i++ )
{
- vTokens->pArray[i] = Io_ReadBlifCleanName( vTokens->pArray[i] );
+ vTokens->pArray[i] = Io_ReadBlifCleanName( (char *)vTokens->pArray[i] );
if ( vTokens->pArray[i] == NULL )
{
sprintf( p->pMan->sError, "Line %d: Invalid gate input assignment.", Io_MvGetLine(p->pMan, pName) );
@@ -1902,3 +2106,5 @@ static int Io_MvParseLineGateBlif( Io_MvMod_t * p, Vec_Ptr_t * vTokens )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/io/ioReadDsd.c b/src/base/io/ioReadDsd.c
index 4848e4e9..35bc6aaa 100644
--- a/src/base/io/ioReadDsd.c
+++ b/src/base/io/ioReadDsd.c
@@ -20,6 +20,9 @@
#include "ioAbc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -183,11 +186,11 @@ Abc_Obj_t * Io_ReadDsd_rec( Abc_Ntk_t * pNtk, char * pCur, char * pSop )
}
}
if ( pSop )
- pObj->pData = Abc_SopRegister( pNtk->pManFunc, pSop );
+ pObj->pData = Abc_SopRegister( (Extra_MmFlex_t *)pNtk->pManFunc, pSop );
else if ( TypeExor )
- pObj->pData = Abc_SopCreateXorSpecial( pNtk->pManFunc, nParts );
+ pObj->pData = Abc_SopCreateXorSpecial( (Extra_MmFlex_t *)pNtk->pManFunc, nParts );
else
- pObj->pData = Abc_SopCreateAnd( pNtk->pManFunc, nParts, NULL );
+ pObj->pData = Abc_SopCreateAnd( (Extra_MmFlex_t *)pNtk->pManFunc, nParts, NULL );
return pObj;
}
if ( *pCur >= 'a' && *pCur <= 'z' )
@@ -248,7 +251,7 @@ Abc_Ntk_t * Io_ReadDsd( char * pForm )
// create PIs
vNames = Abc_NodeGetFakeNames( nInputs );
for ( i = 0; i < nInputs; i++ )
- Abc_ObjAssignName( Abc_NtkCreatePi(pNtk), Vec_PtrEntry(vNames, i), NULL );
+ Abc_ObjAssignName( Abc_NtkCreatePi(pNtk), (char *)Vec_PtrEntry(vNames, i), NULL );
Abc_NodeFreeNames( vNames );
// transform the formula by inserting parantheses
@@ -306,3 +309,5 @@ Abc_Ntk_t * Io_ReadDsd( char * pForm )
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/io/ioReadEdif.c b/src/base/io/ioReadEdif.c
index 26e49d0e..8c739e61 100644
--- a/src/base/io/ioReadEdif.c
+++ b/src/base/io/ioReadEdif.c
@@ -20,6 +20,9 @@
#include "ioAbc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -90,8 +93,8 @@ Abc_Ntk_t * Io_ReadEdifNetwork( Extra_FileReader_t * p )
int fTokensReady, iLine, i;
// read the first line
- vTokens = Extra_FileReaderGetTokens(p);
- if ( strcmp( vTokens->pArray[0], "edif" ) != 0 )
+ vTokens = (Vec_Ptr_t *)Extra_FileReaderGetTokens(p);
+ if ( strcmp( (char *)vTokens->pArray[0], "edif" ) != 0 )
{
printf( "%s: Wrong input file format.\n", Extra_FileReaderGetFileName(p) );
return NULL;
@@ -103,19 +106,19 @@ Abc_Ntk_t * Io_ReadEdifNetwork( Extra_FileReader_t * p )
// go through the lines of the file
fTokensReady = 0;
pProgress = Extra_ProgressBarStart( stdout, Extra_FileReaderGetFileSize(p) );
- for ( iLine = 1; fTokensReady || (vTokens = Extra_FileReaderGetTokens(p)); iLine++ )
+ for ( iLine = 1; fTokensReady || (vTokens = (Vec_Ptr_t *)Extra_FileReaderGetTokens(p)); iLine++ )
{
Extra_ProgressBarUpdate( pProgress, Extra_FileReaderGetCurPosition(p), NULL );
// get the type of the line
fTokensReady = 0;
- if ( strcmp( vTokens->pArray[0], "instance" ) == 0 )
+ if ( strcmp( (char *)vTokens->pArray[0], "instance" ) == 0 )
{
- pNetName = vTokens->pArray[1];
+ pNetName = (char *)vTokens->pArray[1];
pNet = Abc_NtkFindOrCreateNet( pNtk, pNetName );
- vTokens = Extra_FileReaderGetTokens(p);
- vTokens = Extra_FileReaderGetTokens(p);
- pGateName = vTokens->pArray[1];
+ vTokens = (Vec_Ptr_t *)Extra_FileReaderGetTokens(p);
+ vTokens = (Vec_Ptr_t *)Extra_FileReaderGetTokens(p);
+ pGateName = (char *)vTokens->pArray[1];
if ( strncmp( pGateName, "Flip", 4 ) == 0 )
{
pObj = Abc_NtkCreateLatch( pNtk );
@@ -129,63 +132,63 @@ Abc_Ntk_t * Io_ReadEdifNetwork( Extra_FileReader_t * p )
}
Abc_ObjAddFanin( pNet, pObj );
}
- else if ( strcmp( vTokens->pArray[0], "net" ) == 0 )
+ else if ( strcmp( (char *)vTokens->pArray[0], "net" ) == 0 )
{
- pNetName = vTokens->pArray[1];
+ pNetName = (char *)vTokens->pArray[1];
if ( strcmp( pNetName, "CK" ) == 0 || strcmp( pNetName, "RESET" ) == 0 )
continue;
if ( strcmp( pNetName + strlen(pNetName) - 4, "_out" ) == 0 )
pNetName[strlen(pNetName) - 4] = 0;
pNet = Abc_NtkFindNet( pNtk, pNetName );
assert( pNet );
- vTokens = Extra_FileReaderGetTokens(p);
- vTokens = Extra_FileReaderGetTokens(p);
- vTokens = Extra_FileReaderGetTokens(p);
- while ( strcmp( vTokens->pArray[0], "portRef" ) == 0 )
+ vTokens = (Vec_Ptr_t *)Extra_FileReaderGetTokens(p);
+ vTokens = (Vec_Ptr_t *)Extra_FileReaderGetTokens(p);
+ vTokens = (Vec_Ptr_t *)Extra_FileReaderGetTokens(p);
+ while ( strcmp( (char *)vTokens->pArray[0], "portRef" ) == 0 )
{
- if ( strcmp( pNetName, vTokens->pArray[3] ) != 0 )
+ if ( strcmp( pNetName, (char *)vTokens->pArray[3] ) != 0 )
{
- pFanout = Abc_NtkFindNet( pNtk, vTokens->pArray[3] );
+ pFanout = Abc_NtkFindNet( pNtk, (char *)vTokens->pArray[3] );
Abc_ObjAddFanin( Abc_ObjFanin0(pFanout), pNet );
}
- vTokens = Extra_FileReaderGetTokens(p);
+ vTokens = (Vec_Ptr_t *)Extra_FileReaderGetTokens(p);
}
fTokensReady = 1;
}
- else if ( strcmp( vTokens->pArray[0], "library" ) == 0 )
+ else if ( strcmp( (char *)vTokens->pArray[0], "library" ) == 0 )
{
- vTokens = Extra_FileReaderGetTokens(p);
- vTokens = Extra_FileReaderGetTokens(p);
- vTokens = Extra_FileReaderGetTokens(p);
- vTokens = Extra_FileReaderGetTokens(p);
- vTokens = Extra_FileReaderGetTokens(p);
- while ( strcmp( vTokens->pArray[0], "port" ) == 0 )
+ vTokens = (Vec_Ptr_t *)Extra_FileReaderGetTokens(p);
+ vTokens = (Vec_Ptr_t *)Extra_FileReaderGetTokens(p);
+ vTokens = (Vec_Ptr_t *)Extra_FileReaderGetTokens(p);
+ vTokens = (Vec_Ptr_t *)Extra_FileReaderGetTokens(p);
+ vTokens = (Vec_Ptr_t *)Extra_FileReaderGetTokens(p);
+ while ( strcmp( (char *)vTokens->pArray[0], "port" ) == 0 )
{
- pNetName = vTokens->pArray[1];
+ pNetName = (char *)vTokens->pArray[1];
if ( strcmp( pNetName, "CK" ) == 0 || strcmp( pNetName, "RESET" ) == 0 )
{
- vTokens = Extra_FileReaderGetTokens(p);
+ vTokens = (Vec_Ptr_t *)Extra_FileReaderGetTokens(p);
continue;
}
if ( strcmp( pNetName + strlen(pNetName) - 3, "_PO" ) == 0 )
pNetName[strlen(pNetName) - 3] = 0;
- if ( strcmp( vTokens->pArray[3], "INPUT" ) == 0 )
- Io_ReadCreatePi( pNtk, vTokens->pArray[1] );
- else if ( strcmp( vTokens->pArray[3], "OUTPUT" ) == 0 )
- Io_ReadCreatePo( pNtk, vTokens->pArray[1] );
+ if ( strcmp( (char *)vTokens->pArray[3], "INPUT" ) == 0 )
+ Io_ReadCreatePi( pNtk, (char *)vTokens->pArray[1] );
+ else if ( strcmp( (char *)vTokens->pArray[3], "OUTPUT" ) == 0 )
+ Io_ReadCreatePo( pNtk, (char *)vTokens->pArray[1] );
else
{
printf( "%s (line %d): Wrong interface specification.\n", Extra_FileReaderGetFileName(p), iLine );
Abc_NtkDelete( pNtk );
return NULL;
}
- vTokens = Extra_FileReaderGetTokens(p);
+ vTokens = (Vec_Ptr_t *)Extra_FileReaderGetTokens(p);
}
}
- else if ( strcmp( vTokens->pArray[0], "design" ) == 0 )
+ else if ( strcmp( (char *)vTokens->pArray[0], "design" ) == 0 )
{
ABC_FREE( pNtk->pName );
- pNtk->pName = Extra_UtilStrsav( vTokens->pArray[3] );
+ pNtk->pName = (char *)Extra_UtilStrsav( (char *)vTokens->pArray[3] );
break;
}
}
@@ -194,22 +197,22 @@ Abc_Ntk_t * Io_ReadEdifNetwork( Extra_FileReader_t * p )
// assign logic functions
Abc_NtkForEachNode( pNtk, pObj, i )
{
- if ( strncmp( pObj->pData, "And", 3 ) == 0 )
- Abc_ObjSetData( pObj, Abc_SopCreateAnd(pNtk->pManFunc, Abc_ObjFaninNum(pObj), NULL) );
- else if ( strncmp( pObj->pData, "Or", 2 ) == 0 )
- Abc_ObjSetData( pObj, Abc_SopCreateOr(pNtk->pManFunc, Abc_ObjFaninNum(pObj), NULL) );
- else if ( strncmp( pObj->pData, "Nand", 4 ) == 0 )
- Abc_ObjSetData( pObj, Abc_SopCreateNand(pNtk->pManFunc, Abc_ObjFaninNum(pObj)) );
- else if ( strncmp( pObj->pData, "Nor", 3 ) == 0 )
- Abc_ObjSetData( pObj, Abc_SopCreateNor(pNtk->pManFunc, Abc_ObjFaninNum(pObj)) );
- else if ( strncmp( pObj->pData, "Exor", 4 ) == 0 )
- Abc_ObjSetData( pObj, Abc_SopCreateXor(pNtk->pManFunc, Abc_ObjFaninNum(pObj)) );
- else if ( strncmp( pObj->pData, "Exnor", 5 ) == 0 )
- Abc_ObjSetData( pObj, Abc_SopCreateNxor(pNtk->pManFunc, Abc_ObjFaninNum(pObj)) );
- else if ( strncmp( pObj->pData, "Inv", 3 ) == 0 )
- Abc_ObjSetData( pObj, Abc_SopCreateInv(pNtk->pManFunc) );
- else if ( strncmp( pObj->pData, "Buf", 3 ) == 0 )
- Abc_ObjSetData( pObj, Abc_SopCreateBuf(pNtk->pManFunc) );
+ if ( strncmp( (char *)pObj->pData, "And", 3 ) == 0 )
+ Abc_ObjSetData( pObj, Abc_SopCreateAnd((Extra_MmFlex_t *)pNtk->pManFunc, Abc_ObjFaninNum(pObj), NULL) );
+ else if ( strncmp( (char *)pObj->pData, "Or", 2 ) == 0 )
+ Abc_ObjSetData( pObj, Abc_SopCreateOr((Extra_MmFlex_t *)pNtk->pManFunc, Abc_ObjFaninNum(pObj), NULL) );
+ else if ( strncmp( (char *)pObj->pData, "Nand", 4 ) == 0 )
+ Abc_ObjSetData( pObj, Abc_SopCreateNand((Extra_MmFlex_t *)pNtk->pManFunc, Abc_ObjFaninNum(pObj)) );
+ else if ( strncmp( (char *)pObj->pData, "Nor", 3 ) == 0 )
+ Abc_ObjSetData( pObj, Abc_SopCreateNor((Extra_MmFlex_t *)pNtk->pManFunc, Abc_ObjFaninNum(pObj)) );
+ else if ( strncmp( (char *)pObj->pData, "Exor", 4 ) == 0 )
+ Abc_ObjSetData( pObj, Abc_SopCreateXor((Extra_MmFlex_t *)pNtk->pManFunc, Abc_ObjFaninNum(pObj)) );
+ else if ( strncmp( (char *)pObj->pData, "Exnor", 5 ) == 0 )
+ Abc_ObjSetData( pObj, Abc_SopCreateNxor((Extra_MmFlex_t *)pNtk->pManFunc, Abc_ObjFaninNum(pObj)) );
+ else if ( strncmp( (char *)pObj->pData, "Inv", 3 ) == 0 )
+ Abc_ObjSetData( pObj, Abc_SopCreateInv((Extra_MmFlex_t *)pNtk->pManFunc) );
+ else if ( strncmp( (char *)pObj->pData, "Buf", 3 ) == 0 )
+ Abc_ObjSetData( pObj, Abc_SopCreateBuf((Extra_MmFlex_t *)pNtk->pManFunc) );
else
{
printf( "%s: Unknown gate type \"%s\".\n", Extra_FileReaderGetFileName(p), (char*)pObj->pData );
@@ -233,3 +236,5 @@ Abc_Ntk_t * Io_ReadEdifNetwork( Extra_FileReader_t * p )
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/io/ioReadEqn.c b/src/base/io/ioReadEqn.c
index f778197b..1e4f5d46 100644
--- a/src/base/io/ioReadEqn.c
+++ b/src/base/io/ioReadEqn.c
@@ -20,6 +20,9 @@
#include "ioAbc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -100,13 +103,13 @@ Abc_Ntk_t * Io_ReadEqnNetwork( Extra_FileReader_t * p )
// go through the lines of the file
vVars = Vec_PtrAlloc( 100 );
pProgress = Extra_ProgressBarStart( stdout, Extra_FileReaderGetFileSize(p) );
- for ( iLine = 0; (vTokens = Extra_FileReaderGetTokens(p)); iLine++ )
+ for ( iLine = 0; (vTokens = (Vec_Ptr_t *)Extra_FileReaderGetTokens(p)); iLine++ )
{
Extra_ProgressBarUpdate( pProgress, Extra_FileReaderGetCurPosition(p), NULL );
// check if the first token contains anything
- Io_ReadEqnStrCompact( vTokens->pArray[0] );
- if ( strlen(vTokens->pArray[0]) == 0 )
+ Io_ReadEqnStrCompact( (char *)vTokens->pArray[0] );
+ if ( strlen((char *)vTokens->pArray[0]) == 0 )
break;
// if the number of tokens is different from two, error
@@ -118,16 +121,16 @@ Abc_Ntk_t * Io_ReadEqnNetwork( Extra_FileReader_t * p )
}
// get the type of the line
- if ( strncmp( vTokens->pArray[0], "INORDER", 7 ) == 0 )
+ if ( strncmp( (char *)vTokens->pArray[0], "INORDER", 7 ) == 0 )
{
- Io_ReadEqnStrCutAt( vTokens->pArray[1], " \n\r\t", 0, vVars );
- Vec_PtrForEachEntry( vVars, pVarName, i )
+ Io_ReadEqnStrCutAt( (char *)vTokens->pArray[1], " \n\r\t", 0, vVars );
+ Vec_PtrForEachEntry( char *, vVars, pVarName, i )
Io_ReadCreatePi( pNtk, pVarName );
}
- else if ( strncmp( vTokens->pArray[0], "OUTORDER", 8 ) == 0 )
+ else if ( strncmp( (char *)vTokens->pArray[0], "OUTORDER", 8 ) == 0 )
{
- Io_ReadEqnStrCutAt( vTokens->pArray[1], " \n\r\t", 0, vVars );
- Vec_PtrForEachEntry( vVars, pVarName, i )
+ Io_ReadEqnStrCutAt( (char *)vTokens->pArray[1], " \n\r\t", 0, vVars );
+ Vec_PtrForEachEntry( char *, vVars, pVarName, i )
Io_ReadCreatePo( pNtk, pVarName );
}
else
@@ -135,8 +138,8 @@ Abc_Ntk_t * Io_ReadEqnNetwork( Extra_FileReader_t * p )
extern Hop_Obj_t * Parse_FormulaParserEqn( FILE * pOutput, char * pFormInit, Vec_Ptr_t * vVarNames, Hop_Man_t * pMan );
// get hold of the node name and its formula
- pNodeName = vTokens->pArray[0];
- pFormula = vTokens->pArray[1];
+ pNodeName = (char *)vTokens->pArray[0];
+ pFormula = (char *)vTokens->pArray[1];
// compact the formula
Io_ReadEqnStrCompact( pFormula );
@@ -156,7 +159,7 @@ Abc_Ntk_t * Io_ReadEqnNetwork( Extra_FileReader_t * p )
// create the node
pNode = Io_ReadCreateNode( pNtk, pNodeName, (char **)Vec_PtrArray(vVars), Vec_PtrSize(vVars) );
// derive the function
- pNode->pData = Parse_FormulaParserEqn( stdout, pFormula, vVars, pNtk->pManFunc );
+ pNode->pData = Parse_FormulaParserEqn( stdout, pFormula, vVars, (Hop_Man_t *)pNtk->pManFunc );
// remove the cubes
ABC_FREE( pFormulaCopy );
}
@@ -204,7 +207,7 @@ int Io_ReadEqnStrFind( Vec_Ptr_t * vTokens, char * pName )
{
char * pToken;
int i;
- Vec_PtrForEachEntry( vTokens, pToken, i )
+ Vec_PtrForEachEntry( char *, vTokens, pToken, i )
if ( strcmp( pToken, pName ) == 0 )
return i;
return -1;
@@ -237,3 +240,5 @@ void Io_ReadEqnStrCutAt( char * pStr, char * pStop, int fUniqueOnly, Vec_Ptr_t *
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/io/ioReadPla.c b/src/base/io/ioReadPla.c
index 347d1daa..85029ce8 100644
--- a/src/base/io/ioReadPla.c
+++ b/src/base/io/ioReadPla.c
@@ -20,6 +20,9 @@
#include "ioAbc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -95,12 +98,12 @@ Abc_Ntk_t * Io_ReadPlaNetwork( Extra_FileReader_t * p, int fZeros )
// go through the lines of the file
nCubes = 0;
pProgress = Extra_ProgressBarStart( stdout, Extra_FileReaderGetFileSize(p) );
- for ( iLine = 0; (vTokens = Extra_FileReaderGetTokens(p)); iLine++ )
+ for ( iLine = 0; (vTokens = (Vec_Ptr_t *)Extra_FileReaderGetTokens(p)); iLine++ )
{
Extra_ProgressBarUpdate( pProgress, Extra_FileReaderGetCurPosition(p), NULL );
// if it is the end of file, quit the loop
- if ( strcmp( vTokens->pArray[0], ".e" ) == 0 )
+ if ( strcmp( (char *)vTokens->pArray[0], ".e" ) == 0 )
break;
if ( vTokens->nSize == 1 )
@@ -111,25 +114,25 @@ Abc_Ntk_t * Io_ReadPlaNetwork( Extra_FileReader_t * p, int fZeros )
return NULL;
}
- if ( strcmp( vTokens->pArray[0], ".i" ) == 0 )
- nInputs = atoi(vTokens->pArray[1]);
- else if ( strcmp( vTokens->pArray[0], ".o" ) == 0 )
- nOutputs = atoi(vTokens->pArray[1]);
- else if ( strcmp( vTokens->pArray[0], ".p" ) == 0 )
- nProducts = atoi(vTokens->pArray[1]);
- else if ( strcmp( vTokens->pArray[0], ".ilb" ) == 0 )
+ if ( strcmp( (char *)vTokens->pArray[0], ".i" ) == 0 )
+ nInputs = atoi((char *)vTokens->pArray[1]);
+ else if ( strcmp( (char *)vTokens->pArray[0], ".o" ) == 0 )
+ nOutputs = atoi((char *)vTokens->pArray[1]);
+ else if ( strcmp( (char *)vTokens->pArray[0], ".p" ) == 0 )
+ nProducts = atoi((char *)vTokens->pArray[1]);
+ else if ( strcmp( (char *)vTokens->pArray[0], ".ilb" ) == 0 )
{
if ( vTokens->nSize - 1 != nInputs )
printf( "Warning: Mismatch between the number of PIs on the .i line (%d) and the number of PIs on the .ilb line (%d).\n", nInputs, vTokens->nSize - 1 );
for ( i = 1; i < vTokens->nSize; i++ )
- Io_ReadCreatePi( pNtk, vTokens->pArray[i] );
+ Io_ReadCreatePi( pNtk, (char *)vTokens->pArray[i] );
}
- else if ( strcmp( vTokens->pArray[0], ".ob" ) == 0 )
+ else if ( strcmp( (char *)vTokens->pArray[0], ".ob" ) == 0 )
{
if ( vTokens->nSize - 1 != nOutputs )
printf( "Warning: Mismatch between the number of POs on the .o line (%d) and the number of POs on the .ob line (%d).\n", nOutputs, vTokens->nSize - 1 );
for ( i = 1; i < vTokens->nSize; i++ )
- Io_ReadCreatePo( pNtk, vTokens->pArray[i] );
+ Io_ReadCreatePo( pNtk, (char *)vTokens->pArray[i] );
}
else
{
@@ -189,8 +192,8 @@ Abc_Ntk_t * Io_ReadPlaNetwork( Extra_FileReader_t * p, int fZeros )
Abc_NtkDelete( pNtk );
return NULL;
}
- pCubeIn = vTokens->pArray[0];
- pCubeOut = vTokens->pArray[1];
+ pCubeIn = (char *)vTokens->pArray[0];
+ pCubeOut = (char *)vTokens->pArray[1];
if ( strlen(pCubeIn) != (unsigned)nInputs )
{
printf( "%s (line %d): Input cube length (%zu) differs from the number of inputs (%d).\n",
@@ -211,8 +214,8 @@ Abc_Ntk_t * Io_ReadPlaNetwork( Extra_FileReader_t * p, int fZeros )
{
if ( pCubeOut[i] == '0' )
{
- Vec_StrAppend( ppSops[i], pCubeIn );
- Vec_StrAppend( ppSops[i], " 1\n" );
+ Vec_StrPrintStr( ppSops[i], pCubeIn );
+ Vec_StrPrintStr( ppSops[i], " 1\n" );
}
}
}
@@ -222,8 +225,8 @@ Abc_Ntk_t * Io_ReadPlaNetwork( Extra_FileReader_t * p, int fZeros )
{
if ( pCubeOut[i] == '1' )
{
- Vec_StrAppend( ppSops[i], pCubeIn );
- Vec_StrAppend( ppSops[i], " 1\n" );
+ Vec_StrPrintStr( ppSops[i], pCubeIn );
+ Vec_StrPrintStr( ppSops[i], " 1\n" );
}
}
}
@@ -242,12 +245,12 @@ Abc_Ntk_t * Io_ReadPlaNetwork( Extra_FileReader_t * p, int fZeros )
if ( ppSops[i]->nSize == 0 )
{
Abc_ObjRemoveFanins(pNode);
- pNode->pData = Abc_SopRegister( pNtk->pManFunc, " 0\n" );
+ pNode->pData = Abc_SopRegister( (Extra_MmFlex_t *)pNtk->pManFunc, " 0\n" );
Vec_StrFree( ppSops[i] );
continue;
}
Vec_StrPush( ppSops[i], 0 );
- pNode->pData = Abc_SopRegister( pNtk->pManFunc, ppSops[i]->pArray );
+ pNode->pData = Abc_SopRegister( (Extra_MmFlex_t *)pNtk->pManFunc, ppSops[i]->pArray );
Vec_StrFree( ppSops[i] );
}
ABC_FREE( ppSops );
@@ -262,3 +265,5 @@ Abc_Ntk_t * Io_ReadPlaNetwork( Extra_FileReader_t * p, int fZeros )
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/io/ioReadVerilog.c b/src/base/io/ioReadVerilog.c
index 9847c2da..94147745 100644
--- a/src/base/io/ioReadVerilog.c
+++ b/src/base/io/ioReadVerilog.c
@@ -19,12 +19,16 @@
***********************************************************************/
#include "ioAbc.h"
+#include "ver.h"
+
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
-extern Abc_Lib_t * Ver_ParseFile( char * pFileName, Abc_Lib_t * pGateLib, int fCheck, int fUseMemMan );
+//extern Abc_Lib_t * Ver_ParseFile( char * pFileName, Abc_Lib_t * pGateLib, int fCheck, int fUseMemMan );
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
@@ -54,7 +58,7 @@ Abc_Ntk_t * Io_ReadVerilog( char * pFileName, int fCheck )
// detect top-level model
RetValue = Abc_LibFindTopLevelModels( pDesign );
- pNtk = Vec_PtrEntry( pDesign->vTops, 0 );
+ pNtk = (Abc_Ntk_t *)Vec_PtrEntry( pDesign->vTops, 0 );
if ( RetValue > 1 )
printf( "Warning: The design has %d root-level modules. The first one (%s) will be used.\n",
Vec_PtrSize(pDesign->vTops), pNtk->pName );
@@ -88,3 +92,5 @@ Abc_Ntk_t * Io_ReadVerilog( char * pFileName, int fCheck )
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/io/ioUtil.c b/src/base/io/ioUtil.c
index c00c3008..a4dbf949 100644
--- a/src/base/io/ioUtil.c
+++ b/src/base/io/ioUtil.c
@@ -19,6 +19,10 @@
***********************************************************************/
#include "ioAbc.h"
+#include "main.h"
+
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -73,6 +77,8 @@ Io_FileType_t Io_ReadFileType( char * pFileName )
return IO_FILE_BLIFMV;
if ( !strcmp( pExt, "pla" ) )
return IO_FILE_PLA;
+ if ( !strcmp( pExt, "smv" ) )
+ return IO_FILE_SMV;
if ( !strcmp( pExt, "v" ) )
return IO_FILE_VERILOG;
return IO_FILE_UNKNOWN;
@@ -156,7 +162,56 @@ Abc_Ntk_t * Io_ReadNetlist( char * pFileName, Io_FileType_t FileType, int fCheck
return pNtk;
}
-
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Ptr_t *temporaryLtlStore( Abc_Ntk_t *pNtk )
+{
+ Vec_Ptr_t *tempStore;
+ char *pFormula;
+ int i;
+
+ if( pNtk && Vec_PtrSize( pNtk->vLtlProperties ) > 0 )
+ {
+ tempStore = Vec_PtrAlloc( Vec_PtrSize( pNtk->vLtlProperties ) );
+ Vec_PtrForEachEntry( char *, pNtk->vLtlProperties, pFormula, i )
+ Vec_PtrPush( tempStore, pFormula );
+ assert( Vec_PtrSize( tempStore ) == Vec_PtrSize( pNtk->vLtlProperties ) );
+ return tempStore;
+ }
+ else
+ return NULL;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void updateLtlStoreOfNtk( Abc_Ntk_t *pNtk, Vec_Ptr_t *tempLtlStore )
+{
+ int i;
+ char *pFormula;
+
+ assert( tempLtlStore != NULL );
+ Vec_PtrForEachEntry( char *, tempLtlStore, pFormula, i )
+ Vec_PtrPush( pNtk->vLtlProperties, pFormula );
+}
+
/**Function*************************************************************
Synopsis [Read the network from a file.]
@@ -171,8 +226,10 @@ Abc_Ntk_t * Io_ReadNetlist( char * pFileName, Io_FileType_t FileType, int fCheck
Abc_Ntk_t * Io_Read( char * pFileName, Io_FileType_t FileType, int fCheck )
{
Abc_Ntk_t * pNtk, * pTemp;
+ Vec_Ptr_t * vLtl;
// get the netlist
pNtk = Io_ReadNetlist( pFileName, FileType, fCheck );
+ vLtl = temporaryLtlStore( pNtk );
if ( pNtk == NULL )
return NULL;
if ( !Abc_NtkIsNetlist(pNtk) )
@@ -217,6 +274,8 @@ Abc_Ntk_t * Io_Read( char * pFileName, Io_FileType_t FileType, int fCheck )
}
// convert the netlist into the logic network
pNtk = Abc_NtkToLogic( pTemp = pNtk );
+ if( vLtl )
+ updateLtlStoreOfNtk( pNtk, vLtl );
Abc_NtkDelete( pTemp );
if ( pNtk == NULL )
{
@@ -331,6 +390,15 @@ void Io_Write( Abc_Ntk_t * pNtk, char * pFileName, Io_FileType_t FileType )
}
pNtkTemp = Abc_NtkToNetlistBench( pNtk );
}
+ else if ( FileType == IO_FILE_SMV )
+ {
+ if ( !Abc_NtkIsStrash(pNtk) )
+ {
+ fprintf( stdout, "Writing traditional SMV is available for AIGs only.\n" );
+ return;
+ }
+ pNtkTemp = Abc_NtkToNetlistBench( pNtk );
+ }
else
pNtkTemp = Abc_NtkToNetlist( pNtk );
@@ -344,7 +412,7 @@ void Io_Write( Abc_Ntk_t * pNtk, char * pFileName, Io_FileType_t FileType )
{
if ( !Abc_NtkHasSop(pNtkTemp) && !Abc_NtkHasMapping(pNtkTemp) )
Abc_NtkToSop( pNtkTemp, 0 );
- Io_WriteBlif( pNtkTemp, pFileName, 1 );
+ Io_WriteBlif( pNtkTemp, pFileName, 1, 0, 0 );
}
else if ( FileType == IO_FILE_BLIFMV )
{
@@ -364,6 +432,8 @@ void Io_Write( Abc_Ntk_t * pNtk, char * pFileName, Io_FileType_t FileType )
Abc_NtkToAig( pNtkTemp );
Io_WriteEqn( pNtkTemp, pFileName );
}
+ else if ( FileType == IO_FILE_SMV )
+ Io_WriteSmv( pNtkTemp, pFileName );
else if ( FileType == IO_FILE_VERILOG )
{
if ( !Abc_NtkHasAig(pNtkTemp) && !Abc_NtkHasMapping(pNtkTemp) )
@@ -459,7 +529,7 @@ void Io_WriteHie( Abc_Ntk_t * pNtk, char * pBaseName, char * pFileName )
{
if ( !Abc_NtkHasSop(pNtkResult) && !Abc_NtkHasMapping(pNtkResult) )
Abc_NtkToSop( pNtkResult, 0 );
- Io_WriteBlif( pNtkResult, pFileName, 1 );
+ Io_WriteBlif( pNtkResult, pFileName, 1, 0, 0 );
}
else if ( Io_ReadFileType(pFileName) == IO_FILE_VERILOG )
{
@@ -611,7 +681,7 @@ Abc_Obj_t * Io_ReadCreateResetLatch( Abc_Ntk_t * pNtk, int fBlifMv )
Abc_LatchSetInit0( pLatch );
// feed the latch with constant1- node
// pNode = Abc_NtkCreateNode( pNtk );
-// pNode->pData = Abc_SopRegister( pNtk->pManFunc, "2\n1\n" );
+// pNode->pData = Abc_SopRegister( (Extra_MmFlex_t *)pNtk->pManFunc, "2\n1\n" );
pNode = Abc_NtkCreateNodeConst1( pNtk );
Abc_ObjAddFanin( Abc_ObjFanin0(Abc_ObjFanin0(pLatch)), pNode );
return pLatch;
@@ -657,7 +727,7 @@ Abc_Obj_t * Io_ReadCreateNode( Abc_Ntk_t * pNtk, char * pNameOut, char * pNamesI
SeeAlso []
***********************************************************************/
-Abc_Obj_t * Io_ReadCreateConst( Abc_Ntk_t * pNtk, char * pName, bool fConst1 )
+Abc_Obj_t * Io_ReadCreateConst( Abc_Ntk_t * pNtk, char * pName, int fConst1 )
{
Abc_Obj_t * pNet, * pTerm;
pTerm = fConst1? Abc_NtkCreateNodeConst1(pNtk) : Abc_NtkCreateNodeConst0(pNtk);
@@ -725,7 +795,6 @@ Abc_Obj_t * Io_ReadCreateBuf( Abc_Ntk_t * pNtk, char * pNameIn, char * pNameOut
FILE * Io_FileOpen( const char * FileName, const char * PathVar, const char * Mode, int fVerbose )
{
char * t = 0, * c = 0, * i;
- extern char * Abc_FrameReadFlag( char * pFlag );
if ( PathVar == 0 )
{
@@ -768,3 +837,5 @@ FILE * Io_FileOpen( const char * FileName, const char * PathVar, const char * Mo
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/io/ioWriteAiger.c b/src/base/io/ioWriteAiger.c
index 54db0641..3900cf26 100644
--- a/src/base/io/ioWriteAiger.c
+++ b/src/base/io/ioWriteAiger.c
@@ -21,12 +21,16 @@
// The code in this file is developed in collaboration with Mark Jarvin of Toronto.
+#include "bzlib.h"
#include "ioAbc.h"
#include <stdarg.h>
-#include "bzlib.h"
#include "zlib.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
#ifdef _WIN32
#define vsnprintf _vsnprintf
#endif
@@ -137,7 +141,7 @@ Binary Format Definition
static unsigned Io_ObjMakeLit( int Var, int fCompl ) { return (Var << 1) | fCompl; }
static unsigned Io_ObjAigerNum( Abc_Obj_t * pObj ) { return (unsigned)(ABC_PTRINT_T)pObj->pCopy; }
-static void Io_ObjSetAigerNum( Abc_Obj_t * pObj, unsigned Num ) { pObj->pCopy = (void *)(ABC_PTRINT_T)Num; }
+static void Io_ObjSetAigerNum( Abc_Obj_t * pObj, unsigned Num ) { pObj->pCopy = (Abc_Obj_t *)(ABC_PTRINT_T)Num; }
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
@@ -451,7 +455,7 @@ void Io_WriteAigerGz( Abc_Ntk_t * pNtk, char * pFileName, int fWriteSymbols )
// write the nodes into the buffer
Pos = 0;
nBufferSize = 6 * Abc_NtkNodeNum(pNtk) + 100; // skeptically assuming 3 chars per one AIG edge
- pBuffer = ABC_ALLOC( char, nBufferSize );
+ pBuffer = ABC_ALLOC( unsigned char, nBufferSize );
pProgress = Extra_ProgressBarStart( stdout, Abc_NtkObjNumMax(pNtk) );
Abc_AigForEachAnd( pNtk, pObj, i )
{
@@ -751,3 +755,5 @@ void Io_WriteAiger( Abc_Ntk_t * pNtk, char * pFileName, int fWriteSymbols, int f
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/io/ioWriteBaf.c b/src/base/io/ioWriteBaf.c
index 1154e218..a65115b3 100644
--- a/src/base/io/ioWriteBaf.c
+++ b/src/base/io/ioWriteBaf.c
@@ -20,6 +20,9 @@
#include "ioAbc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -126,9 +129,9 @@ void Io_WriteBaf( Abc_Ntk_t * pNtk, char * pFileName )
Abc_NtkCleanCopy( pNtk );
nNodes = 1;
Abc_NtkForEachCi( pNtk, pObj, i )
- pObj->pCopy = (void *)(ABC_PTRINT_T)nNodes++;
+ pObj->pCopy = (Abc_Obj_t *)(ABC_PTRINT_T)nNodes++;
Abc_AigForEachAnd( pNtk, pObj, i )
- pObj->pCopy = (void *)(ABC_PTRINT_T)nNodes++;
+ pObj->pCopy = (Abc_Obj_t *)(ABC_PTRINT_T)nNodes++;
// write the nodes into the buffer
nAnds = 0;
@@ -138,15 +141,15 @@ void Io_WriteBaf( Abc_Ntk_t * pNtk, char * pFileName )
Abc_AigForEachAnd( pNtk, pObj, i )
{
Extra_ProgressBarUpdate( pProgress, nAnds, NULL );
- pBufferNode[nAnds++] = (((int)(ABC_PTRINT_T)Abc_ObjFanin0(pObj)->pCopy) << 1) | Abc_ObjFaninC0(pObj);
- pBufferNode[nAnds++] = (((int)(ABC_PTRINT_T)Abc_ObjFanin1(pObj)->pCopy) << 1) | Abc_ObjFaninC1(pObj);
+ pBufferNode[nAnds++] = (((int)(ABC_PTRINT_T)Abc_ObjFanin0(pObj)->pCopy) << 1) | (int)Abc_ObjFaninC0(pObj);
+ pBufferNode[nAnds++] = (((int)(ABC_PTRINT_T)Abc_ObjFanin1(pObj)->pCopy) << 1) | (int)Abc_ObjFaninC1(pObj);
}
// write the COs into the buffer
Abc_NtkForEachCo( pNtk, pObj, i )
{
Extra_ProgressBarUpdate( pProgress, nAnds, NULL );
- pBufferNode[nAnds] = (((int)(ABC_PTRINT_T)Abc_ObjFanin0(pObj)->pCopy) << 1) | Abc_ObjFaninC0(pObj);
+ pBufferNode[nAnds] = (((int)(ABC_PTRINT_T)Abc_ObjFanin0(pObj)->pCopy) << 1) | (int)Abc_ObjFaninC0(pObj);
if ( Abc_ObjFanoutNum(pObj) > 0 && Abc_ObjIsLatch(Abc_ObjFanout0(pObj)) )
pBufferNode[nAnds] = (pBufferNode[nAnds] << 2) | ((int)(ABC_PTRINT_T)Abc_ObjData(Abc_ObjFanout0(pObj)) & 3);
nAnds++;
@@ -166,3 +169,5 @@ void Io_WriteBaf( Abc_Ntk_t * pNtk, char * pFileName )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/io/ioWriteBblif.c b/src/base/io/ioWriteBblif.c
index e5bd6503..5cace190 100644
--- a/src/base/io/ioWriteBblif.c
+++ b/src/base/io/ioWriteBblif.c
@@ -21,6 +21,9 @@
#include "ioAbc.h"
#include "bblif.h"
+ABC_NAMESPACE_IMPL_START
+
+
// For description of Binary BLIF format, refer to "abc/src/aig/bbl/bblif.h"
////////////////////////////////////////////////////////////////////////
@@ -63,13 +66,13 @@ Bbl_Man_t * Bbl_ManFromAbc( Abc_Ntk_t * pNtk )
Abc_NtkForEachCi( pNtk, pObj, i )
Bbl_ManCreateObject( p, BBL_OBJ_CI, Abc_ObjId(pObj), 0, NULL );
// create internal nodes
- Vec_PtrForEachEntry( vNodes, pObj, i )
- Bbl_ManCreateObject( p, BBL_OBJ_NODE, Abc_ObjId(pObj), Abc_ObjFaninNum(pObj), pObj->pData );
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
+ Bbl_ManCreateObject( p, BBL_OBJ_NODE, Abc_ObjId(pObj), Abc_ObjFaninNum(pObj), (char *)pObj->pData );
// create combinational outputs
Abc_NtkForEachCo( pNtk, pObj, i )
Bbl_ManCreateObject( p, BBL_OBJ_CO, Abc_ObjId(pObj), 1, NULL );
// create fanin/fanout connections for internal nodes
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
Abc_ObjForEachFanin( pObj, pFanin, k )
Bbl_ManAddFanin( p, Abc_ObjId(pObj), Abc_ObjId(pFanin) );
// create fanin/fanout connections for combinational outputs
@@ -109,3 +112,5 @@ void Io_WriteBblif( Abc_Ntk_t * pNtk, char * pFileName )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/io/ioWriteBench.c b/src/base/io/ioWriteBench.c
index 147976da..4ca1ac0a 100644
--- a/src/base/io/ioWriteBench.c
+++ b/src/base/io/ioWriteBench.c
@@ -20,6 +20,9 @@
#include "ioAbc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -47,7 +50,7 @@ static int Io_WriteBenchLutOneNode( FILE * pFile, Abc_Obj_t * pNode, Vec_Int_t *
SeeAlso []
***********************************************************************/
-int Io_WriteBench( Abc_Ntk_t * pNtk, char * pFileName )
+int Io_WriteBench( Abc_Ntk_t * pNtk, const char * pFileName )
{
Abc_Ntk_t * pExdc;
FILE * pFile;
@@ -258,8 +261,8 @@ int Io_WriteBenchLutOneNode( FILE * pFile, Abc_Obj_t * pNode, Vec_Int_t * vTruth
nFanins = Abc_ObjFaninNum(pNode);
assert( nFanins <= 8 );
// compute the truth table
- pTruth = Hop_ManConvertAigToTruth( pNode->pNtk->pManFunc, Hop_Regular(pNode->pData), nFanins, vTruth, 0 );
- if ( Hop_IsComplement(pNode->pData) )
+ pTruth = Hop_ManConvertAigToTruth( (Hop_Man_t *)pNode->pNtk->pManFunc, Hop_Regular((Hop_Obj_t *)pNode->pData), nFanins, vTruth, 0 );
+ if ( Hop_IsComplement((Hop_Obj_t *)pNode->pData) )
Extra_TruthNot( pTruth, pTruth, nFanins );
// consider simple cases
if ( Extra_TruthIsConst0(pTruth, nFanins) )
@@ -333,3 +336,5 @@ int Io_WriteBenchCheckNames( Abc_Ntk_t * pNtk )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/io/ioWriteBlif.c b/src/base/io/ioWriteBlif.c
index d1adaf90..7233161b 100644
--- a/src/base/io/ioWriteBlif.c
+++ b/src/base/io/ioWriteBlif.c
@@ -22,12 +22,15 @@
#include "main.h"
#include "mio.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
-static void Io_NtkWrite( FILE * pFile, Abc_Ntk_t * pNtk, int fWriteLatches );
-static void Io_NtkWriteOne( FILE * pFile, Abc_Ntk_t * pNtk, int fWriteLatches );
+static void Io_NtkWrite( FILE * pFile, Abc_Ntk_t * pNtk, int fWriteLatches, int fBb2Wb, int fSeq );
+static void Io_NtkWriteOne( FILE * pFile, Abc_Ntk_t * pNtk, int fWriteLatches, int fBb2Wb, int fSeq );
static void Io_NtkWritePis( FILE * pFile, Abc_Ntk_t * pNtk, int fWriteLatches );
static void Io_NtkWritePos( FILE * pFile, Abc_Ntk_t * pNtk, int fWriteLatches );
static void Io_NtkWriteSubckt( FILE * pFile, Abc_Obj_t * pNode );
@@ -62,7 +65,7 @@ void Io_WriteBlifLogic( Abc_Ntk_t * pNtk, char * FileName, int fWriteLatches )
fprintf( stdout, "Writing BLIF has failed.\n" );
return;
}
- Io_WriteBlif( pNtkTemp, FileName, fWriteLatches );
+ Io_WriteBlif( pNtkTemp, FileName, fWriteLatches, 0, 0 );
Abc_NtkDelete( pNtkTemp );
}
@@ -77,7 +80,7 @@ void Io_WriteBlifLogic( Abc_Ntk_t * pNtk, char * FileName, int fWriteLatches )
SeeAlso []
***********************************************************************/
-void Io_WriteBlif( Abc_Ntk_t * pNtk, char * FileName, int fWriteLatches )
+void Io_WriteBlif( Abc_Ntk_t * pNtk, char * FileName, int fWriteLatches, int fBb2Wb, int fSeq )
{
FILE * pFile;
Abc_Ntk_t * pNtkTemp;
@@ -92,18 +95,18 @@ void Io_WriteBlif( Abc_Ntk_t * pNtk, char * FileName, int fWriteLatches )
}
fprintf( pFile, "# Benchmark \"%s\" written by ABC on %s\n", pNtk->pName, Extra_TimeStamp() );
// write the master network
- Io_NtkWrite( pFile, pNtk, fWriteLatches );
+ Io_NtkWrite( pFile, pNtk, fWriteLatches, fBb2Wb, fSeq );
// make sure there is no logic hierarchy
assert( Abc_NtkWhiteboxNum(pNtk) == 0 );
// write the hierarchy if present
if ( Abc_NtkBlackboxNum(pNtk) > 0 )
{
- Vec_PtrForEachEntry( pNtk->pDesign->vModules, pNtkTemp, i )
+ Vec_PtrForEachEntry( Abc_Ntk_t *, pNtk->pDesign->vModules, pNtkTemp, i )
{
if ( pNtkTemp == pNtk )
continue;
fprintf( pFile, "\n\n" );
- Io_NtkWrite( pFile, pNtkTemp, fWriteLatches );
+ Io_NtkWrite( pFile, pNtkTemp, fWriteLatches, fBb2Wb, fSeq );
}
}
fclose( pFile );
@@ -120,21 +123,21 @@ void Io_WriteBlif( Abc_Ntk_t * pNtk, char * FileName, int fWriteLatches )
SeeAlso []
***********************************************************************/
-void Io_NtkWrite( FILE * pFile, Abc_Ntk_t * pNtk, int fWriteLatches )
+void Io_NtkWrite( FILE * pFile, Abc_Ntk_t * pNtk, int fWriteLatches, int fBb2Wb, int fSeq )
{
Abc_Ntk_t * pExdc;
assert( Abc_NtkIsNetlist(pNtk) );
// write the model name
fprintf( pFile, ".model %s\n", Abc_NtkName(pNtk) );
// write the network
- Io_NtkWriteOne( pFile, pNtk, fWriteLatches );
+ Io_NtkWriteOne( pFile, pNtk, fWriteLatches, fBb2Wb, fSeq );
// write EXDC network if it exists
pExdc = Abc_NtkExdc( pNtk );
if ( pExdc )
{
fprintf( pFile, "\n" );
fprintf( pFile, ".exdc\n" );
- Io_NtkWriteOne( pFile, pExdc, fWriteLatches );
+ Io_NtkWriteOne( pFile, pExdc, fWriteLatches, fBb2Wb, fSeq );
}
// finalize the file
fprintf( pFile, ".end\n" );
@@ -148,10 +151,51 @@ void Io_NtkWrite( FILE * pFile, Abc_Ntk_t * pNtk, int fWriteLatches )
SideEffects []
+ SeeAlso []
+
+***********************************************************************/
+void Io_NtkWriteConvertedBox( FILE * pFile, Abc_Ntk_t * pNtk, int fSeq )
+{
+ Abc_Obj_t * pObj;
+ int i, v;
+ if ( fSeq )
+ {
+ fprintf( pFile, ".attrib white box seq\n" );
+ }
+ else
+ {
+ fprintf( pFile, ".attrib white box comb\n" );
+ fprintf( pFile, ".delay 1\n" );
+ }
+ Abc_NtkForEachPo( pNtk, pObj, i )
+ {
+ // write the .names line
+ fprintf( pFile, ".names" );
+ Io_NtkWritePis( pFile, pNtk, 1 );
+ if ( fSeq )
+ fprintf( pFile, " %s_in\n", Abc_ObjName(Abc_ObjFanin0(pObj)) );
+ else
+ fprintf( pFile, " %s\n", Abc_ObjName(Abc_ObjFanin0(pObj)) );
+ for ( v = 0; v < Abc_NtkPiNum(pNtk); v++ )
+ fprintf( pFile, "1" );
+ fprintf( pFile, " 1\n" );
+ if ( fSeq )
+ fprintf( pFile, ".latch %s_in %s 1\n", Abc_ObjName(Abc_ObjFanin0(pObj)), Abc_ObjName(Abc_ObjFanin0(pObj)) );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Write one network.]
+
+ Description []
+
+ SideEffects []
+
SeeAlso []
***********************************************************************/
-void Io_NtkWriteOne( FILE * pFile, Abc_Ntk_t * pNtk, int fWriteLatches )
+void Io_NtkWriteOne( FILE * pFile, Abc_Ntk_t * pNtk, int fWriteLatches, int fBb2Wb, int fSeq )
{
ProgressBar * pProgress;
Abc_Obj_t * pNode, * pLatch;
@@ -167,18 +211,13 @@ void Io_NtkWriteOne( FILE * pFile, Abc_Ntk_t * pNtk, int fWriteLatches )
Io_NtkWritePos( pFile, pNtk, fWriteLatches );
fprintf( pFile, "\n" );
- // write the assertions
- if ( Abc_NtkAssertNum(pNtk) )
- {
- fprintf( pFile, ".asserts" );
- Io_NtkWriteAsserts( pFile, pNtk );
- fprintf( pFile, "\n" );
- }
-
// write the blackbox
if ( Abc_NtkHasBlackbox( pNtk ) )
{
- fprintf( pFile, ".blackbox\n" );
+ if ( fBb2Wb )
+ Io_NtkWriteConvertedBox( pFile, pNtk, fSeq );
+ else
+ fprintf( pFile, ".blackbox\n" );
return;
}
@@ -205,7 +244,7 @@ void Io_NtkWriteOne( FILE * pFile, Abc_Ntk_t * pNtk, int fWriteLatches )
}
// write each internal node
- Length = Abc_NtkHasMapping(pNtk)? Mio_LibraryReadGateNameMax(pNtk->pManFunc) : 0;
+ Length = Abc_NtkHasMapping(pNtk)? Mio_LibraryReadGateNameMax((Mio_Library_t *)pNtk->pManFunc) : 0;
pProgress = Extra_ProgressBarStart( stdout, Abc_NtkObjNumMax(pNtk) );
Abc_NtkForEachNode( pNtk, pNode, i )
{
@@ -344,46 +383,6 @@ void Io_NtkWritePos( FILE * pFile, Abc_Ntk_t * pNtk, int fWriteLatches )
/**Function*************************************************************
- Synopsis [Writes the assertion list.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Io_NtkWriteAsserts( FILE * pFile, Abc_Ntk_t * pNtk )
-{
- Abc_Obj_t * pTerm, * pNet;
- int LineLength;
- int AddedLength;
- int NameCounter;
- int i;
-
- LineLength = 8;
- NameCounter = 0;
-
- Abc_NtkForEachAssert( pNtk, pTerm, i )
- {
- pNet = Abc_ObjFanin0(pTerm);
- // get the line length after this name is written
- AddedLength = strlen(Abc_ObjName(pNet)) + 1;
- if ( NameCounter && LineLength + AddedLength + 3 > IO_WRITE_LINE_LENGTH )
- { // write the line extender
- fprintf( pFile, " \\\n" );
- // reset the line length
- LineLength = 0;
- NameCounter = 0;
- }
- fprintf( pFile, " %s", Abc_ObjName(pNet) );
- LineLength += AddedLength;
- NameCounter++;
- }
-}
-
-/**Function*************************************************************
-
Synopsis [Write the latch into a file.]
Description []
@@ -395,7 +394,7 @@ void Io_NtkWriteAsserts( FILE * pFile, Abc_Ntk_t * pNtk )
***********************************************************************/
void Io_NtkWriteSubckt( FILE * pFile, Abc_Obj_t * pNode )
{
- Abc_Ntk_t * pModel = pNode->pData;
+ Abc_Ntk_t * pModel = (Abc_Ntk_t *)pNode->pData;
Abc_Obj_t * pTerm;
int i;
// write the subcircuit
@@ -487,7 +486,7 @@ void Io_NtkWriteNode( FILE * pFile, Abc_Obj_t * pNode, int Length )
***********************************************************************/
void Io_NtkWriteNodeGate( FILE * pFile, Abc_Obj_t * pNode, int Length )
{
- Mio_Gate_t * pGate = pNode->pData;
+ Mio_Gate_t * pGate = (Mio_Gate_t *)pNode->pData;
Mio_Pin_t * pGatePin;
int i;
// write the node
@@ -585,8 +584,52 @@ void Io_WriteTimingInfo( FILE * pFile, Abc_Ntk_t * pNtk )
}
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Abc_NtkConvertBb2Wb( char * pFileNameIn, char * pFileNameOut, int fSeq, int fVerbose )
+{
+ FILE * pFile;
+ Abc_Ntk_t * pNetlist;
+ // check the files
+ pFile = fopen( pFileNameIn, "rb" );
+ if ( pFile == NULL )
+ {
+ printf( "Input file \"%s\" cannot be opened.\n", pFileNameIn );
+ return;
+ }
+ fclose( pFile );
+ // check the files
+ pFile = fopen( pFileNameOut, "wb" );
+ if ( pFile == NULL )
+ {
+ printf( "Output file \"%s\" cannot be opened.\n", pFileNameOut );
+ return;
+ }
+ fclose( pFile );
+ // derive AIG for signal correspondence
+ pNetlist = Io_ReadNetlist( pFileNameIn, Io_ReadFileType(pFileNameIn), 1 );
+ if ( pNetlist == NULL )
+ {
+ printf( "Reading input file \"%s\" has failed.\n", pFileNameIn );
+ return;
+ }
+ Io_WriteBlif( pNetlist, pFileNameOut, 1, 1, fSeq );
+ Abc_NtkDelete( pNetlist );
+}
+
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/io/ioWriteBlifMv.c b/src/base/io/ioWriteBlifMv.c
index e1494475..62028606 100644
--- a/src/base/io/ioWriteBlifMv.c
+++ b/src/base/io/ioWriteBlifMv.c
@@ -22,6 +22,9 @@
#include "main.h"
#include "mio.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -72,7 +75,7 @@ void Io_WriteBlifMv( Abc_Ntk_t * pNtk, char * FileName )
// write the remaining networks
if ( pNtk->pDesign )
{
- Vec_PtrForEachEntry( pNtk->pDesign->vModules, pNtkTemp, i )
+ Vec_PtrForEachEntry( Abc_Ntk_t *, pNtk->pDesign->vModules, pNtkTemp, i )
{
if ( pNtkTemp == pNtk )
continue;
@@ -135,14 +138,6 @@ void Io_NtkWriteBlifMvOne( FILE * pFile, Abc_Ntk_t * pNtk )
Io_NtkWriteBlifMvPos( pFile, pNtk );
fprintf( pFile, "\n" );
- // write the assertions
- if ( Abc_NtkAssertNum(pNtk) )
- {
- fprintf( pFile, ".asserts" );
- Io_NtkWriteBlifMvAsserts( pFile, pNtk );
- fprintf( pFile, "\n" );
- }
-
// write the MV directives
fprintf( pFile, "\n" );
Abc_NtkForEachCi( pNtk, pTerm, i )
@@ -286,46 +281,6 @@ void Io_NtkWriteBlifMvPos( FILE * pFile, Abc_Ntk_t * pNtk )
/**Function*************************************************************
- Synopsis [Writes the assertion list.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Io_NtkWriteBlifMvAsserts( FILE * pFile, Abc_Ntk_t * pNtk )
-{
- Abc_Obj_t * pTerm, * pNet;
- int LineLength;
- int AddedLength;
- int NameCounter;
- int i;
-
- LineLength = 8;
- NameCounter = 0;
-
- Abc_NtkForEachAssert( pNtk, pTerm, i )
- {
- pNet = Abc_ObjFanin0(pTerm);
- // get the line length after this name is written
- AddedLength = strlen(Abc_ObjName(pNet)) + 1;
- if ( NameCounter && LineLength + AddedLength + 3 > IO_WRITE_LINE_LENGTH )
- { // write the line extender
- fprintf( pFile, " \\\n" );
- // reset the line length
- LineLength = 0;
- NameCounter = 0;
- }
- fprintf( pFile, " %s", Abc_ObjName(pNet) );
- LineLength += AddedLength;
- NameCounter++;
- }
-}
-
-/**Function*************************************************************
-
Synopsis [Write the latch into a file.]
Description []
@@ -365,7 +320,7 @@ void Io_NtkWriteBlifMvLatch( FILE * pFile, Abc_Obj_t * pLatch )
***********************************************************************/
void Io_NtkWriteBlifMvSubckt( FILE * pFile, Abc_Obj_t * pNode )
{
- Abc_Ntk_t * pModel = pNode->pData;
+ Abc_Ntk_t * pModel = (Abc_Ntk_t *)pNode->pData;
Abc_Obj_t * pTerm;
int i;
// write the MV directives
@@ -436,7 +391,7 @@ void Io_NtkWriteBlifMvNode( FILE * pFile, Abc_Obj_t * pNode )
fprintf( pFile, "\n" );
// write the cubes
- pCur = Abc_ObjData(pNode);
+ pCur = (char *)Abc_ObjData(pNode);
if ( *pCur == 'd' )
{
fprintf( pFile, ".default " );
@@ -517,3 +472,5 @@ void Io_NtkWriteBlifMvNodeFanins( FILE * pFile, Abc_Obj_t * pNode )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/io/ioWriteBook.c b/src/base/io/ioWriteBook.c
index 322c3ef4..9d0df473 100644
--- a/src/base/io/ioWriteBook.c
+++ b/src/base/io/ioWriteBook.c
@@ -21,6 +21,9 @@
#include "ioAbc.h"
#include "main.h"
#include "mio.h"
+
+ABC_NAMESPACE_IMPL_START
+
#define NODES 0
#define PL 1
#define coreHeight 1
@@ -33,8 +36,8 @@
static unsigned Io_NtkWriteNodes( FILE * pFile, Abc_Ntk_t * pNtk );
static void Io_NtkWritePiPoNodes( FILE * pFile, Abc_Ntk_t * pNtk );
-static void Io_NtkWriteLatchNode( FILE * pFile, Abc_Obj_t * pLatch, bool NodesOrPl );
-static unsigned Io_NtkWriteIntNode( FILE * pFile, Abc_Obj_t * pNode, bool NodesOrPl );
+static void Io_NtkWriteLatchNode( FILE * pFile, Abc_Obj_t * pLatch, int NodesOrPl );
+static unsigned Io_NtkWriteIntNode( FILE * pFile, Abc_Obj_t * pNode, int NodesOrPl );
static unsigned Io_NtkWriteNodeGate( FILE * pFile, Abc_Obj_t * pNode );
static void Io_NtkWriteNets( FILE * pFile, Abc_Ntk_t * pNtk );
static void Io_NtkWriteIntNet( FILE * pFile, Abc_Obj_t * pNode );
@@ -42,13 +45,13 @@ static void Io_NtkBuildLayout( FILE * pFile1, FILE *pFile2, Abc_Ntk_t * pNtk, do
static void Io_NtkWriteScl( FILE * pFile, unsigned numCoreRows, double layoutWidth );
static void Io_NtkWritePl( FILE * pFile, Abc_Ntk_t * pNtk, unsigned numTerms, double layoutHeight, double layoutWidth );
static Vec_Ptr_t * Io_NtkOrderingPads( Abc_Ntk_t * pNtk, Vec_Ptr_t * vTerms );
-static Abc_Obj_t * Io_NtkBfsPads( Abc_Ntk_t * pNtk, Abc_Obj_t * pCurrEntry, unsigned numTerms, bool * pOrdered );
-static bool Abc_NodeIsNand2( Abc_Obj_t * pNode );
-static bool Abc_NodeIsNor2( Abc_Obj_t * pNode );
-static bool Abc_NodeIsAnd2( Abc_Obj_t * pNode );
-static bool Abc_NodeIsOr2( Abc_Obj_t * pNode );
-static bool Abc_NodeIsXor2( Abc_Obj_t * pNode );
-static bool Abc_NodeIsXnor2( Abc_Obj_t * pNode );
+static Abc_Obj_t * Io_NtkBfsPads( Abc_Ntk_t * pNtk, Abc_Obj_t * pCurrEntry, unsigned numTerms, int * pOrdered );
+static int Abc_NodeIsNand2( Abc_Obj_t * pNode );
+static int Abc_NodeIsNor2( Abc_Obj_t * pNode );
+static int Abc_NodeIsAnd2( Abc_Obj_t * pNode );
+static int Abc_NodeIsOr2( Abc_Obj_t * pNode );
+static int Abc_NodeIsXor2( Abc_Obj_t * pNode );
+static int Abc_NodeIsXnor2( Abc_Obj_t * pNode );
static inline double Abc_Rint( double x ) { return (double)(int)x; }
@@ -139,7 +142,7 @@ void Io_WriteBook( Abc_Ntk_t * pNtk, char * FileName )
// write the hierarchy if present
if ( Abc_NtkBlackboxNum(pNtk) > 0 )
{
- Vec_PtrForEachEntry( pNtk->pDesign->vModules, pNtkTemp, i )
+ Vec_PtrForEachEntry( Abc_Ntk_t *, pNtk->pDesign->vModules, pNtkTemp, i )
{
if ( pNtkTemp == pNtk )
continue;
@@ -255,7 +258,7 @@ void Io_NtkWritePiPoNodes( FILE * pFile, Abc_Ntk_t * pNtk )
SeeAlso []
***********************************************************************/
-void Io_NtkWriteLatchNode( FILE * pFile, Abc_Obj_t * pLatch, bool NodesOrPl )
+void Io_NtkWriteLatchNode( FILE * pFile, Abc_Obj_t * pLatch, int NodesOrPl )
{
Abc_Obj_t * pNetLi, * pNetLo;
@@ -278,7 +281,7 @@ void Io_NtkWriteLatchNode( FILE * pFile, Abc_Obj_t * pLatch, bool NodesOrPl )
SeeAlso []
***********************************************************************/
-unsigned Io_NtkWriteIntNode( FILE * pFile, Abc_Obj_t * pNode, bool NodesOrPl )
+unsigned Io_NtkWriteIntNode( FILE * pFile, Abc_Obj_t * pNode, int NodesOrPl )
{
unsigned sizex=0, sizey=coreHeight, isize=0;
//double nx, ny, xstep, ystep;
@@ -317,7 +320,7 @@ unsigned Io_NtkWriteIntNode( FILE * pFile, Abc_Obj_t * pNode, bool NodesOrPl )
else
{
assert( isize > 2 );
- sizex=isize+Abc_SopGetCubeNum(pNode->pData);
+ sizex=isize+Abc_SopGetCubeNum((char *)pNode->pData);
}
}
}
@@ -370,7 +373,7 @@ unsigned Io_NtkWriteIntNode( FILE * pFile, Abc_Obj_t * pNode, bool NodesOrPl )
***********************************************************************/
unsigned Io_NtkWriteNodeGate( FILE * pFile, Abc_Obj_t * pNode )
{
- Mio_Gate_t * pGate = pNode->pData;
+ Mio_Gate_t * pGate = (Mio_Gate_t *)pNode->pData;
Mio_Pin_t * pGatePin;
int i;
// write the node gate
@@ -459,7 +462,7 @@ void Io_NtkWriteIntNet( FILE * pFile, Abc_Obj_t * pNet )
Abc_ObjForEachFanout( pFanin, pNeto, j )
fprintf( pFile, "%s_", Abc_ObjName(pNeto) );
if ( Abc_NtkHasMapping(pNet->pNtk) )
- fprintf( pFile, "%s : ", Mio_GateReadName(pFanin->pData) );
+ fprintf( pFile, "%s : ", Mio_GateReadName((Mio_Gate_t *)pFanin->pData) );
else
fprintf( pFile, "name I : " );
}
@@ -487,7 +490,7 @@ void Io_NtkWriteIntNet( FILE * pFile, Abc_Obj_t * pNet )
Abc_ObjForEachFanout( pFanout, pNeto, j )
fprintf( pFile, "%s_", Abc_ObjName(pNeto) );
if ( Abc_NtkHasMapping(pNet->pNtk) )
- fprintf( pFile, "%s : ", Mio_GateReadName(pFanout->pData) );
+ fprintf( pFile, "%s : ", Mio_GateReadName((Mio_Gate_t *)pFanout->pData) );
else
fprintf( pFile, "name O : " );
}
@@ -626,7 +629,7 @@ void Io_NtkWritePl( FILE * pFile, Abc_Ntk_t * pNtk, unsigned numTerms, double la
delta = layoutWidth / termsOnTop;
for(t = 0; t < termsOnTop; t++)
{
- pTerm = Vec_PtrEntry( vOrderedTerms, t );
+ pTerm = (Abc_Obj_t *)Vec_PtrEntry( vOrderedTerms, t );
if( Abc_ObjIsPi(pTerm) )
fprintf( pFile, "i%s_input\t\t", Abc_ObjName(Abc_ObjFanout0(pTerm)) );
else
@@ -642,7 +645,7 @@ void Io_NtkWritePl( FILE * pFile, Abc_Ntk_t * pNtk, unsigned numTerms, double la
delta = layoutWidth / termsOnBottom;
for(;t < termsOnTop+termsOnBottom; t++)
{
- pTerm = Vec_PtrEntry( vOrderedTerms, t );
+ pTerm = (Abc_Obj_t *)Vec_PtrEntry( vOrderedTerms, t );
if( Abc_ObjIsPi(pTerm) )
fprintf( pFile, "i%s_input\t\t", Abc_ObjName(Abc_ObjFanout0(pTerm)) );
else
@@ -658,7 +661,7 @@ void Io_NtkWritePl( FILE * pFile, Abc_Ntk_t * pNtk, unsigned numTerms, double la
delta = layoutHeight / termsOnLeft;
for(;t < termsOnTop+termsOnBottom+termsOnLeft; t++)
{
- pTerm = Vec_PtrEntry( vOrderedTerms, t );
+ pTerm = (Abc_Obj_t *)Vec_PtrEntry( vOrderedTerms, t );
if( Abc_ObjIsPi(pTerm) )
fprintf( pFile, "i%s_input\t\t", Abc_ObjName(Abc_ObjFanout0(pTerm)) );
else
@@ -674,7 +677,7 @@ void Io_NtkWritePl( FILE * pFile, Abc_Ntk_t * pNtk, unsigned numTerms, double la
delta = layoutHeight / termsOnRight;
for(;t < termsOnTop+termsOnBottom+termsOnLeft+termsOnRight; t++)
{
- pTerm = Vec_PtrEntry( vOrderedTerms, t );
+ pTerm = (Abc_Obj_t *)Vec_PtrEntry( vOrderedTerms, t );
if( Abc_ObjIsPi(pTerm) )
fprintf( pFile, "i%s_input\t\t", Abc_ObjName(Abc_ObjFanout0(pTerm)) );
else
@@ -715,8 +718,8 @@ Vec_Ptr_t * Io_NtkOrderingPads( Abc_Ntk_t * pNtk, Vec_Ptr_t * vTerms )
ProgressBar * pProgress;
unsigned numTerms=Vec_PtrSize(vTerms);
unsigned termIdx=0, termCount=0;
- bool * pOrdered = ABC_ALLOC(bool, numTerms);
- bool newNeighbor=1;
+ int * pOrdered = ABC_ALLOC(int, numTerms);
+ int newNeighbor=1;
Vec_Ptr_t * vOrderedTerms = Vec_PtrAlloc ( numTerms );
Abc_Obj_t * pNeighbor, * pNextTerm;
unsigned i;
@@ -724,13 +727,13 @@ Vec_Ptr_t * Io_NtkOrderingPads( Abc_Ntk_t * pNtk, Vec_Ptr_t * vTerms )
for( i=0 ; i<numTerms ; i++ )
pOrdered[i]=0;
- pNextTerm = Vec_PtrEntry(vTerms, termIdx++);
+ pNextTerm = (Abc_Obj_t *)Vec_PtrEntry(vTerms, termIdx++);
pProgress = Extra_ProgressBarStart( stdout, numTerms );
while( termCount < numTerms && termIdx < numTerms )
{
if( pOrdered[Abc_ObjId(pNextTerm)] && !newNeighbor )
{
- pNextTerm = Vec_PtrEntry( vTerms, termIdx++ );
+ pNextTerm = (Abc_Obj_t *)Vec_PtrEntry( vTerms, termIdx++ );
continue;
}
if(!Vec_PtrPushUnique( vOrderedTerms, pNextTerm ))
@@ -746,7 +749,7 @@ Vec_Ptr_t * Io_NtkOrderingPads( Abc_Ntk_t * pNtk, Vec_Ptr_t * vTerms )
pNextTerm=pNeighbor;
}
else if(termIdx < numTerms)
- pNextTerm = Vec_PtrEntry( vTerms, termIdx++ );
+ pNextTerm = (Abc_Obj_t *)Vec_PtrEntry( vTerms, termIdx++ );
Extra_ProgressBarUpdate( pProgress, termCount, NULL );
}
@@ -766,11 +769,11 @@ Vec_Ptr_t * Io_NtkOrderingPads( Abc_Ntk_t * pNtk, Vec_Ptr_t * vTerms )
SeeAlso []
***********************************************************************/
-Abc_Obj_t * Io_NtkBfsPads( Abc_Ntk_t * pNtk, Abc_Obj_t * pTerm, unsigned numTerms, bool * pOrdered )
+Abc_Obj_t * Io_NtkBfsPads( Abc_Ntk_t * pNtk, Abc_Obj_t * pTerm, unsigned numTerms, int * pOrdered )
{
Vec_Ptr_t * vNeighbors = Vec_PtrAlloc ( numTerms );
Abc_Obj_t * pNet, * pNode, * pNeighbor;
- bool foundNeighbor=0;
+ int foundNeighbor=0;
int i;
assert(Abc_ObjIsPi(pTerm) || Abc_ObjIsPo(pTerm) );
@@ -791,7 +794,7 @@ Abc_Obj_t * Io_NtkBfsPads( Abc_Ntk_t * pNtk, Abc_Obj_t * pTerm, unsigned numTerm
while ( Vec_PtrSize(vNeighbors) >0 )
{
- pNeighbor = Vec_PtrEntry( vNeighbors, 0 );
+ pNeighbor = (Abc_Obj_t *)Vec_PtrEntry( vNeighbors, 0 );
assert( Abc_ObjIsNode(pNeighbor) || Abc_ObjIsTerm(pNeighbor) );
Vec_PtrRemove( vNeighbors, pNeighbor );
@@ -836,7 +839,7 @@ Abc_Obj_t * Io_NtkBfsPads( Abc_Ntk_t * pNtk, Abc_Obj_t * pTerm, unsigned numTerm
SeeAlso []
***********************************************************************/
-bool Abc_NodeIsNand2( Abc_Obj_t * pNode )
+int Abc_NodeIsNand2( Abc_Obj_t * pNode )
{
Abc_Ntk_t * pNtk = pNode->pNtk;
assert( Abc_NtkIsNetlist(pNtk) );
@@ -844,11 +847,11 @@ bool Abc_NodeIsNand2( Abc_Obj_t * pNode )
if ( Abc_ObjFaninNum(pNode) != 2 )
return 0;
if ( Abc_NtkHasSop(pNtk) )
- return ( !strcmp((pNode->pData), "-0 1\n0- 1\n") ||
- !strcmp((pNode->pData), "0- 1\n-0 1\n") ||
- !strcmp((pNode->pData), "11 0\n") );
+ return ( !strcmp(((char *)pNode->pData), "-0 1\n0- 1\n") ||
+ !strcmp(((char *)pNode->pData), "0- 1\n-0 1\n") ||
+ !strcmp(((char *)pNode->pData), "11 0\n") );
if ( Abc_NtkHasMapping(pNtk) )
- return pNode->pData == Mio_LibraryReadNand2(Abc_FrameReadLibGen());
+ return pNode->pData == (void *)Mio_LibraryReadNand2((Mio_Library_t *)Abc_FrameReadLibGen());
assert( 0 );
return 0;
}
@@ -864,7 +867,7 @@ bool Abc_NodeIsNand2( Abc_Obj_t * pNode )
SeeAlso []
***********************************************************************/
-bool Abc_NodeIsNor2( Abc_Obj_t * pNode )
+int Abc_NodeIsNor2( Abc_Obj_t * pNode )
{
Abc_Ntk_t * pNtk = pNode->pNtk;
assert( Abc_NtkIsNetlist(pNtk) );
@@ -872,7 +875,7 @@ bool Abc_NodeIsNor2( Abc_Obj_t * pNode )
if ( Abc_ObjFaninNum(pNode) != 2 )
return 0;
if ( Abc_NtkHasSop(pNtk) )
- return ( !strcmp((pNode->pData), "00 1\n") );
+ return ( !strcmp(((char *)pNode->pData), "00 1\n") );
assert( 0 );
return 0;
}
@@ -888,7 +891,7 @@ bool Abc_NodeIsNor2( Abc_Obj_t * pNode )
SeeAlso []
***********************************************************************/
-bool Abc_NodeIsAnd2( Abc_Obj_t * pNode )
+int Abc_NodeIsAnd2( Abc_Obj_t * pNode )
{
Abc_Ntk_t * pNtk = pNode->pNtk;
assert( Abc_NtkIsNetlist(pNtk) );
@@ -896,9 +899,9 @@ bool Abc_NodeIsAnd2( Abc_Obj_t * pNode )
if ( Abc_ObjFaninNum(pNode) != 2 )
return 0;
if ( Abc_NtkHasSop(pNtk) )
- return Abc_SopIsAndType((pNode->pData));
+ return Abc_SopIsAndType(((char *)pNode->pData));
if ( Abc_NtkHasMapping(pNtk) )
- return pNode->pData == Mio_LibraryReadAnd2(Abc_FrameReadLibGen());
+ return pNode->pData == (void *)Mio_LibraryReadAnd2((Mio_Library_t *)Abc_FrameReadLibGen());
assert( 0 );
return 0;
}
@@ -914,7 +917,7 @@ bool Abc_NodeIsAnd2( Abc_Obj_t * pNode )
SeeAlso []
***********************************************************************/
-bool Abc_NodeIsOr2( Abc_Obj_t * pNode )
+int Abc_NodeIsOr2( Abc_Obj_t * pNode )
{
Abc_Ntk_t * pNtk = pNode->pNtk;
assert( Abc_NtkIsNetlist(pNtk) );
@@ -922,10 +925,10 @@ bool Abc_NodeIsOr2( Abc_Obj_t * pNode )
if ( Abc_ObjFaninNum(pNode) != 2 )
return 0;
if ( Abc_NtkHasSop(pNtk) )
- return ( Abc_SopIsOrType((pNode->pData)) ||
- !strcmp((pNode->pData), "01 0\n") ||
- !strcmp((pNode->pData), "10 0\n") ||
- !strcmp((pNode->pData), "00 0\n") );
+ return ( Abc_SopIsOrType(((char *)pNode->pData)) ||
+ !strcmp(((char *)pNode->pData), "01 0\n") ||
+ !strcmp(((char *)pNode->pData), "10 0\n") ||
+ !strcmp(((char *)pNode->pData), "00 0\n") );
//off-sets, too
assert( 0 );
return 0;
@@ -942,7 +945,7 @@ bool Abc_NodeIsOr2( Abc_Obj_t * pNode )
SeeAlso []
***********************************************************************/
-bool Abc_NodeIsXor2( Abc_Obj_t * pNode )
+int Abc_NodeIsXor2( Abc_Obj_t * pNode )
{
Abc_Ntk_t * pNtk = pNode->pNtk;
assert( Abc_NtkIsNetlist(pNtk) );
@@ -950,7 +953,7 @@ bool Abc_NodeIsXor2( Abc_Obj_t * pNode )
if ( Abc_ObjFaninNum(pNode) != 2 )
return 0;
if ( Abc_NtkHasSop(pNtk) )
- return ( !strcmp((pNode->pData), "01 1\n10 1\n") || !strcmp((pNode->pData), "10 1\n01 1\n") );
+ return ( !strcmp(((char *)pNode->pData), "01 1\n10 1\n") || !strcmp(((char *)pNode->pData), "10 1\n01 1\n") );
assert( 0 );
return 0;
}
@@ -966,7 +969,7 @@ bool Abc_NodeIsXor2( Abc_Obj_t * pNode )
SeeAlso []
***********************************************************************/
-bool Abc_NodeIsXnor2( Abc_Obj_t * pNode )
+int Abc_NodeIsXnor2( Abc_Obj_t * pNode )
{
Abc_Ntk_t * pNtk = pNode->pNtk;
assert( Abc_NtkIsNetlist(pNtk) );
@@ -974,7 +977,7 @@ bool Abc_NodeIsXnor2( Abc_Obj_t * pNode )
if ( Abc_ObjFaninNum(pNode) != 2 )
return 0;
if ( Abc_NtkHasSop(pNtk) )
- return ( !strcmp((pNode->pData), "11 1\n00 1\n") || !strcmp((pNode->pData), "00 1\n11 1\n") );
+ return ( !strcmp(((char *)pNode->pData), "11 1\n00 1\n") || !strcmp(((char *)pNode->pData), "00 1\n11 1\n") );
assert( 0 );
return 0;
}
@@ -984,3 +987,5 @@ bool Abc_NodeIsXnor2( Abc_Obj_t * pNode )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/io/ioWriteCnf.c b/src/base/io/ioWriteCnf.c
index 3df189d1..6cb82a0a 100644
--- a/src/base/io/ioWriteCnf.c
+++ b/src/base/io/ioWriteCnf.c
@@ -21,6 +21,9 @@
#include "ioAbc.h"
#include "satSolver.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -68,7 +71,7 @@ int Io_WriteCnf( Abc_Ntk_t * pNtk, char * pFileName, int fAllPrimes )
if ( Abc_NtkIsLogic(pNtk) )
Abc_NtkToBdd( pNtk );
// create solver with clauses
- pSat = Abc_NtkMiterSatCreate( pNtk, fAllPrimes );
+ pSat = (sat_solver *)Abc_NtkMiterSatCreate( pNtk, fAllPrimes );
if ( pSat == NULL )
{
fprintf( stdout, "The problem is trivially UNSAT. No CNF file is generated.\n" );
@@ -113,3 +116,5 @@ void Io_WriteCnfOutputPiMapping( FILE * pFile, int incrementVars )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/io/ioWriteDot.c b/src/base/io/ioWriteDot.c
index 64be1425..c1b9befc 100644
--- a/src/base/io/ioWriteDot.c
+++ b/src/base/io/ioWriteDot.c
@@ -22,6 +22,9 @@
#include "main.h"
#include "mio.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -105,10 +108,10 @@ void Io_WriteDotNtk( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
}
// mark the nodes from the set
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
pNode->fMarkC = 1;
if ( vNodesShow )
- Vec_PtrForEachEntry( vNodesShow, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodesShow, pNode, i )
pNode->fMarkB = 1;
// get the levels of nodes
@@ -117,7 +120,7 @@ void Io_WriteDotNtk( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
{
LevelMin = Abc_NtkLevelReverse( pNtk );
assert( LevelMax == LevelMin );
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
if ( Abc_ObjIsNode(pNode) )
pNode->Level = LevelMax - pNode->Level + 1;
}
@@ -126,7 +129,7 @@ void Io_WriteDotNtk( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
LevelMin = 10000;
LevelMax = -1;
fHasCos = 0;
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
{
if ( Abc_ObjIsCo(pNode) )
{
@@ -143,7 +146,7 @@ void Io_WriteDotNtk( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
if ( fHasCos )
{
LevelMax++;
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
{
if ( Abc_ObjIsCo(pNode) )
pNode->Level = LevelMax;
@@ -247,7 +250,7 @@ void Io_WriteDotNtk( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
// the labeling node of this level
fprintf( pFile, " Level%d;\n", LevelMax );
// generate the PO nodes
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
{
if ( !Abc_ObjIsCo(pNode) )
continue;
@@ -273,7 +276,7 @@ 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 )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
{
if ( (int)pNode->Level != Level )
continue;
@@ -296,11 +299,11 @@ void Io_WriteDotNtk( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
if ( Abc_NtkIsStrash(pNtk) )
pSopString = "";
else if ( Abc_NtkHasMapping(pNtk) && fGateNames )
- pSopString = Mio_GateReadName(pNode->pData);
+ pSopString = Mio_GateReadName((Mio_Gate_t *)pNode->pData);
else if ( Abc_NtkHasMapping(pNtk) )
- pSopString = Abc_NtkPrintSop(Mio_GateReadSop(pNode->pData));
+ pSopString = Abc_NtkPrintSop(Mio_GateReadSop((Mio_Gate_t *)pNode->pData));
else
- pSopString = Abc_NtkPrintSop(pNode->pData);
+ pSopString = Abc_NtkPrintSop((char *)pNode->pData);
fprintf( pFile, " Node%d [label = \"%d\\n%s\"", pNode->Id, pNode->Id, pSopString );
// fprintf( pFile, " Node%d [label = \"%d\\n%s\"", pNode->Id,
// SuppSize,
@@ -324,7 +327,7 @@ void Io_WriteDotNtk( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
// the labeling node of this level
fprintf( pFile, " Level%d;\n", LevelMin );
// generate the PO nodes
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
{
if ( !Abc_ObjIsCi(pNode) )
{
@@ -356,7 +359,7 @@ void Io_WriteDotNtk( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
// generate invisible edges from the square down
fprintf( pFile, "title1 -> title2 [style = invis];\n" );
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
{
if ( (int)pNode->Level != LevelMax )
continue;
@@ -364,7 +367,7 @@ void Io_WriteDotNtk( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
}
// generate edges
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
{
if ( Abc_ObjIsLatch(pNode) )
continue;
@@ -392,10 +395,10 @@ void Io_WriteDotNtk( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
fclose( pFile );
// unmark the nodes from the set
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
pNode->fMarkC = 0;
if ( vNodesShow )
- Vec_PtrForEachEntry( vNodesShow, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodesShow, pNode, i )
pNode->fMarkB = 0;
// convert the network back into BDDs if this is how it was
@@ -456,10 +459,10 @@ void Io_WriteDotSeq( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
}
// mark the nodes from the set
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
pNode->fMarkC = 1;
if ( vNodesShow )
- Vec_PtrForEachEntry( vNodesShow, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodesShow, pNode, i )
pNode->fMarkB = 1;
// get the levels of nodes
@@ -468,7 +471,7 @@ void Io_WriteDotSeq( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
{
LevelMin = Abc_NtkLevelReverse( pNtk );
assert( LevelMax == LevelMin );
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
if ( Abc_ObjIsNode(pNode) )
pNode->Level = LevelMax - pNode->Level + 1;
}
@@ -477,7 +480,7 @@ void Io_WriteDotSeq( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
LevelMin = 10000;
LevelMax = -1;
fHasCos = 0;
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
{
if ( Abc_ObjIsCo(pNode) )
{
@@ -494,7 +497,7 @@ void Io_WriteDotSeq( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
if ( fHasCos )
{
LevelMax++;
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
{
if ( Abc_ObjIsCo(pNode) )
pNode->Level = LevelMax;
@@ -598,7 +601,7 @@ void Io_WriteDotSeq( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
// the labeling node of this level
fprintf( pFile, " Level%d;\n", LevelMax );
// generate the PO nodes
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
{
if ( !Abc_ObjIsPo(pNode) )
continue;
@@ -629,11 +632,11 @@ void Io_WriteDotSeq( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
if ( Abc_NtkIsStrash(pNtk) )
pSopString = "";
else if ( Abc_NtkHasMapping(pNtk) && fGateNames )
- pSopString = Mio_GateReadName(pNode->pData);
+ pSopString = Mio_GateReadName((Mio_Gate_t *)pNode->pData);
else if ( Abc_NtkHasMapping(pNtk) )
- pSopString = Abc_NtkPrintSop(Mio_GateReadSop(pNode->pData));
+ pSopString = Abc_NtkPrintSop(Mio_GateReadSop((Mio_Gate_t *)pNode->pData));
else
- pSopString = Abc_NtkPrintSop(pNode->pData);
+ pSopString = Abc_NtkPrintSop((char *)pNode->pData);
fprintf( pFile, " Node%d [label = \"%d\\n%s\"", pNode->Id, pNode->Id, pSopString );
fprintf( pFile, ", shape = ellipse" );
@@ -654,7 +657,7 @@ void Io_WriteDotSeq( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
// the labeling node of this level
fprintf( pFile, " Level%d;\n", LevelMin );
// generate the PO nodes
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
{
if ( pNode->Level > 0 )
continue;
@@ -685,7 +688,7 @@ void Io_WriteDotSeq( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
}
// fprintf( pFile, "{\n" );
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
{
if ( !Abc_ObjIsLatch(pNode) )
continue;
@@ -702,7 +705,7 @@ void Io_WriteDotSeq( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
// generate invisible edges from the square down
fprintf( pFile, "title1 -> title2 [style = invis];\n" );
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
{
if ( (int)pNode->Level != LevelMax )
continue;
@@ -712,7 +715,7 @@ void Io_WriteDotSeq( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
}
// generate edges
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
{
if ( Abc_ObjIsBi(pNode) || Abc_ObjIsBo(pNode) )
continue;
@@ -750,10 +753,10 @@ void Io_WriteDotSeq( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho
fclose( pFile );
// unmark the nodes from the set
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
pNode->fMarkC = 0;
if ( vNodesShow )
- Vec_PtrForEachEntry( vNodesShow, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodesShow, pNode, i )
pNode->fMarkB = 0;
// convert the network back into BDDs if this is how it was
@@ -807,7 +810,7 @@ int Abc_NtkCountLogicNodes( Vec_Ptr_t * vNodes )
{
Abc_Obj_t * pObj;
int i, Counter = 0;
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
{
if ( !Abc_ObjIsNode(pObj) )
continue;
@@ -823,3 +826,5 @@ int Abc_NtkCountLogicNodes( Vec_Ptr_t * vNodes )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/io/ioWriteEqn.c b/src/base/io/ioWriteEqn.c
index 228e4ae9..d3784187 100644
--- a/src/base/io/ioWriteEqn.c
+++ b/src/base/io/ioWriteEqn.c
@@ -20,6 +20,9 @@
#include "ioAbc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -108,9 +111,9 @@ void Io_NtkWriteEqnOne( FILE * pFile, Abc_Ntk_t * pNtk )
fprintf( pFile, "%s = ", Abc_ObjName(Abc_ObjFanout0(pNode)) );
// set the input names
Abc_ObjForEachFanin( pNode, pFanin, k )
- Hop_IthVar(pNtk->pManFunc, k)->pData = Abc_ObjName(pFanin);
+ Hop_IthVar((Hop_Man_t *)pNtk->pManFunc, k)->pData = Abc_ObjName(pFanin);
// write the formula
- Hop_ObjPrintEqn( pFile, pNode->pData, vLevels, 0 );
+ Hop_ObjPrintEqn( pFile, (Hop_Obj_t *)pNode->pData, vLevels, 0 );
fprintf( pFile, ";\n" );
}
Extra_ProgressBarStop( pProgress );
@@ -250,3 +253,5 @@ int Io_NtkWriteEqnCheck( Abc_Ntk_t * pNtk )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/io/ioWriteGml.c b/src/base/io/ioWriteGml.c
index d84e5f67..49a90d9c 100644
--- a/src/base/io/ioWriteGml.c
+++ b/src/base/io/ioWriteGml.c
@@ -20,6 +20,9 @@
#include "ioAbc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -114,3 +117,5 @@ void Io_WriteGml( Abc_Ntk_t * pNtk, char * pFileName )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/io/ioWriteList.c b/src/base/io/ioWriteList.c
index c06b39d7..22d0d1af 100644
--- a/src/base/io/ioWriteList.c
+++ b/src/base/io/ioWriteList.c
@@ -20,6 +20,9 @@
#include "ioAbc.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*
-------- Original Message --------
Subject: Re: abc release and retiming
@@ -286,3 +289,5 @@ void Io_WriteCellNet( Abc_Ntk_t * pNtk, char * pFileName )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/io/ioWritePla.c b/src/base/io/ioWritePla.c
index 93332793..ce6ee31f 100644
--- a/src/base/io/ioWritePla.c
+++ b/src/base/io/ioWritePla.c
@@ -20,6 +20,9 @@
#include "ioAbc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -100,7 +103,7 @@ int Io_WritePlaOne( FILE * pFile, Abc_Ntk_t * pNtk )
nProducts++;
continue;
}
- nProducts += Abc_SopGetCubeNum(pDriver->pData);
+ nProducts += Abc_SopGetCubeNum((char *)pDriver->pData);
}
// collect the parameters
@@ -155,11 +158,11 @@ int Io_WritePlaOne( FILE * pFile, Abc_Ntk_t * pNtk )
}
// make sure the cover is not complemented
- assert( !Abc_SopIsComplement( pDriver->pData ) );
+ assert( !Abc_SopIsComplement( (char *)pDriver->pData ) );
// write the cubes
nFanins = Abc_ObjFaninNum(pDriver);
- Abc_SopForEachCube( pDriver->pData, nFanins, pCube )
+ Abc_SopForEachCube( (char *)pDriver->pData, nFanins, pCube )
{
Abc_ObjForEachFanin( pDriver, pFanin, k )
{
@@ -195,3 +198,5 @@ int Io_WritePlaOne( FILE * pFile, Abc_Ntk_t * pNtk )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/io/ioWriteSmv.c b/src/base/io/ioWriteSmv.c
new file mode 100644
index 00000000..c767bcaa
--- /dev/null
+++ b/src/base/io/ioWriteSmv.c
@@ -0,0 +1,265 @@
+/**CFile****************************************************************
+
+ FileName [ioWriteSmv.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Command processing package.]
+
+ Synopsis [Procedures to write the network in SMV format.]
+
+ Author [Satrajit Chatterjee]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: ioWriteSmv.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "ioAbc.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+static int Io_WriteSmvCheckNames( Abc_Ntk_t * pNtk );
+
+static int Io_WriteSmvOne( FILE * pFile, Abc_Ntk_t * pNtk );
+static int Io_WriteSmvOneNode( FILE * pFile, Abc_Obj_t * pNode );
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+// This returns a pointer to a static area, so be careful in using results
+// of this function i.e. don't call this twice in the same printf call.
+//
+// This function replaces '|' with '_' I think abc introduces '|' when
+// flattening hierarchy. The '|' is interpreted as a or function by nusmv
+// which is unfortunate. This probably should be fixed elsewhere.
+static char *cleanUNSAFE( const char *s )
+{
+ char *t;
+ static char buffer[1024];
+ assert (strlen(s) < 1024);
+ strcpy(buffer, s);
+ for (t = buffer; *t != 0; ++t) *t = (*t == '|') ? '_' : *t;
+ return buffer;
+}
+
+static int hasPrefix(const char *needle, const char *haystack)
+{
+ return (strncmp(haystack, needle, strlen(needle)) == 0);
+}
+
+/**Function*************************************************************
+
+ Synopsis [Writes the network in SMV format.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Io_WriteSmv( Abc_Ntk_t * pNtk, char * pFileName )
+{
+ Abc_Ntk_t * pExdc;
+ FILE * pFile;
+ assert( Abc_NtkIsSopNetlist(pNtk) );
+ if ( !Io_WriteSmvCheckNames(pNtk) )
+ {
+ fprintf( stdout, "Io_WriteSmv(): Signal names in this benchmark contain parantheses making them impossible to reproduce in the SMV format. Use \"short_names\".\n" );
+ return 0;
+ }
+ pFile = fopen( pFileName, "w" );
+ if ( pFile == NULL )
+ {
+ fprintf( stdout, "Io_WriteSmv(): Cannot open the output file.\n" );
+ return 0;
+ }
+ fprintf( pFile, "-- benchmark \"%s\" written by ABC on %s\n", pNtk->pName, Extra_TimeStamp() );
+ // write the network
+ Io_WriteSmvOne( pFile, pNtk );
+ // write EXDC network if it exists
+ pExdc = Abc_NtkExdc( pNtk );
+ if ( pExdc )
+ printf( "Io_WriteSmv: EXDC is not written (warning).\n" );
+ // finalize the file
+ fclose( pFile );
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Writes the network in SMV format.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Io_WriteSmvOne( FILE * pFile, Abc_Ntk_t * pNtk )
+{
+ ProgressBar * pProgress;
+ Abc_Obj_t * pNode;
+ int i;
+
+ // write the PIs/POs/latches
+ fprintf( pFile, "MODULE main\n"); // nusmv needs top module to be main
+ fprintf ( pFile, "\n" );
+
+ fprintf( pFile, "VAR -- inputs\n");
+ Abc_NtkForEachPi( pNtk, pNode, i )
+ fprintf( pFile, " %s : boolean;\n",
+ cleanUNSAFE(Abc_ObjName(Abc_ObjFanout0(pNode))) );
+ fprintf ( pFile, "\n" );
+
+ fprintf( pFile, "VAR -- state variables\n");
+ Abc_NtkForEachLatch( pNtk, pNode, i )
+ fprintf( pFile, " %s : boolean;\n",
+ cleanUNSAFE(Abc_ObjName(Abc_ObjFanout0(Abc_ObjFanout0(pNode)))) );
+ fprintf ( pFile, "\n" );
+
+ // No outputs needed for NuSMV:
+ // TODO: Add sepcs by recognizing assume_.* and assert_.*
+ //
+ // Abc_NtkForEachPo( pNtk, pNode, i )
+ // fprintf( pFile, "OUTPUT(%s)\n", Abc_ObjName(Abc_ObjFanin0(pNode)) );
+
+ // write internal nodes
+ fprintf( pFile, "DEFINE\n");
+ pProgress = Extra_ProgressBarStart( stdout, Abc_NtkObjNumMax(pNtk) );
+ Abc_NtkForEachNode( pNtk, pNode, i )
+ {
+ Extra_ProgressBarUpdate( pProgress, i, NULL );
+ Io_WriteSmvOneNode( pFile, pNode );
+ }
+ Extra_ProgressBarStop( pProgress );
+ fprintf ( pFile, "\n" );
+
+ fprintf( pFile, "ASSIGN\n");
+ Abc_NtkForEachLatch( pNtk, pNode, i )
+ {
+ int Reset = (int)(ABC_PTRUINT_T)Abc_ObjData( pNode );
+ assert (Reset >= 1);
+ assert (Reset <= 3);
+
+ if (Reset != 3)
+ {
+ fprintf( pFile, " init(%s) := %d;\n",
+ cleanUNSAFE(Abc_ObjName(Abc_ObjFanout0(Abc_ObjFanout0(pNode)))),
+ Reset - 1);
+ }
+ fprintf( pFile, " next(%s) := ",
+ cleanUNSAFE(Abc_ObjName(Abc_ObjFanout0(Abc_ObjFanout0(pNode)))) );
+ fprintf( pFile, "%s;\n",
+ cleanUNSAFE(Abc_ObjName(Abc_ObjFanin0(Abc_ObjFanin0(pNode)))) );
+ }
+
+ fprintf ( pFile, "\n" );
+ Abc_NtkForEachPo( pNtk, pNode, i )
+ {
+ const char *n = cleanUNSAFE(Abc_ObjName(Abc_ObjFanin0(pNode)));
+ // fprintf( pFile, "-- output %s;\n", n );
+ if (hasPrefix("assume_fair_", n))
+ {
+ fprintf( pFile, "FAIRNESS %s;\n", n );
+ }
+ else if (hasPrefix("Assert_", n) ||
+ hasPrefix("assert_safety_", n))
+ {
+ fprintf( pFile, "INVARSPEC %s;\n", n );
+ }
+ else if (hasPrefix("assert_fair_", n))
+ {
+ fprintf( pFile, "LTLSPEC G F %s;\n", n );
+ }
+ }
+
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Writes the network in SMV format.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Io_WriteSmvOneNode( FILE * pFile, Abc_Obj_t * pNode )
+{
+ int nFanins;
+
+ assert( Abc_ObjIsNode(pNode) );
+ nFanins = Abc_ObjFaninNum(pNode);
+ if ( nFanins == 0 )
+ { // write the constant 1 node
+ assert( Abc_NodeIsConst1(pNode) );
+ fprintf( pFile, " %s", cleanUNSAFE(Abc_ObjName(Abc_ObjFanout0(pNode)) ) );
+ fprintf( pFile, " := 1;\n" );
+ }
+ else if ( nFanins == 1 )
+ { // write the interver/buffer
+ if ( Abc_NodeIsBuf(pNode) )
+ {
+ fprintf( pFile, " %s := ", cleanUNSAFE(Abc_ObjName(Abc_ObjFanout0(pNode))) );
+ fprintf( pFile, "%s;\n", cleanUNSAFE(Abc_ObjName(Abc_ObjFanin0(pNode))) );
+ }
+ else
+ {
+ fprintf( pFile, " %s := !", cleanUNSAFE(Abc_ObjName(Abc_ObjFanout0(pNode))) );
+ fprintf( pFile, "%s;\n", cleanUNSAFE(Abc_ObjName(Abc_ObjFanin0(pNode))) );
+ }
+ }
+ else
+ { // write the AND gate
+ fprintf( pFile, " %s", cleanUNSAFE(Abc_ObjName(Abc_ObjFanout0(pNode))) );
+ fprintf( pFile, " := %s & ", cleanUNSAFE(Abc_ObjName(Abc_ObjFanin0(pNode))) );
+ fprintf( pFile, "%s;\n", cleanUNSAFE(Abc_ObjName(Abc_ObjFanin1(pNode))) );
+ }
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns 1 if the names cannot be written into the bench file.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Io_WriteSmvCheckNames( Abc_Ntk_t * pNtk )
+{
+ Abc_Obj_t * pObj;
+ char * pName;
+ int i;
+ Abc_NtkForEachObj( pNtk, pObj, i )
+ for ( pName = Nm_ManFindNameById(pNtk->pManName, i); pName && *pName; pName++ )
+ if ( *pName == '(' || *pName == ')' )
+ return 0;
+ return 1;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/io/ioWriteVerilog.c b/src/base/io/ioWriteVerilog.c
index f2ac1b1d..7f9bee95 100644
--- a/src/base/io/ioWriteVerilog.c
+++ b/src/base/io/ioWriteVerilog.c
@@ -22,6 +22,9 @@
#include "main.h"
#include "mio.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -80,7 +83,7 @@ void Io_WriteVerilog( Abc_Ntk_t * pNtk, char * pFileName )
// write the network first
Io_WriteVerilogInt( pFile, pNtk );
// write other things
- Vec_PtrForEachEntry( pNtk->pDesign->vModules, pNetlist, i )
+ Vec_PtrForEachEntry( Abc_Ntk_t *, pNtk->pDesign->vModules, pNetlist, i )
{
assert( Abc_NtkIsNetlist(pNetlist) );
if ( pNetlist == pNtk )
@@ -495,7 +498,7 @@ void Io_WriteVerilogObjects( FILE * pFile, Abc_Ntk_t * pNtk )
{
if ( Abc_ObjIsLatch(pObj) )
continue;
- pNtkBox = pObj->pData;
+ pNtkBox = (Abc_Ntk_t *)pObj->pData;
fprintf( pFile, " %s box%0*d", pNtkBox->pName, nDigits, Counter++ );
fprintf( pFile, "(" );
Abc_NtkForEachPi( pNtkBox, pTerm, k )
@@ -513,12 +516,12 @@ void Io_WriteVerilogObjects( FILE * pFile, Abc_Ntk_t * pNtk )
// write nodes
if ( Abc_NtkHasMapping(pNtk) )
{
- Length = Mio_LibraryReadGateNameMax(pNtk->pManFunc);
+ Length = Mio_LibraryReadGateNameMax((Mio_Library_t *)pNtk->pManFunc);
nDigits = Extra_Base10Log( Abc_NtkNodeNum(pNtk) );
Counter = 0;
Abc_NtkForEachNode( pNtk, pObj, k )
{
- Mio_Gate_t * pGate = pObj->pData;
+ Mio_Gate_t * pGate = (Mio_Gate_t *)pObj->pData;
Mio_Pin_t * pGatePin;
// write the node
fprintf( pFile, " %-*s g%0*d", Length, Mio_GateReadName(pGate), nDigits, Counter++ );
@@ -539,17 +542,17 @@ void Io_WriteVerilogObjects( FILE * pFile, Abc_Ntk_t * pNtk )
vLevels = Vec_VecAlloc( 10 );
Abc_NtkForEachNode( pNtk, pObj, i )
{
- pFunc = pObj->pData;
+ pFunc = (Hop_Obj_t *)pObj->pData;
fprintf( pFile, " assign %s = ", Io_WriteVerilogGetName(Abc_ObjName(Abc_ObjFanout0(pObj))) );
// set the input names
Abc_ObjForEachFanin( pObj, pFanin, k )
- Hop_IthVar(pNtk->pManFunc, k)->pData = Extra_UtilStrsav(Io_WriteVerilogGetName(Abc_ObjName(pFanin)));
+ Hop_IthVar((Hop_Man_t *)pNtk->pManFunc, k)->pData = Extra_UtilStrsav(Io_WriteVerilogGetName(Abc_ObjName(pFanin)));
// write the formula
Hop_ObjPrintVerilog( pFile, pFunc, vLevels, 0 );
fprintf( pFile, ";\n" );
// clear the input names
Abc_ObjForEachFanin( pObj, pFanin, k )
- ABC_FREE( Hop_IthVar(pNtk->pManFunc, k)->pData );
+ ABC_FREE( Hop_IthVar((Hop_Man_t *)pNtk->pManFunc, k)->pData );
}
Vec_VecFree( vLevels );
}
@@ -637,3 +640,5 @@ char * Io_WriteVerilogGetName( char * pName )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/io/module.make b/src/base/io/module.make
index 993bd7d2..dee459da 100644
--- a/src/base/io/module.make
+++ b/src/base/io/module.make
@@ -25,4 +25,5 @@ SRC += src/base/io/io.c \
src/base/io/ioWriteGml.c \
src/base/io/ioWriteList.c \
src/base/io/ioWritePla.c \
- src/base/io/ioWriteVerilog.c
+ src/base/io/ioWriteVerilog.c \
+ src/base/io/ioWriteSmv.c
diff --git a/src/base/main/libSupport.c b/src/base/main/libSupport.c
index 6bffc2bd..3c0b20c7 100644
--- a/src/base/main/libSupport.c
+++ b/src/base/main/libSupport.c
@@ -20,8 +20,12 @@
#include <stdio.h>
#include <string.h>
+
+#include "abc.h"
#include "mainInt.h"
-#include "abc_global.h"
+
+ABC_NAMESPACE_IMPL_START
+
#ifndef WIN32
# include <sys/types.h>
@@ -29,6 +33,14 @@
# include <dlfcn.h>
#endif
+// fix by Paddy O'Brien on Sep 22, 2009
+#ifdef __CYGWIN__
+#ifndef RTLD_LOCAL
+#define RTLD_LOCAL 0
+#endif
+#endif
+
+
#define MAX_LIBS 256
static void* libHandles[MAX_LIBS+1]; // will be null terminated
@@ -192,3 +204,5 @@ void Libs_End(Abc_Frame_t * pAbc)
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/main/main.c b/src/base/main/main.c
index ebe7c755..42ea255d 100644
--- a/src/base/main/main.c
+++ b/src/base/main/main.c
@@ -17,9 +17,17 @@
Revision [$Id: main.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
-
+
+#include "abc.h"
#include "mainInt.h"
+#ifdef ABC_PYTHON_EMBED
+#include <Python.h>
+
+#endif /* ABC_PYTHON_EMBED */
+
+ABC_NAMESPACE_IMPL_START
+
// this line should be included in the library project
//#define ABC_LIB
@@ -29,7 +37,7 @@
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
-static int TypeCheck( Abc_Frame_t * pAbc, char * s);
+static int TypeCheck( Abc_Frame_t * pAbc, const char * s);
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
@@ -48,23 +56,20 @@ static int TypeCheck( Abc_Frame_t * pAbc, char * s);
SeeAlso []
***********************************************************************/
-#if defined(ABC_USE_BINARY)
-int main_( int argc, char * argv[] )
-#else
-int main( int argc, char * argv[] )
-#endif
+int Abc_RealMain( int argc, char * argv[] )
{
Abc_Frame_t * pAbc;
char sCommandUsr[500], sCommandTmp[100], sReadCmd[20], sWriteCmd[20], c;
- char * sCommand, * sOutFile, * sInFile;
+ const char * sOutFile, * sInFile;
+ char * sCommand;
int fStatus = 0;
- bool fBatch, fInitSource, fInitRead, fFinalWrite;
+ int fBatch, fInitSource, fInitRead, fFinalWrite;
// added to detect memory leaks:
#if defined(_DEBUG) && defined(_MSC_VER)
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
#endif
-
+
// Npn_Experiment();
// Npn_Generate();
@@ -72,6 +77,23 @@ int main( int argc, char * argv[] )
// will be initialized on first call
pAbc = Abc_FrameGetGlobalFrame();
+#ifdef ABC_PYTHON_EMBED
+ {
+ PyObject* pName;
+ PyObject* pModule;
+ void init_pyabc(void);
+
+ Py_SetProgramName(argv[0]);
+ Py_NoSiteFlag = 1;
+ Py_Initialize();
+
+ init_pyabc();
+
+ pModule = PyImport_ImportModule("pyabc");
+ Py_DECREF(pModule);
+ }
+#endif /* ABC_PYTHON_EMBED */
+
// default options
fBatch = 0;
fInitSource = 1;
@@ -223,9 +245,15 @@ int main( int argc, char * argv[] )
break;
}
}
-
+
+#ifdef ABC_PYTHON_EMBED
+ {
+ Py_Finalize();
+ }
+#endif /* ABC_PYTHON_EMBED */
+
// if the memory should be freed, quit packages
- if ( fStatus < 0 )
+// if ( fStatus < 0 )
{
Abc_Stop();
}
@@ -239,57 +267,6 @@ usage:
#endif
-/**Function*************************************************************
-
- Synopsis [Initialization procedure for the library project.]
-
- Description [Note that when Abc_Start() is run in a static library
- project, it does not load the resource file by default. As a result,
- ABC is not set up the same way, as when it is run on a command line.
- For example, some error messages while parsing files will not be
- produced, and intermediate networks will not be checked for consistancy.
- One possibility is to load the resource file after Abc_Start() as follows:
- Abc_UtilsSource( Abc_FrameGetGlobalFrame() );]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Abc_Start()
-{
- Abc_Frame_t * pAbc;
- // added to detect memory leaks:
-#if defined(_DEBUG) && defined(_MSC_VER)
- _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
-#endif
- // start the glocal frame
- pAbc = Abc_FrameGetGlobalFrame();
- // source the resource file
-// Abc_UtilsSource( pAbc );
-}
-
-/**Function*************************************************************
-
- Synopsis [Deallocation procedure for the library project.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Abc_Stop()
-{
- Abc_Frame_t * pAbc;
- pAbc = Abc_FrameGetGlobalFrame();
- // perform uninitializations
- Abc_FrameEnd( pAbc );
- // stop the framework
- Abc_FrameDeallocate( pAbc );
-}
-
/**Function********************************************************************
Synopsis [Returns 1 if s is a file type recognized, else returns 0.]
@@ -300,7 +277,7 @@ void Abc_Stop()
SideEffects []
******************************************************************************/
-static int TypeCheck( Abc_Frame_t * pAbc, char * s )
+static int TypeCheck( Abc_Frame_t * pAbc, const char * s )
{
if (strcmp(s, "blif") == 0)
return 1;
@@ -324,3 +301,13 @@ static int TypeCheck( Abc_Frame_t * pAbc, char * s )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
+#if defined(ABC_USE_BINARY)
+int main_( int argc, char * argv[] )
+#else
+int main( int argc, char * argv[] )
+#endif
+{
+ return ABC_NAMESPACE_PREFIX Abc_RealMain(argc, argv);
+}
diff --git a/src/base/main/main.h b/src/base/main/main.h
index 0c5aeb3e..f3e03b47 100644
--- a/src/base/main/main.h
+++ b/src/base/main/main.h
@@ -21,12 +21,6 @@
#ifndef __MAIN_H__
#define __MAIN_H__
-////////////////////////////////////////////////////////////////////////
-/// TYPEDEFS ///
-////////////////////////////////////////////////////////////////////////
-
-// the framework containing all data
-typedef struct Abc_Frame_t_ Abc_Frame_t;
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
@@ -39,16 +33,24 @@ typedef struct Abc_Frame_t_ Abc_Frame_t;
// core packages
#include "abc.h"
+
+ABC_NAMESPACE_HEADER_START
+// the framework containing all data
+typedef struct Abc_Frame_t_ Abc_Frame_t;
+ABC_NAMESPACE_HEADER_END
+
#include "cmd.h"
#include "ioAbc.h"
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+////////////////////////////////////////////////////////////////////////
+/// TYPEDEFS ///
+////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// GLOBAL VARIABLES ///
@@ -74,10 +76,11 @@ extern ABC_DLL void Abc_Stop();
extern ABC_DLL Abc_Ntk_t * Abc_FrameReadNtk( Abc_Frame_t * p );
extern ABC_DLL FILE * Abc_FrameReadOut( Abc_Frame_t * p );
extern ABC_DLL FILE * Abc_FrameReadErr( Abc_Frame_t * p );
-extern ABC_DLL bool Abc_FrameReadMode( Abc_Frame_t * p );
-extern ABC_DLL bool Abc_FrameSetMode( Abc_Frame_t * p, bool fNameMode );
+extern ABC_DLL int Abc_FrameReadMode( Abc_Frame_t * p );
+extern ABC_DLL int Abc_FrameSetMode( Abc_Frame_t * p, int fNameMode );
extern ABC_DLL void Abc_FrameRestart( Abc_Frame_t * p );
-extern ABC_DLL bool Abc_FrameShowProgress( Abc_Frame_t * p );
+extern ABC_DLL int Abc_FrameShowProgress( Abc_Frame_t * p );
+extern ABC_DLL void Abc_FrameClearVerifStatus( Abc_Frame_t * p );
extern ABC_DLL void Abc_FrameSetCurrentNetwork( Abc_Frame_t * p, Abc_Ntk_t * pNet );
extern ABC_DLL void Abc_FrameSwapCurrentAndBackup( Abc_Frame_t * p );
@@ -99,7 +102,16 @@ extern ABC_DLL void * Abc_FrameReadLibVer();
extern ABC_DLL void * Abc_FrameReadManDd();
extern ABC_DLL void * Abc_FrameReadManDec();
extern ABC_DLL char * Abc_FrameReadFlag( char * pFlag );
-extern ABC_DLL bool Abc_FrameIsFlagEnabled( char * pFlag );
+extern ABC_DLL int Abc_FrameIsFlagEnabled( char * pFlag );
+
+extern ABC_DLL int Abc_FrameReadBmcFrames( Abc_Frame_t * p );
+extern ABC_DLL int Abc_FrameReadProbStatus( Abc_Frame_t * p );
+extern ABC_DLL void * Abc_FrameReadCex( Abc_Frame_t * p );
+
+extern ABC_DLL int Abc_FrameReadCexPiNum( Abc_Frame_t * p );
+extern ABC_DLL int Abc_FrameReadCexRegNum( Abc_Frame_t * p );
+extern ABC_DLL int Abc_FrameReadCexPo( Abc_Frame_t * p );
+extern ABC_DLL int Abc_FrameReadCexFrame( Abc_Frame_t * p );
extern ABC_DLL void Abc_FrameSetNtkStore( Abc_Ntk_t * pNtk );
extern ABC_DLL void Abc_FrameSetNtkStoreSize( int nStored );
@@ -110,9 +122,11 @@ extern ABC_DLL void Abc_FrameSetLibSuper( void * pLib );
extern ABC_DLL void Abc_FrameSetLibVer( void * pLib );
extern ABC_DLL void Abc_FrameSetFlag( char * pFlag, char * pValue );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/base/main/mainFrame.c b/src/base/main/mainFrame.c
index 81070bd8..6a2fe5b3 100644
--- a/src/base/main/mainFrame.c
+++ b/src/base/main/mainFrame.c
@@ -18,19 +18,20 @@
***********************************************************************/
-#include "mainInt.h"
#include "abc.h"
+#include "mainInt.h"
#include "dec.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
static Abc_Frame_t * s_GlobalFrame = NULL;
-extern void * Aig_ManDupSimple( void * p );
-extern void Aig_ManStop( void * pAig );
-
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
@@ -46,23 +47,32 @@ extern void Aig_ManStop( void * pAig );
SeeAlso []
***********************************************************************/
-Vec_Ptr_t * Abc_FrameReadStore() { return s_GlobalFrame->vStore; }
-int Abc_FrameReadStoreSize() { return Vec_PtrSize(s_GlobalFrame->vStore); }
-void * Abc_FrameReadLibLut() { return s_GlobalFrame->pLibLut; }
-void * Abc_FrameReadLibGen() { return s_GlobalFrame->pLibGen; }
-void * Abc_FrameReadLibGen2() { return s_GlobalFrame->pLibGen2; }
-void * Abc_FrameReadLibSuper() { return s_GlobalFrame->pLibSuper; }
-void * Abc_FrameReadLibVer() { return s_GlobalFrame->pLibVer; }
-void * Abc_FrameReadManDd() { if ( s_GlobalFrame->dd == NULL ) s_GlobalFrame->dd = Cudd_Init( 0, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 ); return s_GlobalFrame->dd; }
-void * Abc_FrameReadManDec() { if ( s_GlobalFrame->pManDec == NULL ) s_GlobalFrame->pManDec = Dec_ManStart(); return s_GlobalFrame->pManDec; }
-char * Abc_FrameReadFlag( char * pFlag ) { return Cmd_FlagReadByName( s_GlobalFrame, pFlag ); }
-
-void Abc_FrameSetLibLut( void * pLib ) { s_GlobalFrame->pLibLut = pLib; }
-void Abc_FrameSetLibGen( void * pLib ) { s_GlobalFrame->pLibGen = pLib; }
-void Abc_FrameSetLibGen2( void * pLib ) { s_GlobalFrame->pLibGen2 = pLib; }
-void Abc_FrameSetLibSuper( void * pLib ) { s_GlobalFrame->pLibSuper = pLib; }
-void Abc_FrameSetLibVer( void * pLib ) { s_GlobalFrame->pLibVer = pLib; }
-void Abc_FrameSetFlag( char * pFlag, char * pValue ) { Cmd_FlagUpdateValue( s_GlobalFrame, pFlag, pValue ); }
+Vec_Ptr_t * Abc_FrameReadStore() { return s_GlobalFrame->vStore; }
+int Abc_FrameReadStoreSize() { return Vec_PtrSize(s_GlobalFrame->vStore); }
+void * Abc_FrameReadLibLut() { return s_GlobalFrame->pLibLut; }
+void * Abc_FrameReadLibGen() { return s_GlobalFrame->pLibGen; }
+void * Abc_FrameReadLibGen2() { return s_GlobalFrame->pLibGen2; }
+void * Abc_FrameReadLibSuper() { return s_GlobalFrame->pLibSuper; }
+void * Abc_FrameReadLibVer() { return s_GlobalFrame->pLibVer; }
+void * Abc_FrameReadManDd() { if ( s_GlobalFrame->dd == NULL ) s_GlobalFrame->dd = Cudd_Init( 0, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 ); return s_GlobalFrame->dd; }
+void * Abc_FrameReadManDec() { if ( s_GlobalFrame->pManDec == NULL ) s_GlobalFrame->pManDec = Dec_ManStart(); return s_GlobalFrame->pManDec; }
+char * Abc_FrameReadFlag( char * pFlag ) { return Cmd_FlagReadByName( s_GlobalFrame, pFlag ); }
+
+int Abc_FrameReadBmcFrames( Abc_Frame_t * p ) { return s_GlobalFrame->nFrames; }
+int Abc_FrameReadProbStatus( Abc_Frame_t * p ) { return s_GlobalFrame->Status; }
+void * Abc_FrameReadCex( Abc_Frame_t * p ) { return s_GlobalFrame->pCex; }
+
+int Abc_FrameReadCexPiNum( Abc_Frame_t * p ) { return s_GlobalFrame->pCex->nPis; }
+int Abc_FrameReadCexRegNum( Abc_Frame_t * p ) { return s_GlobalFrame->pCex->nRegs; }
+int Abc_FrameReadCexPo( Abc_Frame_t * p ) { return s_GlobalFrame->pCex->iPo; }
+int Abc_FrameReadCexFrame( Abc_Frame_t * p ) { return s_GlobalFrame->pCex->iFrame; }
+
+void Abc_FrameSetLibLut( void * pLib ) { s_GlobalFrame->pLibLut = pLib; }
+void Abc_FrameSetLibGen( void * pLib ) { s_GlobalFrame->pLibGen = pLib; }
+void Abc_FrameSetLibGen2( void * pLib ) { s_GlobalFrame->pLibGen2 = pLib; }
+void Abc_FrameSetLibSuper( void * pLib ) { s_GlobalFrame->pLibSuper = pLib; }
+void Abc_FrameSetLibVer( void * pLib ) { s_GlobalFrame->pLibVer = pLib; }
+void Abc_FrameSetFlag( char * pFlag, char * pValue ) { Cmd_FlagUpdateValue( s_GlobalFrame, pFlag, pValue ); }
/**Function*************************************************************
@@ -75,7 +85,7 @@ void Abc_FrameSetFlag( char * pFlag, char * pValue ) { Cmd_FlagUpdateVal
SeeAlso []
***********************************************************************/
-bool Abc_FrameIsFlagEnabled( char * pFlag )
+int Abc_FrameIsFlagEnabled( char * pFlag )
{
char * pValue;
// if flag is not defined, it is not enabled
@@ -105,17 +115,18 @@ Abc_Frame_t * Abc_FrameAllocate()
extern void define_cube_size( int n );
extern void set_espresso_flags();
// allocate and clean
- p = ABC_ALLOC( Abc_Frame_t, 1 );
- memset( p, 0, sizeof(Abc_Frame_t) );
+ p = ABC_CALLOC( Abc_Frame_t, 1 );
// get version
p->sVersion = Abc_UtilsGetVersion( p );
// set streams
p->Err = stderr;
p->Out = stdout;
p->Hst = NULL;
+ p->Status = -1;
+ p->nFrames = -1;
// set the starting step
- p->nSteps = 1;
- p->fBatchMode = 0;
+ p->nSteps = 1;
+ p->fBatchMode = 0;
// networks to be used by choice
p->vStore = Vec_PtrAlloc( 16 );
// initialize decomposition manager
@@ -123,6 +134,7 @@ Abc_Frame_t * Abc_FrameAllocate()
// set_espresso_flags();
// initialize the trace manager
// Abc_HManStart();
+ p->vPlugInComBinPairs = Vec_PtrAlloc( 100 );
return p;
}
@@ -147,15 +159,24 @@ void Abc_FrameDeallocate( Abc_Frame_t * p )
// undefine_cube_size();
Rwt_ManGlobalStop();
// Ivy_TruthManStop();
- if ( p->pLibVer ) Abc_LibFree( p->pLibVer, NULL );
- if ( p->pManDec ) Dec_ManStop( p->pManDec );
+ if ( p->pLibVer ) Abc_LibFree( (Abc_Lib_t *)p->pLibVer, NULL );
+ if ( p->pManDec ) Dec_ManStop( (Dec_Man_t *)p->pManDec );
if ( p->dd ) Extra_StopManager( p->dd );
if ( p->vStore ) Vec_PtrFree( p->vStore );
- if ( p->pSave1 ) Aig_ManStop( p->pSave1 );
- if ( p->pSave2 ) Aig_ManStop( p->pSave2 );
- if ( p->pSave3 ) Aig_ManStop( p->pSave3 );
- if ( p->pSave4 ) Aig_ManStop( p->pSave4 );
+ if ( p->pSave1 ) Aig_ManStop( (Aig_Man_t *)p->pSave1 );
+ if ( p->pSave2 ) Aig_ManStop( (Aig_Man_t *)p->pSave2 );
+ if ( p->pSave3 ) Aig_ManStop( (Aig_Man_t *)p->pSave3 );
+ if ( p->pSave4 ) Aig_ManStop( (Aig_Man_t *)p->pSave4 );
+ if ( p->vPlugInComBinPairs )
+ {
+ char * pTemp;
+ int i;
+ Vec_PtrForEachEntry( char *, p->vPlugInComBinPairs, pTemp, i )
+ ABC_FREE( pTemp );
+ Vec_PtrFree( p->vPlugInComBinPairs );
+ }
Abc_FrameDeleteAllNetworks( p );
+ ABC_FREE( p->pCex );
ABC_FREE( p );
s_GlobalFrame = NULL;
}
@@ -187,7 +208,25 @@ void Abc_FrameRestart( Abc_Frame_t * p )
SeeAlso []
***********************************************************************/
-bool Abc_FrameShowProgress( Abc_Frame_t * p )
+void Abc_FrameClearVerifStatus( Abc_Frame_t * p )
+{
+ p->nFrames = -1;
+ p->Status = -1;
+ ABC_FREE( p->pCex );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_FrameShowProgress( Abc_Frame_t * p )
{
return Abc_FrameIsFlagEnabled( "progressbar" );
}
@@ -275,10 +314,10 @@ int Abc_FrameReadMode( Abc_Frame_t * p )
SeeAlso []
***********************************************************************/
-bool Abc_FrameSetMode( Abc_Frame_t * p, bool fNameMode )
+int Abc_FrameSetMode( Abc_Frame_t * p, int fNameMode )
{
char Buffer[2];
- bool fNameModeOld;
+ int fNameModeOld;
fNameModeOld = Abc_FrameReadMode( p );
Buffer[0] = '0' + fNameMode;
Buffer[1] = 0;
@@ -536,7 +575,7 @@ void Abc_FrameSetSave1( void * pAig )
{
Abc_Frame_t * pFrame = Abc_FrameGetGlobalFrame();
if ( pFrame->pSave1 )
- Aig_ManStop( pFrame->pSave1 );
+ Aig_ManStop( (Aig_Man_t *)pFrame->pSave1 );
pFrame->pSave1 = pAig;
}
@@ -555,7 +594,7 @@ void Abc_FrameSetSave2( void * pAig )
{
Abc_Frame_t * pFrame = Abc_FrameGetGlobalFrame();
if ( pFrame->pSave2 )
- Aig_ManStop( pFrame->pSave2 );
+ Aig_ManStop( (Aig_Man_t *)pFrame->pSave2 );
pFrame->pSave2 = pAig;
}
@@ -578,3 +617,5 @@ void * Abc_FrameReadSave2() { void * pAig = Abc_FrameGetGlobalFrame()->pSave2;
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/main/mainInit.c b/src/base/main/mainInit.c
index 03953e5b..a6f4b9e1 100644
--- a/src/base/main/mainInit.c
+++ b/src/base/main/mainInit.c
@@ -18,8 +18,12 @@
***********************************************************************/
+#include "abc.h"
#include "mainInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -38,8 +42,10 @@ extern void Mio_Init( Abc_Frame_t * pAbc );
extern void Mio_End ( Abc_Frame_t * pAbc );
extern void Super_Init( Abc_Frame_t * pAbc );
extern void Super_End ( Abc_Frame_t * pAbc );
-extern void Libs_Init(Abc_Frame_t * pAbc);
-extern void Libs_End(Abc_Frame_t * pAbc);
+extern void Libs_Init( Abc_Frame_t * pAbc );
+extern void Libs_End( Abc_Frame_t * pAbc );
+extern void Load_Init( Abc_Frame_t * pAbc );
+extern void Load_End( Abc_Frame_t * pAbc );
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
@@ -59,6 +65,7 @@ extern void Libs_End(Abc_Frame_t * pAbc);
void Abc_FrameInit( Abc_Frame_t * pAbc )
{
Cmd_Init( pAbc );
+ Cmd_CommandExecute( pAbc, "set checkread" );
Io_Init( pAbc );
Abc_Init( pAbc );
Fpga_Init( pAbc );
@@ -66,6 +73,8 @@ void Abc_FrameInit( Abc_Frame_t * pAbc )
Mio_Init( pAbc );
Super_Init( pAbc );
Libs_Init( pAbc );
+ Load_Init( pAbc );
+ EXT_ABC_INIT(pAbc) // plugin for external functionality
}
@@ -90,6 +99,8 @@ void Abc_FrameEnd( Abc_Frame_t * pAbc )
Mio_End( pAbc );
Super_End( pAbc );
Libs_End( pAbc );
+ Load_End( pAbc );
+ EXT_ABC_END(pAbc) // plugin for external functionality
}
@@ -98,3 +109,5 @@ void Abc_FrameEnd( Abc_Frame_t * pAbc )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/main/mainInt.h b/src/base/main/mainInt.h
index 01bf5eb2..21fe407d 100644
--- a/src/base/main/mainInt.h
+++ b/src/base/main/mainInt.h
@@ -20,12 +20,24 @@
#ifndef __MAIN_INT_H__
#define __MAIN_INT_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
#include "main.h"
+#include "tim.h"
+#include "if.h"
+#include "aig.h"
+#include "gia.h"
+#include "ssw.h"
+#include "fra.h"
+#include "nwkMerge.h"
+#include "ntlnwk.h"
+#include "ext.h"
+
+ABC_NAMESPACE_HEADER_START
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
@@ -75,21 +87,33 @@ struct Abc_Frame_t_
void * pLibVer; // the current Verilog library
// new code
- void * pAbc8Ntl; // the current design
- void * pAbc8Nwk; // the current mapped network
- void * pAbc8Aig; // the current AIG
- void * pAbc8Lib; // the current LUT library
- void * pAig;
- void * pCex;
+ Ntl_Man_t * pAbc8Ntl; // the current design
+ Nwk_Man_t * pAbc8Nwk; // the current mapped network
+ Aig_Man_t * pAbc8Aig; // the current AIG
+ If_Lib_t * pAbc8Lib; // the current LUT library
+
+ EXT_ABC_FRAME // plugin for external functionality
+ If_Lib_t * pAbc85Lib; // the current LUT library
+
+ Gia_Man_t * pGia;
+ Gia_Man_t * pGia2;
+ Abc_Cex_t * pCex;
void * pSave1;
void * pSave2;
void * pSave3;
void * pSave4;
+ // related to LTL
+ Vec_Ptr_t * vLTLProperties_global;
+
// the addition to keep the best Ntl that can be used to restore
void * pAbc8NtlBestDelay; // the best delay, Ntl
void * pAbc8NtlBestArea; // the best area
+ int Status; // the status of verification problem (proved=1, disproved=0, undecided=-1)
+ int nFrames; // the number of time frames completed by BMC
+
+ Vec_Ptr_t * vPlugInComBinPairs; // pairs of command and its binary name
};
////////////////////////////////////////////////////////////////////////
@@ -120,6 +144,10 @@ extern ABC_DLL void Abc_UtilsPrintHello( Abc_Frame_t * pAbc );
extern ABC_DLL void Abc_UtilsPrintUsage( Abc_Frame_t * pAbc, char * ProgName );
extern ABC_DLL void Abc_UtilsSource( Abc_Frame_t * pAbc );
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif
////////////////////////////////////////////////////////////////////////
diff --git a/src/base/main/mainLib.c b/src/base/main/mainLib.c
new file mode 100644
index 00000000..39078ed9
--- /dev/null
+++ b/src/base/main/mainLib.c
@@ -0,0 +1,93 @@
+/**CFile****************************************************************
+
+ FileName [main.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [The main package.]
+
+ Synopsis [Here everything starts.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: main.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "abc.h"
+#include "mainInt.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Initialization procedure for the library project.]
+
+ Description [Note that when Abc_Start() is run in a static library
+ project, it does not load the resource file by default. As a result,
+ ABC is not set up the same way, as when it is run on a command line.
+ For example, some error messages while parsing files will not be
+ produced, and intermediate networks will not be checked for consistancy.
+ One possibility is to load the resource file after Abc_Start() as follows:
+ Abc_UtilsSource( Abc_FrameGetGlobalFrame() );]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Abc_Start()
+{
+ Abc_Frame_t * pAbc;
+ // added to detect memory leaks:
+#if defined(_DEBUG) && defined(_MSC_VER)
+ _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
+#endif
+ // start the glocal frame
+ pAbc = Abc_FrameGetGlobalFrame();
+ // source the resource file
+// Abc_UtilsSource( pAbc );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Deallocation procedure for the library project.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Abc_Stop()
+{
+ Abc_Frame_t * pAbc;
+ pAbc = Abc_FrameGetGlobalFrame();
+ // perform uninitializations
+ Abc_FrameEnd( pAbc );
+ // stop the framework
+ Abc_FrameDeallocate( pAbc );
+}
+
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/main/mainMC.c b/src/base/main/mainMC.c
index 7761d428..5e77db57 100644
--- a/src/base/main/mainMC.c
+++ b/src/base/main/mainMC.c
@@ -24,6 +24,9 @@
#include "fra.h"
#include "ioa.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -196,3 +199,5 @@ int main( int argc, char * argv[] )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/main/mainUtils.c b/src/base/main/mainUtils.c
index f6751b6b..dadcbdd1 100644
--- a/src/base/main/mainUtils.c
+++ b/src/base/main/mainUtils.c
@@ -7,7 +7,7 @@
PackageName [The main package.]
Synopsis [Miscellaneous utilities.]
-
+
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
@@ -18,6 +18,7 @@
***********************************************************************/
+#include "abc.h"
#include "mainInt.h"
#ifndef _WIN32
@@ -25,10 +26,14 @@
#include <readline/history.h>
#endif
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
-static char * DateReadFromDateString(char * datestr);
+
+static char * DateReadFromDateString( char * datestr );
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
@@ -181,6 +186,22 @@ void Abc_UtilsSource( Abc_Frame_t * pAbc )
}
#endif
+#ifdef ABC_PYTHON_EMBED
+ if ( getenv("ABC_PYTHON_ABC_RC") )
+ {
+ /* read script file from $ABC_PYTHON_ABC_RC */
+
+ char * sPath = getenv("ABC_PYTHON_ABC_RC");
+
+ if (sPath){
+ char * sCmd = ABC_ALLOC(char, strlen(sPath) + 50);
+ (void) sprintf(sCmd, "source -s %s", sPath);
+ (void) Cmd_CommandExecute(pAbc, sCmd);
+ ABC_FREE(sCmd);
+ }
+ }
+ else
+#endif /* #ifdef ABC_PYTHON_EMBED */
{
char * sPath1, * sPath2;
char * home;
@@ -228,13 +249,13 @@ void Abc_UtilsSource( Abc_Frame_t * pAbc )
/* execute the abc script which can be open with the "open_path" */
Cmd_CommandExecute( pAbc, "source -s abc.rc" );
}
-
+
#endif //WIN32
{
// reset command history
char * pName;
int i;
- Vec_PtrForEachEntry( pAbc->aHistory, pName, i )
+ Vec_PtrForEachEntry( char *, pAbc->aHistory, pName, i )
ABC_FREE( pName );
pAbc->aHistory->nSize = 0;
}
@@ -250,9 +271,7 @@ void Abc_UtilsSource( Abc_Frame_t * pAbc )
SideEffects []
******************************************************************************/
-char *
-DateReadFromDateString(
- char * datestr)
+char * DateReadFromDateString( char * datestr )
{
static char result[25];
char day[10];
@@ -291,3 +310,5 @@ DateReadFromDateString(
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/main/module.make b/src/base/main/module.make
index 367f89f6..3d03cc12 100644
--- a/src/base/main/module.make
+++ b/src/base/main/module.make
@@ -1,5 +1,6 @@
SRC += src/base/main/main.c \
src/base/main/mainFrame.c \
src/base/main/mainInit.c \
+ src/base/main/mainLib.c \
src/base/main/libSupport.c \
src/base/main/mainUtils.c
diff --git a/src/base/seq/seq.h b/src/base/seq/seq.h
index 3faca29e..7faefe19 100644
--- a/src/base/seq/seq.h
+++ b/src/base/seq/seq.h
@@ -21,6 +21,7 @@
#ifndef __SEQ_H__
#define __SEQ_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -29,9 +30,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -70,7 +72,7 @@ extern void Seq_NtkSkewForward( Abc_Ntk_t * pNtk, float period, int f
/*=== abcSeq.c ===============================================================*/
extern Abc_Ntk_t * Abc_NtkAigToSeq( Abc_Ntk_t * pNtk );
extern Abc_Ntk_t * Abc_NtkSeqToLogicSop( Abc_Ntk_t * pNtk );
-extern bool Abc_NtkSeqCheck( Abc_Ntk_t * pNtk );
+extern int Abc_NtkSeqCheck( Abc_Ntk_t * pNtk );
/*=== seqShare.c =============================================================*/
extern void Seq_NtkShareFanouts( Abc_Ntk_t * pNtk );
extern void Seq_NtkShareLatches( Abc_Ntk_t * pNtkNew, Abc_Ntk_t * pNtk );
@@ -89,9 +91,11 @@ extern int Seq_MapComputeAreaFlows( Abc_Ntk_t * pNtk, int fVerbose )
extern Vec_Ptr_t * Seq_NtkReachNodes( Abc_Ntk_t * pNtk, int fFromPos );
extern int Seq_NtkCleanup( Abc_Ntk_t * pNtk, int fVerbose );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/base/seq/seqAigCore.c b/src/base/seq/seqAigCore.c
index 42fa14a2..ce4563f9 100644
--- a/src/base/seq/seqAigCore.c
+++ b/src/base/seq/seqAigCore.c
@@ -20,6 +20,9 @@
#include "seqInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -43,8 +46,8 @@ static int Abc_ObjRetimeBackward( Abc_Obj_t * pObj, Abc_Ntk_t * pNtk, st
static void Abc_ObjRetimeBackwardUpdateEdge( Abc_Obj_t * pObj, int Edge, stmm_table * tTable );
static void Abc_NtkRetimeSetInitialValues( Abc_Ntk_t * pNtk, stmm_table * tTable, int * pModel );
-static Vec_Ptr_t * Abc_NtkUtilRetimingTry( Abc_Ntk_t * pNtk, bool fForward );
-static Vec_Ptr_t * Abc_NtkUtilRetimingGetMoves( Abc_Ntk_t * pNtk, Vec_Int_t * vSteps, bool fForward );
+static Vec_Ptr_t * Abc_NtkUtilRetimingTry( Abc_Ntk_t * pNtk, int fForward );
+static Vec_Ptr_t * Abc_NtkUtilRetimingGetMoves( Abc_Ntk_t * pNtk, Vec_Int_t * vSteps, int fForward );
static Vec_Int_t * Abc_NtkUtilRetimingSplit( Vec_Str_t * vLags, int fForward );
static void Abc_ObjRetimeForwardTry( Abc_Obj_t * pObj, int nLatches );
static void Abc_ObjRetimeBackwardTry( Abc_Obj_t * pObj, int nLatches );
@@ -102,7 +105,7 @@ void Seq_NtkSeqRetimeForward( Abc_Ntk_t * pNtk, int fInitial, int fVerbose )
// get the forward moves
vMoves = Abc_NtkUtilRetimingTry( pNtk, 1 );
// undo the forward moves
- Vec_PtrForEachEntryReverse( vMoves, pNode, i )
+ Vec_PtrForEachEntryReverse( Abc_Obj_t *, vMoves, pNode, i )
Abc_ObjRetimeBackwardTry( pNode, 1 );
// implement this forward retiming
Seq_NtkImplementRetimingForward( pNtk, vMoves );
@@ -130,7 +133,7 @@ void Seq_NtkSeqRetimeBackward( Abc_Ntk_t * pNtk, int fInitial, int fVerbose )
// get the backward moves
vMoves = Abc_NtkUtilRetimingTry( pNtk, 0 );
// undo the backward moves
- Vec_PtrForEachEntryReverse( vMoves, pNode, i )
+ Vec_PtrForEachEntryReverse( Abc_Obj_t *, vMoves, pNode, i )
Abc_ObjRetimeForwardTry( pNode, 1 );
// implement this backward retiming
RetValue = Seq_NtkImplementRetimingBackward( pNtk, vMoves, fVerbose );
@@ -202,7 +205,7 @@ void Seq_NtkImplementRetimingForward( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMoves )
{
Abc_Obj_t * pNode;
int i;
- Vec_PtrForEachEntry( vMoves, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vMoves, pNode, i )
Abc_ObjRetimeForward( pNode );
}
@@ -309,7 +312,7 @@ int Seq_NtkImplementRetimingBackward( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMoves, int
// perform the backward moves and build the network for initial state computation
RetValue = 0;
- Vec_PtrForEachEntry( vMoves, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vMoves, pNode, i )
RetValue |= Abc_ObjRetimeBackward( pNode, pNtkProb, tTable, vValues );
// add the PIs corresponding to the white spots
@@ -319,7 +322,6 @@ int Seq_NtkImplementRetimingBackward( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMoves, int
// add the PI/PO names
Abc_NtkAddDummyPiNames( pNtkProb );
Abc_NtkAddDummyPoNames( pNtkProb );
- Abc_NtkAddDummyAssertNames( pNtkProb );
// make sure everything is okay with the network structure
if ( !Abc_NtkDoCheck( pNtkProb ) )
@@ -468,7 +470,7 @@ int Abc_ObjRetimeBackward( Abc_Obj_t * pObj, Abc_Ntk_t * pNtkNew, stmm_table * t
// add new AND-gate to the network
pNodeNew = Abc_NtkCreateNode( pNtkNew );
- pNodeNew->pData = Abc_SopCreateAnd2( pNtkNew->pManFunc, Abc_ObjFaninC0(pObj), Abc_ObjFaninC1(pObj) );
+ pNodeNew->pData = Abc_SopCreateAnd2( (Extra_MmFlex_t *)pNtkNew->pManFunc, Abc_ObjFaninC0(pObj), Abc_ObjFaninC1(pObj) );
// add PO fanouts if any
if ( fMet0 )
@@ -536,7 +538,7 @@ int Abc_ObjRetimeBackward( Abc_Obj_t * pObj, Abc_Ntk_t * pNtkNew, stmm_table * t
// add the buffer
pBuffer = Abc_NtkCreateNode( pNtkNew );
- pBuffer->pData = Abc_SopCreateBuf( pNtkNew->pManFunc );
+ pBuffer->pData = Abc_SopCreateBuf( (Extra_MmFlex_t *)pNtkNew->pManFunc );
Abc_ObjAddFanin( pNodeNew, pBuffer );
// point to it from the table
RetEdge.iNode = pObj->Id;
@@ -547,7 +549,7 @@ int Abc_ObjRetimeBackward( Abc_Obj_t * pObj, Abc_Ntk_t * pNtkNew, stmm_table * t
// add the buffer
pBuffer = Abc_NtkCreateNode( pNtkNew );
- pBuffer->pData = Abc_SopCreateBuf( pNtkNew->pManFunc );
+ pBuffer->pData = Abc_SopCreateBuf( (Extra_MmFlex_t *)pNtkNew->pManFunc );
Abc_ObjAddFanin( pNodeNew, pBuffer );
// point to it from the table
RetEdge.iNode = pObj->Id;
@@ -641,7 +643,7 @@ void Abc_NtkRetimeSetInitialValues( Abc_Ntk_t * pNtk, stmm_table * tTable, int *
SeeAlso []
***********************************************************************/
-Vec_Ptr_t * Abc_NtkUtilRetimingTry( Abc_Ntk_t * pNtk, bool fForward )
+Vec_Ptr_t * Abc_NtkUtilRetimingTry( Abc_Ntk_t * pNtk, int fForward )
{
Vec_Ptr_t * vNodes, * vMoves;
Abc_Obj_t * pNode, * pFanout, * pFanin;
@@ -656,7 +658,7 @@ Vec_Ptr_t * Abc_NtkUtilRetimingTry( Abc_Ntk_t * pNtk, bool fForward )
}
// process the nodes
vMoves = Vec_PtrAlloc( 100 );
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
{
// printf( "(%d,%d) ", Seq_ObjFaninL0(pNode), Seq_ObjFaninL0(pNode) );
// unmark the node as processed
@@ -723,7 +725,7 @@ Vec_Ptr_t * Abc_NtkUtilRetimingTry( Abc_Ntk_t * pNtk, bool fForward )
SeeAlso []
***********************************************************************/
-Vec_Ptr_t * Abc_NtkUtilRetimingGetMoves( Abc_Ntk_t * pNtk, Vec_Int_t * vSteps, bool fForward )
+Vec_Ptr_t * Abc_NtkUtilRetimingGetMoves( Abc_Ntk_t * pNtk, Vec_Int_t * vSteps, int fForward )
{
Seq_RetStep_t RetStep;
Vec_Ptr_t * vMoves;
@@ -833,12 +835,12 @@ Vec_Ptr_t * Abc_NtkUtilRetimingGetMoves( Abc_Ntk_t * pNtk, Vec_Int_t * vSteps, b
// undo the tentative retiming
if ( fForward )
{
- Vec_PtrForEachEntryReverse( vMoves, pNode, i )
+ Vec_PtrForEachEntryReverse( Abc_Obj_t *, vMoves, pNode, i )
Abc_ObjRetimeBackwardTry( pNode, 1 );
}
else
{
- Vec_PtrForEachEntryReverse( vMoves, pNode, i )
+ Vec_PtrForEachEntryReverse( Abc_Obj_t *, vMoves, pNode, i )
Abc_ObjRetimeForwardTry( pNode, 1 );
}
return vMoves;
@@ -975,3 +977,5 @@ void Abc_ObjRetimeBackwardTry( Abc_Obj_t * pObj, int nLatches )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/seq/seqAigIter.c b/src/base/seq/seqAigIter.c
index 392638b8..b71312f7 100644
--- a/src/base/seq/seqAigIter.c
+++ b/src/base/seq/seqAigIter.c
@@ -20,6 +20,9 @@
#include "seqInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -266,3 +269,5 @@ int Seq_RetimeNodeUpdateLValue( Abc_Obj_t * pObj, int Fi )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/seq/seqCreate.c b/src/base/seq/seqCreate.c
index 16c7cc92..ec4fa6aa 100644
--- a/src/base/seq/seqCreate.c
+++ b/src/base/seq/seqCreate.c
@@ -20,6 +20,9 @@
#include "seqInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*
A sequential network is similar to AIG in that it contains only
AND gates. However, the AND-gates are currently not hashed.
@@ -269,7 +272,7 @@ Abc_Ntk_t * Abc_NtkSeqToLogicSop( Abc_Ntk_t * pNtk )
Abc_AigForEachAnd( pNtk, pObj, i )
{
Abc_NtkDupObj(pNtkNew, pObj, 0);
- pObj->pCopy->pData = Abc_SopCreateAnd2( pNtkNew->pManFunc, Abc_ObjFaninC0(pObj), Abc_ObjFaninC1(pObj) );
+ pObj->pCopy->pData = Abc_SopCreateAnd2( (Extra_MmFlex_t *)pNtkNew->pManFunc, Abc_ObjFaninC0(pObj), Abc_ObjFaninC1(pObj) );
}
// share and create the latches
Seq_NtkShareLatches( pNtkNew, pNtk );
@@ -344,10 +347,10 @@ Abc_Ntk_t * Abc_NtkSeqToLogicSop_old( Abc_Ntk_t * pNtk )
if ( Abc_ObjFaninNum(pObj) == 1 )
{
assert( !Abc_ObjFaninC0(pObj) );
- pObj->pCopy->pData = Abc_SopCreateBuf( pNtkNew->pManFunc );
+ pObj->pCopy->pData = Abc_SopCreateBuf( (Extra_MmFlex_t *)pNtkNew->pManFunc );
continue;
}
- pObj->pCopy->pData = Abc_SopCreateAnd2( pNtkNew->pManFunc, Abc_ObjFaninC0(pObj), Abc_ObjFaninC1(pObj) );
+ pObj->pCopy->pData = Abc_SopCreateAnd2( (Extra_MmFlex_t *)pNtkNew->pManFunc, Abc_ObjFaninC0(pObj), Abc_ObjFaninC1(pObj) );
}
// connect the objects
Abc_NtkForEachObj( pNtk, pObj, i )
@@ -419,7 +422,7 @@ Abc_Obj_t * Abc_NodeSeqToLogic( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pFanin, Seq_Lat
SeeAlso []
***********************************************************************/
-bool Abc_NtkSeqCheck( Abc_Ntk_t * pNtk )
+int Abc_NtkSeqCheck( Abc_Ntk_t * pNtk )
{
Abc_Obj_t * pObj;
int i, nFanins;
@@ -480,3 +483,5 @@ bool Abc_NtkSeqCheck( Abc_Ntk_t * pNtk )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/seq/seqFpgaCore.c b/src/base/seq/seqFpgaCore.c
index b106ded2..8ab97b43 100644
--- a/src/base/seq/seqFpgaCore.c
+++ b/src/base/seq/seqFpgaCore.c
@@ -20,6 +20,9 @@
#include "seqInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -125,11 +128,11 @@ Abc_Ntk_t * Seq_NtkFpgaDup( Abc_Ntk_t * pNtk )
Seq_Resize( pNtkNew->pManFunc, nObjsNew );
// duplicate the nodes in the mapping
- Vec_PtrForEachEntry( p->vMapAnds, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vMapAnds, pObj, i )
Abc_NtkDupObj( pNtkNew, pObj, 0 );
// recursively construct the internals of each node
- Vec_PtrForEachEntry( p->vMapAnds, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vMapAnds, pObj, i )
{
vLeaves = Vec_VecEntry( p->vMapCuts, i );
Seq_FpgaMappingBuild_rec( pNtkNew, pNtk, pObj->Id << 8, 1, Seq_NodeGetLag(pObj), vLeaves );
@@ -143,12 +146,12 @@ Abc_Ntk_t * Seq_NtkFpgaDup( Abc_Ntk_t * pNtk )
Seq_NodeDupLats( pObj->pCopy, pObj, 0 );
// transfer the mapping info to the new manager
- Vec_PtrForEachEntry( p->vMapAnds, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vMapAnds, pObj, i )
{
// get the leaves of the cut
vLeaves = Vec_VecEntry( p->vMapCuts, i );
// convert the leaf nodes
- Vec_PtrForEachEntry( vLeaves, pLeaf, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pLeaf, k )
{
SeqEdge = (unsigned)pLeaf;
pLeaf = Abc_NtkObj( pNtk, SeqEdge >> 8 );
@@ -198,7 +201,7 @@ int Seq_NtkFpgaInitCompatible( Abc_Ntk_t * pNtk, int fVerbose )
vTotalEdges = Vec_VecStart( p->nVarsMax );
// go through all the nodes (cuts) used in the mapping
- Vec_PtrForEachEntry( p->vMapAnds, pAnd, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vMapAnds, pAnd, i )
{
// printf( "*** Node %d.\n", pAnd->Id );
@@ -210,7 +213,7 @@ int Seq_NtkFpgaInitCompatible( Abc_Ntk_t * pNtk, int fVerbose )
Seq_FpgaMappingEdges_rec( pNtk, pAnd->Id << 8, NULL, vLeaves, vTotalEdges );
// for each leaf, consider its edges
- Vec_PtrForEachEntry( vLeaves, pLeaf, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pLeaf, k )
{
SeqEdge = (unsigned)pLeaf;
pLeaf = Abc_NtkObj( pNtk, SeqEdge >> 8 );
@@ -221,7 +224,7 @@ int Seq_NtkFpgaInitCompatible( Abc_Ntk_t * pNtk, int fVerbose )
// go through the edges
vEdges = Vec_VecEntry( vTotalEdges, k );
pFanout0 = NULL;
- Vec_PtrForEachEntry( vEdges, pFanout1, m )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vEdges, pFanout1, m )
{
Edge1 = Abc_ObjIsComplement(pFanout1);
pFanout1 = Abc_ObjRegular(pFanout1);
@@ -290,14 +293,14 @@ Abc_Ntk_t * Seq_NtkSeqFpgaMapped( Abc_Ntk_t * pNtk )
pNtkMap = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_BDD );
// duplicate the nodes used in the mapping
- Vec_PtrForEachEntry( p->vMapAnds, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vMapAnds, pObj, i )
pObj->pCopy = Abc_NtkCreateNode( pNtkMap );
// create and share the latches
Seq_NtkShareLatchesMapping( pNtkMap, pNtk, p->vMapAnds, 1 );
// connect the nodes
- Vec_PtrForEachEntry( p->vMapAnds, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vMapAnds, pObj, i )
{
// get the leaves of this gate
vLeaves = Vec_VecEntry( p->vMapCuts, i );
@@ -350,7 +353,7 @@ int Seq_FpgaMappingCount( Abc_Ntk_t * pNtk )
Vec_Ptr_t * vLeaves;
Abc_Obj_t * pAnd;
int i, Counter = 0;
- Vec_PtrForEachEntry( p->vMapAnds, pAnd, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vMapAnds, pAnd, i )
{
vLeaves = Vec_VecEntry( p->vMapCuts, i );
Counter += Seq_FpgaMappingCount_rec( pNtk, pAnd->Id << 8, vLeaves );
@@ -378,7 +381,7 @@ int Seq_FpgaMappingCount_rec( Abc_Ntk_t * pNtk, unsigned SeqEdge, Vec_Ptr_t * vL
pObj = Abc_NtkObj( pNtk, SeqEdge >> 8 );
Lag = SeqEdge & 255;
// if the node is the fanin of the cut, return
- Vec_PtrForEachEntry( vLeaves, pLeaf, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pLeaf, i )
if ( SeqEdge == (unsigned)pLeaf )
return 0;
// continue unfolding
@@ -413,7 +416,7 @@ Abc_Obj_t * Seq_FpgaMappingBuild_rec( Abc_Ntk_t * pNtkNew, Abc_Ntk_t * pNtk, uns
pObj = Abc_NtkObj( pNtk, SeqEdge >> 8 );
Lag = SeqEdge & 255;
// if the node is the fanin of the cut, return
- Vec_PtrForEachEntry( vLeaves, pLeaf, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pLeaf, i )
if ( SeqEdge == (unsigned)pLeaf )
return pObj->pCopy;
// continue unfolding
@@ -460,7 +463,7 @@ DdNode * Seq_FpgaMappingBdd_rec( DdManager * dd, Abc_Ntk_t * pNtk, unsigned SeqE
pObj = Abc_NtkObj( pNtk, SeqEdge >> 8 );
Lag = SeqEdge & 255;
// if the node is the fanin of the cut, return
- Vec_PtrForEachEntry( vLeaves, pLeaf, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pLeaf, i )
if ( SeqEdge == (unsigned)pLeaf )
return Cudd_bddIthVar( dd, i );
// continue unfolding
@@ -504,7 +507,7 @@ void Seq_FpgaMappingEdges_rec( Abc_Ntk_t * pNtk, unsigned SeqEdge, Abc_Obj_t * p
pObj = Abc_NtkObj( pNtk, SeqEdge >> 8 );
Lag = SeqEdge & 255;
// if the node is the fanin of the cut, return
- Vec_PtrForEachEntry( vLeaves, pLeaf, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pLeaf, i )
{
if ( SeqEdge == (unsigned)pLeaf )
{
@@ -546,7 +549,7 @@ void Seq_FpgaMappingConnect_rec( Abc_Ntk_t * pNtk, unsigned SeqEdge, Abc_Obj_t *
pObj = Abc_NtkObj( pNtk, SeqEdge >> 8 );
Lag = SeqEdge & 255;
// if the node is the fanin of the cut, add the connection and return
- Vec_PtrForEachEntry( vLeaves, pLeaf, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pLeaf, i )
{
if ( SeqEdge == (unsigned)pLeaf )
{
@@ -598,7 +601,7 @@ DdNode * Seq_FpgaMappingConnectBdd_rec( Abc_Ntk_t * pNtk, unsigned SeqEdge, Abc_
pObj = Abc_NtkObj( pNtk, SeqEdge >> 8 );
Lag = SeqEdge & 255;
// if the node is the fanin of the cut, add the connection and return
- Vec_PtrForEachEntry( vLeaves, pLeaf, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pLeaf, i )
{
if ( SeqEdge == (unsigned)pLeaf )
{
@@ -641,3 +644,5 @@ DdNode * Seq_FpgaMappingConnectBdd_rec( Abc_Ntk_t * pNtk, unsigned SeqEdge, Abc_
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/seq/seqFpgaIter.c b/src/base/seq/seqFpgaIter.c
index a300b362..c4551a73 100644
--- a/src/base/seq/seqFpgaIter.c
+++ b/src/base/seq/seqFpgaIter.c
@@ -22,6 +22,9 @@
#include "main.h"
#include "fpga.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -268,3 +271,5 @@ int Seq_FpgaNodeUpdateLValue( Abc_Obj_t * pObj, int Fi )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/seq/seqInt.h b/src/base/seq/seqInt.h
index daa2ab38..89ce6843 100644
--- a/src/base/seq/seqInt.h
+++ b/src/base/seq/seqInt.h
@@ -21,6 +21,7 @@
#ifndef __SEQ_INT_H__
#define __SEQ_INT_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -37,9 +38,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
#define SEQ_FULL_MASK 0xFFFFFFFF
@@ -244,9 +246,11 @@ extern int Seq_ObjFanoutLMin( Abc_Obj_t * pObj );
extern int Seq_ObjFanoutLSum( Abc_Obj_t * pObj );
extern int Seq_ObjFaninLSum( Abc_Obj_t * pObj );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/base/seq/seqLatch.c b/src/base/seq/seqLatch.c
index cb3e1e36..f6384fcb 100644
--- a/src/base/seq/seqLatch.c
+++ b/src/base/seq/seqLatch.c
@@ -20,6 +20,9 @@
#include "seqInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -221,3 +224,5 @@ int Seq_NodeCompareLats( Abc_Obj_t * pObj1, int Edge1, Abc_Obj_t * pObj2, int Ed
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/seq/seqMan.c b/src/base/seq/seqMan.c
index bdfb2630..d0697b36 100644
--- a/src/base/seq/seqMan.c
+++ b/src/base/seq/seqMan.c
@@ -20,6 +20,9 @@
#include "seqInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -107,7 +110,7 @@ void Seq_Delete( Abc_Seq_t * p )
if ( p->fStandCells && p->vMapAnds )
{
void * pVoid; int i;
- Vec_PtrForEachEntry( p->vMapAnds, pVoid, i )
+ Vec_PtrForEachEntry( void *, p->vMapAnds, pVoid, i )
free( pVoid );
}
if ( p->vMapDelays ) Vec_VecFree( p->vMapDelays ); // the nodes used in the mapping
@@ -131,3 +134,5 @@ void Seq_Delete( Abc_Seq_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/seq/seqMapCore.c b/src/base/seq/seqMapCore.c
index c465f31f..cd1db3a7 100644
--- a/src/base/seq/seqMapCore.c
+++ b/src/base/seq/seqMapCore.c
@@ -23,6 +23,9 @@
#include "mio.h"
#include "mapper.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -137,7 +140,7 @@ Abc_Ntk_t * Seq_NtkMapDup( Abc_Ntk_t * pNtk )
Seq_Resize( pNtkNew->pManFunc, nObjsNew );
// duplicate the nodes in the mapping
- Vec_PtrForEachEntry( p->vMapAnds, pMatch, i )
+ Vec_PtrForEachEntry( Seq_Match_t *, p->vMapAnds, pMatch, i )
{
// Abc_NtkDupObj( pNtkNew, pMatch->pAnd );
if ( !pMatch->fCompl )
@@ -147,13 +150,13 @@ Abc_Ntk_t * Seq_NtkMapDup( Abc_Ntk_t * pNtk )
}
// compute the real phase assignment
- Vec_PtrForEachEntry( p->vMapAnds, pMatch, i )
+ Vec_PtrForEachEntry( Seq_Match_t *, p->vMapAnds, pMatch, i )
{
pMatch->uPhaseR = 0;
// get the leaves of the cut
vLeaves = Vec_VecEntry( p->vMapCuts, i );
// convert the leaf nodes
- Vec_PtrForEachEntry( vLeaves, pLeaf, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pLeaf, k )
{
SeqEdge = (unsigned)pLeaf;
pLeaf = Abc_NtkObj( pNtk, SeqEdge >> 8 );
@@ -178,7 +181,7 @@ Abc_Ntk_t * Seq_NtkMapDup( Abc_Ntk_t * pNtk )
// recursively construct the internals of each node
- Vec_PtrForEachEntry( p->vMapAnds, pMatch, i )
+ Vec_PtrForEachEntry( Seq_Match_t *, p->vMapAnds, pMatch, i )
{
// if ( pMatch->pSuper == NULL )
// {
@@ -210,12 +213,12 @@ Abc_Ntk_t * Seq_NtkMapDup( Abc_Ntk_t * pNtk )
Seq_NodeDupLats( pObj->pCopy, pObj, 0 );
// transfer the mapping info to the new manager
- Vec_PtrForEachEntry( p->vMapAnds, pMatch, i )
+ Vec_PtrForEachEntry( Seq_Match_t *, p->vMapAnds, pMatch, i )
{
// get the leaves of the cut
vLeaves = Vec_VecEntry( p->vMapCuts, i );
// convert the leaf nodes
- Vec_PtrForEachEntry( vLeaves, pLeaf, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pLeaf, k )
{
SeqEdge = (unsigned)pLeaf;
pLeaf = Abc_NtkObj( pNtk, SeqEdge >> 8 );
@@ -286,7 +289,7 @@ int Seq_NtkMapInitCompatible( Abc_Ntk_t * pNtk, int fVerbose )
vTotalEdges = Vec_VecStart( p->nVarsMax );
// go through all the nodes (cuts) used in the mapping
- Vec_PtrForEachEntry( p->vMapAnds, pMatch, i )
+ Vec_PtrForEachEntry( Seq_Match_t *, p->vMapAnds, pMatch, i )
{
pAnd = pMatch->pAnd;
// printf( "*** Node %d.\n", pAnd->Id );
@@ -299,7 +302,7 @@ int Seq_NtkMapInitCompatible( Abc_Ntk_t * pNtk, int fVerbose )
Seq_MapMappingEdges_rec( pNtk, pAnd->Id << 8, NULL, vLeaves, vTotalEdges );
// for each leaf, consider its edges
- Vec_PtrForEachEntry( vLeaves, pLeaf, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pLeaf, k )
{
SeqEdge = (unsigned)pLeaf;
pLeaf = Abc_NtkObj( pNtk, SeqEdge >> 8 );
@@ -310,7 +313,7 @@ int Seq_NtkMapInitCompatible( Abc_Ntk_t * pNtk, int fVerbose )
// go through the edges
vEdges = Vec_VecEntry( vTotalEdges, k );
pFanout0 = NULL;
- Vec_PtrForEachEntry( vEdges, pFanout1, m )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vEdges, pFanout1, m )
{
Edge1 = Abc_ObjIsComplement(pFanout1);
pFanout1 = Abc_ObjRegular(pFanout1);
@@ -380,14 +383,14 @@ Abc_Ntk_t * Seq_NtkSeqMapMapped( Abc_Ntk_t * pNtk )
pNtkMap = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_BDD );
// duplicate the nodes used in the mapping
- Vec_PtrForEachEntry( p->vMapAnds, pMatch, i )
+ Vec_PtrForEachEntry( Seq_Match_t *, p->vMapAnds, pMatch, i )
pMatch->pAnd->pCopy = Abc_NtkCreateNode( pNtkMap );
// create and share the latches
Seq_NtkShareLatchesMapping( pNtkMap, pNtk, p->vMapAnds, 0 );
// connect the nodes
- Vec_PtrForEachEntry( p->vMapAnds, pMatch, i )
+ Vec_PtrForEachEntry( Seq_Match_t *, p->vMapAnds, pMatch, i )
{
pObj = pMatch->pAnd;
// get the leaves of this gate
@@ -442,7 +445,7 @@ int Seq_MapMappingCount( Abc_Ntk_t * pNtk )
Vec_Ptr_t * vLeaves;
Seq_Match_t * pMatch;
int i, Counter = 0;
- Vec_PtrForEachEntry( p->vMapAnds, pMatch, i )
+ Vec_PtrForEachEntry( Seq_Match_t *, p->vMapAnds, pMatch, i )
{
vLeaves = Vec_VecEntry( p->vMapCuts, i );
Counter += Seq_MapMappingCount_rec( pNtk, pMatch->pAnd->Id << 8, vLeaves );
@@ -470,7 +473,7 @@ int Seq_MapMappingCount_rec( Abc_Ntk_t * pNtk, unsigned SeqEdge, Vec_Ptr_t * vLe
pObj = Abc_NtkObj( pNtk, SeqEdge >> 8 );
Lag = SeqEdge & 255;
// if the node is the fanin of the cut, return
- Vec_PtrForEachEntry( vLeaves, pLeaf, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pLeaf, i )
if ( SeqEdge == (unsigned)pLeaf )
return 0;
// continue unfolding
@@ -505,7 +508,7 @@ Abc_Obj_t * Seq_MapMappingBuild_rec( Abc_Ntk_t * pNtkNew, Abc_Ntk_t * pNtk, unsi
pObj = Abc_NtkObj( pNtk, SeqEdge >> 8 );
Lag = SeqEdge & 255;
// if the node is the fanin of the cut, return
- Vec_PtrForEachEntry( vLeaves, pLeaf, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pLeaf, i )
if ( SeqEdge == (unsigned)pLeaf )
{
// if ( uPhase & (1 << i) ) // negative phase is required
@@ -562,7 +565,7 @@ void Seq_MapMappingEdges_rec( Abc_Ntk_t * pNtk, unsigned SeqEdge, Abc_Obj_t * pP
pObj = Abc_NtkObj( pNtk, SeqEdge >> 8 );
Lag = SeqEdge & 255;
// if the node is the fanin of the cut, return
- Vec_PtrForEachEntry( vLeaves, pLeaf, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pLeaf, i )
{
if ( SeqEdge == (unsigned)pLeaf )
{
@@ -606,7 +609,7 @@ DdNode * Seq_MapMappingConnectBdd_rec( Abc_Ntk_t * pNtk, unsigned SeqEdge, Abc_O
pObj = Abc_NtkObj( pNtk, SeqEdge >> 8 );
Lag = SeqEdge & 255;
// if the node is the fanin of the cut, add the connection and return
- Vec_PtrForEachEntry( vLeaves, pLeaf, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pLeaf, i )
{
if ( SeqEdge == (unsigned)pLeaf )
{
@@ -650,3 +653,5 @@ DdNode * Seq_MapMappingConnectBdd_rec( Abc_Ntk_t * pNtk, unsigned SeqEdge, Abc_O
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/seq/seqMapIter.c b/src/base/seq/seqMapIter.c
index 30333cea..bb762d62 100644
--- a/src/base/seq/seqMapIter.c
+++ b/src/base/seq/seqMapIter.c
@@ -23,6 +23,9 @@
#include "mio.h"
#include "mapperInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
// the internal procedures
static float Seq_MapRetimeDelayLagsInternal( Abc_Ntk_t * pNtk, int fVerbose );
static float Seq_MapRetimeSearch_rec( Abc_Ntk_t * pNtk, float FiMin, float FiMax, float Delta, int fVerbose );
@@ -621,3 +624,5 @@ void Seq_MapCanonicizeTruthTables( Abc_Ntk_t * pNtk )
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/seq/seqMaxMeanCycle.c b/src/base/seq/seqMaxMeanCycle.c
index 46d73cbd..b62e4b33 100644
--- a/src/base/seq/seqMaxMeanCycle.c
+++ b/src/base/seq/seqMaxMeanCycle.c
@@ -21,6 +21,9 @@
#include "seqInt.h"
#include "hash.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -350,7 +353,7 @@ Hash_Ptr_t * Seq_NtkPathDelays( Abc_Ntk_t * pNtk, int fVerbose ) {
Abc_NodeDelayTraceArrival( vNodes->pArray[i] );
// there is a path to each set of Co endpoints
- Vec_PtrForEachEntry( vEndpoints, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vEndpoints, pObj, i )
{
assert(pObj);
assert( Abc_ObjIsCo( pObj ) );
@@ -565,3 +568,5 @@ void Seq_NtkSkewForward( Abc_Ntk_t * pNtk, float period, int fMinimize ) {
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/seq/seqRetCore.c b/src/base/seq/seqRetCore.c
index ddc92cc8..846a6707 100644
--- a/src/base/seq/seqRetCore.c
+++ b/src/base/seq/seqRetCore.c
@@ -21,6 +21,9 @@
#include "seqInt.h"
#include "dec.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -136,7 +139,7 @@ Abc_Ntk_t * Seq_NtkRetimeDerive( Abc_Ntk_t * pNtk, int fVerbose )
// create one AND for each logic node in the topological order
vMapAnds = Abc_NtkDfs( pNtk, 0 );
- Vec_PtrForEachEntry( vMapAnds, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vMapAnds, pObj, i )
{
if ( pObj->Id == 0 )
{
@@ -159,7 +162,7 @@ Abc_Ntk_t * Seq_NtkRetimeDerive( Abc_Ntk_t * pNtk, int fVerbose )
// create internal AND nodes w/o strashing for each logic node (including constants)
vMapFanins = Vec_VecStart( Vec_PtrSize(vMapAnds) );
- Vec_PtrForEachEntry( vMapAnds, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vMapAnds, pObj, i )
{
// get the SOP of the node
if ( Abc_NtkHasMapping(pNtk) )
@@ -179,7 +182,7 @@ Abc_Ntk_t * Seq_NtkRetimeDerive( Abc_Ntk_t * pNtk, int fVerbose )
Seq_Resize( p, Abc_NtkObjNumMax(pNtkNew) );
// add the sequential edges
- Vec_PtrForEachEntry( vMapAnds, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vMapAnds, pObj, i )
{
vMirrors = Vec_VecEntry( vMapFanins, i );
Abc_ObjForEachFanin( pObj, pFanin, k )
@@ -206,7 +209,7 @@ Abc_Ntk_t * Seq_NtkRetimeDerive( Abc_Ntk_t * pNtk, int fVerbose )
p->vMapFanins = vMapFanins;
p->vMapCuts = Vec_VecStart( Vec_PtrSize(p->vMapAnds) );
p->vMapDelays = Vec_VecStart( Vec_PtrSize(p->vMapAnds) );
- Vec_PtrForEachEntry( p->vMapAnds, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vMapAnds, pObj, i )
{
// change the node to be the new one
Vec_PtrWriteEntry( p->vMapAnds, i, pObj->pCopy );
@@ -366,7 +369,7 @@ Abc_Ntk_t * Seq_NtkRetimeReconstruct( Abc_Ntk_t * pNtkOld, Abc_Ntk_t * pNtkSeq )
// connect the objects
// Abc_NtkForEachNode( pNtkOld, pObj, i )
- Vec_PtrForEachEntry( p->vMapAnds, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vMapAnds, pObj, i )
{
// pObj is from pNtkSeq - transform to pNtkOld
pObj = pObj->pNext;
@@ -491,3 +494,5 @@ Abc_Obj_t * Seq_EdgeReconstructPO( Abc_Obj_t * pNode )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/seq/seqRetIter.c b/src/base/seq/seqRetIter.c
index 99c50914..816e71a1 100644
--- a/src/base/seq/seqRetIter.c
+++ b/src/base/seq/seqRetIter.c
@@ -22,6 +22,9 @@
#include "main.h"
#include "fpga.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -106,21 +109,21 @@ int Seq_NtkRetimeDelayLags( Abc_Ntk_t * pNtkOld, Abc_Ntk_t * pNtk, int fVerbose
assert( RetValue );
// fix the problem with non-converged delays
- Vec_PtrForEachEntry( p->vMapAnds, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vMapAnds, pNode, i )
if ( Seq_NodeGetLValueP(pNode) < -ABC_INFINITY/2 )
Seq_NodeSetLValueP( pNode, 0 );
// experiment by adding an epsilon to all LValues
-// Vec_PtrForEachEntry( p->vMapAnds, pNode, i )
+// Vec_PtrForEachEntry( Abc_Obj_t *, p->vMapAnds, pNode, i )
// Seq_NodeSetLValueP( pNode, Seq_NodeGetLValueP(pNode) - p->fEpsilon );
// save the retiming lags
// mark the nodes
- Vec_PtrForEachEntry( p->vMapAnds, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vMapAnds, pNode, i )
pNode->fMarkA = 1;
// process the nodes
Vec_StrFill( p->vLags, p->nSize, 0 );
- Vec_PtrForEachEntry( p->vMapAnds, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vMapAnds, pNode, i )
{
if ( Vec_PtrSize( Vec_VecEntry(p->vMapCuts, i) ) == 0 )
{
@@ -131,7 +134,7 @@ int Seq_NtkRetimeDelayLags( Abc_Ntk_t * pNtkOld, Abc_Ntk_t * pNtk, int fVerbose
Seq_NodeRetimeSetLag_rec( pNode, NodeLag );
}
// unmark the nodes
- Vec_PtrForEachEntry( p->vMapAnds, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vMapAnds, pNode, i )
pNode->fMarkA = 0;
// print the result
@@ -208,7 +211,7 @@ int Seq_NtkMappingForPeriod( Abc_Ntk_t * pNtk, float Fi, int fVerbose )
for ( c = 0; c < p->nMaxIters; c++ )
{
fChange = 0;
- Vec_PtrForEachEntry( p->vMapAnds, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vMapAnds, pObj, i )
{
Counter++;
vLeaves = Vec_VecEntry( p->vMapCuts, i );
@@ -281,7 +284,7 @@ int Seq_NtkNodeUpdateLValue( Abc_Obj_t * pObj, float Fi, Vec_Ptr_t * vLeaves, Ve
}
// get the new arrival time of the cut output
lValueNew = -ABC_INFINITY;
- Vec_PtrForEachEntry( vLeaves, pLeaf, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pLeaf, i )
{
SeqEdge = (unsigned)pLeaf;
pLeaf = Abc_NtkObj( pObj->pNtk, SeqEdge >> 8 );
@@ -354,7 +357,7 @@ void Seq_NodePrintInfo( Abc_Obj_t * pNode )
pNode->Id, Seq_NodeGetLValueP(pNode), Seq_NodeGetLag(pNode) );
// find the number
- Vec_PtrForEachEntry( p->vMapAnds, pObj, Number )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vMapAnds, pObj, Number )
if ( pObj == pNode )
break;
@@ -362,7 +365,7 @@ void Seq_NodePrintInfo( Abc_Obj_t * pNode )
vLeaves = Vec_VecEntry( p->vMapCuts, Number );
// print the leaves
- Vec_PtrForEachEntry( vLeaves, pLeaf, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pLeaf, i )
{
SeqEdge = (unsigned)pLeaf;
pFanin = Abc_NtkObj( pNode->pNtk, SeqEdge >> 8 );
@@ -401,3 +404,5 @@ void Seq_NodePrintInfoPlus( Abc_Obj_t * pNode )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/seq/seqShare.c b/src/base/seq/seqShare.c
index 742de46b..bccfff80 100644
--- a/src/base/seq/seqShare.c
+++ b/src/base/seq/seqShare.c
@@ -20,6 +20,9 @@
#include "seqInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -156,7 +159,7 @@ void Seq_NodeShareOne( Abc_Obj_t * pNode, Abc_InitType_t Init, Vec_Ptr_t * vNode
Seq_NodeInsertFirst( pBuffer, 0, InitNew );
// redirect the fanouts
- Vec_PtrForEachEntry( vNodes, pFanout, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pFanout, i )
Abc_ObjPatchFanin( pFanout, pNode, pBuffer );
}
@@ -279,7 +282,7 @@ void Seq_NtkShareLatches( Abc_Ntk_t * pNtkNew, Abc_Ntk_t * pNtk )
stmm_table * tLatchMap;
int i;
assert( Abc_NtkIsSeq( pNtk ) );
- tLatchMap = stmm_init_table( stmm_ptrcmp, stmm_ptrhash );
+ tLatchMap = stmm_init_table( (int (*)(void))stmm_ptrcmp, (int (*)(void))stmm_ptrhash );
Abc_AigForEachAnd( pNtk, pObj, i )
{
pFanin = Abc_ObjFanin0(pObj);
@@ -315,7 +318,7 @@ void Seq_NtkShareLatchesMapping( Abc_Ntk_t * pNtkNew, Abc_Ntk_t * pNtk, Vec_Ptr_
assert( Abc_NtkIsSeq( pNtk ) );
// start the table
- tLatchMap = stmm_init_table( stmm_ptrcmp, stmm_ptrhash );
+ tLatchMap = stmm_init_table( (int (*)(void))stmm_ptrcmp, (int (*)(void))stmm_ptrhash );
// create the array of all nodes with sharable fanouts
vNodes = Vec_PtrAlloc( 100 );
@@ -324,17 +327,17 @@ void Seq_NtkShareLatchesMapping( Abc_Ntk_t * pNtkNew, Abc_Ntk_t * pNtk, Vec_Ptr_
Vec_PtrPush( vNodes, pObj );
if ( fFpga )
{
- Vec_PtrForEachEntry( vMapAnds, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vMapAnds, pObj, i )
Vec_PtrPush( vNodes, pObj );
}
else
{
- Vec_PtrForEachEntry( vMapAnds, pMatch, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vMapAnds, pMatch, i )
Vec_PtrPush( vNodes, pMatch->pAnd );
}
// process nodes used in the mapping
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
{
// make sure the label is clean
Abc_ObjForEachFanout( pObj, pFanout, k )
@@ -386,3 +389,5 @@ void Seq_NtkShareLatchesClean( Abc_Ntk_t * pNtk )
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/seq/seqUtil.c b/src/base/seq/seqUtil.c
index 55b9df8e..137151e2 100644
--- a/src/base/seq/seqUtil.c
+++ b/src/base/seq/seqUtil.c
@@ -20,6 +20,9 @@
#include "seqInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -595,3 +598,5 @@ int Seq_NtkCleanup( Abc_Ntk_t * pNtk, int fVerbose )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/temp.c b/src/base/temp.c
deleted file mode 100644
index 55709247..00000000
--- a/src/base/temp.c
+++ /dev/null
@@ -1,83 +0,0 @@
-
-/**Function*************************************************************
-
- Synopsis [Command procedure to allow for static BDD variable ordering.]
-
- Description [This procedure should be integrated in "abc\src\base\abci\abc.c"
- similar to how procedure Abc_CommandReorder() is currently integrated.]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Abc_CommandOrder( Abc_Frame_t * pAbc, int argc, char ** argv )
-{
- FILE * pOut, * pErr, * pFile;
- Abc_Ntk_t * pNtk;
- char * pFileName;
- int c;
- int fReverse;
- int fVerbose;
- extern void Abc_NtkImplementCiOrder( Abc_Ntk_t * pNtk, char * pFileName, int fReverse, int fVerbose );
- extern void Abc_NtkFindCiOrder( Abc_Ntk_t * pNtk, int fReverse, int fVerbose );
-
- pNtk = Abc_FrameReadNtk(pAbc);
- pOut = Abc_FrameReadOut(pAbc);
- pErr = Abc_FrameReadErr(pAbc);
-
- // set defaults
- fReverse = 0;
- fVerbose = 0;
- Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "rvh" ) ) != EOF )
- {
- switch ( c )
- {
- case 'r':
- fReverse ^= 1;
- break;
- case 'v':
- fVerbose ^= 1;
- break;
- case 'h':
- goto usage;
- default:
- goto usage;
- }
- }
-
- if ( pNtk == NULL )
- {
- fprintf( pErr, "Empty network.\n" );
- return 1;
- }
-
- // if the var order file is given, implement this order
- pFileName = NULL;
- if ( argc == globalUtilOptind + 1 )
- {
- pFileName = argv[globalUtilOptind];
- pFile = fopen( pFileName, "r" );
- if ( pFile == NULL )
- {
- fprintf( pErr, "Cannot open file \"%s\" with the BDD variable order.\n", pFileName );
- return 1;
- }
- fclose( pFile );
- }
- if ( pFileName )
- Abc_NtkImplementCiOrder( pNtk, pFileName, fReverse, fVerbose );
- else
- Abc_NtkFindCiOrder( pNtk, fReverse, fVerbose );
- return 0;
-
-usage:
- fprintf( pErr, "usage: order [-rvh] <file>\n" );
- fprintf( pErr, "\t computes a good static CI variable order\n" );
- fprintf( pErr, "\t-r : toggle reverse ordering [default = %s]\n", fReverse? "yes": "no" );
- fprintf( pErr, "\t-v : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
- fprintf( pErr, "\t-h : print the command usage\n");
- fprintf( pErr, "\t<file> : (optional) file with the given variable order\n" );
- return 1;
-}
diff --git a/src/base/ver/ver.h b/src/base/ver/ver.h
index 01199863..ab679664 100644
--- a/src/base/ver/ver.h
+++ b/src/base/ver/ver.h
@@ -21,6 +21,7 @@
#ifndef __VER_H__
#define __VER_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -32,9 +33,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -106,9 +108,11 @@ extern void Ver_StreamSkipChars( Ver_Stream_t * p, char * pCharsToSkip
extern void Ver_StreamSkipToChars( Ver_Stream_t * p, char * pCharsToStop );
extern char * Ver_StreamGetWord( Ver_Stream_t * p, char * pCharsToStop );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/base/ver/verCore.c b/src/base/ver/verCore.c
index 42d6349a..bb7142f3 100644
--- a/src/base/ver/verCore.c
+++ b/src/base/ver/verCore.c
@@ -22,6 +22,9 @@
#include "mio.h"
#include "main.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -164,7 +167,7 @@ Abc_Lib_t * Ver_ParseFile( char * pFileName, Abc_Lib_t * pGateLib, int fCheck, i
p->fUseMemMan = fUseMemMan;
if ( glo_fMapped )
{
- Hop_ManStop(p->pDesign->pManFunc);
+ Hop_ManStop((Hop_Man_t *)p->pDesign->pManFunc);
p->pDesign->pManFunc = NULL;
}
// parse the file
@@ -220,7 +223,7 @@ void Ver_ParseInternal( Ver_Man_t * pMan )
return;
// connect the boxes and check
- Vec_PtrForEachEntry( pMan->pDesign->vModules, pNtk, i )
+ Vec_PtrForEachEntry( Abc_Ntk_t *, pMan->pDesign->vModules, pNtk, i )
{
// fix the dangling nets
Abc_NtkFinalizeRead( pNtk );
@@ -484,7 +487,7 @@ int Ver_ParseModule( Ver_Man_t * pMan )
RetValue = Ver_ParseInitial( pMan, pNtk );
else if ( !strcmp( pWord, "endmodule" ) )
break;
- else if ( pMan->pDesign->pGenlib && (pGate = Mio_LibraryReadGateByName(pMan->pDesign->pGenlib, pWord)) ) // current design
+ else if ( pMan->pDesign->pGenlib && (pGate = Mio_LibraryReadGateByName((Mio_Library_t *)pMan->pDesign->pGenlib, pWord)) ) // current design
RetValue = Ver_ParseGate( pMan, pNtk, pGate );
// else if ( pMan->pDesign->pLibrary && st_lookup(pMan->pDesign->pLibrary->tModules, pWord, (char**)&pNtkTemp) ) // gate library
// RetValue = Ver_ParseGate( pMan, pNtkTemp );
@@ -604,7 +607,7 @@ void Ver_ParseRemoveSuffixTable( Ver_Man_t * pMan )
char * pKey, * pValue;
if ( pMan->tName2Suffix == NULL )
return;
- st_foreach_item( pMan->tName2Suffix, gen, (char **)&pKey, (char **)&pValue )
+ st_foreach_item( pMan->tName2Suffix, gen, (const char **)&pKey, (char **)&pValue )
ABC_FREE( pKey );
st_free_table( pMan->tName2Suffix );
pMan->tName2Suffix = NULL;
@@ -1205,9 +1208,9 @@ int Ver_ParseAssign( Ver_Man_t * pMan, Abc_Ntk_t * pNtk )
if ( pMan->fMapped )
{
if ( !strcmp( pEquation, "1\'b0" ) )
- pFunc = (Hop_Obj_t *)Mio_LibraryReadConst0(Abc_FrameReadLibGen());
+ pFunc = (Hop_Obj_t *)Mio_LibraryReadConst0((Mio_Library_t *)Abc_FrameReadLibGen());
else if ( !strcmp( pEquation, "1\'b1" ) )
- pFunc = (Hop_Obj_t *)Mio_LibraryReadConst1(Abc_FrameReadLibGen());
+ pFunc = (Hop_Obj_t *)Mio_LibraryReadConst1((Mio_Library_t *)Abc_FrameReadLibGen());
else
{
// "assign foo = \bar ;"
@@ -1225,7 +1228,7 @@ int Ver_ParseAssign( Ver_Man_t * pMan, Abc_Ntk_t * pNtk )
Vec_PtrPush( pMan->vNames, (void *)(ABC_PTRUINT_T)strlen(pEquation) );
Vec_PtrPush( pMan->vNames, pEquation );
// get the buffer
- pFunc = (Hop_Obj_t *)Mio_LibraryReadBuf(Abc_FrameReadLibGen());
+ pFunc = (Hop_Obj_t *)Mio_LibraryReadBuf((Mio_Library_t *)Abc_FrameReadLibGen());
if ( pFunc == NULL )
{
sprintf( pMan->sError, "Reading assign statement for node %s has failed because the genlib library has no buffer.", Abc_ObjName(pNet) );
@@ -1237,13 +1240,13 @@ int Ver_ParseAssign( Ver_Man_t * pMan, Abc_Ntk_t * pNtk )
else
{
if ( !strcmp(pEquation, "0") || !strcmp(pEquation, "1\'b0") || !strcmp(pEquation, "1\'bx") )
- pFunc = Hop_ManConst0(pNtk->pManFunc);
+ pFunc = Hop_ManConst0((Hop_Man_t *)pNtk->pManFunc);
else if ( !strcmp(pEquation, "1") || !strcmp(pEquation, "1\'b1") )
- pFunc = Hop_ManConst1(pNtk->pManFunc);
+ pFunc = Hop_ManConst1((Hop_Man_t *)pNtk->pManFunc);
else if ( fReduction )
- pFunc = Ver_FormulaReduction( pEquation, pNtk->pManFunc, pMan->vNames, pMan->sError );
+ pFunc = (Hop_Obj_t *)Ver_FormulaReduction( pEquation, pNtk->pManFunc, pMan->vNames, pMan->sError );
else
- pFunc = Ver_FormulaParser( pEquation, pNtk->pManFunc, pMan->vNames, pMan->vStackFn, pMan->vStackOp, pMan->sError );
+ pFunc = (Hop_Obj_t *)Ver_FormulaParser( pEquation, pNtk->pManFunc, pMan->vNames, pMan->vStackFn, pMan->vStackOp, pMan->sError );
if ( pFunc == NULL )
{
Ver_ParsePrintErrorMessage( pMan );
@@ -1260,7 +1263,7 @@ int Ver_ParseAssign( Ver_Man_t * pMan, Abc_Ntk_t * pNtk )
{
// get the name of this signal
Length = (int)(ABC_PTRUINT_T)Vec_PtrEntry( pMan->vNames, 2*i );
- pName = Vec_PtrEntry( pMan->vNames, 2*i + 1 );
+ pName = (char *)Vec_PtrEntry( pMan->vNames, 2*i + 1 );
pName[Length] = 0;
// find the corresponding net
pNet = Ver_ParseFindNet( pNtk, pName );
@@ -1367,15 +1370,15 @@ int Ver_ParseGateStandard( Ver_Man_t * pMan, Abc_Ntk_t * pNtk, Ver_GateType_t Ga
}
// add logic function
if ( GateType == VER_GATE_AND || GateType == VER_GATE_NAND )
- pNode->pData = Hop_CreateAnd( pNtk->pManFunc, Abc_ObjFaninNum(pNode) );
+ pNode->pData = Hop_CreateAnd( (Hop_Man_t *)pNtk->pManFunc, Abc_ObjFaninNum(pNode) );
else if ( GateType == VER_GATE_OR || GateType == VER_GATE_NOR )
- pNode->pData = Hop_CreateOr( pNtk->pManFunc, Abc_ObjFaninNum(pNode) );
+ pNode->pData = Hop_CreateOr( (Hop_Man_t *)pNtk->pManFunc, Abc_ObjFaninNum(pNode) );
else if ( GateType == VER_GATE_XOR || GateType == VER_GATE_XNOR )
- pNode->pData = Hop_CreateExor( pNtk->pManFunc, Abc_ObjFaninNum(pNode) );
+ pNode->pData = Hop_CreateExor( (Hop_Man_t *)pNtk->pManFunc, Abc_ObjFaninNum(pNode) );
else if ( GateType == VER_GATE_BUF || GateType == VER_GATE_NOT )
- pNode->pData = Hop_CreateAnd( pNtk->pManFunc, Abc_ObjFaninNum(pNode) );
+ pNode->pData = Hop_CreateAnd( (Hop_Man_t *)pNtk->pManFunc, Abc_ObjFaninNum(pNode) );
if ( GateType == VER_GATE_NAND || GateType == VER_GATE_NOR || GateType == VER_GATE_XNOR || GateType == VER_GATE_NOT )
- pNode->pData = Hop_Not( pNode->pData );
+ pNode->pData = Hop_Not( (Hop_Obj_t *)pNode->pData );
return 1;
}
@@ -2033,7 +2036,7 @@ int Ver_ParseConnectBox( Ver_Man_t * pMan, Abc_Obj_t * pBox )
{
Vec_Ptr_t * vBundles = (Vec_Ptr_t *)pBox->pCopy;
Abc_Ntk_t * pNtk = pBox->pNtk;
- Abc_Ntk_t * pNtkBox = pBox->pData;
+ Abc_Ntk_t * pNtkBox = (Abc_Ntk_t *)pBox->pData;
Abc_Obj_t * pTerm, * pTermNew, * pNetAct;
Ver_Bundle_t * pBundle;
char * pNameFormal;
@@ -2055,7 +2058,7 @@ int Ver_ParseConnectBox( Ver_Man_t * pMan, Abc_Obj_t * pBox )
Abc_ObjFanin0(pTerm)->pCopy = NULL;
*/
// check if some of them do not have formal names
- Vec_PtrForEachEntry( vBundles, pBundle, k )
+ Vec_PtrForEachEntry( Ver_Bundle_t *, vBundles, pBundle, k )
if ( pBundle->pNameFormal == NULL )
break;
if ( k < Vec_PtrSize(vBundles) )
@@ -2063,7 +2066,7 @@ int Ver_ParseConnectBox( Ver_Man_t * pMan, Abc_Obj_t * pBox )
printf( "Warning: The instance %s of network %s will be connected without using formal names.\n", pNtkBox->pName, Abc_ObjName(pBox) );
// add all actual nets in the bundles
iBundle = 0;
- Vec_PtrForEachEntry( vBundles, pBundle, j )
+ Vec_PtrForEachEntry( Ver_Bundle_t *, vBundles, pBundle, j )
iBundle += Vec_PtrSize(pBundle->vNetsActual);
// check the number of actual nets is the same as the number of formal nets
@@ -2078,9 +2081,9 @@ int Ver_ParseConnectBox( Ver_Man_t * pMan, Abc_Obj_t * pBox )
iBundle = 0;
Abc_NtkForEachPi( pNtkBox, pTerm, i )
{
- pBundle = Vec_PtrEntry( vBundles, iBundle++ );
+ pBundle = (Ver_Bundle_t *)Vec_PtrEntry( vBundles, iBundle++ );
// the bundle is found - add the connections - using order LSB to MSB
- Vec_PtrForEachEntryReverse( pBundle->vNetsActual, pNetAct, k )
+ Vec_PtrForEachEntryReverse( Abc_Obj_t *, pBundle->vNetsActual, pNetAct, k )
{
pTermNew = Abc_NtkCreateBi( pNtk );
Abc_ObjAddFanin( pBox, pTermNew );
@@ -2092,9 +2095,9 @@ int Ver_ParseConnectBox( Ver_Man_t * pMan, Abc_Obj_t * pBox )
// create fanins of the box
Abc_NtkForEachPo( pNtkBox, pTerm, i )
{
- pBundle = Vec_PtrEntry( vBundles, iBundle++ );
+ pBundle = (Ver_Bundle_t *)Vec_PtrEntry( vBundles, iBundle++ );
// the bundle is found - add the connections - using order LSB to MSB
- Vec_PtrForEachEntryReverse( pBundle->vNetsActual, pNetAct, k )
+ Vec_PtrForEachEntryReverse( Abc_Obj_t *, pBundle->vNetsActual, pNetAct, k )
{
pTermNew = Abc_NtkCreateBo( pNtk );
Abc_ObjAddFanin( pTermNew, pBox );
@@ -2105,7 +2108,7 @@ int Ver_ParseConnectBox( Ver_Man_t * pMan, Abc_Obj_t * pBox )
}
// free the bundling
- Vec_PtrForEachEntry( vBundles, pBundle, k )
+ Vec_PtrForEachEntry( Ver_Bundle_t *, vBundles, pBundle, k )
Ver_ParseFreeBundle( pBundle );
Vec_PtrFree( vBundles );
pBox->pCopy = NULL;
@@ -2120,7 +2123,7 @@ int Ver_ParseConnectBox( Ver_Man_t * pMan, Abc_Obj_t * pBox )
pNameFormal = Abc_ObjName( Abc_ObjFanout0(pTerm) );
// try to find the bundle with this formal net
pBundle = NULL;
- Vec_PtrForEachEntry( vBundles, pBundle, k )
+ Vec_PtrForEachEntry( Ver_Bundle_t *, vBundles, pBundle, k )
if ( !strcmp(pBundle->pNameFormal, pNameFormal) )
break;
assert( pBundle != NULL );
@@ -2138,7 +2141,7 @@ int Ver_ParseConnectBox( Ver_Man_t * pMan, Abc_Obj_t * pBox )
// compare names before brace
if ( Length > 0 )
{
- Vec_PtrForEachEntry( vBundles, pBundle, j )
+ Vec_PtrForEachEntry( Ver_Bundle_t *, vBundles, pBundle, j )
if ( !strncmp(pBundle->pNameFormal, pNameFormal, Length) && (int)strlen(pBundle->pNameFormal) == Length )
break;
if ( j == Vec_PtrSize(vBundles) )
@@ -2154,7 +2157,7 @@ int Ver_ParseConnectBox( Ver_Man_t * pMan, Abc_Obj_t * pBox )
}
}
// the bundle is found - add the connections - using order LSB to MSB
- Vec_PtrForEachEntryReverse( pBundle->vNetsActual, pNetAct, k )
+ Vec_PtrForEachEntryReverse( Abc_Obj_t *, pBundle->vNetsActual, pNetAct, k )
{
pTermNew = Abc_NtkCreateBi( pNtk );
Abc_ObjAddFanin( pBox, pTermNew );
@@ -2171,7 +2174,7 @@ int Ver_ParseConnectBox( Ver_Man_t * pMan, Abc_Obj_t * pBox )
pNameFormal = Abc_ObjName( Abc_ObjFanin0(pTerm) );
// try to find this formal net in the bundle
pBundle = NULL;
- Vec_PtrForEachEntry( vBundles, pBundle, k )
+ Vec_PtrForEachEntry( Ver_Bundle_t *, vBundles, pBundle, k )
if ( !strcmp(pBundle->pNameFormal, pNameFormal) )
break;
assert( pBundle != NULL );
@@ -2189,7 +2192,7 @@ int Ver_ParseConnectBox( Ver_Man_t * pMan, Abc_Obj_t * pBox )
// compare names before brace
if ( Length > 0 )
{
- Vec_PtrForEachEntry( vBundles, pBundle, j )
+ Vec_PtrForEachEntry( Ver_Bundle_t *, vBundles, pBundle, j )
if ( !strncmp(pBundle->pNameFormal, pNameFormal, Length) && (int)strlen(pBundle->pNameFormal) == Length )
break;
if ( j == Vec_PtrSize(vBundles) )
@@ -2210,7 +2213,7 @@ int Ver_ParseConnectBox( Ver_Man_t * pMan, Abc_Obj_t * pBox )
}
}
// the bundle is found - add the connections
- Vec_PtrForEachEntryReverse( pBundle->vNetsActual, pNetAct, k )
+ Vec_PtrForEachEntryReverse( Abc_Obj_t *, pBundle->vNetsActual, pNetAct, k )
{
if ( !strcmp(Abc_ObjName(pNetAct), "1\'b0") || !strcmp(Abc_ObjName(pNetAct), "1\'b1") )
{
@@ -2228,7 +2231,7 @@ int Ver_ParseConnectBox( Ver_Man_t * pMan, Abc_Obj_t * pBox )
}
// free the bundling
- Vec_PtrForEachEntry( vBundles, pBundle, k )
+ Vec_PtrForEachEntry( Ver_Bundle_t *, vBundles, pBundle, k )
Ver_ParseFreeBundle( pBundle );
Vec_PtrFree( vBundles );
pBox->pCopy = NULL;
@@ -2253,7 +2256,7 @@ int Ver_ParseConnectDefBoxes( Ver_Man_t * pMan )
Abc_Obj_t * pBox;
int i, k, RetValue = 1;
// go through all the modules
- Vec_PtrForEachEntry( pMan->pDesign->vModules, pNtk, i )
+ Vec_PtrForEachEntry( Abc_Ntk_t *, pMan->pDesign->vModules, pNtk, i )
{
// go through all the boxes of this module
Abc_NtkForEachBox( pNtk, pBox, k )
@@ -2264,7 +2267,7 @@ int Ver_ParseConnectDefBoxes( Ver_Man_t * pMan )
if ( pBox->pData == NULL )
continue;
// if the network is undefined, it will be connected later
- if ( !Ver_NtkIsDefined(pBox->pData) )
+ if ( !Ver_NtkIsDefined((Abc_Ntk_t *)pBox->pData) )
{
RetValue = 2;
continue;
@@ -2273,7 +2276,7 @@ int Ver_ParseConnectDefBoxes( Ver_Man_t * pMan )
if ( !Ver_ParseConnectBox( pMan, pBox ) )
return 0;
// if the network is a true blackbox, skip
- if ( Abc_NtkHasBlackbox(pBox->pData) )
+ if ( Abc_NtkHasBlackbox((Abc_Ntk_t *)pBox->pData) )
continue;
// convert the box to the whitebox
Abc_ObjBlackboxToWhitebox( pBox );
@@ -2300,15 +2303,15 @@ Vec_Ptr_t * Ver_ParseCollectUndefBoxes( Ver_Man_t * pMan )
Abc_Obj_t * pBox;
int i, k;
// clear the module structures
- Vec_PtrForEachEntry( pMan->pDesign->vModules, pNtk, i )
+ Vec_PtrForEachEntry( Abc_Ntk_t *, pMan->pDesign->vModules, pNtk, i )
pNtk->pData = NULL;
// go through all the blackboxes
vUndefs = Vec_PtrAlloc( 16 );
- Vec_PtrForEachEntry( pMan->pDesign->vModules, pNtk, i )
+ Vec_PtrForEachEntry( Abc_Ntk_t *, pMan->pDesign->vModules, pNtk, i )
{
Abc_NtkForEachBlackbox( pNtk, pBox, k )
{
- pNtkBox = pBox->pData;
+ pNtkBox = (Abc_Ntk_t *)pBox->pData;
if ( pNtkBox == NULL )
continue;
if ( Ver_NtkIsDefined(pNtkBox) )
@@ -2320,7 +2323,7 @@ Vec_Ptr_t * Ver_ParseCollectUndefBoxes( Ver_Man_t * pMan )
pNtkBox->pData = Vec_PtrAlloc( 16 );
}
// save the instance
- Vec_PtrPush( pNtkBox->pData, pBox );
+ Vec_PtrPush( (Vec_Ptr_t *)pNtkBox->pData, pBox );
}
}
return vUndefs;
@@ -2344,25 +2347,25 @@ void Ver_ParseReportUndefBoxes( Ver_Man_t * pMan )
int i, k, nBoxes;
// clean
nBoxes = 0;
- Vec_PtrForEachEntry( pMan->pDesign->vModules, pNtk, i )
+ Vec_PtrForEachEntry( Abc_Ntk_t *, pMan->pDesign->vModules, pNtk, i )
{
pNtk->fHiePath = 0;
if ( !Ver_NtkIsDefined(pNtk) )
nBoxes++;
}
// count
- Vec_PtrForEachEntry( pMan->pDesign->vModules, pNtk, i )
+ Vec_PtrForEachEntry( Abc_Ntk_t *, pMan->pDesign->vModules, pNtk, i )
Abc_NtkForEachBlackbox( pNtk, pBox, k )
- if ( pBox->pData && !Ver_NtkIsDefined(pBox->pData) )
+ if ( pBox->pData && !Ver_NtkIsDefined((Abc_Ntk_t *)pBox->pData) )
((Abc_Ntk_t *)pBox->pData)->fHiePath++;
// print the stats
printf( "Warning: The design contains %d undefined objects interpreted as blackboxes:\n", nBoxes );
- Vec_PtrForEachEntry( pMan->pDesign->vModules, pNtk, i )
+ Vec_PtrForEachEntry( Abc_Ntk_t *, pMan->pDesign->vModules, pNtk, i )
if ( !Ver_NtkIsDefined(pNtk) )
printf( "%s (%d) ", Abc_NtkName(pNtk), pNtk->fHiePath );
printf( "\n" );
// clean
- Vec_PtrForEachEntry( pMan->pDesign->vModules, pNtk, i )
+ Vec_PtrForEachEntry( Abc_Ntk_t *, pMan->pDesign->vModules, pNtk, i )
pNtk->fHiePath = 0;
}
@@ -2384,14 +2387,14 @@ int Ver_ParseCheckNondrivenNets( Vec_Ptr_t * vUndefs )
Abc_Obj_t * pBox, * pNet;
int i, k, j, m;
// go through undef box types
- Vec_PtrForEachEntry( vUndefs, pNtk, i )
+ Vec_PtrForEachEntry( Abc_Ntk_t *, vUndefs, pNtk, i )
// go through instances of this type
- Vec_PtrForEachEntry( pNtk->pData, pBox, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, (Vec_Ptr_t *)pNtk->pData, pBox, k )
// go through the bundles of this instance
- Vec_PtrForEachEntryReverse( (Vec_Ptr_t *)pBox->pCopy, pBundle, j )
+ Vec_PtrForEachEntryReverse( Ver_Bundle_t *, (Vec_Ptr_t *)pBox->pCopy, pBundle, j )
// go through the actual nets of this bundle
if ( pBundle )
- Vec_PtrForEachEntry( pBundle->vNetsActual, pNet, m )
+ Vec_PtrForEachEntry( Abc_Obj_t *, pBundle->vNetsActual, pNet, m )
{
if ( Abc_ObjFaninNum(pNet) == 0 ) // non-driven
if ( strcmp(Abc_ObjName(pNet), "1\'b0") && strcmp(Abc_ObjName(pNet), "1\'b1") ) // diff from a const
@@ -2417,10 +2420,10 @@ int Ver_ParseFormalNetsAreDriven( Abc_Ntk_t * pNtk, char * pNameFormal )
Abc_Obj_t * pBox, * pNet;
int k, j, m;
// go through instances of this type
- Vec_PtrForEachEntry( pNtk->pData, pBox, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, (Vec_Ptr_t *)pNtk->pData, pBox, k )
{
// find a bundle with the given name in this instance
- Vec_PtrForEachEntryReverse( (Vec_Ptr_t *)pBox->pCopy, pBundle, j )
+ Vec_PtrForEachEntryReverse( Ver_Bundle_t *, (Vec_Ptr_t *)pBox->pCopy, pBundle, j )
if ( pBundle && !strcmp( pBundle->pNameFormal, pNameFormal ) )
break;
// skip non-driven bundles
@@ -2428,7 +2431,7 @@ int Ver_ParseFormalNetsAreDriven( Abc_Ntk_t * pNtk, char * pNameFormal )
continue;
// check if all nets are driven in this bundle
assert(pBundle); // Verify that pBundle was assigned to.
- Vec_PtrForEachEntry( pBundle->vNetsActual, pNet, m )
+ Vec_PtrForEachEntry( Abc_Obj_t *, pBundle->vNetsActual, pNet, m )
if ( Abc_ObjFaninNum(pNet) > 0 )
return 1;
}
@@ -2452,16 +2455,16 @@ Ver_Bundle_t * Ver_ParseGetNondrivenBundle( Abc_Ntk_t * pNtk, int Counter )
Abc_Obj_t * pBox, * pNet;
int k, m;
// go through instances of this type
- Vec_PtrForEachEntry( pNtk->pData, pBox, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, (Vec_Ptr_t *)pNtk->pData, pBox, k )
{
if ( Counter >= Vec_PtrSize((Vec_Ptr_t *)pBox->pCopy) )
continue;
// get the bundle given distance away
- pBundle = Vec_PtrEntry( (Vec_Ptr_t *)pBox->pCopy, Vec_PtrSize((Vec_Ptr_t *)pBox->pCopy) - 1 - Counter );
+ pBundle = (Ver_Bundle_t *)Vec_PtrEntry( (Vec_Ptr_t *)pBox->pCopy, Vec_PtrSize((Vec_Ptr_t *)pBox->pCopy) - 1 - Counter );
if ( pBundle == NULL )
continue;
// go through the actual nets of this bundle
- Vec_PtrForEachEntry( pBundle->vNetsActual, pNet, m )
+ Vec_PtrForEachEntry( Abc_Obj_t *, pBundle->vNetsActual, pNet, m )
if ( !Abc_ObjFaninNum(pNet) && !Ver_ParseFormalNetsAreDriven(pNtk, pBundle->pNameFormal) ) // non-driven
return pBundle;
}
@@ -2488,7 +2491,7 @@ int Ver_ParseDriveFormal( Ver_Man_t * pMan, Abc_Ntk_t * pNtk, Ver_Bundle_t * pBu
int k, j, m;
// drive this net in the undef box
- Vec_PtrForEachEntry( pBundle0->vNetsActual, pNetAct, m )
+ Vec_PtrForEachEntry( Abc_Obj_t *, pBundle0->vNetsActual, pNetAct, m )
{
// create the formal net
if ( Vec_PtrSize(pBundle0->vNetsActual) == 1 )
@@ -2508,10 +2511,10 @@ int Ver_ParseDriveFormal( Ver_Man_t * pMan, Abc_Ntk_t * pNtk, Ver_Bundle_t * pBu
// go through instances of this type
pName = Extra_UtilStrsav(pBundle0->pNameFormal);
- Vec_PtrForEachEntry( pNtk->pData, pBox, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, (Vec_Ptr_t *)pNtk->pData, pBox, k )
{
// find a bundle with the given name in this instance
- Vec_PtrForEachEntryReverse( (Vec_Ptr_t *)pBox->pCopy, pBundle, j )
+ Vec_PtrForEachEntryReverse( Ver_Bundle_t *, (Vec_Ptr_t *)pBox->pCopy, pBundle, j )
if ( pBundle && !strcmp( pBundle->pNameFormal, pName ) )
break;
// skip non-driven bundles
@@ -2519,7 +2522,7 @@ int Ver_ParseDriveFormal( Ver_Man_t * pMan, Abc_Ntk_t * pNtk, Ver_Bundle_t * pBu
continue;
// check if any nets are driven in this bundle
assert(pBundle); // Verify pBundle was assigned to.
- Vec_PtrForEachEntry( pBundle->vNetsActual, pNetAct, m )
+ Vec_PtrForEachEntry( Abc_Obj_t *, pBundle->vNetsActual, pNetAct, m )
if ( Abc_ObjFaninNum(pNetAct) > 0 )
{
sprintf( pMan->sError, "Internal error while trying to connect undefined boxes. It is likely that the algorithm currently used has its limitations." );
@@ -2527,7 +2530,7 @@ int Ver_ParseDriveFormal( Ver_Man_t * pMan, Abc_Ntk_t * pNtk, Ver_Bundle_t * pBu
return 0;
}
// drive the nets by the undef box
- Vec_PtrForEachEntryReverse( pBundle->vNetsActual, pNetAct, m )
+ Vec_PtrForEachEntryReverse( Abc_Obj_t *, pBundle->vNetsActual, pNetAct, m )
{
pTermNew = Abc_NtkCreateBo( pNetAct->pNtk );
Abc_ObjAddFanin( pTermNew, pBox );
@@ -2561,14 +2564,14 @@ int Ver_ParseDriveInputs( Ver_Man_t * pMan, Vec_Ptr_t * vUndefs )
Abc_Obj_t * pBox, * pBox2, * pTerm, * pTermNew, * pNetFormal, * pNetAct;
int i, k, j, m, CountCur, CountTotal = -1;
// iterate through the undef boxes
- Vec_PtrForEachEntry( vUndefs, pNtk, i )
+ Vec_PtrForEachEntry( Abc_Ntk_t *, vUndefs, pNtk, i )
{
// count the number of unconnected bundles for instances of this type of box
CountTotal = -1;
- Vec_PtrForEachEntry( pNtk->pData, pBox, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, (Vec_Ptr_t *)pNtk->pData, pBox, k )
{
CountCur = 0;
- Vec_PtrForEachEntry( (Vec_Ptr_t *)pBox->pCopy, pBundle, j )
+ Vec_PtrForEachEntry( Ver_Bundle_t *, (Vec_Ptr_t *)pBox->pCopy, pBundle, j )
CountCur += (pBundle != NULL);
if ( CountTotal == -1 )
CountTotal = CountCur;
@@ -2582,12 +2585,12 @@ int Ver_ParseDriveInputs( Ver_Man_t * pMan, Vec_Ptr_t * vUndefs )
}
// create formals
- pBox = Vec_PtrEntry( pNtk->pData, 0 );
- Vec_PtrForEachEntry( (Vec_Ptr_t *)pBox->pCopy, pBundle, j )
+ pBox = (Abc_Obj_t *)Vec_PtrEntry( (Vec_Ptr_t *)pNtk->pData, 0 );
+ Vec_PtrForEachEntry( Ver_Bundle_t *, (Vec_Ptr_t *)pBox->pCopy, pBundle, j )
{
if ( pBundle == NULL )
continue;
- Vec_PtrForEachEntry( pBundle->vNetsActual, pNetAct, m )
+ Vec_PtrForEachEntry( Abc_Obj_t *, pBundle->vNetsActual, pNetAct, m )
{
// find create the formal net
if ( Vec_PtrSize(pBundle->vNetsActual) == 1 )
@@ -2607,15 +2610,15 @@ int Ver_ParseDriveInputs( Ver_Man_t * pMan, Vec_Ptr_t * vUndefs )
}
// go through all the boxes
- Vec_PtrForEachEntry( pNtk->pData, pBox, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, (Vec_Ptr_t *)pNtk->pData, pBox, k )
{
// go through all the bundles
- Vec_PtrForEachEntry( (Vec_Ptr_t *)pBox->pCopy, pBundle, j )
+ Vec_PtrForEachEntry( Ver_Bundle_t *, (Vec_Ptr_t *)pBox->pCopy, pBundle, j )
{
if ( pBundle == NULL )
continue;
// drive the nets by the undef box
- Vec_PtrForEachEntryReverse( pBundle->vNetsActual, pNetAct, m )
+ Vec_PtrForEachEntryReverse( Abc_Obj_t *, pBundle->vNetsActual, pNetAct, m )
{
pTermNew = Abc_NtkCreateBi( pNetAct->pNtk );
Abc_ObjAddFanin( pBox, pTermNew );
@@ -2652,9 +2655,9 @@ int Ver_ParseMaxBoxSize( Vec_Ptr_t * vUndefs )
Abc_Obj_t * pBox;
int i, k, nMaxSize = 0;
// go through undef box types
- Vec_PtrForEachEntry( vUndefs, pNtk, i )
+ Vec_PtrForEachEntry( Abc_Ntk_t *, vUndefs, pNtk, i )
// go through instances of this type
- Vec_PtrForEachEntry( pNtk->pData, pBox, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, (Vec_Ptr_t *)pNtk->pData, pBox, k )
// check the number of bundles of this instance
if ( nMaxSize < Vec_PtrSize((Vec_Ptr_t *)pBox->pCopy) )
nMaxSize = Vec_PtrSize((Vec_Ptr_t *)pBox->pCopy);
@@ -2688,21 +2691,21 @@ void Ver_ParsePrintLog( Ver_Man_t * pMan )
pFile = fopen( Buffer, "w" );
// count the total number of instances and how many times they occur
- Vec_PtrForEachEntry( pMan->pDesign->vModules, pNtk, i )
+ Vec_PtrForEachEntry( Abc_Ntk_t *, pMan->pDesign->vModules, pNtk, i )
pNtk->fHieVisited = 0;
- Vec_PtrForEachEntry( pMan->pDesign->vModules, pNtk, i )
+ Vec_PtrForEachEntry( Abc_Ntk_t *, pMan->pDesign->vModules, pNtk, i )
Abc_NtkForEachBox( pNtk, pBox, k )
{
if ( Abc_ObjIsLatch(pBox) )
continue;
- pNtkBox = pBox->pData;
+ pNtkBox = (Abc_Ntk_t *)pBox->pData;
if ( pNtkBox == NULL )
continue;
pNtkBox->fHieVisited++;
}
// print each box and its stats
fprintf( pFile, "The hierarhical design %s contains %d modules:\n", pMan->pFileName, Vec_PtrSize(pMan->pDesign->vModules) );
- Vec_PtrForEachEntry( pMan->pDesign->vModules, pNtk, i )
+ Vec_PtrForEachEntry( Abc_Ntk_t *, pMan->pDesign->vModules, pNtk, i )
{
fprintf( pFile, "%-24s : ", Abc_NtkName(pNtk) );
if ( !Ver_NtkIsDefined(pNtk) )
@@ -2720,7 +2723,7 @@ void Ver_ParsePrintLog( Ver_Man_t * pMan )
fprintf( pFile, " box = %6d", Abc_NtkBoxNum(pNtk)-Abc_NtkLatchNum(pNtk) );
fprintf( pFile, "\n" );
}
- Vec_PtrForEachEntry( pMan->pDesign->vModules, pNtk, i )
+ Vec_PtrForEachEntry( Abc_Ntk_t *, pMan->pDesign->vModules, pNtk, i )
pNtk->fHieVisited = 0;
// report instances with dangling outputs
@@ -2730,21 +2733,21 @@ void Ver_ParsePrintLog( Ver_Man_t * pMan )
Ver_Bundle_t * pBundle;
int j, nActNets, Counter = 0;
// count the number of instances with dangling outputs
- Vec_PtrForEachEntry( pMan->pDesign->vModules, pNtk, i )
+ Vec_PtrForEachEntry( Abc_Ntk_t *, pMan->pDesign->vModules, pNtk, i )
{
Abc_NtkForEachBox( pNtk, pBox, k )
{
if ( Abc_ObjIsLatch(pBox) )
continue;
vBundles = (Vec_Ptr_t *)pBox->pCopy;
- pNtkBox = pBox->pData;
+ pNtkBox = (Abc_Ntk_t *)pBox->pData;
if ( pNtkBox == NULL )
continue;
if ( !Ver_NtkIsDefined(pNtkBox) )
continue;
// count the number of actual nets
nActNets = 0;
- Vec_PtrForEachEntry( vBundles, pBundle, j )
+ Vec_PtrForEachEntry( Ver_Bundle_t *, vBundles, pBundle, j )
nActNets += Vec_PtrSize(pBundle->vNetsActual);
// the box is defined and will be connected
if ( nActNets != Abc_NtkPiNum(pNtkBox) + Abc_NtkPoNum(pNtkBox) )
@@ -2758,21 +2761,21 @@ void Ver_ParsePrintLog( Ver_Man_t * pMan )
fprintf( pFile, "\n" );
fprintf( pFile, "The outputs of %d box instances are not connected:\n", Counter );
// enumerate through the boxes
- Vec_PtrForEachEntry( pMan->pDesign->vModules, pNtk, i )
+ Vec_PtrForEachEntry( Abc_Ntk_t *, pMan->pDesign->vModules, pNtk, i )
{
Abc_NtkForEachBox( pNtk, pBox, k )
{
if ( Abc_ObjIsLatch(pBox) )
continue;
vBundles = (Vec_Ptr_t *)pBox->pCopy;
- pNtkBox = pBox->pData;
+ pNtkBox = (Abc_Ntk_t *)pBox->pData;
if ( pNtkBox == NULL )
continue;
if ( !Ver_NtkIsDefined(pNtkBox) )
continue;
// count the number of actual nets
nActNets = 0;
- Vec_PtrForEachEntry( vBundles, pBundle, j )
+ Vec_PtrForEachEntry( Ver_Bundle_t *, vBundles, pBundle, j )
nActNets += Vec_PtrSize(pBundle->vNetsActual);
// the box is defined and will be connected
if ( nActNets != Abc_NtkPiNum(pNtkBox) + Abc_NtkPoNum(pNtkBox) )
@@ -2835,7 +2838,7 @@ int Ver_ParseAttachBoxes( Ver_Man_t * pMan )
{
// go through undef box types
pBundle = NULL;
- Vec_PtrForEachEntry( vUndefs, pNtk, i )
+ Vec_PtrForEachEntry( Abc_Ntk_t *, vUndefs, pNtk, i )
if ( (pBundle = Ver_ParseGetNondrivenBundle( pNtk, Counter )) )
break;
if ( pBundle == NULL )
@@ -2853,9 +2856,9 @@ int Ver_ParseAttachBoxes( Ver_Man_t * pMan )
return 0;
// cleanup
- Vec_PtrForEachEntry( vUndefs, pNtk, i )
+ Vec_PtrForEachEntry( Abc_Ntk_t *, vUndefs, pNtk, i )
{
- Vec_PtrFree( pNtk->pData );
+ Vec_PtrFree( (Vec_Ptr_t *)pNtk->pData );
pNtk->pData = NULL;
}
Vec_PtrFree( vUndefs );
@@ -2970,3 +2973,5 @@ Abc_Obj_t * Ver_ParseCreateInv( Abc_Ntk_t * pNtk, Abc_Obj_t * pNet )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/ver/verFormula.c b/src/base/ver/verFormula.c
index 3ed5f556..bf34b00f 100644
--- a/src/base/ver/verFormula.c
+++ b/src/base/ver/verFormula.c
@@ -20,6 +20,9 @@
#include "ver.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -84,9 +87,9 @@ void * Ver_FormulaParser( char * pFormula, void * pMan, Vec_Ptr_t * vNames, Vec_
Vec_IntClear( vStackOp );
if ( !strcmp(pFormula, "0") || !strcmp(pFormula, "1\'b0") )
- return Hop_ManConst0(pMan);
+ return Hop_ManConst0((Hop_Man_t *)pMan);
if ( !strcmp(pFormula, "1") || !strcmp(pFormula, "1\'b1") )
- return Hop_ManConst1(pMan);
+ return Hop_ManConst1((Hop_Man_t *)pMan);
// make sure that the number of opening and closing parantheses is the same
nParans = 0;
@@ -214,7 +217,7 @@ void * Ver_FormulaParser( char * pFormula, void * pMan, Vec_Ptr_t * vNames, Vec_
// }
// perform the given operation
- if ( Ver_FormulaParserTopOper( pMan, vStackFn, Oper ) == NULL )
+ if ( Ver_FormulaParserTopOper( (Hop_Man_t *)pMan, vStackFn, Oper ) == NULL )
{
sprintf( pErrorMessage, "Parse_FormulaParser(): Unknown operation\n" );
return NULL;
@@ -245,7 +248,7 @@ void * Ver_FormulaParser( char * pFormula, void * pMan, Vec_Ptr_t * vNames, Vec_
sprintf( pErrorMessage, "Parse_FormulaParser(): Incorrect state." );
return NULL;
}
- bTemp = Hop_IthVar( pMan, v );
+ bTemp = Hop_IthVar( (Hop_Man_t *)pMan, v );
Vec_PtrPush( vStackFn, bTemp ); // Cudd_Ref( bTemp );
Flag = VER_PARSE_FLAG_VAR;
break;
@@ -269,7 +272,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, Hop_Not(Vec_PtrPop(vStackFn)) );
+ Vec_PtrPush( vStackFn, Hop_Not((Hop_Obj_t *)Vec_PtrPop(vStackFn)) );
}
}
else // if ( Flag == VER_PARSE_FLAG_OPER )
@@ -285,7 +288,7 @@ void * Ver_FormulaParser( char * pFormula, void * pMan, Vec_Ptr_t * vNames, Vec_
Oper2 = Vec_IntPop( vStackOp ); // the operation before the last one
if ( Oper2 >= Oper1 && !(Oper1 == Oper2 && Oper1 == VER_PARSE_OPER_MUX) )
{ // if Oper2 precedence is higher or equal, execute it
- if ( Ver_FormulaParserTopOper( pMan, vStackFn, Oper2 ) == NULL )
+ if ( Ver_FormulaParserTopOper( (Hop_Man_t *)pMan, vStackFn, Oper2 ) == NULL )
{
sprintf( pErrorMessage, "Parse_FormulaParser(): Unknown operation\n" );
return NULL;
@@ -305,7 +308,7 @@ void * Ver_FormulaParser( char * pFormula, void * pMan, Vec_Ptr_t * vNames, Vec_
{
if ( Vec_PtrSize(vStackFn) )
{
- bFunc = Vec_PtrPop(vStackFn);
+ bFunc = (Hop_Obj_t *)Vec_PtrPop(vStackFn);
if ( !Vec_PtrSize(vStackFn) )
if ( !Vec_IntSize(vStackOp) )
{
@@ -340,8 +343,8 @@ Hop_Obj_t * Ver_FormulaParserTopOper( Hop_Man_t * pMan, Vec_Ptr_t * vStackFn, in
{
Hop_Obj_t * bArg0, * bArg1, * bArg2, * bFunc;
// perform the given operation
- bArg2 = Vec_PtrPop( vStackFn );
- bArg1 = Vec_PtrPop( vStackFn );
+ bArg2 = (Hop_Obj_t *)Vec_PtrPop( vStackFn );
+ bArg1 = (Hop_Obj_t *)Vec_PtrPop( vStackFn );
if ( Oper == VER_PARSE_OPER_AND )
bFunc = Hop_And( pMan, bArg1, bArg2 );
else if ( Oper == VER_PARSE_OPER_XOR )
@@ -352,7 +355,7 @@ Hop_Obj_t * Ver_FormulaParserTopOper( Hop_Man_t * pMan, Vec_Ptr_t * vStackFn, in
bFunc = Hop_Not( Hop_Exor( pMan, bArg1, bArg2 ) );
else if ( Oper == VER_PARSE_OPER_MUX )
{
- bArg0 = Vec_PtrPop( vStackFn );
+ bArg0 = (Hop_Obj_t *)Vec_PtrPop( vStackFn );
// bFunc = Cudd_bddIte( dd, bArg0, bArg1, bArg2 ); Cudd_Ref( bFunc );
bFunc = Hop_Mux( pMan, bArg0, bArg1, bArg2 );
// Cudd_RecursiveDeref( dd, bArg0 );
@@ -407,7 +410,7 @@ int Ver_FormulaParserFindVar( char * pString, Vec_Ptr_t * vNames )
nLength2 = (int)(ABC_PTRUINT_T)Vec_PtrEntry( vNames, 2*i + 0 );
if ( nLength2 != nLength )
continue;
- pTemp2 = Vec_PtrEntry( vNames, 2*i + 1 );
+ pTemp2 = (char *)Vec_PtrEntry( vNames, 2*i + 1 );
if ( strncmp( pString, pTemp2, nLength ) )
continue;
return i;
@@ -459,11 +462,11 @@ void * Ver_FormulaReduction( char * pFormula, void * pMan, Vec_Ptr_t * vNames, c
}
// compute the function
if ( Symbol == '&' )
- pRes = Hop_CreateAnd( pMan, Vec_PtrSize(vNames)/2 );
+ pRes = Hop_CreateAnd( (Hop_Man_t *)pMan, Vec_PtrSize(vNames)/2 );
else if ( Symbol == '|' )
- pRes = Hop_CreateOr( pMan, Vec_PtrSize(vNames)/2 );
+ pRes = Hop_CreateOr( (Hop_Man_t *)pMan, Vec_PtrSize(vNames)/2 );
else if ( Symbol == '^' )
- pRes = Hop_CreateExor( pMan, Vec_PtrSize(vNames)/2 );
+ pRes = Hop_CreateExor( (Hop_Man_t *)pMan, Vec_PtrSize(vNames)/2 );
return Hop_NotCond( pRes, fCompl );
}
@@ -472,3 +475,5 @@ void * Ver_FormulaReduction( char * pFormula, void * pMan, Vec_Ptr_t * vNames, c
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/ver/verParse.c b/src/base/ver/verParse.c
index c38399f2..553d0348 100644
--- a/src/base/ver/verParse.c
+++ b/src/base/ver/verParse.c
@@ -20,6 +20,9 @@
#include "ver.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -124,3 +127,5 @@ char * Ver_ParseGetName( Ver_Man_t * pMan )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/ver/verStream.c b/src/base/ver/verStream.c
index 8acaf5ec..75e183b3 100644
--- a/src/base/ver/verStream.c
+++ b/src/base/ver/verStream.c
@@ -20,6 +20,9 @@
#include "ver.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -441,3 +444,5 @@ char * Ver_StreamGetWord( Ver_Stream_t * p, char * pCharsToStop )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/ver/verWords.c b/src/base/ver/verWords.c
index f9d27010..3934a373 100644
--- a/src/base/ver/verWords.c
+++ b/src/base/ver/verWords.c
@@ -20,6 +20,9 @@
#include "ver.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -46,3 +49,5 @@
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/base/ver/ver_.c b/src/base/ver/ver_.c
index 76599dac..ef9f8155 100644
--- a/src/base/ver/ver_.c
+++ b/src/base/ver/ver_.c
@@ -20,6 +20,9 @@
#include "ver.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -46,3 +49,5 @@
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cas/cas.h b/src/bdd/cas/cas.h
index 68a5c3a0..33958325 100644
--- a/src/bdd/cas/cas.h
+++ b/src/bdd/cas/cas.h
@@ -21,6 +21,7 @@
#ifndef __CAS_H__
#define __CAS_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -29,9 +30,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
#define MAXINPUTS 1024
#define MAXOUTPUTS 1024
@@ -50,9 +52,11 @@ extern "C" {
/*=== zzz.c ==========================================================*/
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/bdd/cas/casCore.c b/src/bdd/cas/casCore.c
index 4010235c..5511b8e7 100644
--- a/src/bdd/cas/casCore.c
+++ b/src/bdd/cas/casCore.c
@@ -23,9 +23,14 @@
#include <string.h>
#include <time.h>
+#include "main.h"
+#include "cmd.h"
#include "extra.h"
#include "cas.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// static functions ///
////////////////////////////////////////////////////////////////////////
@@ -254,8 +259,6 @@ int Abc_CascadeExperiment( char * pFileGeneric, DdManager * dd, DdNode ** pOutpu
// verify the results
if ( fCheck )
{
- extern int Cmd_CommandExecute( void * pAbc, char * sCommand );
- extern void * Abc_FrameGetGlobalFrame();
char Command[200];
sprintf( Command, "cec %s %s", FileNameIni, FileNameFin );
Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), Command );
@@ -845,7 +848,7 @@ void WriteDDintoBLIFfile( FILE * pFile, DdNode * Func, char * OutputName, char *
refAddr = ( long )Cudd_Regular(Func);
diff = 0;
gen = st_init_gen( visited );
- while ( st_gen( gen, ( char ** ) &Node, NULL ) )
+ while ( st_gen( gen, ( const char ** ) &Node, NULL ) )
{
diff |= refAddr ^ ( long ) Node;
}
@@ -867,7 +870,7 @@ void WriteDDintoBLIFfile( FILE * pFile, DdNode * Func, char * OutputName, char *
gen = st_init_gen( visited );
- while ( st_gen( gen, ( char ** ) &Node, NULL ) )
+ while ( st_gen( gen, ( const char ** ) &Node, NULL ) )
{
if ( Node->index == CUDD_MAXINDEX )
{
@@ -990,7 +993,7 @@ void WriteDDintoBLIFfileReorder( DdManager * dd, FILE * pFile, DdNode * Func, ch
refAddr = ( long )Cudd_Regular(bFmin);
diff = 0;
gen = st_init_gen( visited );
- while ( st_gen( gen, ( char ** ) &Node, NULL ) )
+ while ( st_gen( gen, ( const char ** ) &Node, NULL ) )
{
diff |= refAddr ^ ( long ) Node;
}
@@ -1012,7 +1015,7 @@ void WriteDDintoBLIFfileReorder( DdManager * dd, FILE * pFile, DdNode * Func, ch
gen = st_init_gen( visited );
- while ( st_gen( gen, ( char ** ) &Node, NULL ) )
+ while ( st_gen( gen, ( const char ** ) &Node, NULL ) )
{
if ( Node->index == CUDD_MAXINDEX )
{
@@ -1143,7 +1146,7 @@ cuddBddTransferPermute( DdManager * ddS, DdManager * ddD, DdNode * f, int * Perm
gen = st_init_gen( table );
if ( gen == NULL )
goto failure;
- while ( st_gen( gen, ( char ** ) &key, ( char ** ) &value ) )
+ while ( st_gen( gen, ( const char ** ) &key, ( char ** ) &value ) )
{
Cudd_RecursiveDeref( ddD, value );
}
@@ -1259,3 +1262,5 @@ cuddBddTransferPermuteRecur( DdManager * ddS,
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cas/casDec.c b/src/bdd/cas/casDec.c
index 25309d32..111f559e 100644
--- a/src/bdd/cas/casDec.c
+++ b/src/bdd/cas/casDec.c
@@ -26,6 +26,9 @@
#include "extra.h"
#include "cas.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// type definitions ///
////////////////////////////////////////////////////////////////////////
@@ -506,3 +509,5 @@ void WriteLUTSintoBLIFfile( FILE * pFile, DdManager * dd, LUT ** pLuts, int nLut
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cudd.h b/src/bdd/cudd/cudd.h
index a31fcdae..14f67abf 100644
--- a/src/bdd/cudd/cudd.h
+++ b/src/bdd/cudd/cudd.h
@@ -30,6 +30,7 @@
#ifndef _CUDD
#define _CUDD
+
/*---------------------------------------------------------------------------*/
/* Nested includes */
/*---------------------------------------------------------------------------*/
@@ -37,6 +38,9 @@
#include "mtr.h"
#include "epd.h"
+ABC_NAMESPACE_HEADER_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -530,20 +534,20 @@ typedef DdApaDigit * DdApaNumber;
/* These are potential duplicates. */
#ifndef EXTERN
# ifdef __cplusplus
-# define EXTERN extern "C"
+# ifdef ABC_NAMESPACE
+# define EXTERN extern
+# else
+# define EXTERN extern "C"
+# endif
# else
# define EXTERN extern
# endif
#endif
+
#ifndef ARGS
-# if defined(__STDC__) || defined(__cplusplus)
-# define ARGS(protos) protos /* ANSI C */
-# else /* !(__STDC__ || __cplusplus) */
-# define ARGS(protos) () /* K&R C */
-# endif /* !(__STDC__ || __cplusplus) */
+#define ARGS(protos) protos
#endif
-
/**AutomaticStart*************************************************************/
/*---------------------------------------------------------------------------*/
@@ -956,4 +960,8 @@ EXTERN int Cudd_bddIsVarHardGroup ARGS((DdManager *dd, int index));
/**AutomaticEnd***************************************************************/
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif /* _CUDD */
diff --git a/src/bdd/cudd/cuddAPI.c b/src/bdd/cudd/cuddAPI.c
index cbba4d95..729dd329 100644
--- a/src/bdd/cudd/cuddAPI.c
+++ b/src/bdd/cudd/cuddAPI.c
@@ -167,6 +167,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -1740,7 +1743,7 @@ Cudd_ReadGarbageCollectionTime(
Synopsis [Returns the number of nodes freed.]
- Description [Returns the number of nodes returned to the ABC_FREE list if the
+ Description [Returns the number of nodes returned to the free list if the
keeping of this statistic is enabled; -1 otherwise. This statistic is
enabled only if the package is compiled with DD_STATS defined.]
@@ -3078,7 +3081,7 @@ Cudd_PrintInfo(
Synopsis [Reports the peak number of nodes.]
Description [Reports the peak number of nodes. This number includes
- node on the ABC_FREE list. At the peak, the number of nodes on the ABC_FREE
+ node on the free list. At the peak, the number of nodes on the free
list is guaranteed to be less than DD_MEM_CHUNK.]
SideEffects [None]
@@ -4407,3 +4410,5 @@ addMultiplicityGroups(
} /* end of addMultiplicityGroups */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddAddAbs.c b/src/bdd/cudd/cuddAddAbs.c
index b256ad0f..40d3222b 100644
--- a/src/bdd/cudd/cuddAddAbs.c
+++ b/src/bdd/cudd/cuddAddAbs.c
@@ -35,6 +35,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -564,3 +567,5 @@ addCheckPositiveCube(
} /* end of addCheckPositiveCube */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddAddApply.c b/src/bdd/cudd/cuddAddApply.c
index 60c06de6..5bdc5773 100644
--- a/src/bdd/cudd/cuddAddApply.c
+++ b/src/bdd/cudd/cuddAddApply.c
@@ -45,6 +45,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -915,3 +918,5 @@ cuddAddMonadicApplyRecur(
/* Definition of static functions */
/*---------------------------------------------------------------------------*/
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddAddFind.c b/src/bdd/cudd/cuddAddFind.c
index 0469b014..6cc58f2d 100644
--- a/src/bdd/cudd/cuddAddFind.c
+++ b/src/bdd/cudd/cuddAddFind.c
@@ -30,6 +30,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -281,3 +284,5 @@ addDoIthBit(
} /* end of addDoIthBit */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddAddInv.c b/src/bdd/cudd/cuddAddInv.c
index fc4a340b..05650c0e 100644
--- a/src/bdd/cudd/cuddAddInv.c
+++ b/src/bdd/cudd/cuddAddInv.c
@@ -27,6 +27,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
@@ -170,3 +173,5 @@ cuddAddScalarInverseRecur(
/* Definition of static functions */
/*---------------------------------------------------------------------------*/
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddAddIte.c b/src/bdd/cudd/cuddAddIte.c
index bcfae83a..def55537 100644
--- a/src/bdd/cudd/cuddAddIte.c
+++ b/src/bdd/cudd/cuddAddIte.c
@@ -36,6 +36,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -611,3 +614,5 @@ addVarToConst(
}
} /* end of addVarToConst */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddAddNeg.c b/src/bdd/cudd/cuddAddNeg.c
index bdb08ddc..d99d0357 100644
--- a/src/bdd/cudd/cuddAddNeg.c
+++ b/src/bdd/cudd/cuddAddNeg.c
@@ -29,6 +29,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
@@ -260,3 +263,5 @@ cuddAddRoundOffRecur(
/* Definition of static functions */
/*---------------------------------------------------------------------------*/
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddAddWalsh.c b/src/bdd/cudd/cuddAddWalsh.c
index 3022b73d..44b4415d 100644
--- a/src/bdd/cudd/cuddAddWalsh.c
+++ b/src/bdd/cudd/cuddAddWalsh.c
@@ -29,6 +29,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
@@ -363,3 +366,5 @@ addWalshInt(
return(u);
} /* end of addWalshInt */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddAndAbs.c b/src/bdd/cudd/cuddAndAbs.c
index 5ec47beb..9ee70498 100644
--- a/src/bdd/cudd/cuddAndAbs.c
+++ b/src/bdd/cudd/cuddAndAbs.c
@@ -27,6 +27,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
@@ -304,3 +307,5 @@ cuddBddAndAbstractRecur(
/* Definition of static functions */
/*---------------------------------------------------------------------------*/
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddAnneal.c b/src/bdd/cudd/cuddAnneal.c
index 32155603..c133cdc8 100644
--- a/src/bdd/cudd/cuddAnneal.c
+++ b/src/bdd/cudd/cuddAnneal.c
@@ -38,6 +38,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -786,3 +789,5 @@ restoreOrder(
} /* end of restoreOrder */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddApa.c b/src/bdd/cudd/cuddApa.c
index 13e80ce2..04dac030 100644
--- a/src/bdd/cudd/cuddApa.c
+++ b/src/bdd/cudd/cuddApa.c
@@ -31,6 +31,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -651,7 +654,7 @@ Cudd_ApaCountMinterm(
return(NULL);
}
Cudd_ApaSetToLiteral(*digits,min,0);
- table = st_init_table(st_ptrcmp,st_ptrhash);
+ table = st_init_table(st_ptrcmp, st_ptrhash);;
if (table == NULL) {
ABC_FREE(max);
ABC_FREE(min);
@@ -661,7 +664,7 @@ Cudd_ApaCountMinterm(
if (i == NULL) {
ABC_FREE(max);
ABC_FREE(min);
- st_foreach(table, cuddApaStCountfree, NULL);
+ st_foreach(table, (ST_PFSR)cuddApaStCountfree, NULL);
st_free_table(table);
return(NULL);
}
@@ -669,7 +672,7 @@ Cudd_ApaCountMinterm(
if (count == NULL) {
ABC_FREE(max);
ABC_FREE(min);
- st_foreach(table, cuddApaStCountfree, NULL);
+ st_foreach(table, (ST_PFSR)cuddApaStCountfree, NULL);
st_free_table(table);
if (Cudd_Regular(node)->ref == 1) ABC_FREE(i);
return(NULL);
@@ -681,7 +684,7 @@ Cudd_ApaCountMinterm(
}
ABC_FREE(max);
ABC_FREE(min);
- st_foreach(table, cuddApaStCountfree, NULL);
+ st_foreach(table, (ST_PFSR)cuddApaStCountfree, NULL);
st_free_table(table);
if (Cudd_Regular(node)->ref == 1) ABC_FREE(i);
return(count);
@@ -928,3 +931,5 @@ cuddApaStCountfree(
} /* end of cuddApaStCountfree */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddApprox.c b/src/bdd/cudd/cuddApprox.c
index c575b54b..9641aac0 100644
--- a/src/bdd/cudd/cuddApprox.c
+++ b/src/bdd/cudd/cuddApprox.c
@@ -54,6 +54,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -912,7 +915,7 @@ gatherInfo(
return(NULL);
}
memset(info->page, 0, info->size * sizeof(NodeData)); /* clear all page */
- info->table = st_init_table(st_ptrcmp,st_ptrhash);
+ info->table = st_init_table(st_ptrcmp, st_ptrhash);;
if (info->table == NULL) {
ABC_FREE(info->page);
ABC_FREE(info);
@@ -2190,3 +2193,5 @@ BAapplyBias(
return(infoF->care);
} /* end of BAapplyBias */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddBddAbs.c b/src/bdd/cudd/cuddBddAbs.c
index 9552464e..80d24ca4 100644
--- a/src/bdd/cudd/cuddBddAbs.c
+++ b/src/bdd/cudd/cuddBddAbs.c
@@ -38,6 +38,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
@@ -687,3 +690,5 @@ bddCheckPositiveCube(
} /* end of bddCheckPositiveCube */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddBddCorr.c b/src/bdd/cudd/cuddBddCorr.c
index a532f31d..f3f017b0 100644
--- a/src/bdd/cudd/cuddBddCorr.c
+++ b/src/bdd/cudd/cuddBddCorr.c
@@ -33,6 +33,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
@@ -80,7 +83,7 @@ static int num_calls;
static double bddCorrelationAux ARGS((DdManager *dd, DdNode *f, DdNode *g, st_table *table));
static double bddCorrelationWeightsAux ARGS((DdManager *dd, DdNode *f, DdNode *g, double *prob, st_table *table));
static int CorrelCompare ARGS((const char *key1, const char *key2));
-static int CorrelHash ARGS((char *key, int modulus));
+static int CorrelHash ARGS((const char *key, int modulus));
static enum st_retval CorrelCleanUp ARGS((char *key, char *value, char *arg));
/**AutomaticEnd***************************************************************/
@@ -122,7 +125,7 @@ Cudd_bddCorrelation(
table = st_init_table(CorrelCompare,CorrelHash);
if (table == NULL) return((double)CUDD_OUT_OF_MEM);
correlation = bddCorrelationAux(manager,f,g,table);
- st_foreach(table, CorrelCleanUp, NIL(char));
+ st_foreach(table, (ST_PFSR)CorrelCleanUp, NIL(char));
st_free_table(table);
return(correlation);
@@ -165,7 +168,7 @@ Cudd_bddCorrelationWeights(
table = st_init_table(CorrelCompare,CorrelHash);
if (table == NULL) return((double)CUDD_OUT_OF_MEM);
correlation = bddCorrelationWeightsAux(manager,f,g,prob,table);
- st_foreach(table, CorrelCleanUp, NIL(char));
+ st_foreach(table, (ST_PFSR)CorrelCleanUp, NIL(char));
st_free_table(table);
return(correlation);
@@ -434,13 +437,13 @@ CorrelCompare(
******************************************************************************/
static int
CorrelHash(
- char * key,
+ const char * key,
int modulus)
{
- HashEntry *entry;
+ const HashEntry *entry;
int val = 0;
- entry = (HashEntry *) key;
+ entry = (const HashEntry *) key;
#if SIZEOF_VOID_P == 8 && SIZEOF_INT == 4
val = ((int) ((long)entry->f))*997 + ((int) ((long)entry->g));
#else
@@ -479,3 +482,5 @@ CorrelCleanUp(
} /* end of CorrelCleanUp */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddBddIte.c b/src/bdd/cudd/cuddBddIte.c
index 672d6344..92d1171b 100644
--- a/src/bdd/cudd/cuddBddIte.c
+++ b/src/bdd/cudd/cuddBddIte.c
@@ -47,6 +47,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
@@ -1252,3 +1255,5 @@ bddVarToCanonicalSimple(
} /* end of bddVarToCanonicalSimple */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddBridge.c b/src/bdd/cudd/cuddBridge.c
index ccc0893f..da0b4379 100644
--- a/src/bdd/cudd/cuddBridge.c
+++ b/src/bdd/cudd/cuddBridge.c
@@ -47,6 +47,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -411,7 +414,7 @@ cuddBddTransfer(
st_generator *gen = NULL;
DdNode *key, *value;
- table = st_init_table(st_ptrcmp,st_ptrhash);
+ table = st_init_table(st_ptrcmp, st_ptrhash);;
if (table == NULL) goto failure;
res = cuddBddTransferRecur(ddS, ddD, f, table);
if (res != NULL) cuddRef(res);
@@ -421,7 +424,7 @@ cuddBddTransfer(
** reordering. */
gen = st_init_gen(table);
if (gen == NULL) goto failure;
- while (st_gen(gen, (char **) &key, (char **) &value)) {
+ while (st_gen(gen, (const char **) &key, (char **) &value)) {
Cudd_RecursiveDeref(ddD, value);
}
st_free_gen(gen); gen = NULL;
@@ -979,3 +982,5 @@ cuddBddTransferRecur(
} /* end of cuddBddTransferRecur */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddCache.c b/src/bdd/cudd/cuddCache.c
index e4aa0299..d66a8606 100644
--- a/src/bdd/cudd/cuddCache.c
+++ b/src/bdd/cudd/cuddCache.c
@@ -39,6 +39,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -865,7 +868,7 @@ cuddCacheResize(
unsigned int slots, oldslots;
double offset;
int moved = 0;
- extern void (*MMoutOfMemory)(long);
+// extern void (*MMoutOfMemory)(long);
void (*saveHandler)(long);
#ifndef DD_CACHE_PROFILE
ptruint misalignment;
@@ -899,7 +902,7 @@ cuddCacheResize(
table->acache = oldacache;
/* Do not try to resize again. */
table->maxCacheHard = oldslots - 1;
- table->cacheSlack = - (oldslots + 1);
+ table->cacheSlack = - (int)(oldslots + 1);
return;
}
/* If the size of the cache entry is a power of 2, we want to
@@ -1021,3 +1024,5 @@ cuddComputeFloorLog2(
/*---------------------------------------------------------------------------*/
/* Definition of static functions */
/*---------------------------------------------------------------------------*/
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddCheck.c b/src/bdd/cudd/cuddCheck.c
index aec8246d..92c0f5e1 100644
--- a/src/bdd/cudd/cuddCheck.c
+++ b/src/bdd/cudd/cuddCheck.c
@@ -37,6 +37,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -125,7 +128,7 @@ Cudd_DebugCheck(
int index;
- edgeTable = st_init_table(st_ptrcmp,st_ptrhash);
+ edgeTable = st_init_table(st_ptrcmp, st_ptrhash);;
if (edgeTable == NULL) return(CUDD_OUT_OF_MEM);
/* Check the BDD/ADD subtables. */
@@ -380,7 +383,7 @@ Cudd_DebugCheck(
flag = 1;
}
gen = st_init_gen(edgeTable);
- while (st_gen(gen,(char **)&f,(char **)&count)) {
+ while (st_gen(gen,(const char **)&f,(char **)&count)) {
if (count > (int)(f->ref) && f->ref != DD_MAXREF) {
#if SIZEOF_VOID_P == 8
fprintf(table->err,"ref count error at node 0x%lx, count = %d, id = %d, ref = %d, then = 0x%lx, else = 0x%lx\n",(unsigned long)f,count,f->index,f->ref,(unsigned long)cuddT(f),(unsigned long)cuddE(f));
@@ -849,3 +852,5 @@ debugCheckParent(
}
}
#endif
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddClip.c b/src/bdd/cudd/cuddClip.c
index 4da296ef..23331339 100644
--- a/src/bdd/cudd/cuddClip.c
+++ b/src/bdd/cudd/cuddClip.c
@@ -36,6 +36,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
@@ -529,3 +532,5 @@ cuddBddClipAndAbsRecur(
} /* end of cuddBddClipAndAbsRecur */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddCof.c b/src/bdd/cudd/cuddCof.c
index f79e3f91..26ff330d 100644
--- a/src/bdd/cudd/cuddCof.c
+++ b/src/bdd/cudd/cuddCof.c
@@ -32,6 +32,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -298,3 +301,5 @@ cuddCofactorRecur(
/* Definition of static functions */
/*---------------------------------------------------------------------------*/
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddCompose.c b/src/bdd/cudd/cuddCompose.c
index 43d65a5d..6fc4fa48 100644
--- a/src/bdd/cudd/cuddCompose.c
+++ b/src/bdd/cudd/cuddCompose.c
@@ -58,6 +58,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
@@ -1720,3 +1723,5 @@ ddIsIthAddVarPair(
cuddT(g) == DD_ZERO(dd) && cuddE(g) == DD_ONE(dd));
} /* end of ddIsIthAddVarPair */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddDecomp.c b/src/bdd/cudd/cuddDecomp.c
index 871a99bb..95a00536 100644
--- a/src/bdd/cudd/cuddDecomp.c
+++ b/src/bdd/cudd/cuddDecomp.c
@@ -37,6 +37,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -130,7 +133,7 @@ static int cuddConjunctsAux ARGS((DdManager * dd, DdNode * f, DdNode ** c1, DdNo
SideEffects [The factors are returned in an array as side effects.
The array is allocated by this function. It is the caller's responsibility
- to ABC_FREE it. On successful completion, the conjuncts are already
+ to free it. On successful completion, the conjuncts are already
referenced. If the function returns 0, the array for the conjuncts is
not allocated. If the function returns 1, the only factor equals the
function to be decomposed.]
@@ -229,7 +232,7 @@ Cudd_bddApproxConjDecomp(
SideEffects [The two disjuncts are returned in an array as side effects.
The array is allocated by this function. It is the caller's responsibility
- to ABC_FREE it. On successful completion, the disjuncts are already
+ to free it. On successful completion, the disjuncts are already
referenced. If the function returns 0, the array for the disjuncts is
not allocated. If the function returns 1, the only factor equals the
function to be decomposed.]
@@ -268,7 +271,7 @@ Cudd_bddApproxDisjDecomp(
SideEffects [The factors are returned in an array as side effects.
The array is allocated by this function. It is the caller's responsibility
- to ABC_FREE it. On successful completion, the conjuncts are already
+ to free it. On successful completion, the conjuncts are already
referenced. If the function returns 0, the array for the conjuncts is
not allocated. If the function returns 1, the only factor equals the
function to be decomposed.]
@@ -412,7 +415,7 @@ Cudd_bddIterConjDecomp(
SideEffects [The two disjuncts are returned in an array as side effects.
The array is allocated by this function. It is the caller's responsibility
- to ABC_FREE it. On successful completion, the disjuncts are already
+ to free it. On successful completion, the disjuncts are already
referenced. If the function returns 0, the array for the disjuncts is
not allocated. If the function returns 1, the only factor equals the
function to be decomposed.]
@@ -452,7 +455,7 @@ Cudd_bddIterDisjDecomp(
SideEffects [The two factors are returned in an array as side effects.
The array is allocated by this function. It is the caller's responsibility
- to ABC_FREE it. On successful completion, the conjuncts are already
+ to free it. On successful completion, the conjuncts are already
referenced. If the function returns 0, the array for the conjuncts is
not allocated. If the function returns 1, the only factor equals the
function to be decomposed.]
@@ -531,7 +534,7 @@ Cudd_bddGenConjDecomp(
SideEffects [The two disjuncts are returned in an array as side effects.
The array is allocated by this function. It is the caller's responsibility
- to ABC_FREE it. On successful completion, the disjuncts are already
+ to free it. On successful completion, the disjuncts are already
referenced. If the function returns 0, the array for the disjuncts is
not allocated. If the function returns 1, the only factor equals the
function to be decomposed.]
@@ -571,7 +574,7 @@ Cudd_bddGenDisjDecomp(
SideEffects [The two factors are returned in an array as side effects.
The array is allocated by this function. It is the caller's responsibility
- to ABC_FREE it. On successful completion, the conjuncts are already
+ to free it. On successful completion, the conjuncts are already
referenced. If the function returns 0, the array for the conjuncts is
not allocated. If the function returns 1, the only factor equals the
function to be decomposed.]
@@ -689,7 +692,7 @@ Cudd_bddVarConjDecomp(
SideEffects [The two disjuncts are returned in an array as side effects.
The array is allocated by this function. It is the caller's responsibility
- to ABC_FREE it. On successful completion, the disjuncts are already
+ to free it. On successful completion, the disjuncts are already
referenced. If the function returns 0, the array for the disjuncts is
not allocated. If the function returns 1, the only factor equals the
function to be decomposed.]
@@ -1617,7 +1620,7 @@ ZeroCase(
Cudd_RecursiveDeref(dd, g2);
Cudd_RecursiveDeref(dd, h2);
} else {
- /* now ABC_FREE what was created and not used */
+ /* now free what was created and not used */
if ((factors->g == g1) || (factors->g == h1)) {
Cudd_RecursiveDeref(dd, g2);
Cudd_RecursiveDeref(dd, h2);
@@ -1943,7 +1946,7 @@ BuildConjuncts(
Cudd_RecursiveDeref(dd, g2);
Cudd_RecursiveDeref(dd, h2);
} else {
- /* now ABC_FREE what was created and not used */
+ /* now free what was created and not used */
if ((factors->g == g1) || (factors->g == h1)) {
Cudd_RecursiveDeref(dd, g2);
Cudd_RecursiveDeref(dd, h2);
@@ -1996,7 +1999,7 @@ cuddConjunctsAux(
*c2 = NULL;
/* initialize distances table */
- distanceTable = st_init_table(st_ptrcmp,st_ptrhash);
+ distanceTable = st_init_table(st_ptrcmp, st_ptrhash);;
if (distanceTable == NULL) goto outOfMem;
/* make the entry for the constant */
@@ -2023,7 +2026,7 @@ cuddConjunctsAux(
cuddRef(*c1); cuddRef(*c2);
stGen = st_init_gen(distanceTable);
if (stGen == NULL) goto outOfMem;
- while(st_gen(stGen, (char **)&key, (char **)&value)) {
+ while(st_gen(stGen, (const char **)&key, (char **)&value)) {
ABC_FREE(value);
}
st_free_gen(stGen); stGen = NULL;
@@ -2035,7 +2038,7 @@ cuddConjunctsAux(
maxLocalRef = 0;
stGen = st_init_gen(distanceTable);
if (stGen == NULL) goto outOfMem;
- while(st_gen(stGen, (char **)&key, (char **)&value)) {
+ while(st_gen(stGen, (const char **)&key, (char **)&value)) {
nodeStat = (NodeStat *)value;
maxLocalRef = (nodeStat->localRef > maxLocalRef) ?
nodeStat->localRef : maxLocalRef;
@@ -2045,7 +2048,7 @@ cuddConjunctsAux(
/* Count minterms for each node. */
max = pow(2.0, (double)Cudd_SupportSize(dd,f)); /* potential overflow */
- mintermTable = st_init_table(st_ptrcmp,st_ptrhash);
+ mintermTable = st_init_table(st_ptrcmp, st_ptrhash);;
if (mintermTable == NULL) goto outOfMem;
minterms = CountMinterms(f, max, mintermTable, dd->err);
if (minterms == -1.0) goto outOfMem;
@@ -2061,10 +2064,10 @@ cuddConjunctsAux(
approxDistance, maxLocalRef, ghTable, mintermTable);
if (factors == NULL) goto outOfMem;
- /* ABC_FREE up tables */
+ /* Free up tables */
stGen = st_init_gen(distanceTable);
if (stGen == NULL) goto outOfMem;
- while(st_gen(stGen, (char **)&key, (char **)&value)) {
+ while(st_gen(stGen, (const char **)&key, (char **)&value)) {
ABC_FREE(value);
}
st_free_gen(stGen); stGen = NULL;
@@ -2073,7 +2076,7 @@ cuddConjunctsAux(
stGen = st_init_gen(mintermTable);
if (stGen == NULL) goto outOfMem;
- while(st_gen(stGen, (char **)&key, (char **)&value)) {
+ while(st_gen(stGen, (const char **)&key, (char **)&value)) {
ABC_FREE(value);
}
st_free_gen(stGen); stGen = NULL;
@@ -2107,7 +2110,7 @@ cuddConjunctsAux(
stGen = st_init_gen(cacheTable);
if (stGen == NULL) goto outOfMem;
- while(st_gen(stGen, (char **)&key, (char **)&value)) {
+ while(st_gen(stGen, (const char **)&key, (char **)&value)) {
ConjunctsFree(dd, (Conjuncts *)value);
}
st_free_gen(stGen); stGen = NULL;
@@ -2120,7 +2123,7 @@ outOfMem:
if (distanceTable != NULL) {
stGen = st_init_gen(distanceTable);
if (stGen == NULL) goto outOfMem;
- while(st_gen(stGen, (char **)&key, (char **)&value)) {
+ while(st_gen(stGen, (const char **)&key, (char **)&value)) {
ABC_FREE(value);
}
st_free_gen(stGen); stGen = NULL;
@@ -2129,7 +2132,7 @@ outOfMem:
if (mintermTable != NULL) {
stGen = st_init_gen(mintermTable);
if (stGen == NULL) goto outOfMem;
- while(st_gen(stGen, (char **)&key, (char **)&value)) {
+ while(st_gen(stGen, (const char **)&key, (char **)&value)) {
ABC_FREE(value);
}
st_free_gen(stGen); stGen = NULL;
@@ -2139,7 +2142,7 @@ outOfMem:
if (cacheTable != NULL) {
stGen = st_init_gen(cacheTable);
if (stGen == NULL) goto outOfMem;
- while(st_gen(stGen, (char **)&key, (char **)&value)) {
+ while(st_gen(stGen, (const char **)&key, (char **)&value)) {
ConjunctsFree(dd, (Conjuncts *)value);
}
st_free_gen(stGen); stGen = NULL;
@@ -2149,3 +2152,5 @@ outOfMem:
return(0);
} /* end of cuddConjunctsAux */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddEssent.c b/src/bdd/cudd/cuddEssent.c
index db4b8b49..2d82019c 100644
--- a/src/bdd/cudd/cuddEssent.c
+++ b/src/bdd/cudd/cuddEssent.c
@@ -28,6 +28,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -277,3 +280,5 @@ ddFindEssentialRecur(
} /* end of ddFindEssentialRecur */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddExact.c b/src/bdd/cudd/cuddExact.c
index 9472dd8b..b9ed4676 100644
--- a/src/bdd/cudd/cuddExact.c
+++ b/src/bdd/cudd/cuddExact.c
@@ -43,6 +43,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -1002,3 +1005,5 @@ checkSymmInfo(
} /* end of checkSymmInfo */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddExport.c b/src/bdd/cudd/cuddExport.c
index 18caeaa0..cccf2465 100644
--- a/src/bdd/cudd/cuddExport.c
+++ b/src/bdd/cudd/cuddExport.c
@@ -38,6 +38,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -136,7 +139,7 @@ Cudd_DumpBlif(
scan = cuddT(scan);
}
Cudd_RecursiveDeref(dd,support);
- support = NULL; /* so that we do not try to ABC_FREE it in case of failure */
+ support = NULL; /* so that we do not try to free it in case of failure */
/* Write the header (.model .inputs .outputs). */
if (mname == NULL) {
@@ -342,7 +345,7 @@ Cudd_DumpDot(
scan = cuddT(scan);
}
Cudd_RecursiveDeref(dd,support);
- support = NULL; /* so that we do not try to ABC_FREE it in case of failure */
+ support = NULL; /* so that we do not try to free it in case of failure */
/* Initialize symbol table for visited nodes. */
visited = st_init_table(st_ptrcmp, st_ptrhash);
@@ -370,7 +373,7 @@ Cudd_DumpDot(
diff = 0;
gen = st_init_gen(visited);
if (gen == NULL) goto failure;
- while (st_gen(gen, (char **) &scan, NULL)) {
+ while (st_gen(gen, (const char **) &scan, NULL)) {
diff |= refAddr ^ (long) scan;
}
st_free_gen(gen); gen = NULL;
@@ -621,7 +624,7 @@ Cudd_DumpDaVinci(
refAddr = (long) Cudd_Regular(f[0]);
diff = 0;
gen = st_init_gen(visited);
- while (st_gen(gen, (char **) &scan, NULL)) {
+ while (st_gen(gen, (const char **) &scan, NULL)) {
diff |= refAddr ^ (long) scan;
}
st_free_gen(gen);
@@ -737,7 +740,7 @@ Cudd_DumpDDcal(
refAddr = (long) Cudd_Regular(f[0]);
diff = 0;
gen = st_init_gen(visited);
- while (st_gen(gen, (char **) &scan, NULL)) {
+ while (st_gen(gen, (const char **) &scan, NULL)) {
diff |= refAddr ^ (long) scan;
}
st_free_gen(gen);
@@ -767,7 +770,7 @@ Cudd_DumpDDcal(
scan = cuddT(scan);
}
Cudd_RecursiveDeref(dd,support);
- support = NULL; /* so that we do not try to ABC_FREE it in case of failure */
+ support = NULL; /* so that we do not try to free it in case of failure */
for (i = 0; i < nvars; i++) {
if (sorted[dd->invperm[i]]) {
if (inames == NULL || inames[dd->invperm[i]] == NULL) {
@@ -1287,3 +1290,5 @@ ddDoDumpFactoredForm(
} /* end of ddDoDumpFactoredForm */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddGenCof.c b/src/bdd/cudd/cuddGenCof.c
index 660526ee..93e15da0 100644
--- a/src/bdd/cudd/cuddGenCof.c
+++ b/src/bdd/cudd/cuddGenCof.c
@@ -49,6 +49,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
@@ -100,7 +103,7 @@ static int cuddBddConstrainDecomp ARGS((DdManager *dd, DdNode *f, DdNode **decom
static DdNode * cuddBddCharToVect ARGS((DdManager *dd, DdNode *f, DdNode *x));
static int cuddBddLICMarkEdges ARGS((DdManager *dd, DdNode *f, DdNode *c, st_table *table, st_table *cache));
static DdNode * cuddBddLICBuildResult ARGS((DdManager *dd, DdNode *f, st_table *cache, st_table *table));
-static int MarkCacheHash ARGS((char *ptr, int modulus));
+static int MarkCacheHash ARGS((const char *ptr, int modulus));
static int MarkCacheCompare ARGS((const char *ptr1, const char *ptr2));
static enum st_retval MarkCacheCleanUp ARGS((char *key, char *value, char *arg));
static DdNode * cuddBddSqueeze ARGS((DdManager *dd, DdNode *l, DdNode *u));
@@ -1237,7 +1240,7 @@ cuddBddLICompaction(
** appears. Hence, the same node and constrain may give different results
** in successive invocations.
*/
- marktable = st_init_table(st_ptrcmp,st_ptrhash);
+ marktable = st_init_table(st_ptrcmp, st_ptrhash);;
if (marktable == NULL) {
return(NULL);
}
@@ -1247,14 +1250,14 @@ cuddBddLICompaction(
return(NULL);
}
if (cuddBddLICMarkEdges(dd,f,c,marktable,markcache) == CUDD_OUT_OF_MEM) {
- st_foreach(markcache, MarkCacheCleanUp, NULL);
+ st_foreach(markcache, (ST_PFSR)MarkCacheCleanUp, NULL);
st_free_table(marktable);
st_free_table(markcache);
return(NULL);
}
- st_foreach(markcache, MarkCacheCleanUp, NULL);
+ st_foreach(markcache, (ST_PFSR)MarkCacheCleanUp, NULL);
st_free_table(markcache);
- buildcache = st_init_table(st_ptrcmp,st_ptrhash);
+ buildcache = st_init_table(st_ptrcmp, st_ptrhash);;
if (buildcache == NULL) {
st_free_table(marktable);
return(NULL);
@@ -1662,13 +1665,13 @@ cuddBddLICBuildResult(
******************************************************************************/
static int
MarkCacheHash(
- char * ptr,
+ const char * ptr,
int modulus)
{
int val = 0;
- MarkCacheKey *entry;
+ const MarkCacheKey *entry;
- entry = (MarkCacheKey *) ptr;
+ entry = (const MarkCacheKey *) ptr;
val = (int) (ptrint) entry->f;
val = val * 997 + (int) (ptrint) entry->c;
@@ -1966,3 +1969,5 @@ cuddBddSqueeze(
return(Cudd_NotCond(r,comple));
} /* end of cuddBddSqueeze */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddGenetic.c b/src/bdd/cudd/cuddGenetic.c
index 3b10aecb..d2739c85 100644
--- a/src/bdd/cudd/cuddGenetic.c
+++ b/src/bdd/cudd/cuddGenetic.c
@@ -56,6 +56,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -115,7 +118,7 @@ static int sift_up ARGS((DdManager *table, int x, int x_low));
static int build_dd ARGS((DdManager *table, int num, int lower, int upper));
static int largest ARGS(());
static int rand_int ARGS((int a));
-static int array_hash ARGS((char *array, int modulus));
+static int array_hash ARGS((const char *array, int modulus));
static int array_compare ARGS((const char *array1, const char *array2));
static int find_best ARGS(());
static double find_average_fitness ARGS(());
@@ -333,7 +336,7 @@ cuddGa(
repeat[index]--;
if (repeat[index] == 0) {
int *pointer = &STOREDD(index,0);
- result = st_delete(computed, (char **)&pointer,NULL);
+ result = st_delete(computed, (const char **)&pointer,NULL);
if (!result) {
ABC_FREE(storedd);
ABC_FREE(repeat);
@@ -632,14 +635,14 @@ rand_int(
******************************************************************************/
static int
array_hash(
- char * array,
+ const char * array,
int modulus)
{
int val = 0;
int i;
- int *intarray;
+ const int *intarray;
- intarray = (int *) array;
+ intarray = (const int *) array;
for (i = 0; i < numvars; i++) {
val = val * 997 + intarray[i];
@@ -919,3 +922,5 @@ roulette(
} /* end of roulette */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddGroup.c b/src/bdd/cudd/cuddGroup.c
index 3d987400..e38eee72 100644
--- a/src/bdd/cudd/cuddGroup.c
+++ b/src/bdd/cudd/cuddGroup.c
@@ -52,6 +52,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -2059,7 +2062,7 @@ ddVarGroupCheck(
ddIsVarHandled(table, yindex)) {
if (Cudd_bddIsVarToBeGrouped(table, xindex) ||
Cudd_bddIsVarToBeGrouped(table, yindex) ) {
- if (table->keys - table->isolated <= originalSize) {
+ if (table->keys - table->isolated <= (unsigned)originalSize) {
return(1);
}
}
@@ -2140,3 +2143,5 @@ ddIsVarHandled(
return dd->subtables[dd->perm[index]].varHandled;
} /* end of ddIsVarHandled */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddHarwell.c b/src/bdd/cudd/cuddHarwell.c
index 45ff736c..af552148 100644
--- a/src/bdd/cudd/cuddHarwell.c
+++ b/src/bdd/cudd/cuddHarwell.c
@@ -24,6 +24,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -539,3 +542,5 @@ Cudd_addHarwell(
/* Definition of static functions */
/*---------------------------------------------------------------------------*/
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddInit.c b/src/bdd/cudd/cuddInit.c
index 20a88b11..43b2ac29 100644
--- a/src/bdd/cudd/cuddInit.c
+++ b/src/bdd/cudd/cuddInit.c
@@ -32,6 +32,9 @@
#include "util_hack.h"
#define CUDD_MAIN
#include "cuddInt.h"
+
+ABC_NAMESPACE_IMPL_START
+
#undef CUDD_MAIN
/*---------------------------------------------------------------------------*/
@@ -105,7 +108,7 @@ Cudd_Init(
DdNode *one, *zero;
unsigned int maxCacheSize;
unsigned int looseUpTo;
- extern void (*MMoutOfMemory)(long);
+// extern void (*MMoutOfMemory)(long);
void (*saveHandler)(long);
if (maxMemory == 0) {
@@ -171,6 +174,7 @@ Cudd_Init(
unique->memused += sizeof(DdNode *) * unique->maxSize;
+ unique->bReached = NULL;
return(unique);
} /* end of Cudd_Init */
@@ -281,3 +285,5 @@ cuddZddFreeUniv(
/* Definition of static functions */
/*---------------------------------------------------------------------------*/
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddInt.h b/src/bdd/cudd/cuddInt.h
index df843e33..84146132 100644
--- a/src/bdd/cudd/cuddInt.h
+++ b/src/bdd/cudd/cuddInt.h
@@ -25,6 +25,7 @@
#define _CUDDINT
+
/*---------------------------------------------------------------------------*/
/* Nested includes */
/*---------------------------------------------------------------------------*/
@@ -46,6 +47,9 @@
#include "cudd.h"
#include "st.h"
+ABC_NAMESPACE_HEADER_START
+
+
#if defined(__GNUC__)
# define DD_INLINE __inline__
# if (__GNUC__ >2 || __GNUC_MINOR__ >=7)
@@ -346,7 +350,7 @@ struct DdManager { /* specialized DD symbol table */
long *linear; /* linear transform matrix */
/* Memory Management */
DdNode **memoryList; /* memory manager for symbol table */
- DdNode *nextFree; /* list of ABC_FREE nodes */
+ DdNode *nextFree; /* list of free nodes */
char *stash; /* memory reserve */
#ifndef DD_NO_DEATH_ROW
DdNode **deathRow; /* queue for dereferencing */
@@ -410,7 +414,7 @@ struct DdManager { /* specialized DD symbol table */
double cacheLastInserts; /* insertions at the last cache resizing */
double cachedeletions; /* number of deletions during garbage coll. */
#ifdef DD_STATS
- double nodesFreed; /* number of nodes returned to the ABC_FREE list */
+ double nodesFreed; /* number of nodes returned to the free list */
double nodesDropped; /* number of nodes killed by dereferencing */
#endif
unsigned int peakLiveNodes; /* maximum number of live nodes */
@@ -435,6 +439,7 @@ struct DdManager { /* specialized DD symbol table */
int nvars; /* variables used so far */
int threshold; /* for pseudo var threshold value*/
#endif
+ DdNode * bReached;
};
typedef struct Move {
@@ -481,10 +486,10 @@ typedef struct DdLevelQueue {
/**Macro***********************************************************************
- Synopsis [Adds node to the head of the ABC_FREE list.]
+ Synopsis [Adds node to the head of the free list.]
- Description [Adds node to the head of the ABC_FREE list. Does not
- deallocate memory chunks that become ABC_FREE. This function is also
+ Description [Adds node to the head of the free list. Does not
+ deallocate memory chunks that become free. This function is also
used by the dynamic reordering functions.]
SideEffects [None]
@@ -1128,6 +1133,12 @@ EXTERN int cuddZddSymmSifting ARGS((DdManager *table, int lower, int upper));
EXTERN int cuddZddSymmSiftingConv ARGS((DdManager *table, int lower, int upper));
EXTERN int cuddZddP ARGS((DdManager *zdd, DdNode *f));
+EXTERN void (*MMoutOfMemory)(long);
+
/**AutomaticEnd***************************************************************/
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif /* _CUDDINT */
diff --git a/src/bdd/cudd/cuddInteract.c b/src/bdd/cudd/cuddInteract.c
index 3745b408..3891e9d0 100644
--- a/src/bdd/cudd/cuddInteract.c
+++ b/src/bdd/cudd/cuddInteract.c
@@ -50,6 +50,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -400,3 +403,5 @@ ddClearGlobal(
} /* end of ddClearGlobal */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddLCache.c b/src/bdd/cudd/cuddLCache.c
index 97546cda..bf6af8bd 100644
--- a/src/bdd/cudd/cuddLCache.c
+++ b/src/bdd/cudd/cuddLCache.c
@@ -48,6 +48,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -658,7 +661,7 @@ cuddHashTableInsert(
is an entry for the given key in the table; NULL otherwise. If the
entry is present, its reference counter is decremented if not
saturated. If the counter reaches 0, the value of the entry is
- dereferenced, and the entry is returned to the ABC_FREE list.]
+ dereferenced, and the entry is returned to the free list.]
SideEffects [None]
@@ -1071,7 +1074,7 @@ cuddLocalCacheResize(
int i, shift;
unsigned int posn;
unsigned int slots, oldslots;
- extern void (*MMoutOfMemory)(long);
+// extern void (*MMoutOfMemory)(long);
void (*saveHandler)(long);
olditem = cache->item;
@@ -1261,7 +1264,7 @@ cuddHashTableResize(
#endif
int shift;
int oldNumBuckets = hash->numBuckets;
- extern void (*MMoutOfMemory)(long);
+// extern void (*MMoutOfMemory)(long);
void (*saveHandler)(long);
/* Compute the new size of the table. */
@@ -1362,7 +1365,7 @@ cuddHashTableAlloc(
{
int i;
unsigned int itemsize = hash->itemsize;
- extern void (*MMoutOfMemory)(long);
+// extern void (*MMoutOfMemory)(long);
void (*saveHandler)(long);
#ifdef __osf__
#pragma pointer_size save
@@ -1384,7 +1387,7 @@ cuddHashTableAlloc(
hash->manager->stash = NULL;
/* Inhibit resizing of tables. */
hash->manager->maxCacheHard = hash->manager->cacheSlots - 1;
- hash->manager->cacheSlack = -(hash->manager->cacheSlots + 1);
+ hash->manager->cacheSlack = -(int)(hash->manager->cacheSlots + 1);
for (i = 0; i < hash->manager->size; i++) {
hash->manager->subtables[i].maxKeys <<= 2;
}
@@ -1426,3 +1429,5 @@ cuddHashTableAlloc(
return(item);
} /* end of cuddHashTableAlloc */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddLevelQ.c b/src/bdd/cudd/cuddLevelQ.c
index 28823a83..1a09820a 100644
--- a/src/bdd/cudd/cuddLevelQ.c
+++ b/src/bdd/cudd/cuddLevelQ.c
@@ -21,7 +21,7 @@
pointers. The level queue functions make sure that each node
appears at most once in the queue. They do so by keeping a hash
table where the node is used as key. Queue items are recycled via a
- ABC_FREE list for efficiency.
+ free list for efficiency.
Internal procedures provided by this module:
<ul>
@@ -53,6 +53,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -125,7 +128,7 @@ static int hashResize ARGS((DdLevelQueue *queue));
Description [Initializes a level queue. A level queue is a queue
where inserts are based on the levels of the nodes. Within each
level the policy is FIFO. Level queues are useful in traversing a
- BDD top-down. Queue items are kept in a ABC_FREE list when dequeued for
+ BDD top-down. Queue items are kept in a free list when dequeued for
efficiency. Returns a pointer to the new queue if successful; NULL
otherwise.]
@@ -263,7 +266,7 @@ cuddLevelQueueEnqueue(
item = hashLookup(queue,key);
if (item != NULL) return(item);
- /* Get a ABC_FREE item from either the ABC_FREE list or the memory manager. */
+ /* Get a free item from either the free list or the memory manager. */
if (queue->freelist == NULL) {
item = (DdQueueItem *) ABC_ALLOC(char, queue->itemsize);
if (item == NULL)
@@ -335,7 +338,7 @@ cuddLevelQueueDequeue(
queue->last[level] = NULL;
queue->first = item->next;
- /* Put item on the ABC_FREE list. */
+ /* Put item on the free list. */
item->next = queue->freelist;
queue->freelist = item;
/* Update stats. */
@@ -493,7 +496,7 @@ hashResize(
#endif
int shift;
int oldNumBuckets = queue->numBuckets;
- extern void (*MMoutOfMemory)(long);
+// extern void (*MMoutOfMemory)(long);
void (*saveHandler)(long);
/* Compute the new size of the subtable. */
@@ -531,3 +534,5 @@ hashResize(
return(1);
} /* end of hashResize */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddLinear.c b/src/bdd/cudd/cuddLinear.c
index 30537e6c..9cb19e95 100644
--- a/src/bdd/cudd/cuddLinear.c
+++ b/src/bdd/cudd/cuddLinear.c
@@ -37,6 +37,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -1331,3 +1334,5 @@ cuddXorLinear(
} /* end of cuddXorLinear */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddLiteral.c b/src/bdd/cudd/cuddLiteral.c
index 43740690..c5684e9b 100644
--- a/src/bdd/cudd/cuddLiteral.c
+++ b/src/bdd/cudd/cuddLiteral.c
@@ -28,6 +28,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
@@ -235,3 +238,5 @@ cuddBddLiteralSetIntersectionRecur(
/* Definition of static functions */
/*---------------------------------------------------------------------------*/
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddMatMult.c b/src/bdd/cudd/cuddMatMult.c
index 75e5a732..b4ec5c6a 100644
--- a/src/bdd/cudd/cuddMatMult.c
+++ b/src/bdd/cudd/cuddMatMult.c
@@ -32,6 +32,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
@@ -678,3 +681,5 @@ cuddAddOuterSumRecur(
return(R);
} /* end of cuddAddOuterSumRecur */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddPriority.c b/src/bdd/cudd/cuddPriority.c
index af07c7f0..f67fb88a 100644
--- a/src/bdd/cudd/cuddPriority.c
+++ b/src/bdd/cudd/cuddPriority.c
@@ -46,6 +46,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
@@ -1474,3 +1477,5 @@ createResult(
return(res);
} /* end of createResult */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddRead.c b/src/bdd/cudd/cuddRead.c
index 8e4ea60c..52670a6c 100644
--- a/src/bdd/cudd/cuddRead.c
+++ b/src/bdd/cudd/cuddRead.c
@@ -26,6 +26,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
@@ -488,3 +491,5 @@ Cudd_bddRead(
/* Definition of static functions */
/*---------------------------------------------------------------------------*/
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddRef.c b/src/bdd/cudd/cuddRef.c
index 7cb5d41b..a8f654af 100644
--- a/src/bdd/cudd/cuddRef.c
+++ b/src/bdd/cudd/cuddRef.c
@@ -41,6 +41,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -308,7 +311,7 @@ Cudd_DelayedDerefBdd(
#if 0
if (table->nextDead == table->deathRowDepth) {
if (table->deathRowDepth < table->looseUpTo / 2) {
- extern void (*MMoutOfMemory)(long);
+// extern void (*MMoutOfMemory)(long);
void (*saveHandler)(long) = MMoutOfMemory;
DdNodePtr *newRow;
MMoutOfMemory = Cudd_OutOfMem;
@@ -779,3 +782,5 @@ cuddTimesInDeathRow(
/*---------------------------------------------------------------------------*/
/* Definition of static functions */
/*---------------------------------------------------------------------------*/
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddReorder.c b/src/bdd/cudd/cuddReorder.c
index 7c2fac39..93bbb10b 100644
--- a/src/bdd/cudd/cuddReorder.c
+++ b/src/bdd/cudd/cuddReorder.c
@@ -48,6 +48,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -378,10 +381,10 @@ cuddDynamicAllocNode(
int i;
DdNodePtr *mem;
DdNode *list, *node;
- extern void (*MMoutOfMemory)(long);
+// extern void (*MMoutOfMemory)(long);
void (*saveHandler)(long);
- if (table->nextFree == NULL) { /* ABC_FREE list is empty */
+ if (table->nextFree == NULL) { /* free list is empty */
/* Try to allocate a new block. */
saveHandler = MMoutOfMemory;
MMoutOfMemory = Cudd_OutOfMem;
@@ -392,7 +395,7 @@ cuddDynamicAllocNode(
table->stash = NULL;
/* Inhibit resizing of tables. */
table->maxCacheHard = table->cacheSlots - 1;
- table->cacheSlack = -(table->cacheSlots + 1);
+ table->cacheSlack = -(int)(table->cacheSlots + 1);
for (i = 0; i < table->size; i++) {
table->subtables[i].maxKeys <<= 2;
}
@@ -438,7 +441,7 @@ cuddDynamicAllocNode(
table->nextFree = &list[0];
}
- } /* if ABC_FREE list empty */
+ } /* if free list empty */
node = table->nextFree;
table->nextFree = node->next;
@@ -742,7 +745,7 @@ cuddSwapInPlace(
DdNodePtr *previousP;
DdNode *tmp;
DdNode *sentinel = &(table->sentinel);
- extern void (*MMoutOfMemory)(long);
+// extern void (*MMoutOfMemory)(long);
void (*saveHandler)(long);
#if DD_DEBUG
@@ -2088,3 +2091,5 @@ ddCheckPermuation(
}
return(1);
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddSat.c b/src/bdd/cudd/cuddSat.c
index a1fb79f7..cb0534c3 100644
--- a/src/bdd/cudd/cuddSat.c
+++ b/src/bdd/cudd/cuddSat.c
@@ -45,6 +45,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -214,7 +217,7 @@ Cudd_ShortestPath(
sol = getPath(manager,visited,f,weight,cost);
} while (manager->reordered == 1);
- st_foreach(visited, freePathPair, NULL);
+ st_foreach(visited, (ST_PFSR)freePathPair, NULL);
st_free_table(visited);
*length = cost;
@@ -284,7 +287,7 @@ Cudd_LargestCube(
sol = getCube(manager,visited,f,cost);
} while (manager->reordered == 1);
- st_foreach(visited, freePathPair, NULL);
+ st_foreach(visited, (ST_PFSR)freePathPair, NULL);
st_free_table(visited);
*length = cost;
@@ -345,7 +348,7 @@ Cudd_ShortestLength(
cost = my_pair->pos;
}
- st_foreach(visited, freePathPair, NULL);
+ st_foreach(visited, (ST_PFSR)freePathPair, NULL);
st_free_table(visited);
return(cost);
@@ -1303,3 +1306,5 @@ getCube(
return(sol);
} /* end of getCube */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddSign.c b/src/bdd/cudd/cuddSign.c
index d58c1b43..b2b043a4 100644
--- a/src/bdd/cudd/cuddSign.c
+++ b/src/bdd/cudd/cuddSign.c
@@ -28,6 +28,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
@@ -149,7 +152,7 @@ Cudd_CofMinterm(
table_mem += table->num_bins * sizeof(st_table_entry *);
#endif
if (Cudd_Regular(node)->ref == 1) ABC_FREE(values);
- st_foreach(table, cuddStCountfree, NULL);
+ st_foreach(table, (ST_PFSR)cuddStCountfree, NULL);
st_free_table(table);
#ifdef DD_STATS
(void) fprintf(dd->out,"Number of calls: %d\tTable memory: %d bytes\n",
@@ -290,3 +293,5 @@ ddCofMintermAux(
} /* end of ddCofMintermAux */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddSolve.c b/src/bdd/cudd/cuddSolve.c
index a78055f3..18d29dac 100644
--- a/src/bdd/cudd/cuddSolve.c
+++ b/src/bdd/cudd/cuddSolve.c
@@ -31,6 +31,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -337,3 +340,5 @@ cuddVerifySol(
/* Definition of static functions */
/*---------------------------------------------------------------------------*/
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddSplit.c b/src/bdd/cudd/cuddSplit.c
index 1f9a0425..bad35d60 100644
--- a/src/bdd/cudd/cuddSplit.c
+++ b/src/bdd/cudd/cuddSplit.c
@@ -35,6 +35,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -150,7 +153,7 @@ Cudd_SplitSet(
cuddRef(result);
ABC_FREE(varSeen);
} else {
- mtable = st_init_table(st_ptrcmp,st_ptrhash);
+ mtable = st_init_table(st_ptrcmp, st_ptrhash);;
if (mtable == NULL) {
(void) fprintf(manager->out,
"Cudd_SplitSet: out-of-memory.\n");
@@ -164,7 +167,7 @@ Cudd_SplitSet(
*/
num = bddAnnotateMintermCount(manager,S,max,mtable);
if (m == num) {
- st_foreach(mtable,cuddStCountfree,NIL(char));
+ st_foreach(mtable,(ST_PFSR)cuddStCountfree,NIL(char));
st_free_table(mtable);
ABC_FREE(varSeen);
return(S);
@@ -173,7 +176,7 @@ Cudd_SplitSet(
result = cuddSplitSetRecur(manager,mtable,varSeen,S,m,max,0);
if (result)
cuddRef(result);
- st_foreach(mtable,cuddStCountfree,NULL);
+ st_foreach(mtable,(ST_PFSR)cuddStCountfree,NULL);
st_free_table(mtable);
ABC_FREE(varSeen);
}
@@ -655,3 +658,5 @@ bddAnnotateMintermCount(
return(min_N);
} /* end of bddAnnotateMintermCount */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddSubsetHB.c b/src/bdd/cudd/cuddSubsetHB.c
index 59f8e6d2..86ed380f 100644
--- a/src/bdd/cudd/cuddSubsetHB.c
+++ b/src/bdd/cudd/cuddSubsetHB.c
@@ -49,6 +49,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -367,7 +370,7 @@ cuddSubsetHeavyBranch(
st_free_table(approxTable);
return(NULL);
}
- while(st_gen(stGen, (char **)&key, (char **)&value)) {
+ while(st_gen(stGen, (const char **)&key, (char **)&value)) {
Cudd_RecursiveDeref(dd, (DdNode *)value);
}
st_free_gen(stGen); stGen = NULL;
@@ -378,7 +381,7 @@ cuddSubsetHeavyBranch(
st_free_table(storeTable);
return(NULL);
}
- while(st_gen(stGen, (char **)&key, (char **)&value)) {
+ while(st_gen(stGen, (const char **)&key, (char **)&value)) {
Cudd_RecursiveDeref(dd, (DdNode *)key);
}
st_free_gen(stGen); stGen = NULL;
@@ -777,7 +780,7 @@ SubsetCountMinterm(
#endif
max = pow(2.0,(double) nvars);
- table = st_init_table(st_ptrcmp,st_ptrhash);
+ table = st_init_table(st_ptrcmp, st_ptrhash);;
if (table == NULL) goto OUT_OF_MEM;
maxPages = INITIAL_PAGES;
mintermPages = ABC_ALLOC(double *,maxPages);
@@ -1309,3 +1312,5 @@ BuildSubsetBdd(
}
} /* end of BuildSubsetBdd */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddSubsetSP.c b/src/bdd/cudd/cuddSubsetSP.c
index 25c22b88..d336187b 100644
--- a/src/bdd/cudd/cuddSubsetSP.c
+++ b/src/bdd/cudd/cuddSubsetSP.c
@@ -44,6 +44,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -410,7 +413,7 @@ cuddSubsetShortPaths(
st_free_table(subsetNodeTable);
}
st_free_table(info->maxpathTable);
- st_foreach(pathTable, stPathTableDdFree, (char *)dd);
+ st_foreach(pathTable, (ST_PFSR)stPathTableDdFree, (char *)dd);
ABC_FREE(info);
@@ -996,7 +999,7 @@ CreatePathTable(
int childQueueIndex, parentQueueIndex;
/* Creating path Table for storing data about nodes */
- pathTable = st_init_table(st_ptrcmp,st_ptrhash);
+ pathTable = st_init_table(st_ptrcmp, st_ptrhash);;
/* initializing pages for info about each node */
maxNodeDistPages = INITIAL_PAGES;
@@ -1101,7 +1104,7 @@ CreatePathTable(
*/
if (!CreateBotDist(node, pathTable, pathLengthArray, fp)) return(NULL);
- /* ABC_FREE BFS queue pages as no longer required */
+ /* free BFS queue pages as no longer required */
for (i = 0; i <= queuePage; i++) ABC_FREE(queuePages[i]);
ABC_FREE(queuePages);
return(pathTable);
@@ -1595,7 +1598,7 @@ BuildSubsetBdd(
/**Function********************************************************************
- Synopsis [Procedure to ABC_FREE te result dds stored in the NodeDist pages.]
+ Synopsis [Procedure to free the result dds stored in the NodeDist pages.]
Description [None]
@@ -1624,3 +1627,5 @@ stPathTableDdFree(
return(ST_CONTINUE);
} /* end of stPathTableFree */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddSymmetry.c b/src/bdd/cudd/cuddSymmetry.c
index a608a21f..88e607e5 100644
--- a/src/bdd/cudd/cuddSymmetry.c
+++ b/src/bdd/cudd/cuddSymmetry.c
@@ -41,6 +41,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -1666,3 +1669,5 @@ ddSymmSummary(
return;
} /* end of ddSymmSummary */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddTable.c b/src/bdd/cudd/cuddTable.c
index 3c76c1af..6ec6f6e7 100644
--- a/src/bdd/cudd/cuddTable.c
+++ b/src/bdd/cudd/cuddTable.c
@@ -57,6 +57,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -202,10 +205,10 @@ cuddAllocNode(
int i;
DdNodePtr *mem;
DdNode *list, *node;
- extern void (*MMoutOfMemory)(long);
+// extern void (*MMoutOfMemory)(long);
void (*saveHandler)(long);
- if (unique->nextFree == NULL) { /* ABC_FREE list is empty */
+ if (unique->nextFree == NULL) { /* free list is empty */
/* Check for exceeded limits. */
if ((unique->keys - unique->dead) + (unique->keysZ - unique->deadZ) >
unique->maxLive) {
@@ -699,7 +702,7 @@ cuddGarbageCollect(
cuddLocalCacheClearDead(unique);
}
- /* Now return dead nodes to ABC_FREE list. Count them for sanity check. */
+ /* Now return dead nodes to free list. Count them for sanity check. */
totalDeleted = 0;
#ifndef DD_UNSORTED_FREE_LIST
tree = NULL;
@@ -905,7 +908,7 @@ cuddGarbageCollectZdd(
}
}
- /* Now return dead nodes to ABC_FREE list. Count them for sanity check. */
+ /* Now return dead nodes to free list. Count them for sanity check. */
totalDeleted = 0;
#ifndef DD_UNSORTED_FREE_LIST
tree = NULL;
@@ -1501,7 +1504,7 @@ cuddRehash(
DdNode *node, *next;
DdNode *sentinel = &(unique->sentinel);
hack split;
- extern void (*MMoutOfMemory)(long);
+// extern void (*MMoutOfMemory)(long);
void (*saveHandler)(long);
if (unique->gcFrac == DD_GC_FRAC_HI && unique->slots > unique->looseUpTo) {
@@ -1673,7 +1676,7 @@ cuddShrinkSubtable(
DdNode *node, *next;
DdNode *sentinel = &(unique->sentinel);
unsigned int slots, oldslots;
- extern void (*MMoutOfMemory)(long);
+// extern void (*MMoutOfMemory)(long);
void (*saveHandler)(long);
oldnodelist = unique->subtables[i].nodelist;
@@ -1820,7 +1823,7 @@ cuddInsertSubtables(
unique->errorCode = CUDD_MEMORY_OUT;
return(0);
}
- for (j = 0; j < numSlots; j++) {
+ for (j = 0; j < (int)numSlots; j++) {
newnodelist[j] = sentinel;
}
}
@@ -1925,7 +1928,7 @@ cuddInsertSubtables(
unique->errorCode = CUDD_MEMORY_OUT;
return(0);
}
- for (j = 0; j < numSlots; j++) {
+ for (j = 0; j < (int)numSlots; j++) {
newnodelist[j] = sentinel;
}
}
@@ -1960,7 +1963,7 @@ cuddInsertSubtables(
ABC_FREE(unique->map);
unique->map = newmap;
}
- /* Install the new tables and ABC_FREE the old ones. */
+ /* Install the new tables and free the old ones. */
ABC_FREE(unique->subtables);
unique->subtables = newsubtables;
unique->maxSize = newsize;
@@ -2233,7 +2236,7 @@ cuddResizeTableZdd(
unique->errorCode = CUDD_MEMORY_OUT;
return(0);
}
- for (j = 0; j < numSlots; j++) {
+ for (j = 0; j < (int)numSlots; j++) {
newnodelist[j] = NULL;
}
}
@@ -2301,7 +2304,7 @@ cuddResizeTableZdd(
unique->errorCode = CUDD_MEMORY_OUT;
return(0);
}
- for (j = 0; j < numSlots; j++) {
+ for (j = 0; j < (int)numSlots; j++) {
newnodelist[j] = NULL;
}
}
@@ -2356,7 +2359,7 @@ cuddSlowTableGrowth(
int i;
unique->maxCacheHard = unique->cacheSlots - 1;
- unique->cacheSlack = -(unique->cacheSlots + 1);
+ unique->cacheSlack = -(int)(unique->cacheSlots + 1);
for (i = 0; i < unique->size; i++) {
unique->subtables[i].maxKeys <<= 2;
}
@@ -2396,7 +2399,7 @@ ddRehashZdd(
int j, pos;
DdNodePtr *nodelist, *oldnodelist;
DdNode *node, *next;
- extern void (*MMoutOfMemory)(long);
+// extern void (*MMoutOfMemory)(long);
void (*saveHandler)(long);
if (unique->slots > unique->looseUpTo) {
@@ -3141,3 +3144,5 @@ See the CUDD Programmer's Guide for additional details.");
abort();
} /* end of ddReportRefMess */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddUtil.c b/src/bdd/cudd/cuddUtil.c
index 7e0eb22a..cbaafb5a 100644
--- a/src/bdd/cudd/cuddUtil.c
+++ b/src/bdd/cudd/cuddUtil.c
@@ -79,6 +79,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -444,7 +447,7 @@ Cudd_EstimateCofactor(
DdNode *ptr;
st_table *table;
- table = st_init_table(st_ptrcmp,st_ptrhash);
+ table = st_init_table(st_ptrcmp, st_ptrhash);;
if (table == NULL) return(CUDD_OUT_OF_MEM);
val = cuddEstimateCofactor(dd,table,Cudd_Regular(f),i,phase,&ptr);
ddClearFlag(Cudd_Regular(f));
@@ -586,12 +589,12 @@ Cudd_CountPath(
st_table *table;
double i;
- table = st_init_table(st_ptrcmp,st_ptrhash);
+ table = st_init_table(st_ptrcmp, st_ptrhash);;
if (table == NULL) {
return((double)CUDD_OUT_OF_MEM);
}
i = ddCountPathAux(Cudd_Regular(node),table);
- st_foreach(table, cuddStCountfree, NULL);
+ st_foreach(table, (ST_PFSR)cuddStCountfree, NULL);
st_free_table(table);
return(i);
@@ -633,7 +636,7 @@ Cudd_EpdCountMinterm(
return(CUDD_OUT_OF_MEM);
}
status = ddEpdCountMintermAux(Cudd_Regular(node),&max,epd,table);
- st_foreach(table, ddEpdFree, NULL);
+ st_foreach(table, (ST_PFSR)ddEpdFree, NULL);
st_free_table(table);
if (status == CUDD_OUT_OF_MEM) {
EpdMakeZero(epd, 0);
@@ -670,12 +673,12 @@ Cudd_CountPathsToNonZero(
st_table *table;
double i;
- table = st_init_table(st_ptrcmp,st_ptrhash);
+ table = st_init_table(st_ptrcmp, st_ptrhash);;
if (table == NULL) {
return((double)CUDD_OUT_OF_MEM);
}
i = ddCountPathsToNonZero(node,table);
- st_foreach(table, cuddStCountfree, NULL);
+ st_foreach(table, (ST_PFSR)cuddStCountfree, NULL);
st_free_table(table);
return(i);
@@ -2187,7 +2190,7 @@ Cudd_FirstNode(
gen->stack.stack = NULL;
gen->node = NULL;
- gen->gen.nodes.visited = st_init_table(st_ptrcmp,st_ptrhash);
+ gen->gen.nodes.visited = st_init_table(st_ptrcmp, st_ptrhash);;
if (gen->gen.nodes.visited == NULL) {
ABC_FREE(gen);
return(NULL);
@@ -2210,7 +2213,7 @@ Cudd_FirstNode(
}
/* Find the first node. */
- retval = st_gen(gen->gen.nodes.stGen, (char **) &(gen->node), NULL);
+ retval = st_gen(gen->gen.nodes.stGen, (const char **) &(gen->node), NULL);
if (retval != 0) {
gen->status = CUDD_GEN_NONEMPTY;
*node = gen->node;
@@ -2242,7 +2245,7 @@ Cudd_NextNode(
int retval;
/* Find the next node. */
- retval = st_gen(gen->gen.nodes.stGen, (char **) &(gen->node), NULL);
+ retval = st_gen(gen->gen.nodes.stGen, (const char **) &(gen->node), NULL);
if (retval == 0) {
gen->status = CUDD_GEN_EMPTY;
} else {
@@ -2647,7 +2650,7 @@ cuddP(
DdNode * f)
{
int retval;
- st_table *table = st_init_table(st_ptrcmp,st_ptrhash);
+ st_table *table = st_init_table(st_ptrcmp, st_ptrhash);;
if (table == NULL) return(0);
@@ -3632,3 +3635,5 @@ ddEpdFree(
return(ST_CONTINUE);
} /* end of ddEpdFree */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddWindow.c b/src/bdd/cudd/cuddWindow.c
index b97e3358..62c92ff2 100644
--- a/src/bdd/cudd/cuddWindow.c
+++ b/src/bdd/cudd/cuddWindow.c
@@ -34,6 +34,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -995,3 +998,5 @@ ddWindowConv4(
} /* end of ddWindowConv4 */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddZddCount.c b/src/bdd/cudd/cuddZddCount.c
index bc8a1ee4..8f974e5e 100644
--- a/src/bdd/cudd/cuddZddCount.c
+++ b/src/bdd/cudd/cuddZddCount.c
@@ -37,6 +37,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -113,7 +116,7 @@ Cudd_zddCount(
if (res == CUDD_OUT_OF_MEM) {
zdd->errorCode = CUDD_MEMORY_OUT;
}
- st_foreach(table, st_zdd_countfree, NIL(char));
+ st_foreach(table, (ST_PFSR)st_zdd_countfree, NIL(char));
st_free_table(table);
return(res);
@@ -152,7 +155,7 @@ Cudd_zddCountDouble(
if (res == (double)CUDD_OUT_OF_MEM) {
zdd->errorCode = CUDD_MEMORY_OUT;
}
- st_foreach(table, st_zdd_count_dbl_free, NIL(char));
+ st_foreach(table, (ST_PFSR)st_zdd_count_dbl_free, NIL(char));
st_free_table(table);
return(res);
@@ -322,3 +325,5 @@ st_zdd_count_dbl_free(
return(ST_CONTINUE);
} /* end of st_zdd_count_dbl_free */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddZddFuncs.c b/src/bdd/cudd/cuddZddFuncs.c
index 9dc27a95..2560159c 100644
--- a/src/bdd/cudd/cuddZddFuncs.c
+++ b/src/bdd/cudd/cuddZddFuncs.c
@@ -51,6 +51,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -1601,3 +1604,5 @@ cuddZddGetNegVarLevel(
int nv = cuddZddGetNegVarIndex(dd, index);
return(dd->permZ[nv]);
} /* end of cuddZddGetNegVarLevel */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddZddGroup.c b/src/bdd/cudd/cuddZddGroup.c
index 8845dc49..0bf611e5 100644
--- a/src/bdd/cudd/cuddZddGroup.c
+++ b/src/bdd/cudd/cuddZddGroup.c
@@ -43,6 +43,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -1315,3 +1318,5 @@ zddMergeGroups(
} /* end of zddMergeGroups */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddZddIsop.c b/src/bdd/cudd/cuddZddIsop.c
index f4b057ea..cd7c16bf 100644
--- a/src/bdd/cudd/cuddZddIsop.c
+++ b/src/bdd/cudd/cuddZddIsop.c
@@ -37,6 +37,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -883,3 +886,5 @@ cuddMakeBddFromZddCover(
/* Definition of static functions */
/*---------------------------------------------------------------------------*/
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddZddLin.c b/src/bdd/cudd/cuddZddLin.c
index 4d4135d1..14cad0b1 100644
--- a/src/bdd/cudd/cuddZddLin.c
+++ b/src/bdd/cudd/cuddZddLin.c
@@ -35,6 +35,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -937,3 +940,5 @@ cuddZddUndoMovesOutOfMem:
} /* end of cuddZddUndoMoves */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddZddMisc.c b/src/bdd/cudd/cuddZddMisc.c
index 6a4ddd09..b78faea1 100644
--- a/src/bdd/cudd/cuddZddMisc.c
+++ b/src/bdd/cudd/cuddZddMisc.c
@@ -36,6 +36,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -250,3 +253,5 @@ cuddZddDagInt(
} /* cuddZddDagInt */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddZddPort.c b/src/bdd/cudd/cuddZddPort.c
index 6d4a3236..dfefece1 100644
--- a/src/bdd/cudd/cuddZddPort.c
+++ b/src/bdd/cudd/cuddZddPort.c
@@ -35,6 +35,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -352,3 +355,5 @@ zddPortToBddStep(
} /* end of zddPortToBddStep */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddZddReord.c b/src/bdd/cudd/cuddZddReord.c
index 4c6e394b..1d73721c 100644
--- a/src/bdd/cudd/cuddZddReord.c
+++ b/src/bdd/cudd/cuddZddReord.c
@@ -49,6 +49,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -1413,7 +1416,7 @@ zddReorderPostprocess(
DdNodePtr *nodelist, *oldnodelist;
DdNode *node, *next;
unsigned int slots, oldslots;
- extern void (*MMoutOfMemory)(long);
+// extern void (*MMoutOfMemory)(long);
void (*saveHandler)(long);
#ifdef DD_VERBOSE
@@ -1632,3 +1635,5 @@ zddFixTree(
} /* end of zddFixTree */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddZddSetop.c b/src/bdd/cudd/cuddZddSetop.c
index f1bd72f3..566c610b 100644
--- a/src/bdd/cudd/cuddZddSetop.c
+++ b/src/bdd/cudd/cuddZddSetop.c
@@ -49,6 +49,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -1135,3 +1138,5 @@ zddVarToConst(
} /* end of zddVarToConst */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddZddSymm.c b/src/bdd/cudd/cuddZddSymm.c
index c752c394..644673cd 100644
--- a/src/bdd/cudd/cuddZddSymm.c
+++ b/src/bdd/cudd/cuddZddSymm.c
@@ -43,6 +43,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -1675,3 +1678,5 @@ cuddZddSymmSummary(
} /* end of cuddZddSymmSummary */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/cuddZddUtil.c b/src/bdd/cudd/cuddZddUtil.c
index efa73d15..72ee639a 100644
--- a/src/bdd/cudd/cuddZddUtil.c
+++ b/src/bdd/cudd/cuddZddUtil.c
@@ -38,6 +38,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -551,7 +554,7 @@ Cudd_zddDumpDot(
}
Cudd_RecursiveDeref(dd,support);
}
- support = NULL; /* so that we do not try to ABC_FREE it in case of failure */
+ support = NULL; /* so that we do not try to free it in case of failure */
/* Initialize symbol table for visited nodes. */
visited = st_init_table(st_ptrcmp, st_ptrhash);
@@ -578,7 +581,7 @@ Cudd_zddDumpDot(
refAddr = (long) f[0];
diff = 0;
gen = st_init_gen(visited);
- while (st_gen(gen, (char **) &scan, NULL)) {
+ while (st_gen(gen, (const char **) &scan, NULL)) {
diff |= refAddr ^ (long) scan;
}
st_free_gen(gen);
@@ -1019,3 +1022,5 @@ zddPrintCoverAux(
return;
} /* end of zddPrintCoverAux */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/cudd/testcudd.c b/src/bdd/cudd/testcudd.c
index d8affadc..1b6de5aa 100644
--- a/src/bdd/cudd/testcudd.c
+++ b/src/bdd/cudd/testcudd.c
@@ -26,6 +26,9 @@
#include "util_hack.h"
#include "cuddInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
@@ -986,3 +989,5 @@ testHamming(
return(1);
} /* end of testHamming */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/dsd/dsd.h b/src/bdd/dsd/dsd.h
index affdbe6f..00b38625 100644
--- a/src/bdd/dsd/dsd.h
+++ b/src/bdd/dsd/dsd.h
@@ -28,6 +28,7 @@
#ifndef __DSD_H__
#define __DSD_H__
+
////////////////////////////////////////////////////////////////////////
/// STRUCTURE DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
@@ -36,9 +37,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
// types of DSD nodes
enum Dsd_Type_t_ {
@@ -118,9 +120,11 @@ extern void Dsd_NodePrint( FILE * pFile, Dsd_Node_t * pNode );
/*=== dsdLocal.c =======================================================*/
extern DdNode * Dsd_TreeGetPrimeFunction( DdManager * dd, Dsd_Node_t * pNode );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/bdd/dsd/dsdApi.c b/src/bdd/dsd/dsdApi.c
index d1c90e23..181dfb28 100644
--- a/src/bdd/dsd/dsdApi.c
+++ b/src/bdd/dsd/dsdApi.c
@@ -17,6 +17,9 @@
***********************************************************************/
#include "dsdInt.h"
+
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -95,3 +98,5 @@ DdManager * Dsd_ManagerReadDd( Dsd_Manager_t * pMan ) { return pMan-
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/dsd/dsdCheck.c b/src/bdd/dsd/dsdCheck.c
index 926237ca..4cecba59 100644
--- a/src/bdd/dsd/dsdCheck.c
+++ b/src/bdd/dsd/dsdCheck.c
@@ -18,6 +18,9 @@
#include "dsdInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -312,3 +315,5 @@ int Dsd_CheckRootFunctionIdentity_rec( DdManager * dd, DdNode * bF1, DdNode * bF
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/dsd/dsdInt.h b/src/bdd/dsd/dsdInt.h
index 62ce7e99..78b7b154 100644
--- a/src/bdd/dsd/dsdInt.h
+++ b/src/bdd/dsd/dsdInt.h
@@ -19,9 +19,13 @@
#ifndef __DSD_INT_H__
#define __DSD_INT_H__
+
#include "extra.h"
#include "dsd.h"
+ABC_NAMESPACE_HEADER_START
+
+
////////////////////////////////////////////////////////////////////////
/// TYPEDEF DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
@@ -83,6 +87,10 @@ extern void Dsd_TreeNodeDelete( DdManager * dd, Dsd_Node_t * pNode );
extern void Dsd_TreeUnmark( Dsd_Manager_t * dMan );
extern DdNode * Dsd_TreeGetPrimeFunctionOld( DdManager * dd, Dsd_Node_t * pNode, int fRemap );
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif
////////////////////////////////////////////////////////////////////////
diff --git a/src/bdd/dsd/dsdLocal.c b/src/bdd/dsd/dsdLocal.c
index 98b6d7d0..a61b656c 100644
--- a/src/bdd/dsd/dsdLocal.c
+++ b/src/bdd/dsd/dsdLocal.c
@@ -18,6 +18,9 @@
#include "dsdInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// FUNCTION DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -97,7 +100,7 @@ DdNode * Dsd_TreeGetPrimeFunction( DdManager * dd, Dsd_Node_t * pNode )
}
// remap the function
- pCache = st_init_table(st_ptrcmp,st_ptrhash);
+ pCache = st_init_table(st_ptrcmp, st_ptrhash);;
bRes = Extra_dsdRemap( dd, bFunc, pCache, pVar2Form, pForm2Var, pbCube0, pbCube1 ); Cudd_Ref( bRes );
st_free_table( pCache );
@@ -335,3 +338,5 @@ DdNode * dsdTreeGetPrimeFunction( DdManager * dd, Dsd_Node_t * pNode, int fRemap
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/dsd/dsdMan.c b/src/bdd/dsd/dsdMan.c
index 6df6a15e..8d108317 100644
--- a/src/bdd/dsd/dsdMan.c
+++ b/src/bdd/dsd/dsdMan.c
@@ -18,6 +18,9 @@
#include "dsdInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// FUNCTION DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -100,7 +103,7 @@ void Dsd_ManagerStop( Dsd_Manager_t * dMan )
Dsd_Node_t * pNode;
DdNode * bFunc;
// delete the nodes
- st_foreach_item( dMan->Table, gen, (char**)&bFunc, (char**)&pNode )
+ st_foreach_item( dMan->Table, gen, (const char**)&bFunc, (char**)&pNode )
Dsd_TreeNodeDelete( dMan->dd, Dsd_Regular(pNode) );
st_free_table(dMan->Table);
ABC_FREE( dMan->pInputs );
@@ -112,3 +115,5 @@ void Dsd_ManagerStop( Dsd_Manager_t * dMan )
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/dsd/dsdProc.c b/src/bdd/dsd/dsdProc.c
index 0192346c..7171315c 100644
--- a/src/bdd/dsd/dsdProc.c
+++ b/src/bdd/dsd/dsdProc.c
@@ -18,6 +18,9 @@
#include "dsdInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// FUNCTION DECLARATIONS ///
@@ -1606,3 +1609,5 @@ int dsdKernelVerifyDecomposition( Dsd_Manager_t * pDsdMan, Dsd_Node_t * pDE )
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/dsd/dsdTree.c b/src/bdd/dsd/dsdTree.c
index a4641afc..9d1269a1 100644
--- a/src/bdd/dsd/dsdTree.c
+++ b/src/bdd/dsd/dsdTree.c
@@ -18,6 +18,9 @@
#include "dsdInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// FUNCTION DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -58,8 +61,8 @@ Dsd_Node_t * Dsd_TreeNodeCreate( int Type, int nDecs, int BlockNum )
// allocate memory for this node
Dsd_Node_t * p = (Dsd_Node_t *) ABC_ALLOC( char, sizeof(Dsd_Node_t) );
memset( p, 0, sizeof(Dsd_Node_t) );
- p->Type = Type; // the type of this block
- p->nDecs = nDecs; // the number of decompositions
+ p->Type = (Dsd_Type_t)Type; // the type of this block
+ p->nDecs = nDecs; // the number of decompositions
if ( p->nDecs )
{
p->pDecs = (Dsd_Node_t **) ABC_ALLOC( char, p->nDecs * sizeof(Dsd_Node_t *) );
@@ -1060,3 +1063,5 @@ DdNode * Dsd_TreeGetPrimeFunctionOld( DdManager * dd, Dsd_Node_t * pNode, int fR
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/epd/epd.c b/src/bdd/epd/epd.c
index 50da97c4..f86f24f4 100644
--- a/src/bdd/epd/epd.c
+++ b/src/bdd/epd/epd.c
@@ -28,6 +28,9 @@
#include "util_hack.h"
#include "epd.h"
+ABC_NAMESPACE_IMPL_START
+
+
/**Function********************************************************************
@@ -1312,3 +1315,5 @@ IsNanOrInfDouble(double value)
}
return(0);
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/epd/epd.h b/src/bdd/epd/epd.h
index 66db80e3..733d7a52 100644
--- a/src/bdd/epd/epd.h
+++ b/src/bdd/epd/epd.h
@@ -25,6 +25,9 @@
#define _EPD
+ABC_NAMESPACE_HEADER_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -157,4 +160,8 @@ int IsInfDouble(double value);
int IsNanDouble(double value);
int IsNanOrInfDouble(double value);
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif /* _EPD */
diff --git a/src/bdd/mtr/mtr.h b/src/bdd/mtr/mtr.h
index 201329ae..189ac1be 100644
--- a/src/bdd/mtr/mtr.h
+++ b/src/bdd/mtr/mtr.h
@@ -36,6 +36,8 @@
/* Nested includes */
/*---------------------------------------------------------------------------*/
+ABC_NAMESPACE_HEADER_START
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
@@ -58,17 +60,18 @@
/* These are potential duplicates. */
#ifndef EXTERN
# ifdef __cplusplus
-# define EXTERN extern "C"
+# ifdef ABC_NAMESPACE
+# define EXTERN extern
+# else
+# define EXTERN extern "C"
+# endif
# else
-# define EXTERN extern
+# define EXTERN extern
# endif
#endif
+
#ifndef ARGS
-# if defined(__STDC__) || defined(__cplusplus)
-# define ARGS(protos) protos /* ANSI C */
-# else /* !(__STDC__ || __cplusplus) */
-# define ARGS(protos) () /* K&R C */
-# endif /* !(__STDC__ || __cplusplus) */
+#define ARGS(protos) protos
#endif
#if defined(__GNUC__)
@@ -170,4 +173,6 @@ EXTERN MtrNode * Mtr_ReadGroups ARGS((FILE *fp, int nleaves));
/**AutomaticEnd***************************************************************/
+ABC_NAMESPACE_HEADER_END
+
#endif /* __MTR */
diff --git a/src/bdd/mtr/mtrBasic.c b/src/bdd/mtr/mtrBasic.c
index 428fa0b1..56c78a23 100644
--- a/src/bdd/mtr/mtrBasic.c
+++ b/src/bdd/mtr/mtrBasic.c
@@ -36,6 +36,9 @@
#include "util_hack.h"
#include "mtrInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
@@ -424,3 +427,5 @@ Mtr_PrintTree(
/* Definition of static functions */
/*---------------------------------------------------------------------------*/
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/mtr/mtrGroup.c b/src/bdd/mtr/mtrGroup.c
index 363b776b..176643f4 100644
--- a/src/bdd/mtr/mtrGroup.c
+++ b/src/bdd/mtr/mtrGroup.c
@@ -36,6 +36,9 @@
#include "util_hack.h"
#include "mtrInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -688,3 +691,5 @@ mtrShiftHL(
} /* end of mtrShiftHL */
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/mtr/mtrInt.h b/src/bdd/mtr/mtrInt.h
index a8d5aa6c..2a470411 100644
--- a/src/bdd/mtr/mtrInt.h
+++ b/src/bdd/mtr/mtrInt.h
@@ -24,8 +24,12 @@
#ifndef _MTRINT
#define _MTRINT
+
#include "mtr.h"
+ABC_NAMESPACE_HEADER_START
+
+
/*---------------------------------------------------------------------------*/
/* Nested includes */
/*---------------------------------------------------------------------------*/
@@ -62,4 +66,8 @@
/**AutomaticEnd***************************************************************/
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif /* _MTRINT */
diff --git a/src/bdd/parse/parse.h b/src/bdd/parse/parse.h
index 4923fbdd..5c97dd4e 100644
--- a/src/bdd/parse/parse.h
+++ b/src/bdd/parse/parse.h
@@ -19,6 +19,10 @@
#ifndef __PARSE_H__
#define __PARSE_H__
+
+ABC_NAMESPACE_HEADER_START
+
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -47,6 +51,10 @@
extern DdNode * Parse_FormulaParser( FILE * pOutput, char * pFormula, int nVars, int nRanks,
char * ppVarNames[], DdManager * dd, DdNode * pbVars[] );
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif
////////////////////////////////////////////////////////////////////////
diff --git a/src/bdd/parse/parseCore.c b/src/bdd/parse/parseCore.c
index 85200dd9..497d603c 100644
--- a/src/bdd/parse/parseCore.c
+++ b/src/bdd/parse/parseCore.c
@@ -43,6 +43,9 @@
#include "parseInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
// the list of operation symbols to be used in expressions
#define PARSE_SYM_OPEN '(' // opening paranthesis
#define PARSE_SYM_CLOSE ')' // closing paranthesis
@@ -342,7 +345,7 @@ DdNode * Parse_FormulaParser( FILE * pOutput, char * pFormulaInit, int nVars, in
if ( fLower )
{
- bFunc = Parse_StackFnPop( pStackFn );
+ bFunc = (DdNode *)Parse_StackFnPop( pStackFn );
bFunc = Extra_bddMove( dd, bTemp = bFunc, -nVars ); Cudd_Ref( bFunc );
Cudd_RecursiveDeref( dd, bTemp );
Parse_StackFnPush( pStackFn, bFunc );
@@ -465,7 +468,7 @@ DdNode * Parse_FormulaParser( FILE * pOutput, char * pFormulaInit, int nVars, in
{
if ( !Parse_StackFnIsEmpty(pStackFn) )
{
- bFunc = Parse_StackFnPop(pStackFn);
+ bFunc = (DdNode *)Parse_StackFnPop(pStackFn);
if ( Parse_StackFnIsEmpty(pStackFn) )
if ( Parse_StackOpIsEmpty(pStackOp) )
{
@@ -502,8 +505,8 @@ DdNode * Parse_ParserPerformTopOp( DdManager * dd, Parse_StackFn_t * pStackFn, i
{
DdNode * bArg1, * bArg2, * bFunc;
// perform the given operation
- bArg2 = Parse_StackFnPop( pStackFn );
- bArg1 = Parse_StackFnPop( pStackFn );
+ bArg2 = (DdNode *)Parse_StackFnPop( pStackFn );
+ bArg1 = (DdNode *)Parse_StackFnPop( pStackFn );
if ( Oper == PARSE_OPER_AND )
bFunc = Cudd_bddAnd( dd, bArg1, bArg2 );
else if ( Oper == PARSE_OPER_XOR )
@@ -529,3 +532,5 @@ DdNode * Parse_ParserPerformTopOp( DdManager * dd, Parse_StackFn_t * pStackFn, i
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/parse/parseEqn.c b/src/bdd/parse/parseEqn.c
index eceecc0c..55b9c2f0 100644
--- a/src/bdd/parse/parseEqn.c
+++ b/src/bdd/parse/parseEqn.c
@@ -25,6 +25,9 @@
#include "vec.h"
#include "hop.h"
+ABC_NAMESPACE_IMPL_START
+
+
// the list of operation symbols to be used in expressions
#define PARSE_EQN_SYM_OPEN '(' // opening paranthesis
#define PARSE_EQN_SYM_CLOSE ')' // closing paranthesis
@@ -213,7 +216,7 @@ Hop_Obj_t * Parse_FormulaParserEqn( FILE * pOutput, char * pFormInit, Vec_Ptr_t
}
// variable name is found
fFound = 0;
- Vec_PtrForEachEntry( vVarNames, pName, v )
+ Vec_PtrForEachEntry( char *, vVarNames, pName, v )
if ( strncmp(pTemp, pName, i) == 0 && strlen(pName) == (unsigned)i )
{
pTemp += i-1;
@@ -254,7 +257,7 @@ Hop_Obj_t * Parse_FormulaParserEqn( FILE * pOutput, char * pFormInit, Vec_Ptr_t
}
else
{
- Parse_StackFnPush( pStackFn, Hop_Not(Parse_StackFnPop(pStackFn)) );
+ Parse_StackFnPush( pStackFn, Hop_Not((Hop_Obj_t *)Parse_StackFnPop(pStackFn)) );
}
}
else // if ( Flag == PARSE_EQN_FLAG_OPER )
@@ -291,7 +294,7 @@ Hop_Obj_t * Parse_FormulaParserEqn( FILE * pOutput, char * pFormInit, Vec_Ptr_t
{
if ( !Parse_StackFnIsEmpty(pStackFn) )
{
- gFunc = Parse_StackFnPop(pStackFn);
+ gFunc = (Hop_Obj_t *)Parse_StackFnPop(pStackFn);
if ( Parse_StackFnIsEmpty(pStackFn) )
if ( Parse_StackOpIsEmpty(pStackOp) )
{
@@ -328,8 +331,8 @@ Hop_Obj_t * Parse_ParserPerformTopOp( Hop_Man_t * pMan, Parse_StackFn_t * pStack
{
Hop_Obj_t * gArg1, * gArg2, * gFunc;
// perform the given operation
- gArg2 = Parse_StackFnPop( pStackFn );
- gArg1 = Parse_StackFnPop( pStackFn );
+ gArg2 = (Hop_Obj_t *)Parse_StackFnPop( pStackFn );
+ gArg1 = (Hop_Obj_t *)Parse_StackFnPop( pStackFn );
if ( Oper == PARSE_EQN_OPER_AND )
gFunc = Hop_And( pMan, gArg1, gArg2 );
else if ( Oper == PARSE_EQN_OPER_OR )
@@ -347,3 +350,5 @@ Hop_Obj_t * Parse_ParserPerformTopOp( Hop_Man_t * pMan, Parse_StackFn_t * pStack
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/parse/parseInt.h b/src/bdd/parse/parseInt.h
index 17f48375..f0f3f302 100644
--- a/src/bdd/parse/parseInt.h
+++ b/src/bdd/parse/parseInt.h
@@ -19,16 +19,20 @@
#ifndef __PARSE_INT_H__
#define __PARSE_INT_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
#include <stdio.h>
-#include "cuddInt.h"
#include "extra.h"
+#include "cuddInt.h"
#include "parse.h"
+ABC_NAMESPACE_HEADER_START
+
+
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
@@ -37,8 +41,6 @@
/// STRUCTURE DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
-typedef int bool;
-
typedef struct ParseStackFnStruct Parse_StackFn_t; // the function stack
typedef struct ParseStackOpStruct Parse_StackOp_t; // the operation stack
@@ -56,17 +58,21 @@ typedef struct ParseStackOpStruct Parse_StackOp_t; // the operation stack
/*=== parseStack.c =============================================================*/
extern Parse_StackFn_t * Parse_StackFnStart ( int nDepth );
-extern bool Parse_StackFnIsEmpty( Parse_StackFn_t * p );
+extern int Parse_StackFnIsEmpty( Parse_StackFn_t * p );
extern void Parse_StackFnPush ( Parse_StackFn_t * p, void * bFunc );
extern void * Parse_StackFnPop ( Parse_StackFn_t * p );
extern void Parse_StackFnFree ( Parse_StackFn_t * p );
extern Parse_StackOp_t * Parse_StackOpStart ( int nDepth );
-extern bool Parse_StackOpIsEmpty( Parse_StackOp_t * p );
+extern int Parse_StackOpIsEmpty( Parse_StackOp_t * p );
extern void Parse_StackOpPush ( Parse_StackOp_t * p, int Oper );
extern int Parse_StackOpPop ( Parse_StackOp_t * p );
extern void Parse_StackOpFree ( Parse_StackOp_t * p );
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif
////////////////////////////////////////////////////////////////////////
diff --git a/src/bdd/parse/parseStack.c b/src/bdd/parse/parseStack.c
index 7ce488f1..2e6d266d 100644
--- a/src/bdd/parse/parseStack.c
+++ b/src/bdd/parse/parseStack.c
@@ -18,6 +18,9 @@
#include "parseInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -72,9 +75,9 @@ Parse_StackFn_t * Parse_StackFnStart( int nDepth )
SeeAlso []
***********************************************************************/
-bool Parse_StackFnIsEmpty( Parse_StackFn_t * p )
+int Parse_StackFnIsEmpty( Parse_StackFn_t * p )
{
- return (bool)(p->Top == 0);
+ return (int)(p->Top == 0);
}
/**Function*************************************************************
@@ -171,9 +174,9 @@ Parse_StackOp_t * Parse_StackOpStart( int nDepth )
SeeAlso []
***********************************************************************/
-bool Parse_StackOpIsEmpty( Parse_StackOp_t * p )
+int Parse_StackOpIsEmpty( Parse_StackOp_t * p )
{
- return (bool)(p->Top == 0);
+ return (int)(p->Top == 0);
}
/**Function*************************************************************
@@ -241,3 +244,5 @@ void Parse_StackOpFree( Parse_StackOp_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/reo/reo.h b/src/bdd/reo/reo.h
index 2f9c421e..9d82329c 100644
--- a/src/bdd/reo/reo.h
+++ b/src/bdd/reo/reo.h
@@ -19,6 +19,7 @@
#ifndef __REO_H__
#define __REO_H__
+
#include <stdio.h>
#include <stdlib.h>
#include "extra.h"
@@ -27,9 +28,10 @@
/// MACRO DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
// reordering parameters
#define REO_REORDER_LIMIT 1.15 // determines the quality/runtime trade-off
@@ -219,9 +221,11 @@ extern DdNode * Extra_ReorderCudd( DdManager * dd, DdNode * aFunc, int pPermut
extern int Extra_bddReorderTest( DdManager * dd, DdNode * bF );
extern int Extra_addReorderTest( DdManager * dd, DdNode * aF );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/bdd/reo/reoApi.c b/src/bdd/reo/reoApi.c
index 000489ed..d6c7430e 100644
--- a/src/bdd/reo/reoApi.c
+++ b/src/bdd/reo/reoApi.c
@@ -18,6 +18,9 @@
#include "reo.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -287,3 +290,5 @@ void Extra_ReorderArray( reo_man * p, DdManager * dd, DdNode * Funcs[], DdNode *
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/reo/reoCore.c b/src/bdd/reo/reoCore.c
index a37bae13..d0535ff9 100644
--- a/src/bdd/reo/reoCore.c
+++ b/src/bdd/reo/reoCore.c
@@ -18,6 +18,9 @@
#include "reo.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -315,7 +318,7 @@ void reoResizeStructures( reo_man * p, int nDdVarsMax, int nNodesMax, int nFuncs
}
else if ( p->nNodesMaxAlloc < nNodesMax )
{
- void * pTemp;
+ reo_unit ** pTemp;
int nMemChunksAllocPrev = p->nMemChunksAlloc;
p->nNodesMaxAlloc = nNodesMax;
@@ -434,3 +437,5 @@ int reoCheckLevels( reo_man * p )
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/reo/reoProfile.c b/src/bdd/reo/reoProfile.c
index 8a48d809..68d4b3cc 100644
--- a/src/bdd/reo/reoProfile.c
+++ b/src/bdd/reo/reoProfile.c
@@ -18,6 +18,9 @@
#include "reo.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -363,3 +366,5 @@ void reoProfileWidthVerifyLevel( reo_plane * pPlane, int Level )
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/reo/reoShuffle.c b/src/bdd/reo/reoShuffle.c
index 8dab67a4..8d43cb3b 100644
--- a/src/bdd/reo/reoShuffle.c
+++ b/src/bdd/reo/reoShuffle.c
@@ -18,6 +18,9 @@
#include "reo.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -222,3 +225,5 @@ clk = clock();
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/reo/reoSift.c b/src/bdd/reo/reoSift.c
index 93d82f08..b30a8f60 100644
--- a/src/bdd/reo/reoSift.c
+++ b/src/bdd/reo/reoSift.c
@@ -18,6 +18,9 @@
#include "reo.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -339,3 +342,5 @@ void reoReorderSift( reo_man * p )
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/reo/reoSwap.c b/src/bdd/reo/reoSwap.c
index 0e829407..a78fc88d 100644
--- a/src/bdd/reo/reoSwap.c
+++ b/src/bdd/reo/reoSwap.c
@@ -18,6 +18,9 @@
#include "reo.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -233,7 +236,7 @@ double reoReorderSwapAdjacentVars( reo_man * p, int lev0, int fMovingUp )
// (2) walk through the uppoer level, and tranform all the remaning nodes
// while employing cache for the new lower level
// (3) walk through the old lower level, find those nodes whose ref counters are not zero,
- // and move them to the new uppoer level, ABC_FREE other nodes
+ // and move them to the new uppoer level, free other nodes
// (1) walk through the upper level, find units without cofactors in the lower level
// and move them to the new lower level (while adding to the cache)
@@ -759,7 +762,7 @@ double reoReorderSwapAdjacentVars( reo_man * p, int lev0, int fMovingUp )
}
// (3) walk through the old lower level, find those nodes whose ref counters are not zero,
- // and move them to the new uppoer level, ABC_FREE other nodes
+ // and move them to the new uppoer level, free other nodes
for ( pLoop = pListOld1; pLoop; )
{
pUnit = pLoop;
@@ -898,3 +901,5 @@ finish:
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/reo/reoTest.c b/src/bdd/reo/reoTest.c
index f0e70cf9..f59da1a7 100644
--- a/src/bdd/reo/reoTest.c
+++ b/src/bdd/reo/reoTest.c
@@ -18,6 +18,9 @@
#include "reo.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -249,3 +252,5 @@ int Extra_addReorderTest( DdManager * dd, DdNode * aF )
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/reo/reoTransfer.c b/src/bdd/reo/reoTransfer.c
index ec02ac0c..7fd64d75 100644
--- a/src/bdd/reo/reoTransfer.c
+++ b/src/bdd/reo/reoTransfer.c
@@ -18,6 +18,9 @@
#include "reo.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -89,7 +92,7 @@ reo_unit * reoTransferNodesToUnits_rec( reo_man * p, DdNode * F )
// add to the hash table
if ( F->ref != 1 )
{
- // the next ABC_FREE entry is already found - it is pointed to by HKey
+ // the next free entry is already found - it is pointed to by HKey
// while we traversed the diagram, the hash entry to which HKey points,
// might have been used. Make sure that its signature is different.
for ( ; p->HTable[HKey].Sign == p->Signature; HKey = (HKey+1) % p->nTableSize );
@@ -199,3 +202,5 @@ DdNode * reoTransferUnitsToNodes_rec( reo_man * p, reo_unit * pUnit )
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/bdd/reo/reoUnits.c b/src/bdd/reo/reoUnits.c
index f8bca7ad..70be8b82 100644
--- a/src/bdd/reo/reoUnits.c
+++ b/src/bdd/reo/reoUnits.c
@@ -18,6 +18,9 @@
#include "reo.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -30,7 +33,7 @@ static void reoUnitsAddToFreeUnitList( reo_man * p );
/**Function*************************************************************
- Synopsis [Extract the next unit from the ABC_FREE unit list.]
+ Synopsis [Extract the next unit from the free unit list.]
Description []
@@ -54,7 +57,7 @@ reo_unit * reoUnitsGetNextUnit(reo_man * p )
/**Function*************************************************************
- Synopsis [Returns the unit to the ABC_FREE unit list.]
+ Synopsis [Returns the unit to the free unit list.]
Description []
@@ -72,7 +75,7 @@ void reoUnitsRecycleUnit( reo_man * p, reo_unit * pUnit )
/**Function*************************************************************
- Synopsis [Returns the list of units to the ABC_FREE unit list.]
+ Synopsis [Returns the list of units to the free unit list.]
Description []
@@ -182,3 +185,5 @@ void reoUnitsAddToFreeUnitList( reo_man * p )
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/demo.c b/src/demo.c
index de162409..0656cb1e 100644
--- a/src/demo.c
+++ b/src/demo.c
@@ -21,6 +21,9 @@
#include <stdio.h>
#include <time.h>
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -179,3 +182,5 @@ clkVer = clock() - clk;
return 0;
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/generic.c b/src/generic.c
index f94c50e6..df934f7d 100644
--- a/src/generic.c
+++ b/src/generic.c
@@ -20,6 +20,9 @@
#include "__Int.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -45,3 +48,5 @@
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/generic.h b/src/generic.h
index fcc4cf26..923cddd3 100644
--- a/src/generic.h
+++ b/src/generic.h
@@ -21,6 +21,7 @@
#ifndef __zzz_H__
#define __zzz_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -29,9 +30,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -47,9 +49,11 @@ extern "C" {
/*=== zzz.c ==========================================================*/
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/map/amap/amap.h b/src/map/amap/amap.h
index 284af309..de7fcc18 100644
--- a/src/map/amap/amap.h
+++ b/src/map/amap/amap.h
@@ -21,6 +21,7 @@
#ifndef __AMAP_H__
#define __AMAP_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -29,14 +30,16 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
+typedef struct Amap_Lib_t_ Amap_Lib_t;
typedef struct Amap_Par_t_ Amap_Par_t;
struct Amap_Par_t_
@@ -45,7 +48,7 @@ struct Amap_Par_t_
int nIterArea; // iteratoins of exact area
int fUseMuxes; // enables the use of MUXes
int fUseXors; // enables the use of XORs
- int fFreeInvs; // assume inverters are ABC_FREE (area = 0)
+ int fFreeInvs; // assume inverters are free (area = 0)
float fEpsilon; // used to compare floating point numbers
int fVerbose; // verbosity flag
};
@@ -68,15 +71,19 @@ struct Amap_Out_t_
////////////////////////////////////////////////////////////////////////
/*=== amapCore.c ==========================================================*/
-extern void Amap_ManSetDefaultParams( Amap_Par_t * pPars );
+extern void Amap_ManSetDefaultParams( Amap_Par_t * pPars );
//extern Vec_Ptr_t * Amap_ManTest( Aig_Man_t * pAig, Amap_Par_t * pPars );
+/*=== amapLib.c ==========================================================*/
+extern void Amap_LibFree( Amap_Lib_t * p );
+extern void Amap_LibPrintSelectedGates( Amap_Lib_t * p, int fAllGates );
+extern Amap_Lib_t * Amap_LibReadAndPrepare( char * pFileName, int fVerbose, int fVeryVerbose );
/*=== amapLiberty.c ==========================================================*/
-extern int Amap_LibertyParse( char * pFileName, char * pFileGenlib, int fVerbose );
+extern int Amap_LibertyParse( char * pFileName, char * pFileGenlib, int fVerbose );
+
+
+ABC_NAMESPACE_HEADER_END
-#ifdef __cplusplus
-}
-#endif
#endif
diff --git a/src/map/amap/amapCore.c b/src/map/amap/amapCore.c
index 7dedc067..4f2d2310 100644
--- a/src/map/amap/amapCore.c
+++ b/src/map/amap/amapCore.c
@@ -19,6 +19,10 @@
***********************************************************************/
#include "amapInt.h"
+#include "main.h"
+
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -46,7 +50,7 @@ void Amap_ManSetDefaultParams( Amap_Par_t * p )
p->nIterArea = 4; // iteratoins of exact area
p->fUseMuxes = 0; // enables the use of MUXes
p->fUseXors = 1; // enables the use of XORs
- p->fFreeInvs = 0; // assume inverters are ABC_FREE (area = 0)
+ p->fFreeInvs = 0; // assume inverters are free (area = 0)
p->fEpsilon = (float)0.001; // used to compare floating point numbers
p->fVerbose = 0; // verbosity flag
}
@@ -64,12 +68,12 @@ void Amap_ManSetDefaultParams( Amap_Par_t * p )
***********************************************************************/
Vec_Ptr_t * Amap_ManTest( Aig_Man_t * pAig, Amap_Par_t * pPars )
{
- extern void * Abc_FrameReadLibGen2();
+// extern void * Abc_FrameReadLibGen2();
Vec_Ptr_t * vRes;
Amap_Man_t * p;
Amap_Lib_t * pLib;
int clkTotal = clock();
- pLib = Abc_FrameReadLibGen2();
+ pLib = (Amap_Lib_t *)Abc_FrameReadLibGen2();
if ( pLib == NULL )
{
printf( "Library is not available.\n" );
@@ -101,3 +105,5 @@ ABC_PRT( "Total runtime", clock() - clkTotal );
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/amap/amapGraph.c b/src/map/amap/amapGraph.c
index 6f269301..bc0878d1 100644
--- a/src/map/amap/amapGraph.c
+++ b/src/map/amap/amapGraph.c
@@ -20,6 +20,9 @@
#include "amapInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -341,7 +344,7 @@ void Amap_ManCreate( Amap_Man_t * p, Aig_Man_t * pAig )
Aig_ManForEachPi( pAig, pObj, i )
pObj->pData = Amap_ManCreatePi( p );
// load the AIG into the mapper
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
{
fChoices = 0;
if ( p->fUseXor && Aig_ObjRecognizeExor(pObj, &pFan0, &pFan1 ) )
@@ -392,3 +395,5 @@ void Amap_ManCreate( Amap_Man_t * p, Aig_Man_t * pAig )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/amap/amapInt.h b/src/map/amap/amapInt.h
index d6d5d68b..92e77e10 100644
--- a/src/map/amap/amapInt.h
+++ b/src/map/amap/amapInt.h
@@ -21,6 +21,7 @@
#ifndef __AMAP_INT_H__
#define __AMAP_INT_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -32,9 +33,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
// the largest gate size in the library
// (gates above this size will be ignored)
@@ -59,7 +61,6 @@ typedef enum {
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
-typedef struct Amap_Lib_t_ Amap_Lib_t;
typedef struct Amap_Pin_t_ Amap_Pin_t;
typedef struct Amap_Gat_t_ Amap_Gat_t;
typedef struct Amap_Nod_t_ Amap_Nod_t;
@@ -264,7 +265,7 @@ static inline void Amap_ObjSetChoice( Amap_Obj_t * pObj, Amap_Obj_t * pE
static inline int Amap_ObjPhaseReal( Amap_Obj_t * pObj ) { return Amap_Regular(pObj)->fPhase ^ Amap_IsComplement(pObj); }
static inline int Amap_ObjRefsTotal( Amap_Obj_t * pObj ) { return pObj->nFouts[0] + pObj->nFouts[1]; }
-static inline Amap_Gat_t * Amap_LibGate( Amap_Lib_t * p, int i ) { return Vec_PtrEntry(p->vGates, i); }
+static inline Amap_Gat_t * Amap_LibGate( Amap_Lib_t * p, int i ) { return (Amap_Gat_t *)Vec_PtrEntry(p->vGates, i); }
static inline Amap_Nod_t * Amap_LibNod( Amap_Lib_t * p, int i ) { return p->pNodes + i; }
// returns pointer to the next cut (internal cuts only)
@@ -282,20 +283,20 @@ extern void Kit_DsdPrintFromTruth( unsigned * pTruth, int nVars );
// iterator over the primary inputs
#define Amap_ManForEachPi( p, pObj, i ) \
- Vec_PtrForEachEntry( p->vPis, pObj, i )
+ Vec_PtrForEachEntry( Amap_Obj_t *, p->vPis, pObj, i )
// iterator over the primary outputs
#define Amap_ManForEachPo( p, pObj, i ) \
- Vec_PtrForEachEntry( p->vPos, pObj, i )
+ Vec_PtrForEachEntry( Amap_Obj_t *, p->vPos, pObj, i )
// iterator over all objects, including those currently not used
#define Amap_ManForEachObj( p, pObj, i ) \
- Vec_PtrForEachEntry( p->vObjs, pObj, i ) if ( (pObj) == NULL ) {} else
+ Vec_PtrForEachEntry( Amap_Obj_t *, p->vObjs, pObj, i ) if ( (pObj) == NULL ) {} else
// iterator over all nodes
#define Amap_ManForEachNode( p, pObj, i ) \
- Vec_PtrForEachEntry( p->vObjs, pObj, i ) if ( (pObj) == NULL || !Amap_ObjIsNode(pObj) ) {} else
+ Vec_PtrForEachEntry( Amap_Obj_t *, p->vObjs, pObj, i ) if ( (pObj) == NULL || !Amap_ObjIsNode(pObj) ) {} else
// iterator through all gates of the library
#define Amap_LibForEachGate( pLib, pGate, i ) \
- Vec_PtrForEachEntry( pLib->vGates, pGate, i )
+ Vec_PtrForEachEntry( Amap_Gat_t *, pLib->vGates, pGate, i )
// iterator through all pins of the gate
#define Amap_GateForEachPin( pGate, pPin ) \
for ( pPin = pGate->Pins; pPin < pGate->Pins + pGate->nPins; pPin++ )
@@ -337,12 +338,9 @@ extern void Amap_ManCreateChoice( Amap_Man_t * p, Amap_Obj_t * pObj );
extern void Amap_ManCreate( Amap_Man_t * p, Aig_Man_t * pAig );
/*=== amapLib.c ==========================================================*/
extern Amap_Lib_t * Amap_LibAlloc();
-extern void Amap_LibFree( Amap_Lib_t * p );
extern int Amap_LibNumPinsMax( Amap_Lib_t * p );
extern void Amap_LibWrite( FILE * pFile, Amap_Lib_t * pLib, int fPrintDsd );
extern Vec_Ptr_t * Amap_LibSelectGates( Amap_Lib_t * p, int fVerbose );
-extern void Amap_LibPrintSelectedGates( Amap_Lib_t * p, int fAllGates );
-extern Amap_Lib_t * Amap_LibReadAndPrepare( char * pFileName, int fVerbose, int fVeryVerbose );
/*=== amapMan.c ==========================================================*/
extern Amap_Man_t * Amap_ManStart( int nNodes );
extern void Amap_ManStop( Amap_Man_t * p );
@@ -368,9 +366,11 @@ extern int Amap_LibCreateNode( Amap_Lib_t * p, int iFan0, int iFan1, i
extern int Amap_LibCreateMux( Amap_Lib_t * p, int iFan0, int iFan1, int iFan2 );
extern int ** Amap_LibLookupTableAlloc( Vec_Ptr_t * vVec, int fVerbose );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/map/amap/amapLib.c b/src/map/amap/amapLib.c
index f2e5113f..474b444d 100644
--- a/src/map/amap/amapLib.c
+++ b/src/map/amap/amapLib.c
@@ -20,6 +20,9 @@
#include "amapInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -237,7 +240,7 @@ Amap_Gat_t * Amap_LibFindGate( Amap_Lib_t * p, unsigned uTruth )
{
Amap_Gat_t * pGate;
int i;
- Vec_PtrForEachEntry( p->vSorted, pGate, i )
+ Vec_PtrForEachEntry( Amap_Gat_t *, p->vSorted, pGate, i )
if ( pGate->nPins <= 5 && pGate->pFunc[0] == uTruth )
return pGate;
return NULL;
@@ -264,11 +267,11 @@ Vec_Ptr_t * Amap_LibSelectGates( Amap_Lib_t * p, int fVerbose )
p->pGateBuf = Amap_LibFindGate( p, 0xAAAAAAAA );
p->pGateInv = Amap_LibFindGate( p, ~0xAAAAAAAA );
vSelect = Vec_PtrAlloc( 100 );
- Vec_PtrForEachEntry( p->vSorted, pGate, i )
+ Vec_PtrForEachEntry( Amap_Gat_t *, p->vSorted, pGate, i )
{
if ( pGate->pFunc == NULL )
continue;
- Vec_PtrForEachEntryStop( p->vSorted, pGate2, k, i )
+ Vec_PtrForEachEntryStop( Amap_Gat_t *, p->vSorted, pGate2, k, i )
{
if ( pGate2->pFunc == NULL )
continue;
@@ -301,7 +304,7 @@ void Amap_LibPrintSelectedGates( Amap_Lib_t * p, int fAllGates )
Amap_Gat_t * pGate;
int i;
vArray = fAllGates? p->vGates : p->vSelect;
- Vec_PtrForEachEntry( vArray, pGate, i )
+ Vec_PtrForEachEntry( Amap_Gat_t *, vArray, pGate, i )
{
printf( "Gate %4d : %15s Area = %9.2f\n", pGate->Id, pGate->pName, pGate->dArea );
printf( " Formula: %s=%s\n", pGate->pOutName, pGate->pForm );
@@ -359,3 +362,5 @@ Amap_Lib_t * Amap_LibReadAndPrepare( char * pFileName, int fVerbose, int fVeryVe
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/amap/amapLiberty.c b/src/map/amap/amapLiberty.c
index 4177e27e..cf74a612 100644
--- a/src/map/amap/amapLiberty.c
+++ b/src/map/amap/amapLiberty.c
@@ -20,6 +20,9 @@
#include "amapInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -920,3 +923,5 @@ int Amap_LibertyParse( char * pFileName, char * pFileGenlib, int fVerbose )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/amap/amapMan.c b/src/map/amap/amapMan.c
index a1a66869..6304c078 100644
--- a/src/map/amap/amapMan.c
+++ b/src/map/amap/amapMan.c
@@ -20,6 +20,9 @@
#include "amapInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -97,3 +100,5 @@ void Amap_ManStop( Amap_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/amap/amapMatch.c b/src/map/amap/amapMatch.c
index a997ad48..ca513e61 100644
--- a/src/map/amap/amapMatch.c
+++ b/src/map/amap/amapMatch.c
@@ -20,6 +20,9 @@
#include "amapInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -536,3 +539,5 @@ void Amap_ManMap( Amap_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/amap/amapMerge.c b/src/map/amap/amapMerge.c
index 23d8384b..ecf11b07 100644
--- a/src/map/amap/amapMerge.c
+++ b/src/map/amap/amapMerge.c
@@ -20,6 +20,9 @@
#include "amapInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -394,9 +397,9 @@ void Amap_ManMergeNodeCutsMux( Amap_Man_t * p, Amap_Obj_t * pNode )
continue;
if ( Amap_ManFindCut( pNode, pFanin2, fComplFanin2, Vec_IntEntry(vRules, x+2), p->vCuts2 ) )
continue;
- Vec_PtrForEachEntry( p->vCuts0, pCut0, c0 )
- Vec_PtrForEachEntry( p->vCuts1, pCut1, c1 )
- Vec_PtrForEachEntry( p->vCuts2, pCut2, c2 )
+ Vec_PtrForEachEntry( Amap_Cut_t *, p->vCuts0, pCut0, c0 )
+ Vec_PtrForEachEntry( Amap_Cut_t *, p->vCuts1, pCut1, c1 )
+ Vec_PtrForEachEntry( Amap_Cut_t *, p->vCuts2, pCut2, c2 )
{
Amap_Nod_t * pNod = Amap_LibNod( p->pLib, Vec_IntEntry(vRules, x+3) );
if ( pNod->pSets == NULL )
@@ -533,3 +536,5 @@ ABC_PRT( "Time ", clock() - clk );
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/amap/amapOutput.c b/src/map/amap/amapOutput.c
index 1decc52e..d590b7b9 100644
--- a/src/map/amap/amapOutput.c
+++ b/src/map/amap/amapOutput.c
@@ -20,6 +20,9 @@
#include "amapInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -179,3 +182,5 @@ Vec_Ptr_t * Amap_ManProduceMapped( Amap_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/amap/amapParse.c b/src/map/amap/amapParse.c
index bfa8e6a5..dd6137c9 100644
--- a/src/map/amap/amapParse.c
+++ b/src/map/amap/amapParse.c
@@ -20,6 +20,10 @@
#include "amapInt.h"
#include "hop.h"
+#include "kit.h"
+
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -69,8 +73,8 @@ Hop_Obj_t * Amap_ParseFormulaOper( Hop_Man_t * pMan, Vec_Ptr_t * pStackFn, int O
{
Hop_Obj_t * gArg1, * gArg2, * gFunc;
// perform the given operation
- gArg2 = Vec_PtrPop( pStackFn );
- gArg1 = Vec_PtrPop( pStackFn );
+ gArg2 = (Hop_Obj_t *)Vec_PtrPop( pStackFn );
+ gArg1 = (Hop_Obj_t *)Vec_PtrPop( pStackFn );
if ( Oper == AMAP_EQN_OPER_AND )
gFunc = Hop_And( pMan, gArg1, gArg2 );
else if ( Oper == AMAP_EQN_OPER_OR )
@@ -177,7 +181,7 @@ Hop_Obj_t * Amap_ParseFormula( FILE * pOutput, char * pFormInit, Vec_Ptr_t * vVa
break;
}
else // if ( Flag == PARSE_FLAG_VAR )
- Vec_PtrPush( pStackFn, Hop_Not( Vec_PtrPop(pStackFn) ) );
+ Vec_PtrPush( pStackFn, Hop_Not( (Hop_Obj_t *)Vec_PtrPop(pStackFn) ) );
break;
case AMAP_EQN_SYM_AND:
case AMAP_EQN_SYM_OR:
@@ -261,7 +265,7 @@ Hop_Obj_t * Amap_ParseFormula( FILE * pOutput, char * pFormInit, Vec_Ptr_t * vVa
}
// variable name is found
fFound = 0;
- Vec_PtrForEachEntry( vVarNames, pName, v )
+ Vec_PtrForEachEntry( char *, vVarNames, pName, v )
if ( strncmp(pTemp, pName, i) == 0 && strlen(pName) == (unsigned)i )
{
pTemp += i-1;
@@ -307,7 +311,7 @@ Hop_Obj_t * Amap_ParseFormula( FILE * pOutput, char * pFormInit, Vec_Ptr_t * vVa
}
else
{
- Vec_PtrPush( pStackFn, Hop_Not(Vec_PtrPop(pStackFn)) );
+ Vec_PtrPush( pStackFn, Hop_Not((Hop_Obj_t *)Vec_PtrPop(pStackFn)) );
}
}
else // if ( Flag == AMAP_EQN_FLAG_OPER )
@@ -344,7 +348,7 @@ Hop_Obj_t * Amap_ParseFormula( FILE * pOutput, char * pFormInit, Vec_Ptr_t * vVa
{
if ( Vec_PtrSize(pStackFn) != 0 )
{
- gFunc = Vec_PtrPop(pStackFn);
+ gFunc = (Hop_Obj_t *)Vec_PtrPop(pStackFn);
if ( Vec_PtrSize(pStackFn) == 0 )
if ( Vec_IntSize( pStackOp ) == 0 )
{
@@ -379,7 +383,7 @@ Hop_Obj_t * Amap_ParseFormula( FILE * pOutput, char * pFormInit, Vec_Ptr_t * vVa
***********************************************************************/
int Amap_LibParseEquations( Amap_Lib_t * p, int fVerbose )
{
- extern int Kit_TruthSupportSize( unsigned * pTruth, int nVars );
+// extern int Kit_TruthSupportSize( unsigned * pTruth, int nVars );
Hop_Man_t * pMan;
Hop_Obj_t * pObj;
Vec_Ptr_t * vNames;
@@ -395,7 +399,7 @@ int Amap_LibParseEquations( Amap_Lib_t * p, int fVerbose )
vNames = Vec_PtrAlloc( 100 );
pMan = Hop_ManStart();
Hop_IthVar( pMan, nPinMax - 1 );
- Vec_PtrForEachEntry( p->vGates, pGate, i )
+ Vec_PtrForEachEntry( Amap_Gat_t *, p->vGates, pGate, i )
{
if ( pGate->nPins == 0 )
{
@@ -463,3 +467,5 @@ void Amap_LibParseTest( char * pFileName )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/amap/amapPerm.c b/src/map/amap/amapPerm.c
index 17fb57e2..71d4749a 100644
--- a/src/map/amap/amapPerm.c
+++ b/src/map/amap/amapPerm.c
@@ -21,6 +21,9 @@
#include "amapInt.h"
#include "kit.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -210,7 +213,7 @@ unsigned * Amap_LibVerifyPerm_rec( Amap_Lib_t * pLib, Amap_Nod_t * pNod,
int i;
assert( pNod->Type != AMAP_OBJ_MUX );
if ( pNod->Id == 0 )
- return Vec_PtrEntry( vTtElems, (*piInput)++ );
+ return (unsigned *)Vec_PtrEntry( vTtElems, (*piInput)++ );
pFan0 = Amap_LibNod( pLib, Amap_Lit2Var(pNod->iFan0) );
pTruth0 = Amap_LibVerifyPerm_rec( pLib, pFan0, vTtElems, vTruth, nWords, piInput );
pFan1 = Amap_LibNod( pLib, Amap_Lit2Var(pNod->iFan1) );
@@ -262,7 +265,7 @@ void Amap_LibVerifyPerm( Amap_Lib_t * pLib, Amap_Gat_t * pGate, Kit_DsdNtk_t * p
vTtElemsPol = Vec_PtrAlloc( pGate->nPins );
for ( i = 0; i < (int)pGate->nPins; i++ )
{
- pTruth = Vec_PtrEntry( vTtElems, Amap_Lit2Var(pArray[i]) );
+ pTruth = (unsigned *)Vec_PtrEntry( vTtElems, Amap_Lit2Var(pArray[i]) );
if ( Amap_LitIsCompl( pArray[i] ) )
Kit_TruthNot( pTruth, pTruth, pGate->nPins );
Vec_PtrPush( vTtElemsPol, pTruth );
@@ -342,3 +345,5 @@ int Amap_LibDeriveGatePerm( Amap_Lib_t * pLib, Amap_Gat_t * pGate, Kit_DsdNtk_t
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/amap/amapRead.c b/src/map/amap/amapRead.c
index 7ebc239b..ec169773 100644
--- a/src/map/amap/amapRead.c
+++ b/src/map/amap/amapRead.c
@@ -19,6 +19,10 @@
***********************************************************************/
#include "amapInt.h"
+#include "ioAbc.h"
+
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -68,7 +72,7 @@ static inline char * Amap_ParseStrsav( Aig_MmFlex_t * p, char * pStr )
***********************************************************************/
char * Amap_LoadFile( char * pFileName )
{
- extern FILE * Io_FileOpen( const char * FileName, const char * PathVar, const char * Mode, int fVerbose );
+// extern FILE * Io_FileOpen( const char * FileName, const char * PathVar, const char * Mode, int fVerbose );
FILE * pFile;
char * pBuffer;
int nFileSize;
@@ -197,7 +201,7 @@ int Amap_ParseCountPins( Vec_Ptr_t * vTokens, int iPos )
{
char * pToken;
int i, Counter = 0;
- Vec_PtrForEachEntryStart( vTokens, pToken, i, iPos )
+ Vec_PtrForEachEntryStart( char *, vTokens, pToken, i, iPos )
if ( !strcmp( pToken, AMAP_STRING_PIN ) )
Counter++;
else if ( !strcmp( pToken, AMAP_STRING_GATE ) )
@@ -295,7 +299,7 @@ int Amap_CollectFormulaTokens( Vec_Ptr_t * vTokens, char * pToken, int iPos )
while ( *(pPrev-1) != ';' )
{
*pPrev++ = ' ';
- pNext = Vec_PtrEntry(vTokens, iPos++);
+ pNext = (char *)Vec_PtrEntry(vTokens, iPos++);
while ( *pNext )
*pPrev++ = *pNext++;
}
@@ -322,7 +326,7 @@ Amap_Lib_t * Amap_ParseTokens( Vec_Ptr_t * vTokens, int fVerbose )
char * pToken;
int nPins, iPos = 0;
p = Amap_LibAlloc();
- pToken = Vec_PtrEntry(vTokens, iPos++);
+ pToken = (char *)Vec_PtrEntry(vTokens, iPos++);
do
{
if ( strcmp( pToken, AMAP_STRING_GATE ) )
@@ -339,28 +343,28 @@ Amap_Lib_t * Amap_ParseTokens( Vec_Ptr_t * vTokens, int fVerbose )
pGate->pLib = p;
pGate->nPins = nPins;
// read gate
- pToken = Vec_PtrEntry(vTokens, iPos++);
+ pToken = (char *)Vec_PtrEntry(vTokens, iPos++);
pGate->pName = Amap_ParseStrsav( p->pMemGates, pToken );
- pToken = Vec_PtrEntry(vTokens, iPos++);
+ pToken = (char *)Vec_PtrEntry(vTokens, iPos++);
pGate->dArea = atof( pToken );
- pToken = Vec_PtrEntry(vTokens, iPos++);
+ pToken = (char *)Vec_PtrEntry(vTokens, iPos++);
pGate->pOutName = Amap_ParseStrsav( p->pMemGates, pToken );
- pToken = Vec_PtrEntry(vTokens, iPos++);
+ pToken = (char *)Vec_PtrEntry(vTokens, iPos++);
iPos = Amap_CollectFormulaTokens( vTokens, pToken, iPos );
pGate->pForm = Amap_ParseStrsav( p->pMemGates, pToken );
// read pins
Amap_GateForEachPin( pGate, pPin )
{
- pToken = Vec_PtrEntry(vTokens, iPos++);
+ pToken = (char *)Vec_PtrEntry(vTokens, iPos++);
if ( strcmp( pToken, AMAP_STRING_PIN ) )
{
printf( "Cannot parse gate %s.\n", pGate->pName );
return NULL;
}
// read pin
- pToken = Vec_PtrEntry(vTokens, iPos++);
+ pToken = (char *)Vec_PtrEntry(vTokens, iPos++);
pPin->pName = Amap_ParseStrsav( p->pMemGates, pToken );
- pToken = Vec_PtrEntry(vTokens, iPos++);
+ pToken = (char *)Vec_PtrEntry(vTokens, iPos++);
if ( strcmp( pToken, AMAP_STRING_UNKNOWN ) == 0 )
pPin->Phase = AMAP_PHASE_UNKNOWN;
else if ( strcmp( pToken, AMAP_STRING_INV ) == 0 )
@@ -372,17 +376,17 @@ Amap_Lib_t * Amap_ParseTokens( Vec_Ptr_t * vTokens, int fVerbose )
printf( "Cannot read phase of pin %s of gate %s\n", pPin->pName, pGate->pName );
return NULL;
}
- pToken = Vec_PtrEntry(vTokens, iPos++);
+ pToken = (char *)Vec_PtrEntry(vTokens, iPos++);
pPin->dLoadInput = atof( pToken );
- pToken = Vec_PtrEntry(vTokens, iPos++);
+ pToken = (char *)Vec_PtrEntry(vTokens, iPos++);
pPin->dLoadMax = atof( pToken );
- pToken = Vec_PtrEntry(vTokens, iPos++);
+ pToken = (char *)Vec_PtrEntry(vTokens, iPos++);
pPin->dDelayBlockRise = atof( pToken );
- pToken = Vec_PtrEntry(vTokens, iPos++);
+ pToken = (char *)Vec_PtrEntry(vTokens, iPos++);
pPin->dDelayFanoutRise = atof( pToken );
- pToken = Vec_PtrEntry(vTokens, iPos++);
+ pToken = (char *)Vec_PtrEntry(vTokens, iPos++);
pPin->dDelayBlockFall = atof( pToken );
- pToken = Vec_PtrEntry(vTokens, iPos++);
+ pToken = (char *)Vec_PtrEntry(vTokens, iPos++);
pPin->dDelayFanoutFall = atof( pToken );
if ( pPin->dDelayBlockRise > pPin->dDelayBlockFall )
pPin->dDelayBlockMax = pPin->dDelayBlockRise;
@@ -396,7 +400,7 @@ Amap_Lib_t * Amap_ParseTokens( Vec_Ptr_t * vTokens, int fVerbose )
Vec_PtrPop( p->vGates );
Vec_PtrPush( p->vGates, pGate );
}
- pToken = Vec_PtrEntry(vTokens, iPos++);
+ pToken = (char *)Vec_PtrEntry(vTokens, iPos++);
}
while ( strcmp( pToken, ".end" ) );
return p;
@@ -437,3 +441,5 @@ Amap_Lib_t * Amap_LibReadFile( char * pFileName, int fVerbose )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/amap/amapRule.c b/src/map/amap/amapRule.c
index 27de49ee..8308a197 100644
--- a/src/map/amap/amapRule.c
+++ b/src/map/amap/amapRule.c
@@ -21,6 +21,9 @@
#include "amapInt.h"
#include "kit.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -100,7 +103,7 @@ int Amap_CreateCheckAllZero( Vec_Ptr_t * vVecNods )
{
Vec_Int_t * vNods;
int i;
- Vec_PtrForEachEntryReverse( vVecNods, vNods, i )
+ Vec_PtrForEachEntryReverse( Vec_Int_t *, vVecNods, vNods, i )
if ( Vec_IntSize(vNods) != 1 || Vec_IntEntry(vNods,0) != 0 )
return 0;
return 1;
@@ -123,7 +126,7 @@ Vec_Int_t * Amap_CreateRulesVector_rec( Amap_Lib_t * p, Vec_Ptr_t * vVecNods, in
Vec_Int_t * vRes, * vNods, * vNods0, * vNods1;
int i, k;
if ( Vec_PtrSize(vVecNods) == 1 )
- return Vec_IntDup( Vec_PtrEntry(vVecNods, 0) );
+ return Vec_IntDup( (Vec_Int_t *)Vec_PtrEntry(vVecNods, 0) );
vRes = Vec_IntAlloc( 10 );
vVecNods0 = Vec_PtrAlloc( Vec_PtrSize(vVecNods) );
vVecNods1 = Vec_PtrAlloc( Vec_PtrSize(vVecNods) );
@@ -133,9 +136,9 @@ Vec_Int_t * Amap_CreateRulesVector_rec( Amap_Lib_t * p, Vec_Ptr_t * vVecNods, in
{
Vec_PtrClear( vVecNods0 );
Vec_PtrClear( vVecNods1 );
- Vec_PtrForEachEntryStop( vVecNods, vNods, k, i )
+ Vec_PtrForEachEntryStop( Vec_Int_t *, vVecNods, vNods, k, i )
Vec_PtrPush( vVecNods0, vNods );
- Vec_PtrForEachEntryStart( vVecNods, vNods, k, i )
+ Vec_PtrForEachEntryStart( Vec_Int_t *, vVecNods, vNods, k, i )
Vec_PtrPush( vVecNods1, vNods );
vNods0 = Amap_CreateRulesVector_rec( p, vVecNods0, fXor );
vNods1 = Amap_CreateRulesVector_rec( p, vVecNods1, fXor );
@@ -151,7 +154,7 @@ Vec_Int_t * Amap_CreateRulesVector_rec( Amap_Lib_t * p, Vec_Ptr_t * vVecNods, in
{
Vec_PtrClear( vVecNods0 );
Vec_PtrClear( vVecNods1 );
- Vec_PtrForEachEntryReverse( vVecNods, vNods, k )
+ Vec_PtrForEachEntryReverse( Vec_Int_t *, vVecNods, vNods, k )
{
if ( i & (1 << k) )
Vec_PtrPush( vVecNods1, vNods );
@@ -218,11 +221,11 @@ Vec_Int_t * Amap_CreateRulesFromDsd_rec( Amap_Lib_t * pLib, Kit_DsdNtk_t * p, in
{
assert( pObj->nFans == 3 );
assert( Kit_DsdObjTruth(pObj)[0] == 0xCACACACA );
- vRes = Amap_CreateRulesPrime( pLib, Vec_PtrEntry(vVecNods, 0),
- Vec_PtrEntry(vVecNods, 1), Vec_PtrEntry(vVecNods, 2) );
+ vRes = Amap_CreateRulesPrime( pLib, (Vec_Int_t *)Vec_PtrEntry(vVecNods, 0),
+ (Vec_Int_t *)Vec_PtrEntry(vVecNods, 1), (Vec_Int_t *)Vec_PtrEntry(vVecNods, 2) );
}
else assert( 0 );
- Vec_PtrForEachEntry( vVecNods, vNodsFanin, k )
+ Vec_PtrForEachEntry( Vec_Int_t *, vVecNods, vNodsFanin, k )
Vec_IntFree( vNodsFanin );
Vec_PtrFree( vVecNods );
return vRes;
@@ -341,7 +344,7 @@ void Amap_LibCreateRules( Amap_Lib_t * pLib, int fVeryVerbose )
pLib->vRulesX = Vec_PtrAlloc( 100 );
pLib->vRules3 = Vec_IntAlloc( 100 );
Amap_LibCreateVar( pLib );
- Vec_PtrForEachEntry( pLib->vSelect, pGate, i )
+ Vec_PtrForEachEntry( Amap_Gat_t *, pLib->vSelect, pGate, i )
{
if ( pGate->nPins < 2 )
continue;
@@ -366,3 +369,5 @@ void Amap_LibCreateRules( Amap_Lib_t * pLib, int fVeryVerbose )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/amap/amapUniq.c b/src/map/amap/amapUniq.c
index e57161e4..a2375389 100644
--- a/src/map/amap/amapUniq.c
+++ b/src/map/amap/amapUniq.c
@@ -20,6 +20,9 @@
#include "amapInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -87,9 +90,9 @@ static inline void Vec_IntPushOrderWithMask( Vec_Int_t * p, int Entry )
int Amap_LibFindNode( Amap_Lib_t * pLib, int iFan0, int iFan1, int fXor )
{
if ( fXor )
- return Vec_IntCheckWithMask( Vec_PtrEntry(pLib->vRulesX, iFan0), iFan1 );
+ return Vec_IntCheckWithMask( (Vec_Int_t *)Vec_PtrEntry(pLib->vRulesX, iFan0), iFan1 );
else
- return Vec_IntCheckWithMask( Vec_PtrEntry(pLib->vRules, iFan0), iFan1 );
+ return Vec_IntCheckWithMask( (Vec_Int_t *)Vec_PtrEntry(pLib->vRules, iFan0), iFan1 );
}
/**Function*************************************************************
@@ -207,21 +210,21 @@ Amap_Lit2Var(iFan1), (Amap_LitIsCompl(iFan1)?'-':'+') );
if ( fXor )
{
if ( iFan0 == iFan1 )
- Vec_IntPushOrderWithMask( Vec_PtrEntry(p->vRulesX, iFan0), (pNode->Id << 16) | iFan1 );
+ Vec_IntPushOrderWithMask( (Vec_Int_t *)Vec_PtrEntry(p->vRulesX, iFan0), (pNode->Id << 16) | iFan1 );
else
{
- Vec_IntPushOrderWithMask( Vec_PtrEntry(p->vRulesX, iFan0), (pNode->Id << 16) | iFan1 );
- Vec_IntPushOrderWithMask( Vec_PtrEntry(p->vRulesX, iFan1), (pNode->Id << 16) | iFan0 );
+ Vec_IntPushOrderWithMask( (Vec_Int_t *)Vec_PtrEntry(p->vRulesX, iFan0), (pNode->Id << 16) | iFan1 );
+ Vec_IntPushOrderWithMask( (Vec_Int_t *)Vec_PtrEntry(p->vRulesX, iFan1), (pNode->Id << 16) | iFan0 );
}
}
else
{
if ( iFan0 == iFan1 )
- Vec_IntPushOrderWithMask( Vec_PtrEntry(p->vRules, iFan0), (pNode->Id << 16) | iFan1 );
+ Vec_IntPushOrderWithMask( (Vec_Int_t *)Vec_PtrEntry(p->vRules, iFan0), (pNode->Id << 16) | iFan1 );
else
{
- Vec_IntPushOrderWithMask( Vec_PtrEntry(p->vRules, iFan0), (pNode->Id << 16) | iFan1 );
- Vec_IntPushOrderWithMask( Vec_PtrEntry(p->vRules, iFan1), (pNode->Id << 16) | iFan0 );
+ Vec_IntPushOrderWithMask( (Vec_Int_t *)Vec_PtrEntry(p->vRules, iFan0), (pNode->Id << 16) | iFan1 );
+ Vec_IntPushOrderWithMask( (Vec_Int_t *)Vec_PtrEntry(p->vRules, iFan1), (pNode->Id << 16) | iFan0 );
}
}
return pNode->Id;
@@ -279,13 +282,13 @@ int ** Amap_LibLookupTableAlloc( Vec_Ptr_t * vVec, int fVerbose )
int i, k, nTotal, nSize, nEntries, Value;
// count the total size
nEntries = nSize = Vec_PtrSize( vVec );
- Vec_PtrForEachEntry( vVec, vOne, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vVec, vOne, i )
nEntries += Vec_IntSize(vOne);
pBuffer = ABC_ALLOC( int, nSize * sizeof(void *) + nEntries );
pRes = (int **)pBuffer;
pRes[0] = pBuffer + nSize * sizeof(void *);
nTotal = 0;
- Vec_PtrForEachEntry( vVec, vOne, i )
+ Vec_PtrForEachEntry( Vec_Int_t *, vVec, vOne, i )
{
pRes[i] = pRes[0] + nTotal;
nTotal += Vec_IntSize(vOne) + 1;
@@ -310,3 +313,5 @@ int ** Amap_LibLookupTableAlloc( Vec_Ptr_t * vVec, int fVerbose )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/cov/cov.h b/src/map/cov/cov.h
index 8ca81740..f8136a7f 100644
--- a/src/map/cov/cov.h
+++ b/src/map/cov/cov.h
@@ -21,13 +21,12 @@
#ifndef __COV_H__
#define __COV_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
#include "abc.h"
#include "covInt.h"
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -69,7 +68,7 @@ struct Cov_Man_t_
int nNodes; // the number of nodes processed
};
-static inline Cov_Obj_t * Abc_ObjGetStr( Abc_Obj_t * pObj ) { return Vec_PtrEntry(((Cov_Man_t *)pObj->pNtk->pManCut)->vObjStrs, pObj->Id); }
+static inline Cov_Obj_t * Abc_ObjGetStr( Abc_Obj_t * pObj ) { return (Cov_Obj_t *)Vec_PtrEntry(((Cov_Man_t *)pObj->pNtk->pManCut)->vObjStrs, pObj->Id); }
static inline void Abc_ObjSetSupp( Abc_Obj_t * pObj, Vec_Int_t * vVec ) { Abc_ObjGetStr(pObj)->vSupp = vVec; }
static inline Vec_Int_t * Abc_ObjGetSupp( Abc_Obj_t * pObj ) { return Abc_ObjGetStr(pObj)->vSupp; }
@@ -89,7 +88,7 @@ extern Abc_Ntk_t * Abc_NtkCovDerive( Cov_Man_t * p, Abc_Ntk_t * pNtk );
extern Abc_Ntk_t * Abc_NtkCovDeriveClean( Cov_Man_t * p, Abc_Ntk_t * pNtk );
extern Abc_Ntk_t * Abc_NtkCovDeriveRegular( Cov_Man_t * p, Abc_Ntk_t * pNtk );
/*=== covCore.c ===========================================================*/
-extern Abc_Ntk_t * Abc_NtkSopEsopCover( Abc_Ntk_t * pNtk, int nFaninMax, bool fUseEsop, bool fUseSop, bool fUseInvs, bool fVerbose );
+extern Abc_Ntk_t * Abc_NtkSopEsopCover( Abc_Ntk_t * pNtk, int nFaninMax, int fUseEsop, int fUseSop, int fUseInvs, int fVerbose );
/*=== covMan.c ============================================================*/
extern Cov_Man_t * Cov_ManAlloc( Abc_Ntk_t * pNtk, int nFaninMax );
extern void Cov_ManFree( Cov_Man_t * p );
@@ -97,9 +96,8 @@ extern void Abc_NodeCovDropData( Cov_Man_t * p, Abc_Obj_t * pObj );
/*=== covTest.c ===========================================================*/
extern Abc_Ntk_t * Abc_NtkCovTestSop( Abc_Ntk_t * pNtk );
-#ifdef __cplusplus
-}
-#endif
+
+ABC_NAMESPACE_HEADER_END
#endif
diff --git a/src/map/cov/covBuild.c b/src/map/cov/covBuild.c
index 560178be..3975c91d 100644
--- a/src/map/cov/covBuild.c
+++ b/src/map/cov/covBuild.c
@@ -20,6 +20,9 @@
#include "cov.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -79,9 +82,9 @@ Abc_Obj_t * Abc_NtkCovDeriveCube( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pObj, Min_Cub
Vec_IntWriteEntry( vLits, i, Lit==1 );
Abc_ObjAddFanin( pNodeNew, pFanin->pCopy );
}
- pNodeNew->pData = Abc_SopCreateAnd( pNtkNew->pManFunc, vLits->nSize, vLits->pArray );
+ pNodeNew->pData = Abc_SopCreateAnd( (Extra_MmFlex_t *)pNtkNew->pManFunc, vLits->nSize, vLits->pArray );
if ( fCompl )
- Abc_SopComplement( pNodeNew->pData );
+ Abc_SopComplement( (char *)pNodeNew->pData );
Vec_IntFree( vLits );
return pNodeNew;
}
@@ -150,7 +153,7 @@ Abc_Obj_t * Abc_NtkCovDeriveNode_rec( Cov_Man_t * p, Abc_Ntk_t * pNtkNew, Abc_Ob
pFaninNew = Abc_NtkCovDeriveCube( pNtkNew, pObj, pCube, vSupp, 0 );
Abc_ObjAddFanin( pNodeNew, pFaninNew );
}
- pNodeNew->pData = Abc_SopCreateXorSpecial( pNtkNew->pManFunc, nCubes );
+ pNodeNew->pData = Abc_SopCreateXorSpecial( (Extra_MmFlex_t *)pNtkNew->pManFunc, nCubes );
}
/*
printf( "Created node %d(%d) at level %d: ", pNodeNew->Id, pObj->Id, Level );
@@ -277,8 +280,8 @@ Abc_Obj_t * Abc_NtkCovDeriveCubeInv( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pObj, Min_
// Abc_ObjAddFanin( pNodeNew, pFanin->pCopy );
Abc_ObjAddFanin( pNodeNew, Abc_NtkCovDeriveInv( pNtkNew, pFanin, Lit==1 ) );
}
-// pNodeNew->pData = Abc_SopCreateAnd( pNtkNew->pManFunc, vLits->nSize, vLits->pArray );
- pNodeNew->pData = Abc_SopCreateAnd( pNtkNew->pManFunc, vLits->nSize, NULL );
+// pNodeNew->pData = Abc_SopCreateAnd( (Extra_MmFlex_t *)pNtkNew->pManFunc, vLits->nSize, vLits->pArray );
+ pNodeNew->pData = Abc_SopCreateAnd( (Extra_MmFlex_t *)pNtkNew->pManFunc, vLits->nSize, NULL );
Vec_IntFree( vLits );
return pNodeNew;
}
@@ -332,7 +335,7 @@ Abc_Obj_t * Abc_NtkCovDeriveNodeInv_rec( Cov_Man_t * p, Abc_Ntk_t * pNtkNew, Abc
pFaninNew = Abc_NtkCovDeriveCubeInv( pNtkNew, pObj, pCube, vSupp );
Abc_ObjAddFanin( pNodeNew, pFaninNew );
}
- pNodeNew->pData = Abc_SopCreateXorSpecial( pNtkNew->pManFunc, nCubes );
+ pNodeNew->pData = Abc_SopCreateXorSpecial( (Extra_MmFlex_t *)pNtkNew->pManFunc, nCubes );
}
pObj->pCopy = pNodeNew;
@@ -469,7 +472,7 @@ Abc_Obj_t * Abc_NtkCovDerive_rec( Cov_Man_t * p, Abc_Ntk_t * pNtkNew, Abc_Obj_t
// derive the function
vCover = Vec_StrAlloc( 100 );
Min_CoverCreate( vCover, pCover, (char)Type );
- pNodeNew->pData = Abc_SopRegister( pNtkNew->pManFunc, Vec_StrArray(vCover) );
+ pNodeNew->pData = Abc_SopRegister((Extra_MmFlex_t *)pNtkNew->pManFunc, Vec_StrArray(vCover) );
Vec_StrFree( vCover );
}
@@ -514,7 +517,7 @@ Abc_Ntk_t * Abc_NtkCovDeriveRegular( Cov_Man_t * p, Abc_Ntk_t * pNtk )
if ( Abc_ObjFaninC0(pObj) )
{
if ( pNodeNew->pData && Abc_ObjFanoutNum(Abc_ObjFanin0(pObj)) == 1 )
- Abc_SopComplement( pNodeNew->pData );
+ Abc_SopComplement( (char *)pNodeNew->pData );
else
pNodeNew = Abc_NtkCreateNodeInv( pNtkNew, pNodeNew );
}
@@ -537,3 +540,5 @@ Abc_Ntk_t * Abc_NtkCovDeriveRegular( Cov_Man_t * p, Abc_Ntk_t * pNtk )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/cov/covCore.c b/src/map/cov/covCore.c
index e36a4d2d..a53f6b49 100644
--- a/src/map/cov/covCore.c
+++ b/src/map/cov/covCore.c
@@ -20,12 +20,15 @@
#include "cov.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
-static void Abc_NtkCovCovers( Cov_Man_t * p, Abc_Ntk_t * pNtk, bool fVerbose );
-static int Abc_NtkCovCoversOne( Cov_Man_t * p, Abc_Ntk_t * pNtk, bool fVerbose );
+static void Abc_NtkCovCovers( Cov_Man_t * p, Abc_Ntk_t * pNtk, int fVerbose );
+static int Abc_NtkCovCoversOne( Cov_Man_t * p, Abc_Ntk_t * pNtk, int fVerbose );
static void Abc_NtkCovCovers_rec( Cov_Man_t * p, Abc_Obj_t * pObj, Vec_Ptr_t * vBoundary );
/*
static int Abc_NodeCovPropagateEsop( Cov_Man_t * p, Abc_Obj_t * pObj, Abc_Obj_t * pObj0, Abc_Obj_t * pObj1 );
@@ -54,7 +57,7 @@ static Min_Cube_t * Abc_NodeCovSum( Cov_Man_t * p, Min_Cube_t * pCover0, Min_Cub
SeeAlso []
***********************************************************************/
-Abc_Ntk_t * Abc_NtkSopEsopCover( Abc_Ntk_t * pNtk, int nFaninMax, bool fUseEsop, bool fUseSop, bool fUseInvs, bool fVerbose )
+Abc_Ntk_t * Abc_NtkSopEsopCover( Abc_Ntk_t * pNtk, int nFaninMax, int fUseEsop, int fUseSop, int fUseInvs, int fVerbose )
{
Abc_Ntk_t * pNtkNew;
Cov_Man_t * p;
@@ -102,7 +105,7 @@ Abc_Ntk_t * Abc_NtkSopEsopCover( Abc_Ntk_t * pNtk, int nFaninMax, bool fUseEsop,
SeeAlso []
***********************************************************************/
-void Abc_NtkCovCovers( Cov_Man_t * p, Abc_Ntk_t * pNtk, bool fVerbose )
+void Abc_NtkCovCovers( Cov_Man_t * p, Abc_Ntk_t * pNtk, int fVerbose )
{
Abc_Obj_t * pObj;
int i, clk = clock();
@@ -146,7 +149,7 @@ ABC_PRT( "Total", clock() - clk );
SeeAlso []
***********************************************************************/
-int Abc_NtkCovCoversOne( Cov_Man_t * p, Abc_Ntk_t * pNtk, bool fVerbose )
+int Abc_NtkCovCoversOne( Cov_Man_t * p, Abc_Ntk_t * pNtk, int fVerbose )
{
ProgressBar * pProgress;
Abc_Obj_t * pObj;
@@ -202,7 +205,7 @@ int Abc_NtkCovCoversOne( Cov_Man_t * p, Abc_Ntk_t * pNtk, bool fVerbose )
// create the new boundary
p->nBoundary = 0;
- Vec_PtrForEachEntry( vBoundary, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vBoundary, pObj, i )
{
if ( !pObj->fMarkA )
{
@@ -1021,3 +1024,5 @@ int Abc_NodeCovUnionSop( Cov_Man_t * p, Min_Cube_t * pCover0, Min_Cube_t * pCove
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/cov/covInt.h b/src/map/cov/covInt.h
index a06519c0..b2d293d4 100644
--- a/src/map/cov/covInt.h
+++ b/src/map/cov/covInt.h
@@ -18,8 +18,15 @@
***********************************************************************/
+#ifndef __COV_INT_H__
+#define __COV_INT_H__
+
#include "abc.h"
+
+ABC_NAMESPACE_HEADER_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -636,8 +643,12 @@ static inline int Min_CoverContainsCube( Min_Man_t * p, Min_Cube_t * pCube )
return 0;
}
+
+ABC_NAMESPACE_HEADER_END
+
+#endif
+
+
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
-
-
diff --git a/src/map/cov/covMan.c b/src/map/cov/covMan.c
index 74a5cf8a..fb6353c7 100644
--- a/src/map/cov/covMan.c
+++ b/src/map/cov/covMan.c
@@ -20,6 +20,9 @@
#include "cov.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -142,3 +145,5 @@ void Abc_NodeCovDropData( Cov_Man_t * p, Abc_Obj_t * pObj )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/cov/covMinEsop.c b/src/map/cov/covMinEsop.c
index 7dd3db30..8497a6b4 100644
--- a/src/map/cov/covMinEsop.c
+++ b/src/map/cov/covMinEsop.c
@@ -20,6 +20,9 @@
#include "covInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -297,3 +300,5 @@ void Min_EsopAddCube( Min_Man_t * p, Min_Cube_t * pCube )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/cov/covMinMan.c b/src/map/cov/covMinMan.c
index 74aa2e8c..12a9e573 100644
--- a/src/map/cov/covMinMan.c
+++ b/src/map/cov/covMinMan.c
@@ -20,6 +20,9 @@
#include "covInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -111,3 +114,5 @@ void Min_ManFree( Min_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/cov/covMinSop.c b/src/map/cov/covMinSop.c
index 731a6698..244b4702 100644
--- a/src/map/cov/covMinSop.c
+++ b/src/map/cov/covMinSop.c
@@ -20,6 +20,9 @@
#include "covInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -613,3 +616,5 @@ int Min_SopCheck( Min_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/cov/covMinUtil.c b/src/map/cov/covMinUtil.c
index c383a3e8..b573a5cb 100644
--- a/src/map/cov/covMinUtil.c
+++ b/src/map/cov/covMinUtil.c
@@ -20,6 +20,9 @@
#include "covInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -336,3 +339,5 @@ int Min_CoverSuppVarNum( Min_Man_t * p, Min_Cube_t * pCover )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/cov/covTest.c b/src/map/cov/covTest.c
index 39432c90..23851742 100644
--- a/src/map/cov/covTest.c
+++ b/src/map/cov/covTest.c
@@ -20,6 +20,9 @@
#include "cov.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -118,14 +121,14 @@ int Abc_NodeDeriveSops( Min_Man_t * p, Abc_Obj_t * pRoot, Vec_Ptr_t * vSupp, Vec
int i, nCubes, fCompl0, fCompl1;
// set elementary vars
- Vec_PtrForEachEntry( vSupp, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vSupp, pObj, i )
{
pObj->pCopy = (Abc_Obj_t *)Min_CubeAllocVar( p, i, 0 );
pObj->pNext = (Abc_Obj_t *)Min_CubeAllocVar( p, i, 1 );
}
// get the cover for each node in the array
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
{
// get the complements
fCompl0 = Abc_ObjFaninC0(pObj);
@@ -165,9 +168,9 @@ Min_CoverWrite( stdout, pCoverN );
// nCubes = Min_CoverCountCubes(pCoverP);
// clean the copy fields
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
pObj->pCopy = pObj->pNext = NULL;
- Vec_PtrForEachEntry( vSupp, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vSupp, pObj, i )
pObj->pCopy = pObj->pNext = NULL;
// Min_CoverWriteFile( pCoverP, Abc_ObjName(pRoot), 0 );
@@ -313,11 +316,11 @@ int Abc_NodeDeriveEsops( Min_Man_t * p, Abc_Obj_t * pRoot, Vec_Ptr_t * vSupp, Ve
int i;
// set elementary vars
- Vec_PtrForEachEntry( vSupp, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vSupp, pObj, i )
pObj->pCopy = (Abc_Obj_t *)Min_CubeAllocVar( p, i, 0 );
// get the cover for each node in the array
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
{
pCover = Abc_NodeDeriveCover( p,
(Min_Cube_t *)Abc_ObjFanin0(pObj)->pCopy,
@@ -351,9 +354,9 @@ int Abc_NodeDeriveEsops( Min_Man_t * p, Abc_Obj_t * pRoot, Vec_Ptr_t * vSupp, Ve
pCover = Min_CoverCollect( p, p->nVars );
*/
// clean the copy fields
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
pObj->pCopy = NULL;
- Vec_PtrForEachEntry( vSupp, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vSupp, pObj, i )
pObj->pCopy = NULL;
// Min_CoverWriteFile( pCover, Abc_ObjName(pRoot), 1 );
@@ -415,3 +418,5 @@ void Abc_NtkTestEsop( Abc_Ntk_t * pNtk )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/fpga/fpga.c b/src/map/fpga/fpga.c
index fa2a138c..08adb52e 100644
--- a/src/map/fpga/fpga.c
+++ b/src/map/fpga/fpga.c
@@ -19,6 +19,9 @@
#include "fpgaInt.h"
#include "main.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -78,9 +81,9 @@ void Fpga_Init( Abc_Frame_t * pAbc )
SeeAlso []
***********************************************************************/
-void Fpga_End()
+void Fpga_End( Abc_Frame_t * pAbc )
{
- Fpga_LutLibFree( Abc_FrameReadLibLut() );
+ Fpga_LutLibFree( (Fpga_LutLib_t *)Abc_FrameReadLibLut() );
}
@@ -153,7 +156,7 @@ int Fpga_CommandReadLibrary( Abc_Frame_t * pAbc, int argc, char **argv )
goto usage;
}
// replace the current library
- Fpga_LutLibFree( Abc_FrameReadLibLut() );
+ Fpga_LutLibFree( (Fpga_LutLib_t *)Abc_FrameReadLibLut() );
Abc_FrameSetLibLut( pLib );
return 0;
@@ -224,7 +227,7 @@ int Fpga_CommandPrintLibrary( Abc_Frame_t * pAbc, int argc, char **argv )
}
// set the new network
- Fpga_LutLibPrint( Abc_FrameReadLibLut() );
+ Fpga_LutLibPrint( (Fpga_LutLib_t *)Abc_FrameReadLibLut() );
return 0;
usage:
@@ -272,7 +275,7 @@ void Fpga_SetSimpleLutLib( int nLutSize )
}
if ( pLutLib == NULL )
return;
- Fpga_LutLibFree( Abc_FrameReadLibLut() );
+ Fpga_LutLibFree( (Fpga_LutLib_t *)Abc_FrameReadLibLut() );
Abc_FrameSetLibLut( Fpga_LutLibDup(pLutLib) );
}
@@ -281,3 +284,5 @@ void Fpga_SetSimpleLutLib( int nLutSize )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/fpga/fpga.h b/src/map/fpga/fpga.h
index 0479847c..082e6635 100644
--- a/src/map/fpga/fpga.h
+++ b/src/map/fpga/fpga.h
@@ -19,6 +19,7 @@
#ifndef __FPGA_H__
#define __FPGA_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -27,9 +28,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
// the maximum size of LUTs used for mapping
#define FPGA_MAX_LUTSIZE 32
@@ -164,9 +166,11 @@ extern Fpga_NodeVec_t * Fpga_CollectNodeTfo( Fpga_Man_t * pMan, Fpga_Node_t * pN
/*=== fpga.c =============================================================*/
extern void Fpga_SetSimpleLutLib( int nLutSize );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/map/fpga/fpgaCore.c b/src/map/fpga/fpgaCore.c
index 17feac7c..74739852 100644
--- a/src/map/fpga/fpgaCore.c
+++ b/src/map/fpga/fpgaCore.c
@@ -18,6 +18,9 @@
#include "fpgaInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -186,3 +189,5 @@ ABC_PRT( "Time", clock() - clk );
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/fpga/fpgaCreate.c b/src/map/fpga/fpgaCreate.c
index 5245f050..168b69c6 100644
--- a/src/map/fpga/fpgaCreate.c
+++ b/src/map/fpga/fpgaCreate.c
@@ -19,6 +19,9 @@
#include "fpgaInt.h"
#include "main.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -169,7 +172,7 @@ Fpga_Man_t * Fpga_ManCreate( int nInputs, int nOutputs, int fVerbose )
// start the manager
p = ABC_ALLOC( Fpga_Man_t, 1 );
memset( p, 0, sizeof(Fpga_Man_t) );
- p->pLutLib = Abc_FrameReadLibLut();
+ p->pLutLib = (Fpga_LutLib_t *)Abc_FrameReadLibLut();
p->nVarsMax = p->pLutLib->LutMax;
p->fVerbose = fVerbose;
p->fAreaRecovery = 1;
@@ -580,3 +583,5 @@ void Fpga_ManStats( Fpga_Man_t * p )
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/fpga/fpgaCut.c b/src/map/fpga/fpgaCut.c
index aca4a8ef..5f46be18 100644
--- a/src/map/fpga/fpgaCut.c
+++ b/src/map/fpga/fpgaCut.c
@@ -18,6 +18,9 @@
#include "fpgaInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -1179,3 +1182,5 @@ Fpga_Cut_t * Fpga_CutArray2List( Fpga_Cut_t ** pArray, int nCuts )
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/fpga/fpgaCutUtils.c b/src/map/fpga/fpgaCutUtils.c
index 0f003ee7..9b5b2be9 100644
--- a/src/map/fpga/fpgaCutUtils.c
+++ b/src/map/fpga/fpgaCutUtils.c
@@ -18,6 +18,9 @@
#include "fpgaInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -469,3 +472,5 @@ void Fpga_MappingSetUsedCuts( Fpga_Man_t * pMan )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/fpga/fpgaFanout.c b/src/map/fpga/fpgaFanout.c
index c28a8799..e4e8894c 100644
--- a/src/map/fpga/fpgaFanout.c
+++ b/src/map/fpga/fpgaFanout.c
@@ -18,6 +18,9 @@
#include "fpgaInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
#ifdef MAP_ALLOCATE_FANOUT
////////////////////////////////////////////////////////////////////////
@@ -139,3 +142,5 @@ int Fpga_NodeGetFanoutNum( Fpga_Node_t * pNode )
#endif
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/fpga/fpgaGENERIC.c b/src/map/fpga/fpgaGENERIC.c
index 4483c215..c5a67228 100644
--- a/src/map/fpga/fpgaGENERIC.c
+++ b/src/map/fpga/fpgaGENERIC.c
@@ -18,6 +18,9 @@
#include "fpgaInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -44,3 +47,5 @@
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/fpga/fpgaInt.h b/src/map/fpga/fpgaInt.h
index ba9538c2..26de9b80 100644
--- a/src/map/fpga/fpgaInt.h
+++ b/src/map/fpga/fpgaInt.h
@@ -19,6 +19,7 @@
#ifndef __FPGA_INT_H__
#define __FPGA_INT_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -29,6 +30,9 @@
#include "extra.h"
#include "fpga.h"
+ABC_NAMESPACE_HEADER_START
+
+
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
@@ -377,6 +381,10 @@ extern void Fpga_MappingSetChoiceLevels( Fpga_Man_t * pMan );
/*=== CUDD package.c ===============================================================*/
extern unsigned int Cudd_Prime( unsigned int p );
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif
////////////////////////////////////////////////////////////////////////
diff --git a/src/map/fpga/fpgaLib.c b/src/map/fpga/fpgaLib.c
index d5b12293..1c173ad9 100644
--- a/src/map/fpga/fpgaLib.c
+++ b/src/map/fpga/fpgaLib.c
@@ -18,6 +18,9 @@
#include "fpgaInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -248,3 +251,5 @@ int Fpga_LutLibDelaysAreDiscrete( Fpga_LutLib_t * pLutLib )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/fpga/fpgaMatch.c b/src/map/fpga/fpgaMatch.c
index 30448750..08db4bb1 100644
--- a/src/map/fpga/fpgaMatch.c
+++ b/src/map/fpga/fpgaMatch.c
@@ -18,6 +18,9 @@
#include "fpgaInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -792,3 +795,5 @@ float Fpga_FindBestNode( Fpga_Man_t * p, Fpga_NodeVec_t * vNodes, Fpga_Node_t **
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/fpga/fpgaSwitch.c b/src/map/fpga/fpgaSwitch.c
index 5e881959..524262ec 100644
--- a/src/map/fpga/fpgaSwitch.c
+++ b/src/map/fpga/fpgaSwitch.c
@@ -18,6 +18,9 @@
#include "fpgaInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -149,3 +152,5 @@ float Fpga_MappingGetSwitching( Fpga_Man_t * pMan, Fpga_NodeVec_t * vMapping )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/fpga/fpgaTime.c b/src/map/fpga/fpgaTime.c
index d9bf7947..5454ce3c 100644
--- a/src/map/fpga/fpgaTime.c
+++ b/src/map/fpga/fpgaTime.c
@@ -18,6 +18,9 @@
#include "fpgaInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -260,3 +263,5 @@ void Fpga_TimePropagateArrival( Fpga_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/fpga/fpgaTruth.c b/src/map/fpga/fpgaTruth.c
index 7eca8e3e..d37ff81d 100644
--- a/src/map/fpga/fpgaTruth.c
+++ b/src/map/fpga/fpgaTruth.c
@@ -19,6 +19,9 @@
#include "fpgaInt.h"
#include "cudd.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -81,17 +84,17 @@ void * Fpga_TruthsCutBdd( void * dd, Fpga_Cut_t * pCut )
assert( pCut->nLeaves > 1 );
// set the leaf variables
for ( i = 0; i < pCut->nLeaves; i++ )
- pCut->ppLeaves[i]->pCuts->uSign = (unsigned)(ABC_PTRUINT_T)Cudd_bddIthVar( dd, i );
+ pCut->ppLeaves[i]->pCuts->uSign = (unsigned)(ABC_PTRUINT_T)Cudd_bddIthVar( (DdManager *)dd, i );
// recursively compute the function
vVisited = Fpga_NodeVecAlloc( 10 );
- bFunc = Fpga_TruthsCutBdd_rec( dd, pCut, vVisited ); Cudd_Ref( bFunc );
+ bFunc = Fpga_TruthsCutBdd_rec( (DdManager *)dd, pCut, vVisited ); Cudd_Ref( bFunc );
// clean the intermediate BDDs
for ( i = 0; i < pCut->nLeaves; i++ )
pCut->ppLeaves[i]->pCuts->uSign = 0;
for ( i = 0; i < vVisited->nSize; i++ )
{
pCut = (Fpga_Cut_t *)vVisited->pArray[i];
- Cudd_RecursiveDeref( dd, (DdNode*)(ABC_PTRUINT_T)pCut->uSign );
+ Cudd_RecursiveDeref( (DdManager *)dd, (DdNode*)(ABC_PTRUINT_T)pCut->uSign );
pCut->uSign = 0;
}
// printf( "%d ", vVisited->nSize );
@@ -164,3 +167,5 @@ int Fpga_CutVolume( Fpga_Cut_t * pCut )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/fpga/fpgaUtils.c b/src/map/fpga/fpgaUtils.c
index f360254b..f10971ad 100644
--- a/src/map/fpga/fpgaUtils.c
+++ b/src/map/fpga/fpgaUtils.c
@@ -18,6 +18,9 @@
#include "fpgaInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -983,3 +986,5 @@ Fpga_NodeVec_t * Fpga_MappingOrderCosByLevel( Fpga_Man_t * pMan )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/fpga/fpgaVec.c b/src/map/fpga/fpgaVec.c
index b17697dd..35260029 100644
--- a/src/map/fpga/fpgaVec.c
+++ b/src/map/fpga/fpgaVec.c
@@ -18,6 +18,9 @@
#include "fpgaInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -406,3 +409,5 @@ void Fpga_NodeVecReverse( Fpga_NodeVec_t * vNodes )
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/if/if.h b/src/map/if/if.h
index 91d6e037..96f6f109 100644
--- a/src/map/if/if.h
+++ b/src/map/if/if.h
@@ -21,10 +21,11 @@
#ifndef __IF_H__
#define __IF_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
-
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -34,9 +35,10 @@
#include "mem.h"
#include "tim.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
@@ -92,8 +94,10 @@ struct If_Par_t_
int fCutMin; // performs cut minimization by removing functionally reducdant variables
int fSeqMap; // sequential mapping
int fBidec; // use bi-decomposition
+ int fUseBat; // use one specialized feature
int fVerbose; // the verbosity flag
// internal parameters
+ int fDelayOpt; // special delay optimization
int fAreaOnly; // area only mode
int fTruth; // truth table computation enabled
int fUsePerm; // use permutation (delay info)
@@ -101,13 +105,16 @@ struct If_Par_t_
int fUseSops; // use local SOPs as a cost function
int fUseCnfs; // use local CNFs as a cost function
int fUseMv; // use local MV-SOPs as a cost function
+ int fUseAdders; // timing model for adders
int nLatches; // the number of latches in seq mapping
int fLiftLeaves; // shift the leaves for seq mapping
+ int fUseCoAttrs; // use CO attributes
If_Lib_t * pLutLib; // the LUT library
float * pTimesArr; // arrival times
float * pTimesReq; // required times
int (* pFuncCost) (If_Cut_t *); // procedure to compute the user's cost of a cut
int (* pFuncUser) (If_Man_t *, If_Obj_t *, If_Cut_t *); // procedure called for each cut when cut computation is finished
+ int (* pFuncCell) (unsigned *, int, int); // procedure called for cut functions
void * pReoMan; // reordering manager
};
@@ -166,10 +173,13 @@ struct If_Man_t_
Mem_Fixed_t * pMemSet; // memory manager for sets of cuts (entrysize = nCutSize*(nCutsMax+1))
If_Set_t * pMemCi; // memory for CI cutsets
If_Set_t * pMemAnd; // memory for AND cutsets
- If_Set_t * pFreeList; // the list of ABC_FREE cutsets
+ If_Set_t * pFreeList; // the list of free cutsets
int nSmallSupp; // the small support
+ int nCutsTotal;
+ int nCutsUseless;
// timing manager
Tim_Man_t * pManTim;
+ Vec_Int_t * vCoAttrs; // CO attributes 0=optimize; 1=keep; 2=relax
// statistics
// int timeTruth;
};
@@ -183,9 +193,10 @@ struct If_Cut_t_
float Power; // the power flow
float Delay; // delay of the cut
unsigned uSign; // cut signature
- unsigned Cost : 14; // the user's cost of the cut
+ unsigned Cost : 13; // the user's cost of the cut
unsigned fCompl : 1; // the complemented attribute
unsigned fUser : 1; // using the user's area and delay
+ unsigned fUseless: 1; // using the user's area and delay
unsigned nLimit : 8; // the maximum number of leaves
unsigned nLeaves : 8; // the number of leaves
int * pLeaves; // array of fanins
@@ -198,7 +209,7 @@ struct If_Set_t_
{
short nCutsMax; // the max number of cuts
short nCuts; // the current number of cuts
- If_Set_t * pNext; // next cutset in the ABC_FREE list
+ If_Set_t * pNext; // next cutset in the free list
If_Cut_t ** ppCuts; // the array of pointers to the cuts
};
@@ -212,7 +223,8 @@ struct If_Obj_t_
unsigned fRepr : 1; // representative of the equivalence class
unsigned fMark : 1; // multipurpose mark
unsigned fVisit : 1; // multipurpose mark
- unsigned Level : 22; // logic level of the node
+ unsigned fSpec : 1; // multipurpose mark
+ unsigned Level : 21; // logic level of the node
int Id; // integer ID
int IdPio; // integer ID of PIs/POs
int nRefs; // the number of references
@@ -229,6 +241,18 @@ struct If_Obj_t_
If_Cut_t CutBest; // the best cut selected
};
+typedef struct If_And_t_ If_And_t;
+struct If_And_t_
+{
+ unsigned iFan0 : 15; // fanin0
+ unsigned fCompl0 : 1; // compl fanin0
+ unsigned iFan1 : 15; // fanin1
+ unsigned fCompl1 : 1; // compl fanin1
+ unsigned Id : 15; // Id
+ unsigned fCompl : 1; // compl output
+ unsigned Delay : 16; // delay
+};
+
static inline If_Obj_t * If_Regular( If_Obj_t * p ) { return (If_Obj_t *)((ABC_PTRUINT_T)(p) & ~01); }
static inline If_Obj_t * If_Not( If_Obj_t * p ) { return (If_Obj_t *)((ABC_PTRUINT_T)(p) ^ 01); }
static inline If_Obj_t * If_NotCond( If_Obj_t * p, int c ) { return (If_Obj_t *)((ABC_PTRUINT_T)(p) ^ (c)); }
@@ -253,6 +277,7 @@ static inline int If_ObjIsTerm( If_Obj_t * pObj ) { r
static inline int If_ObjIsLatch( If_Obj_t * pObj ) { return If_ObjIsCi(pObj) && pObj->pFanin0 != NULL; }
static inline int If_ObjIsAnd( If_Obj_t * pObj ) { return pObj->Type == IF_AND; }
+static inline int If_ObjId( If_Obj_t * pObj ) { return pObj->Id; }
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; }
@@ -275,6 +300,9 @@ static inline void If_ObjSetLValue( If_Obj_t * pObj, float LValue ) { p
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 int If_CutDataInt( If_Cut_t * pCut ) { return *(int *)pCut; }
+static inline void If_CutSetDataInt( If_Cut_t * pCut, int Data ) { *(int *)pCut = Data; }
+
static inline int If_CutLeaveNum( If_Cut_t * pCut ) { return pCut->nLeaves; }
static inline int * If_CutLeaves( If_Cut_t * pCut ) { return pCut->pLeaves; }
static inline unsigned * If_CutTruth( If_Cut_t * pCut ) { return pCut->pTruth; }
@@ -284,6 +312,11 @@ static inline int If_CutPermWords( int nVarsMax ) { r
static inline float If_CutLutArea( If_Man_t * p, If_Cut_t * pCut ) { return pCut->fUser? (float)pCut->Cost : (p->pPars->pLutLib? p->pPars->pLutLib->pLutAreas[pCut->nLeaves] : (float)1.0); }
+static inline word If_AndToWrd( If_And_t m ) { union { If_And_t x; word y; } v; v.x = m; return v.y; }
+static inline If_And_t If_WrdToAnd( word m ) { union { If_And_t x; word y; } v; v.y = m; return v.x; }
+static inline void If_AndClear( If_And_t * pNode ) { *pNode = If_WrdToAnd(0); }
+
+
////////////////////////////////////////////////////////////////////////
/// MACRO DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
@@ -298,27 +331,27 @@ static inline float If_CutLutArea( If_Man_t * p, If_Cut_t * pCut ) { r
// iterator over the primary inputs
#define If_ManForEachCi( p, pObj, i ) \
- Vec_PtrForEachEntry( p->vCis, pObj, i )
+ Vec_PtrForEachEntry( If_Obj_t *, p->vCis, pObj, i )
// iterator over the primary outputs
#define If_ManForEachCo( p, pObj, i ) \
- Vec_PtrForEachEntry( p->vCos, pObj, i )
+ Vec_PtrForEachEntry( If_Obj_t *, p->vCos, pObj, i )
// iterator over the primary inputs
#define If_ManForEachPi( p, pObj, i ) \
- Vec_PtrForEachEntryStop( p->vCis, pObj, i, If_ManCiNum(p) - p->pPars->nLatches )
+ Vec_PtrForEachEntryStop( If_Obj_t *, p->vCis, pObj, i, If_ManCiNum(p) - p->pPars->nLatches )
// iterator over the primary outputs
#define If_ManForEachPo( p, pObj, i ) \
- Vec_PtrForEachEntryStop( p->vCos, pObj, i, If_ManCoNum(p) - p->pPars->nLatches )
+ Vec_PtrForEachEntryStop( If_Obj_t *, p->vCos, pObj, i, If_ManCoNum(p) - p->pPars->nLatches )
// iterator over the latches
#define If_ManForEachLatchInput( p, pObj, i ) \
- Vec_PtrForEachEntryStart( p->vCos, pObj, i, If_ManCoNum(p) - p->pPars->nLatches )
+ Vec_PtrForEachEntryStart( If_Obj_t *, p->vCos, pObj, i, If_ManCoNum(p) - p->pPars->nLatches )
#define If_ManForEachLatchOutput( p, pObj, i ) \
- Vec_PtrForEachEntryStart( p->vCis, pObj, i, If_ManCiNum(p) - p->pPars->nLatches )
+ Vec_PtrForEachEntryStart( If_Obj_t *, p->vCis, pObj, i, If_ManCiNum(p) - p->pPars->nLatches )
// iterator over all objects in topological order
#define If_ManForEachObj( p, pObj, i ) \
- Vec_PtrForEachEntry( p->vObjs, pObj, i )
+ Vec_PtrForEachEntry( If_Obj_t *, p->vObjs, pObj, i )
// iterator over all objects in reverse topological order
#define If_ManForEachObjReverse( p, pObj, i ) \
- Vec_PtrForEachEntry( p->vObjsRev, pObj, i )
+ Vec_PtrForEachEntry( If_Obj_t *, p->vObjsRev, pObj, i )
// iterator over logic nodes
#define If_ManForEachNode( p, pObj, i ) \
If_ManForEachObj( p, pObj, i ) if ( pObj->Type != IF_AND ) {} else
@@ -404,6 +437,8 @@ extern void If_ManImproveMapping( If_Man_t * p );
/*=== ifSeq.c =============================================================*/
extern int If_ManPerformMappingSeq( If_Man_t * p );
/*=== ifTime.c ============================================================*/
+extern int If_CutDelaySopCost( If_Man_t * p, If_Cut_t * pCut );
+extern Vec_Wrd_t * If_CutDelaySopArray( If_Man_t * p, If_Cut_t * pCut );
extern float If_CutDelay( If_Man_t * p, If_Cut_t * pCut );
extern void If_CutPropagateRequired( If_Man_t * p, If_Cut_t * pCut, float Required );
extern void If_CutRotatePins( If_Man_t * p, If_Cut_t * pCut );
@@ -427,14 +462,12 @@ extern void If_ManMarkMapping( If_Man_t * p );
extern Vec_Ptr_t * If_ManCollectMappingDirect( If_Man_t * p );
extern Vec_Int_t * If_ManCollectMappingInt( If_Man_t * p );
-
extern int If_ManCountSpecialPos( If_Man_t * p );
+// othe packages
+extern int Bat_ManCellFuncLookup( unsigned * pTruth, int nVars, int nLeaves );
-
-#ifdef __cplusplus
-}
-#endif
+ABC_NAMESPACE_HEADER_END
#endif
diff --git a/src/map/if/ifCore.c b/src/map/if/ifCore.c
index e3fd47f1..fcecb401 100644
--- a/src/map/if/ifCore.c
+++ b/src/map/if/ifCore.c
@@ -20,6 +20,9 @@
#include "if.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -56,7 +59,7 @@ int If_ManPerformMapping( If_Man_t * p )
if ( p->pPars->fSeqMap )
{
// if ( p->pPars->fVerbose )
- printf( "Performing sequential mapping without retiming.\n" );
+ Abc_Print( 1, "Performing sequential mapping without retiming.\n" );
return If_ManPerformMappingSeq( p );
}
return If_ManPerformMappingComb( p );
@@ -128,21 +131,20 @@ int If_ManPerformMappingComb( If_Man_t * p )
if ( p->pPars->fVerbose )
{
-// printf( "Total memory = %7.2f Mb. Peak cut memory = %7.2f Mb. ",
+// Abc_Print( 1, "Total memory = %7.2f Mb. Peak cut memory = %7.2f Mb. ",
// 1.0 * (p->nObjBytes + 2*sizeof(void *)) * If_ManObjNum(p) / (1<<20),
// 1.0 * p->nSetBytes * Mem_FixedReadMaxEntriesUsed(p->pMemSet) / (1<<20) );
- ABC_PRT( "Total time", clock() - clkTotal );
+ Abc_PrintTime( 1, "Total time", clock() - clkTotal );
}
-// printf( "Cross cut memory = %d.\n", Mem_FixedReadMaxEntriesUsed(p->pMemSet) );
+// Abc_Print( 1, "Cross cut memory = %d.\n", Mem_FixedReadMaxEntriesUsed(p->pMemSet) );
s_MappingTime = clock() - clkTotal;
-// printf( "Special POs = %d.\n", If_ManCountSpecialPos(p) );
+// Abc_Print( 1, "Special POs = %d.\n", If_ManCountSpecialPos(p) );
{
extern int If_CutGetCones( If_Man_t * p );
extern int If_CutCountTotalFanins( If_Man_t * p );
// If_CutGetCones( p );
// If_CutCountTotalFanins( p );
}
-
return 1;
}
@@ -151,3 +153,5 @@ int If_ManPerformMappingComb( If_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/if/ifCut.c b/src/map/if/ifCut.c
index d3ce5397..58224692 100644
--- a/src/map/if/ifCut.c
+++ b/src/map/if/ifCut.c
@@ -20,6 +20,9 @@
#include "if.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -440,7 +443,7 @@ static inline int If_ManSortCompare( If_Man_t * p, If_Cut_t * pC0, If_Cut_t * pC
return -1;
if ( pC0->Area > pC1->Area + p->fEpsilon )
return 1;
- //printf("area(%.2f, %.2f), power(%.2f, %.2f), edge(%.2f, %.2f)\n",
+ //Abc_Print( 1,"area(%.2f, %.2f), power(%.2f, %.2f), edge(%.2f, %.2f)\n",
// pC0->Area, pC1->Area, pC0->Power, pC1->Power, pC0->Edge, pC1->Edge);
if ( pC0->Power < pC1->Power - p->fEpsilon )
return -1;
@@ -511,7 +514,7 @@ static inline int If_ManSortCompare( If_Man_t * p, If_Cut_t * pC0, If_Cut_t * pC
return 1;
return 0;
}
- else // reglar
+ else // regular
{
if ( p->SortMode == 1 ) // area
{
@@ -682,16 +685,28 @@ void If_CutSort( If_Man_t * p, If_Set_t * pCutSet, If_Cut_t * pCut )
return;
}
+ if ( p->pPars->fUseBat && !pCut->fUseless )
+ {
+ If_Cut_t * pFirst = pCutSet->ppCuts[0];
+ if ( pFirst->fUseless || If_ManSortCompare(p, pFirst, pCut) == 1 )
+ {
+ pCutSet->ppCuts[0] = pCut;
+ pCutSet->ppCuts[pCutSet->nCuts] = pFirst;
+ If_CutSort( p, pCutSet, pFirst );
+ return;
+ }
+ }
+
// the cut will be added - find its place
for ( i = pCutSet->nCuts-1; i >= 0; i-- )
{
// Counter++;
- if ( If_ManSortCompare( p, pCutSet->ppCuts[i], pCut ) <= 0 )
+ if ( If_ManSortCompare( p, pCutSet->ppCuts[i], pCut ) <= 0 || (i == 0 && !pCutSet->ppCuts[0]->fUseless && pCut->fUseless) )
break;
pCutSet->ppCuts[i+1] = pCutSet->ppCuts[i];
pCutSet->ppCuts[i] = pCut;
}
-// printf( "%d ", Counter );
+// Abc_Print( 1, "%d ", Counter );
// update the number of cuts
if ( pCutSet->nCuts < pCutSet->nCutsMax )
@@ -746,7 +761,7 @@ int If_CutCheck( If_Cut_t * pCut )
{
if ( pCut->pLeaves[i-1] >= pCut->pLeaves[i] )
{
- printf( "If_CutCheck(): Cut has wrong ordering of inputs.\n" );
+ Abc_Print( -1, "If_CutCheck(): Cut has wrong ordering of inputs.\n" );
return 0;
}
assert( pCut->pLeaves[i-1] < pCut->pLeaves[i] );
@@ -769,10 +784,10 @@ int If_CutCheck( If_Cut_t * pCut )
void If_CutPrint( If_Cut_t * pCut )
{
unsigned i;
- printf( "{" );
+ Abc_Print( 1, "{" );
for ( i = 0; i < pCut->nLeaves; i++ )
- printf( " %d", pCut->pLeaves[i] );
- printf( " }\n" );
+ Abc_Print( 1, " %d", pCut->pLeaves[i] );
+ Abc_Print( 1, " }\n" );
}
/**Function*************************************************************
@@ -790,10 +805,10 @@ void If_CutPrintTiming( If_Man_t * p, If_Cut_t * pCut )
{
If_Obj_t * pLeaf;
unsigned i;
- printf( "{" );
+ Abc_Print( 1, "{" );
If_CutForEachLeaf( p, pCut, pLeaf, i )
- printf( " %d(%.2f/%.2f)", pLeaf->Id, If_ObjCutBest(pLeaf)->Delay, pLeaf->Required );
- printf( " }\n" );
+ Abc_Print( 1, " %d(%.2f/%.2f)", pLeaf->Id, If_ObjCutBest(pLeaf)->Delay, pLeaf->Required );
+ Abc_Print( 1, " }\n" );
}
/**Function*************************************************************
@@ -1345,11 +1360,11 @@ int If_CutGetCones( If_Man_t * p )
if ( If_ObjIsAnd(pObj) && pObj->nRefs )
{
Counter += !If_CutGetCone_rec( p, pObj, If_ObjCutBest(pObj) );
-// printf( "%d ", If_CutGetCutMinLevel( p, If_ObjCutBest(pObj) ) );
+// Abc_Print( 1, "%d ", If_CutGetCutMinLevel( p, If_ObjCutBest(pObj) ) );
}
}
- printf( "Cound not find boundary for %d nodes.\n", Counter );
- ABC_PRT( "Cones", clock() - clk );
+ Abc_Print( 1, "Cound not find boundary for %d nodes.\n", Counter );
+ Abc_PrintTime( 1, "Cones", clock() - clk );
return 1;
}
@@ -1405,8 +1420,8 @@ int If_CutCountTotalFanins( If_Man_t * p )
Counter += Vec_IntSize(vLeaves);
}
}
- printf( "Total cut inputs = %d. Total fanins incremental = %d.\n", nFaninsTotal, Counter );
- ABC_PRT( "Fanins", clock() - clk );
+ Abc_Print( 1, "Total cut inputs = %d. Total fanins incremental = %d.\n", nFaninsTotal, Counter );
+ Abc_PrintTime( 1, "Fanins", clock() - clk );
Vec_IntFree( vLeaves );
return 1;
}
@@ -1416,3 +1431,5 @@ int If_CutCountTotalFanins( If_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/if/ifLib.c b/src/map/if/ifLib.c
index 176edb24..90e37a0f 100644
--- a/src/map/if/ifLib.c
+++ b/src/map/if/ifLib.c
@@ -20,6 +20,9 @@
#include "if.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -51,7 +54,7 @@ If_Lib_t * If_LutLibRead( char * FileName )
pFile = fopen( FileName, "r" );
if ( pFile == NULL )
{
- printf( "Cannot open LUT library file \"%s\".\n", FileName );
+ Abc_Print( -1, "Cannot open LUT library file \"%s\".\n", FileName );
return NULL;
}
@@ -69,7 +72,7 @@ If_Lib_t * If_LutLibRead( char * FileName )
continue;
if ( i != atoi(pToken) )
{
- printf( "Error in the LUT library file \"%s\".\n", FileName );
+ Abc_Print( 1, "Error in the LUT library file \"%s\".\n", FileName );
ABC_FREE( p );
return NULL;
}
@@ -86,7 +89,7 @@ If_Lib_t * If_LutLibRead( char * FileName )
// check for out-of-bound
if ( k > i )
{
- printf( "LUT %d has too many pins (%d). Max allowed is %d.\n", i, k, i );
+ Abc_Print( 1, "LUT %d has too many pins (%d). Max allowed is %d.\n", i, k, i );
return NULL;
}
@@ -96,7 +99,7 @@ If_Lib_t * If_LutLibRead( char * FileName )
if ( i == IF_MAX_LUTSIZE )
{
- printf( "Skipping LUTs of size more than %d.\n", i );
+ Abc_Print( 1, "Skipping LUTs of size more than %d.\n", i );
return NULL;
}
i++;
@@ -110,10 +113,10 @@ If_Lib_t * If_LutLibRead( char * FileName )
for ( k = 0; k < i; k++ )
{
if ( p->pLutDelays[i][k] <= 0.0 )
- printf( "Warning: Pin %d of LUT %d has delay %f. Pin delays should be non-negative numbers. Technology mapping may not work correctly.\n",
+ Abc_Print( 0, "Pin %d of LUT %d has delay %f. Pin delays should be non-negative numbers. Technology mapping may not work correctly.\n",
k, i, p->pLutDelays[i][k] );
if ( k && p->pLutDelays[i][k-1] > p->pLutDelays[i][k] )
- printf( "Warning: Pin %d of LUT %d has delay %f. Pin %d of LUT %d has delay %f. Pin delays should be in non-decreasing order. Technology mapping may not work correctly.\n",
+ Abc_Print( 0, "Pin %d of LUT %d has delay %f. Pin %d of LUT %d has delay %f. Pin delays should be in non-decreasing order. Technology mapping may not work correctly.\n",
k-1, i, p->pLutDelays[i][k-1],
k, i, p->pLutDelays[i][k] );
}
@@ -123,7 +126,7 @@ If_Lib_t * If_LutLibRead( char * FileName )
for ( i = 1; i <= p->LutMax; i++ )
{
if ( p->pLutDelays[i][0] <= 0.0 )
- printf( "Warning: LUT %d has delay %f. Pin delays should be non-negative numbers. Technology mapping may not work correctly.\n",
+ Abc_Print( 0, "LUT %d has delay %f. Pin delays should be non-negative numbers. Technology mapping may not work correctly.\n",
i, p->pLutDelays[i][0] );
}
}
@@ -185,21 +188,21 @@ void If_LutLibFree( If_Lib_t * pLutLib )
void If_LutLibPrint( If_Lib_t * pLutLib )
{
int i, k;
- printf( "# The area/delay of k-variable LUTs:\n" );
- printf( "# k area delay\n" );
+ Abc_Print( 1, "# The area/delay of k-variable LUTs:\n" );
+ Abc_Print( 1, "# k area delay\n" );
if ( pLutLib->fVarPinDelays )
{
for ( i = 1; i <= pLutLib->LutMax; i++ )
{
- printf( "%d %7.2f ", i, pLutLib->pLutAreas[i] );
+ Abc_Print( 1, "%d %7.2f ", i, pLutLib->pLutAreas[i] );
for ( k = 0; k < i; k++ )
- printf( " %7.2f", pLutLib->pLutDelays[i][k] );
- printf( "\n" );
+ Abc_Print( 1, " %7.2f", pLutLib->pLutDelays[i][k] );
+ Abc_Print( 1, "\n" );
}
}
else
for ( i = 1; i <= pLutLib->LutMax; i++ )
- printf( "%d %7.2f %7.2f\n", i, pLutLib->pLutAreas[i], pLutLib->pLutDelays[i][0] );
+ Abc_Print( 1, "%d %7.2f %7.2f\n", i, pLutLib->pLutAreas[i], pLutLib->pLutDelays[i][0] );
}
/**Function*************************************************************
@@ -334,3 +337,5 @@ float If_LutLibSlowestPinDelay( If_Lib_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/if/ifMan.c b/src/map/if/ifMan.c
index 6294e3d2..f0c37e70 100644
--- a/src/map/if/ifMan.c
+++ b/src/map/if/ifMan.c
@@ -20,6 +20,9 @@
#include "if.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -50,14 +53,14 @@ If_Man_t * If_ManStart( If_Par_t * pPars )
// start the manager
p = ABC_ALLOC( If_Man_t, 1 );
memset( p, 0, sizeof(If_Man_t) );
- p->pPars = pPars;
+ p->pPars = pPars;
p->fEpsilon = pPars->Epsilon;
// allocate arrays for nodes
- p->vCis = Vec_PtrAlloc( 100 );
- p->vCos = Vec_PtrAlloc( 100 );
- p->vObjs = Vec_PtrAlloc( 100 );
+ p->vCis = Vec_PtrAlloc( 100 );
+ p->vCos = Vec_PtrAlloc( 100 );
+ p->vObjs = Vec_PtrAlloc( 100 );
// p->vMapped = Vec_PtrAlloc( 100 );
- p->vTemp = Vec_PtrAlloc( 100 );
+ p->vTemp = Vec_PtrAlloc( 100 );
// prepare the memory manager
p->nTruthWords = p->pPars->fTruth? If_CutTruthWords( p->pPars->nLutSize ) : 0;
p->nPermWords = p->pPars->fUsePerm? If_CutPermWords( p->pPars->nLutSize ) : 0;
@@ -68,7 +71,7 @@ If_Man_t * If_ManStart( If_Par_t * pPars )
// p->pMemSet = Mem_FixedStart( p->nSetBytes );
// report expected memory usage
if ( p->pPars->fVerbose )
- printf( "K = %d. Memory (bytes): Truth = %4d. Cut = %4d. Obj = %4d. Set = %4d.\n",
+ Abc_Print( 1, "K = %d. Memory (bytes): Truth = %4d. Cut = %4d. Obj = %4d. Set = %4d.\n",
p->pPars->nLutSize, 4 * p->nTruthWords, p->nCutBytes, p->nObjBytes, p->nSetBytes );
// room for temporary truth tables
p->puTemp[0] = p->pPars->fTruth? ABC_ALLOC( unsigned, 4 * p->nTruthWords ) : NULL;
@@ -76,7 +79,7 @@ If_Man_t * If_ManStart( If_Par_t * pPars )
p->puTemp[2] = p->puTemp[1] + p->nTruthWords;
p->puTemp[3] = p->puTemp[2] + p->nTruthWords;
// create the constant node
- p->pConst1 = If_ManSetupObj( p );
+ p->pConst1 = If_ManSetupObj( p );
p->pConst1->Type = IF_CONST1;
p->pConst1->fPhase = 1;
p->nObjs[IF_CONST1]++;
@@ -124,8 +127,11 @@ void If_ManRestart( If_Man_t * p )
***********************************************************************/
void If_ManStop( If_Man_t * p )
{
-// ABC_PRT( "Truth", p->timeTruth );
-// printf( "Small support = %d.\n", p->nSmallSupp );
+ if ( p->nCutsUseless && p->pPars->fVerbose )
+ Abc_Print( 1, "Useless cuts = %7d (out of %7d) (%6.2f %%)\n", p->nCutsUseless, p->nCutsTotal, 100.0*p->nCutsUseless/(p->nCutsTotal+1) );
+// Abc_PrintTime( 1, "Truth", p->timeTruth );
+// Abc_Print( 1, "Small support = %d.\n", p->nSmallSupp );
+ Vec_IntFreeP( &p->vCoAttrs );
Vec_PtrFree( p->vCis );
Vec_PtrFree( p->vCos );
Vec_PtrFree( p->vObjs );
@@ -192,6 +198,7 @@ If_Obj_t * If_ManCreateCo( If_Man_t * p, If_Obj_t * pDriver )
pObj->Type = IF_CO;
pObj->fCompl0 = If_IsComplement(pDriver); pDriver = If_Regular(pDriver);
pObj->pFanin0 = pDriver; pDriver->nRefs++;
+ pObj->fPhase = (pObj->fCompl0 ^ pDriver->fPhase);
pObj->Level = pDriver->Level;
if ( p->nLevelMax < (int)pObj->Level )
p->nLevelMax = (int)pObj->Level;
@@ -379,6 +386,8 @@ void If_ManSetupCutTriv( If_Man_t * p, If_Cut_t * pCut, int ObjId )
for ( i = 0; i < nTruthWords; i++ )
If_CutTruth(pCut)[i] = 0xAAAAAAAA;
}
+
+ assert( pCut->pLeaves[0] < p->vObjs->nSize );
}
/**Function*************************************************************
@@ -566,12 +575,12 @@ void If_ManSetupSetAll( If_Man_t * p, int nCrossCut )
if ( p->pPars->fVerbose )
{
- printf( "Node = %7d. Ch = %5d. Total mem = %7.2f Mb. Peak cut mem = %7.2f Mb.\n",
+ Abc_Print( 1, "Node = %7d. Ch = %5d. Total mem = %7.2f Mb. Peak cut mem = %7.2f Mb.\n",
If_ManAndNum(p), p->nChoices,
1.0 * (p->nObjBytes + 2*sizeof(void *)) * If_ManObjNum(p) / (1<<20),
1.0 * p->nSetBytes * nCrossCut / (1<<20) );
}
-// printf( "Cross cut = %d.\n", nCrossCut );
+// Abc_Print( 1, "Cross cut = %d.\n", nCrossCut );
}
@@ -580,3 +589,5 @@ void If_ManSetupSetAll( If_Man_t * p, int nCrossCut )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/if/ifMap.c b/src/map/if/ifMap.c
index ca57868d..66e59d2f 100644
--- a/src/map/if/ifMap.c
+++ b/src/map/if/ifMap.c
@@ -20,6 +20,9 @@
#include "if.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -87,10 +90,13 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep
if ( pCut->nLeaves > 0 )
{
// recompute the parameters of the best cut
- pCut->Delay = If_CutDelay( p, pCut );
+ if ( p->pPars->fDelayOpt )
+ pCut->Delay = If_CutDelaySopCost( p, pCut );
+ else
+ pCut->Delay = If_CutDelay( p, pCut );
// assert( pCut->Delay <= pObj->Required + p->fEpsilon );
if ( pCut->Delay > pObj->Required + 2*p->fEpsilon )
- printf( "If_ObjPerformMappingAnd(): Warning! Delay of node %d (%f) exceeds the required times (%f).\n",
+ Abc_Print( 1, "If_ObjPerformMappingAnd(): Warning! Delay of node %d (%f) exceeds the required times (%f).\n",
pObj->Id, pCut->Delay, pObj->Required + p->fEpsilon );
pCut->Area = (Mode == 2)? If_CutAreaDerefed( p, pCut ) : If_CutAreaFlow( p, pCut );
if ( p->pPars->fEdge )
@@ -106,17 +112,20 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep
If_ObjForEachCut( pObj->pFanin0, pCut0, i )
If_ObjForEachCut( pObj->pFanin1, pCut1, k )
{
- // get the next ABC_FREE cut
+ // get the next free cut
assert( pCutSet->nCuts <= pCutSet->nCutsMax );
pCut = pCutSet->ppCuts[pCutSet->nCuts];
// make sure K-feasible cut exists
if ( If_WordCountOnes(pCut0->uSign | pCut1->uSign) > p->pPars->nLutSize )
continue;
- // merge the nodes
+ // merge the cuts
if ( !If_CutMerge( pCut0, pCut1, pCut ) )
continue;
+ if ( pObj->fSpec && pCut->nLeaves == (unsigned)p->pPars->nLutSize )
+ continue;
assert( p->pPars->fSeqMap || pCut->nLeaves > 1 );
p->nCutsMerged++;
+ p->nCutsTotal++;
// check if this cut is contained in any of the available cuts
// if ( p->pPars->pFuncCost == NULL && If_CutFilter( p, pCut ) ) // do not filter functionality cuts
if ( If_CutFilter( pCutSet, pCut ) )
@@ -128,6 +137,12 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep
// int clk = clock();
If_CutComputeTruth( p, pCut, pCut0, pCut1, pObj->fCompl0, pObj->fCompl1 );
// p->timeTruth += clock() - clk;
+ if ( p->pPars->pFuncCell )
+ {
+ assert( pCut->nLimit >= 4 && pCut->nLimit <= 6 );
+ pCut->fUseless = !p->pPars->pFuncCell( If_CutTruth(pCut), pCut->nLimit, pCut->nLeaves );
+ p->nCutsUseless += pCut->fUseless;
+ }
}
// compute the application-specific cost and depth
pCut->fUser = (p->pPars->pFuncCost != NULL);
@@ -135,8 +150,11 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep
if ( pCut->Cost == IF_COST_MAX )
continue;
// check if the cut satisfies the required times
- pCut->Delay = If_CutDelay( p, pCut );
-// printf( "%.2f ", pCut->Delay );
+ if ( p->pPars->fDelayOpt )
+ pCut->Delay = If_CutDelaySopCost( p, pCut );
+ else
+ pCut->Delay = If_CutDelay( p, pCut );
+// Abc_Print( 1, "%.2f ", pCut->Delay );
if ( Mode && pCut->Delay > pObj->Required + p->fEpsilon )
continue;
// compute area of the cut (this area may depend on the application specific cost)
@@ -163,6 +181,8 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep
// ref the selected cut
if ( Mode && pObj->nRefs > 0 )
If_CutAreaRef( p, If_ObjCutBest(pObj) );
+ if ( If_ObjCutBest(pObj)->fUseless )
+ Abc_Print( 1, "The best cut is useless.\n" );
// call the user specified function for each cut
if ( p->pPars->pFuncUser )
@@ -214,7 +234,7 @@ void If_ObjPerformMappingChoice( If_Man_t * p, If_Obj_t * pObj, int Mode, int fP
If_ObjForEachCut( pTemp, pCutTemp, i )
{
assert( p->pPars->fSeqMap || pCutTemp->nLeaves > 1 );
- // get the next ABC_FREE cut
+ // get the next free cut
assert( pCutSet->nCuts <= pCutSet->nCutsMax );
pCut = pCutSet->ppCuts[pCutSet->nCuts];
// copy the cut into storage
@@ -239,7 +259,7 @@ void If_ObjPerformMappingChoice( If_Man_t * p, If_Obj_t * pObj, int Mode, int fP
// insert the cut into storage
If_CutSort( p, pCutSet, pCut );
}
- }
+ }
assert( pCutSet->nCuts > 0 );
// add the trivial cut to the set
@@ -304,7 +324,7 @@ int If_ManPerformMappingRound( If_Man_t * p, int nCutsUsed, int Mode, int fPrepr
}
else if ( If_ObjIsCi(pObj) )
{
-//printf( "processing CI %d\n", pObj->Id );
+//Abc_Print( 1, "processing CI %d\n", pObj->Id );
arrTime = Tim_ManGetCiArrival( p->pManTim, pObj->IdPio );
If_ObjSetArrTime( pObj, arrTime );
}
@@ -342,10 +362,10 @@ int If_ManPerformMappingRound( If_Man_t * p, int nCutsUsed, int Mode, int fPrepr
if ( p->pPars->fVerbose )
{
char Symb = fPreprocess? 'P' : ((Mode == 0)? 'D' : ((Mode == 1)? 'F' : 'A'));
- printf( "%c: Del = %7.2f. Ar = %9.1f. Edge = %8d. Switch = %7.2f. Cut = %8d. ",
+ Abc_Print( 1, "%c: Del = %7.2f. Ar = %9.1f. Edge = %8d. Switch = %7.2f. Cut = %8d. ",
Symb, p->RequiredGlo, p->AreaGlo, p->nNets, p->dPower, p->nCutsMerged );
- ABC_PRT( "T", clock() - clk );
-// printf( "Max number of cuts = %d. Average number of cuts = %5.2f.\n",
+ Abc_PrintTime( 1, "T", clock() - clk );
+// Abc_Print( 1, "Max number of cuts = %d. Average number of cuts = %5.2f.\n",
// p->nCutsMax, 1.0 * p->nCutsMerged / If_ManAndNum(p) );
}
return 1;
@@ -357,3 +377,5 @@ int If_ManPerformMappingRound( If_Man_t * p, int nCutsUsed, int Mode, int fPrepr
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/if/ifReduce.c b/src/map/if/ifReduce.c
index b3130600..622688e7 100644
--- a/src/map/if/ifReduce.c
+++ b/src/map/if/ifReduce.c
@@ -20,6 +20,9 @@
#include "if.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -55,9 +58,9 @@ void If_ManImproveMapping( If_Man_t * p )
If_ManComputeRequired( p );
if ( p->pPars->fVerbose )
{
- printf( "E: Del = %7.2f. Ar = %9.1f. Edge = %8d. Switch = %7.2f. Cut = %8d. ",
+ Abc_Print( 1, "E: Del = %7.2f. Ar = %9.1f. Edge = %8d. Switch = %7.2f. Cut = %8d. ",
p->RequiredGlo, p->AreaGlo, p->nNets, p->dPower, p->nCutsMerged );
- ABC_PRT( "T", clock() - clk );
+ Abc_PrintTime( 1, "T", clock() - clk );
}
/*
@@ -66,9 +69,9 @@ void If_ManImproveMapping( If_Man_t * p )
If_ManComputeRequired( p, 0 );
if ( p->pPars->fVerbose )
{
- printf( "R: Del = %6.2f. Area = %8.2f. Nets = %6d. Cuts = %8d. Lim = %2d. Ave = %5.2f. ",
+ Abc_Print( 1, "R: Del = %6.2f. Area = %8.2f. Nets = %6d. Cuts = %8d. Lim = %2d. Ave = %5.2f. ",
p->RequiredGlo, p->AreaGlo, p->nNets, p->nCutsMerged, p->nCutsUsed, 1.0 * p->nCutsMerged / If_ManAndNum(p) );
- ABC_PRT( "T", clock() - clk );
+ Abc_PrintTime( 1, "T", clock() - clk );
}
*/
/*
@@ -77,9 +80,9 @@ void If_ManImproveMapping( If_Man_t * p )
If_ManComputeRequired( p, 0 );
if ( p->pPars->fVerbose )
{
- printf( "E: Del = %6.2f. Area = %8.2f. Nets = %6d. Cuts = %8d. Lim = %2d. Ave = %5.2f. ",
+ Abc_Print( 1, "E: Del = %6.2f. Area = %8.2f. Nets = %6d. Cuts = %8d. Lim = %2d. Ave = %5.2f. ",
p->RequiredGlo, p->AreaGlo, p->nNets, p->nCutsMerged, p->nCutsUsed, 1.0 * p->nCutsMerged / If_ManAndNum(p) );
- ABC_PRT( "T", clock() - clk );
+ Abc_PrintTime( 1, "T", clock() - clk );
}
*/
}
@@ -126,7 +129,7 @@ int If_ManImproveCutCost( If_Man_t * p, Vec_Ptr_t * vFront )
{
If_Obj_t * pFanin;
int i, Counter = 0;
- Vec_PtrForEachEntry( vFront, pFanin, i )
+ Vec_PtrForEachEntry( If_Obj_t *, vFront, pFanin, i )
if ( pFanin->nRefs == 0 )
Counter++;
return Counter;
@@ -170,7 +173,7 @@ void If_ManImproveNodeExpand( If_Man_t * p, If_Obj_t * pObj, int nLimit, Vec_Ptr
If_CutAreaRef( p, pCut );
assert( CostBef >= CostAft );
// clean up
- Vec_PtrForEachEntry( vVisited, pFanin, i )
+ Vec_PtrForEachEntry( If_Obj_t *, vVisited, pFanin, i )
pFanin->fMark = 0;
// update the node
If_ManImproveNodeUpdate( p, pObj, vFront );
@@ -261,7 +264,7 @@ void If_ManImproveNodeUpdate( If_Man_t * p, If_Obj_t * pObj, Vec_Ptr_t * vFront
If_CutAreaDeref( p, pCut );
// update the node's cut
pCut->nLeaves = Vec_PtrSize(vFront);
- Vec_PtrForEachEntry( vFront, pFanin, i )
+ Vec_PtrForEachEntry( If_Obj_t *, vFront, pFanin, i )
pCut->pLeaves[i] = pFanin->Id;
If_CutOrder( pCut );
// ref the new cut
@@ -363,7 +366,7 @@ int If_ManImproveNodeFaninCompact0( If_Man_t * p, If_Obj_t * pObj, int nLimit, V
{
If_Obj_t * pFanin;
int i;
- Vec_PtrForEachEntry( vFront, pFanin, i )
+ Vec_PtrForEachEntry( If_Obj_t *, vFront, pFanin, i )
{
if ( If_ObjIsCi(pFanin) )
continue;
@@ -393,7 +396,7 @@ int If_ManImproveNodeFaninCompact1( If_Man_t * p, If_Obj_t * pObj, int nLimit, V
{
If_Obj_t * pFanin;
int i;
- Vec_PtrForEachEntry( vFront, pFanin, i )
+ Vec_PtrForEachEntry( If_Obj_t *, vFront, pFanin, i )
{
if ( If_ObjIsCi(pFanin) )
continue;
@@ -421,7 +424,7 @@ int If_ManImproveNodeFaninCompact2( If_Man_t * p, If_Obj_t * pObj, int nLimit, V
{
If_Obj_t * pFanin;
int i;
- Vec_PtrForEachEntry( vFront, pFanin, i )
+ Vec_PtrForEachEntry( If_Obj_t *, vFront, pFanin, i )
{
if ( If_ObjIsCi(pFanin) )
continue;
@@ -574,3 +577,5 @@ void If_ManImproveReduce( If_Man_t * p, int nLimit )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/if/ifSeq.c b/src/map/if/ifSeq.c
index e4e27e71..8b5808d5 100644
--- a/src/map/if/ifSeq.c
+++ b/src/map/if/ifSeq.c
@@ -20,6 +20,9 @@
#include "if.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -99,7 +102,7 @@ Vec_Ptr_t * If_ManCollectLatches( If_Man_t * p )
If_ManForEachLatchOutput( p, pObj, i )
If_ManCollectLatches_rec( pObj, vLatches );
// clean marks
- Vec_PtrForEachEntry( vLatches, pObj, i )
+ Vec_PtrForEachEntry( If_Obj_t *, vLatches, pObj, i )
pObj->fMark = 0;
assert( Vec_PtrSize(vLatches) == p->pPars->nLatches );
return vLatches;
@@ -127,7 +130,7 @@ int If_ManPerformMappingRoundSeq( If_Man_t * p, int nIter )
if ( nIter == 1 )
{
// if some latches depend on PIs, update their values
- Vec_PtrForEachEntry( p->vLatchOrder, pObj, i )
+ Vec_PtrForEachEntry( If_Obj_t *, p->vLatchOrder, pObj, i )
{
If_ObjSetLValue( pObj, If_ObjLValue(If_ObjFanin0(pObj)) - p->Period );
If_ObjSetArrTime( pObj, If_ObjLValue(pObj) );
@@ -144,7 +147,7 @@ int If_ManPerformMappingRoundSeq( If_Man_t * p, int nIter )
}
// postprocess the mapping
-//printf( "Itereation %d: \n", nIter );
+//Abc_Print( 1, "Itereation %d: \n", nIter );
If_ManForEachNode( p, pObj, i )
{
// update the LValues stored separately
@@ -153,15 +156,15 @@ int If_ManPerformMappingRoundSeq( If_Man_t * p, int nIter )
If_ObjSetLValue( pObj, If_ObjCutBest(pObj)->Delay );
fChange = 1;
}
-//printf( "%d ", (int)If_ObjLValue(pObj) );
+//Abc_Print( 1, "%d ", (int)If_ObjLValue(pObj) );
// reset the visit counters
assert( pObj->nVisits == 0 );
pObj->nVisits = pObj->nVisitsCopy;
}
-//printf( "\n" );
+//Abc_Print( 1, "\n" );
// propagate LValues over the registers
- Vec_PtrForEachEntry( p->vLatchOrder, pObj, i )
+ Vec_PtrForEachEntry( If_Obj_t *, p->vLatchOrder, pObj, i )
{
If_ObjSetLValue( pObj, If_ObjLValue(If_ObjFanin0(pObj)) - p->Period );
If_ObjSetArrTime( pObj, If_ObjLValue(pObj) );
@@ -173,9 +176,9 @@ int If_ManPerformMappingRoundSeq( If_Man_t * p, int nIter )
{
p->RequiredGlo = If_ManDelayMax( p, 1 );
// p->AreaGlo = If_ManScanMapping(p);
- printf( "S%d: Fi = %6.2f. Del = %6.2f. Area = %8.2f. Cuts = %8d. ",
+ Abc_Print( 1, "S%d: Fi = %6.2f. Del = %6.2f. Area = %8.2f. Cuts = %8d. ",
nIter, (float)p->Period, p->RequiredGlo, p->AreaGlo, p->nCutsMerged );
- ABC_PRT( "T", clock() - clk );
+ Abc_PrintTime( 1, "T", clock() - clk );
}
return fChange;
}
@@ -228,7 +231,7 @@ int If_ManBinarySearchPeriod( If_Man_t * p )
break;
}
p->RequiredGlo = If_ManDelayMax( p, 1 );
-//printf( "Global = %d \n", (int)p->RequiredGlo );
+//Abc_Print( 1, "Global = %d \n", (int)p->RequiredGlo );
if ( p->RequiredGlo > p->Period + p->fEpsilon )
break;
}
@@ -238,14 +241,14 @@ int If_ManBinarySearchPeriod( If_Man_t * p )
if ( p->pPars->fVerbose )
{
// p->AreaGlo = If_ManScanMapping(p);
- printf( "Attempt = %2d. Iters = %3d. Area = %10.2f. Fi = %6.2f. ", p->nAttempts, c, p->AreaGlo, (float)p->Period );
+ Abc_Print( 1, "Attempt = %2d. Iters = %3d. Area = %10.2f. Fi = %6.2f. ", p->nAttempts, c, p->AreaGlo, (float)p->Period );
if ( fConverged )
- printf( " Feasible" );
+ Abc_Print( 1, " Feasible" );
else if ( c > p->nMaxIters )
- printf( "Infeasible (timeout)" );
+ Abc_Print( 1, "Infeasible (timeout)" );
else
- printf( "Infeasible" );
- printf( "\n" );
+ Abc_Print( 1, "Infeasible" );
+ Abc_Print( 1, "\n" );
}
return fConverged;
}
@@ -302,12 +305,12 @@ void If_ManPerformMappingSeqPost( If_Man_t * p )
If_ManForEachPo( p, pObj, i )
{
p->pPars->pTimesReq[i] = p->RequiredGlo2;
-// printf( "Out %3d : %2d \n", i, (int)p->pPars->pTimesReq[i] );
+// Abc_Print( 1, "Out %3d : %2d \n", i, (int)p->pPars->pTimesReq[i] );
}
If_ManForEachLatchInput( p, pObjLi, i )
{
p->pPars->pTimesReq[i] = If_ObjLValue(If_ObjFanin0(pObjLi));
-// printf( "Out %3d : %2d \n", i, (int)p->pPars->pTimesReq[i] );
+// Abc_Print( 1, "Out %3d : %2d \n", i, (int)p->pPars->pTimesReq[i] );
}
// undo previous mapping
@@ -359,7 +362,7 @@ int If_ManPerformMappingSeq( If_Man_t * p )
// make sure the clock period works
if ( !If_ManBinarySearchPeriod( p ) )
{
- printf( "If_ManPerformMappingSeq(): The upper bound on the clock period cannot be computed.\n" );
+ Abc_Print( 1, "If_ManPerformMappingSeq(): The upper bound on the clock period cannot be computed.\n" );
return 0;
}
@@ -372,14 +375,14 @@ int If_ManPerformMappingSeq( If_Man_t * p )
p->Period = PeriodBest;
if ( !If_ManBinarySearchPeriod( p ) )
{
- printf( "If_ManPerformMappingSeq(): The final clock period cannot be confirmed.\n" );
+ Abc_Print( 1, "If_ManPerformMappingSeq(): The final clock period cannot be confirmed.\n" );
return 0;
}
}
// if ( p->pPars->fVerbose )
{
- printf( "The best clock period is %3d. ", p->Period );
- ABC_PRT( "Time", clock() - clkTotal );
+ Abc_Print( 1, "The best clock period is %3d. ", p->Period );
+ Abc_PrintTime( 1, "Time", clock() - clkTotal );
}
p->RequiredGlo = (float)(PeriodBest);
@@ -394,3 +397,5 @@ int If_ManPerformMappingSeq( If_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/if/ifTime.c b/src/map/if/ifTime.c
index 20521805..bfe0d969 100644
--- a/src/map/if/ifTime.c
+++ b/src/map/if/ifTime.c
@@ -19,6 +19,10 @@
***********************************************************************/
#include "if.h"
+#include "kit.h"
+
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -32,6 +36,363 @@ static void If_CutSortInputPins( If_Man_t * p, If_Cut_t * pCut, int * pPinPerm,
/**Function*************************************************************
+ Synopsis [Inserts the entry while sorting them by delay.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+word If_AndVerifyArray( Vec_Wrd_t * vAnds, int nVars )
+{
+ Vec_Wrd_t * vTruths;
+ If_And_t This;
+ word Entry, Truth0, Truth1, TruthR;
+ int i;
+ static word Truth[8] = {
+ 0xAAAAAAAAAAAAAAAA,
+ 0xCCCCCCCCCCCCCCCC,
+ 0xF0F0F0F0F0F0F0F0,
+ 0xFF00FF00FF00FF00,
+ 0xFFFF0000FFFF0000,
+ 0xFFFFFFFF00000000,
+ 0x0000000000000000,
+ 0xFFFFFFFFFFFFFFFF
+ };
+ if ( Vec_WrdSize(vAnds) == 0 )
+ return Truth[6];
+ if ( Vec_WrdSize(vAnds) == 1 && Vec_WrdEntry(vAnds,0) == 0 )
+ return Truth[7];
+ vTruths = Vec_WrdAlloc( Vec_WrdSize(vAnds) );
+ for ( i = 0; i < nVars; i++ )
+ Vec_WrdPush( vTruths, Truth[i] );
+ Vec_WrdForEachEntryStart( vAnds, Entry, i, nVars )
+ {
+ This = If_WrdToAnd(Entry);
+ Truth0 = Vec_WrdEntry( vTruths, This.iFan0 );
+ Truth0 = This.fCompl0 ? ~Truth0 : Truth0;
+ Truth1 = Vec_WrdEntry( vTruths, This.iFan1 );
+ Truth1 = This.fCompl1 ? ~Truth1 : Truth1;
+ TruthR = Truth0 & Truth1;
+ Vec_WrdPush( vTruths, TruthR );
+ }
+ Vec_WrdFree( vTruths );
+ TruthR = This.fCompl ? ~TruthR : TruthR;
+ return TruthR;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Inserts the entry while sorting them by delay.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void If_AndInsertSorted( Vec_Wrd_t * vAnds, If_And_t And )
+{
+ If_And_t This, Prev;
+ int i;
+ Vec_WrdPush( vAnds, If_AndToWrd(And) );
+ for ( i = Vec_WrdSize(vAnds) - 1; i > 0; i-- )
+ {
+ This = If_WrdToAnd( Vec_WrdEntry(vAnds, i) );
+ Prev = If_WrdToAnd( Vec_WrdEntry(vAnds, i-1) );
+ if ( This.Delay <= Prev.Delay )
+ break;
+ Vec_WrdWriteEntry( vAnds, i, If_AndToWrd(Prev) );
+ Vec_WrdWriteEntry( vAnds, i-1, If_AndToWrd(This) );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Decomposes the cube into a bunch of AND gates.]
+
+ Description [Records the result of decomposition into vLits. Returns
+ the last AND gate of the decomposition.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+If_And_t If_CutDelaySopCube( Vec_Wrd_t * vCube, Vec_Wrd_t * vAnds, int fOrGate )
+{
+ If_And_t This, Prev, Next;
+ assert( Vec_WrdSize(vCube) > 0 );
+ while ( Vec_WrdSize(vCube) > 1 )
+ {
+ // get last
+ This = If_WrdToAnd( Vec_WrdPop(vCube) );
+ Prev = If_WrdToAnd( Vec_WrdPop(vCube) );
+ // create new
+ If_AndClear( &Next );
+ Next.iFan0 = Prev.Id;
+ Next.fCompl0 = Prev.fCompl ^ fOrGate;
+ Next.iFan1 = This.Id;
+ Next.fCompl1 = This.fCompl ^ fOrGate;
+ Next.Id = Vec_WrdSize(vAnds);
+ Next.fCompl = fOrGate;
+ Next.Delay = 1 + ABC_MAX( This.Delay, Prev.Delay );
+ // add new
+ If_AndInsertSorted( vCube, Next );
+ Vec_WrdPush( vAnds, If_AndToWrd(Next) );
+ }
+ return If_WrdToAnd( Vec_WrdPop(vCube) );
+}
+
+
+
+/**Function*************************************************************
+
+ Synopsis [Returns the well-balanced structure of AIG nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Wrd_t * If_CutDelaySopAnds( If_Man_t * p, If_Cut_t * pCut, Vec_Int_t * vCover, int fCompl )
+{
+ Vec_Wrd_t * vAnds, * vAndGate, * vOrGate;
+ If_Obj_t * pLeaf;
+ If_And_t Leaf;
+ int i, k, Entry, Literal;
+ vAnds = Vec_WrdAlloc( 32 );
+ if ( Vec_IntSize(vCover) == 0 ) // const 0
+ {
+ assert( fCompl == 0 );
+ return vAnds;
+ }
+ if ( Vec_IntSize(vCover) == 1 && Vec_IntEntry(vCover, 0) == 0 ) // const 1
+ {
+ assert( fCompl == 0 );
+ Vec_WrdPush( vAnds, 0 );
+ return vAnds;
+ }
+ If_CutForEachLeaf( p, pCut, pLeaf, k )
+ {
+ If_AndClear( &Leaf );
+ Leaf.Id = k;
+ Leaf.Delay = (int)If_ObjCutBest(pLeaf)->Delay;
+ Vec_WrdPush( vAnds, If_AndToWrd(Leaf) );
+ }
+ // iterate through the cubes
+ vOrGate = Vec_WrdAlloc( 16 );
+ vAndGate = Vec_WrdAlloc( 16 );
+ Vec_IntForEachEntry( vCover, Entry, i )
+ {
+ Vec_WrdClear( vAndGate );
+ If_CutForEachLeaf( p, pCut, pLeaf, k )
+ {
+ Literal = 3 & (Entry >> (k << 1));
+ if ( Literal == 1 ) // neg literal
+ {
+ If_AndClear( &Leaf );
+ Leaf.fCompl = 1;
+ Leaf.Id = k;
+ Leaf.Delay = (int)If_ObjCutBest(pLeaf)->Delay;
+ If_AndInsertSorted( vAndGate, Leaf );
+ }
+ else if ( Literal == 2 ) // pos literal
+ {
+ If_AndClear( &Leaf );
+ Leaf.Id = k;
+ Leaf.Delay = (int)If_ObjCutBest(pLeaf)->Delay;
+ If_AndInsertSorted( vAndGate, Leaf );
+ }
+ else if ( Literal != 0 )
+ assert( 0 );
+ }
+ Leaf = If_CutDelaySopCube( vAndGate, vAnds, 0 );
+ If_AndInsertSorted( vOrGate, Leaf );
+ }
+ Leaf = If_CutDelaySopCube( vOrGate, vAnds, 1 );
+ Vec_WrdFree( vAndGate );
+ Vec_WrdFree( vOrGate );
+ if ( Vec_WrdSize(vAnds) == (int)pCut->nLeaves )
+ {
+// Extra_PrintBinary( stdout, If_CutTruth(pCut), 32 ); printf( "\n" );
+ assert( Leaf.Id < pCut->nLeaves );
+ Leaf.iFan0 = Leaf.iFan1 = Leaf.Id;
+ Leaf.Id = Vec_WrdSize(vAnds);
+ Vec_WrdPush( vAnds, If_AndToWrd(Leaf) );
+ }
+ if ( fCompl )
+ {
+ Leaf = If_WrdToAnd( Vec_WrdPop(vAnds) );
+ Leaf.fCompl ^= 1;
+ Vec_WrdPush( vAnds, If_AndToWrd(Leaf) );
+ }
+ return vAnds;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes balanced AND decomposition.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Vec_Wrd_t * If_CutDelaySopArray( If_Man_t * p, If_Cut_t * pCut )
+{
+ Vec_Int_t * vCover;
+ Vec_Wrd_t * vAnds;
+ int RetValue;
+ vCover = Vec_IntAlloc(0);
+ RetValue = Kit_TruthIsop( If_CutTruth(pCut), If_CutLeaveNum(pCut), vCover, 1 );
+ if ( RetValue == -1 )
+ {
+ Vec_IntFree( vCover );
+ return NULL;
+ }
+ assert( RetValue == 0 || RetValue == 1 );
+ vAnds = If_CutDelaySopAnds( p, pCut, vCover, RetValue ^ pCut->fCompl );
+/*
+ if ( pCut->nLeaves <= 5 )
+ {
+ if ( *If_CutTruth(pCut) != (unsigned)If_AndVerifyArray(vAnds, pCut->nLeaves) )
+ {
+ unsigned Truth0 = *If_CutTruth(pCut);
+ unsigned Truth1 = (unsigned)If_AndVerifyArray(vAnds, pCut->nLeaves);
+
+ printf( "\n" );
+ Extra_PrintBinary( stdout, &Truth0, 32 ); printf( "\n" );
+ Extra_PrintBinary( stdout, &Truth1, 32 ); printf( "\n" );
+
+ printf( "Verification failed for %d vars.\n", pCut->nLeaves );
+ }
+// else
+// printf( "Verification passed for %d vars.\n", pCut->nLeaves );
+ }
+ else if ( pCut->nLeaves == 6 )
+ {
+ if ( *((word *)If_CutTruth(pCut)) != If_AndVerifyArray(vAnds, pCut->nLeaves) )
+ printf( "Verification failed for %d vars.\n", pCut->nLeaves );
+// else
+// printf( "Verification passed for %d vars.\n", pCut->nLeaves );
+ }
+*/
+ Vec_IntFree( vCover );
+ return vAnds;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Derives the maximum depth from the leaf to the root.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int If_CutDelayLeafDepth_rec( Vec_Wrd_t * vAnds, If_And_t And, int iLeaf )
+{
+ int Depth0, Depth1, Depth;
+ if ( (int)And.Id == iLeaf )
+ return 0;
+ if ( And.iFan0 == And.iFan1 )
+ return -100;
+ Depth0 = If_CutDelayLeafDepth_rec( vAnds, If_WrdToAnd(Vec_WrdEntry(vAnds, And.iFan0)), iLeaf );
+ Depth1 = If_CutDelayLeafDepth_rec( vAnds, If_WrdToAnd(Vec_WrdEntry(vAnds, And.iFan1)), iLeaf );
+ Depth = ABC_MAX( Depth0, Depth1 );
+ Depth = (Depth == -100) ? -100 : Depth + 1;
+ return Depth;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Derives the maximum depth from the leaf to the root.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int If_CutDelayLeafDepth( Vec_Wrd_t * vAnds, int iLeaf )
+{
+ If_And_t Leaf;
+ if ( Vec_WrdSize(vAnds) == 0 ) // const 0
+ return -100;
+ if ( Vec_WrdSize(vAnds) == 1 && Vec_WrdEntry(vAnds, 0) == 0 ) // const 1
+ return -100;
+ Leaf = If_WrdToAnd(Vec_WrdEntryLast(vAnds));
+ if ( Leaf.iFan0 == Leaf.iFan1 )
+ {
+ if ( (int)Leaf.iFan0 == iLeaf )
+ return 0;
+ return -100;
+ }
+ return If_CutDelayLeafDepth_rec( vAnds, Leaf, iLeaf );
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Computes the SOP delay using balanced AND decomposition.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int If_CutDelaySopCost( If_Man_t * p, If_Cut_t * pCut )
+{
+ If_And_t Leaf;
+ Vec_Wrd_t * vAnds;
+ int i;//, Delay;
+ // mark cut as a user cut
+ pCut->fUser = 1;
+ vAnds = If_CutDelaySopArray( p, pCut );
+ if ( vAnds == NULL )
+ {
+ assert( 0 );
+ return ABC_INFINITY;
+ }
+ // get the cost
+ If_AndClear( &Leaf );
+ if ( Vec_WrdSize(vAnds) )
+ Leaf = If_WrdToAnd( Vec_WrdEntryLast(vAnds) );
+ if ( pCut->nLeaves > 2 && Vec_WrdSize(vAnds) > (int)pCut->nLeaves )
+ pCut->Cost = Vec_WrdSize(vAnds) - pCut->nLeaves;
+ else
+ pCut->Cost = 1;
+ // get the permutation
+ for ( i = 0; i < (int)pCut->nLeaves; i++ )
+ pCut->pPerm[i] = If_CutDelayLeafDepth( vAnds, i );
+ Vec_WrdFree( vAnds );
+ // verify the delay
+// Delay = If_CutDelay( p, pCut );
+// assert( (int)Leaf.Delay == Delay );
+ return Leaf.Delay;
+}
+
+
+
+
+
+
+/**Function*************************************************************
+
Synopsis [Computes delay.]
Description []
@@ -81,7 +442,7 @@ float If_CutDelay( If_Man_t * p, If_Cut_t * pCut )
assert( !p->pPars->fLiftLeaves );
If_CutForEachLeaf( p, pCut, pLeaf, i )
{
- DelayCur = If_ObjCutBest(pLeaf)->Delay + (float)pCut->pPerm[i];
+ DelayCur = If_ObjCutBest(pLeaf)->Delay + (float)(pCut->pPerm ? pCut->pPerm[i] : 1.0);
Delay = IF_MAX( Delay, DelayCur );
}
}
@@ -99,13 +460,6 @@ float If_CutDelay( If_Man_t * p, If_Cut_t * pCut )
{
If_CutForEachLeaf( p, pCut, pLeaf, i )
{
-/*
- if ( pLeaf->IdPio > 2000 )
- {
- int x = 0;
- printf( "-%d %6.3f ", pLeaf->IdPio, If_ObjCutBest(pLeaf)->Delay );
- }
-*/
DelayCur = If_ObjCutBest(pLeaf)->Delay;
Delay = IF_MAX( Delay, DelayCur );
}
@@ -164,7 +518,7 @@ void If_CutPropagateRequired( If_Man_t * p, If_Cut_t * pCut, float ObjRequired )
{
If_CutForEachLeaf( p, pCut, pLeaf, i )
{
- Required = ObjRequired - (float)pCut->pPerm[i];
+ Required = ObjRequired - (float)(pCut->pPerm ? pCut->pPerm[i] : 1.0);
pLeaf->Required = IF_MIN( pLeaf->Required, Required );
}
}
@@ -252,3 +606,5 @@ void If_CutRotatePins( If_Man_t * p, If_Cut_t * pCut )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/if/ifTruth.c b/src/map/if/ifTruth.c
index 637a42b4..75bc49db 100644
--- a/src/map/if/ifTruth.c
+++ b/src/map/if/ifTruth.c
@@ -20,6 +20,9 @@
#include "if.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -414,6 +417,7 @@ int If_CutTruthMinimize( If_Man_t * p, If_Cut_t * pCut )
// if ( If_CutLeaveNum(pCut) - nSuppSize > 1 )
// return 0;
//printf( "%d %d ", If_CutLeaveNum(pCut), nSuppSize );
+// pCut->fUseless = 1;
// shrink the truth table
If_TruthShrink( p->puTemp[0], If_CutTruth(pCut), nSuppSize, pCut->nLimit, uSupport, 1 );
@@ -440,3 +444,5 @@ int If_CutTruthMinimize( If_Man_t * p, If_Cut_t * pCut )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/if/ifUtil.c b/src/map/if/ifUtil.c
index 1e6d7704..da3a4aa5 100644
--- a/src/map/if/ifUtil.c
+++ b/src/map/if/ifUtil.c
@@ -20,6 +20,9 @@
#include "if.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -103,7 +106,7 @@ float If_ManDelayMax( If_Man_t * p, int fSeq )
int i;
if ( p->pPars->fLatchPaths && p->pPars->nLatches == 0 )
{
- printf( "Delay optimization of latch path is not performed because there is no latches.\n" );
+ Abc_Print( 0, "Delay optimization of latch path is not performed because there is no latches.\n" );
p->pPars->fLatchPaths = 0;
}
DelayBest = -IF_FLOAT_LARGE;
@@ -163,18 +166,25 @@ void If_ManComputeRequired( If_Man_t * p )
if ( If_ObjArrTime(If_ObjFanin0(pObj)) > p->pPars->pTimesReq[i] + p->fEpsilon )
{
Counter++;
- // printf( "Required times are violated for output %d (arr = %d; req = %d).\n",
+ // Abc_Print( 0, "Required times are violated for output %d (arr = %d; req = %d).\n",
// i, (int)If_ObjArrTime(If_ObjFanin0(pObj)), (int)p->pPars->pTimesReq[i] );
}
If_ObjFanin0(pObj)->Required = p->pPars->pTimesReq[i];
}
if ( Counter )
- printf( "Required times are violated for %d outputs.\n", Counter );
+ Abc_Print( 0, "Required times are violated for %d outputs.\n", Counter );
}
else
{
// get the global required times
p->RequiredGlo = If_ManDelayMax( p, 0 );
+/*
+ ////////////////////////////////////////
+ // redefine the delay target (positive number means percentage)
+ if ( p->pPars->DelayTarget > 0 )
+ p->pPars->DelayTarget = p->RequiredGlo * (100.0 + p->pPars->DelayTarget) / 100.0;
+ ////////////////////////////////////////
+*/
// update the required times according to the target
if ( p->pPars->DelayTarget != -1 )
{
@@ -183,7 +193,7 @@ void If_ManComputeRequired( If_Man_t * p )
if ( p->fNextRound == 0 )
{
p->fNextRound = 1;
- printf( "Cannot meet the target required times (%4.2f). Mapping continues anyway.\n", p->pPars->DelayTarget );
+ Abc_Print( 0, "Cannot meet the target required times (%4.2f). Mapping continues anyway.\n", p->pPars->DelayTarget );
}
}
else if ( p->RequiredGlo < p->pPars->DelayTarget - p->fEpsilon )
@@ -191,7 +201,7 @@ void If_ManComputeRequired( If_Man_t * p )
if ( p->fNextRound == 0 )
{
p->fNextRound = 1;
- printf( "Relaxing the required times from (%4.2f) to the target (%4.2f).\n", p->RequiredGlo, p->pPars->DelayTarget );
+// Abc_Print( 0, "Relaxing the required times from (%4.2f) to the target (%4.2f).\n", p->RequiredGlo, p->pPars->DelayTarget );
}
p->RequiredGlo = p->pPars->DelayTarget;
}
@@ -212,7 +222,7 @@ void If_ManComputeRequired( If_Man_t * p )
}
}
// go through the nodes in the reverse topological order
- // Vec_PtrForEachEntry( p->vMapped, pObj, i )
+ // Vec_PtrForEachEntry( If_Obj_t *, p->vMapped, pObj, i )
// If_CutPropagateRequired( p, If_ObjCutBest(pObj), pObj->Required );
If_ManForEachObjReverse( p, pObj, i )
{
@@ -225,12 +235,49 @@ void If_ManComputeRequired( If_Man_t * p )
{
// get the global required times
p->RequiredGlo = If_ManDelayMax( p, 0 );
+ // update the required times according to the target
+ if ( p->pPars->DelayTarget != -1 )
+ {
+ if ( p->RequiredGlo > p->pPars->DelayTarget + p->fEpsilon )
+ {
+ if ( p->fNextRound == 0 )
+ {
+ p->fNextRound = 1;
+ Abc_Print( 0, "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 ( p->fNextRound == 0 )
+ {
+ p->fNextRound = 1;
+// Abc_Print( 0, "Relaxing the required times from (%4.2f) to the target (%4.2f).\n", p->RequiredGlo, p->pPars->DelayTarget );
+ }
+ p->RequiredGlo = p->pPars->DelayTarget;
+ }
+ }
// do not propagate required times if area minimization is requested
if ( p->pPars->fAreaOnly )
return;
// set the required times for the POs
Tim_ManIncrementTravId( p->pManTim );
- if ( p->pPars->fLatchPaths )
+ if ( p->vCoAttrs )
+ {
+ assert( If_ManCoNum(p) == Vec_IntSize(p->vCoAttrs) );
+ If_ManForEachCo( p, pObj, i )
+ {
+ if ( Vec_IntEntry(p->vCoAttrs, i) == -1 ) // -1=internal
+ continue;
+ if ( Vec_IntEntry(p->vCoAttrs, i) == 0 ) // 0=optimize
+ Tim_ManSetCoRequired( p->pManTim, i, p->RequiredGlo );
+ else if ( Vec_IntEntry(p->vCoAttrs, i) == 1 ) // 1=keep
+ Tim_ManSetCoRequired( p->pManTim, i, If_ObjArrTime(If_ObjFanin0(pObj)) );
+ else if ( Vec_IntEntry(p->vCoAttrs, i) == 2 ) // 2=relax
+ Tim_ManSetCoRequired( p->pManTim, i, IF_FLOAT_LARGE );
+ else assert( 0 );
+ }
+ }
+ else if ( p->pPars->fLatchPaths )
{
assert( 0 );
If_ManForEachPo( p, pObj, i )
@@ -529,7 +576,7 @@ int If_ManCrossCut( If_Man_t * p )
pObj->nVisits = pObj->nVisitsCopy;
}
assert( nCutSize == 0 );
-// printf( "Max cross cut size = %6d.\n", nCutSizeMax );
+// Abc_Print( 1, "Max cross cut size = %6d.\n", nCutSizeMax );
return nCutSizeMax;
}
@@ -561,12 +608,12 @@ Vec_Ptr_t * If_ManReverseOrder( If_Man_t * p )
}
vOrder = Vec_PtrAlloc( If_ManObjNum(p) );
for ( i = p->nLevelMax; i >= 0; i-- )
- for ( pObj = ppStore[i]; pObj; pObj = pObj->pCopy )
+ for ( pObj = ppStore[i]; pObj; pObj = (If_Obj_t *)pObj->pCopy )
Vec_PtrPush( vOrder, pObj );
ABC_FREE( ppStore );
// print the order
-// Vec_PtrForEachEntry( vOrder, pObj, i )
-// printf( "Obj %2d Type %d Level = %d\n", pObj->Id, pObj->Type, pObj->Level );
+// Vec_PtrForEachEntry( If_Obj_t *, vOrder, pObj, i )
+// Abc_Print( 1, "Obj %2d Type %d Level = %d\n", pObj->Id, pObj->Type, pObj->Level );
return vOrder;
}
@@ -727,3 +774,5 @@ int If_ManCountSpecialPos( If_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/if/if_.c b/src/map/if/if_.c
index d2960077..cc7a2162 100644
--- a/src/map/if/if_.c
+++ b/src/map/if/if_.c
@@ -20,6 +20,9 @@
#include "if.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -45,3 +48,5 @@
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/mapper/mapper.c b/src/map/mapper/mapper.c
index 37052100..f13a7641 100644
--- a/src/map/mapper/mapper.c
+++ b/src/map/mapper/mapper.c
@@ -21,6 +21,9 @@
#include "mio.h"
#include "mapperInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -58,10 +61,10 @@ void Map_Init( Abc_Frame_t * pAbc )
SeeAlso []
***********************************************************************/
-void Map_End()
+void Map_End( Abc_Frame_t * pAbc )
{
// Map_SuperLibFree( s_pSuperLib );
- Map_SuperLibFree( Abc_FrameReadLibSuper() );
+ Map_SuperLibFree( (Map_SuperLib_t *)Abc_FrameReadLibSuper() );
}
@@ -149,13 +152,13 @@ int Map_CommandReadLibrary( Abc_Frame_t * pAbc, int argc, char **argv )
// replace the current library
// Map_SuperLibFree( s_pSuperLib );
// s_pSuperLib = pLib;
- Map_SuperLibFree( Abc_FrameReadLibSuper() );
+ Map_SuperLibFree( (Map_SuperLib_t *)Abc_FrameReadLibSuper() );
Abc_FrameSetLibSuper( pLib );
// replace the current genlib library
// if ( s_pLib ) Mio_LibraryDelete( s_pLib );
// s_pLib = s_pSuperLib->pGenlib;
- Mio_LibraryDelete( Abc_FrameReadLibGen() );
- Abc_FrameSetLibGen( pLib->pGenlib );
+ Mio_LibraryDelete( (Mio_Library_t *)Abc_FrameReadLibGen() );
+ Abc_FrameSetLibGen( (Mio_Library_t *)pLib->pGenlib );
return 0;
usage:
@@ -174,3 +177,5 @@ usage:
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/mapper/mapper.h b/src/map/mapper/mapper.h
index ac31feac..aaad08ee 100644
--- a/src/map/mapper/mapper.h
+++ b/src/map/mapper/mapper.h
@@ -19,6 +19,7 @@
#ifndef __MAPPER_H__
#define __MAPPER_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -27,9 +28,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// STRUCTURE DEFINITIONS ///
@@ -84,7 +86,7 @@ extern Map_Node_t ** Map_ManReadOutputs( Map_Man_t * p );
extern Map_Node_t * Map_ManReadConst1 ( Map_Man_t * p );
extern Map_Time_t * Map_ManReadInputArrivals( Map_Man_t * p );
extern Mio_Library_t * Map_ManReadGenLib ( Map_Man_t * p );
-extern bool Map_ManReadVerbose( Map_Man_t * p );
+extern int Map_ManReadVerbose( Map_Man_t * p );
extern float Map_ManReadAreaFinal( Map_Man_t * p );
extern float Map_ManReadRequiredGlo( Map_Man_t * p );
extern void Map_ManSetTimeToMap( Map_Man_t * p, int Time );
@@ -95,7 +97,7 @@ extern void Map_ManSetOutputNames( Map_Man_t * p, char ** ppNames );
extern void Map_ManSetAreaRecovery( Map_Man_t * p, int fAreaRecovery );
extern void Map_ManSetDelayTarget( Map_Man_t * p, float DelayTarget );
extern void Map_ManSetInputArrivals( Map_Man_t * p, Map_Time_t * pArrivals );
-extern void Map_ManSetObeyFanoutLimits( Map_Man_t * p, bool fObeyFanoutLimits );
+extern void Map_ManSetObeyFanoutLimits( Map_Man_t * p, int fObeyFanoutLimits );
extern void Map_ManSetNumIterations( Map_Man_t * p, int nNumIterations );
extern int Map_ManReadPass( Map_Man_t * p );
extern void Map_ManSetPass( Map_Man_t * p, int nPass );
@@ -167,6 +169,7 @@ extern void Map_CutCreateFromNode( Map_Man_t * p, Map_Super_t * pSupe
extern int Map_Mapping( Map_Man_t * p );
/*=== mapperLib.c =============================================================*/
extern int Map_SuperLibDeriveFromGenlib( Mio_Library_t * pLib );
+extern void Map_SuperLibFree( Map_SuperLib_t * p );
/*=== mapperMntk.c =============================================================*/
//extern Mntk_Man_t * Map_ConvertMappingToMntk( Map_Man_t * pMan );
/*=== mapperSuper.c =============================================================*/
@@ -183,9 +186,11 @@ extern void Map_ManCleanData( Map_Man_t * p );
extern void Map_MappingSetupTruthTables( unsigned uTruths[][2] );
extern void Map_MappingSetupTruthTablesLarge( unsigned uTruths[][32] );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/map/mapper/mapperCanon.c b/src/map/mapper/mapperCanon.c
index 4f93ad3b..e9445a4f 100644
--- a/src/map/mapper/mapperCanon.c
+++ b/src/map/mapper/mapperCanon.c
@@ -18,6 +18,9 @@
#include "mapperInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -270,3 +273,5 @@ int Map_CanonComputeFast( Map_Man_t * p, int nVarsMax, int nVarsReal, unsigned u
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/mapper/mapperCore.c b/src/map/mapper/mapperCore.c
index fc0d9609..85530a1e 100644
--- a/src/map/mapper/mapperCore.c
+++ b/src/map/mapper/mapperCore.c
@@ -19,6 +19,9 @@
#include "mapperInt.h"
//#include "resm.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -226,3 +229,5 @@ ABC_PRT( "Time", clock() - clk );
Map_MappingPrintOutputArrivals( p );
return 1;
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/mapper/mapperCreate.c b/src/map/mapper/mapperCreate.c
index ee2b089c..af1a858f 100644
--- a/src/map/mapper/mapperCreate.c
+++ b/src/map/mapper/mapperCreate.c
@@ -18,6 +18,9 @@
#include "mapperInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -51,7 +54,7 @@ Map_Node_t ** Map_ManReadOutputs( Map_Man_t * p ) { return
Map_Node_t * Map_ManReadConst1 ( Map_Man_t * p ) { return p->pConst1; }
Map_Time_t * Map_ManReadInputArrivals( Map_Man_t * p ) { return p->pInputArrivals;}
Mio_Library_t * Map_ManReadGenLib ( Map_Man_t * p ) { return p->pSuperLib->pGenlib; }
-bool Map_ManReadVerbose( Map_Man_t * p ) { return p->fVerbose; }
+int Map_ManReadVerbose( Map_Man_t * p ) { return p->fVerbose; }
float Map_ManReadAreaFinal( Map_Man_t * p ) { return p->AreaFinal; }
float Map_ManReadRequiredGlo( Map_Man_t * p ) { return p->fRequiredGlo; }
void Map_ManSetTimeToMap( Map_Man_t * p, int Time ) { p->timeToMap = Time; }
@@ -62,7 +65,7 @@ void Map_ManSetOutputNames( Map_Man_t * p, char ** ppNames ) { p->ppO
void Map_ManSetAreaRecovery( Map_Man_t * p, int fAreaRecovery ) { p->fAreaRecovery = fAreaRecovery;}
void Map_ManSetDelayTarget( Map_Man_t * p, float DelayTarget ) { p->DelayTarget = DelayTarget;}
void Map_ManSetInputArrivals( Map_Man_t * p, Map_Time_t * pArrivals ) { p->pInputArrivals = pArrivals;}
-void Map_ManSetObeyFanoutLimits( Map_Man_t * p, bool fObeyFanoutLimits ) { p->fObeyFanoutLimits = fObeyFanoutLimits; }
+void Map_ManSetObeyFanoutLimits( Map_Man_t * p, int fObeyFanoutLimits ) { p->fObeyFanoutLimits = fObeyFanoutLimits; }
void Map_ManSetNumIterations( Map_Man_t * p, int nIterations ) { p->nIterations = nIterations; }
int Map_ManReadFanoutViolations( Map_Man_t * p ) { return p->nFanoutViolations; }
void Map_ManSetFanoutViolations( Map_Man_t * p, int nVio ) { p->nFanoutViolations = nVio; }
@@ -192,7 +195,7 @@ Map_Man_t * Map_ManCreate( int nInputs, int nOutputs, int fVerbose )
// start the manager
p = ABC_ALLOC( Map_Man_t, 1 );
memset( p, 0, sizeof(Map_Man_t) );
- p->pSuperLib = Abc_FrameReadLibSuper();
+ p->pSuperLib = (Map_SuperLib_t *)Abc_FrameReadLibSuper();
p->nVarsMax = p->pSuperLib->nVarsMax;
p->fVerbose = fVerbose;
p->fEpsilon = (float)0.001;
@@ -598,3 +601,5 @@ void Map_NodeSetChoice( Map_Man_t * pMan, Map_Node_t * pNodeOld, Map_Node_t * pN
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/mapper/mapperCut.c b/src/map/mapper/mapperCut.c
index 19878d5b..e0afa792 100644
--- a/src/map/mapper/mapperCut.c
+++ b/src/map/mapper/mapperCut.c
@@ -18,6 +18,9 @@
#include "mapperInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -1166,3 +1169,5 @@ unsigned Map_CutComputeTruth( Map_Man_t * p, Map_Cut_t * pCut, Map_Cut_t * pTemp
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/mapper/mapperCutUtils.c b/src/map/mapper/mapperCutUtils.c
index 42bdd103..aa307368 100644
--- a/src/map/mapper/mapperCutUtils.c
+++ b/src/map/mapper/mapperCutUtils.c
@@ -18,6 +18,9 @@
#include "mapperInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -272,3 +275,5 @@ void Map_CutInsertFanouts( Map_Node_t * pNode, Map_Cut_t * pCut, int fPhase )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/mapper/mapperFanout.c b/src/map/mapper/mapperFanout.c
index 63cdbd2a..f835abe4 100644
--- a/src/map/mapper/mapperFanout.c
+++ b/src/map/mapper/mapperFanout.c
@@ -18,6 +18,9 @@
#include "mapperInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
#ifdef MAP_ALLOCATE_FANOUT
////////////////////////////////////////////////////////////////////////
@@ -139,3 +142,5 @@ int Map_NodeGetFanoutNum( Map_Node_t * pNode )
#endif
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/mapper/mapperGENERIC.c b/src/map/mapper/mapperGENERIC.c
index 823eb4f2..ff71d3e1 100644
--- a/src/map/mapper/mapperGENERIC.c
+++ b/src/map/mapper/mapperGENERIC.c
@@ -18,6 +18,9 @@
#include "mapperInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -44,3 +47,5 @@
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/mapper/mapperInt.h b/src/map/mapper/mapperInt.h
index 7f4c93dc..ac8110fc 100644
--- a/src/map/mapper/mapperInt.h
+++ b/src/map/mapper/mapperInt.h
@@ -19,6 +19,7 @@
#ifndef __MAPPER_INT_H__
#define __MAPPER_INT_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -27,10 +28,13 @@
#include <stdlib.h>
#include <string.h>
#include <float.h>
-#include "cuddInt.h"
#include "main.h"
#include "mio.h"
#include "mapper.h"
+#include "cuddInt.h"
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
@@ -113,10 +117,10 @@ struct Map_ManStruct_t_
float AreaBase; // the area after delay-oriented mapping
float AreaFinal; // the area after delay-oriented mapping
int nIterations; // How many matching passes to do
- bool fObeyFanoutLimits;// Should mapper try to obey fanout limits or not
+ int fObeyFanoutLimits;// Should mapper try to obey fanout limits or not
float DelayTarget; // the required times set by the user
int nTravIds; // the traversal counter
- bool fSwitching; // Should mapper try to obey fanout limits or not
+ int fSwitching; // Should mapper try to obey fanout limits or not
// the supergate library
Map_SuperLib_t * pSuperLib; // the current supergate library
@@ -169,7 +173,7 @@ struct Map_SuperLibStruct_t_
int nSupersAll; // the total number of supergates
int nSupersReal; // the total number of supergates
int nLines; // the total number of lines in the supergate file
- bool fVerbose; // the verbosity flag
+ int fVerbose; // the verbosity flag
// hash tables
Map_Super_t ** ppSupers; // the array of supergates
@@ -373,7 +377,7 @@ extern void Map_NodeAddFaninFanout( Map_Node_t * pFanin, Map_Node_t
extern void Map_NodeRemoveFaninFanout( Map_Node_t * pFanin, Map_Node_t * pFanoutToRemove );
extern int Map_NodeGetFanoutNum( Map_Node_t * pNode );
/*=== mapperLib.c ============================================================*/
-extern Map_SuperLib_t * Map_SuperLibCreate( char * pFileName, char * pExcludeFile, bool fAlgorithm, bool fVerbose );
+extern Map_SuperLib_t * Map_SuperLibCreate( char * pFileName, char * pExcludeFile, int fAlgorithm, int fVerbose );
extern void Map_SuperLibFree( Map_SuperLib_t * p );
/*=== mapperMatch.c ===============================================================*/
extern int Map_MappingMatches( Map_Man_t * p );
@@ -469,6 +473,10 @@ extern void Map_NodeVecWriteEntry( Map_NodeVec_t * p, int i, Map_No
extern Map_Node_t * Map_NodeVecReadEntry( Map_NodeVec_t * p, int i );
extern void Map_NodeVecSortByLevel( Map_NodeVec_t * p );
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif
////////////////////////////////////////////////////////////////////////
diff --git a/src/map/mapper/mapperLib.c b/src/map/mapper/mapperLib.c
index cc64d8b8..9cc8747d 100644
--- a/src/map/mapper/mapperLib.c
+++ b/src/map/mapper/mapperLib.c
@@ -23,6 +23,9 @@
#include "mapperInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -50,7 +53,7 @@
SeeAlso []
***********************************************************************/
-Map_SuperLib_t * Map_SuperLibCreate( char * pFileName, char * pExcludeFile, bool fAlgorithm, bool fVerbose )
+Map_SuperLib_t * Map_SuperLibCreate( char * pFileName, char * pExcludeFile, int fAlgorithm, int fVerbose )
{
Map_SuperLib_t * p;
int clk;
@@ -251,3 +254,5 @@ int Map_SuperLibDeriveFromGenlib( Mio_Library_t * pLib )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/mapper/mapperMatch.c b/src/map/mapper/mapperMatch.c
index 32af030a..5fce3dc0 100644
--- a/src/map/mapper/mapperMatch.c
+++ b/src/map/mapper/mapperMatch.c
@@ -18,6 +18,9 @@
#include "mapperInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*
A potential improvement:
When an internal node is not used in the mapping, its required times
@@ -595,3 +598,5 @@ void Map_NodeTransferArrivalTimes( Map_Man_t * p, Map_Node_t * pNode )
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/mapper/mapperRefs.c b/src/map/mapper/mapperRefs.c
index 852e759f..9b0be068 100644
--- a/src/map/mapper/mapperRefs.c
+++ b/src/map/mapper/mapperRefs.c
@@ -18,6 +18,9 @@
#include "mapperInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -555,3 +558,5 @@ float Map_MappingGetArea( Map_Man_t * pMan, Map_NodeVec_t * vMapping )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/mapper/mapperSuper.c b/src/map/mapper/mapperSuper.c
index 92f73ecb..3be70541 100644
--- a/src/map/mapper/mapperSuper.c
+++ b/src/map/mapper/mapperSuper.c
@@ -18,6 +18,9 @@
#include "mapperInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -448,3 +451,5 @@ void Map_LibraryPrintClasses( Map_SuperLib_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/mapper/mapperSwitch.c b/src/map/mapper/mapperSwitch.c
index 9dd6e42b..11e99d24 100644
--- a/src/map/mapper/mapperSwitch.c
+++ b/src/map/mapper/mapperSwitch.c
@@ -18,6 +18,9 @@
#include "mapperInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -221,3 +224,5 @@ float Map_MappingGetSwitching( Map_Man_t * pMan, Map_NodeVec_t * vMapping )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/mapper/mapperTable.c b/src/map/mapper/mapperTable.c
index a0805991..2120b5ce 100644
--- a/src/map/mapper/mapperTable.c
+++ b/src/map/mapper/mapperTable.c
@@ -18,6 +18,9 @@
#include "mapperInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -400,3 +403,5 @@ void Map_SuperTableSortSupergatesByDelay( Map_HashTable_t * p, int nSupersMax )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/mapper/mapperTime.c b/src/map/mapper/mapperTime.c
index 309863fd..d12b607a 100644
--- a/src/map/mapper/mapperTime.c
+++ b/src/map/mapper/mapperTime.c
@@ -18,6 +18,9 @@
#include "mapperInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -96,7 +99,7 @@ float Map_TimeCutComputeArrival( Map_Node_t * pNode, Map_Cut_t * pCut, int fPhas
unsigned uPhaseTot = pM->uPhaseBest;
Map_Time_t * ptArrRes = &pM->tArrive;
Map_Time_t * ptArrIn;
- bool fPinPhase;
+ int fPinPhase;
float tDelay;
int i;
@@ -508,3 +511,5 @@ float Map_MatchComputeReqTimes( Map_Cut_t * pCut, int fPhase, Map_Time_t * ptArr
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/mapper/mapperTree.c b/src/map/mapper/mapperTree.c
index 4cabf86c..f6a0d2d3 100644
--- a/src/map/mapper/mapperTree.c
+++ b/src/map/mapper/mapperTree.c
@@ -22,6 +22,9 @@
#include "mapperInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -560,7 +563,7 @@ void Map_LibraryAddFaninDelays( Map_SuperLib_t * pLib, Map_Super_t * pGate, Map_
{
Mio_PinPhase_t PinPhase;
float tDelayBlockRise, tDelayBlockFall, tDelayPin;
- bool fMaxDelay = 0;
+ int fMaxDelay = 0;
int i;
// use this node to enable max-delay model
@@ -823,3 +826,5 @@ void Map_LibraryPrintTree( Map_SuperLib_t * pLib )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/mapper/mapperTree_old.c b/src/map/mapper/mapperTree_old.c
index 041ba2a0..d0acff12 100644
--- a/src/map/mapper/mapperTree_old.c
+++ b/src/map/mapper/mapperTree_old.c
@@ -22,6 +22,9 @@
#include "mapperInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -558,7 +561,7 @@ void Map_LibraryAddFaninDelays( Map_SuperLib_t * pLib, Map_Super_t * pGate, Map_
{
Mio_PinPhase_t PinPhase;
float tDelayBlockRise, tDelayBlockFall, tDelayPin;
- bool fMaxDelay = 0;
+ int fMaxDelay = 0;
int i;
// use this node to enable max-delay model
@@ -821,3 +824,5 @@ void Map_LibraryPrintTree( Map_SuperLib_t * pLib )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/mapper/mapperTruth.c b/src/map/mapper/mapperTruth.c
index dcc8c1d3..377df9b4 100644
--- a/src/map/mapper/mapperTruth.c
+++ b/src/map/mapper/mapperTruth.c
@@ -18,6 +18,9 @@
#include "mapperInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -308,3 +311,5 @@ void Map_CutsCollect_rec( Map_Cut_t * pCut, Map_NodeVec_t * vVisited )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/mapper/mapperUtils.c b/src/map/mapper/mapperUtils.c
index b1f425a3..26033fdb 100644
--- a/src/map/mapper/mapperUtils.c
+++ b/src/map/mapper/mapperUtils.c
@@ -18,6 +18,9 @@
#include "mapperInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -1151,3 +1154,5 @@ int Map_MappingCountUsedNodes( Map_Man_t * pMan, int fChoices )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/mapper/mapperVec.c b/src/map/mapper/mapperVec.c
index f675e0c5..dd87e752 100644
--- a/src/map/mapper/mapperVec.c
+++ b/src/map/mapper/mapperVec.c
@@ -18,6 +18,9 @@
#include "mapperInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -316,3 +319,5 @@ int Map_NodeVecCompareLevels( Map_Node_t ** pp1, Map_Node_t ** pp2 )
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/mio/mio.c b/src/map/mio/mio.c
index b7dd2895..2121b7b9 100644
--- a/src/map/mio/mio.c
+++ b/src/map/mio/mio.c
@@ -29,9 +29,8 @@
#include "mapper.h"
#include "amap.h"
-extern void Amap_LibFree( void * p );
-extern void Amap_LibPrintSelectedGates( void * p, int fAllGates );
-extern void * Amap_LibReadAndPrepare( char * pFileName, int fVerbose, int fVeryVerbose );
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -87,6 +86,7 @@ static char * pMcncGenlib[25] = {
***********************************************************************/
void Mio_Init( Abc_Frame_t * pAbc )
{
+/*
char * pFileTemp = "mcnc_temp.genlib";
void * pLibGen;
FILE * pFile;
@@ -108,6 +108,7 @@ void Mio_Init( Abc_Frame_t * pAbc )
#else
unlink( pFileTemp );
#endif
+*/
Cmd_CommandAdd( pAbc, "SC mapping", "read_liberty", Mio_CommandReadLiberty, 0 );
@@ -129,11 +130,11 @@ void Mio_Init( Abc_Frame_t * pAbc )
SeeAlso []
***********************************************************************/
-void Mio_End()
+void Mio_End( Abc_Frame_t * pAbc )
{
// Mio_LibraryDelete( s_pLib );
- Mio_LibraryDelete( Abc_FrameReadLibGen() );
- Amap_LibFree( Abc_FrameReadLibGen2() );
+ Mio_LibraryDelete( (Mio_Library_t *)Abc_FrameReadLibGen() );
+ Amap_LibFree( (Amap_Lib_t *)Abc_FrameReadLibGen2() );
}
@@ -284,24 +285,23 @@ int Mio_CommandReadLibrary( Abc_Frame_t * pAbc, int argc, char **argv )
// free the current superlib because it depends on the old Mio library
if ( Abc_FrameReadLibSuper() )
{
- extern void Map_SuperLibFree( Map_SuperLib_t * p );
- Map_SuperLibFree( Abc_FrameReadLibSuper() );
+ Map_SuperLibFree( (Map_SuperLib_t *)Abc_FrameReadLibSuper() );
Abc_FrameSetLibSuper( NULL );
}
// replace the current library
- Mio_LibraryDelete( Abc_FrameReadLibGen() );
+ Mio_LibraryDelete( (Mio_Library_t *)Abc_FrameReadLibGen() );
Abc_FrameSetLibGen( pLib );
// set the new network
- pLib = Amap_LibReadAndPrepare( FileName, 1, 0 );
+ pLib = (Mio_Library_t *)Amap_LibReadAndPrepare( FileName, 1, 0 );
if ( pLib == NULL )
{
fprintf( pErr, "Reading GENLIB library has failed.\n" );
return 1;
}
// replace the current library
- Amap_LibFree( Abc_FrameReadLibGen2() );
+ Amap_LibFree( (Amap_Lib_t *)Abc_FrameReadLibGen2() );
Abc_FrameSetLibGen2( pLib );
return 0;
@@ -383,7 +383,7 @@ int Mio_CommandReadLibrary2( Abc_Frame_t * pAbc, int argc, char **argv )
fclose( pFile );
// set the new network
- pLib = Amap_LibReadAndPrepare( FileName, fVerbose, fVeryVerbose );
+ pLib = (Mio_Library_t *)Amap_LibReadAndPrepare( FileName, fVerbose, fVeryVerbose );
if ( pLib == NULL )
{
fprintf( pErr, "Reading GENLIB library has failed.\n" );
@@ -391,7 +391,7 @@ int Mio_CommandReadLibrary2( Abc_Frame_t * pAbc, int argc, char **argv )
}
// replace the current library
- Amap_LibFree( Abc_FrameReadLibGen2() );
+ Amap_LibFree( (Amap_Lib_t *)Abc_FrameReadLibGen2() );
Abc_FrameSetLibGen2( pLib );
return 0;
@@ -455,7 +455,7 @@ int Mio_CommandPrintLibrary( Abc_Frame_t * pAbc, int argc, char **argv )
}
// set the new network
- Mio_WriteLibrary( stdout, Abc_FrameReadLibGen(), 0 );
+ Mio_WriteLibrary( stdout, (Mio_Library_t *)Abc_FrameReadLibGen(), 0 );
return 0;
usage:
@@ -519,7 +519,7 @@ int Mio_CommandPrintLibrary2( Abc_Frame_t * pAbc, int argc, char **argv )
}
// set the new network
- Amap_LibPrintSelectedGates( Abc_FrameReadLibGen2(), fPrintAll );
+ Amap_LibPrintSelectedGates( (Amap_Lib_t *)Abc_FrameReadLibGen2(), fPrintAll );
return 0;
usage:
@@ -536,3 +536,5 @@ usage:
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/mio/mio.h b/src/map/mio/mio.h
index 66fea292..0e993520 100644
--- a/src/map/mio/mio.h
+++ b/src/map/mio/mio.h
@@ -19,6 +19,7 @@
#ifndef __MIO_H__
#define __MIO_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -27,9 +28,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// STRUCTURE DEFINITIONS ///
@@ -134,16 +136,18 @@ extern void Mio_GateDelete( Mio_Gate_t * pGate );
extern void Mio_PinDelete( Mio_Pin_t * pPin );
extern Mio_Pin_t * Mio_PinDup( Mio_Pin_t * pPin );
extern void Mio_WriteLibrary( FILE * pFile, Mio_Library_t * pLib, int fPrintSops );
-extern Mio_Gate_t ** Mio_CollectRoots( Mio_Library_t * pLib, int nInputs, float tDelay, bool fSkipInv, int * pnGates );
+extern Mio_Gate_t ** Mio_CollectRoots( Mio_Library_t * pLib, int nInputs, float tDelay, int fSkipInv, int * pnGates );
extern void Mio_DeriveTruthTable( Mio_Gate_t * pGate, unsigned uTruthsIn[][2], int nSigns, int nInputs, unsigned uTruthRes[] );
extern void Mio_DeriveGateDelays( Mio_Gate_t * pGate,
float ** ptPinDelays, int nPins, int nInputs, float tDelayZero,
float * ptDelaysRes, float * ptPinDelayMax );
extern Mio_Gate_t * Mio_GateCreatePseudo( int nInputs );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/map/mio/mioApi.c b/src/map/mio/mioApi.c
index 61cc2509..9b267c30 100644
--- a/src/map/mio/mioApi.c
+++ b/src/map/mio/mioApi.c
@@ -18,6 +18,9 @@
#include "mioInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -173,3 +176,5 @@ Mio_Pin_t * Mio_PinReadNext ( Mio_Pin_t * pPin ) { return p
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/mio/mioFunc.c b/src/map/mio/mioFunc.c
index 05fe245d..f6f327e3 100644
--- a/src/map/mio/mioFunc.c
+++ b/src/map/mio/mioFunc.c
@@ -19,6 +19,9 @@
#include "mioInt.h"
#include "parse.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -110,13 +113,13 @@ int Mio_GateParseFormula( Mio_Gate_t * pGate )
if ( strcmp( pGate->pForm, MIO_STRING_CONST0 ) == 0 )
{
pGate->bFunc = b0;
- pGate->pSop = Abc_SopRegister( pGate->pLib->pMmFlex, " 0\n" );
+ pGate->pSop = Abc_SopRegister( (Extra_MmFlex_t *)pGate->pLib->pMmFlex, " 0\n" );
pGate->pLib->pGate0 = pGate;
}
else if ( strcmp( pGate->pForm, MIO_STRING_CONST1 ) == 0 )
{
pGate->bFunc = b1;
- pGate->pSop = Abc_SopRegister( pGate->pLib->pMmFlex, " 1\n" );
+ pGate->pSop = Abc_SopRegister( (Extra_MmFlex_t *)pGate->pLib->pMmFlex, " 1\n" );
pGate->pLib->pGate1 = pGate;
}
else
@@ -271,3 +274,5 @@ int Mio_GateCollectNames( char * pFormula, char * pPinNames[] )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/mio/mioInt.h b/src/map/mio/mioInt.h
index 654b7e19..35a583b6 100644
--- a/src/map/mio/mioInt.h
+++ b/src/map/mio/mioInt.h
@@ -19,6 +19,7 @@
#ifndef __MIO_INT_H__
#define __MIO_INT_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -29,6 +30,9 @@
#include "mio.h"
#include "extra.h"
+ABC_NAMESPACE_HEADER_START
+
+
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
@@ -121,6 +125,10 @@ struct Mio_PinStruct_t_
/*=== mioRead.c =============================================================*/
/*=== mioUtils.c =============================================================*/
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif
////////////////////////////////////////////////////////////////////////
diff --git a/src/map/mio/mioRead.c b/src/map/mio/mioRead.c
index fdb340aa..42c6d8bf 100644
--- a/src/map/mio/mioRead.c
+++ b/src/map/mio/mioRead.c
@@ -19,6 +19,9 @@
#include <ctype.h>
#include "mioInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -27,10 +30,10 @@
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
-static Mio_Library_t * Mio_LibraryReadOne( Abc_Frame_t * pAbc, char * FileName, bool fExtendedFormat, st_table * tExcludeGate, int fVerbose );
-static int Mio_LibraryReadInternal( Mio_Library_t * pLib, char * pBuffer, bool fExtendedFormat, st_table * tExcludeGate, int fVerbose );
-static Mio_Gate_t * Mio_LibraryReadGate( char ** ppToken, bool fExtendedFormat );
-static Mio_Pin_t * Mio_LibraryReadPin( char ** ppToken, bool fExtendedFormat );
+static Mio_Library_t * Mio_LibraryReadOne( Abc_Frame_t * pAbc, char * FileName, int fExtendedFormat, st_table * tExcludeGate, int fVerbose );
+static int Mio_LibraryReadInternal( Mio_Library_t * pLib, char * pBuffer, int fExtendedFormat, st_table * tExcludeGate, int fVerbose );
+static Mio_Gate_t * Mio_LibraryReadGate( char ** ppToken, int fExtendedFormat );
+static Mio_Pin_t * Mio_LibraryReadPin( char ** ppToken, int fExtendedFormat );
static char * chomp( char *s );
static void Mio_LibraryDetectSpecialGates( Mio_Library_t * pLib );
static void Io_ReadFileRemoveComments( char * pBuffer, int * pnDots, int * pnLines );
@@ -63,13 +66,13 @@ Mio_Library_t * Mio_LibraryRead( void * pAbc, char * FileName, char * ExcludeFil
return 0;
}
- fprintf ( Abc_FrameReadOut( pAbc ), "Read %d gates from exclude file\n", num );
+ fprintf ( Abc_FrameReadOut( (Abc_Frame_t *)pAbc ), "Read %d gates from exclude file\n", num );
}
- pLib = Mio_LibraryReadOne( pAbc, FileName, 0, tExcludeGate, fVerbose ); // try normal format first ..
+ pLib = Mio_LibraryReadOne( (Abc_Frame_t *)pAbc, FileName, 0, tExcludeGate, fVerbose ); // try normal format first ..
if ( pLib == NULL )
{
- pLib = Mio_LibraryReadOne( pAbc, FileName, 1, tExcludeGate, fVerbose ); // .. otherwise try extended format
+ pLib = Mio_LibraryReadOne( (Abc_Frame_t *)pAbc, FileName, 1, tExcludeGate, fVerbose ); // .. otherwise try extended format
if ( pLib != NULL )
printf ( "Warning: Read extended GENLIB format but ignoring extensions\n" );
}
@@ -88,7 +91,7 @@ Mio_Library_t * Mio_LibraryRead( void * pAbc, char * FileName, char * ExcludeFil
SeeAlso []
***********************************************************************/
-Mio_Library_t * Mio_LibraryReadOne( Abc_Frame_t * pAbc, char * FileName, bool fExtendedFormat, st_table * tExcludeGate, int fVerbose )
+Mio_Library_t * Mio_LibraryReadOne( Abc_Frame_t * pAbc, char * FileName, int fExtendedFormat, st_table * tExcludeGate, int fVerbose )
{
Mio_Library_t * pLib;
char * pBuffer = 0;
@@ -167,7 +170,7 @@ Mio_Library_t * Mio_LibraryReadOne( Abc_Frame_t * pAbc, char * FileName, bool fE
SeeAlso []
***********************************************************************/
-int Mio_LibraryReadInternal( Mio_Library_t * pLib, char * pBuffer, bool fExtendedFormat, st_table * tExcludeGate, int fVerbose )
+int Mio_LibraryReadInternal( Mio_Library_t * pLib, char * pBuffer, int fExtendedFormat, st_table * tExcludeGate, int fVerbose )
{
Mio_Gate_t * pGate, ** ppGate;
char * pToken;
@@ -236,7 +239,7 @@ int Mio_LibraryReadInternal( Mio_Library_t * pLib, char * pBuffer, bool fExtende
SeeAlso []
***********************************************************************/
-Mio_Gate_t * Mio_LibraryReadGate( char ** ppToken, bool fExtendedFormat )
+Mio_Gate_t * Mio_LibraryReadGate( char ** ppToken, int fExtendedFormat )
{
Mio_Gate_t * pGate;
Mio_Pin_t * pPin, ** ppPin;
@@ -305,7 +308,7 @@ Mio_Gate_t * Mio_LibraryReadGate( char ** ppToken, bool fExtendedFormat )
SeeAlso []
***********************************************************************/
-Mio_Pin_t * Mio_LibraryReadPin( char ** ppToken, bool fExtendedFormat )
+Mio_Pin_t * Mio_LibraryReadPin( char ** ppToken, int fExtendedFormat )
{
Mio_Pin_t * pPin;
char * pToken = *ppToken;
@@ -584,7 +587,7 @@ int Mio_LibraryReadExclude( void * pAbc, char * ExcludeFile, st_table * tExclude
if ( pEx == NULL )
{
- fprintf ( Abc_FrameReadErr( pAbc ), "Error: Could not open exclude file %s. Stop.\n", ExcludeFile );
+ fprintf ( Abc_FrameReadErr( (Abc_Frame_t *)pAbc ), "Error: Could not open exclude file %s. Stop.\n", ExcludeFile );
return -1;
}
@@ -664,3 +667,5 @@ void Io_ReadFileRemoveComments( char * pBuffer, int * pnDots, int * pnLines )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/mio/mioUtils.c b/src/map/mio/mioUtils.c
index 376a0bed..0e8cbb03 100644
--- a/src/map/mio/mioUtils.c
+++ b/src/map/mio/mioUtils.c
@@ -18,6 +18,9 @@
#include "mioInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -220,7 +223,7 @@ void Mio_WritePin( FILE * pFile, Mio_Pin_t * pPin )
SeeAlso []
***********************************************************************/
-Mio_Gate_t ** Mio_CollectRoots( Mio_Library_t * pLib, int nInputs, float tDelay, bool fSkipInv, int * pnGates )
+Mio_Gate_t ** Mio_CollectRoots( Mio_Library_t * pLib, int nInputs, float tDelay, int fSkipInv, int * pnGates )
{
Mio_Gate_t * pGate;
Mio_Gate_t ** ppGates;
@@ -534,3 +537,5 @@ Mio_Gate_t * Mio_GateCreatePseudo( int nInputs )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/super/super.c b/src/map/super/super.c
index 97420c5c..6483547e 100644
--- a/src/map/super/super.c
+++ b/src/map/super/super.c
@@ -20,6 +20,9 @@
#include "mainInt.h"
#include "mio.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -59,7 +62,7 @@ void Super_Init( Abc_Frame_t * pAbc )
SeeAlso []
***********************************************************************/
-void Super_End()
+void Super_End( Abc_Frame_t * pAbc )
{
}
@@ -152,8 +155,8 @@ int Super_CommandSupergates( Abc_Frame_t * pAbc, int argc, char **argv )
char * FileName, * ExcludeFile;
float DelayLimit;
float AreaLimit;
- bool fSkipInvs;
- bool fWriteOldFormat;
+ int fSkipInvs;
+ int fWriteOldFormat;
int nVarsMax, nLevels, TimeLimit;
int fVerbose;
int c;
@@ -317,3 +320,5 @@ usage:
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/super/super.h b/src/map/super/super.h
index 9f5e83ae..246ea092 100644
--- a/src/map/super/super.h
+++ b/src/map/super/super.h
@@ -19,6 +19,7 @@
#ifndef __SUPER_H__
#define __SUPER_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -27,9 +28,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// STRUCTURE DEFINITIONS ///
@@ -49,9 +51,11 @@ extern "C" {
/*=== superCore.c =============================================================*/
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/map/super/superAnd.c b/src/map/super/superAnd.c
index 3014d505..17ba9771 100644
--- a/src/map/super/superAnd.c
+++ b/src/map/super/superAnd.c
@@ -18,6 +18,9 @@
#include "superInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -694,3 +697,5 @@ int Super2_LibWriteCompare( char * pStr1, char * pStr2 )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/super/superGENERIC.c b/src/map/super/superGENERIC.c
index 1f2b7651..9d1f4cf0 100644
--- a/src/map/super/superGENERIC.c
+++ b/src/map/super/superGENERIC.c
@@ -18,6 +18,9 @@
#include "superInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -44,3 +47,5 @@
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/super/superGate.c b/src/map/super/superGate.c
index 6ffab984..a1962b09 100644
--- a/src/map/super/superGate.c
+++ b/src/map/super/superGate.c
@@ -16,8 +16,12 @@
***********************************************************************/
+#include <math.h>
#include "superInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -99,9 +103,9 @@ static void Super_ManStop( Super_Man_t * pMan );
static void Super_AddGateToTable( Super_Man_t * pMan, Super_Gate_t * pGate );
static void Super_First( Super_Man_t * pMan, int nVarsMax );
-static Super_Man_t * Super_Compute( Super_Man_t * pMan, Mio_Gate_t ** ppGates, int nGates, bool fSkipInv );
+static Super_Man_t * Super_Compute( Super_Man_t * pMan, Mio_Gate_t ** ppGates, int nGates, int fSkipInv );
static Super_Gate_t * Super_CreateGateNew( Super_Man_t * pMan, Mio_Gate_t * pRoot, Super_Gate_t ** pSupers, int nSupers, unsigned uTruth[], float Area, float tPinDelaysRes[], float tDelayMax, int nPins );
-static bool Super_CompareGates( Super_Man_t * pMan, unsigned uTruth[], float Area, float tPinDelaysRes[], int nPins );
+static int Super_CompareGates( Super_Man_t * pMan, unsigned uTruth[], float Area, float tPinDelaysRes[], int nPins );
static int Super_DelayCompare( Super_Gate_t ** ppG1, Super_Gate_t ** ppG2 );
static int Super_AreaCompare( Super_Gate_t ** ppG1, Super_Gate_t ** ppG2 );
static void Super_TranferGatesToArray( Super_Man_t * pMan );
@@ -134,7 +138,7 @@ static void Super_WriteLibraryTree_rec( FILE * pFile, Super_Man_t * pM
SeeAlso []
***********************************************************************/
-void Super_Precompute( Mio_Library_t * pLibGen, int nVarsMax, int nLevels, float tDelayMax, float tAreaMax, int TimeLimit, bool fSkipInv, bool fWriteOldFormat, int fVerbose )
+void Super_Precompute( Mio_Library_t * pLibGen, int nVarsMax, int nLevels, float tDelayMax, float tAreaMax, int TimeLimit, int fSkipInv, int fWriteOldFormat, int fVerbose )
{
Super_Man_t * pMan;
Mio_Gate_t ** ppGates;
@@ -291,7 +295,7 @@ void Super_First( Super_Man_t * pMan, int nVarsMax )
SeeAlso []
***********************************************************************/
-Super_Man_t * Super_Compute( Super_Man_t * pMan, Mio_Gate_t ** ppGates, int nGates, bool fSkipInv )
+Super_Man_t * Super_Compute( Super_Man_t * pMan, Mio_Gate_t ** ppGates, int nGates, int fSkipInv )
{
Super_Gate_t * pSupers[6], * pGate0, * pGate1, * pGate2, * pGate3, * pGate4, * pGate5, * pGateNew;
float tPinDelaysRes[6], * ptPinDelays[6], tPinDelayMax, tDelayMio;
@@ -757,7 +761,7 @@ void Super_AddGateToTable( Super_Man_t * pMan, Super_Gate_t * pGate )
SeeAlso []
***********************************************************************/
-bool Super_CompareGates( Super_Man_t * pMan, unsigned uTruth[], float Area, float tPinDelaysRes[], int nPins )
+int Super_CompareGates( Super_Man_t * pMan, unsigned uTruth[], float Area, float tPinDelaysRes[], int nPins )
{
Super_Gate_t ** ppList, * pPrev, * pGate, * pGate2;
int i, fNewIsBetter, fGateIsBetter;
@@ -1012,7 +1016,7 @@ void Super_WriteFileHeader( Super_Man_t * pMan, FILE * pFile )
fprintf( pFile, "# The number of attempts = %10d.\n", pMan->nTried );
fprintf( pFile, "# The number of supergates = %10d.\n", pMan->nGates );
fprintf( pFile, "# The number of functions = %10d.\n", pMan->nUnique );
- fprintf( pFile, "# The total functions = %.0f (2^%d).\n", pow(2,pMan->nMints), pMan->nMints );
+ fprintf( pFile, "# The total functions = %.0f (2^%d).\n", pow((double)2,pMan->nMints), pMan->nMints );
fprintf( pFile, "#\n" );
fprintf( pFile, "# Generation time (sec) = %10.2f.\n", (float)(pMan->Time)/(float)(CLOCKS_PER_SEC) );
fprintf( pFile, "#\n" );
@@ -1336,3 +1340,5 @@ void Super_WriteLibraryTree_rec( FILE * pFile, Super_Man_t * pMan, Super_Gate_t
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/map/super/superInt.h b/src/map/super/superInt.h
index ec6d0a38..0d4215ff 100644
--- a/src/map/super/superInt.h
+++ b/src/map/super/superInt.h
@@ -19,6 +19,7 @@
#ifndef __super_INT_H__
#define __super_INT_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -30,6 +31,9 @@
#include "stmm.h"
#include "super.h"
+ABC_NAMESPACE_HEADER_START
+
+
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
@@ -53,7 +57,11 @@
/*=== superAnd.c =============================================================*/
extern void Super2_Precompute( int nInputs, int nLevels, int fVerbose );
/*=== superGate.c =============================================================*/
-extern void Super_Precompute( Mio_Library_t * pLibGen, int nInputs, int nLevels, float tDelayMax, float tAreaMax, int TimeLimit, bool fSkipInv, bool fWriteOldFormat, int fVerbose );
+extern void Super_Precompute( Mio_Library_t * pLibGen, int nInputs, int nLevels, float tDelayMax, float tAreaMax, int TimeLimit, int fSkipInv, int fWriteOldFormat, int fVerbose );
+
+
+
+ABC_NAMESPACE_HEADER_END
#endif
diff --git a/src/map/super/superWrite.c b/src/map/super/superWrite.c
index 395ef145..b8d14837 100644
--- a/src/map/super/superWrite.c
+++ b/src/map/super/superWrite.c
@@ -18,6 +18,9 @@
#include "superInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*
One record in the supergate library file consists of:
@@ -74,3 +77,5 @@
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/avl/avl.c b/src/misc/avl/avl.c
index 2c2dec88..7144cb56 100644
--- a/src/misc/avl/avl.c
+++ b/src/misc/avl/avl.c
@@ -15,6 +15,9 @@
#include "avl.h"
+ABC_NAMESPACE_IMPL_START
+
+
#define HEIGHT(node) (node == NIL(avl_node) ? -1 : (node)->height)
@@ -614,3 +617,5 @@ do_check_tree (node, compar, error)
return comp_height;
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/avl/avl.h b/src/misc/avl/avl.h
index 21d811da..50a06b69 100644
--- a/src/misc/avl/avl.h
+++ b/src/misc/avl/avl.h
@@ -10,8 +10,15 @@
#ifndef AVL_INCLUDED
#define AVL_INCLUDED
+
+ABC_NAMESPACE_HEADER_START
+
+
#define EXTERN
-#define ARGS(protos) protos
+
+#ifndef ARGS
+#define ARGS(protos) protos
+#endif
#define MAX(a,b) ((a) > (b) ? (a) : (b))
@@ -77,4 +84,8 @@ EXTERN avl_generator *avl_init_gen ARGS((avl_tree *, int));
for(gen = avl_init_gen(table, dir); \
avl_gen(gen, key_p, value_p) || (avl_free_gen(gen),0);)
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif
diff --git a/src/misc/bzlib/blocksort.c b/src/misc/bzlib/blocksort.c
index 95adb5ef..0dc4ff46 100644
--- a/src/misc/bzlib/blocksort.c
+++ b/src/misc/bzlib/blocksort.c
@@ -21,6 +21,8 @@
#include "bzlib_private.h"
+ABC_NAMESPACE_IMPL_START
+
/*---------------------------------------------*/
/*--- Fallback O(N log(N)^2) sorting ---*/
/*--- algorithm, for repetitive blocks ---*/
@@ -1092,3 +1094,5 @@ void BZ2_blockSort ( EState* s )
/*-------------------------------------------------------------*/
/*--- end blocksort.c ---*/
/*-------------------------------------------------------------*/
+
+ABC_NAMESPACE_IMPL_END
diff --git a/src/misc/bzlib/bzlib.c b/src/misc/bzlib/bzlib.c
index 9d040682..93aa083d 100644
--- a/src/misc/bzlib/bzlib.c
+++ b/src/misc/bzlib/bzlib.c
@@ -30,6 +30,14 @@
#include "bzlib_private.h"
+ABC_NAMESPACE_IMPL_START
+
+#ifdef _WIN32
+#define fileno _fileno
+#define fdopen _fdopen
+#define setmode _setmode
+#endif
+
/*---------------------------------------------------*/
/*--- Compression stuff ---*/
/*---------------------------------------------------*/
@@ -164,7 +172,7 @@ int BZ_API(BZ2_bzCompressInit)
if (strm->bzalloc == NULL) strm->bzalloc = default_bzalloc;
if (strm->bzfree == NULL) strm->bzfree = default_bzfree;
- s = BZALLOC( sizeof(EState) );
+ s = (EState *)BZALLOC( sizeof(EState) );
if (s == NULL) return BZ_MEM_ERROR;
s->strm = strm;
@@ -173,9 +181,9 @@ int BZ_API(BZ2_bzCompressInit)
s->ftab = NULL;
n = 100000 * blockSize100k;
- s->arr1 = BZALLOC( n * sizeof(UInt32) );
- s->arr2 = BZALLOC( (n+BZ_N_OVERSHOOT) * sizeof(UInt32) );
- s->ftab = BZALLOC( 65537 * sizeof(UInt32) );
+ s->arr1 = (unsigned *)BZALLOC( n * sizeof(UInt32) );
+ s->arr2 = (unsigned *)BZALLOC( (n+BZ_N_OVERSHOOT) * sizeof(UInt32) );
+ s->ftab = (unsigned *)BZALLOC( 65537 * sizeof(UInt32) );
if (s->arr1 == NULL || s->arr2 == NULL || s->ftab == NULL) {
if (s->arr1 != NULL) BZFREE(s->arr1);
@@ -361,7 +369,7 @@ Bool handle_compress ( bz_stream* strm )
{
Bool progress_in = False;
Bool progress_out = False;
- EState* s = strm->state;
+ EState* s = (EState *)strm->state;
while (True) {
@@ -408,7 +416,7 @@ int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action )
Bool progress;
EState* s;
if (strm == NULL) return BZ_PARAM_ERROR;
- s = strm->state;
+ s = (EState *)strm->state;
if (s == NULL) return BZ_PARAM_ERROR;
if (s->strm != strm) return BZ_PARAM_ERROR;
@@ -468,7 +476,7 @@ int BZ_API(BZ2_bzCompressEnd) ( bz_stream *strm )
{
EState* s;
if (strm == NULL) return BZ_PARAM_ERROR;
- s = strm->state;
+ s = (EState *)strm->state;
if (s == NULL) return BZ_PARAM_ERROR;
if (s->strm != strm) return BZ_PARAM_ERROR;
@@ -504,7 +512,7 @@ int BZ_API(BZ2_bzDecompressInit)
if (strm->bzalloc == NULL) strm->bzalloc = default_bzalloc;
if (strm->bzfree == NULL) strm->bzfree = default_bzfree;
- s = BZALLOC( sizeof(DState) );
+ s = (DState *)BZALLOC( sizeof(DState) );
if (s == NULL) return BZ_MEM_ERROR;
s->strm = strm;
strm->state = s;
@@ -683,7 +691,7 @@ Bool unRLE_obuf_to_output_FAST ( DState* s )
/*---------------------------------------------------*/
-__inline__ Int32 BZ2_indexIntoF ( Int32 indx, Int32 *cftab )
+Int32 BZ2_indexIntoF ( Int32 indx, Int32 *cftab )
{
Int32 nb, na, mid;
nb = 0;
@@ -809,7 +817,7 @@ int BZ_API(BZ2_bzDecompress) ( bz_stream *strm )
Bool corrupt;
DState* s;
if (strm == NULL) return BZ_PARAM_ERROR;
- s = strm->state;
+ s = (DState *)strm->state;
if (s == NULL) return BZ_PARAM_ERROR;
if (s->strm != strm) return BZ_PARAM_ERROR;
@@ -862,7 +870,7 @@ int BZ_API(BZ2_bzDecompressEnd) ( bz_stream *strm )
{
DState* s;
if (strm == NULL) return BZ_PARAM_ERROR;
- s = strm->state;
+ s = (DState *)strm->state;
if (s == NULL) return BZ_PARAM_ERROR;
if (s->strm != strm) return BZ_PARAM_ERROR;
@@ -933,7 +941,7 @@ BZFILE* BZ_API(BZ2_bzWriteOpen)
if (ferror(f))
{ BZ_SETERR(BZ_IO_ERROR); return NULL; };
- bzf = malloc ( sizeof(bzFile) );
+ bzf = (bzFile *)malloc ( sizeof(bzFile) );
if (bzf == NULL)
{ BZ_SETERR(BZ_MEM_ERROR); return NULL; };
@@ -981,7 +989,7 @@ void BZ_API(BZ2_bzWrite)
{ BZ_SETERR(BZ_OK); return; };
bzf->strm.avail_in = len;
- bzf->strm.next_in = buf;
+ bzf->strm.next_in = (char *)buf;
while (True) {
bzf->strm.avail_out = BZ_MAX_UNUSED;
@@ -1106,7 +1114,7 @@ BZFILE* BZ_API(BZ2_bzReadOpen)
if (ferror(f))
{ BZ_SETERR(BZ_IO_ERROR); return NULL; };
- bzf = malloc ( sizeof(bzFile) );
+ bzf = (bzFile *)malloc ( sizeof(bzFile) );
if (bzf == NULL)
{ BZ_SETERR(BZ_MEM_ERROR); return NULL; };
@@ -1178,7 +1186,7 @@ int BZ_API(BZ2_bzRead)
{ BZ_SETERR(BZ_OK); return 0; };
bzf->strm.avail_out = len;
- bzf->strm.next_out = buf;
+ bzf->strm.next_out = (char *)buf;
while (True) {
@@ -1427,7 +1435,7 @@ BZFILE * bzopen_or_bzdopen
#ifdef BZ_STRICT_ANSI
fp = NULL;
#else
- fp = fdopen(fd,mode2);
+ fp = (FILE *)fdopen(fd,mode2);
#endif
}
if (fp == NULL) return NULL;
@@ -1569,3 +1577,8 @@ const char * BZ_API(BZ2_bzerror) (BZFILE *b, int *errnum)
/*-------------------------------------------------------------*/
/*--- end bzlib.c ---*/
/*-------------------------------------------------------------*/
+
+ABC_NAMESPACE_IMPL_END
+
+
+
diff --git a/src/misc/bzlib/bzlib.h b/src/misc/bzlib/bzlib.h
index b1f892b0..68a6cd01 100644
--- a/src/misc/bzlib/bzlib.h
+++ b/src/misc/bzlib/bzlib.h
@@ -27,10 +27,6 @@
#ifndef _BZLIB_H
#define _BZLIB_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
#define BZ_RUN 0
#define BZ_FLUSH 1
#define BZ_FINISH 2
@@ -99,6 +95,10 @@ typedef
# define BZ_EXTERN extern
#endif
+#include <stdio.h>
+#include "abc_global.h"
+
+ABC_NAMESPACE_HEADER_START
/*-- Core (low-level) library functions --*/
@@ -276,9 +276,9 @@ BZ_EXTERN const char * BZ_API(BZ2_bzerror) (
);
#endif
-#ifdef __cplusplus
-}
-#endif
+
+ABC_NAMESPACE_HEADER_END
+
#endif
diff --git a/src/misc/bzlib/bzlib_private.h b/src/misc/bzlib/bzlib_private.h
index 23427879..072f0486 100644
--- a/src/misc/bzlib/bzlib_private.h
+++ b/src/misc/bzlib/bzlib_private.h
@@ -22,6 +22,7 @@
#ifndef _BZLIB_PRIVATE_H
#define _BZLIB_PRIVATE_H
+
#include <stdlib.h>
#ifndef BZ_NO_STDIO
@@ -30,9 +31,10 @@
#include <string.h>
#endif
-#include "bzlib.h"
+#include "bzlib.h"
+ABC_NAMESPACE_HEADER_START
/*-- General stuff. --*/
@@ -481,7 +483,7 @@ typedef
/*-- externs for decompression. --*/
-extern Int32
+Int32
BZ2_indexIntoF ( Int32, Int32* );
extern Int32
@@ -501,8 +503,10 @@ BZ2_hbCreateDecodeTables ( Int32*, Int32*, Int32*, UChar*,
#ifndef NULL
#define NULL 0
#endif
+
#endif
+ABC_NAMESPACE_HEADER_END
/*-------------------------------------------------------------*/
/*--- end bzlib_private.h ---*/
diff --git a/src/misc/bzlib/compress.c b/src/misc/bzlib/compress.c
index 7d9b3da7..b149a28c 100644
--- a/src/misc/bzlib/compress.c
+++ b/src/misc/bzlib/compress.c
@@ -28,6 +28,9 @@
#include "bzlib_private.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------*/
/*--- Bit stream I/O ---*/
@@ -670,3 +673,5 @@ void BZ2_compressBlock ( EState* s, Bool is_last_block )
/*-------------------------------------------------------------*/
/*--- end compress.c ---*/
/*-------------------------------------------------------------*/
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/bzlib/crctable.c b/src/misc/bzlib/crctable.c
index 215687b2..6e033d0d 100644
--- a/src/misc/bzlib/crctable.c
+++ b/src/misc/bzlib/crctable.c
@@ -21,6 +21,9 @@
#include "bzlib_private.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*--
I think this is an implementation of the AUTODIN-II,
Ethernet & FDDI 32-bit CRC standard. Vaguely derived
@@ -102,3 +105,5 @@ UInt32 BZ2_crc32Table[256] = {
/*-------------------------------------------------------------*/
/*--- end crctable.c ---*/
/*-------------------------------------------------------------*/
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/bzlib/decompress.c b/src/misc/bzlib/decompress.c
index bba5e0fa..47dd98e4 100644
--- a/src/misc/bzlib/decompress.c
+++ b/src/misc/bzlib/decompress.c
@@ -21,6 +21,9 @@
#include "bzlib_private.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------*/
static
@@ -209,13 +212,13 @@ Int32 BZ2_decompress ( DState* s )
s->blockSize100k -= BZ_HDR_0;
if (s->smallDecompress) {
- s->ll16 = BZALLOC( s->blockSize100k * 100000 * sizeof(UInt16) );
- s->ll4 = BZALLOC(
+ s->ll16 = (unsigned short *)BZALLOC( s->blockSize100k * 100000 * sizeof(UInt16) );
+ s->ll4 = (unsigned char *)BZALLOC(
((1 + s->blockSize100k * 100000) >> 1) * sizeof(UChar)
);
if (s->ll16 == NULL || s->ll4 == NULL) RETURN(BZ_MEM_ERROR);
} else {
- s->tt = BZALLOC( s->blockSize100k * 100000 * sizeof(Int32) );
+ s->tt = (unsigned *)BZALLOC( s->blockSize100k * 100000 * sizeof(Int32) );
if (s->tt == NULL) RETURN(BZ_MEM_ERROR);
}
@@ -624,3 +627,5 @@ Int32 BZ2_decompress ( DState* s )
/*-------------------------------------------------------------*/
/*--- end decompress.c ---*/
/*-------------------------------------------------------------*/
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/bzlib/huffman.c b/src/misc/bzlib/huffman.c
index 87e79e38..0f367d62 100644
--- a/src/misc/bzlib/huffman.c
+++ b/src/misc/bzlib/huffman.c
@@ -21,6 +21,9 @@
#include "bzlib_private.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------*/
#define WEIGHTOF(zz0) ((zz0) & 0xffffff00)
#define DEPTHOF(zz1) ((zz1) & 0x000000ff)
@@ -203,3 +206,5 @@ void BZ2_hbCreateDecodeTables ( Int32 *limit,
/*-------------------------------------------------------------*/
/*--- end huffman.c ---*/
/*-------------------------------------------------------------*/
+
+ABC_NAMESPACE_IMPL_END
diff --git a/src/misc/bzlib/randtable.c b/src/misc/bzlib/randtable.c
index 068b7636..9cabcb69 100644
--- a/src/misc/bzlib/randtable.c
+++ b/src/misc/bzlib/randtable.c
@@ -21,6 +21,9 @@
#include "bzlib_private.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------*/
Int32 BZ2_rNums[512] = {
@@ -82,3 +85,5 @@ Int32 BZ2_rNums[512] = {
/*-------------------------------------------------------------*/
/*--- end randtable.c ---*/
/*-------------------------------------------------------------*/
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/espresso/cofactor.c b/src/misc/espresso/cofactor.c
index 1a2c6e8a..fec36afd 100644
--- a/src/misc/espresso/cofactor.c
+++ b/src/misc/espresso/cofactor.c
@@ -9,6 +9,9 @@
*/
#include "espresso.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*
The cofactor of a cover against a cube "c" is a cover formed by the
cofactor of each cube in the cover against c. The cofactor of two
@@ -382,3 +385,5 @@ pcube *T;
*Tdest++ = NULL; /* sentinel */
Tdest[1] = (pcube) Tdest; /* save pointer to last */
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/espresso/cols.c b/src/misc/espresso/cols.c
index ec3797e6..95f1ce7f 100644
--- a/src/misc/espresso/cols.c
+++ b/src/misc/espresso/cols.c
@@ -10,6 +10,9 @@
//#include "port.h"
#include "sparse_int.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*
* allocate a new col vector
@@ -312,3 +315,5 @@ sm_col *pcol;
(void) fprintf(fp, " %d", p->row_num);
}
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/espresso/compl.c b/src/misc/espresso/compl.c
index 8f1c6606..a17eb278 100644
--- a/src/misc/espresso/compl.c
+++ b/src/misc/espresso/compl.c
@@ -26,6 +26,9 @@
#include "espresso.h"
+ABC_NAMESPACE_IMPL_START
+
+
#define USE_COMPL_LIFT 0
#define USE_COMPL_LIFT_ONSET 1
#define USE_COMPL_LIFT_ONSET_COMPLEX 2
@@ -678,3 +681,5 @@ pcover *Tnew; /* returned only if answer determined */
return MAYBE;
}
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/espresso/contain.c b/src/misc/espresso/contain.c
index 710c4894..e6073076 100644
--- a/src/misc/espresso/contain.c
+++ b/src/misc/espresso/contain.c
@@ -24,6 +24,9 @@
#include "espresso.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*
sf_contain -- perform containment on a set family (delete sets which
@@ -443,3 +446,5 @@ IN int totcnt, size;
FREE(E1);
return R;
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/espresso/cubehack.c b/src/misc/espresso/cubehack.c
index 8e1724fc..58935716 100644
--- a/src/misc/espresso/cubehack.c
+++ b/src/misc/espresso/cubehack.c
@@ -27,6 +27,9 @@ bool use_random_order;
*/
#include "espresso.h"
+ABC_NAMESPACE_IMPL_START
+
+
void
cautious_define_cube_size(n)
@@ -136,3 +139,5 @@ set_espresso_flags()
use_super_gasp = FALSE;
use_random_order = FALSE;
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/espresso/cubestr.c b/src/misc/espresso/cubestr.c
index 77389e73..4b6dbcea 100644
--- a/src/misc/espresso/cubestr.c
+++ b/src/misc/espresso/cubestr.c
@@ -13,6 +13,9 @@
#include "espresso.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*
cube_setup -- assume that the fields "num_vars", "num_binary_vars", and
part_size[num_binary_vars .. num_vars-1] are setup, and initialize the
@@ -150,3 +153,5 @@ void restore_cube_struct()
cube = temp_cube_save; /* structure copy ! */
cdata = temp_cdata_save; /* "" */
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/espresso/cvrin.c b/src/misc/espresso/cvrin.c
index d33db46a..993a9841 100644
--- a/src/misc/espresso/cvrin.c
+++ b/src/misc/espresso/cvrin.c
@@ -15,6 +15,9 @@
#include <ctype.h>
#include "espresso.h"
+ABC_NAMESPACE_IMPL_START
+
+
static bool line_length_error;
static int lineno;
@@ -809,3 +812,5 @@ int *ip;
}
return FALSE;
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/espresso/cvrm.c b/src/misc/espresso/cvrm.c
index f55178e8..2a573ae0 100644
--- a/src/misc/espresso/cvrm.c
+++ b/src/misc/espresso/cvrm.c
@@ -17,6 +17,9 @@
#include "espresso.h"
+ABC_NAMESPACE_IMPL_START
+
+
static void cb_unravel(c, start, end, startbase, B1)
IN register pcube c;
@@ -537,3 +540,5 @@ int i;
PLA->F = NULL;
return 1;
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/espresso/cvrmisc.c b/src/misc/espresso/cvrmisc.c
index 0f3de195..995c37a1 100644
--- a/src/misc/espresso/cvrmisc.c
+++ b/src/misc/espresso/cvrmisc.c
@@ -9,6 +9,9 @@
*/
#include "espresso.h"
+ABC_NAMESPACE_IMPL_START
+
+
/* cost -- compute the cost of a cover */
void cover_cost(F, cost)
@@ -140,3 +143,5 @@ char *s;
(void) fprintf(stderr, "espresso: %s\n", s);
exit(1);
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/espresso/cvrout.c b/src/misc/espresso/cvrout.c
index 60b9d9e8..4ac1cfd7 100644
--- a/src/misc/espresso/cvrout.c
+++ b/src/misc/espresso/cvrout.c
@@ -14,6 +14,9 @@
#include "espresso.h"
+ABC_NAMESPACE_IMPL_START
+
+
void fprint_pla(fp, PLA, output_type)
INOUT FILE *fp;
IN pPLA PLA;
@@ -571,7 +574,7 @@ int output_symbolic;
}
- /* Print out the contraints */
+ /* Print out the constraints */
if (! output_symbolic) {
(void) fprintf(fp,
"# Symbolic constraints for variable %d (Numeric form)\n", var);
@@ -607,3 +610,5 @@ int output_symbolic;
}
}
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/espresso/dominate.c b/src/misc/espresso/dominate.c
index a930d453..6cdc5d79 100644
--- a/src/misc/espresso/dominate.c
+++ b/src/misc/espresso/dominate.c
@@ -9,6 +9,9 @@
*/
#include "mincov_int.h"
+ABC_NAMESPACE_IMPL_START
+
+
int
sm_row_dominance(A)
@@ -96,3 +99,5 @@ int *weight;
return colcnt - A->ncols;
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/espresso/equiv.c b/src/misc/espresso/equiv.c
index f6495f1f..6c7fb89b 100644
--- a/src/misc/espresso/equiv.c
+++ b/src/misc/espresso/equiv.c
@@ -9,6 +9,9 @@
*/
#include "espresso.h"
+ABC_NAMESPACE_IMPL_START
+
+
void find_equiv_outputs(PLA)
pPLA PLA;
@@ -92,3 +95,5 @@ pcover f1, f2;
return TRUE;
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/espresso/espresso.c b/src/misc/espresso/espresso.c
index 8f05d43f..296f5673 100644
--- a/src/misc/espresso/espresso.c
+++ b/src/misc/espresso/espresso.c
@@ -47,6 +47,9 @@
#include "espresso.h"
+ABC_NAMESPACE_IMPL_START
+
+
pcover espresso(F, D1, R)
pcover F, D1, R;
{
@@ -137,3 +140,5 @@ begin:
return F;
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/espresso/espresso.h b/src/misc/espresso/espresso.h
index 3ca331ac..27d1c124 100644
--- a/src/misc/espresso/espresso.h
+++ b/src/misc/espresso/espresso.h
@@ -56,7 +56,11 @@
/* Define host machine characteristics of "unsigned int" */
#ifndef BPI
-#define BPI 32 /* # bits per integer */
+#define BPI
+
+
+ABC_NAMESPACE_HEADER_START
+ 32 /* # bits per integer */
#endif
#if BPI == 32
@@ -509,6 +513,10 @@ extern struct cdata_struct cdata, temp_cdata_save;
#else
#define DISJOINT 0x5555
#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif
/* function declarations */
diff --git a/src/misc/espresso/essen.c b/src/misc/espresso/essen.c
index 6a46295d..c4f9999b 100644
--- a/src/misc/espresso/essen.c
+++ b/src/misc/espresso/essen.c
@@ -14,6 +14,9 @@
#include "espresso.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*
essential -- return a cover consisting of the cubes of F which are
essential prime implicants (with respect to F u D); Further, remove
@@ -177,3 +180,5 @@ register pcube p, c;
set_free(temp);
return R;
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/espresso/exact.c b/src/misc/espresso/exact.c
index b1943636..8bfa1ce3 100644
--- a/src/misc/espresso/exact.c
+++ b/src/misc/espresso/exact.c
@@ -9,6 +9,9 @@
*/
#include "espresso.h"
+ABC_NAMESPACE_IMPL_START
+
+
static void dump_irredundant();
static pcover do_minimize();
@@ -179,3 +182,5 @@ sm_matrix *table;
(void) fclose(fp_pi_table);
}
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/espresso/expand.c b/src/misc/espresso/expand.c
index 6b41a786..050626d5 100644
--- a/src/misc/espresso/expand.c
+++ b/src/misc/espresso/expand.c
@@ -39,6 +39,9 @@
*/
#include "espresso.h"
+
+ABC_NAMESPACE_IMPL_START
+
/*
expand -- expand each nonprime cube of F into a prime implicant
@@ -693,3 +696,5 @@ pcover F, R;
set_free(FREESET);
return Fall_primes;
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/espresso/gasp.c b/src/misc/espresso/gasp.c
index aa3254d3..76e1233e 100644
--- a/src/misc/espresso/gasp.c
+++ b/src/misc/espresso/gasp.c
@@ -26,6 +26,9 @@
#include "espresso.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*
* reduce_gasp -- compute the maximal reduction of each cube of F
@@ -226,3 +229,5 @@ cost_t *cost;
EXECUTE(F = irredundant(G, D), IRRED_TIME, F, *cost);
return F;
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/espresso/gimpel.c b/src/misc/espresso/gimpel.c
index 4b75ae59..01d5e418 100644
--- a/src/misc/espresso/gimpel.c
+++ b/src/misc/espresso/gimpel.c
@@ -9,6 +9,9 @@
*/
#include "mincov_int.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*
* check for:
@@ -105,3 +108,5 @@ solution_t **best;
return 0;
}
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/espresso/globals.c b/src/misc/espresso/globals.c
index 2ec1d1db..9f43e0b0 100644
--- a/src/misc/espresso/globals.c
+++ b/src/misc/espresso/globals.c
@@ -9,6 +9,9 @@
*/
#include "espresso.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*
* Global Variable Declarations
*/
@@ -74,3 +77,5 @@ int bit_count[256] = {
2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8
};
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/espresso/hack.c b/src/misc/espresso/hack.c
index 13cdf895..a3efec1c 100644
--- a/src/misc/espresso/hack.c
+++ b/src/misc/espresso/hack.c
@@ -9,6 +9,9 @@
*/
#include "espresso.h"
+ABC_NAMESPACE_IMPL_START
+
+
void map_dcset(PLA)
pPLA PLA;
{
@@ -639,3 +642,5 @@ int verbose_mode;
kiss_print_cube(stdout, PLA, p, "~1");
}
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/espresso/indep.c b/src/misc/espresso/indep.c
index 10b363a0..52de654b 100644
--- a/src/misc/espresso/indep.c
+++ b/src/misc/espresso/indep.c
@@ -9,6 +9,9 @@
*/
#include "mincov_int.h"
+ABC_NAMESPACE_IMPL_START
+
+
static sm_matrix *build_intersection_matrix();
@@ -132,3 +135,5 @@ sm_matrix *A;
return B;
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/espresso/irred.c b/src/misc/espresso/irred.c
index 2e9f4e26..fadc2256 100644
--- a/src/misc/espresso/irred.c
+++ b/src/misc/espresso/irred.c
@@ -9,6 +9,9 @@
*/
#include "espresso.h"
+ABC_NAMESPACE_IMPL_START
+
+
static void fcube_is_covered();
static void ftautology();
static bool ftaut_special_cases();
@@ -438,3 +441,5 @@ start:
/* Not much we can do about it */
return MAYBE;
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/espresso/main.c b/src/misc/espresso/main.c
index 0a511c0e..157ef5a0 100644
--- a/src/misc/espresso/main.c
+++ b/src/misc/espresso/main.c
@@ -14,7 +14,10 @@
*/
#include "espresso.h"
-#include "main.h" /* table definitions for options */
+#include "main.h"
+
+ABC_NAMESPACE_IMPL_START
+ /* table definitions for options */
static FILE *last_fp;
static int input_type = FD_type;
@@ -744,3 +747,5 @@ register char *argv[], *s;
}
return FALSE;
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/espresso/map.c b/src/misc/espresso/map.c
index 68168745..7fdf1340 100644
--- a/src/misc/espresso/map.c
+++ b/src/misc/espresso/map.c
@@ -9,6 +9,9 @@
*/
#include "espresso.h"
+ABC_NAMESPACE_IMPL_START
+
+
static pcube Gcube;
static pset Gminterm;
@@ -115,3 +118,5 @@ pcover T;
}
set_free(m);
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/espresso/matrix.c b/src/misc/espresso/matrix.c
index 747fe54f..08fa1f95 100644
--- a/src/misc/espresso/matrix.c
+++ b/src/misc/espresso/matrix.c
@@ -10,6 +10,9 @@
//#include "port.h"
#include "sparse_int.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*
* free-lists are only used if 'FAST_AND_LOOSE' is set; this is because
* we lose the debugging capability of libmm_t which trashes objects when
@@ -572,3 +575,5 @@ sm_cleanup()
sm_col_freelist = 0;
#endif
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/espresso/mincov.c b/src/misc/espresso/mincov.c
index ee18a3f1..3f9410f6 100644
--- a/src/misc/espresso/mincov.c
+++ b/src/misc/espresso/mincov.c
@@ -9,6 +9,9 @@
*/
#include "mincov_int.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*
* mincov.c
*/
@@ -376,3 +379,5 @@ sm_row *cover;
}
return 1;
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/espresso/opo.c b/src/misc/espresso/opo.c
index 19522f89..52dc4d76 100644
--- a/src/misc/espresso/opo.c
+++ b/src/misc/espresso/opo.c
@@ -9,6 +9,9 @@
*/
#include "espresso.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*
* Phase assignment technique (T. Sasao):
*
@@ -622,3 +625,5 @@ pPLA PLA;
EXEC_S(PLA->F = espresso(PLA->F, PLA->D, PLA->R), "ESPRESSO ",PLA->F);
}
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/espresso/pair.c b/src/misc/espresso/pair.c
index a5345178..26d27716 100644
--- a/src/misc/espresso/pair.c
+++ b/src/misc/espresso/pair.c
@@ -9,6 +9,9 @@
*/
#include "espresso.h"
+ABC_NAMESPACE_IMPL_START
+
+
void set_pair(PLA)
pPLA PLA;
{
@@ -678,3 +681,5 @@ register ppair pair;
FREE(pair->var2);
FREE(pair);
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/espresso/part.c b/src/misc/espresso/part.c
index 42843aeb..32baeda7 100644
--- a/src/misc/espresso/part.c
+++ b/src/misc/espresso/part.c
@@ -9,6 +9,9 @@
*/
#include "mincov_int.h"
+ABC_NAMESPACE_IMPL_START
+
+
static int visit_col();
static void
@@ -120,3 +123,5 @@ sm_matrix **L, **R;
return 1;
}
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/espresso/primes.c b/src/misc/espresso/primes.c
index 3e40da27..52792857 100644
--- a/src/misc/espresso/primes.c
+++ b/src/misc/espresso/primes.c
@@ -9,6 +9,9 @@
*/
#include "espresso.h"
+ABC_NAMESPACE_IMPL_START
+
+
static bool primes_consensus_special_cases();
static pcover primes_consensus_merge();
static pcover and_with_cofactor();
@@ -168,3 +171,5 @@ register pset cof;
}
return sf_inactive(A);
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/espresso/reduce.c b/src/misc/espresso/reduce.c
index 00e4507f..45241439 100644
--- a/src/misc/espresso/reduce.c
+++ b/src/misc/espresso/reduce.c
@@ -18,6 +18,9 @@
#include "espresso.h"
+ABC_NAMESPACE_IMPL_START
+
+
static bool toggle = TRUE;
@@ -256,3 +259,5 @@ OUT pcube *result; /* returned only if answer determined */
/* Not much we can do about it */
return MAYBE;
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/espresso/rows.c b/src/misc/espresso/rows.c
index bf0c0baa..b807153e 100644
--- a/src/misc/espresso/rows.c
+++ b/src/misc/espresso/rows.c
@@ -10,6 +10,9 @@
//#include "port.h"
#include "sparse_int.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*
* allocate a new row vector
@@ -312,3 +315,5 @@ sm_row *prow;
(void) fprintf(fp, " %d", p->col_num);
}
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/espresso/set.c b/src/misc/espresso/set.c
index e3629343..fc78f484 100644
--- a/src/misc/espresso/set.c
+++ b/src/misc/espresso/set.c
@@ -14,6 +14,9 @@
/* LINTLIBRARY */
#include "espresso.h"
+
+ABC_NAMESPACE_IMPL_START
+
static pset_family set_family_garbage = NULL;
static void intcpy(d, s, n)
@@ -818,3 +821,5 @@ register int *permute, npermute;
sf_free(A);
return B;
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/espresso/setc.c b/src/misc/espresso/setc.c
index 64130ec5..976ff478 100644
--- a/src/misc/espresso/setc.c
+++ b/src/misc/espresso/setc.c
@@ -49,6 +49,9 @@
#include "espresso.h"
+ABC_NAMESPACE_IMPL_START
+
+
/* see if the cube has a full row of 1's (with respect to cof) */
bool full_row(p, cof)
IN register pcube p, cof;
@@ -481,3 +484,5 @@ register pset a, b;
}
return 0;
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/espresso/sharp.c b/src/misc/espresso/sharp.c
index 53435078..25c49844 100644
--- a/src/misc/espresso/sharp.c
+++ b/src/misc/espresso/sharp.c
@@ -13,6 +13,9 @@
#include "espresso.h"
+ABC_NAMESPACE_IMPL_START
+
+
long start_time;
@@ -245,3 +248,5 @@ pcover A, B;
Tsave = sf_union(Tsave, sf_contain(T));
return Tsave;
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/espresso/sminterf.c b/src/misc/espresso/sminterf.c
index 50a6db4e..d1abe534 100644
--- a/src/misc/espresso/sminterf.c
+++ b/src/misc/espresso/sminterf.c
@@ -9,6 +9,9 @@
*/
#include "espresso.h"
+ABC_NAMESPACE_IMPL_START
+
+
pset
do_sm_minimum_cover(A)
@@ -42,3 +45,5 @@ pset_family A;
return cover;
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/espresso/solution.c b/src/misc/espresso/solution.c
index 26119185..c76407de 100644
--- a/src/misc/espresso/solution.c
+++ b/src/misc/espresso/solution.c
@@ -9,6 +9,9 @@
*/
#include "mincov_int.h"
+ABC_NAMESPACE_IMPL_START
+
+
solution_t *
solution_alloc()
@@ -112,3 +115,5 @@ solution_t *best1, *best2;
}
}
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/espresso/sparse.c b/src/misc/espresso/sparse.c
index 137ce7c1..919aeca6 100644
--- a/src/misc/espresso/sparse.c
+++ b/src/misc/espresso/sparse.c
@@ -20,6 +20,9 @@
#include "espresso.h"
+ABC_NAMESPACE_IMPL_START
+
+
pcover make_sparse(F, D, R)
pcover F, D, R;
{
@@ -144,3 +147,5 @@ pcover F, D;
}
return F;
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/espresso/sparse.h b/src/misc/espresso/sparse.h
index 212a32ed..9a15fc65 100644
--- a/src/misc/espresso/sparse.h
+++ b/src/misc/espresso/sparse.h
@@ -10,6 +10,10 @@
#ifndef SPARSE_H
#define SPARSE_H
+
+ABC_NAMESPACE_HEADER_START
+
+
/*
* sparse.h -- sparse matrix package header file
*/
@@ -132,4 +136,8 @@ extern int sm_col_compare(), sm_col_hash();
extern int sm_row_dominance(), sm_col_dominance(), sm_block_partition();
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif
diff --git a/src/misc/espresso/unate.c b/src/misc/espresso/unate.c
index bd71207f..f50f2a26 100644
--- a/src/misc/espresso/unate.c
+++ b/src/misc/espresso/unate.c
@@ -13,6 +13,9 @@
#include "espresso.h"
+ABC_NAMESPACE_IMPL_START
+
+
static pset_family abs_covered();
static pset_family abs_covered_many();
static int abs_select_restricted();
@@ -439,3 +442,5 @@ pset restrict;
return best_var;
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/espresso/util_old.h b/src/misc/espresso/util_old.h
index 5451cbe9..32be6ffa 100644
--- a/src/misc/espresso/util_old.h
+++ b/src/misc/espresso/util_old.h
@@ -240,7 +240,8 @@ extern long random();
/*
#if !defined(__osf__)
-#define MAXPATHLEN 1024
+#define MAXPATHLEN
+ 1024
#endif
*/
@@ -298,4 +299,11 @@ extern char *util_optarg;
#endif
#include <varargs.h>
+
+ABC_NAMESPACE_HEADER_START
+
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif
diff --git a/src/misc/espresso/verify.c b/src/misc/espresso/verify.c
index e5340724..992e4d74 100644
--- a/src/misc/espresso/verify.c
+++ b/src/misc/espresso/verify.c
@@ -12,6 +12,9 @@
#include "espresso.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*
* verify -- check that all minterms of F are contained in (Fold u Dold)
* and that all minterms of Fold are contained in (F u Dold).
@@ -191,3 +194,5 @@ pPLA PLA;
(void) fflush(stdout);
return verify_error;
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/ext/ext.h b/src/misc/ext/ext.h
new file mode 100644
index 00000000..8db5a056
--- /dev/null
+++ b/src/misc/ext/ext.h
@@ -0,0 +1,57 @@
+/**CFile****************************************************************
+
+ FileName [ext.h]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName []
+
+ Synopsis [plugin for external functionality]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: ext.h,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#ifndef __EXT_H__
+#define __EXT_H__
+
+#define EXT_ABC_FRAME
+#define EXT_ABC_INIT(pAbc)
+#define EXT_ABC_END(pAbc)
+
+////////////////////////////////////////////////////////////////////////
+/// INCLUDES ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// PARAMETERS ///
+////////////////////////////////////////////////////////////////////////
+
+ABC_NAMESPACE_HEADER_START
+
+////////////////////////////////////////////////////////////////////////
+/// BASIC TYPES ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// MACRO DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+ABC_NAMESPACE_HEADER_END
+
+#endif
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
diff --git a/src/misc/extra/extra.h b/src/misc/extra/extra.h
index dc2c2b0b..96ff6072 100644
--- a/src/misc/extra/extra.h
+++ b/src/misc/extra/extra.h
@@ -29,6 +29,7 @@
#ifndef __EXTRA_H__
#define __EXTRA_H__
+
#ifdef _WIN32
#define inline __inline // compatible with MS VS 6.0
#endif
@@ -42,13 +43,14 @@
#include <string.h>
#include <assert.h>
#include <time.h>
-#include "abc_global.h"
+
#include "st.h"
#include "cuddInt.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
@@ -173,6 +175,7 @@ extern DdNode * Extra_bddMove( DdManager * dd, DdNode * bF, int nVars );
extern DdNode * extraBddMove( DdManager * dd, DdNode * bF, DdNode * bFlag );
extern void Extra_StopManager( DdManager * dd );
extern void Extra_bddPrint( DdManager * dd, DdNode * F );
+extern void Extra_bddPrintSupport( DdManager * dd, DdNode * F );
extern void extraDecomposeCover( DdManager* dd, DdNode* zC, DdNode** zC0, DdNode** zC1, DdNode** zC2 );
extern int Extra_bddSuppSize( DdManager * dd, DdNode * bSupp );
extern int Extra_bddSuppContainVar( DdManager * dd, DdNode * bS, DdNode * bVar );
@@ -325,6 +328,7 @@ extern char * Extra_FileNameGeneric( char * FileName );
extern char * Extra_FileNameGenericAppend( char * pBase, char * pSuffix );
extern int Extra_FileSize( char * pFileName );
extern char * Extra_FileRead( FILE * pFile );
+extern int Extra_FileIsType( char * pFileName, char * pS1, char * pS2, char * pS3 );
extern char * Extra_TimeStamp();
extern char * Extra_StringAppend( char * pStrGiven, char * pStrAdd );
extern unsigned Extra_ReadBinary( char * Buffer );
@@ -332,7 +336,7 @@ extern void Extra_PrintBinary( FILE * pFile, unsigned Sign[], int nBits
extern int Extra_ReadHexadecimal( unsigned Sign[], char * pString, int nVars );
extern void Extra_PrintHexadecimal( FILE * pFile, unsigned Sign[], int nVars );
extern void Extra_PrintHexadecimalString( char * pString, unsigned Sign[], int nVars );
-extern void Extra_PrintHex( FILE * pFile, unsigned uTruth, int nVars );
+extern void Extra_PrintHex( FILE * pFile, unsigned * pTruth, int nVars );
extern void Extra_PrintSymbols( FILE * pFile, char Char, int nTimes, int fPrintNewLine );
/*=== extraUtilReader.c ========================================================*/
@@ -437,8 +441,10 @@ static inline void Extra_ProgressBarUpdate( ProgressBar * p, int nItemsCur, char
/*=== extraUtilTruth.c ================================================================*/
-static inline int Extra_Float2Int( float Val ) { return *((int *)&Val); }
-static inline float Extra_Int2Float( int Num ) { return *((float *)&Num); }
+//static inline int Extra_Float2Int( float Val ) { return *((int *)&Val); }
+//static inline float Extra_Int2Float( int Num ) { return *((float *)&Num); }
+static inline int Extra_Float2Int( float Val ) { union { int x; float y; } v; v.y = Val; return v.x; }
+static inline float Extra_Int2Float( int Num ) { union { int x; float y; } v; v.x = Num; return v.y; }
static inline int Extra_BitWordNum( int nBits ) { return nBits/(8*sizeof(unsigned)) + ((nBits%(8*sizeof(unsigned))) > 0); }
static inline int Extra_TruthWordNum( int nVars ) { return nVars <= 5 ? 1 : (1 << (nVars - 5)); }
@@ -590,20 +596,22 @@ extern long Extra_CpuTime();
extern double Extra_CpuTimeDouble();
extern int Extra_GetSoftDataLimit();
extern ABC_DLL void Extra_UtilGetoptReset();
-extern int Extra_UtilGetopt( int argc, char *argv[], char *optstring );
+extern int Extra_UtilGetopt( int argc, char *argv[], const char *optstring );
extern char * Extra_UtilPrintTime( long t );
-extern char * Extra_UtilStrsav( char *s );
+extern char * Extra_UtilStrsav( const char *s );
extern char * Extra_UtilTildeExpand( char *fname );
extern char * Extra_UtilFileSearch( char *file, char *path, char *mode );
-extern void (*Extra_UtilMMoutOfMemory)();
+extern void (*Extra_UtilMMoutOfMemory)( long size );
-extern char * globalUtilOptarg;
+extern const char * globalUtilOptarg;
extern int globalUtilOptind;
/**AutomaticEnd***************************************************************/
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif /* __EXTRA_H__ */
diff --git a/src/misc/extra/extraBddAuto.c b/src/misc/extra/extraBddAuto.c
index ebafb3a8..3b0e2aa0 100644
--- a/src/misc/extra/extraBddAuto.c
+++ b/src/misc/extra/extraBddAuto.c
@@ -18,6 +18,9 @@
#include "extra.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -1556,3 +1559,5 @@ DdNode * extraBddSpaceFromMatrixNeg( DdManager * dd, DdNode * zA )
/* Definition of static functions */
/*---------------------------------------------------------------------------*/
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/extra/extraBddCas.c b/src/misc/extra/extraBddCas.c
index ccf7397d..14de2d2b 100644
--- a/src/misc/extra/extraBddCas.c
+++ b/src/misc/extra/extraBddCas.c
@@ -18,6 +18,9 @@
#include "extra.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -266,7 +269,7 @@ st_table * Extra_bddNodePathsUnderCut( DdManager * dd, DdNode * bFunc, int CutLe
s_CutLevel = CutLevel;
- Result = st_init_table(st_ptrcmp,st_ptrhash);
+ Result = st_init_table(st_ptrcmp, st_ptrhash);;
// the terminal cases
if ( Cudd_IsConstant( bFunc ) )
{
@@ -290,8 +293,8 @@ st_table * Extra_bddNodePathsUnderCut( DdManager * dd, DdNode * bFunc, int CutLe
// Step 1: Start the tables and collect information about the nodes above the cut
// this information tells how many edges point to each node
- Visited = st_init_table(st_ptrcmp,st_ptrhash);
- CutNodes = st_init_table(st_ptrcmp,st_ptrhash);
+ Visited = st_init_table(st_ptrcmp, st_ptrhash);;
+ CutNodes = st_init_table(st_ptrcmp, st_ptrhash);;
CountNodeVisits_rec( dd, aFunc, Visited );
@@ -303,7 +306,7 @@ st_table * Extra_bddNodePathsUnderCut( DdManager * dd, DdNode * bFunc, int CutLe
st_generator * gen;
DdNode * aNode;
traventry * p;
- st_foreach_item( Visited, gen, (char**)&aNode, (char**)&p )
+ st_foreach_item( Visited, gen, (const char**)&aNode, (char**)&p )
{
Cudd_RecursiveDeref( dd, p->bSum );
ABC_FREE( p );
@@ -315,7 +318,7 @@ st_table * Extra_bddNodePathsUnderCut( DdManager * dd, DdNode * bFunc, int CutLe
{
st_generator * gen;
DdNode * aNode, * bNode, * bSum;
- st_foreach_item( CutNodes, gen, (char**)&aNode, (char**)&bSum)
+ st_foreach_item( CutNodes, gen, (const char**)&aNode, (char**)&bSum)
{
// aNode is not referenced, because aFunc is holding it
bNode = Cudd_addBddPattern( dd, aNode ); Cudd_Ref( bNode );
@@ -376,8 +379,8 @@ int Extra_bddNodePathsUnderCutArray( DdManager * dd, DdNode ** paNodes, DdNode *
// Step 1: Start the table and collect information about the nodes above the cut
// this information tells how many edges point to each node
- CutNodes = st_init_table(st_ptrcmp,st_ptrhash);
- Visited = st_init_table(st_ptrcmp,st_ptrhash);
+ CutNodes = st_init_table(st_ptrcmp, st_ptrhash);;
+ Visited = st_init_table(st_ptrcmp, st_ptrhash);;
for ( i = 0; i < nNodes; i++ )
CountNodeVisits_rec( dd, paNodes[i], Visited );
@@ -391,7 +394,7 @@ int Extra_bddNodePathsUnderCutArray( DdManager * dd, DdNode ** paNodes, DdNode *
st_generator * gen;
DdNode * aNode;
traventry * p;
- st_foreach_item( Visited, gen, (char**)&aNode, (char**)&p )
+ st_foreach_item( Visited, gen, (const char**)&aNode, (char**)&p )
{
Cudd_RecursiveDeref( dd, p->bSum );
ABC_FREE( p );
@@ -404,7 +407,7 @@ int Extra_bddNodePathsUnderCutArray( DdManager * dd, DdNode ** paNodes, DdNode *
st_generator * gen;
DdNode * aNode, * bSum;
Counter = 0;
- st_foreach_item( CutNodes, gen, (char**)&aNode, (char**)&bSum)
+ st_foreach_item( CutNodes, gen, (const char**)&aNode, (char**)&bSum)
{
paNodesRes[Counter] = aNode; Cudd_Ref( aNode );
pbCubesRes[Counter] = bSum;
@@ -525,7 +528,7 @@ int Extra_ProfileWidth( DdManager * dd, DdNode * Func, int * pProfile, int CutLe
int WidthMax;
// start the mapping table
- tNodeTopRef = st_init_table(st_ptrcmp,st_ptrhash);
+ tNodeTopRef = st_init_table(st_ptrcmp, st_ptrhash);;
// add the topmost node to the profile
extraProfileUpdateTopLevel( tNodeTopRef, 0, Func );
@@ -533,7 +536,7 @@ int Extra_ProfileWidth( DdManager * dd, DdNode * Func, int * pProfile, int CutLe
tNodes = Extra_CollectNodes( Func );
// go though all the nodes and set the top level the cofactors are pointed from
// Cudd_ForeachNode( dd, Func, genDD, node )
- st_foreach_item( tNodes, gen, (char**)&node, NULL )
+ st_foreach_item( tNodes, gen, (const char**)&node, NULL )
{
// assert( Cudd_Regular(node) ); // this procedure works only with ADD/ZDD (not BDD w/ compl.edges)
nodeR = Cudd_Regular(node);
@@ -551,7 +554,7 @@ int Extra_ProfileWidth( DdManager * dd, DdNode * Func, int * pProfile, int CutLe
pProfile[i] = 0;
// create the profile
- st_foreach_item( tNodeTopRef, gen, (char**)&node, (char**)&LevelStart )
+ st_foreach_item( tNodeTopRef, gen, (const char**)&node, (char**)&LevelStart )
{
nodeR = Cudd_Regular(node);
Limit = (cuddIsConstant(nodeR))? dd->size: dd->perm[nodeR->index];
@@ -634,7 +637,7 @@ DdNode * CreateTheCodes_rec( DdManager * dd, DdNode * bEncoded, int Level, DdNod
st_generator * gen;
DdNode * bColumn, * bCode;
nCols = 0;
- st_foreach_item( CutNodes, gen, (char**)&bCode, (char**)&bColumn )
+ st_foreach_item( CutNodes, gen, (const char**)&bCode, (char**)&bColumn )
{
if ( bCode == b0 )
{ // the unused part of the columns
@@ -1228,3 +1231,5 @@ void CollectNodesAndComputePaths_rec( DdManager * dd, DdNode * aFunc, DdNode * b
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/extra/extraBddImage.c b/src/misc/extra/extraBddImage.c
index 11d60a40..38c18f63 100644
--- a/src/misc/extra/extraBddImage.c
+++ b/src/misc/extra/extraBddImage.c
@@ -18,6 +18,9 @@
#include "extra.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*
The ideas implemented in this file are inspired by the paper:
Pankaj Chauhan, Edmund Clarke, Somesh Jha, Jim Kukula, Tom Shiple,
@@ -1155,3 +1158,5 @@ DdNode * Extra_bddImageRead2( Extra_ImageTree2_t * pTree )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/extra/extraBddKmap.c b/src/misc/extra/extraBddKmap.c
index 6b54b450..5f384bc9 100644
--- a/src/misc/extra/extraBddKmap.c
+++ b/src/misc/extra/extraBddKmap.c
@@ -22,6 +22,9 @@
#include "extra.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -283,6 +286,7 @@ void Extra_PrintKMap(
// determine the Karnaugh map parameters
nVarsVer = nVars/2;
nVarsHor = nVars - nVarsVer;
+
nCellsVer = (1<<nVarsVer);
nCellsHor = (1<<nVarsHor);
nSkipSpaces = nVarsVer + 1;
@@ -801,3 +805,5 @@ int BinCode ( int GrayCode )
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/extra/extraBddMisc.c b/src/misc/extra/extraBddMisc.c
index 0c285fc7..cdded9b8 100644
--- a/src/misc/extra/extraBddMisc.c
+++ b/src/misc/extra/extraBddMisc.c
@@ -20,6 +20,9 @@
#include "extra.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -285,6 +288,25 @@ void Extra_bddPrint( DdManager * dd, DdNode * F )
/**Function********************************************************************
+ Synopsis [Outputs the BDD in a readable format.]
+
+ Description []
+
+ SideEffects [None]
+
+ SeeAlso []
+
+******************************************************************************/
+void Extra_bddPrintSupport( DdManager * dd, DdNode * F )
+{
+ DdNode * bSupp;
+ bSupp = Cudd_Support( dd, F ); Cudd_Ref( bSupp );
+ Extra_bddPrint( dd, bSupp );
+ Cudd_RecursiveDeref( dd, bSupp );
+}
+
+/**Function********************************************************************
+
Synopsis [Returns the size of the support.]
Description []
@@ -1164,7 +1186,7 @@ DdNode * extraTransferPermute( DdManager * ddS, DdManager * ddD, DdNode * f, int
gen = st_init_gen( table );
if ( gen == NULL )
goto failure;
- while ( st_gen( gen, ( char ** ) &key, ( char ** ) &value ) )
+ while ( st_gen( gen, ( const char ** ) &key, ( char ** ) &value ) )
{
Cudd_RecursiveDeref( ddD, value );
}
@@ -1642,3 +1664,5 @@ cuddBddPermuteRecur( DdManager * manager /* DD manager */ ,
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/extra/extraBddSymm.c b/src/misc/extra/extraBddSymm.c
index e42130d4..0adcbd2a 100644
--- a/src/misc/extra/extraBddSymm.c
+++ b/src/misc/extra/extraBddSymm.c
@@ -21,6 +21,9 @@
#include "extra.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -1467,3 +1470,5 @@ DdNode * extraZddSelectOneSubset(
/*---------------------------------------------------------------------------*/
/* Definition of static Functions */
/*---------------------------------------------------------------------------*/
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/extra/extraBddUnate.c b/src/misc/extra/extraBddUnate.c
index 715731bd..3aa18e51 100644
--- a/src/misc/extra/extraBddUnate.c
+++ b/src/misc/extra/extraBddUnate.c
@@ -22,6 +22,9 @@
#include "extra.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -639,3 +642,5 @@ DdNode * extraZddGetSingletonsBoth(
/*---------------------------------------------------------------------------*/
/* Definition of static Functions */
/*---------------------------------------------------------------------------*/
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/extra/extraUtilBitMatrix.c b/src/misc/extra/extraUtilBitMatrix.c
index dd63e05c..c3651fe4 100644
--- a/src/misc/extra/extraUtilBitMatrix.c
+++ b/src/misc/extra/extraUtilBitMatrix.c
@@ -18,6 +18,9 @@
#include "extra.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -413,3 +416,5 @@ int Extra_BitMatrixIsClique( Extra_BitMat_t * pMat )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/extra/extraUtilCanon.c b/src/misc/extra/extraUtilCanon.c
index c9c199d8..99d5dc42 100644
--- a/src/misc/extra/extraUtilCanon.c
+++ b/src/misc/extra/extraUtilCanon.c
@@ -20,6 +20,9 @@
#include "extra.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -36,8 +39,303 @@
/* Variable declarations */
/*---------------------------------------------------------------------------*/
-static unsigned s_Truths3[256];
-static char s_Phases3[256][9];
+
+static unsigned s_Truths3[256] =
+{
+ 0x00000000, 0x01010101, 0x01010101, 0x03030303, 0x01010101, 0x05050505, 0x06060606, 0x07070707,
+ 0x01010101, 0x06060606, 0x05050505, 0x07070707, 0x03030303, 0x07070707, 0x07070707, 0x0f0f0f0f,
+ 0x01010101, 0x11111111, 0x12121212, 0x13131313, 0x14141414, 0x15151515, 0x16161616, 0x17171717,
+ 0x18181818, 0x19191919, 0x1a1a1a1a, 0x1b1b1b1b, 0x1c1c1c1c, 0x1d1d1d1d, 0x1e1e1e1e, 0x1f1f1f1f,
+ 0x01010101, 0x12121212, 0x11111111, 0x13131313, 0x18181818, 0x1a1a1a1a, 0x19191919, 0x1b1b1b1b,
+ 0x14141414, 0x16161616, 0x15151515, 0x17171717, 0x1c1c1c1c, 0x1e1e1e1e, 0x1d1d1d1d, 0x1f1f1f1f,
+ 0x03030303, 0x13131313, 0x13131313, 0x33333333, 0x1c1c1c1c, 0x35353535, 0x36363636, 0x37373737,
+ 0x1c1c1c1c, 0x36363636, 0x35353535, 0x37373737, 0x3c3c3c3c, 0x3d3d3d3d, 0x3d3d3d3d, 0x3f3f3f3f,
+ 0x01010101, 0x14141414, 0x18181818, 0x1c1c1c1c, 0x11111111, 0x15151515, 0x19191919, 0x1d1d1d1d,
+ 0x12121212, 0x16161616, 0x1a1a1a1a, 0x1e1e1e1e, 0x13131313, 0x17171717, 0x1b1b1b1b, 0x1f1f1f1f,
+ 0x05050505, 0x15151515, 0x1a1a1a1a, 0x35353535, 0x15151515, 0x55555555, 0x56565656, 0x57575757,
+ 0x1a1a1a1a, 0x56565656, 0x5a5a5a5a, 0x5b5b5b5b, 0x35353535, 0x57575757, 0x5b5b5b5b, 0x5f5f5f5f,
+ 0x06060606, 0x16161616, 0x19191919, 0x36363636, 0x19191919, 0x56565656, 0x66666666, 0x67676767,
+ 0x16161616, 0x69696969, 0x56565656, 0x6b6b6b6b, 0x36363636, 0x6b6b6b6b, 0x67676767, 0x6f6f6f6f,
+ 0x07070707, 0x17171717, 0x1b1b1b1b, 0x37373737, 0x1d1d1d1d, 0x57575757, 0x67676767, 0x77777777,
+ 0x1e1e1e1e, 0x6b6b6b6b, 0x5b5b5b5b, 0x7b7b7b7b, 0x3d3d3d3d, 0x7d7d7d7d, 0x7e7e7e7e, 0x7f7f7f7f,
+ 0x01010101, 0x18181818, 0x14141414, 0x1c1c1c1c, 0x12121212, 0x1a1a1a1a, 0x16161616, 0x1e1e1e1e,
+ 0x11111111, 0x19191919, 0x15151515, 0x1d1d1d1d, 0x13131313, 0x1b1b1b1b, 0x17171717, 0x1f1f1f1f,
+ 0x06060606, 0x19191919, 0x16161616, 0x36363636, 0x16161616, 0x56565656, 0x69696969, 0x6b6b6b6b,
+ 0x19191919, 0x66666666, 0x56565656, 0x67676767, 0x36363636, 0x67676767, 0x6b6b6b6b, 0x6f6f6f6f,
+ 0x05050505, 0x1a1a1a1a, 0x15151515, 0x35353535, 0x1a1a1a1a, 0x5a5a5a5a, 0x56565656, 0x5b5b5b5b,
+ 0x15151515, 0x56565656, 0x55555555, 0x57575757, 0x35353535, 0x5b5b5b5b, 0x57575757, 0x5f5f5f5f,
+ 0x07070707, 0x1b1b1b1b, 0x17171717, 0x37373737, 0x1e1e1e1e, 0x5b5b5b5b, 0x6b6b6b6b, 0x7b7b7b7b,
+ 0x1d1d1d1d, 0x67676767, 0x57575757, 0x77777777, 0x3d3d3d3d, 0x7e7e7e7e, 0x7d7d7d7d, 0x7f7f7f7f,
+ 0x03030303, 0x1c1c1c1c, 0x1c1c1c1c, 0x3c3c3c3c, 0x13131313, 0x35353535, 0x36363636, 0x3d3d3d3d,
+ 0x13131313, 0x36363636, 0x35353535, 0x3d3d3d3d, 0x33333333, 0x37373737, 0x37373737, 0x3f3f3f3f,
+ 0x07070707, 0x1d1d1d1d, 0x1e1e1e1e, 0x3d3d3d3d, 0x17171717, 0x57575757, 0x6b6b6b6b, 0x7d7d7d7d,
+ 0x1b1b1b1b, 0x67676767, 0x5b5b5b5b, 0x7e7e7e7e, 0x37373737, 0x77777777, 0x7b7b7b7b, 0x7f7f7f7f,
+ 0x07070707, 0x1e1e1e1e, 0x1d1d1d1d, 0x3d3d3d3d, 0x1b1b1b1b, 0x5b5b5b5b, 0x67676767, 0x7e7e7e7e,
+ 0x17171717, 0x6b6b6b6b, 0x57575757, 0x7d7d7d7d, 0x37373737, 0x7b7b7b7b, 0x77777777, 0x7f7f7f7f,
+ 0x0f0f0f0f, 0x1f1f1f1f, 0x1f1f1f1f, 0x3f3f3f3f, 0x1f1f1f1f, 0x5f5f5f5f, 0x6f6f6f6f, 0x7f7f7f7f,
+ 0x1f1f1f1f, 0x6f6f6f6f, 0x5f5f5f5f, 0x7f7f7f7f, 0x3f3f3f3f, 0x7f7f7f7f, 0x7f7f7f7f, 0xffffffff
+};
+
+static char s_Phases3[256][9] =
+{
+/* 0 */ { 8, 0, 1, 2, 3, 4, 5, 6, 7 },
+/* 1 */ { 1, 0 },
+/* 2 */ { 1, 1 },
+/* 3 */ { 2, 0, 1 },
+/* 4 */ { 1, 2 },
+/* 5 */ { 2, 0, 2 },
+/* 6 */ { 2, 0, 3 },
+/* 7 */ { 1, 0 },
+/* 8 */ { 1, 3 },
+/* 9 */ { 2, 1, 2 },
+/* 10 */ { 2, 1, 3 },
+/* 11 */ { 1, 1 },
+/* 12 */ { 2, 2, 3 },
+/* 13 */ { 1, 2 },
+/* 14 */ { 1, 3 },
+/* 15 */ { 4, 0, 1, 2, 3 },
+/* 16 */ { 1, 4 },
+/* 17 */ { 2, 0, 4 },
+/* 18 */ { 2, 0, 5 },
+/* 19 */ { 1, 0 },
+/* 20 */ { 2, 0, 6 },
+/* 21 */ { 1, 0 },
+/* 22 */ { 1, 0 },
+/* 23 */ { 1, 0 },
+/* 24 */ { 2, 0, 7 },
+/* 25 */ { 1, 0 },
+/* 26 */ { 1, 0 },
+/* 27 */ { 1, 0 },
+/* 28 */ { 1, 0 },
+/* 29 */ { 1, 0 },
+/* 30 */ { 1, 0 },
+/* 31 */ { 1, 0 },
+/* 32 */ { 1, 5 },
+/* 33 */ { 2, 1, 4 },
+/* 34 */ { 2, 1, 5 },
+/* 35 */ { 1, 1 },
+/* 36 */ { 2, 1, 6 },
+/* 37 */ { 1, 1 },
+/* 38 */ { 1, 1 },
+/* 39 */ { 1, 1 },
+/* 40 */ { 2, 1, 7 },
+/* 41 */ { 1, 1 },
+/* 42 */ { 1, 1 },
+/* 43 */ { 1, 1 },
+/* 44 */ { 1, 1 },
+/* 45 */ { 1, 1 },
+/* 46 */ { 1, 1 },
+/* 47 */ { 1, 1 },
+/* 48 */ { 2, 4, 5 },
+/* 49 */ { 1, 4 },
+/* 50 */ { 1, 5 },
+/* 51 */ { 4, 0, 1, 4, 5 },
+/* 52 */ { 1, 6 },
+/* 53 */ { 1, 0 },
+/* 54 */ { 1, 0 },
+/* 55 */ { 1, 0 },
+/* 56 */ { 1, 7 },
+/* 57 */ { 1, 1 },
+/* 58 */ { 1, 1 },
+/* 59 */ { 1, 1 },
+/* 60 */ { 4, 0, 1, 6, 7 },
+/* 61 */ { 1, 0 },
+/* 62 */ { 1, 1 },
+/* 63 */ { 2, 0, 1 },
+/* 64 */ { 1, 6 },
+/* 65 */ { 2, 2, 4 },
+/* 66 */ { 2, 2, 5 },
+/* 67 */ { 1, 2 },
+/* 68 */ { 2, 2, 6 },
+/* 69 */ { 1, 2 },
+/* 70 */ { 1, 2 },
+/* 71 */ { 1, 2 },
+/* 72 */ { 2, 2, 7 },
+/* 73 */ { 1, 2 },
+/* 74 */ { 1, 2 },
+/* 75 */ { 1, 2 },
+/* 76 */ { 1, 2 },
+/* 77 */ { 1, 2 },
+/* 78 */ { 1, 2 },
+/* 79 */ { 1, 2 },
+/* 80 */ { 2, 4, 6 },
+/* 81 */ { 1, 4 },
+/* 82 */ { 1, 5 },
+/* 83 */ { 1, 4 },
+/* 84 */ { 1, 6 },
+/* 85 */ { 4, 0, 2, 4, 6 },
+/* 86 */ { 1, 0 },
+/* 87 */ { 1, 0 },
+/* 88 */ { 1, 7 },
+/* 89 */ { 1, 2 },
+/* 90 */ { 4, 0, 2, 5, 7 },
+/* 91 */ { 1, 0 },
+/* 92 */ { 1, 6 },
+/* 93 */ { 1, 2 },
+/* 94 */ { 1, 2 },
+/* 95 */ { 2, 0, 2 },
+/* 96 */ { 2, 4, 7 },
+/* 97 */ { 1, 4 },
+/* 98 */ { 1, 5 },
+/* 99 */ { 1, 4 },
+/* 100 */ { 1, 6 },
+/* 101 */ { 1, 4 },
+/* 102 */ { 4, 0, 3, 4, 7 },
+/* 103 */ { 1, 0 },
+/* 104 */ { 1, 7 },
+/* 105 */ { 4, 0, 3, 5, 6 },
+/* 106 */ { 1, 7 },
+/* 107 */ { 1, 0 },
+/* 108 */ { 1, 7 },
+/* 109 */ { 1, 3 },
+/* 110 */ { 1, 3 },
+/* 111 */ { 2, 0, 3 },
+/* 112 */ { 1, 4 },
+/* 113 */ { 1, 4 },
+/* 114 */ { 1, 5 },
+/* 115 */ { 1, 4 },
+/* 116 */ { 1, 6 },
+/* 117 */ { 1, 4 },
+/* 118 */ { 1, 4 },
+/* 119 */ { 2, 0, 4 },
+/* 120 */ { 1, 7 },
+/* 121 */ { 1, 5 },
+/* 122 */ { 1, 5 },
+/* 123 */ { 2, 0, 5 },
+/* 124 */ { 1, 6 },
+/* 125 */ { 2, 0, 6 },
+/* 126 */ { 2, 0, 7 },
+/* 127 */ { 1, 0 },
+/* 128 */ { 1, 7 },
+/* 129 */ { 2, 3, 4 },
+/* 130 */ { 2, 3, 5 },
+/* 131 */ { 1, 3 },
+/* 132 */ { 2, 3, 6 },
+/* 133 */ { 1, 3 },
+/* 134 */ { 1, 3 },
+/* 135 */ { 1, 3 },
+/* 136 */ { 2, 3, 7 },
+/* 137 */ { 1, 3 },
+/* 138 */ { 1, 3 },
+/* 139 */ { 1, 3 },
+/* 140 */ { 1, 3 },
+/* 141 */ { 1, 3 },
+/* 142 */ { 1, 3 },
+/* 143 */ { 1, 3 },
+/* 144 */ { 2, 5, 6 },
+/* 145 */ { 1, 4 },
+/* 146 */ { 1, 5 },
+/* 147 */ { 1, 5 },
+/* 148 */ { 1, 6 },
+/* 149 */ { 1, 6 },
+/* 150 */ { 4, 1, 2, 4, 7 },
+/* 151 */ { 1, 1 },
+/* 152 */ { 1, 7 },
+/* 153 */ { 4, 1, 2, 5, 6 },
+/* 154 */ { 1, 5 },
+/* 155 */ { 1, 1 },
+/* 156 */ { 1, 6 },
+/* 157 */ { 1, 2 },
+/* 158 */ { 1, 2 },
+/* 159 */ { 2, 1, 2 },
+/* 160 */ { 2, 5, 7 },
+/* 161 */ { 1, 4 },
+/* 162 */ { 1, 5 },
+/* 163 */ { 1, 5 },
+/* 164 */ { 1, 6 },
+/* 165 */ { 4, 1, 3, 4, 6 },
+/* 166 */ { 1, 3 },
+/* 167 */ { 1, 1 },
+/* 168 */ { 1, 7 },
+/* 169 */ { 1, 1 },
+/* 170 */ { 4, 1, 3, 5, 7 },
+/* 171 */ { 1, 1 },
+/* 172 */ { 1, 7 },
+/* 173 */ { 1, 3 },
+/* 174 */ { 1, 3 },
+/* 175 */ { 2, 1, 3 },
+/* 176 */ { 1, 5 },
+/* 177 */ { 1, 4 },
+/* 178 */ { 1, 5 },
+/* 179 */ { 1, 5 },
+/* 180 */ { 1, 6 },
+/* 181 */ { 1, 4 },
+/* 182 */ { 1, 4 },
+/* 183 */ { 2, 1, 4 },
+/* 184 */ { 1, 7 },
+/* 185 */ { 1, 5 },
+/* 186 */ { 1, 5 },
+/* 187 */ { 2, 1, 5 },
+/* 188 */ { 1, 7 },
+/* 189 */ { 2, 1, 6 },
+/* 190 */ { 2, 1, 7 },
+/* 191 */ { 1, 1 },
+/* 192 */ { 2, 6, 7 },
+/* 193 */ { 1, 4 },
+/* 194 */ { 1, 5 },
+/* 195 */ { 4, 2, 3, 4, 5 },
+/* 196 */ { 1, 6 },
+/* 197 */ { 1, 2 },
+/* 198 */ { 1, 3 },
+/* 199 */ { 1, 2 },
+/* 200 */ { 1, 7 },
+/* 201 */ { 1, 2 },
+/* 202 */ { 1, 3 },
+/* 203 */ { 1, 3 },
+/* 204 */ { 4, 2, 3, 6, 7 },
+/* 205 */ { 1, 2 },
+/* 206 */ { 1, 3 },
+/* 207 */ { 2, 2, 3 },
+/* 208 */ { 1, 6 },
+/* 209 */ { 1, 4 },
+/* 210 */ { 1, 5 },
+/* 211 */ { 1, 4 },
+/* 212 */ { 1, 6 },
+/* 213 */ { 1, 6 },
+/* 214 */ { 1, 7 },
+/* 215 */ { 2, 2, 4 },
+/* 216 */ { 1, 7 },
+/* 217 */ { 1, 6 },
+/* 218 */ { 1, 7 },
+/* 219 */ { 2, 2, 5 },
+/* 220 */ { 1, 6 },
+/* 221 */ { 2, 2, 6 },
+/* 222 */ { 2, 2, 7 },
+/* 223 */ { 1, 2 },
+/* 224 */ { 1, 7 },
+/* 225 */ { 1, 4 },
+/* 226 */ { 1, 5 },
+/* 227 */ { 1, 5 },
+/* 228 */ { 1, 6 },
+/* 229 */ { 1, 6 },
+/* 230 */ { 1, 7 },
+/* 231 */ { 2, 3, 4 },
+/* 232 */ { 1, 7 },
+/* 233 */ { 1, 6 },
+/* 234 */ { 1, 7 },
+/* 235 */ { 2, 3, 5 },
+/* 236 */ { 1, 7 },
+/* 237 */ { 2, 3, 6 },
+/* 238 */ { 2, 3, 7 },
+/* 239 */ { 1, 3 },
+/* 240 */ { 4, 4, 5, 6, 7 },
+/* 241 */ { 1, 4 },
+/* 242 */ { 1, 5 },
+/* 243 */ { 2, 4, 5 },
+/* 244 */ { 1, 6 },
+/* 245 */ { 2, 4, 6 },
+/* 246 */ { 2, 4, 7 },
+/* 247 */ { 1, 4 },
+/* 248 */ { 1, 7 },
+/* 249 */ { 2, 5, 6 },
+/* 250 */ { 2, 5, 7 },
+/* 251 */ { 1, 5 },
+/* 252 */ { 2, 6, 7 },
+/* 253 */ { 1, 6 },
+/* 254 */ { 1, 7 },
+/* 255 */ { 8, 0, 1, 2, 3, 4, 5, 6, 7 }
+};
+
/*---------------------------------------------------------------------------*/
/* Macro declarations */
@@ -299,7 +597,7 @@ void Map_Var3Print()
{
if ( i % 8 == 0 )
printf( "\n" );
- Extra_PrintHex( stdout, uCanons[i], 5 );
+ Extra_PrintHex( stdout, uCanons + i, 5 );
printf( ", " );
}
printf( "\n" );
@@ -384,305 +682,10 @@ void Map_Var4Test()
/* Definition of static Functions */
/*---------------------------------------------------------------------------*/
-static unsigned s_Truths3[256] =
-{
- 0x00000000, 0x01010101, 0x01010101, 0x03030303, 0x01010101, 0x05050505, 0x06060606, 0x07070707,
- 0x01010101, 0x06060606, 0x05050505, 0x07070707, 0x03030303, 0x07070707, 0x07070707, 0x0f0f0f0f,
- 0x01010101, 0x11111111, 0x12121212, 0x13131313, 0x14141414, 0x15151515, 0x16161616, 0x17171717,
- 0x18181818, 0x19191919, 0x1a1a1a1a, 0x1b1b1b1b, 0x1c1c1c1c, 0x1d1d1d1d, 0x1e1e1e1e, 0x1f1f1f1f,
- 0x01010101, 0x12121212, 0x11111111, 0x13131313, 0x18181818, 0x1a1a1a1a, 0x19191919, 0x1b1b1b1b,
- 0x14141414, 0x16161616, 0x15151515, 0x17171717, 0x1c1c1c1c, 0x1e1e1e1e, 0x1d1d1d1d, 0x1f1f1f1f,
- 0x03030303, 0x13131313, 0x13131313, 0x33333333, 0x1c1c1c1c, 0x35353535, 0x36363636, 0x37373737,
- 0x1c1c1c1c, 0x36363636, 0x35353535, 0x37373737, 0x3c3c3c3c, 0x3d3d3d3d, 0x3d3d3d3d, 0x3f3f3f3f,
- 0x01010101, 0x14141414, 0x18181818, 0x1c1c1c1c, 0x11111111, 0x15151515, 0x19191919, 0x1d1d1d1d,
- 0x12121212, 0x16161616, 0x1a1a1a1a, 0x1e1e1e1e, 0x13131313, 0x17171717, 0x1b1b1b1b, 0x1f1f1f1f,
- 0x05050505, 0x15151515, 0x1a1a1a1a, 0x35353535, 0x15151515, 0x55555555, 0x56565656, 0x57575757,
- 0x1a1a1a1a, 0x56565656, 0x5a5a5a5a, 0x5b5b5b5b, 0x35353535, 0x57575757, 0x5b5b5b5b, 0x5f5f5f5f,
- 0x06060606, 0x16161616, 0x19191919, 0x36363636, 0x19191919, 0x56565656, 0x66666666, 0x67676767,
- 0x16161616, 0x69696969, 0x56565656, 0x6b6b6b6b, 0x36363636, 0x6b6b6b6b, 0x67676767, 0x6f6f6f6f,
- 0x07070707, 0x17171717, 0x1b1b1b1b, 0x37373737, 0x1d1d1d1d, 0x57575757, 0x67676767, 0x77777777,
- 0x1e1e1e1e, 0x6b6b6b6b, 0x5b5b5b5b, 0x7b7b7b7b, 0x3d3d3d3d, 0x7d7d7d7d, 0x7e7e7e7e, 0x7f7f7f7f,
- 0x01010101, 0x18181818, 0x14141414, 0x1c1c1c1c, 0x12121212, 0x1a1a1a1a, 0x16161616, 0x1e1e1e1e,
- 0x11111111, 0x19191919, 0x15151515, 0x1d1d1d1d, 0x13131313, 0x1b1b1b1b, 0x17171717, 0x1f1f1f1f,
- 0x06060606, 0x19191919, 0x16161616, 0x36363636, 0x16161616, 0x56565656, 0x69696969, 0x6b6b6b6b,
- 0x19191919, 0x66666666, 0x56565656, 0x67676767, 0x36363636, 0x67676767, 0x6b6b6b6b, 0x6f6f6f6f,
- 0x05050505, 0x1a1a1a1a, 0x15151515, 0x35353535, 0x1a1a1a1a, 0x5a5a5a5a, 0x56565656, 0x5b5b5b5b,
- 0x15151515, 0x56565656, 0x55555555, 0x57575757, 0x35353535, 0x5b5b5b5b, 0x57575757, 0x5f5f5f5f,
- 0x07070707, 0x1b1b1b1b, 0x17171717, 0x37373737, 0x1e1e1e1e, 0x5b5b5b5b, 0x6b6b6b6b, 0x7b7b7b7b,
- 0x1d1d1d1d, 0x67676767, 0x57575757, 0x77777777, 0x3d3d3d3d, 0x7e7e7e7e, 0x7d7d7d7d, 0x7f7f7f7f,
- 0x03030303, 0x1c1c1c1c, 0x1c1c1c1c, 0x3c3c3c3c, 0x13131313, 0x35353535, 0x36363636, 0x3d3d3d3d,
- 0x13131313, 0x36363636, 0x35353535, 0x3d3d3d3d, 0x33333333, 0x37373737, 0x37373737, 0x3f3f3f3f,
- 0x07070707, 0x1d1d1d1d, 0x1e1e1e1e, 0x3d3d3d3d, 0x17171717, 0x57575757, 0x6b6b6b6b, 0x7d7d7d7d,
- 0x1b1b1b1b, 0x67676767, 0x5b5b5b5b, 0x7e7e7e7e, 0x37373737, 0x77777777, 0x7b7b7b7b, 0x7f7f7f7f,
- 0x07070707, 0x1e1e1e1e, 0x1d1d1d1d, 0x3d3d3d3d, 0x1b1b1b1b, 0x5b5b5b5b, 0x67676767, 0x7e7e7e7e,
- 0x17171717, 0x6b6b6b6b, 0x57575757, 0x7d7d7d7d, 0x37373737, 0x7b7b7b7b, 0x77777777, 0x7f7f7f7f,
- 0x0f0f0f0f, 0x1f1f1f1f, 0x1f1f1f1f, 0x3f3f3f3f, 0x1f1f1f1f, 0x5f5f5f5f, 0x6f6f6f6f, 0x7f7f7f7f,
- 0x1f1f1f1f, 0x6f6f6f6f, 0x5f5f5f5f, 0x7f7f7f7f, 0x3f3f3f3f, 0x7f7f7f7f, 0x7f7f7f7f, 0xffffffff
-};
-
-static char s_Phases3[256][9] =
-{
-/* 0 */ { 8, 0, 1, 2, 3, 4, 5, 6, 7 },
-/* 1 */ { 1, 0 },
-/* 2 */ { 1, 1 },
-/* 3 */ { 2, 0, 1 },
-/* 4 */ { 1, 2 },
-/* 5 */ { 2, 0, 2 },
-/* 6 */ { 2, 0, 3 },
-/* 7 */ { 1, 0 },
-/* 8 */ { 1, 3 },
-/* 9 */ { 2, 1, 2 },
-/* 10 */ { 2, 1, 3 },
-/* 11 */ { 1, 1 },
-/* 12 */ { 2, 2, 3 },
-/* 13 */ { 1, 2 },
-/* 14 */ { 1, 3 },
-/* 15 */ { 4, 0, 1, 2, 3 },
-/* 16 */ { 1, 4 },
-/* 17 */ { 2, 0, 4 },
-/* 18 */ { 2, 0, 5 },
-/* 19 */ { 1, 0 },
-/* 20 */ { 2, 0, 6 },
-/* 21 */ { 1, 0 },
-/* 22 */ { 1, 0 },
-/* 23 */ { 1, 0 },
-/* 24 */ { 2, 0, 7 },
-/* 25 */ { 1, 0 },
-/* 26 */ { 1, 0 },
-/* 27 */ { 1, 0 },
-/* 28 */ { 1, 0 },
-/* 29 */ { 1, 0 },
-/* 30 */ { 1, 0 },
-/* 31 */ { 1, 0 },
-/* 32 */ { 1, 5 },
-/* 33 */ { 2, 1, 4 },
-/* 34 */ { 2, 1, 5 },
-/* 35 */ { 1, 1 },
-/* 36 */ { 2, 1, 6 },
-/* 37 */ { 1, 1 },
-/* 38 */ { 1, 1 },
-/* 39 */ { 1, 1 },
-/* 40 */ { 2, 1, 7 },
-/* 41 */ { 1, 1 },
-/* 42 */ { 1, 1 },
-/* 43 */ { 1, 1 },
-/* 44 */ { 1, 1 },
-/* 45 */ { 1, 1 },
-/* 46 */ { 1, 1 },
-/* 47 */ { 1, 1 },
-/* 48 */ { 2, 4, 5 },
-/* 49 */ { 1, 4 },
-/* 50 */ { 1, 5 },
-/* 51 */ { 4, 0, 1, 4, 5 },
-/* 52 */ { 1, 6 },
-/* 53 */ { 1, 0 },
-/* 54 */ { 1, 0 },
-/* 55 */ { 1, 0 },
-/* 56 */ { 1, 7 },
-/* 57 */ { 1, 1 },
-/* 58 */ { 1, 1 },
-/* 59 */ { 1, 1 },
-/* 60 */ { 4, 0, 1, 6, 7 },
-/* 61 */ { 1, 0 },
-/* 62 */ { 1, 1 },
-/* 63 */ { 2, 0, 1 },
-/* 64 */ { 1, 6 },
-/* 65 */ { 2, 2, 4 },
-/* 66 */ { 2, 2, 5 },
-/* 67 */ { 1, 2 },
-/* 68 */ { 2, 2, 6 },
-/* 69 */ { 1, 2 },
-/* 70 */ { 1, 2 },
-/* 71 */ { 1, 2 },
-/* 72 */ { 2, 2, 7 },
-/* 73 */ { 1, 2 },
-/* 74 */ { 1, 2 },
-/* 75 */ { 1, 2 },
-/* 76 */ { 1, 2 },
-/* 77 */ { 1, 2 },
-/* 78 */ { 1, 2 },
-/* 79 */ { 1, 2 },
-/* 80 */ { 2, 4, 6 },
-/* 81 */ { 1, 4 },
-/* 82 */ { 1, 5 },
-/* 83 */ { 1, 4 },
-/* 84 */ { 1, 6 },
-/* 85 */ { 4, 0, 2, 4, 6 },
-/* 86 */ { 1, 0 },
-/* 87 */ { 1, 0 },
-/* 88 */ { 1, 7 },
-/* 89 */ { 1, 2 },
-/* 90 */ { 4, 0, 2, 5, 7 },
-/* 91 */ { 1, 0 },
-/* 92 */ { 1, 6 },
-/* 93 */ { 1, 2 },
-/* 94 */ { 1, 2 },
-/* 95 */ { 2, 0, 2 },
-/* 96 */ { 2, 4, 7 },
-/* 97 */ { 1, 4 },
-/* 98 */ { 1, 5 },
-/* 99 */ { 1, 4 },
-/* 100 */ { 1, 6 },
-/* 101 */ { 1, 4 },
-/* 102 */ { 4, 0, 3, 4, 7 },
-/* 103 */ { 1, 0 },
-/* 104 */ { 1, 7 },
-/* 105 */ { 4, 0, 3, 5, 6 },
-/* 106 */ { 1, 7 },
-/* 107 */ { 1, 0 },
-/* 108 */ { 1, 7 },
-/* 109 */ { 1, 3 },
-/* 110 */ { 1, 3 },
-/* 111 */ { 2, 0, 3 },
-/* 112 */ { 1, 4 },
-/* 113 */ { 1, 4 },
-/* 114 */ { 1, 5 },
-/* 115 */ { 1, 4 },
-/* 116 */ { 1, 6 },
-/* 117 */ { 1, 4 },
-/* 118 */ { 1, 4 },
-/* 119 */ { 2, 0, 4 },
-/* 120 */ { 1, 7 },
-/* 121 */ { 1, 5 },
-/* 122 */ { 1, 5 },
-/* 123 */ { 2, 0, 5 },
-/* 124 */ { 1, 6 },
-/* 125 */ { 2, 0, 6 },
-/* 126 */ { 2, 0, 7 },
-/* 127 */ { 1, 0 },
-/* 128 */ { 1, 7 },
-/* 129 */ { 2, 3, 4 },
-/* 130 */ { 2, 3, 5 },
-/* 131 */ { 1, 3 },
-/* 132 */ { 2, 3, 6 },
-/* 133 */ { 1, 3 },
-/* 134 */ { 1, 3 },
-/* 135 */ { 1, 3 },
-/* 136 */ { 2, 3, 7 },
-/* 137 */ { 1, 3 },
-/* 138 */ { 1, 3 },
-/* 139 */ { 1, 3 },
-/* 140 */ { 1, 3 },
-/* 141 */ { 1, 3 },
-/* 142 */ { 1, 3 },
-/* 143 */ { 1, 3 },
-/* 144 */ { 2, 5, 6 },
-/* 145 */ { 1, 4 },
-/* 146 */ { 1, 5 },
-/* 147 */ { 1, 5 },
-/* 148 */ { 1, 6 },
-/* 149 */ { 1, 6 },
-/* 150 */ { 4, 1, 2, 4, 7 },
-/* 151 */ { 1, 1 },
-/* 152 */ { 1, 7 },
-/* 153 */ { 4, 1, 2, 5, 6 },
-/* 154 */ { 1, 5 },
-/* 155 */ { 1, 1 },
-/* 156 */ { 1, 6 },
-/* 157 */ { 1, 2 },
-/* 158 */ { 1, 2 },
-/* 159 */ { 2, 1, 2 },
-/* 160 */ { 2, 5, 7 },
-/* 161 */ { 1, 4 },
-/* 162 */ { 1, 5 },
-/* 163 */ { 1, 5 },
-/* 164 */ { 1, 6 },
-/* 165 */ { 4, 1, 3, 4, 6 },
-/* 166 */ { 1, 3 },
-/* 167 */ { 1, 1 },
-/* 168 */ { 1, 7 },
-/* 169 */ { 1, 1 },
-/* 170 */ { 4, 1, 3, 5, 7 },
-/* 171 */ { 1, 1 },
-/* 172 */ { 1, 7 },
-/* 173 */ { 1, 3 },
-/* 174 */ { 1, 3 },
-/* 175 */ { 2, 1, 3 },
-/* 176 */ { 1, 5 },
-/* 177 */ { 1, 4 },
-/* 178 */ { 1, 5 },
-/* 179 */ { 1, 5 },
-/* 180 */ { 1, 6 },
-/* 181 */ { 1, 4 },
-/* 182 */ { 1, 4 },
-/* 183 */ { 2, 1, 4 },
-/* 184 */ { 1, 7 },
-/* 185 */ { 1, 5 },
-/* 186 */ { 1, 5 },
-/* 187 */ { 2, 1, 5 },
-/* 188 */ { 1, 7 },
-/* 189 */ { 2, 1, 6 },
-/* 190 */ { 2, 1, 7 },
-/* 191 */ { 1, 1 },
-/* 192 */ { 2, 6, 7 },
-/* 193 */ { 1, 4 },
-/* 194 */ { 1, 5 },
-/* 195 */ { 4, 2, 3, 4, 5 },
-/* 196 */ { 1, 6 },
-/* 197 */ { 1, 2 },
-/* 198 */ { 1, 3 },
-/* 199 */ { 1, 2 },
-/* 200 */ { 1, 7 },
-/* 201 */ { 1, 2 },
-/* 202 */ { 1, 3 },
-/* 203 */ { 1, 3 },
-/* 204 */ { 4, 2, 3, 6, 7 },
-/* 205 */ { 1, 2 },
-/* 206 */ { 1, 3 },
-/* 207 */ { 2, 2, 3 },
-/* 208 */ { 1, 6 },
-/* 209 */ { 1, 4 },
-/* 210 */ { 1, 5 },
-/* 211 */ { 1, 4 },
-/* 212 */ { 1, 6 },
-/* 213 */ { 1, 6 },
-/* 214 */ { 1, 7 },
-/* 215 */ { 2, 2, 4 },
-/* 216 */ { 1, 7 },
-/* 217 */ { 1, 6 },
-/* 218 */ { 1, 7 },
-/* 219 */ { 2, 2, 5 },
-/* 220 */ { 1, 6 },
-/* 221 */ { 2, 2, 6 },
-/* 222 */ { 2, 2, 7 },
-/* 223 */ { 1, 2 },
-/* 224 */ { 1, 7 },
-/* 225 */ { 1, 4 },
-/* 226 */ { 1, 5 },
-/* 227 */ { 1, 5 },
-/* 228 */ { 1, 6 },
-/* 229 */ { 1, 6 },
-/* 230 */ { 1, 7 },
-/* 231 */ { 2, 3, 4 },
-/* 232 */ { 1, 7 },
-/* 233 */ { 1, 6 },
-/* 234 */ { 1, 7 },
-/* 235 */ { 2, 3, 5 },
-/* 236 */ { 1, 7 },
-/* 237 */ { 2, 3, 6 },
-/* 238 */ { 2, 3, 7 },
-/* 239 */ { 1, 3 },
-/* 240 */ { 4, 4, 5, 6, 7 },
-/* 241 */ { 1, 4 },
-/* 242 */ { 1, 5 },
-/* 243 */ { 2, 4, 5 },
-/* 244 */ { 1, 6 },
-/* 245 */ { 2, 4, 6 },
-/* 246 */ { 2, 4, 7 },
-/* 247 */ { 1, 4 },
-/* 248 */ { 1, 7 },
-/* 249 */ { 2, 5, 6 },
-/* 250 */ { 2, 5, 7 },
-/* 251 */ { 1, 5 },
-/* 252 */ { 2, 6, 7 },
-/* 253 */ { 1, 6 },
-/* 254 */ { 1, 7 },
-/* 255 */ { 8, 0, 1, 2, 3, 4, 5, 6, 7 }
-};
-
-
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/extra/extraUtilFile.c b/src/misc/extra/extraUtilFile.c
index 96cf8601..2ddec21e 100644
--- a/src/misc/extra/extraUtilFile.c
+++ b/src/misc/extra/extraUtilFile.c
@@ -20,6 +20,9 @@
#include "extra.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -248,6 +251,32 @@ char * Extra_FileRead( FILE * pFile )
/**Function*************************************************************
+ Synopsis [Returns one if the file has a given extension.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Extra_FileIsType( char * pFileName, char * pS1, char * pS2, char * pS3 )
+{
+ int lenS, lenF = strlen(pFileName);
+ lenS = pS1 ? strlen(pS1) : 0;
+ if ( lenS && lenF > lenS && !strncmp( pFileName+lenF-lenS, pS1, lenS ) )
+ return 1;
+ lenS = pS2 ? strlen(pS2) : 0;
+ if ( lenS && lenF > lenS && !strncmp( pFileName+lenF-lenS, pS2, lenS ) )
+ return 1;
+ lenS = pS3 ? strlen(pS3) : 0;
+ if ( lenS && lenF > lenS && !strncmp( pFileName+lenF-lenS, pS3, lenS ) )
+ return 1;
+ return 0;
+}
+
+/**Function*************************************************************
+
Synopsis [Returns the time stamp.]
Description [The file should be closed.]
@@ -425,7 +454,7 @@ void Extra_PrintHexadecimalString( char * pString, unsigned Sign[], int nVars )
SeeAlso []
***********************************************************************/
-void Extra_PrintHex( FILE * pFile, unsigned uTruth, int nVars )
+void Extra_PrintHex( FILE * pFile, unsigned * pTruth, int nVars )
{
int nMints, nDigits, Digit, k;
@@ -435,11 +464,11 @@ void Extra_PrintHex( FILE * pFile, unsigned uTruth, int nVars )
nDigits = nMints / 4;
for ( k = nDigits - 1; k >= 0; k-- )
{
- Digit = ((uTruth >> (k * 4)) & 15);
+ Digit = ((pTruth[k/8] >> (k * 4)) & 15);
if ( Digit < 10 )
fprintf( pFile, "%d", Digit );
else
- fprintf( pFile, "%c", 'a' + Digit-10 );
+ fprintf( pFile, "%c", 'A' + Digit-10 );
}
// fprintf( pFile, "\n" );
}
@@ -505,3 +534,5 @@ char * Extra_StringAppend( char * pStrGiven, char * pStrAdd )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/extra/extraUtilMemory.c b/src/misc/extra/extraUtilMemory.c
index 626d58b5..673887fa 100644
--- a/src/misc/extra/extraUtilMemory.c
+++ b/src/misc/extra/extraUtilMemory.c
@@ -20,6 +20,9 @@
#include "extra.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -35,7 +38,7 @@ struct Extra_MmFixed_t_
int nEntriesAlloc; // the total number of entries allocated
int nEntriesUsed; // the number of entries in use
int nEntriesMax; // the max number of entries in use
- char * pEntriesFree; // the linked list of ABC_FREE entries
+ char * pEntriesFree; // the linked list of free entries
// this is where the memory is stored
int nChunkSize; // the size of one chunk
@@ -52,8 +55,8 @@ struct Extra_MmFlex_t_
{
// information about individual entries
int nEntriesUsed; // the number of entries allocated
- char * pCurrent; // the current pointer to ABC_FREE memory
- char * pEnd; // the first entry outside the ABC_FREE memory
+ char * pCurrent; // the current pointer to free memory
+ char * pEnd; // the first entry outside the free memory
// this is where the memory is stored
int nChunkSize; // the size of one chunk
@@ -201,7 +204,7 @@ char * Extra_MmFixedEntryFetch( Extra_MmFixed_t * p )
char * pTemp;
int i;
- // check if there are still ABC_FREE entries
+ // check if there are still free entries
if ( p->nEntriesUsed == p->nEntriesAlloc )
{ // need to allocate more entries
assert( p->pEntriesFree == NULL );
@@ -230,7 +233,7 @@ char * Extra_MmFixedEntryFetch( Extra_MmFixed_t * p )
p->nEntriesUsed++;
if ( p->nEntriesMax < p->nEntriesUsed )
p->nEntriesMax = p->nEntriesUsed;
- // return the first entry in the ABC_FREE entry list
+ // return the first entry in the free entry list
pTemp = p->pEntriesFree;
p->pEntriesFree = *((char **)pTemp);
return pTemp;
@@ -251,7 +254,7 @@ void Extra_MmFixedEntryRecycle( Extra_MmFixed_t * p, char * pEntry )
{
// decrement the counter of used entries
p->nEntriesUsed--;
- // add the entry to the linked list of ABC_FREE entries
+ // add the entry to the linked list of free entries
*((char **)pEntry) = p->pEntriesFree;
p->pEntriesFree = pEntry;
}
@@ -285,7 +288,7 @@ void Extra_MmFixedRestart( Extra_MmFixed_t * p )
}
// set the last link
*((char **)pTemp) = NULL;
- // set the ABC_FREE entry list
+ // set the free entry list
p->pEntriesFree = p->pChunks[0];
// set the correct statistics
p->nMemoryAlloc = p->nEntrySize * p->nChunkSize;
@@ -415,7 +418,7 @@ void Extra_MmFlexStop( Extra_MmFlex_t * p )
char * Extra_MmFlexEntryFetch( Extra_MmFlex_t * p, int nBytes )
{
char * pTemp;
- // check if there are still ABC_FREE entries
+ // check if there are still free entries
if ( p->pCurrent == NULL || p->pCurrent + nBytes > p->pEnd )
{ // need to allocate more entries
if ( p->nChunks == p->nChunksAlloc )
@@ -565,7 +568,7 @@ char * Extra_MmStepEntryFetch( Extra_MmStep_t * p, int nBytes )
p->pLargeChunks = ABC_REALLOC( void *, p->pLargeChunks, p->nLargeChunksAlloc );
}
p->pLargeChunks[ p->nLargeChunks++ ] = ABC_ALLOC( char, nBytes );
- return p->pLargeChunks[ p->nLargeChunks - 1 ];
+ return (char *)p->pLargeChunks[ p->nLargeChunks - 1 ];
}
return Extra_MmFixedEntryFetch( p->pMap[nBytes] );
}
@@ -621,3 +624,5 @@ int Extra_MmStepReadMemUsage( Extra_MmStep_t * p )
/* Definition of static functions */
/*---------------------------------------------------------------------------*/
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/extra/extraUtilMisc.c b/src/misc/extra/extraUtilMisc.c
index 293b23e7..e4c5acd5 100644
--- a/src/misc/extra/extraUtilMisc.c
+++ b/src/misc/extra/extraUtilMisc.c
@@ -20,6 +20,9 @@
#include "extra.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -70,7 +73,6 @@ static void Extra_Permutations_rec( char ** pRes, int nFact, int n, char Array[]
int Extra_Base2Log( unsigned Num )
{
int Res;
- assert( Num >= 0 );
if ( Num == 0 ) return 0;
if ( Num == 1 ) return 1;
for ( Res = 0, Num--; Num; Num >>= 1, Res++ );
@@ -115,7 +117,6 @@ int Extra_Base2LogDouble( double Num )
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++ );
@@ -265,7 +266,7 @@ int Extra_Factorial( int n )
Description [The number of permutations in the array is n!. The number of
entries in each permutation is n. Therefore, the resulting array is a
- two-dimentional array of the size: n! x n. To ABC_FREE the resulting array,
+ two-dimentional array of the size: n! x n. To free the resulting array,
call ABC_FREE() on the pointer returned by this procedure.]
SideEffects []
@@ -2233,3 +2234,5 @@ void Extra_TruthExpandGeneratePermTable()
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/extra/extraUtilProgress.c b/src/misc/extra/extraUtilProgress.c
index 5e3b0f06..e7add47f 100644
--- a/src/misc/extra/extraUtilProgress.c
+++ b/src/misc/extra/extraUtilProgress.c
@@ -20,6 +20,10 @@
#include <stdio.h>
#include "extra.h"
+#include "main.h"
+
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -58,9 +62,6 @@ static void Extra_ProgressBarClean( ProgressBar * p );
ProgressBar * Extra_ProgressBarStart( FILE * pFile, int nItemsTotal )
{
ProgressBar * p;
- extern int Abc_FrameShowProgress( void * p );
- extern void * Abc_FrameGetGlobalFrame();
-
if ( !Abc_FrameShowProgress(Abc_FrameGetGlobalFrame()) ) return NULL;
p = ABC_ALLOC( ProgressBar, 1 );
memset( p, 0, sizeof(ProgressBar) );
@@ -174,3 +175,5 @@ void Extra_ProgressBarClean( ProgressBar * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/extra/extraUtilReader.c b/src/misc/extra/extraUtilReader.c
index 46179e50..bcf3da37 100644
--- a/src/misc/extra/extraUtilReader.c
+++ b/src/misc/extra/extraUtilReader.c
@@ -22,6 +22,9 @@
#include "extra.h"
#include "vec.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -232,7 +235,7 @@ int Extra_FileReaderGetLineNumber( Extra_FileReader_t * p, int iToken )
void * Extra_FileReaderGetTokens( Extra_FileReader_t * p )
{
Vec_Ptr_t * vTokens;
- while ( (vTokens = Extra_FileReaderGetTokens_int( p )) )
+ while ( (vTokens = (Vec_Ptr_t *)Extra_FileReaderGetTokens_int( p )) )
if ( vTokens->nSize > 0 )
break;
return vTokens;
@@ -381,3 +384,5 @@ void Extra_FileReaderReload( Extra_FileReader_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/extra/extraUtilTruth.c b/src/misc/extra/extraUtilTruth.c
index 3b0b16eb..4da5cb6a 100644
--- a/src/misc/extra/extraUtilTruth.c
+++ b/src/misc/extra/extraUtilTruth.c
@@ -20,6 +20,9 @@
#include "extra.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*---------------------------------------------------------------------------*/
/* Constant declarations */
/*---------------------------------------------------------------------------*/
@@ -1146,3 +1149,5 @@ unsigned Extra_TruthSemiCanonicize( unsigned * pInOut, unsigned * pAux, int nVar
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/extra/extraUtilUtil.c b/src/misc/extra/extraUtilUtil.c
index 3f0dd365..37ea9321 100644
--- a/src/misc/extra/extraUtilUtil.c
+++ b/src/misc/extra/extraUtilUtil.c
@@ -19,8 +19,11 @@
***********************************************************************/
#include <stdio.h>
+#include <string.h>
#include "extra.h"
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -38,10 +41,10 @@
* Purpose: get option letter from argv.
*/
-char * globalUtilOptarg; // Global argument pointer (util_optarg)
+const char * globalUtilOptarg; // Global argument pointer (util_optarg)
int globalUtilOptind = 0; // Global argv index (util_optind)
-static char *pScanStr;
+static const char *pScanStr;
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
@@ -92,10 +95,10 @@ void Extra_UtilGetoptReset()
SeeAlso []
***********************************************************************/
-int Extra_UtilGetopt( int argc, char *argv[], char *optstring )
+int Extra_UtilGetopt( int argc, char *argv[], const char *optstring )
{
register int c;
- register char *place;
+ register const char *place;
globalUtilOptarg = NULL;
@@ -163,10 +166,10 @@ char * Extra_UtilPrintTime( long t )
SeeAlso []
***********************************************************************/
-char * Extra_UtilStrsav( char *s )
+char * Extra_UtilStrsav( const char *s )
{
if(s == NULL) { /* added 7/95, for robustness */
- return s;
+ return NULL;
}
else {
return strcpy(ABC_ALLOC(char, strlen(s)+1), s);
@@ -226,7 +229,7 @@ char * Extra_UtilTildeExpand( char *fname )
SeeAlso []
***********************************************************************/
-int Extra_UtilCheckFile(char *filename, char *mode)
+int Extra_UtilCheckFile(char *filename, const char *mode)
{
FILE *fp;
int got_file;
@@ -310,7 +313,7 @@ char * Extra_UtilFileSearch(char *file, char *path, char *mode)
***********************************************************************/
/* MMout_of_memory -- out of memory for lazy people, flush and exit */
-void Extra_UtilMMout_Of_Memory( long size )
+void Extra_UtilMMout_Of_Memory( long size )
{
(void) fflush(stdout);
(void) fprintf(stderr, "\nout of memory allocating %u bytes\n",
@@ -330,7 +333,7 @@ void Extra_UtilMMout_Of_Memory( long size )
SeeAlso []
***********************************************************************/
-void (*Extra_UtilMMoutOfMemory)() = Extra_UtilMMout_Of_Memory;
+void (*Extra_UtilMMoutOfMemory)( long size ) = (void (*)( long size ))Extra_UtilMMout_Of_Memory;
/**Function*************************************************************
@@ -366,9 +369,15 @@ double Extra_CpuTimeDouble()
return (double)clock()/CLOCKS_PER_SEC;
}
#else
+
+ABC_NAMESPACE_IMPL_END
+
#include <sys/time.h>
#include <sys/resource.h>
#include <unistd.h>
+
+ABC_NAMESPACE_IMPL_START
+
double Extra_CpuTimeDouble()
{
struct rusage ru;
@@ -398,3 +407,5 @@ void Extra_MemTest()
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/hash/hash.h b/src/misc/hash/hash.h
index dad4db18..9b5b25d6 100644
--- a/src/misc/hash/hash.h
+++ b/src/misc/hash/hash.h
@@ -21,6 +21,7 @@
#ifndef __HASH_H__
#define __HASH_H__
+
#ifdef _WIN32
#define inline __inline // compatible with MS VS 6.0
#endif
@@ -34,6 +35,9 @@
#include "hashFlt.h"
#include "hashPtr.h"
+ABC_NAMESPACE_HEADER_START
+
+
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
@@ -58,5 +62,9 @@ int Hash_DefaultHashFunc(int key, int nBins) {
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif
diff --git a/src/misc/hash/hashFlt.h b/src/misc/hash/hashFlt.h
index 4b9951cb..b4a8fb49 100644
--- a/src/misc/hash/hashFlt.h
+++ b/src/misc/hash/hashFlt.h
@@ -21,6 +21,7 @@
#ifndef __HASH_FLT_H__
#define __HASH_FLT_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -28,6 +29,9 @@
#include <stdio.h>
#include "extra.h"
+ABC_NAMESPACE_HEADER_START
+
+
extern int Hash_DefaultHashFunc(int key, int nBins);
////////////////////////////////////////////////////////////////////////
@@ -327,4 +331,8 @@ static inline void Hash_FltFree( Hash_Flt_t *p ) {
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif
diff --git a/src/misc/hash/hashInt.h b/src/misc/hash/hashInt.h
index f58a9fac..23947946 100644
--- a/src/misc/hash/hashInt.h
+++ b/src/misc/hash/hashInt.h
@@ -21,6 +21,7 @@
#ifndef __HASH_INT_H__
#define __HASH_INT_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -28,6 +29,9 @@
#include <stdio.h>
#include "extra.h"
+ABC_NAMESPACE_HEADER_START
+
+
extern int Hash_DefaultHashFunc(int key, int nBins);
////////////////////////////////////////////////////////////////////////
@@ -291,4 +295,8 @@ static inline void Hash_IntFree( Hash_Int_t *p ) {
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif
diff --git a/src/misc/hash/hashPtr.h b/src/misc/hash/hashPtr.h
index 136250ee..9e510866 100644
--- a/src/misc/hash/hashPtr.h
+++ b/src/misc/hash/hashPtr.h
@@ -21,6 +21,7 @@
#ifndef __HASH_PTR_H__
#define __HASH_PTR_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -28,6 +29,9 @@
#include <stdio.h>
#include "extra.h"
+ABC_NAMESPACE_HEADER_START
+
+
extern int Hash_DefaultHashFunc(int key, int nBins);
////////////////////////////////////////////////////////////////////////
@@ -328,4 +332,8 @@ static inline void Hash_PtrFree( Hash_Ptr_t *p ) {
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif
diff --git a/src/misc/mvc/mvc.c b/src/misc/mvc/mvc.c
index 001b1c63..05a47b2a 100644
--- a/src/misc/mvc/mvc.c
+++ b/src/misc/mvc/mvc.c
@@ -18,6 +18,9 @@
#include "mvc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -44,3 +47,5 @@
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/mvc/mvc.h b/src/misc/mvc/mvc.h
index 4cc765b2..93229470 100644
--- a/src/misc/mvc/mvc.h
+++ b/src/misc/mvc/mvc.h
@@ -19,6 +19,7 @@
#ifndef __MVC_H__
#define __MVC_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -27,6 +28,9 @@
#include "extra.h"
#include "extra.h"
+ABC_NAMESPACE_HEADER_START
+
+
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
@@ -724,6 +728,10 @@ extern Mvc_Manager_t * Mvc_ManagerAllocCube( int nWords );
extern Mvc_Manager_t * Mvc_ManagerFreeCover( Mvc_Cover_t * pCover );
extern Mvc_Manager_t * Mvc_ManagerFreeCube( Mvc_Cover_t * pCube, int nWords );
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif
////////////////////////////////////////////////////////////////////////
diff --git a/src/misc/mvc/mvcApi.c b/src/misc/mvc/mvcApi.c
index eb942f93..f1b57f0b 100644
--- a/src/misc/mvc/mvcApi.c
+++ b/src/misc/mvc/mvcApi.c
@@ -18,6 +18,9 @@
#include "mvc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -231,3 +234,5 @@ Mvc_Cover_t * Mvc_CoverCreateTautology( Mvc_Cover_t * pCover )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/mvc/mvcCompare.c b/src/misc/mvc/mvcCompare.c
index 9cff99cd..5061cc6c 100644
--- a/src/misc/mvc/mvcCompare.c
+++ b/src/misc/mvc/mvcCompare.c
@@ -18,6 +18,9 @@
#include "mvc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -367,3 +370,5 @@ int Mvc_CubeCompareIntOutsideAndUnderMask( Mvc_Cube_t * pC1, Mvc_Cube_t * pC2, M
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/mvc/mvcContain.c b/src/misc/mvc/mvcContain.c
index 950a80a2..810702c7 100644
--- a/src/misc/mvc/mvcContain.c
+++ b/src/misc/mvc/mvcContain.c
@@ -18,6 +18,9 @@
#include "mvc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -171,3 +174,5 @@ void Mvc_CoverRemoveContained( Mvc_Cover_t * pCover )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/mvc/mvcCover.c b/src/misc/mvc/mvcCover.c
index bad76170..c387ebb3 100644
--- a/src/misc/mvc/mvcCover.c
+++ b/src/misc/mvc/mvcCover.c
@@ -18,6 +18,9 @@
#include "mvc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -249,3 +252,5 @@ void Mvc_CoverDeallocateArrayLits( Mvc_Cover_t * pCover )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/mvc/mvcCube.c b/src/misc/mvc/mvcCube.c
index 9ccdb427..355c0b56 100644
--- a/src/misc/mvc/mvcCube.c
+++ b/src/misc/mvc/mvcCube.c
@@ -18,6 +18,9 @@
#include "mvc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -173,3 +176,5 @@ void Mvc_CubeBitRemoveDcs( Mvc_Cube_t * pCube )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/mvc/mvcDivide.c b/src/misc/mvc/mvcDivide.c
index 45063943..7ba3547f 100644
--- a/src/misc/mvc/mvcDivide.c
+++ b/src/misc/mvc/mvcDivide.c
@@ -18,6 +18,9 @@
#include "mvc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -435,3 +438,5 @@ void Mvc_CoverVerifyDivision( Mvc_Cover_t * pCover, Mvc_Cover_t * pDiv, Mvc_Cove
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/mvc/mvcDivisor.c b/src/misc/mvc/mvcDivisor.c
index 1ce556a5..bbdd735f 100644
--- a/src/misc/mvc/mvcDivisor.c
+++ b/src/misc/mvc/mvcDivisor.c
@@ -18,6 +18,9 @@
#include "mvc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -76,7 +79,7 @@ void Mvc_CoverDivisorZeroKernel( Mvc_Cover_t * pCover )
// iLit = Mvc_CoverBestLiteral( pCover, NULL );
if ( iLit == -1 )
return;
- // derive the cube-ABC_FREE quotient
+ // derive the cube-free quotient
Mvc_CoverDivideByLiteralQuo( pCover, iLit ); // the same cover
Mvc_CoverMakeCubeFree( pCover ); // the same cover
// call recursively
@@ -88,3 +91,5 @@ void Mvc_CoverDivisorZeroKernel( Mvc_Cover_t * pCover )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/mvc/mvcList.c b/src/misc/mvc/mvcList.c
index 8a82f911..1b39dfbb 100644
--- a/src/misc/mvc/mvcList.c
+++ b/src/misc/mvc/mvcList.c
@@ -18,6 +18,9 @@
#include "mvc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -360,3 +363,5 @@ Mvc_Cube_t * Mvc_ListGetTailFromHead( Mvc_Cube_t * pHead )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/mvc/mvcLits.c b/src/misc/mvc/mvcLits.c
index 910158e9..e1016cd5 100644
--- a/src/misc/mvc/mvcLits.c
+++ b/src/misc/mvc/mvcLits.c
@@ -18,6 +18,9 @@
#include "mvc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -343,3 +346,5 @@ int Mvc_CoverIsOneLiteral( Mvc_Cover_t * pCover )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/mvc/mvcMan.c b/src/misc/mvc/mvcMan.c
index 168410a4..05366afa 100644
--- a/src/misc/mvc/mvcMan.c
+++ b/src/misc/mvc/mvcMan.c
@@ -19,6 +19,9 @@
#include <string.h>
#include "mvc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -75,3 +78,5 @@ void Mvc_ManagerFree( Mvc_Manager_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/mvc/mvcOpAlg.c b/src/misc/mvc/mvcOpAlg.c
index 65c02fa5..da160b39 100644
--- a/src/misc/mvc/mvcOpAlg.c
+++ b/src/misc/mvc/mvcOpAlg.c
@@ -18,6 +18,9 @@
#include "mvc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -161,3 +164,5 @@ int Mvc_CoverAlgebraicEqual( Mvc_Cover_t * pCover1, Mvc_Cover_t * pCover2 )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/mvc/mvcOpBool.c b/src/misc/mvc/mvcOpBool.c
index 0b34f1de..32339dfe 100644
--- a/src/misc/mvc/mvcOpBool.c
+++ b/src/misc/mvc/mvcOpBool.c
@@ -18,6 +18,9 @@
#include "mvc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -149,3 +152,5 @@ Mvc_CoverPrint( pSharp );
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/mvc/mvcPrint.c b/src/misc/mvc/mvcPrint.c
index 52ac76b3..b7ba494c 100644
--- a/src/misc/mvc/mvcPrint.c
+++ b/src/misc/mvc/mvcPrint.c
@@ -20,6 +20,9 @@
//#include "vm.h"
//#include "vmInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -218,3 +221,5 @@ void Mvc_CubePrintMv( Mvc_Data_t * pData, Mvc_Cover_t * pCover, Mvc_Cube_t * pCu
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/mvc/mvcSort.c b/src/misc/mvc/mvcSort.c
index 3c975cb3..7382512a 100644
--- a/src/misc/mvc/mvcSort.c
+++ b/src/misc/mvc/mvcSort.c
@@ -18,6 +18,9 @@
#include "mvc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -139,3 +142,5 @@ Mvc_Cube_t * Mvc_CoverSortMerge( Mvc_Cube_t * pList1, Mvc_Cube_t * pList2, Mvc_C
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/mvc/mvcUtils.c b/src/misc/mvc/mvcUtils.c
index bb4b1191..d938169a 100644
--- a/src/misc/mvc/mvcUtils.c
+++ b/src/misc/mvc/mvcUtils.c
@@ -18,6 +18,9 @@
#include "mvc.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -866,3 +869,5 @@ int Mvc_UtilsCheckUnusedZeros( Mvc_Cover_t * pCover )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/nm/nm.h b/src/misc/nm/nm.h
index 6f46c291..015b4ef4 100644
--- a/src/misc/nm/nm.h
+++ b/src/misc/nm/nm.h
@@ -21,6 +21,7 @@
#ifndef __NM_H__
#define __NM_H__
+
/*
This manager is designed to store ID-to-name and name-to-ID mapping
for Boolean networks and And-Inverter Graphs.
@@ -50,9 +51,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -80,9 +82,11 @@ extern int Nm_ManFindIdByName( Nm_Man_t * p, char * pName, int Type );
extern int Nm_ManFindIdByNameTwoTypes( Nm_Man_t * p, char * pName, int Type1, int Type2 );
extern Vec_Int_t * Nm_ManReturnNameIds( Nm_Man_t * p );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/misc/nm/nmApi.c b/src/misc/nm/nmApi.c
index 0d79a84c..e6bfb069 100644
--- a/src/misc/nm/nmApi.c
+++ b/src/misc/nm/nmApi.c
@@ -20,6 +20,9 @@
#include "nmInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -119,7 +122,7 @@ char * Nm_ManStoreIdName( Nm_Man_t * p, int ObjId, int Type, char * pName, char
// create a new entry
nEntrySize = sizeof(Nm_Entry_t) + strlen(pName) + (pSuffix?strlen(pSuffix):0) + 1;
// nEntrySize = (nEntrySize / 4 + ((nEntrySize % 4) > 0)) * 4;
- nEntrySize = (nEntrySize / 8 + ((nEntrySize % 8) > 0)) * 8;
+ nEntrySize = (nEntrySize / sizeof(char*) + ((nEntrySize % sizeof(char*)) > 0)) * sizeof(char*); // added by Saurabh on Sep 3, 2009
pEntry = (Nm_Entry_t *)Extra_MmFlexEntryFetch( p->pMem, nEntrySize );
pEntry->pNextI2N = pEntry->pNextN2I = pEntry->pNameSake = NULL;
pEntry->ObjId = ObjId;
@@ -271,3 +274,5 @@ Vec_Int_t * Nm_ManReturnNameIds( Nm_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/nm/nmInt.h b/src/misc/nm/nmInt.h
index 03948f22..0978c6b6 100644
--- a/src/misc/nm/nmInt.h
+++ b/src/misc/nm/nmInt.h
@@ -21,6 +21,7 @@
#ifndef __NM_INT_H__
#define __NM_INT_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -33,9 +34,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -78,9 +80,11 @@ extern Nm_Entry_t * Nm_ManTableLookupId( Nm_Man_t * p, int ObjId );
extern Nm_Entry_t * Nm_ManTableLookupName( Nm_Man_t * p, char * pName, int Type );
extern unsigned int Cudd_PrimeNm( unsigned int p );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/misc/nm/nmTable.c b/src/misc/nm/nmTable.c
index a147b16c..29c751a6 100644
--- a/src/misc/nm/nmTable.c
+++ b/src/misc/nm/nmTable.c
@@ -20,6 +20,9 @@
#include "nmInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -337,3 +340,5 @@ unsigned int Cudd_PrimeNm( unsigned int p)
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/st/st.c b/src/misc/st/st.c
index 13445e9e..9705b987 100644
--- a/src/misc/st/st.c
+++ b/src/misc/st/st.c
@@ -9,9 +9,12 @@
*/
#include <stdio.h>
#include <stdlib.h>
-#include "abc_global.h"
+
#include "st.h"
+ABC_NAMESPACE_IMPL_START
+
+
#define ST_NUMCMP(x,y) ((x) != (y))
#define ST_NUMHASH(x,size) (ABC_ABS((long)x)%(size))
//#define ST_PTRHASH(x,size) ((int)((ABC_PTRUINT_T)(x)>>2)%size) // 64-bit bug fix 9/17/2007
@@ -26,51 +29,46 @@
(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();
+static int rehash(st_table *table);
+
+int st_numhash(const char*, int);
+int st_ptrhash(const char*, int);
+int st_numcmp(const char*, const char*);
+int st_ptrcmp(const char*, const char*);
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;
+st_init_table_with_params(st_compare_func_type compare, st_hash_func_type hash, int size, int density, double grow_factor, int reorder_flag)
{
int i;
- st_table *new;
+ st_table *newTable;
- new = ABC_ALLOC(st_table, 1);
- if (new == NULL) {
+ newTable = ABC_ALLOC(st_table, 1);
+ if (newTable == 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;
+ newTable->compare = compare;
+ newTable->hash = hash;
+ newTable->num_entries = 0;
+ newTable->max_density = density;
+ newTable->grow_factor = grow_factor;
+ newTable->reorder_flag = reorder_flag;
if (size <= 0) {
size = 1;
}
- new->num_bins = size;
- new->bins = ABC_ALLOC(st_table_entry *, size);
- if (new->bins == NULL) {
- ABC_FREE(new);
+ newTable->num_bins = size;
+ newTable->bins = ABC_ALLOC(st_table_entry *, size);
+ if (newTable->bins == NULL) {
+ ABC_FREE(newTable);
return NULL;
}
for(i = 0; i < size; i++) {
- new->bins[i] = 0;
+ newTable->bins[i] = 0;
}
- return new;
+ return newTable;
}
st_table *
-st_init_table(compare, hash)
-int (*compare)();
-int (*hash)();
+st_init_table(st_compare_func_type compare, st_hash_func_type hash)
{
return st_init_table_with_params(compare, hash, ST_DEFAULT_INIT_TABLE_SIZE,
ST_DEFAULT_MAX_DENSITY,
@@ -79,8 +77,7 @@ int (*hash)();
}
void
-st_free_table(table)
-st_table *table;
+st_free_table(st_table *table)
{
register st_table_entry *ptr, *next;
int i;
@@ -113,10 +110,7 @@ st_table *table;
}
int
-st_lookup(table, key, value)
-st_table *table;
-register char *key;
-char **value;
+st_lookup(st_table *table, register const char *key, char **value)
{
int hash_val;
register st_table_entry *ptr, **last;
@@ -136,10 +130,7 @@ char **value;
}
int
-st_lookup_int(table, key, value)
-st_table *table;
-register char *key;
-int *value;
+st_lookup_int(st_table *table, register char *key, int *value)
{
int hash_val;
register st_table_entry *ptr, **last;
@@ -176,13 +167,10 @@ int *value;
}
int
-st_insert(table, key, value)
-register st_table *table;
-register char *key;
-char *value;
+st_insert(register st_table *table, register const char *key, char *value)
{
int hash_val;
- st_table_entry *new;
+ st_table_entry *newEntry;
register st_table_entry *ptr, **last;
hash_val = do_hash(key, table);
@@ -196,14 +184,14 @@ char *value;
}
hash_val = do_hash(key, table);
}
- new = ABC_ALLOC(st_table_entry, 1);
- if (new == NULL) {
+ newEntry = ABC_ALLOC(st_table_entry, 1);
+ if (newEntry == NULL) {
return ST_OUT_OF_MEM;
}
- new->key = key;
- new->record = value;
- new->next = table->bins[hash_val];
- table->bins[hash_val] = new;
+ newEntry->key = key;
+ newEntry->record = value;
+ newEntry->next = table->bins[hash_val];
+ table->bins[hash_val] = newEntry;
table->num_entries++;
return 0;
} else {
@@ -213,13 +201,10 @@ char *value;
}
int
-st_add_direct(table, key, value)
-st_table *table;
-char *key;
-char *value;
+st_add_direct(st_table *table, char *key, char *value)
{
int hash_val;
- st_table_entry *new;
+ st_table_entry *newEntry;
hash_val = do_hash(key, table);
if (table->num_entries / table->num_bins >= table->max_density) {
@@ -228,26 +213,23 @@ char *value;
}
}
hash_val = do_hash(key, table);
- new = ABC_ALLOC(st_table_entry, 1);
- if (new == NULL) {
+ newEntry = ABC_ALLOC(st_table_entry, 1);
+ if (newEntry == NULL) {
return ST_OUT_OF_MEM;
}
- new->key = key;
- new->record = value;
- new->next = table->bins[hash_val];
- table->bins[hash_val] = new;
+ newEntry->key = key;
+ newEntry->record = value;
+ newEntry->next = table->bins[hash_val];
+ table->bins[hash_val] = newEntry;
table->num_entries++;
return 1;
}
int
-st_find_or_add(table, key, slot)
-st_table *table;
-char *key;
-char ***slot;
+st_find_or_add(st_table *table, char *key, char ***slot)
{
int hash_val;
- st_table_entry *new, *ptr, **last;
+ st_table_entry *newEntry, *ptr, **last;
hash_val = do_hash(key, table);
@@ -260,16 +242,16 @@ char ***slot;
}
hash_val = do_hash(key, table);
}
- new = ABC_ALLOC(st_table_entry, 1);
- if (new == NULL) {
+ newEntry = ABC_ALLOC(st_table_entry, 1);
+ if (newEntry == NULL) {
return ST_OUT_OF_MEM;
}
- new->key = key;
- new->record = (char *) 0;
- new->next = table->bins[hash_val];
- table->bins[hash_val] = new;
+ newEntry->key = key;
+ newEntry->record = (char *) 0;
+ newEntry->next = table->bins[hash_val];
+ table->bins[hash_val] = newEntry;
table->num_entries++;
- if (slot != NULL) *slot = &new->record;
+ if (slot != NULL) *slot = &newEntry->record;
return 0;
} else {
if (slot != NULL) *slot = &ptr->record;
@@ -278,10 +260,7 @@ char ***slot;
}
int
-st_find(table, key, slot)
-st_table *table;
-char *key;
-char ***slot;
+st_find(st_table *table, char *key, char ***slot)
{
int hash_val;
st_table_entry *ptr, **last;
@@ -301,8 +280,7 @@ char ***slot;
}
static int
-rehash(table)
-register st_table *table;
+rehash(register st_table *table)
{
register st_table_entry *ptr, *next, **old_bins;
int i, old_num_bins, hash_val, old_num_entries;
@@ -348,59 +326,55 @@ register st_table *table;
}
st_table *
-st_copy(old_table)
-st_table *old_table;
+st_copy(st_table *old_table)
{
- st_table *new_table;
- st_table_entry *ptr, *newptr, *next, *new;
+ st_table *newEntry_table;
+ st_table_entry *ptr, *newEntryptr, *next, *newEntry;
int i, j, num_bins = old_table->num_bins;
- new_table = ABC_ALLOC(st_table, 1);
- if (new_table == NULL) {
+ newEntry_table = ABC_ALLOC(st_table, 1);
+ if (newEntry_table == NULL) {
return NULL;
}
- *new_table = *old_table;
- new_table->bins = ABC_ALLOC(st_table_entry *, num_bins);
- if (new_table->bins == NULL) {
- ABC_FREE(new_table);
+ *newEntry_table = *old_table;
+ newEntry_table->bins = ABC_ALLOC(st_table_entry *, num_bins);
+ if (newEntry_table->bins == NULL) {
+ ABC_FREE(newEntry_table);
return NULL;
}
for(i = 0; i < num_bins ; i++) {
- new_table->bins[i] = NULL;
+ newEntry_table->bins[i] = NULL;
ptr = old_table->bins[i];
while (ptr != NULL) {
- new = ABC_ALLOC(st_table_entry, 1);
- if (new == NULL) {
+ newEntry = ABC_ALLOC(st_table_entry, 1);
+ if (newEntry == NULL) {
for (j = 0; j <= i; j++) {
- newptr = new_table->bins[j];
- while (newptr != NULL) {
- next = newptr->next;
- ABC_FREE(newptr);
- newptr = next;
+ newEntryptr = newEntry_table->bins[j];
+ while (newEntryptr != NULL) {
+ next = newEntryptr->next;
+ ABC_FREE(newEntryptr);
+ newEntryptr = next;
}
}
- ABC_FREE(new_table->bins);
- ABC_FREE(new_table);
+ ABC_FREE(newEntry_table->bins);
+ ABC_FREE(newEntry_table);
return NULL;
}
- *new = *ptr;
- new->next = new_table->bins[i];
- new_table->bins[i] = new;
+ *newEntry = *ptr;
+ newEntry->next = newEntry_table->bins[i];
+ newEntry_table->bins[i] = newEntry;
ptr = ptr->next;
}
}
- return new_table;
+ return newEntry_table;
}
int
-st_delete(table, keyp, value)
-register st_table *table;
-register char **keyp;
-char **value;
+st_delete(register st_table *table, register const char **keyp, char **value)
{
int hash_val;
- char *key = *keyp;
+ const char *key = *keyp;
register st_table_entry *ptr, **last;
hash_val = do_hash(key, table);
@@ -420,10 +394,7 @@ char **value;
}
int
-st_delete_int(table, keyp, value)
-register st_table *table;
-register long *keyp;
-char **value;
+st_delete_int(register st_table *table, register long *keyp, char **value)
{
int hash_val;
char *key = (char *) *keyp;
@@ -446,10 +417,7 @@ char **value;
}
int
-st_foreach(table, func, arg)
-st_table *table;
-enum st_retval (*func)();
-char *arg;
+st_foreach(st_table *table, enum st_retval (*func)(const char *, char *, char *), char *arg)
{
st_table_entry *ptr, **last;
enum st_retval retval;
@@ -477,9 +445,7 @@ char *arg;
}
int
-st_strhash(string, modulus)
-register char *string;
-int modulus;
+st_strhash(const char *string, int modulus)
{
register int val = 0;
register int c;
@@ -492,40 +458,31 @@ int modulus;
}
int
-st_numhash(x, size)
-char *x;
-int size;
+st_numhash(const char *x, int size)
{
return ST_NUMHASH(x, size);
}
int
-st_ptrhash(x, size)
-char *x;
-int size;
+st_ptrhash(const char *x, int size)
{
return ST_PTRHASH(x, size);
}
int
-st_numcmp(x, y)
-char *x;
-char *y;
+st_numcmp(const char *x, const char *y)
{
return ST_NUMCMP(x, y);
}
int
-st_ptrcmp(x, y)
-char *x;
-char *y;
+st_ptrcmp(const char *x, const char *y)
{
return ST_NUMCMP(x, y);
}
-
+
st_generator *
-st_init_gen(table)
-st_table *table;
+st_init_gen(st_table *table)
{
st_generator *gen;
@@ -541,10 +498,7 @@ st_table *table;
int
-st_gen(gen, key_p, value_p)
-st_generator *gen;
-char **key_p;
-char **value_p;
+st_gen(st_generator *gen, const char **key_p, char **value_p)
{
register int i;
@@ -571,10 +525,7 @@ char **value_p;
int
-st_gen_int(gen, key_p, value_p)
-st_generator *gen;
-char **key_p;
-long *value_p;
+st_gen_int(st_generator *gen, const char **key_p, long *value_p)
{
register int i;
@@ -601,8 +552,10 @@ long *value_p;
void
-st_free_gen(gen)
-st_generator *gen;
+st_free_gen(st_generator *gen)
{
ABC_FREE(gen);
}
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/st/st.h b/src/misc/st/st.h
index b15f3c83..81bd461e 100644
--- a/src/misc/st/st.h
+++ b/src/misc/st/st.h
@@ -14,21 +14,25 @@
#ifndef ST_INCLUDED
#define ST_INCLUDED
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+#include "abc_global.h"
+
+ABC_NAMESPACE_HEADER_START
+
+typedef int (*st_compare_func_type)(const char*, const char*);
+typedef int (*st_hash_func_type)(const char*, int);
typedef struct st_table_entry st_table_entry;
struct st_table_entry {
- char *key;
+ const char *key;
char *record;
st_table_entry *next;
};
typedef struct st_table st_table;
struct st_table {
- int (*compare)();
- int (*hash)();
+ st_compare_func_type compare;
+ st_hash_func_type hash;
int num_bins;
int num_entries;
int max_density;
@@ -49,30 +53,30 @@ struct st_generator {
enum st_retval {ST_CONTINUE, ST_STOP, ST_DELETE};
-typedef enum st_retval (*ST_PFSR)();
+typedef enum st_retval (*ST_PFSR)(const char *, char *, char *);
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 st_table *st_init_table_with_params (st_compare_func_type compare, st_hash_func_type hash, int size, int density, double grow_factor, int reorder_flag);
+extern st_table *st_init_table (st_compare_func_type, st_hash_func_type);
extern void st_free_table (st_table *);
-extern int st_lookup (st_table *, char *, char **);
+extern int st_lookup (st_table *, const char *, char **);
extern int st_lookup_int (st_table *, char *, int *);
-extern int st_insert (st_table *, char *, char *);
+extern int st_insert (st_table *, const 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 (st_table *, const 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 int st_strhash (const char *, int);
+extern int st_numhash (const char *, int);
+extern int st_ptrhash (const char *, int);
+extern int st_numcmp (const char *, const char *);
+extern int st_ptrcmp (const char *, const 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 int st_gen (st_generator *, const char **, char **);
+extern int st_gen_int (st_generator *, const char **, long *);
extern void st_free_gen (st_generator *);
@@ -89,8 +93,10 @@ extern void st_free_gen (st_generator *);
#define ST_OUT_OF_MEM -10000
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif /* ST_INCLUDED */
diff --git a/src/misc/st/stmm.c b/src/misc/st/stmm.c
index 5aaf8b9d..9aed8b11 100644
--- a/src/misc/st/stmm.c
+++ b/src/misc/st/stmm.c
@@ -11,6 +11,9 @@
#include "extra.h"
#include "stmm.h"
+ABC_NAMESPACE_IMPL_START
+
+
#define STMM_NUMCMP(x,y) ((x) != (y))
#define STMM_NUMHASH(x,size) (ABC_ABS((long)x)%(size))
//#define STMM_PTRHASH(x,size) ((int)((ABC_PTRUINT_T)(x)>>2)%size) // 64-bit bug fix 9/17/2007
@@ -25,54 +28,45 @@
(table->hash == stmm_numhash) ? STMM_NUMHASH((key), (table)->num_bins) :\
(*table->hash)((key), (table)->num_bins))
-static int rehash ();
-int stmm_numhash (), stmm_ptrhash (), stmm_numcmp (), stmm_ptrcmp ();
+static int rehash (stmm_table *table);
+//int stmm_numhash (), stmm_ptrhash (), stmm_numcmp (), stmm_ptrcmp ();
stmm_table *
-stmm_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;
+stmm_init_table_with_params (stmm_compare_func_type compare, stmm_hash_func_type hash, int size, int density, double grow_factor, int reorder_flag)
{
int i;
- stmm_table *new;
+ stmm_table *newTable;
- new = ABC_ALLOC(stmm_table, 1);
- if (new == NULL) {
+ newTable = ABC_ALLOC(stmm_table, 1);
+ if (newTable == 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;
+ newTable->compare = compare;
+ newTable->hash = hash;
+ newTable->num_entries = 0;
+ newTable->max_density = density;
+ newTable->grow_factor = grow_factor;
+ newTable->reorder_flag = reorder_flag;
if (size <= 0) {
size = 1;
}
- new->num_bins = size;
- new->bins = ABC_ALLOC(stmm_table_entry *, size);
- if (new->bins == NULL) {
- ABC_FREE (new);
+ newTable->num_bins = size;
+ newTable->bins = ABC_ALLOC(stmm_table_entry *, size);
+ if (newTable->bins == NULL) {
+ ABC_FREE(newTable);
return NULL;
}
for (i = 0; i < size; i++) {
- new->bins[i] = 0;
+ newTable->bins[i] = 0;
}
// added by alanmi
- new->pMemMan = Extra_MmFixedStart(sizeof (stmm_table_entry));
- return new;
+ newTable->pMemMan = Extra_MmFixedStart(sizeof (stmm_table_entry));
+ return newTable;
}
stmm_table *
-stmm_init_table (compare, hash)
- int (*compare) ();
- int (*hash) ();
+stmm_init_table (stmm_compare_func_type compare, stmm_hash_func_type hash)
{
return stmm_init_table_with_params (compare, hash,
STMM_DEFAULT_INIT_TABLE_SIZE,
@@ -82,8 +76,7 @@ stmm_init_table (compare, hash)
}
void
-stmm_free_table (table)
- stmm_table *table;
+stmm_free_table (stmm_table *table)
{
/*
register stmm_table_entry *ptr, *next;
@@ -103,14 +96,13 @@ stmm_free_table (table)
// added by alanmi
if ( table->pMemMan )
Extra_MmFixedStop (table->pMemMan);
- ABC_FREE (table->bins);
- ABC_FREE (table);
+ ABC_FREE(table->bins);
+ ABC_FREE(table);
}
// this function recycles all the bins
void
-stmm_clean (table)
- stmm_table *table;
+stmm_clean (stmm_table *table)
{
int i;
// clean the bins
@@ -139,10 +131,7 @@ stmm_clean (table)
}
int
-stmm_lookup (table, key, value)
- stmm_table *table;
- register char *key;
- char **value;
+stmm_lookup (stmm_table *table, register char *key, char **value)
{
int hash_val;
register stmm_table_entry *ptr, **last;
@@ -164,10 +153,7 @@ stmm_lookup (table, key, value)
}
int
-stmm_lookup_int (table, key, value)
- stmm_table *table;
- register char *key;
- int *value;
+stmm_lookup_int (stmm_table *table, register char *key, int *value)
{
int hash_val;
register stmm_table_entry *ptr, **last;
@@ -211,13 +197,10 @@ stmm_lookup_int (table, key, value)
}
int
-stmm_insert (table, key, value)
- register stmm_table *table;
- register char *key;
- char *value;
+stmm_insert (register stmm_table *table, register char *key, char *value)
{
int hash_val;
- stmm_table_entry *new;
+ stmm_table_entry *newEntry;
register stmm_table_entry *ptr, **last;
hash_val = do_hash (key, table);
@@ -232,16 +215,16 @@ stmm_insert (table, key, value)
hash_val = do_hash (key, table);
}
-// new = ABC_ALLOC( stmm_table_entry, 1 );
- new = (stmm_table_entry *) Extra_MmFixedEntryFetch (table->pMemMan);
- if (new == NULL) {
+// newEntry = ABC_ALLOC( stmm_table_entry, 1 );
+ newEntry = (stmm_table_entry *) Extra_MmFixedEntryFetch (table->pMemMan);
+ if (newEntry == NULL) {
return STMM_OUT_OF_MEM;
}
- new->key = key;
- new->record = value;
- new->next = table->bins[hash_val];
- table->bins[hash_val] = new;
+ newEntry->key = key;
+ newEntry->record = value;
+ newEntry->next = table->bins[hash_val];
+ table->bins[hash_val] = newEntry;
table->num_entries++;
return 0;
}
@@ -252,13 +235,10 @@ stmm_insert (table, key, value)
}
int
-stmm_add_direct (table, key, value)
- stmm_table *table;
- char *key;
- char *value;
+stmm_add_direct (stmm_table *table, char *key, char *value)
{
int hash_val;
- stmm_table_entry *new;
+ stmm_table_entry *newEntry;
hash_val = do_hash (key, table);
if (table->num_entries / table->num_bins >= table->max_density) {
@@ -268,28 +248,25 @@ stmm_add_direct (table, key, value)
}
hash_val = do_hash (key, table);
-// new = ABC_ALLOC( stmm_table_entry, 1 );
- new = (stmm_table_entry *) Extra_MmFixedEntryFetch (table->pMemMan);
- if (new == NULL) {
+// newEntry = ABC_ALLOC( stmm_table_entry, 1 );
+ newEntry = (stmm_table_entry *) Extra_MmFixedEntryFetch (table->pMemMan);
+ if (newEntry == NULL) {
return STMM_OUT_OF_MEM;
}
- new->key = key;
- new->record = value;
- new->next = table->bins[hash_val];
- table->bins[hash_val] = new;
+ newEntry->key = key;
+ newEntry->record = value;
+ newEntry->next = table->bins[hash_val];
+ table->bins[hash_val] = newEntry;
table->num_entries++;
return 1;
}
int
-stmm_find_or_add (table, key, slot)
- stmm_table *table;
- char *key;
- char ***slot;
+stmm_find_or_add (stmm_table *table, char *key, char ***slot)
{
int hash_val;
- stmm_table_entry *new, *ptr, **last;
+ stmm_table_entry *newEntry, *ptr, **last;
hash_val = do_hash (key, table);
@@ -303,19 +280,19 @@ stmm_find_or_add (table, key, slot)
hash_val = do_hash (key, table);
}
- // new = ABC_ALLOC( stmm_table_entry, 1 );
- new = (stmm_table_entry *) Extra_MmFixedEntryFetch (table->pMemMan);
- if (new == NULL) {
+ // newEntry = ABC_ALLOC( stmm_table_entry, 1 );
+ newEntry = (stmm_table_entry *) Extra_MmFixedEntryFetch (table->pMemMan);
+ if (newEntry == NULL) {
return STMM_OUT_OF_MEM;
}
- new->key = key;
- new->record = (char *) 0;
- new->next = table->bins[hash_val];
- table->bins[hash_val] = new;
+ newEntry->key = key;
+ newEntry->record = (char *) 0;
+ newEntry->next = table->bins[hash_val];
+ table->bins[hash_val] = newEntry;
table->num_entries++;
if (slot != NULL)
- *slot = &new->record;
+ *slot = &newEntry->record;
return 0;
}
else {
@@ -326,10 +303,7 @@ stmm_find_or_add (table, key, slot)
}
int
-stmm_find (table, key, slot)
- stmm_table *table;
- char *key;
- char ***slot;
+stmm_find (stmm_table *table, char *key, char ***slot)
{
int hash_val;
stmm_table_entry *ptr, **last;
@@ -351,8 +325,7 @@ stmm_find (table, key, slot)
}
static int
-rehash (table)
- register stmm_table *table;
+rehash (register stmm_table *table)
{
register stmm_table_entry *ptr, *next, **old_bins;
int i, old_num_bins, hash_val, old_num_entries;
@@ -392,77 +365,73 @@ rehash (table)
ptr = next;
}
}
- ABC_FREE (old_bins);
+ ABC_FREE(old_bins);
return 1;
}
stmm_table *
-stmm_copy (old_table)
- stmm_table *old_table;
+stmm_copy (stmm_table *old_table)
{
- stmm_table *new_table;
- stmm_table_entry *ptr, /* *newptr, *next, */ *new;
+ stmm_table *newEntry_table;
+ stmm_table_entry *ptr, /* *newEntryptr, *next, */ *newEntry;
int i, /*j, */ num_bins = old_table->num_bins;
- new_table = ABC_ALLOC(stmm_table, 1);
- if (new_table == NULL) {
+ newEntry_table = ABC_ALLOC(stmm_table, 1);
+ if (newEntry_table == NULL) {
return NULL;
}
- *new_table = *old_table;
- new_table->bins = ABC_ALLOC(stmm_table_entry *, num_bins);
- if (new_table->bins == NULL) {
- ABC_FREE (new_table);
+ *newEntry_table = *old_table;
+ newEntry_table->bins = ABC_ALLOC(stmm_table_entry *, num_bins);
+ if (newEntry_table->bins == NULL) {
+ ABC_FREE(newEntry_table);
return NULL;
}
- // allocate the memory manager for the new table
- new_table->pMemMan =
+ // allocate the memory manager for the newEntry table
+ newEntry_table->pMemMan =
Extra_MmFixedStart (sizeof (stmm_table_entry));
for (i = 0; i < num_bins; i++) {
- new_table->bins[i] = NULL;
+ newEntry_table->bins[i] = NULL;
ptr = old_table->bins[i];
while (ptr != NULL) {
-// new = ABC_ALLOC( stmm_table_entry, 1 );
- new =
- (stmm_table_entry *) Extra_MmFixedEntryFetch (new_table->
+// newEntry = ABC_ALLOC( stmm_table_entry, 1 );
+ newEntry =
+ (stmm_table_entry *) Extra_MmFixedEntryFetch (newEntry_table->
pMemMan);
- if (new == NULL) {
+ if (newEntry == NULL) {
/*
for ( j = 0; j <= i; j++ )
{
- newptr = new_table->bins[j];
- while ( newptr != NULL )
+ newEntryptr = newEntry_table->bins[j];
+ while ( newEntryptr != NULL )
{
- next = newptr->next;
- ABC_FREE( newptr );
- newptr = next;
+ next = newEntryptr->next;
+ ABC_FREE( newEntryptr );
+ newEntryptr = next;
}
}
*/
- Extra_MmFixedStop (new_table->pMemMan);
+ Extra_MmFixedStop (newEntry_table->pMemMan);
- ABC_FREE (new_table->bins);
- ABC_FREE (new_table);
+ ABC_FREE(newEntry_table->bins);
+ ABC_FREE(newEntry_table);
return NULL;
}
- *new = *ptr;
- new->next = new_table->bins[i];
- new_table->bins[i] = new;
+ *newEntry = *ptr;
+ newEntry->next = newEntry_table->bins[i];
+ newEntry_table->bins[i] = newEntry;
ptr = ptr->next;
}
}
- return new_table;
+ return newEntry_table;
}
int
-stmm_delete (table, keyp, value)
- register stmm_table *table;
- register char **keyp;
- char **value;
+stmm_delete (register stmm_table *table, register char **keyp, char **value)
{
int hash_val;
char *key = *keyp;
@@ -488,10 +457,7 @@ stmm_delete (table, keyp, value)
}
int
-stmm_delete_int (table, keyp, value)
- register stmm_table *table;
- register long *keyp;
- char **value;
+stmm_delete_int (register stmm_table *table, register long *keyp, char **value)
{
int hash_val;
char *key = (char *) *keyp;
@@ -517,10 +483,7 @@ stmm_delete_int (table, keyp, value)
}
int
-stmm_foreach (table, func, arg)
- stmm_table *table;
- enum stmm_retval (*func) ();
- char *arg;
+stmm_foreach (stmm_table *table, enum stmm_retval (*func) (char *, char *, char *), char *arg)
{
stmm_table_entry *ptr, **last;
enum stmm_retval retval;
@@ -552,9 +515,7 @@ stmm_foreach (table, func, arg)
}
int
-stmm_strhash (string, modulus)
- register char *string;
- int modulus;
+stmm_strhash (register const char *string, int modulus)
{
register int val = 0;
register int c;
@@ -567,40 +528,31 @@ stmm_strhash (string, modulus)
}
int
-stmm_numhash (x, size)
- char *x;
- int size;
+stmm_numhash (const char *x, int size)
{
return STMM_NUMHASH (x, size);
}
int
-stmm_ptrhash (x, size)
- char *x;
- int size;
+stmm_ptrhash (const char *x, int size)
{
return STMM_PTRHASH (x, size);
}
int
-stmm_numcmp (x, y)
- char *x;
- char *y;
+stmm_numcmp (const char *x, const char *y)
{
return STMM_NUMCMP (x, y);
}
int
-stmm_ptrcmp (x, y)
- char *x;
- char *y;
+stmm_ptrcmp (const char *x, const char *y)
{
return STMM_NUMCMP (x, y);
}
stmm_generator *
-stmm_init_gen (table)
- stmm_table *table;
+stmm_init_gen (stmm_table *table)
{
stmm_generator *gen;
@@ -616,10 +568,7 @@ stmm_init_gen (table)
int
-stmm_gen (gen, key_p, value_p)
- stmm_generator *gen;
- char **key_p;
- char **value_p;
+stmm_gen (stmm_generator *gen, char **key_p, char **value_p)
{
register int i;
@@ -646,10 +595,7 @@ stmm_gen (gen, key_p, value_p)
int
-stmm_gen_int (gen, key_p, value_p)
- stmm_generator *gen;
- char **key_p;
- long *value_p;
+stmm_gen_int (stmm_generator *gen, char **key_p, long *value_p)
{
register int i;
@@ -677,8 +623,9 @@ stmm_gen_int (gen, key_p, value_p)
void
-stmm_free_gen (gen)
- stmm_generator *gen;
+stmm_free_gen (stmm_generator *gen)
{
- ABC_FREE (gen);
+ ABC_FREE(gen);
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/st/stmm.h b/src/misc/st/stmm.h
index 9dede7d8..c23c6942 100644
--- a/src/misc/st/stmm.h
+++ b/src/misc/st/stmm.h
@@ -14,11 +14,15 @@
#ifndef STMM_INCLUDED
#define STMM_INCLUDED
+
#include "extra.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
+typedef int (*stmm_compare_func_type)(const char*, const char*);
+typedef int (*stmm_hash_func_type)(const char*, int);
typedef struct stmm_table_entry stmm_table_entry;
typedef struct stmm_table stmm_table;
@@ -33,8 +37,8 @@ struct stmm_table_entry
struct stmm_table
{
- int (*compare) ();
- int (*hash) ();
+ stmm_compare_func_type compare;
+ stmm_hash_func_type hash;
int num_bins;
int num_entries;
int max_density;
@@ -59,12 +63,11 @@ struct stmm_generator
enum stmm_retval
{ STMM_CONTINUE, STMM_STOP, STMM_DELETE };
-typedef enum stmm_retval (*STMM_PFSR) ();
-typedef int (*STMM_PFI) ();
+typedef enum stmm_retval (*STMM_PFSR) (char *, char *, char *);
EXTERN stmm_table *stmm_init_table_with_params
-ARGS ((STMM_PFI, STMM_PFI, int, int, double, int));
-EXTERN stmm_table *stmm_init_table ARGS ((STMM_PFI, STMM_PFI));
+ARGS ((stmm_compare_func_type compare, stmm_hash_func_type hash, int size, int density, double grow_factor, int reorder_flag));
+EXTERN stmm_table *stmm_init_table ARGS ((stmm_compare_func_type, stmm_hash_func_type));
EXTERN void stmm_free_table ARGS ((stmm_table *));
EXTERN int stmm_lookup ARGS ((stmm_table *, char *, char **));
EXTERN int stmm_lookup_int ARGS ((stmm_table *, char *, int *));
@@ -76,11 +79,11 @@ EXTERN stmm_table *stmm_copy ARGS ((stmm_table *));
EXTERN int stmm_delete ARGS ((stmm_table *, char **, char **));
EXTERN int stmm_delete_int ARGS ((stmm_table *, long *, char **));
EXTERN int stmm_foreach ARGS ((stmm_table *, STMM_PFSR, char *));
-EXTERN int stmm_strhash ARGS ((char *, int));
-EXTERN int stmm_numhash ARGS ((char *, int));
-EXTERN int stmm_ptrhash ARGS ((char *, int));
-EXTERN int stmm_numcmp ARGS ((char *, char *));
-EXTERN int stmm_ptrcmp ARGS ((char *, char *));
+EXTERN int stmm_strhash ARGS ((const char *, int));
+EXTERN int stmm_numhash ARGS ((const char *, int));
+EXTERN int stmm_ptrhash ARGS ((const char *, int));
+EXTERN int stmm_numcmp ARGS ((const char *, const char *));
+EXTERN int stmm_ptrcmp ARGS ((const char *, const char *));
EXTERN stmm_generator *stmm_init_gen ARGS ((stmm_table *));
EXTERN int stmm_gen ARGS ((stmm_generator *, char **, char **));
EXTERN int stmm_gen_int ARGS ((stmm_generator *, char **, long *));
@@ -120,8 +123,10 @@ EXTERN void stmm_clean ARGS ((stmm_table *));
*/
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif /* STMM_INCLUDED */
diff --git a/src/misc/util/abc_global.h b/src/misc/util/abc_global.h
index 3c6ca9aa..aca9a509 100644
--- a/src/misc/util/abc_global.h
+++ b/src/misc/util/abc_global.h
@@ -24,10 +24,11 @@
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
-
+
#ifdef _WIN32
#define inline __inline // compatible with MS VS 6.0
#pragma warning(disable : 4152) // warning C4152: nonstandard extension, function/data pointer conversion in expression
+#pragma warning(disable : 4200) // warning C4200: nonstandard extension used : zero-sized array in struct/union
#pragma warning(disable : 4244) // warning C4244: '+=' : conversion from 'int ' to 'unsigned short ', possible loss of data
#pragma warning(disable : 4514) // warning C4514: 'Vec_StrPop' : unreferenced inline function has been removed
#pragma warning(disable : 4710) // warning C4710: function 'Vec_PtrGrow' not inlined
@@ -51,13 +52,62 @@
#include <crtdbg.h>
#endif
+#if !defined(___unused)
+#if defined(__GNUC__)
+#define ___unused __attribute__ ((__unused__))
+#else
+#define ___unused
+#endif
+#endif
+
+/*
+#ifdef __cplusplus
+#error "C++ code"
+#else
+#error "C code"
+#endif
+*/
+
+#include <time.h>
+#include <stdarg.h>
+
+#ifndef __cplusplus
+typedef int bool;
+#endif
+
////////////////////////////////////////////////////////////////////////
-/// PARAMETERS ///
+/// NAMESPACES ///
////////////////////////////////////////////////////////////////////////
+//#define ABC_NAMESPACE xxx
+
#ifdef __cplusplus
-extern "C" {
-#endif
+# ifdef ABC_NAMESPACE
+# define ABC_NAMESPACE_HEADER_START namespace ABC_NAMESPACE {
+# define ABC_NAMESPACE_HEADER_END }
+# define ABC_NAMESPACE_IMPL_START namespace ABC_NAMESPACE {
+# define ABC_NAMESPACE_IMPL_END }
+# define ABC_NAMESPACE_PREFIX ABC_NAMESPACE::
+# else
+# define ABC_NAMESPACE_HEADER_START extern "C" {
+# define ABC_NAMESPACE_HEADER_END }
+# define ABC_NAMESPACE_IMPL_START
+# define ABC_NAMESPACE_IMPL_END
+# define ABC_NAMESPACE_PREFIX
+# endif // #ifdef ABC_NAMESPACE
+#else
+# define ABC_NAMESPACE_HEADER_START
+# define ABC_NAMESPACE_HEADER_END
+# define ABC_NAMESPACE_IMPL_START
+# define ABC_NAMESPACE_IMPL_END
+# define ABC_NAMESPACE_PREFIX
+#endif // #ifdef __cplusplus
+
+////////////////////////////////////////////////////////////////////////
+/// PARAMETERS ///
+////////////////////////////////////////////////////////////////////////
+
+ABC_NAMESPACE_HEADER_START
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -144,10 +194,13 @@ typedef unsigned __int64 ABC_UINT64_T;
#error unknown platform
#endif /* defined(PLATFORM) */
+typedef ABC_UINT64_T word;
+
////////////////////////////////////////////////////////////////////////
/// MACRO DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
+
#define ABC_ABS(a) ((a) < 0 ? -(a) : (a))
#define ABC_MAX(a,b) ((a) > (b) ? (a) : (b))
#define ABC_MIN(a,b) ((a) < (b) ? (a) : (b))
@@ -157,8 +210,8 @@ typedef unsigned __int64 ABC_UINT64_T;
#define ABC_PRTr(a,t) (printf("%s = ", (a)), printf("%7.2f sec\r", (float)(t)/(float)(CLOCKS_PER_SEC)))
#define ABC_PRTn(a,t) (printf("%s = ", (a)), printf("%6.2f sec ", (float)(t)/(float)(CLOCKS_PER_SEC)))
#define ABC_PRTP(a,t,T) (printf("%s = ", (a)), printf("%7.2f sec (%6.2f %%)\n", (float)(t)/(float)(CLOCKS_PER_SEC), (T)? 100.0*(t)/(T) : 0.0))
-#define ABC_PRM(a,f) (printf("%s = ", (a)), printf("%7.2f Mb ", 1.0*(f)/(1<<20)))
-
+#define ABC_PRM(a,f) (printf("%s = ", (a)), printf("%7.3f Mb ", 1.0*(f)/(1<<20)))
+#define ABC_PRMP(a,f,F) (printf("%s = ", (a)), printf("%7.3f Mb (%6.2f %%) ", (1.0*(f)/(1<<20)), ((F)? 100.0*(f)/(F) : 0.0) ) )
//#define ABC_USE_MEM_REC 1
@@ -171,7 +224,9 @@ typedef unsigned __int64 ABC_UINT64_T;
((obj) ? ((type *) realloc((char *)(obj), sizeof(type) * (num))) : \
((type *) malloc(sizeof(type) * (num))))
#else
+ABC_NAMESPACE_HEADER_END
#include "utilMem.h"
+ABC_NAMESPACE_HEADER_START
#define ABC_ALLOC(type, num) ((type *) Util_MemRecAlloc(malloc(sizeof(type) * (num))))
#define ABC_CALLOC(type, num) ((type *) Util_MemRecAlloc(calloc((num), sizeof(type))))
#define ABC_FALLOC(type, num) ((type *) memset(Util_MemRecAlloc(malloc(sizeof(type) * (num))), 0xff, sizeof(type) * (num)))
@@ -181,9 +236,71 @@ typedef unsigned __int64 ABC_UINT64_T;
((type *) Util_MemRecAlloc(malloc(sizeof(type) * (num)))))
#endif
-#ifdef __cplusplus
+
+enum Abc_VerbLevel
+{
+ ABC_PROMPT = -2,
+ ABC_ERROR = -1,
+ ABC_WARNING = 0,
+ ABC_STANDARD = 1,
+ ABC_VERBOSE = 2
+};
+
+static inline void Abc_Print( int level, const char * format, ... )
+{
+ va_list args;
+// if ( level > -2 )
+// return;
+ if ( level == ABC_ERROR )
+ printf( "Error: " );
+ else if ( level == ABC_WARNING )
+ printf( "Warning: " );
+ va_start( args, format );
+ vprintf( format, args );
+ va_end( args );
+}
+
+static inline void Abc_PrintTime( int level, const char * pStr, int time )
+{
+ if ( level == ABC_ERROR )
+ printf( "Error: " );
+ else if ( level == ABC_WARNING )
+ printf( "Warning: " );
+ ABC_PRT( pStr, time );
}
-#endif
+
+static inline void Abc_PrintTimeP( int level, const char * pStr, int time, int Time )
+{
+ if ( level == ABC_ERROR )
+ printf( "Error: " );
+ else if ( level == ABC_WARNING )
+ printf( "Warning: " );
+ ABC_PRTP( pStr, time, Time );
+}
+
+static inline void Abc_PrintMemoryP( int level, const char * pStr, int time, int Time )
+{
+ if ( level == ABC_ERROR )
+ printf( "Error: " );
+ else if ( level == ABC_WARNING )
+ printf( "Warning: " );
+ ABC_PRMP( pStr, time, Time );
+}
+
+
+// sequential counter-example
+typedef struct Abc_Cex_t_ Abc_Cex_t;
+struct Abc_Cex_t_
+{
+ int iPo; // the zero-based number of PO, for which verification failed
+ int iFrame; // the zero-based number of the time-frame, for which verificaiton failed
+ int nRegs; // the number of registers in the miter
+ int nPis; // the number of primary inputs in the miter
+ int nBits; // the number of words of bit data used
+ unsigned pData[0]; // the cex bit data (the number of bits: nRegs + (iFrame+1) * nPis)
+};
+
+ABC_NAMESPACE_HEADER_END
#endif
diff --git a/src/misc/util/module.make b/src/misc/util/module.make
index d6d908e7..11d59f51 100644
--- a/src/misc/util/module.make
+++ b/src/misc/util/module.make
@@ -1 +1 @@
-SRC +=
+SRC += utilFile.c
diff --git a/src/misc/util/utilFile.c b/src/misc/util/utilFile.c
new file mode 100644
index 00000000..abdcd635
--- /dev/null
+++ b/src/misc/util/utilFile.c
@@ -0,0 +1,170 @@
+/**CFile****************************************************************
+
+ FileName [utilFile.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Temporary file utilities.]
+
+ Synopsis [Temporary file utilities.]
+
+ Author [Niklas Een]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - September 29, 2010.]
+
+ Revision [$Id: utilFile.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+
+#include "abc_global.h"
+
+ABC_NAMESPACE_IMPL_START
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+#if defined(_MSC_VER)
+
+#include <Windows.h>
+#include <process.h>
+#include <io.h>
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static ABC_UINT64_T realTimeAbs() // -- absolute time in nano-seconds
+{
+ LARGE_INTEGER f, t;
+ double realTime_freq;
+ int ok;
+
+ ok = QueryPerformanceFrequency(&f); assert(ok);
+ realTime_freq = 1.0 / (__int64)(((ABC_UINT64_T)f.LowPart) | ((ABC_UINT64_T)f.HighPart << 32));
+
+ ok = QueryPerformanceCounter(&t); assert(ok);
+ return (ABC_UINT64_T)(__int64)(((__int64)(((ABC_UINT64_T)t.LowPart | ((ABC_UINT64_T)t.HighPart << 32))) * realTime_freq * 1000000000));
+}
+
+#endif
+
+
+
+// Opens a temporary file with given prefix and returns file descriptor (-1 on failure)
+// and a string containing the name of the file (to be freed by caller).
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int tmpFile(const char* prefix, const char* suffix, char** out_name)
+{
+#if !defined(_MSC_VER)
+ int fd;
+
+ *out_name = (char*)malloc(strlen(prefix) + strlen(suffix) + 7);
+ assert(*out_name != NULL);
+ sprintf(*out_name, "%sXXXXXX", prefix);
+ fd = mkstemp(*out_name);
+ if (fd == -1){
+ free(*out_name);
+ *out_name = NULL;
+ }else{
+ // Kludge:
+ close(fd);
+ unlink(*out_name);
+ strcat(*out_name, suffix);
+ fd = open(fd);
+ if (fd == -1){
+ free(*out_name);
+ *out_name = NULL;
+ }
+ }
+ return fd;
+
+#else
+ int i, fd;
+ *out_name = (char*)malloc(strlen(prefix) + strlen(suffix) + 27);
+ for (i = 0; i < 10; i++){
+ sprintf(*out_name, "%s%I64X%d%s", prefix, realTimeAbs(), _getpid(), suffix);
+ fd = _open(*out_name, O_CREAT | O_EXCL | O_BINARY | O_RDWR, _S_IREAD | _S_IWRITE);
+ if (fd == -1){
+ free(*out_name);
+ *out_name = NULL;
+ }
+ return fd;
+ }
+ assert(0); // -- could not open temporary file
+ return 0;
+#endif
+}
+
+
+//mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
+
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+/*
+int main(int argc, char** argv)
+{
+ char* tmp_filename;
+ int fd = tmpFile("__abctmp_", &tmp_filename);
+ FILE* out = fdopen(fd, "wb");
+
+ fprintf(out, "This file contains important information.\n");
+ fclose(out);
+
+ printf("Created: %s\n", tmp_filename);
+ free(tmp_filename);
+
+ return 0;
+}
+*/
+
+
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/util/utilMem.c b/src/misc/util/utilMem.c
new file mode 100644
index 00000000..0bce119b
--- /dev/null
+++ b/src/misc/util/utilMem.c
@@ -0,0 +1,341 @@
+/**CFile****************************************************************
+
+ FileName [utilMem.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Memory recycling utilities.]
+
+ Synopsis [Memory recycling utilities.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: utilMem.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <assert.h>
+
+#include "abc_global.h"
+
+ABC_NAMESPACE_IMPL_START
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+
+typedef struct Vec_Mem_t_ Vec_Mem_t;
+struct Vec_Mem_t_
+{
+ int nCap;
+ int nSize;
+ void ** pArray;
+};
+
+void * s_vAllocs = NULL;
+void * s_vFrees = NULL;
+int s_fInterrupt = 0;
+
+#define ABC_MEM_ALLOC(type, num) ((type *) malloc(sizeof(type) * (num)))
+#define ABC_MEM_CALLOC(type, num) ((type *) calloc((num), sizeof(type)))
+#define ABC_MEM_FALLOC(type, num) ((type *) memset(malloc(sizeof(type) * (num)), 0xff, sizeof(type) * (num)))
+#define ABC_MEM_FREE(obj) ((obj) ? (free((char *) (obj)), (obj) = 0) : 0)
+#define ABC_MEM_REALLOC(type, obj, num) \
+ ((obj) ? ((type *) realloc((char *)(obj), sizeof(type) * (num))) : \
+ ((type *) malloc(sizeof(type) * (num))))
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Allocates a vector with the given capacity.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline Vec_Mem_t * Vec_MemAlloc( int nCap )
+{
+ Vec_Mem_t * p;
+ p = ABC_MEM_ALLOC( Vec_Mem_t, 1 );
+ if ( nCap > 0 && nCap < 8 )
+ nCap = 8;
+ p->nSize = 0;
+ p->nCap = nCap;
+ p->pArray = p->nCap? ABC_MEM_ALLOC( void *, p->nCap ) : NULL;
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Frees the vector.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Vec_MemFree( Vec_Mem_t * p )
+{
+ ABC_MEM_FREE( p->pArray );
+ ABC_MEM_FREE( p );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Resizes the vector to the given capacity.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Vec_MemGrow( Vec_Mem_t * p, int nCapMin )
+{
+ if ( p->nCap >= nCapMin )
+ return;
+ p->pArray = ABC_MEM_REALLOC( void *, p->pArray, nCapMin );
+ p->nCap = nCapMin;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Vec_MemPush( Vec_Mem_t * p, void * Entry )
+{
+ if ( p->nSize == p->nCap )
+ {
+ if ( p->nCap < 16 )
+ Vec_MemGrow( p, 16 );
+ else
+ Vec_MemGrow( p, 2 * p->nCap );
+ }
+ p->pArray[p->nSize++] = Entry;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Sorting the entries by their integer value.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static void Vec_MemSort( Vec_Mem_t * p, int (*Vec_MemSortCompare)() )
+{
+ if ( p->nSize < 2 )
+ return;
+ qsort( (void *)p->pArray, p->nSize, sizeof(void *),
+ (int (*)(const void *, const void *)) Vec_MemSortCompare );
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Remembers an allocated pointer.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void * Util_MemRecAlloc( void * pMem )
+{
+ if ( s_vAllocs )
+ Vec_MemPush( (Vec_Mem_t *)s_vAllocs, pMem );
+ return pMem;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Remembers a deallocated pointer.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void * Util_MemRecFree( void * pMem )
+{
+ if ( s_vFrees )
+ Vec_MemPush( (Vec_Mem_t *)s_vFrees, pMem );
+ return pMem;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Procedure used for sorting the nodes in decreasing order of levels.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Util_ComparePointers( void ** pp1, void ** pp2 )
+{
+ if ( *pp1 < *pp2 )
+ return -1;
+ if ( *pp1 > *pp2 )
+ return 1;
+ return 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Finds entries that do not appear in both lists.]
+
+ Description [Assumes that the vectors are sorted in the increasing order.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline Vec_Mem_t * Vec_MemTwoMerge( Vec_Mem_t * vArr1, Vec_Mem_t * vArr2 )
+{
+ Vec_Mem_t * vArr = Vec_MemAlloc( vArr1->nSize + vArr2->nSize );
+ void ** pBeg = vArr->pArray;
+ void ** pBeg1 = vArr1->pArray;
+ void ** pBeg2 = vArr2->pArray;
+ void ** pEnd1 = vArr1->pArray + vArr1->nSize;
+ void ** pEnd2 = vArr2->pArray + vArr2->nSize;
+ while ( pBeg1 < pEnd1 && pBeg2 < pEnd2 )
+ {
+ if ( *pBeg1 == *pBeg2 )
+ pBeg1++, pBeg2++;
+ else if ( *pBeg1 < *pBeg2 )
+ {
+ free( *pBeg1 );
+ *pBeg++ = *pBeg1++;
+ }
+ else
+ assert( 0 );
+// *pBeg++ = *pBeg2++;
+ }
+ while ( pBeg1 < pEnd1 )
+ *pBeg++ = *pBeg1++;
+// while ( pBeg2 < pEnd2 )
+// *pBeg++ = *pBeg2++;
+ assert( pBeg2 >= pEnd2 );
+ vArr->nSize = pBeg - vArr->pArray;
+ assert( vArr->nSize <= vArr->nCap );
+ assert( vArr->nSize >= vArr1->nSize );
+ assert( vArr->nSize >= vArr2->nSize );
+ return vArr;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Recycles the accumulated memory.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Util_MemRecRecycle()
+{
+ Vec_Mem_t * vMerge;
+ assert( s_vAllocs == NULL );
+ assert( s_vFrees == NULL );
+ Vec_MemSort( (Vec_Mem_t *)s_vAllocs, (int (*)())Util_ComparePointers );
+ Vec_MemSort( (Vec_Mem_t *)s_vFrees, (int (*)())Util_ComparePointers );
+ vMerge = (Vec_Mem_t *)Vec_MemTwoMerge( (Vec_Mem_t *)s_vAllocs, (Vec_Mem_t *)s_vFrees );
+ Vec_MemFree( vMerge );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Starts memory structures.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Util_MemRecStart()
+{
+ assert( s_vAllocs == NULL && s_vFrees == NULL );
+ s_vAllocs = Vec_MemAlloc( 1000 );
+ s_vFrees = Vec_MemAlloc( 1000 );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Quits memory structures.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Util_MemRecQuit()
+{
+ assert( s_vAllocs != NULL && s_vFrees != NULL );
+ Vec_MemFree( (Vec_Mem_t *)s_vAllocs );
+ Vec_MemFree( (Vec_Mem_t *)s_vFrees );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Starts memory structures.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Util_MemRecIsSet()
+{
+ return s_vAllocs != NULL && s_vFrees != NULL;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/util/utilMem.h b/src/misc/util/utilMem.h
new file mode 100644
index 00000000..1f8432c1
--- /dev/null
+++ b/src/misc/util/utilMem.h
@@ -0,0 +1,73 @@
+/**CFile****************************************************************
+
+ FileName [utilInt.h]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Memory recycling utilities.]
+
+ Synopsis [Internal declarations.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: utilInt.h,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#ifndef __UTIL_INT_H__
+#define __UTIL_INT_H__
+
+
+////////////////////////////////////////////////////////////////////////
+/// INCLUDES ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// PARAMETERS ///
+////////////////////////////////////////////////////////////////////////
+
+
+
+ABC_NAMESPACE_HEADER_START
+
+
+extern void * s_vAllocs; // storage of allocated pointers
+extern void * s_vFrees; // storage of deallocated pointers
+extern int s_fInterrupt; // set to 1 when it is time to backout
+
+////////////////////////////////////////////////////////////////////////
+/// BASIC TYPES ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// MACRO DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/*=== utilMem.c ==========================================================*/
+extern void * Util_MemRecAlloc( void * pMem );
+extern void * Util_MemRecFree( void * pMem );
+extern void Util_MemStart();
+extern void Util_MemQuit();
+extern void Util_MemRecycle();
+extern int Util_MemRecIsSet();
+
+
+
+ABC_NAMESPACE_HEADER_END
+
+
+
+#endif
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
diff --git a/src/misc/util/util_hack.h b/src/misc/util/util_hack.h
index 33fb6c6b..f7ad89f9 100644
--- a/src/misc/util/util_hack.h
+++ b/src/misc/util/util_hack.h
@@ -21,17 +21,19 @@
#ifndef __UTIL_HACK_H__
#define __UTIL_HACK_H__
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <time.h>
#include <math.h>
+
#include "abc_global.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+ABC_NAMESPACE_HEADER_START
+
#ifndef EXTERN
#define EXTERN extern
@@ -54,17 +56,13 @@ extern "C" {
#define util_optind globalUtilOptind
#ifndef ARGS
-# ifdef __STDC__
-# define ARGS(args) args
-# else
-# define ARGS(args) ()
-# endif
+#define ARGS(protos) protos
#endif
extern long Extra_CpuTime();
extern int Extra_GetSoftDataLimit();
extern void Extra_UtilGetoptReset();
-extern int Extra_UtilGetopt( int argc, char *argv[], char *optstring );
+extern int Extra_UtilGetopt( int argc, char *argv[], const char *optstring );
extern char * Extra_UtilPrintTime( long t );
extern char * Extra_UtilStrsav( char *s );
extern char * Extra_UtilTildeExpand( char *fname );
@@ -73,8 +71,10 @@ extern char * Extra_UtilFileSearch( char *file, char *path, char *mode );
extern char * globalUtilOptarg;
extern int globalUtilOptind;
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/misc/vec/vec.h b/src/misc/vec/vec.h
index d6ed53b9..fadf6405 100644
--- a/src/misc/vec/vec.h
+++ b/src/misc/vec/vec.h
@@ -21,17 +21,20 @@
#ifndef __VEC_H__
#define __VEC_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
#include "abc_global.h"
+
#include "vecInt.h"
#include "vecFlt.h"
#include "vecStr.h"
#include "vecPtr.h"
#include "vecVec.h"
#include "vecAtt.h"
+#include "vecWrd.h"
////////////////////////////////////////////////////////////////////////
/// MACRO DEFINITIONS ///
@@ -41,9 +44,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -53,9 +57,11 @@ extern "C" {
/// FUNCTION DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/misc/vec/vecAtt.h b/src/misc/vec/vecAtt.h
index 74379bf6..60b2d17a 100644
--- a/src/misc/vec/vecAtt.h
+++ b/src/misc/vec/vecAtt.h
@@ -21,12 +21,16 @@
#ifndef __VEC_ATT_H__
#define __VEC_ATT_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
#include <stdio.h>
+ABC_NAMESPACE_HEADER_START
+
+
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
@@ -65,9 +69,9 @@ struct Vec_Att_t_
void ** pArrayPtr; // the pointer attribute array
// attribute specific info
void * pMan; // the manager for this attribute
- void (*pFuncFreeMan) (void *); // the procedure to ABC_FREE the manager
+ 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 ABC_FREE one attribute
+ void (*pFuncFreeObj) (void *, void *); // the procedure to free one attribute
};
////////////////////////////////////////////////////////////////////////
@@ -282,6 +286,10 @@ static inline void ** Vec_AttArray( Vec_Att_t * p )
return p->pArrayPtr;
}
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif
////////////////////////////////////////////////////////////////////////
diff --git a/src/misc/vec/vecFlt.h b/src/misc/vec/vecFlt.h
index 8f0ea42d..8273b033 100644
--- a/src/misc/vec/vecFlt.h
+++ b/src/misc/vec/vecFlt.h
@@ -21,12 +21,16 @@
#ifndef __VEC_FLT_H__
#define __VEC_FLT_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
#include <stdio.h>
+ABC_NAMESPACE_HEADER_START
+
+
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
@@ -220,6 +224,25 @@ static inline void Vec_FltFree( Vec_Flt_t * p )
SeeAlso []
***********************************************************************/
+static inline void Vec_FltFreeP( Vec_Flt_t ** p )
+{
+ if ( *p == NULL )
+ return;
+ ABC_FREE( (*p)->pArray );
+ ABC_FREE( (*p) );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
static inline float * Vec_FltReleaseArray( Vec_Flt_t * p )
{
float * pArray = p->pArray;
@@ -378,16 +401,17 @@ static inline void Vec_FltFill( Vec_Flt_t * p, int nSize, float Entry )
SeeAlso []
***********************************************************************/
-static inline void Vec_FltFillExtra( Vec_Flt_t * p, int nSize, float Entry )
+static inline void Vec_FltFillExtra( Vec_Flt_t * p, int nSize, float Fill )
{
int i;
- if ( p->nSize >= nSize )
+ if ( nSize <= p->nSize )
return;
- if ( nSize < 2 * p->nSize )
- nSize = 2 * p->nSize;
- Vec_FltGrow( p, nSize );
+ if ( nSize > 2 * p->nCap )
+ Vec_FltGrow( p, nSize );
+ else if ( nSize > p->nCap )
+ Vec_FltGrow( p, 2 * p->nCap );
for ( i = p->nSize; i < nSize; i++ )
- p->pArray[i] = Entry;
+ p->pArray[i] = Fill;
p->nSize = nSize;
}
@@ -628,5 +652,9 @@ static inline void Vec_FltSort( Vec_Flt_t * p, int fReverse )
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif
diff --git a/src/misc/vec/vecInt.h b/src/misc/vec/vecInt.h
index 966f5ac9..6fcce5c6 100644
--- a/src/misc/vec/vecInt.h
+++ b/src/misc/vec/vecInt.h
@@ -21,12 +21,16 @@
#ifndef __VEC_INT_H__
#define __VEC_INT_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
#include <stdio.h>
+ABC_NAMESPACE_HEADER_START
+
+
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
@@ -116,6 +120,26 @@ static inline Vec_Int_t * Vec_IntStart( int nSize )
SeeAlso []
***********************************************************************/
+static inline Vec_Int_t * Vec_IntStartFull( int nSize )
+{
+ Vec_Int_t * p;
+ p = Vec_IntAlloc( nSize );
+ p->nSize = nSize;
+ memset( p->pArray, 0xff, sizeof(int) * nSize );
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Allocates a vector with the given size and cleans it.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
static inline Vec_Int_t * Vec_IntStartNatural( int nSize )
{
Vec_Int_t * p;
@@ -244,6 +268,25 @@ static inline void Vec_IntFree( Vec_Int_t * p )
SeeAlso []
***********************************************************************/
+static inline void Vec_IntFreeP( Vec_Int_t ** p )
+{
+ if ( *p == NULL )
+ return;
+ ABC_FREE( (*p)->pArray );
+ ABC_FREE( (*p) );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
static inline int * Vec_IntReleaseArray( Vec_Int_t * p )
{
int * pArray = p->pArray;
@@ -347,10 +390,10 @@ static inline void Vec_IntWriteEntry( Vec_Int_t * p, int i, int Entry )
SeeAlso []
***********************************************************************/
-static inline void Vec_IntAddToEntry( Vec_Int_t * p, int i, int Addition )
+static inline int Vec_IntAddToEntry( Vec_Int_t * p, int i, int Addition )
{
assert( i >= 0 && i < p->nSize );
- p->pArray[i] += Addition;
+ return p->pArray[i] += Addition;
}
/**Function*************************************************************
@@ -424,11 +467,12 @@ static inline void Vec_IntFill( Vec_Int_t * p, int nSize, int Fill )
static inline void Vec_IntFillExtra( Vec_Int_t * p, int nSize, int Fill )
{
int i;
- if ( p->nSize >= nSize )
+ if ( nSize <= p->nSize )
return;
- if ( nSize < 2 * p->nSize )
- nSize = 2 * p->nSize;
- Vec_IntGrow( p, nSize );
+ if ( nSize > 2 * p->nCap )
+ Vec_IntGrow( p, nSize );
+ else if ( nSize > p->nCap )
+ Vec_IntGrow( p, 2 * p->nCap );
for ( i = p->nSize; i < nSize; i++ )
p->pArray[i] = Fill;
p->nSize = nSize;
@@ -453,6 +497,23 @@ static inline int Vec_IntGetEntry( Vec_Int_t * p, int i )
/**Function*************************************************************
+ Synopsis [Returns the entry even if the place not exist.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int * Vec_IntGetEntryP( Vec_Int_t * p, int i )
+{
+ Vec_IntFillExtra( p, i + 1, 0 );
+ return Vec_IntEntryP( p, i );
+}
+
+/**Function*************************************************************
+
Synopsis [Inserts the entry even if the place does not exist.]
Description []
@@ -713,6 +774,27 @@ static inline int Vec_IntRemove( Vec_Int_t * p, int Entry )
/**Function*************************************************************
+ Synopsis [Interts entry at the index iHere. Shifts other entries.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Vec_IntInsert( Vec_Int_t * p, int iHere, int Entry )
+{
+ int i;
+ assert( iHere >= 0 && iHere < p->nSize );
+ Vec_IntPush( p, 0 );
+ for ( i = p->nSize - 1; i > iHere; i-- )
+ p->pArray[i] = p->pArray[i-1];
+ p->pArray[i] = Entry;
+}
+
+/**Function*************************************************************
+
Synopsis [Find entry.]
Description []
@@ -790,18 +872,66 @@ static inline void Vec_IntReverseOrder( Vec_Int_t * p )
SeeAlso []
***********************************************************************/
-static inline Vec_Int_t * Vec_IntInvert( Vec_Int_t * p )
+static inline Vec_Int_t * Vec_IntInvert( Vec_Int_t * p, int Fill )
{
- Vec_Int_t * vRes;
int Entry, i;
- vRes = Vec_IntStart( Vec_IntFindMax(p) + 1 );
+ Vec_Int_t * vRes = Vec_IntAlloc( 0 );
+ Vec_IntFill( vRes, Vec_IntFindMax(p) + 1, Fill );
Vec_IntForEachEntry( p, Entry, i )
- Vec_IntWriteEntry( vRes, Entry, i );
+ if ( Entry != Fill )
+ Vec_IntWriteEntry( vRes, Entry, i );
return vRes;
}
/**Function*************************************************************
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Vec_IntSum( Vec_Int_t * p )
+{
+ int i, Counter = 0;
+ for ( i = 0; i < p->nSize; i++ )
+ Counter += p->pArray[i];
+ return Counter;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Counts the number of common entries.]
+
+ Description [Assumes that the entries are non-negative integers that
+ are not very large, so inversion of the array can be performed.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Vec_IntCountCommon( Vec_Int_t * p1, Vec_Int_t * p2 )
+{
+ Vec_Int_t * vTemp;
+ int Entry, i, Counter = 0;
+ if ( Vec_IntSize(p1) < Vec_IntSize(p2) )
+ vTemp = p1, p1 = p2, p2 = vTemp;
+ assert( Vec_IntSize(p1) >= Vec_IntSize(p2) );
+ vTemp = Vec_IntInvert( p2, -1 );
+ Vec_IntFillExtra( vTemp, Vec_IntFindMax(p1) + 1, -1 );
+ Vec_IntForEachEntry( p1, Entry, i )
+ if ( Vec_IntEntry(vTemp, Entry) >= 0 )
+ Counter++;
+ Vec_IntFree( vTemp );
+ return Counter;
+}
+
+/**Function*************************************************************
+
Synopsis [Comparison procedure for two integers.]
Description []
@@ -863,6 +993,28 @@ static inline void Vec_IntSort( Vec_Int_t * p, int fReverse )
(int (*)(const void *, const void *)) Vec_IntSortCompare1 );
}
+/**Function*************************************************************
+
+ Synopsis [Leaves only unique entries.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static void Vec_IntUniqify( Vec_Int_t * p )
+{
+ int i, k;
+ if ( p->nSize < 2 )
+ return;
+ Vec_IntSort( p, 0 );
+ for ( i = k = 1; i < p->nSize; i++ )
+ if ( p->pArray[i] != p->pArray[i-1] )
+ p->pArray[k++] = p->pArray[i];
+ p->nSize = k;
+}
/**Function*************************************************************
@@ -970,6 +1122,10 @@ static inline Vec_Int_t * Vec_IntTwoMerge( Vec_Int_t * vArr1, Vec_Int_t * vArr2
return vArr;
}
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif
////////////////////////////////////////////////////////////////////////
diff --git a/src/misc/vec/vecPtr.h b/src/misc/vec/vecPtr.h
index 7b153d90..9915f2d6 100644
--- a/src/misc/vec/vecPtr.h
+++ b/src/misc/vec/vecPtr.h
@@ -21,12 +21,16 @@
#ifndef __VEC_PTR_H__
#define __VEC_PTR_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
#include <stdio.h>
+ABC_NAMESPACE_HEADER_START
+
+
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
@@ -48,16 +52,16 @@ struct Vec_Ptr_t_
////////////////////////////////////////////////////////////////////////
// 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-- )
+#define Vec_PtrForEachEntry( Type, vVec, pEntry, i ) \
+ for ( i = 0; (i < Vec_PtrSize(vVec)) && (((pEntry) = (Type)Vec_PtrEntry(vVec, i)), 1); i++ )
+#define Vec_PtrForEachEntryStart( Type, vVec, pEntry, i, Start ) \
+ for ( i = Start; (i < Vec_PtrSize(vVec)) && (((pEntry) = (Type)Vec_PtrEntry(vVec, i)), 1); i++ )
+#define Vec_PtrForEachEntryStop( Type, vVec, pEntry, i, Stop ) \
+ for ( i = 0; (i < Stop) && (((pEntry) = (Type)Vec_PtrEntry(vVec, i)), 1); i++ )
+#define Vec_PtrForEachEntryStartStop( Type, vVec, pEntry, i, Start, Stop ) \
+ for ( i = Start; (i < Stop) && (((pEntry) = (Type)Vec_PtrEntry(vVec, i)), 1); i++ )
+#define Vec_PtrForEachEntryReverse( Type, vVec, pEntry, i ) \
+ for ( i = Vec_PtrSize(vVec) - 1; (i >= 0) && (((pEntry) = (Type)Vec_PtrEntry(vVec, i)), 1); i-- )
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
@@ -223,6 +227,25 @@ static inline void Vec_PtrFree( Vec_Ptr_t * p )
SeeAlso []
***********************************************************************/
+static inline void Vec_PtrFreeP( Vec_Ptr_t ** p )
+{
+ if ( *p == NULL )
+ return;
+ ABC_FREE( (*p)->pArray );
+ ABC_FREE( (*p) );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
static inline void ** Vec_PtrReleaseArray( Vec_Ptr_t * p )
{
void ** pArray = p->pArray;
@@ -382,17 +405,17 @@ static inline void Vec_PtrFill( Vec_Ptr_t * p, int nSize, void * Entry )
SeeAlso []
***********************************************************************/
-static inline void Vec_PtrFillExtra( Vec_Ptr_t * p, int nSize, void * Entry )
+static inline void Vec_PtrFillExtra( Vec_Ptr_t * p, int nSize, void * Fill )
{
int i;
- if ( p->nSize >= nSize )
+ if ( nSize <= p->nSize )
return;
- assert( p->nSize < nSize );
- if ( nSize < 2 * p->nSize )
- nSize = 2 * p->nSize;
- Vec_PtrGrow( p, nSize );
+ if ( nSize > 2 * p->nCap )
+ Vec_PtrGrow( p, nSize );
+ else if ( nSize > p->nCap )
+ Vec_PtrGrow( p, 2 * p->nCap );
for ( i = p->nSize; i < nSize; i++ )
- p->pArray[i] = Entry;
+ p->pArray[i] = Fill;
p->nSize = nSize;
}
@@ -479,7 +502,7 @@ static inline void Vec_PtrFreeFree( Vec_Ptr_t * p )
void * pTemp;
int i;
if ( p == NULL ) return;
- Vec_PtrForEachEntry( p, pTemp, i )
+ Vec_PtrForEachEntry( void *, p, pTemp, i )
ABC_FREE( pTemp );
Vec_PtrFree( p );
}
@@ -537,6 +560,33 @@ static inline void Vec_PtrPush( Vec_Ptr_t * p, void * Entry )
SeeAlso []
***********************************************************************/
+static inline void Vec_PtrPushFirst( Vec_Ptr_t * p, void * Entry )
+{
+ int i;
+ if ( p->nSize == p->nCap )
+ {
+ if ( p->nCap < 16 )
+ Vec_PtrGrow( p, 16 );
+ else
+ Vec_PtrGrow( 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 []
+
+***********************************************************************/
static inline int Vec_PtrPushUnique( Vec_Ptr_t * p, void * Entry )
{
int i;
@@ -617,6 +667,27 @@ static inline void Vec_PtrRemove( Vec_Ptr_t * p, void * Entry )
/**Function*************************************************************
+ Synopsis [Interts entry at the index iHere. Shifts other entries.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Vec_PtrInsert( Vec_Ptr_t * p, int iHere, void * Entry )
+{
+ int i;
+ assert( iHere >= 0 && iHere < p->nSize );
+ Vec_PtrPush( p, 0 );
+ for ( i = p->nSize - 1; i > iHere; i-- )
+ p->pArray[i] = p->pArray[i-1];
+ p->pArray[i] = Entry;
+}
+
+/**Function*************************************************************
+
Synopsis [Moves the first nItems to the end.]
Description []
@@ -659,6 +730,26 @@ static inline void Vec_PtrReverseOrder( Vec_Ptr_t * p )
/**Function*************************************************************
+ Synopsis [Comparison procedure for two integers.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static int Vec_PtrSortComparePtr( void ** pp1, void ** pp2 )
+{
+ if ( *pp1 < *pp2 )
+ return -1;
+ if ( *pp1 > *pp2 )
+ return 1;
+ return 0;
+}
+
+/**Function*************************************************************
+
Synopsis [Sorting the entries by their integer value.]
Description []
@@ -668,12 +759,17 @@ static inline void Vec_PtrReverseOrder( Vec_Ptr_t * p )
SeeAlso []
***********************************************************************/
+static void Vec_PtrSort( Vec_Ptr_t * p, int (*Vec_PtrSortCompare)() ) ___unused;
static void Vec_PtrSort( Vec_Ptr_t * p, int (*Vec_PtrSortCompare)() )
{
if ( p->nSize < 2 )
return;
- qsort( (void *)p->pArray, p->nSize, sizeof(void *),
- (int (*)(const void *, const void *)) Vec_PtrSortCompare );
+ if ( Vec_PtrSortCompare == NULL )
+ qsort( (void *)p->pArray, p->nSize, sizeof(void *),
+ (int (*)(const void *, const void *)) Vec_PtrSortComparePtr );
+ else
+ qsort( (void *)p->pArray, p->nSize, sizeof(void *),
+ (int (*)(const void *, const void *)) Vec_PtrSortCompare );
}
/**Function*************************************************************
@@ -687,13 +783,13 @@ static void Vec_PtrSort( Vec_Ptr_t * p, int (*Vec_PtrSortCompare)() )
SeeAlso []
***********************************************************************/
+static void Vec_PtrUniqify( Vec_Ptr_t * p, int (*Vec_PtrSortCompare)() ) ___unused;
static void Vec_PtrUniqify( Vec_Ptr_t * p, int (*Vec_PtrSortCompare)() )
{
int i, k;
if ( p->nSize < 2 )
return;
- qsort( (void *)p->pArray, p->nSize, sizeof(void *),
- (int (*)(const void *, const void *)) Vec_PtrSortCompare );
+ Vec_PtrSort( p, Vec_PtrSortCompare );
for ( i = k = 1; i < p->nSize; i++ )
if ( p->pArray[i] != p->pArray[i-1] )
p->pArray[k++] = p->pArray[i];
@@ -880,6 +976,10 @@ static inline Vec_Ptr_t * Vec_PtrAllocTruthTables( int nVars )
return p;
}
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif
diff --git a/src/misc/vec/vecStr.h b/src/misc/vec/vecStr.h
index bd10154c..c92760f2 100644
--- a/src/misc/vec/vecStr.h
+++ b/src/misc/vec/vecStr.h
@@ -21,12 +21,16 @@
#ifndef __VEC_STR_H__
#define __VEC_STR_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
#include <stdio.h>
+ABC_NAMESPACE_HEADER_START
+
+
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
@@ -214,6 +218,25 @@ static inline void Vec_StrFree( Vec_Str_t * p )
SeeAlso []
***********************************************************************/
+static inline void Vec_StrFreeP( Vec_Str_t ** p )
+{
+ if ( *p == NULL )
+ return;
+ ABC_FREE( (*p)->pArray );
+ ABC_FREE( (*p) );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
static inline char * Vec_StrReleaseArray( Vec_Str_t * p )
{
char * pArray = p->pArray;
@@ -359,11 +382,12 @@ static inline void Vec_StrFill( Vec_Str_t * p, int nSize, char Fill )
static inline void Vec_StrFillExtra( Vec_Str_t * p, int nSize, char Fill )
{
int i;
- if ( p->nSize >= nSize )
+ if ( nSize <= p->nSize )
return;
- if ( nSize < 2 * p->nSize )
- nSize = 2 * p->nSize;
- Vec_StrGrow( p, nSize );
+ if ( nSize > 2 * p->nCap )
+ Vec_StrGrow( p, nSize );
+ else if ( nSize > p->nCap )
+ Vec_StrGrow( p, 2 * p->nCap );
for ( i = p->nSize; i < nSize; i++ )
p->pArray[i] = Fill;
p->nSize = nSize;
@@ -459,26 +483,22 @@ static inline void Vec_StrPush( Vec_Str_t * p, char Entry )
p->pArray[p->nSize++] = Entry;
}
-/**Function********************************************************************
-
- Synopsis [Finds the smallest integer larger of equal than the logarithm.]
+/**Function*************************************************************
- Description [Returns [Log10(Num)].]
+ Synopsis [Returns the last entry and removes it from the list.]
+ Description []
+
SideEffects []
SeeAlso []
-******************************************************************************/
-static inline int Vec_StrBase10Log( unsigned Num )
+***********************************************************************/
+static inline char Vec_StrPop( Vec_Str_t * p )
{
- 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 */
+ assert( p->nSize > 0 );
+ return p->pArray[--p->nSize];
+}
/**Function*************************************************************
@@ -493,26 +513,22 @@ static inline int Vec_StrBase10Log( unsigned Num )
***********************************************************************/
static inline void Vec_StrPrintNum( Vec_Str_t * p, int Num )
{
- int i, nDigits;
- if ( Num < 0 )
- {
- Vec_StrPush( p, '-' );
- Num = -Num;
- }
- if ( Num < 10 )
+ int i;
+ char Digits[16];
+ if ( Num == 0 )
{
- Vec_StrPush( p, (char)('0' + Num) );
+ Vec_StrPush( p, '0' );
return;
}
- nDigits = Vec_StrBase10Log( Num );
- Vec_StrGrow( p, p->nSize + nDigits );
- for ( i = nDigits - 1; i >= 0; i-- )
+ if ( Num < 0 )
{
- Vec_StrWriteEntry( p, p->nSize + i, (char)('0' + Num % 10) );
- Num /= 10;
+ Vec_StrPush( p, '-' );
+ Num = -Num;
}
- assert( Num == 0 );
- p->nSize += nDigits;
+ for ( i = 0; Num; Num /= 10, i++ )
+ Digits[i] = (char)('0' + Num % 10);
+ for ( i--; i >= 0; i-- )
+ Vec_StrPush( p, Digits[i] );
}
/**Function*************************************************************
@@ -526,7 +542,7 @@ static inline void Vec_StrPrintNum( Vec_Str_t * p, int Num )
SeeAlso []
***********************************************************************/
-static inline void Vec_StrPrintStr( Vec_Str_t * p, char * pStr )
+static inline void Vec_StrPrintStr( Vec_Str_t * p, const char * pStr )
{
int i, Length = strlen(pStr);
for ( i = 0; i < Length; i++ )
@@ -544,30 +560,9 @@ static inline void Vec_StrPrintStr( Vec_Str_t * p, char * pStr )
SeeAlso []
***********************************************************************/
-static inline void Vec_StrAppend( Vec_Str_t * p, char * pString )
+static inline void Vec_StrAppend( Vec_Str_t * p, const 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];
+ Vec_StrPrintStr( p, pString );
}
/**Function*************************************************************
@@ -655,6 +650,10 @@ static inline void Vec_StrSort( Vec_Str_t * p, int fReverse )
(int (*)(const void *, const void *)) Vec_StrSortCompare1 );
}
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif
////////////////////////////////////////////////////////////////////////
diff --git a/src/misc/vec/vecVec.h b/src/misc/vec/vecVec.h
index a77cdf76..8915329b 100644
--- a/src/misc/vec/vecVec.h
+++ b/src/misc/vec/vecVec.h
@@ -21,12 +21,16 @@
#ifndef __VEC_VEC_H__
#define __VEC_VEC_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
#include <stdio.h>
+ABC_NAMESPACE_HEADER_START
+
+
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
@@ -60,26 +64,26 @@ struct Vec_Vec_t_
for ( i = LevelStart; (i >= LevelStop) && (((vVec) = (Vec_Ptr_t*)Vec_VecEntry(vGlob, i)), 1); i-- )
// iteratores through entries
-#define Vec_VecForEachEntry( vGlob, pEntry, i, k ) \
+#define Vec_VecForEachEntry( Type, vGlob, pEntry, i, k ) \
for ( i = 0; i < Vec_VecSize(vGlob); i++ ) \
- Vec_PtrForEachEntry( Vec_VecEntry(vGlob, i), pEntry, k )
-#define Vec_VecForEachEntryLevel( vGlob, pEntry, i, Level ) \
- Vec_PtrForEachEntry( Vec_VecEntry(vGlob, Level), pEntry, i )
-#define Vec_VecForEachEntryStart( vGlob, pEntry, i, k, LevelStart ) \
+ Vec_PtrForEachEntry( Type, (Vec_Ptr_t *)Vec_VecEntry(vGlob, i), pEntry, k )
+#define Vec_VecForEachEntryLevel( Type, vGlob, pEntry, i, Level ) \
+ Vec_PtrForEachEntry( Type, (Vec_Ptr_t *)Vec_VecEntry(vGlob, Level), pEntry, i )
+#define Vec_VecForEachEntryStart( Type, 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 ) \
+ Vec_PtrForEachEntry( Type, (Vec_Ptr_t *)Vec_VecEntry(vGlob, i), pEntry, k )
+#define Vec_VecForEachEntryStartStop( Type, 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 ) \
+ Vec_PtrForEachEntry( Type, (Vec_Ptr_t *)Vec_VecEntry(vGlob, i), pEntry, k )
+#define Vec_VecForEachEntryReverse( Type, 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 ) \
+ Vec_PtrForEachEntryReverse( Type, (Vec_Ptr_t *)Vec_VecEntry(vGlob, i), pEntry, k )
+#define Vec_VecForEachEntryReverseReverse( Type, vGlob, pEntry, i, k ) \
for ( i = Vec_VecSize(vGlob) - 1; i >= 0; i-- ) \
- Vec_PtrForEachEntryReverse( Vec_VecEntry(vGlob, i), pEntry, k )
-#define Vec_VecForEachEntryReverseStart( vGlob, pEntry, i, k, LevelStart ) \
+ Vec_PtrForEachEntryReverse( Type, (Vec_Ptr_t *)Vec_VecEntry(vGlob, i), pEntry, k )
+#define Vec_VecForEachEntryReverseStart( Type, vGlob, pEntry, i, k, LevelStart ) \
for ( i = LevelStart; i >= 0; i-- ) \
- Vec_PtrForEachEntry( Vec_VecEntry(vGlob, i), pEntry, k )
+ Vec_PtrForEachEntry( Type, (Vec_Ptr_t *)Vec_VecEntry(vGlob, i), pEntry, k )
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
@@ -207,6 +211,25 @@ static inline void Vec_VecFree( Vec_Vec_t * p )
/**Function*************************************************************
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Vec_VecFreeP( Vec_Vec_t ** p )
+{
+ if ( *p == NULL )
+ return;
+ Vec_VecFree( *p );
+ *p = NULL;
+}
+
+/**Function*************************************************************
+
Synopsis [Frees the vector.]
Description []
@@ -390,6 +413,10 @@ static inline void Vec_VecSort( Vec_Vec_t * p, int fReverse )
(int (*)(const void *, const void *)) Vec_VecSortCompare1 );
}
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif
////////////////////////////////////////////////////////////////////////
diff --git a/src/misc/vec/vecWrd.h b/src/misc/vec/vecWrd.h
new file mode 100644
index 00000000..94449262
--- /dev/null
+++ b/src/misc/vec/vecWrd.h
@@ -0,0 +1,1071 @@
+/**CFile****************************************************************
+
+ FileName [vecWrd.h]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [Resizable arrays.]
+
+ Synopsis [Resizable arrays of long unsigned integers.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: vecWrd.h,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#ifndef __VEC_WRD_H__
+#define __VEC_WRD_H__
+
+
+////////////////////////////////////////////////////////////////////////
+/// INCLUDES ///
+////////////////////////////////////////////////////////////////////////
+
+#include <stdio.h>
+
+ABC_NAMESPACE_HEADER_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// PARAMETERS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// BASIC TYPES ///
+////////////////////////////////////////////////////////////////////////
+
+typedef struct Vec_Wrd_t_ Vec_Wrd_t;
+struct Vec_Wrd_t_
+{
+ int nCap;
+ int nSize;
+ word * pArray;
+};
+
+////////////////////////////////////////////////////////////////////////
+/// MACRO DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+#define Vec_WrdForEachEntry( vVec, Entry, i ) \
+ for ( i = 0; (i < Vec_WrdSize(vVec)) && (((Entry) = Vec_WrdEntry(vVec, i)), 1); i++ )
+#define Vec_WrdForEachEntryStart( vVec, Entry, i, Start ) \
+ for ( i = Start; (i < Vec_WrdSize(vVec)) && (((Entry) = Vec_WrdEntry(vVec, i)), 1); i++ )
+#define Vec_WrdForEachEntryStop( vVec, Entry, i, Stop ) \
+ for ( i = 0; (i < Stop) && (((Entry) = Vec_WrdEntry(vVec, i)), 1); i++ )
+#define Vec_WrdForEachEntryStartStop( vVec, Entry, i, Start, Stop ) \
+ for ( i = Start; (i < Stop) && (((Entry) = Vec_WrdEntry(vVec, i)), 1); i++ )
+#define Vec_WrdForEachEntryReverse( vVec, pEntry, i ) \
+ for ( i = Vec_WrdSize(vVec) - 1; (i >= 0) && (((pEntry) = Vec_WrdEntry(vVec, i)), 1); i-- )
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Allocates a vector with the given capacity.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline Vec_Wrd_t * Vec_WrdAlloc( int nCap )
+{
+ Vec_Wrd_t * p;
+ p = ABC_ALLOC( Vec_Wrd_t, 1 );
+ if ( nCap > 0 && nCap < 16 )
+ nCap = 16;
+ p->nSize = 0;
+ p->nCap = nCap;
+ p->pArray = p->nCap? ABC_ALLOC( word, p->nCap ) : NULL;
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Allocates a vector with the given size and cleans it.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline Vec_Wrd_t * Vec_WrdStart( int nSize )
+{
+ Vec_Wrd_t * p;
+ p = Vec_WrdAlloc( nSize );
+ p->nSize = nSize;
+ memset( p->pArray, 0, sizeof(word) * nSize );
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Allocates a vector with the given size and cleans it.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline Vec_Wrd_t * Vec_WrdStartFull( int nSize )
+{
+ Vec_Wrd_t * p;
+ p = Vec_WrdAlloc( nSize );
+ p->nSize = nSize;
+ memset( p->pArray, 0xff, sizeof(word) * nSize );
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Allocates a vector with the given size and cleans it.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline Vec_Wrd_t * Vec_WrdStartNatural( int nSize )
+{
+ Vec_Wrd_t * p;
+ int i;
+ p = Vec_WrdAlloc( nSize );
+ p->nSize = nSize;
+ for ( i = 0; i < nSize; i++ )
+ p->pArray[i] = i;
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Creates the vector from an integer array of the given size.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline Vec_Wrd_t * Vec_WrdAllocArray( word * pArray, int nSize )
+{
+ Vec_Wrd_t * p;
+ p = ABC_ALLOC( Vec_Wrd_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_Wrd_t * Vec_WrdAllocArrayCopy( word * pArray, int nSize )
+{
+ Vec_Wrd_t * p;
+ p = ABC_ALLOC( Vec_Wrd_t, 1 );
+ p->nSize = nSize;
+ p->nCap = nSize;
+ p->pArray = ABC_ALLOC( word, nSize );
+ memcpy( p->pArray, pArray, sizeof(word) * nSize );
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Duplicates the integer array.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline Vec_Wrd_t * Vec_WrdDup( Vec_Wrd_t * pVec )
+{
+ Vec_Wrd_t * p;
+ p = ABC_ALLOC( Vec_Wrd_t, 1 );
+ p->nSize = pVec->nSize;
+ p->nCap = pVec->nSize;
+ p->pArray = p->nCap? ABC_ALLOC( word, p->nCap ) : NULL;
+ memcpy( p->pArray, pVec->pArray, sizeof(word) * pVec->nSize );
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Transfers the array into another vector.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline Vec_Wrd_t * Vec_WrdDupArray( Vec_Wrd_t * pVec )
+{
+ Vec_Wrd_t * p;
+ p = ABC_ALLOC( Vec_Wrd_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_WrdFree( Vec_Wrd_t * p )
+{
+ ABC_FREE( p->pArray );
+ ABC_FREE( p );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Vec_WrdFreeP( Vec_Wrd_t ** p )
+{
+ if ( *p == NULL )
+ return;
+ ABC_FREE( (*p)->pArray );
+ ABC_FREE( (*p) );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline word * Vec_WrdReleaseArray( Vec_Wrd_t * p )
+{
+ word * pArray = p->pArray;
+ p->nCap = 0;
+ p->nSize = 0;
+ p->pArray = NULL;
+ return pArray;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline word * Vec_WrdArray( Vec_Wrd_t * p )
+{
+ return p->pArray;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Vec_WrdSize( Vec_Wrd_t * p )
+{
+ return p->nSize;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline word Vec_WrdEntry( Vec_Wrd_t * p, int i )
+{
+ assert( i >= 0 && i < p->nSize );
+ return p->pArray[i];
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline word * Vec_WrdEntryP( Vec_Wrd_t * p, int i )
+{
+ assert( i >= 0 && i < p->nSize );
+ return p->pArray + i;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Vec_WrdWriteEntry( Vec_Wrd_t * p, int i, word Entry )
+{
+ assert( i >= 0 && i < p->nSize );
+ p->pArray[i] = Entry;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline word Vec_WrdAddToEntry( Vec_Wrd_t * p, int i, int Addition )
+{
+ assert( i >= 0 && i < p->nSize );
+ return p->pArray[i] += Addition;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline word Vec_WrdEntryLast( Vec_Wrd_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_WrdGrow( Vec_Wrd_t * p, int nCapMin )
+{
+ if ( p->nCap >= nCapMin )
+ return;
+ p->pArray = ABC_REALLOC( word, 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_WrdFill( Vec_Wrd_t * p, int nSize, int Fill )
+{
+ int i;
+ Vec_WrdGrow( p, nSize );
+ for ( i = 0; i < nSize; i++ )
+ p->pArray[i] = Fill;
+ p->nSize = nSize;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Fills the vector with given number of entries.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Vec_WrdFillExtra( Vec_Wrd_t * p, int nSize, int Fill )
+{
+ int i;
+ if ( nSize <= p->nSize )
+ return;
+ if ( nSize > 2 * p->nCap )
+ Vec_WrdGrow( p, nSize );
+ else if ( nSize > p->nCap )
+ Vec_WrdGrow( p, 2 * p->nCap );
+ for ( i = p->nSize; i < nSize; i++ )
+ p->pArray[i] = Fill;
+ p->nSize = nSize;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the entry even if the place not exist.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline word Vec_WrdGetEntry( Vec_Wrd_t * p, int i )
+{
+ Vec_WrdFillExtra( p, i + 1, 0 );
+ return Vec_WrdEntry( p, i );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the entry even if the place not exist.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline word * Vec_WrdGetEntryP( Vec_Wrd_t * p, int i )
+{
+ Vec_WrdFillExtra( p, i + 1, 0 );
+ return Vec_WrdEntryP( p, i );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Inserts the entry even if the place does not exist.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Vec_WrdSetEntry( Vec_Wrd_t * p, int i, word Entry )
+{
+ Vec_WrdFillExtra( p, i + 1, 0 );
+ Vec_WrdWriteEntry( p, i, Entry );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Vec_WrdShrink( Vec_Wrd_t * p, int nSizeNew )
+{
+ assert( p->nSize >= nSizeNew );
+ p->nSize = nSizeNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Vec_WrdClear( Vec_Wrd_t * p )
+{
+ p->nSize = 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Vec_WrdPush( Vec_Wrd_t * p, word Entry )
+{
+ if ( p->nSize == p->nCap )
+ {
+ if ( p->nCap < 16 )
+ Vec_WrdGrow( p, 16 );
+ else
+ Vec_WrdGrow( p, 2 * p->nCap );
+ }
+ p->pArray[p->nSize++] = Entry;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Vec_WrdPushFirst( Vec_Wrd_t * p, word Entry )
+{
+ int i;
+ if ( p->nSize == p->nCap )
+ {
+ if ( p->nCap < 16 )
+ Vec_WrdGrow( p, 16 );
+ else
+ Vec_WrdGrow( 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 [Inserts the entry while preserving the increasing order.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Vec_WrdPushOrder( Vec_Wrd_t * p, word Entry )
+{
+ int i;
+ if ( p->nSize == p->nCap )
+ {
+ if ( p->nCap < 16 )
+ Vec_WrdGrow( p, 16 );
+ else
+ Vec_WrdGrow( 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_WrdPushUniqueOrder( Vec_Wrd_t * p, word Entry )
+{
+ int i;
+ for ( i = 0; i < p->nSize; i++ )
+ if ( p->pArray[i] == Entry )
+ return 1;
+ Vec_WrdPushOrder( p, Entry );
+ return 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Vec_WrdPushUnique( Vec_Wrd_t * p, word Entry )
+{
+ int i;
+ for ( i = 0; i < p->nSize; i++ )
+ if ( p->pArray[i] == Entry )
+ return 1;
+ Vec_WrdPush( p, Entry );
+ return 0;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the pointer to the next nWords entries in the vector.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline word * Vec_WrdFetch( Vec_Wrd_t * p, int nWords )
+{
+ if ( nWords == 0 )
+ return NULL;
+ assert( nWords > 0 );
+ p->nSize += nWords;
+ if ( p->nSize > p->nCap )
+ {
+// Vec_WrdGrow( p, 2 * p->nSize );
+ return NULL;
+ }
+ return p->pArray + p->nSize - nWords;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Returns the last entry and removes it from the list.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline word Vec_WrdPop( Vec_Wrd_t * p )
+{
+ assert( p->nSize > 0 );
+ return p->pArray[--p->nSize];
+}
+
+/**Function*************************************************************
+
+ Synopsis [Find entry.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Vec_WrdFind( Vec_Wrd_t * p, word 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_WrdRemove( Vec_Wrd_t * p, word 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 [Interts entry at the index iHere. Shifts other entries.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Vec_WrdInsert( Vec_Wrd_t * p, int iHere, word Entry )
+{
+ int i;
+ assert( iHere >= 0 && iHere < p->nSize );
+ Vec_WrdPush( p, 0 );
+ for ( i = p->nSize - 1; i > iHere; i-- )
+ p->pArray[i] = p->pArray[i-1];
+ p->pArray[i] = Entry;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Find entry.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline word Vec_WrdFindMax( Vec_Wrd_t * p )
+{
+ word Best;
+ int i;
+ if ( p->nSize == 0 )
+ return 0;
+ Best = p->pArray[0];
+ for ( i = 1; i < p->nSize; i++ )
+ if ( Best < p->pArray[i] )
+ Best = p->pArray[i];
+ return Best;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Find entry.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline word Vec_WrdFindMin( Vec_Wrd_t * p )
+{
+ word Best;
+ int i;
+ if ( p->nSize == 0 )
+ return 0;
+ Best = p->pArray[0];
+ for ( i = 1; i < p->nSize; i++ )
+ if ( Best > p->pArray[i] )
+ Best = p->pArray[i];
+ return Best;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Reverses the order of entries.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Vec_WrdReverseOrder( Vec_Wrd_t * p )
+{
+ word Temp;
+ int i;
+ for ( i = 0; i < p->nSize/2; i++ )
+ {
+ Temp = p->pArray[i];
+ p->pArray[i] = p->pArray[p->nSize-1-i];
+ p->pArray[p->nSize-1-i] = Temp;
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline Vec_Wrd_t * Vec_WrdInvert( Vec_Wrd_t * p, word Fill )
+{
+ int i;
+ word Entry;
+ Vec_Wrd_t * vRes = Vec_WrdAlloc( 0 );
+ Vec_WrdFill( vRes, Vec_WrdFindMax(p) + 1, Fill );
+ Vec_WrdForEachEntry( p, Entry, i )
+ if ( Entry != Fill )
+ Vec_WrdWriteEntry( vRes, Entry, i );
+ return vRes;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline word Vec_WrdSum( Vec_Wrd_t * p )
+{
+ word Counter = 0;
+ int i;
+ for ( i = 0; i < p->nSize; i++ )
+ Counter += p->pArray[i];
+ return Counter;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Counts the number of common entries.]
+
+ Description [Assumes that the entries are non-negative integers that
+ are not very large, so inversion of the array can be performed.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Vec_WrdCountCommon( Vec_Wrd_t * p1, Vec_Wrd_t * p2 )
+{
+ Vec_Wrd_t * vTemp;
+ word Entry;
+ int i, Counter = 0;
+ if ( Vec_WrdSize(p1) < Vec_WrdSize(p2) )
+ vTemp = p1, p1 = p2, p2 = vTemp;
+ assert( Vec_WrdSize(p1) >= Vec_WrdSize(p2) );
+ vTemp = Vec_WrdInvert( p2, -1 );
+ Vec_WrdFillExtra( vTemp, Vec_WrdFindMax(p1) + 1, -1 );
+ Vec_WrdForEachEntry( p1, Entry, i )
+ if ( Vec_WrdEntry(vTemp, Entry) >= 0 )
+ Counter++;
+ Vec_WrdFree( vTemp );
+ return Counter;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Comparison procedure for two integers.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static int Vec_WrdSortCompare1( word * pp1, word * 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 int Vec_WrdSortCompare2( word * pp1, word * 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_WrdSort( Vec_Wrd_t * p, int fReverse )
+{
+ if ( fReverse )
+ qsort( (void *)p->pArray, p->nSize, sizeof(word),
+ (int (*)(const void *, const void *)) Vec_WrdSortCompare2 );
+ else
+ qsort( (void *)p->pArray, p->nSize, sizeof(word),
+ (int (*)(const void *, const void *)) Vec_WrdSortCompare1 );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Leaves only unique entries.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static void Vec_WrdUniqify( Vec_Wrd_t * p )
+{
+ int i, k;
+ if ( p->nSize < 2 )
+ return;
+ Vec_WrdSort( p, 0 );
+ for ( i = k = 1; i < p->nSize; i++ )
+ if ( p->pArray[i] != p->pArray[i-1] )
+ p->pArray[k++] = p->pArray[i];
+ p->nSize = k;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Comparison procedure for two integers.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static int Vec_WrdSortCompareUnsigned( word * pp1, word * 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_WrdSortUnsigned( Vec_Wrd_t * p )
+{
+ qsort( (void *)p->pArray, p->nSize, sizeof(word),
+ (int (*)(const void *, const void *)) Vec_WrdSortCompareUnsigned );
+}
+
+
+
+ABC_NAMESPACE_HEADER_END
+
+#endif
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
diff --git a/src/misc/zlib/README b/src/misc/zlib/README
index 758cc500..d4219bf8 100644
--- a/src/misc/zlib/README
+++ b/src/misc/zlib/README
@@ -1,56 +1,52 @@
ZLIB DATA COMPRESSION LIBRARY
-zlib 1.2.3 is a general purpose data compression library. All the code is
+zlib 1.2.5 is a general purpose data compression library. All the code is
thread safe. The data format used by the zlib library is described by RFCs
(Request for Comments) 1950 to 1952 in the files
http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format)
-and rfc1952.txt (gzip format). These documents are also available in other
-formats from ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html
+and rfc1952.txt (gzip format).
All functions of the compression library are documented in the file zlib.h
-(volunteer to write man pages welcome, contact zlib@gzip.org). A usage example
+(volunteer to write man pages welcome, contact zlib@gzip.org). A usage example
of the library is given in the file example.c which also tests that the library
-is working correctly. Another example is given in the file minigzip.c. The
+is working correctly. Another example is given in the file minigzip.c. The
compression library itself is composed of all source files except example.c and
minigzip.c.
To compile all files and run the test program, follow the instructions given at
-the top of Makefile. In short "make test; make install" should work for most
-machines. For Unix: "./configure; make test; make install". For MSDOS, use one
-of the special makefiles such as Makefile.msc. For VMS, use make_vms.com.
+the top of Makefile.in. In short "./configure; make test", and if that goes
+well, "make install" should work for most flavors of Unix. For Windows, use one
+of the special makefiles in win32/ or contrib/vstudio/ . For VMS, use
+make_vms.com.
Questions about zlib should be sent to <zlib@gzip.org>, or to Gilles Vollant
-<info@winimage.com> for the Windows DLL version. The zlib home page is
-http://www.zlib.org or http://www.gzip.org/zlib/ Before reporting a problem,
-please check this site to verify that you have the latest version of zlib;
-otherwise get the latest version and check whether the problem still exists or
-not.
+<info@winimage.com> for the Windows DLL version. The zlib home page is
+http://zlib.net/ . Before reporting a problem, please check this site to
+verify that you have the latest version of zlib; otherwise get the latest
+version and check whether the problem still exists or not.
-PLEASE read the zlib FAQ http://www.gzip.org/zlib/zlib_faq.html before asking
-for help.
+PLEASE read the zlib FAQ http://zlib.net/zlib_faq.html before asking for help.
-Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997
-issue of Dr. Dobb's Journal; a copy of the article is available in
-http://dogma.net/markn/articles/zlibtool/zlibtool.htm
+Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997
+issue of Dr. Dobb's Journal; a copy of the article is available at
+http://marknelson.us/1997/01/01/zlib-engine/ .
-The changes made in version 1.2.3 are documented in the file ChangeLog.
+The changes made in version 1.2.5 are documented in the file ChangeLog.
-Unsupported third party contributions are provided in directory "contrib".
+Unsupported third party contributions are provided in directory contrib/ .
-A Java implementation of zlib is available in the Java Development Kit
-http://java.sun.com/j2se/1.4.2/docs/api/java/util/zip/package-summary.html
-See the zlib home page http://www.zlib.org for details.
+zlib is available in Java using the java.util.zip package, documented at
+http://java.sun.com/developer/technicalArticles/Programming/compression/ .
-A Perl interface to zlib written by Paul Marquess <pmqs@cpan.org> is in the
-CPAN (Comprehensive Perl Archive Network) sites
-http://www.cpan.org/modules/by-module/Compress/
+A Perl interface to zlib written by Paul Marquess <pmqs@cpan.org> is available
+at CPAN (Comprehensive Perl Archive Network) sites, including
+http://search.cpan.org/~pmqs/IO-Compress-Zlib/ .
A Python interface to zlib written by A.M. Kuchling <amk@amk.ca> is
available in Python 1.5 and later versions, see
-http://www.python.org/doc/lib/module-zlib.html
+http://www.python.org/doc/lib/module-zlib.html .
-A zlib binding for TCL written by Andreas Kupries <a.kupries@westend.com> is
-availlable at http://www.oche.de/~akupries/soft/trf/trf_zip.html
+zlib is built into tcl: http://wiki.tcl.tk/4610 .
An experimental package to read and write files in .zip format, written on top
of zlib by Gilles Vollant <info@winimage.com>, is available in the
@@ -74,25 +70,21 @@ Notes for some targets:
- zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with
other compilers. Use "make test" to check your compiler.
-- gzdopen is not supported on RISCOS, BEOS and by some Mac compilers.
+- gzdopen is not supported on RISCOS or BEOS.
- For PalmOs, see http://palmzlib.sourceforge.net/
-- When building a shared, i.e. dynamic library on Mac OS X, the library must be
- installed before testing (do "make install" before "make test"), since the
- library location is specified in the library.
-
Acknowledgments:
- The deflate format used by zlib was defined by Phil Katz. The deflate
- and zlib specifications were written by L. Peter Deutsch. Thanks to all the
- people who reported problems and suggested various improvements in zlib;
- they are too numerous to cite here.
+ The deflate format used by zlib was defined by Phil Katz. The deflate and
+ zlib specifications were written by L. Peter Deutsch. Thanks to all the
+ people who reported problems and suggested various improvements in zlib; they
+ are too numerous to cite here.
Copyright notice:
- (C) 1995-2004 Jean-loup Gailly and Mark Adler
+ (C) 1995-2010 Jean-loup Gailly and Mark Adler
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -113,13 +105,11 @@ Copyright notice:
Jean-loup Gailly Mark Adler
jloup@gzip.org madler@alumni.caltech.edu
-If you use the zlib library in a product, we would appreciate *not*
-receiving lengthy legal documents to sign. The sources are provided
-for free but without warranty of any kind. The library has been
-entirely written by Jean-loup Gailly and Mark Adler; it does not
-include third-party code.
+If you use the zlib library in a product, we would appreciate *not* receiving
+lengthy legal documents to sign. The sources are provided for free but without
+warranty of any kind. The library has been entirely written by Jean-loup
+Gailly and Mark Adler; it does not include third-party code.
-If you redistribute modified sources, we would appreciate that you include
-in the file ChangeLog history information documenting your changes. Please
-read the FAQ for more information on the distribution of modified source
-versions.
+If you redistribute modified sources, we would appreciate that you include in
+the file ChangeLog history information documenting your changes. Please read
+the FAQ for more information on the distribution of modified source versions.
diff --git a/src/misc/zlib/adler32.c b/src/misc/zlib/adler32.c
index 007ba262..7783d96c 100644
--- a/src/misc/zlib/adler32.c
+++ b/src/misc/zlib/adler32.c
@@ -1,12 +1,22 @@
/* adler32.c -- compute the Adler-32 checksum of a data stream
- * Copyright (C) 1995-2004 Mark Adler
+ * Copyright (C) 1995-2007 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* @(#) $Id$ */
-#define ZLIB_INTERNAL
-#include "zlib.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "abc_global.h"
+
+#include "zutil.h"
+
+ABC_NAMESPACE_IMPL_START
+
+#define local static
+
+local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2);
#define BASE 65521UL /* largest prime smaller than 65536 */
#define NMAX 5552
@@ -54,10 +64,7 @@
#endif
/* ========================================================================= */
-uLong ZEXPORT adler32(adler, buf, len)
- uLong adler;
- const Bytef *buf;
- uInt len;
+uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len)
{
unsigned long sum2;
unsigned n;
@@ -125,10 +132,7 @@ uLong ZEXPORT adler32(adler, buf, len)
}
/* ========================================================================= */
-uLong ZEXPORT adler32_combine(adler1, adler2, len2)
- uLong adler1;
- uLong adler2;
- z_off_t len2;
+local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2)
{
unsigned long sum1;
unsigned long sum2;
@@ -141,9 +145,24 @@ uLong ZEXPORT adler32_combine(adler1, adler2, len2)
MOD(sum2);
sum1 += (adler2 & 0xffff) + BASE - 1;
sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
- if (sum1 > BASE) sum1 -= BASE;
- if (sum1 > BASE) sum1 -= BASE;
- if (sum2 > (BASE << 1)) sum2 -= (BASE << 1);
- if (sum2 > BASE) sum2 -= BASE;
+ if (sum1 >= BASE) sum1 -= BASE;
+ if (sum1 >= BASE) sum1 -= BASE;
+ if (sum2 >= (BASE << 1)) sum2 -= (BASE << 1);
+ if (sum2 >= BASE) sum2 -= BASE;
return sum1 | (sum2 << 16);
}
+
+/* ========================================================================= */
+uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2, z_off_t len2)
+{
+ return adler32_combine_(adler1, adler2, len2);
+}
+
+uLong ZEXPORT adler32_combine64(uLong adler1, uLong adler2, z_off64_t len2)
+{
+ return adler32_combine_(adler1, adler2, len2);
+}
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/zlib/compress_.c b/src/misc/zlib/compress_.c
index df04f014..7fbfdb3b 100644
--- a/src/misc/zlib/compress_.c
+++ b/src/misc/zlib/compress_.c
@@ -1,5 +1,5 @@
/* compress.c -- compress a memory buffer
- * Copyright (C) 1995-2003 Jean-loup Gailly.
+ * Copyright (C) 1995-2005 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -8,6 +8,8 @@
#define ZLIB_INTERNAL
#include "zlib.h"
+ABC_NAMESPACE_IMPL_START
+
/* ===========================================================================
Compresses the source buffer into the destination buffer. The level
parameter has the same meaning as in deflateInit. sourceLen is the byte
@@ -19,12 +21,7 @@
memory, Z_BUF_ERROR if there was not enough room in the output buffer,
Z_STREAM_ERROR if the level parameter is invalid.
*/
-int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
- Bytef *dest;
- uLongf *destLen;
- const Bytef *source;
- uLong sourceLen;
- int level;
+int ZEXPORT compress2 (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen, int level)
{
z_stream stream;
int err;
@@ -59,11 +56,7 @@ int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
/* ===========================================================================
*/
-int ZEXPORT compress (dest, destLen, source, sourceLen)
- Bytef *dest;
- uLongf *destLen;
- const Bytef *source;
- uLong sourceLen;
+int ZEXPORT compress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)
{
return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
}
@@ -72,8 +65,12 @@ int ZEXPORT compress (dest, destLen, source, sourceLen)
If the default memLevel or windowBits for deflateInit() is changed, then
this function needs to be updated.
*/
-uLong ZEXPORT compressBound (sourceLen)
- uLong sourceLen;
+uLong ZEXPORT compressBound (uLong sourceLen)
{
- return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 11;
+ return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
+ (sourceLen >> 25) + 13;
}
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/zlib/crc32.c b/src/misc/zlib/crc32.c
index f658a9ef..749480ef 100644
--- a/src/misc/zlib/crc32.c
+++ b/src/misc/zlib/crc32.c
@@ -1,5 +1,5 @@
/* crc32.c -- compute the CRC-32 of a data stream
- * Copyright (C) 1995-2005 Mark Adler
+ * Copyright (C) 1995-2006, 2010 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*
* Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster
@@ -26,14 +26,23 @@
# endif /* !DYNAMIC_CRC_TABLE */
#endif /* MAKECRCH */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "abc_global.h"
+
#include "zutil.h" /* for STDC and FAR definitions */
+ABC_NAMESPACE_IMPL_START
+
#define local static
/* Find a four-byte integer type for crc32_little() and crc32_big(). */
#ifndef NOBYFOUR
# ifdef STDC /* need ANSI C limits.h to determine sizes */
+ABC_NAMESPACE_IMPL_END
# include <limits.h>
+ABC_NAMESPACE_IMPL_START
# define BYFOUR
# if (UINT_MAX == 0xffffffffUL)
typedef unsigned int u4;
@@ -53,7 +62,7 @@
/* Definitions for doing the crc four data bytes at a time. */
#ifdef BYFOUR
-# define REV(w) (((w)>>24)+(((w)>>8)&0xff00)+ \
+# define REV(w) ((((w)>>24)&0xff)+(((w)>>8)&0xff00)+ \
(((w)&0xff00)<<8)+(((w)&0xff)<<24))
local unsigned long crc32_little OF((unsigned long,
const unsigned char FAR *, unsigned));
@@ -68,6 +77,8 @@
local unsigned long gf2_matrix_times OF((unsigned long *mat,
unsigned long vec));
local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat));
+local uLong crc32_combine_(uLong crc1, uLong crc2, z_off64_t len2);
+
#ifdef DYNAMIC_CRC_TABLE
@@ -180,9 +191,7 @@ local void make_crc_table()
}
#ifdef MAKECRCH
-local void write_table(out, table)
- FILE *out;
- const unsigned long FAR *table;
+local void write_table(FILE *out, const unsigned long FAR *table)
{
int n;
@@ -196,7 +205,9 @@ local void write_table(out, table)
/* ========================================================================
* Tables of CRC-32s of all single-byte values, made by make_crc_table().
*/
+ABC_NAMESPACE_IMPL_END
#include "crc32.h"
+ABC_NAMESPACE_IMPL_START
#endif /* DYNAMIC_CRC_TABLE */
/* =========================================================================
@@ -216,10 +227,7 @@ const unsigned long FAR * ZEXPORT get_crc_table()
#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
/* ========================================================================= */
-unsigned long ZEXPORT crc32(crc, buf, len)
- unsigned long crc;
- const unsigned char FAR *buf;
- unsigned len;
+unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf, uInt len)
{
if (buf == Z_NULL) return 0UL;
@@ -259,10 +267,7 @@ unsigned long ZEXPORT crc32(crc, buf, len)
#define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4
/* ========================================================================= */
-local unsigned long crc32_little(crc, buf, len)
- unsigned long crc;
- const unsigned char FAR *buf;
- unsigned len;
+local unsigned long crc32_little(unsigned long crc, const unsigned char FAR *buf, unsigned len)
{
register u4 c;
register const u4 FAR *buf4;
@@ -299,10 +304,7 @@ local unsigned long crc32_little(crc, buf, len)
#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4
/* ========================================================================= */
-local unsigned long crc32_big(crc, buf, len)
- unsigned long crc;
- const unsigned char FAR *buf;
- unsigned len;
+local unsigned long crc32_big(unsigned long crc, const unsigned char FAR *buf, unsigned len)
{
register u4 c;
register const u4 FAR *buf4;
@@ -339,9 +341,7 @@ local unsigned long crc32_big(crc, buf, len)
#define GF2_DIM 32 /* dimension of GF(2) vectors (length of CRC) */
/* ========================================================================= */
-local unsigned long gf2_matrix_times(mat, vec)
- unsigned long *mat;
- unsigned long vec;
+local unsigned long gf2_matrix_times(unsigned long *mat, unsigned long vec)
{
unsigned long sum;
@@ -356,9 +356,7 @@ local unsigned long gf2_matrix_times(mat, vec)
}
/* ========================================================================= */
-local void gf2_matrix_square(square, mat)
- unsigned long *square;
- unsigned long *mat;
+local void gf2_matrix_square(unsigned long *square, unsigned long *mat)
{
int n;
@@ -367,22 +365,19 @@ local void gf2_matrix_square(square, mat)
}
/* ========================================================================= */
-uLong ZEXPORT crc32_combine(crc1, crc2, len2)
- uLong crc1;
- uLong crc2;
- z_off_t len2;
+local uLong crc32_combine_(uLong crc1, uLong crc2, z_off64_t len2)
{
int n;
unsigned long row;
unsigned long even[GF2_DIM]; /* even-power-of-two zeros operator */
unsigned long odd[GF2_DIM]; /* odd-power-of-two zeros operator */
- /* degenerate case */
- if (len2 == 0)
+ /* degenerate case (also disallow negative lengths) */
+ if (len2 <= 0)
return crc1;
/* put operator for one zero bit in odd */
- odd[0] = 0xedb88320L; /* CRC-32 polynomial */
+ odd[0] = 0xedb88320UL; /* CRC-32 polynomial */
row = 1;
for (n = 1; n < GF2_DIM; n++) {
odd[n] = row;
@@ -421,3 +416,18 @@ uLong ZEXPORT crc32_combine(crc1, crc2, len2)
crc1 ^= crc2;
return crc1;
}
+
+/* ========================================================================= */
+uLong ZEXPORT crc32_combine(uLong crc1, uLong crc2, z_off_t len2)
+{
+ return crc32_combine_(crc1, crc2, len2);
+}
+
+uLong ZEXPORT crc32_combine64(uLong crc1, uLong crc2, z_off64_t len2)
+{
+ return crc32_combine_(crc1, crc2, len2);
+}
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/zlib/crc32.h b/src/misc/zlib/crc32.h
index 8053b611..d023439a 100644
--- a/src/misc/zlib/crc32.h
+++ b/src/misc/zlib/crc32.h
@@ -2,6 +2,8 @@
* Generated automatically by crc32.c
*/
+ABC_NAMESPACE_HEADER_START
+
local const unsigned long FAR crc_table[TBLS][256] =
{
{
@@ -439,3 +441,5 @@ local const unsigned long FAR crc_table[TBLS][256] =
#endif
}
};
+
+ABC_NAMESPACE_HEADER_END
diff --git a/src/misc/zlib/deflate.c b/src/misc/zlib/deflate.c
index 29ce1f64..ceeeed06 100644
--- a/src/misc/zlib/deflate.c
+++ b/src/misc/zlib/deflate.c
@@ -1,5 +1,5 @@
/* deflate.c -- compress data using the deflation algorithm
- * Copyright (C) 1995-2005 Jean-loup Gailly.
+ * Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -49,10 +49,17 @@
/* @(#) $Id$ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "abc_global.h"
+
#include "deflate.h"
+ABC_NAMESPACE_IMPL_START
+
const char deflate_copyright[] =
- " deflate 1.2.3 Copyright 1995-2005 Jean-loup Gailly ";
+ " deflate 1.2.5 Copyright 1995-2010 Jean-loup Gailly and Mark Adler ";
/*
If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot
@@ -79,19 +86,18 @@ local block_state deflate_fast OF((deflate_state *s, int flush));
#ifndef FASTEST
local block_state deflate_slow OF((deflate_state *s, int flush));
#endif
+local block_state deflate_rle OF((deflate_state *s, int flush));
+local block_state deflate_huff OF((deflate_state *s, int flush));
local void lm_init OF((deflate_state *s));
local void putShortMSB OF((deflate_state *s, uInt b));
local void flush_pending OF((z_streamp strm));
local int read_buf OF((z_streamp strm, Bytef *buf, unsigned size));
-#ifndef FASTEST
#ifdef ASMV
void match_init OF((void)); /* asm code initialization */
uInt longest_match OF((deflate_state *s, IPos cur_match));
#else
local uInt longest_match OF((deflate_state *s, IPos cur_match));
#endif
-#endif
-local uInt longest_match_fast OF((deflate_state *s, IPos cur_match));
#ifdef DEBUG
local void check_match OF((deflate_state *s, IPos start, IPos match,
@@ -110,11 +116,6 @@ local void check_match OF((deflate_state *s, IPos start, IPos match,
#endif
/* Matches of length 3 are discarded if their distance exceeds TOO_FAR */
-#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
-/* Minimum amount of lookahead, except at the end of the input file.
- * See deflate.c for comments about the MIN_MATCH+1.
- */
-
/* Values for max_lazy_match, good_match and max_chain_length, depending on
* the desired pack level (0..9). The values given below have been tuned to
* exclude worst case performance for pathological files. Better values may be
@@ -201,11 +202,7 @@ struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head));
/* ========================================================================= */
-int ZEXPORT deflateInit_(strm, level, version, stream_size)
- z_streamp strm;
- int level;
- const char *version;
- int stream_size;
+int ZEXPORT deflateInit_(z_streamp strm, int level, const char *version, int stream_size)
{
return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL,
Z_DEFAULT_STRATEGY, version, stream_size);
@@ -213,16 +210,8 @@ int ZEXPORT deflateInit_(strm, level, version, stream_size)
}
/* ========================================================================= */
-int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
- version, stream_size)
- z_streamp strm;
- int level;
- int method;
- int windowBits;
- int memLevel;
- int strategy;
- const char *version;
- int stream_size;
+int ZEXPORT deflateInit2_(z_streamp strm, int level, int method, int windowBits, int memLevel, int strategy,
+ const char *version, int stream_size)
{
deflate_state *s;
int wrap = 1;
@@ -288,6 +277,8 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos));
s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos));
+ s->high_water = 0; /* nothing written to s->window yet */
+
s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */
overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);
@@ -312,10 +303,7 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
}
/* ========================================================================= */
-int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
- z_streamp strm;
- const Bytef *dictionary;
- uInt dictLength;
+int ZEXPORT deflateSetDictionary (z_streamp strm, const Bytef *dictionary, uInt dictLength)
{
deflate_state *s;
uInt length = dictLength;
@@ -332,8 +320,8 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
strm->adler = adler32(strm->adler, dictionary, dictLength);
if (length < MIN_MATCH) return Z_OK;
- if (length > MAX_DIST(s)) {
- length = MAX_DIST(s);
+ if (length > s->w_size) {
+ length = s->w_size;
dictionary += dictLength - length; /* use the tail of the dictionary */
}
zmemcpy(s->window, dictionary, length);
@@ -354,8 +342,7 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
}
/* ========================================================================= */
-int ZEXPORT deflateReset (strm)
- z_streamp strm;
+int ZEXPORT deflateReset (z_streamp strm)
{
deflate_state *s;
@@ -390,9 +377,7 @@ int ZEXPORT deflateReset (strm)
}
/* ========================================================================= */
-int ZEXPORT deflateSetHeader (strm, head)
- z_streamp strm;
- gz_headerp head;
+int ZEXPORT deflateSetHeader (z_streamp strm, gz_headerp head)
{
if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
if (strm->state->wrap != 2) return Z_STREAM_ERROR;
@@ -401,10 +386,7 @@ int ZEXPORT deflateSetHeader (strm, head)
}
/* ========================================================================= */
-int ZEXPORT deflatePrime (strm, bits, value)
- z_streamp strm;
- int bits;
- int value;
+int ZEXPORT deflatePrime (z_streamp strm, int bits, int value)
{
if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
strm->state->bi_valid = bits;
@@ -413,10 +395,7 @@ int ZEXPORT deflatePrime (strm, bits, value)
}
/* ========================================================================= */
-int ZEXPORT deflateParams(strm, level, strategy)
- z_streamp strm;
- int level;
- int strategy;
+int ZEXPORT deflateParams(z_streamp strm, int level, int strategy)
{
deflate_state *s;
compress_func func;
@@ -435,9 +414,10 @@ int ZEXPORT deflateParams(strm, level, strategy)
}
func = configuration_table[s->level].func;
- if (func != configuration_table[level].func && strm->total_in != 0) {
+ if ((strategy != s->strategy || func != configuration_table[level].func) &&
+ strm->total_in != 0) {
/* Flush the last buffer: */
- err = deflate(strm, Z_PARTIAL_FLUSH);
+ err = deflate(strm, Z_BLOCK);
}
if (s->level != level) {
s->level = level;
@@ -451,12 +431,7 @@ int ZEXPORT deflateParams(strm, level, strategy)
}
/* ========================================================================= */
-int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain)
- z_streamp strm;
- int good_length;
- int max_lazy;
- int nice_length;
- int max_chain;
+int ZEXPORT deflateTune(z_streamp strm, int good_length, int max_lazy, int nice_length, int max_chain)
{
deflate_state *s;
@@ -481,33 +456,64 @@ int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain)
* resulting from using fixed blocks instead of stored blocks, which deflate
* can emit on compressed data for some combinations of the parameters.
*
- * This function could be more sophisticated to provide closer upper bounds
- * for every combination of windowBits and memLevel, as well as wrap.
- * But even the conservative upper bound of about 14% expansion does not
- * seem onerous for output buffer allocation.
+ * This function could be more sophisticated to provide closer upper bounds for
+ * every combination of windowBits and memLevel. But even the conservative
+ * upper bound of about 14% expansion does not seem onerous for output buffer
+ * allocation.
*/
-uLong ZEXPORT deflateBound(strm, sourceLen)
- z_streamp strm;
- uLong sourceLen;
+uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen)
{
deflate_state *s;
- uLong destLen;
+ uLong complen, wraplen;
+ Bytef *str;
- /* conservative upper bound */
- destLen = sourceLen +
- ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 11;
+ /* conservative upper bound for compressed data */
+ complen = sourceLen +
+ ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 5;
- /* if can't get parameters, return conservative bound */
+ /* if can't get parameters, return conservative bound plus zlib wrapper */
if (strm == Z_NULL || strm->state == Z_NULL)
- return destLen;
+ return complen + 6;
- /* if not default parameters, return conservative bound */
+ /* compute wrapper length */
s = strm->state;
+ switch (s->wrap) {
+ case 0: /* raw deflate */
+ wraplen = 0;
+ break;
+ case 1: /* zlib wrapper */
+ wraplen = 6 + (s->strstart ? 4 : 0);
+ break;
+ case 2: /* gzip wrapper */
+ wraplen = 18;
+ if (s->gzhead != Z_NULL) { /* user-supplied gzip header */
+ if (s->gzhead->extra != Z_NULL)
+ wraplen += 2 + s->gzhead->extra_len;
+ str = s->gzhead->name;
+ if (str != Z_NULL)
+ do {
+ wraplen++;
+ } while (*str++);
+ str = s->gzhead->comment;
+ if (str != Z_NULL)
+ do {
+ wraplen++;
+ } while (*str++);
+ if (s->gzhead->hcrc)
+ wraplen += 2;
+ }
+ break;
+ default: /* for compiler happiness */
+ wraplen = 6;
+ }
+
+ /* if not default parameters, return conservative bound */
if (s->w_bits != 15 || s->hash_bits != 8 + 7)
- return destLen;
+ return complen + wraplen;
/* default settings: return tight bound for that case */
- return compressBound(sourceLen);
+ return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
+ (sourceLen >> 25) + 13 - 6 + wraplen;
}
/* =========================================================================
@@ -515,9 +521,7 @@ uLong ZEXPORT deflateBound(strm, sourceLen)
* IN assertion: the stream state is correct and there is enough room in
* pending_buf.
*/
-local void putShortMSB (s, b)
- deflate_state *s;
- uInt b;
+local void putShortMSB (deflate_state *s, uInt b)
{
put_byte(s, (Byte)(b >> 8));
put_byte(s, (Byte)(b & 0xff));
@@ -529,8 +533,7 @@ local void putShortMSB (s, b)
* to avoid allocating a large strm->next_out buffer and copying into it.
* (See also read_buf()).
*/
-local void flush_pending(strm)
- z_streamp strm;
+local void flush_pending(z_streamp strm)
{
unsigned len = strm->state->pending;
@@ -549,15 +552,13 @@ local void flush_pending(strm)
}
/* ========================================================================= */
-int ZEXPORT deflate (strm, flush)
- z_streamp strm;
- int flush;
+int ZEXPORT deflate (z_streamp strm, int flush)
{
int old_flush; /* value of flush param for previous deflate call */
deflate_state *s;
if (strm == Z_NULL || strm->state == Z_NULL ||
- flush > Z_FINISH || flush < 0) {
+ flush > Z_BLOCK || flush < 0) {
return Z_STREAM_ERROR;
}
s = strm->state;
@@ -581,7 +582,7 @@ int ZEXPORT deflate (strm, flush)
put_byte(s, 31);
put_byte(s, 139);
put_byte(s, 8);
- if (s->gzhead == NULL) {
+ if (s->gzhead == Z_NULL) {
put_byte(s, 0);
put_byte(s, 0);
put_byte(s, 0);
@@ -608,7 +609,7 @@ int ZEXPORT deflate (strm, flush)
(s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
4 : 0));
put_byte(s, s->gzhead->os & 0xff);
- if (s->gzhead->extra != NULL) {
+ if (s->gzhead->extra != Z_NULL) {
put_byte(s, s->gzhead->extra_len & 0xff);
put_byte(s, (s->gzhead->extra_len >> 8) & 0xff);
}
@@ -650,7 +651,7 @@ int ZEXPORT deflate (strm, flush)
}
#ifdef GZIP
if (s->status == EXTRA_STATE) {
- if (s->gzhead->extra != NULL) {
+ if (s->gzhead->extra != Z_NULL) {
uInt beg = s->pending; /* start of bytes to update crc */
while (s->gzindex < (s->gzhead->extra_len & 0xffff)) {
@@ -678,7 +679,7 @@ int ZEXPORT deflate (strm, flush)
s->status = NAME_STATE;
}
if (s->status == NAME_STATE) {
- if (s->gzhead->name != NULL) {
+ if (s->gzhead->name != Z_NULL) {
uInt beg = s->pending; /* start of bytes to update crc */
int val;
@@ -709,7 +710,7 @@ int ZEXPORT deflate (strm, flush)
s->status = COMMENT_STATE;
}
if (s->status == COMMENT_STATE) {
- if (s->gzhead->comment != NULL) {
+ if (s->gzhead->comment != Z_NULL) {
uInt beg = s->pending; /* start of bytes to update crc */
int val;
@@ -787,7 +788,9 @@ int ZEXPORT deflate (strm, flush)
(flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {
block_state bstate;
- bstate = (*(configuration_table[s->level].func))(s, flush);
+ bstate = s->strategy == Z_HUFFMAN_ONLY ? deflate_huff(s, flush) :
+ (s->strategy == Z_RLE ? deflate_rle(s, flush) :
+ (*(configuration_table[s->level].func))(s, flush));
if (bstate == finish_started || bstate == finish_done) {
s->status = FINISH_STATE;
@@ -808,13 +811,17 @@ int ZEXPORT deflate (strm, flush)
if (bstate == block_done) {
if (flush == Z_PARTIAL_FLUSH) {
_tr_align(s);
- } else { /* FULL_FLUSH or SYNC_FLUSH */
+ } else if (flush != Z_BLOCK) { /* FULL_FLUSH or SYNC_FLUSH */
_tr_stored_block(s, (char*)0, 0L, 0);
/* For a full flush, this empty block will be recognized
* as a special marker by inflate_sync().
*/
if (flush == Z_FULL_FLUSH) {
CLEAR_HASH(s); /* forget history */
+ if (s->lookahead == 0) {
+ s->strstart = 0;
+ s->block_start = 0L;
+ }
}
}
flush_pending(strm);
@@ -856,8 +863,7 @@ int ZEXPORT deflate (strm, flush)
}
/* ========================================================================= */
-int ZEXPORT deflateEnd (strm)
- z_streamp strm;
+int ZEXPORT deflateEnd (z_streamp strm)
{
int status;
@@ -891,9 +897,7 @@ int ZEXPORT deflateEnd (strm)
* To simplify the source, this is not supported for 16-bit MSDOS (which
* doesn't have enough memory anyway to duplicate compression states).
*/
-int ZEXPORT deflateCopy (dest, source)
- z_streamp dest;
- z_streamp source;
+int ZEXPORT deflateCopy (z_streamp dest, z_streamp source)
{
#ifdef MAXSEG_64K
return Z_STREAM_ERROR;
@@ -953,10 +957,7 @@ int ZEXPORT deflateCopy (dest, source)
* allocating a large strm->next_in buffer and copying from it.
* (See also flush_pending()).
*/
-local int read_buf(strm, buf, size)
- z_streamp strm;
- Bytef *buf;
- unsigned size;
+local int read_buf(z_streamp strm, Bytef *buf, unsigned size)
{
unsigned len = strm->avail_in;
@@ -983,8 +984,7 @@ local int read_buf(strm, buf, size)
/* ===========================================================================
* Initialize the "longest match" routines for a new zlib stream
*/
-local void lm_init (s)
- deflate_state *s;
+local void lm_init (deflate_state *s)
{
s->window_size = (ulg)2L*s->w_size;
@@ -1024,9 +1024,7 @@ local void lm_init (s)
/* For 80x86 and 680x0, an optimized version will be provided in match.asm or
* match.S. The code will be functionally equivalent.
*/
-local uInt longest_match(s, cur_match)
- deflate_state *s;
- IPos cur_match; /* current match */
+local uInt longest_match(deflate_state *s, IPos cur_match)
{
unsigned chain_length = s->max_chain_length;/* max hash chain length */
register Bytef *scan = s->window + s->strstart; /* current string */
@@ -1167,14 +1165,13 @@ local uInt longest_match(s, cur_match)
return s->lookahead;
}
#endif /* ASMV */
-#endif /* FASTEST */
+
+#else /* FASTEST */
/* ---------------------------------------------------------------------------
- * Optimized version for level == 1 or strategy == Z_RLE only
+ * Optimized version for FASTEST only
*/
-local uInt longest_match_fast(s, cur_match)
- deflate_state *s;
- IPos cur_match; /* current match */
+local uInt longest_match(deflate_state *s, IPos cur_match)
{
register Bytef *scan = s->window + s->strstart; /* current string */
register Bytef *match; /* matched string */
@@ -1225,14 +1222,13 @@ local uInt longest_match_fast(s, cur_match)
return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead;
}
+#endif /* FASTEST */
+
#ifdef DEBUG
/* ===========================================================================
* Check that the match at match_start is indeed a match.
*/
-local void check_match(s, start, match, length)
- deflate_state *s;
- IPos start, match;
- int length;
+local void check_match(deflate_state *s, IPos start, IPos match, int length)
{
/* check that the match is indeed a match */
if (zmemcmp(s->window + match,
@@ -1263,8 +1259,7 @@ local void check_match(s, start, match, length)
* performed for at least two bytes (required for the zip translate_eol
* option -- not supported here).
*/
-local void fill_window(s)
- deflate_state *s;
+local void fill_window(deflate_state *s)
{
register unsigned n, m;
register Posf *p;
@@ -1303,7 +1298,6 @@ local void fill_window(s)
later. (Using level 0 permanently is not an optimal usage of
zlib, so we don't care about this pathological case.)
*/
- /* %%% avoid this when Z_RLE */
n = s->hash_size;
p = &s->head[n];
do {
@@ -1355,27 +1349,61 @@ local void fill_window(s)
*/
} while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0);
+
+ /* If the WIN_INIT bytes after the end of the current data have never been
+ * written, then zero those bytes in order to avoid memory check reports of
+ * the use of uninitialized (or uninitialised as Julian writes) bytes by
+ * the longest match routines. Update the high water mark for the next
+ * time through here. WIN_INIT is set to MAX_MATCH since the longest match
+ * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead.
+ */
+ if (s->high_water < s->window_size) {
+ ulg curr = s->strstart + (ulg)(s->lookahead);
+ ulg init;
+
+ if (s->high_water < curr) {
+ /* Previous high water mark below current data -- zero WIN_INIT
+ * bytes or up to end of window, whichever is less.
+ */
+ init = s->window_size - curr;
+ if (init > WIN_INIT)
+ init = WIN_INIT;
+ zmemzero(s->window + curr, (unsigned)init);
+ s->high_water = curr + init;
+ }
+ else if (s->high_water < (ulg)curr + WIN_INIT) {
+ /* High water mark at or above current data, but below current data
+ * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up
+ * to end of window, whichever is less.
+ */
+ init = (ulg)curr + WIN_INIT - s->high_water;
+ if (init > s->window_size - s->high_water)
+ init = s->window_size - s->high_water;
+ zmemzero(s->window + s->high_water, (unsigned)init);
+ s->high_water += init;
+ }
+ }
}
/* ===========================================================================
* Flush the current block, with given end-of-file flag.
* IN assertion: strstart is set to the end of the current match.
*/
-#define FLUSH_BLOCK_ONLY(s, eof) { \
+#define FLUSH_BLOCK_ONLY(s, last) { \
_tr_flush_block(s, (s->block_start >= 0L ? \
(charf *)&s->window[(unsigned)s->block_start] : \
(charf *)Z_NULL), \
(ulg)((long)s->strstart - s->block_start), \
- (eof)); \
+ (last)); \
s->block_start = s->strstart; \
flush_pending(s->strm); \
Tracev((stderr,"[FLUSH]")); \
}
/* Same but force premature exit if necessary. */
-#define FLUSH_BLOCK(s, eof) { \
- FLUSH_BLOCK_ONLY(s, eof); \
- if (s->strm->avail_out == 0) return (eof) ? finish_started : need_more; \
+#define FLUSH_BLOCK(s, last) { \
+ FLUSH_BLOCK_ONLY(s, last); \
+ if (s->strm->avail_out == 0) return (last) ? finish_started : need_more; \
}
/* ===========================================================================
@@ -1387,9 +1415,7 @@ local void fill_window(s)
* NOTE: this function should be optimized to avoid extra copying from
* window to pending_buf.
*/
-local block_state deflate_stored(s, flush)
- deflate_state *s;
- int flush;
+local block_state deflate_stored(deflate_state *s, int flush)
{
/* Stored blocks are limited to 0xffff bytes, pending_buf is limited
* to pending_buf_size, and each stored block has a 5 byte header:
@@ -1445,11 +1471,9 @@ local block_state deflate_stored(s, flush)
* new strings in the dictionary only for unmatched strings or for short
* matches. It is used only for the fast compression options.
*/
-local block_state deflate_fast(s, flush)
- deflate_state *s;
- int flush;
+local block_state deflate_fast(deflate_state *s, int flush)
{
- IPos hash_head = NIL; /* head of the hash chain */
+ IPos hash_head; /* head of the hash chain */
int bflush; /* set if current block must be flushed */
for (;;) {
@@ -1469,6 +1493,7 @@ local block_state deflate_fast(s, flush)
/* Insert the string window[strstart .. strstart+2] in the
* dictionary, and set hash_head to the head of the hash chain:
*/
+ hash_head = NIL;
if (s->lookahead >= MIN_MATCH) {
INSERT_STRING(s, s->strstart, hash_head);
}
@@ -1481,19 +1506,8 @@ local block_state deflate_fast(s, flush)
* of window index 0 (in particular we have to avoid a match
* of the string with itself at the start of the input file).
*/
-#ifdef FASTEST
- if ((s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) ||
- (s->strategy == Z_RLE && s->strstart - hash_head == 1)) {
- s->match_length = longest_match_fast (s, hash_head);
- }
-#else
- if (s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) {
- s->match_length = longest_match (s, hash_head);
- } else if (s->strategy == Z_RLE && s->strstart - hash_head == 1) {
- s->match_length = longest_match_fast (s, hash_head);
- }
-#endif
- /* longest_match() or longest_match_fast() sets match_start */
+ s->match_length = longest_match (s, hash_head);
+ /* longest_match() sets match_start */
}
if (s->match_length >= MIN_MATCH) {
check_match(s, s->strstart, s->match_start, s->match_length);
@@ -1551,11 +1565,9 @@ local block_state deflate_fast(s, flush)
* evaluation for matches: a match is finally adopted only if there is
* no better match at the next window position.
*/
-local block_state deflate_slow(s, flush)
- deflate_state *s;
- int flush;
+local block_state deflate_slow(deflate_state *s, int flush)
{
- IPos hash_head = NIL; /* head of hash chain */
+ IPos hash_head; /* head of hash chain */
int bflush; /* set if current block must be flushed */
/* Process the input block. */
@@ -1576,6 +1588,7 @@ local block_state deflate_slow(s, flush)
/* Insert the string window[strstart .. strstart+2] in the
* dictionary, and set hash_head to the head of the hash chain:
*/
+ hash_head = NIL;
if (s->lookahead >= MIN_MATCH) {
INSERT_STRING(s, s->strstart, hash_head);
}
@@ -1591,12 +1604,8 @@ local block_state deflate_slow(s, flush)
* of window index 0 (in particular we have to avoid a match
* of the string with itself at the start of the input file).
*/
- if (s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) {
- s->match_length = longest_match (s, hash_head);
- } else if (s->strategy == Z_RLE && s->strstart - hash_head == 1) {
- s->match_length = longest_match_fast (s, hash_head);
- }
- /* longest_match() or longest_match_fast() sets match_start */
+ s->match_length = longest_match (s, hash_head);
+ /* longest_match() sets match_start */
if (s->match_length <= 5 && (s->strategy == Z_FILTERED
#if TOO_FAR <= 32767
@@ -1674,21 +1683,16 @@ local block_state deflate_slow(s, flush)
}
#endif /* FASTEST */
-#if 0
/* ===========================================================================
* For Z_RLE, simply look for runs of bytes, generate matches only of distance
* one. Do not maintain a hash table. (It will be regenerated if this run of
* deflate switches away from Z_RLE.)
*/
-local block_state deflate_rle(s, flush)
- deflate_state *s;
- int flush;
+local block_state deflate_rle(deflate_state *s, int flush)
{
- int bflush; /* set if current block must be flushed */
- uInt run; /* length of run */
- uInt max; /* maximum length of run */
- uInt prev; /* byte at distance one to match */
- Bytef *scan; /* scan for end of run */
+ int bflush; /* set if current block must be flushed */
+ uInt prev; /* byte at distance one to match */
+ Bytef *scan, *strend; /* scan goes up to strend for length of run */
for (;;) {
/* Make sure that we always have enough lookahead, except
@@ -1704,23 +1708,33 @@ local block_state deflate_rle(s, flush)
}
/* See how many times the previous byte repeats */
- run = 0;
- if (s->strstart > 0) { /* if there is a previous byte, that is */
- max = s->lookahead < MAX_MATCH ? s->lookahead : MAX_MATCH;
+ s->match_length = 0;
+ if (s->lookahead >= MIN_MATCH && s->strstart > 0) {
scan = s->window + s->strstart - 1;
- prev = *scan++;
- do {
- if (*scan++ != prev)
- break;
- } while (++run < max);
+ prev = *scan;
+ if (prev == *++scan && prev == *++scan && prev == *++scan) {
+ strend = s->window + s->strstart + MAX_MATCH;
+ do {
+ } while (prev == *++scan && prev == *++scan &&
+ prev == *++scan && prev == *++scan &&
+ prev == *++scan && prev == *++scan &&
+ prev == *++scan && prev == *++scan &&
+ scan < strend);
+ s->match_length = MAX_MATCH - (int)(strend - scan);
+ if (s->match_length > s->lookahead)
+ s->match_length = s->lookahead;
+ }
}
/* Emit match if have run of MIN_MATCH or longer, else emit literal */
- if (run >= MIN_MATCH) {
- check_match(s, s->strstart, s->strstart - 1, run);
- _tr_tally_dist(s, 1, run - MIN_MATCH, bflush);
- s->lookahead -= run;
- s->strstart += run;
+ if (s->match_length >= MIN_MATCH) {
+ check_match(s, s->strstart, s->strstart - 1, s->match_length);
+
+ _tr_tally_dist(s, 1, s->match_length - MIN_MATCH, bflush);
+
+ s->lookahead -= s->match_length;
+ s->strstart += s->match_length;
+ s->match_length = 0;
} else {
/* No match, output a literal byte */
Tracevv((stderr,"%c", s->window[s->strstart]));
@@ -1733,4 +1747,38 @@ local block_state deflate_rle(s, flush)
FLUSH_BLOCK(s, flush == Z_FINISH);
return flush == Z_FINISH ? finish_done : block_done;
}
-#endif
+
+/* ===========================================================================
+ * For Z_HUFFMAN_ONLY, do not look for matches. Do not maintain a hash table.
+ * (It will be regenerated if this run of deflate switches away from Huffman.)
+ */
+local block_state deflate_huff(deflate_state *s, int flush)
+{
+ int bflush; /* set if current block must be flushed */
+
+ for (;;) {
+ /* Make sure that we have a literal to write. */
+ if (s->lookahead == 0) {
+ fill_window(s);
+ if (s->lookahead == 0) {
+ if (flush == Z_NO_FLUSH)
+ return need_more;
+ break; /* flush the current block */
+ }
+ }
+
+ /* Output a literal byte */
+ s->match_length = 0;
+ Tracevv((stderr,"%c", s->window[s->strstart]));
+ _tr_tally_lit (s, s->window[s->strstart], bflush);
+ s->lookahead--;
+ s->strstart++;
+ if (bflush) FLUSH_BLOCK(s, 0);
+ }
+ FLUSH_BLOCK(s, flush == Z_FINISH);
+ return flush == Z_FINISH ? finish_done : block_done;
+}
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/zlib/deflate.h b/src/misc/zlib/deflate.h
index 05a5ab3a..8d17d971 100644
--- a/src/misc/zlib/deflate.h
+++ b/src/misc/zlib/deflate.h
@@ -1,5 +1,5 @@
/* deflate.h -- internal compression state
- * Copyright (C) 1995-2004 Jean-loup Gailly
+ * Copyright (C) 1995-2010 Jean-loup Gailly
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -15,6 +15,8 @@
#include "zutil.h"
+ABC_NAMESPACE_HEADER_START
+
/* define NO_GZIP when compiling if you want to disable gzip header and
trailer creation by deflate(). NO_GZIP would be used to avoid linking in
the crc code when it is not needed. For shared libraries, gzip encoding
@@ -260,6 +262,13 @@ typedef struct internal_state {
* are always zero.
*/
+ ulg high_water;
+ /* High water mark offset in window for initialized bytes -- bytes above
+ * this are set to zero in order to avoid memory check warnings when
+ * longest match routines access bytes past the input. This is then
+ * updated to the new high water mark.
+ */
+
} FAR deflate_state;
/* Output a byte on the stream.
@@ -278,14 +287,18 @@ typedef struct internal_state {
* distances are limited to MAX_DIST instead of WSIZE.
*/
+#define WIN_INIT MAX_MATCH
+/* Number of bytes after end of data in window to initialize in order to avoid
+ memory checker errors from longest match routines */
+
/* in trees.c */
-void _tr_init OF((deflate_state *s));
-int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
-void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len,
- int eof));
-void _tr_align OF((deflate_state *s));
-void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,
- int eof));
+void ZLIB_INTERNAL _tr_init OF((deflate_state *s));
+int ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
+void ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf,
+ ulg stored_len, int last));
+void ZLIB_INTERNAL _tr_align OF((deflate_state *s));
+void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf,
+ ulg stored_len, int last));
#define d_code(dist) \
((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
@@ -298,11 +311,11 @@ void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,
/* Inline versions of _tr_tally for speed: */
#if defined(GEN_TREES_H) || !defined(STDC)
- extern uch _length_code[];
- extern uch _dist_code[];
+ extern uch ZLIB_INTERNAL _length_code[];
+ extern uch ZLIB_INTERNAL _dist_code[];
#else
- extern const uch _length_code[];
- extern const uch _dist_code[];
+ extern const uch ZLIB_INTERNAL _length_code[];
+ extern const uch ZLIB_INTERNAL _dist_code[];
#endif
# define _tr_tally_lit(s, c, flush) \
@@ -328,4 +341,6 @@ void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,
flush = _tr_tally(s, distance, length)
#endif
+ABC_NAMESPACE_HEADER_END
+
#endif /* DEFLATE_H */
diff --git a/src/misc/zlib/gzclose.c b/src/misc/zlib/gzclose.c
new file mode 100644
index 00000000..07d6e0d9
--- /dev/null
+++ b/src/misc/zlib/gzclose.c
@@ -0,0 +1,33 @@
+/* gzclose.c -- zlib gzclose() function
+ * Copyright (C) 2004, 2010 Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "abc_global.h"
+
+#include "gzguts.h"
+
+ABC_NAMESPACE_IMPL_START
+
+/* gzclose() is in a separate file so that it is linked in only if it is used.
+ That way the other gzclose functions can be used instead to avoid linking in
+ unneeded compression or decompression routines. */
+int ZEXPORT gzclose(gzFile file)
+{
+#ifndef NO_GZCOMPRESS
+ gz_statep state;
+
+ if (file == NULL)
+ return Z_STREAM_ERROR;
+ state = (gz_statep)file;
+
+ return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file);
+#else
+ return gzclose_r(file);
+#endif
+}
+
+ABC_NAMESPACE_IMPL_END
diff --git a/src/misc/zlib/gzguts.h b/src/misc/zlib/gzguts.h
new file mode 100644
index 00000000..7334b92e
--- /dev/null
+++ b/src/misc/zlib/gzguts.h
@@ -0,0 +1,147 @@
+/* gzguts.h -- zlib internal header definitions for gz* operations
+ * Copyright (C) 2004, 2005, 2010 Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+#ifdef _LARGEFILE64_SOURCE
+# ifndef _LARGEFILE_SOURCE
+# define _LARGEFILE_SOURCE 1
+# endif
+# ifdef _FILE_OFFSET_BITS
+# undef _FILE_OFFSET_BITS
+# endif
+#endif
+
+#if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ)
+# define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
+#else
+# define ZLIB_INTERNAL
+#endif
+
+#include <stdio.h>
+#include "zlib.h"
+#ifdef STDC
+# include <string.h>
+# include <stdlib.h>
+# include <limits.h>
+#endif
+#include <fcntl.h>
+
+#ifdef NO_DEFLATE /* for compatibility with old definition */
+# define NO_GZCOMPRESS
+#endif
+
+#ifdef _MSC_VER
+# include <io.h>
+# define vsnprintf _vsnprintf
+#endif
+
+#ifndef local
+# define local static
+#endif
+/* compile with -Dlocal if your debugger can't find static symbols */
+
+/* gz* functions always use library allocation functions */
+#ifndef STDC
+ extern voidp malloc OF((uInt size));
+ extern void free OF((voidpf ptr));
+#endif
+
+/* get errno and strerror definition */
+#if defined UNDER_CE
+# include <windows.h>
+# define zstrerror() gz_strwinerror((DWORD)GetLastError())
+#else
+# ifdef STDC
+# include <errno.h>
+# define zstrerror() strerror(errno)
+# else
+# define zstrerror() "stdio error (consult errno)"
+# endif
+#endif
+
+#include <stdio.h>
+#include "abc_global.h"
+
+ABC_NAMESPACE_HEADER_START
+
+#ifdef _WIN32
+#define open _open
+#define close _close
+#define lseek _lseek
+#define read _read
+#define write _write
+#endif
+
+/* provide prototypes for these when building zlib without LFS */
+#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0
+ ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
+ ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));
+ ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));
+ ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));
+#endif
+
+/* default i/o buffer size -- double this for output when reading */
+#define GZBUFSIZE 8192
+
+/* gzip modes, also provide a little integrity check on the passed structure */
+#define GZ_NONE 0
+#define GZ_READ 7247
+#define GZ_WRITE 31153
+#define GZ_APPEND 1 /* mode set to GZ_WRITE after the file is opened */
+
+/* values for gz_state how */
+#define LOOK 0 /* look for a gzip header */
+#define COPY 1 /* copy input directly */
+#define GZIP 2 /* decompress a gzip stream */
+
+/* internal gzip file state data structure */
+typedef struct {
+ /* used for both reading and writing */
+ int mode; /* see gzip modes above */
+ int fd; /* file descriptor */
+ char *path; /* path or fd for error messages */
+ z_off64_t pos; /* current position in uncompressed data */
+ unsigned size; /* buffer size, zero if not allocated yet */
+ unsigned want; /* requested buffer size, default is GZBUFSIZE */
+ unsigned char *in; /* input buffer */
+ unsigned char *out; /* output buffer (double-sized when reading) */
+ unsigned char *next; /* next output data to deliver or write */
+ /* just for reading */
+ unsigned have; /* amount of output data unused at next */
+ int eof; /* true if end of input file reached */
+ z_off64_t start; /* where the gzip data started, for rewinding */
+ z_off64_t raw; /* where the raw data started, for seeking */
+ int how; /* 0: get header, 1: copy, 2: decompress */
+ int direct; /* true if last read direct, false if gzip */
+ /* just for writing */
+ int level; /* compression level */
+ int strategy; /* compression strategy */
+ /* seek request */
+ z_off64_t skip; /* amount to skip (already rewound if backwards) */
+ int seek; /* true if seek request pending */
+ /* error information */
+ int err; /* error code */
+ char *msg; /* error message */
+ /* zlib inflate or deflate stream */
+ z_stream strm; /* stream structure in-place (not a pointer) */
+} gz_state;
+typedef gz_state FAR *gz_statep;
+
+/* shared functions */
+void ZLIB_INTERNAL gz_error OF((gz_statep, int, const char *));
+#if defined UNDER_CE
+char ZLIB_INTERNAL *gz_strwinerror OF((DWORD error));
+#endif
+
+/* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t
+ value -- needed when comparing unsigned to z_off64_t, which is signed
+ (possible z_off64_t types off_t, off64_t, and long are all signed) */
+#ifdef INT_MAX
+# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX)
+#else
+unsigned ZLIB_INTERNAL gz_intmax OF((void));
+# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())
+#endif
+
+ABC_NAMESPACE_HEADER_END
diff --git a/src/misc/zlib/gzio.c b/src/misc/zlib/gzio.c
deleted file mode 100644
index 7e90f492..00000000
--- a/src/misc/zlib/gzio.c
+++ /dev/null
@@ -1,1026 +0,0 @@
-/* gzio.c -- IO on .gz files
- * Copyright (C) 1995-2005 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- *
- * Compile this file with -DNO_GZCOMPRESS to avoid the compression code.
- */
-
-/* @(#) $Id$ */
-
-#include <stdio.h>
-
-#include "zutil.h"
-
-#ifdef NO_DEFLATE /* for compatibility with old definition */
-# define NO_GZCOMPRESS
-#endif
-
-#ifndef NO_DUMMY_DECL
-struct internal_state {int dummy;}; /* for buggy compilers */
-#endif
-
-#ifndef Z_BUFSIZE
-# ifdef MAXSEG_64K
-# define Z_BUFSIZE 4096 /* minimize memory usage for 16-bit DOS */
-# else
-# define Z_BUFSIZE 16384
-# endif
-#endif
-#ifndef Z_PRINTF_BUFSIZE
-# define Z_PRINTF_BUFSIZE 4096
-#endif
-
-#ifdef __MVS__
-# pragma map (fdopen , "\174\174FDOPEN")
- FILE *fdopen(int, const char *);
-#endif
-
-#ifndef STDC
-extern voidp malloc OF((uInt size));
-extern void free OF((voidpf ptr));
-#endif
-
-#define ALLOC(size) malloc(size)
-#define TRYFREE(p) {if (p) free(p);}
-
-static int const gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */
-
-/* gzip flag byte */
-#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */
-#define HEAD_CRC 0x02 /* bit 1 set: header CRC present */
-#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
-#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
-#define COMMENT 0x10 /* bit 4 set: file comment present */
-#define RESERVED 0xE0 /* bits 5..7: reserved */
-
-typedef struct gz_stream {
- z_stream stream;
- int z_err; /* error code for last stream operation */
- int z_eof; /* set if end of input file */
- FILE *file; /* .gz file */
- Byte *inbuf; /* input buffer */
- Byte *outbuf; /* output buffer */
- uLong crc; /* crc32 of uncompressed data */
- char *msg; /* error message */
- char *path; /* path name for debugging only */
- int transparent; /* 1 if input file is not a .gz file */
- char mode; /* 'w' or 'r' */
- z_off_t start; /* start of compressed data in file (header skipped) */
- z_off_t in; /* bytes into deflate or inflate */
- z_off_t out; /* bytes out of deflate or inflate */
- int back; /* one character push-back */
- int last; /* true if push-back is last character */
-} gz_stream;
-
-
-local gzFile gz_open OF((const char *path, const char *mode, int fd));
-local int do_flush OF((gzFile file, int flush));
-local int get_byte OF((gz_stream *s));
-local void check_header OF((gz_stream *s));
-local int destroy OF((gz_stream *s));
-local void putLong OF((FILE *file, uLong x));
-local uLong getLong OF((gz_stream *s));
-
-/* ===========================================================================
- Opens a gzip (.gz) file for reading or writing. The mode parameter
- is as in fopen ("rb" or "wb"). The file is given either by file descriptor
- or path name (if fd == -1).
- gz_open returns NULL if the file could not be opened or if there was
- insufficient memory to allocate the (de)compression state; errno
- can be checked to distinguish the two cases (if errno is zero, the
- zlib error is Z_MEM_ERROR).
-*/
-local gzFile gz_open (path, mode, fd)
- const char *path;
- const char *mode;
- int fd;
-{
- int err;
- int level = Z_DEFAULT_COMPRESSION; /* compression level */
- int strategy = Z_DEFAULT_STRATEGY; /* compression strategy */
- char *p = (char*)mode;
- gz_stream *s;
- char fmode[80]; /* copy of mode, without the compression level */
- char *m = fmode;
-
- if (!path || !mode) return Z_NULL;
-
- s = (gz_stream *)ALLOC(sizeof(gz_stream));
- if (!s) return Z_NULL;
-
- s->stream.zalloc = (alloc_func)0;
- s->stream.zfree = (free_func)0;
- s->stream.opaque = (voidpf)0;
- s->stream.next_in = s->inbuf = Z_NULL;
- s->stream.next_out = s->outbuf = Z_NULL;
- s->stream.avail_in = s->stream.avail_out = 0;
- s->file = NULL;
- s->z_err = Z_OK;
- s->z_eof = 0;
- s->in = 0;
- s->out = 0;
- s->back = EOF;
- s->crc = crc32(0L, Z_NULL, 0);
- s->msg = NULL;
- s->transparent = 0;
-
- s->path = (char*)ALLOC(strlen(path)+1);
- if (s->path == NULL) {
- return destroy(s), (gzFile)Z_NULL;
- }
- strcpy(s->path, path); /* do this early for debugging */
-
- s->mode = '\0';
- do {
- if (*p == 'r') s->mode = 'r';
- if (*p == 'w' || *p == 'a') s->mode = 'w';
- if (*p >= '0' && *p <= '9') {
- level = *p - '0';
- } else if (*p == 'f') {
- strategy = Z_FILTERED;
- } else if (*p == 'h') {
- strategy = Z_HUFFMAN_ONLY;
- } else if (*p == 'R') {
- strategy = Z_RLE;
- } else {
- *m++ = *p; /* copy the mode */
- }
- } while (*p++ && m != fmode + sizeof(fmode));
- if (s->mode == '\0') return destroy(s), (gzFile)Z_NULL;
-
- if (s->mode == 'w') {
-#ifdef NO_GZCOMPRESS
- err = Z_STREAM_ERROR;
-#else
- err = deflateInit2(&(s->stream), level,
- Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, strategy);
- /* windowBits is passed < 0 to suppress zlib header */
-
- s->stream.next_out = s->outbuf = (Byte*)ALLOC(Z_BUFSIZE);
-#endif
- if (err != Z_OK || s->outbuf == Z_NULL) {
- return destroy(s), (gzFile)Z_NULL;
- }
- } else {
- s->stream.next_in = s->inbuf = (Byte*)ALLOC(Z_BUFSIZE);
-
- err = inflateInit2(&(s->stream), -MAX_WBITS);
- /* windowBits is passed < 0 to tell that there is no zlib header.
- * Note that in this case inflate *requires* an extra "dummy" byte
- * after the compressed stream in order to complete decompression and
- * return Z_STREAM_END. Here the gzip CRC32 ensures that 4 bytes are
- * present after the compressed stream.
- */
- if (err != Z_OK || s->inbuf == Z_NULL) {
- return destroy(s), (gzFile)Z_NULL;
- }
- }
- s->stream.avail_out = Z_BUFSIZE;
-
- errno = 0;
- s->file = fd < 0 ? F_OPEN(path, fmode) : (FILE*)fdopen(fd, fmode);
-
- if (s->file == NULL) {
- return destroy(s), (gzFile)Z_NULL;
- }
- if (s->mode == 'w') {
- /* Write a very simple .gz header:
- */
- fprintf(s->file, "%c%c%c%c%c%c%c%c%c%c", gz_magic[0], gz_magic[1],
- Z_DEFLATED, 0 /*flags*/, 0,0,0,0 /*time*/, 0 /*xflags*/, OS_CODE);
- s->start = 10L;
- /* We use 10L instead of ftell(s->file) to because ftell causes an
- * fflush on some systems. This version of the library doesn't use
- * start anyway in write mode, so this initialization is not
- * necessary.
- */
- } else {
- check_header(s); /* skip the .gz header */
- s->start = ftell(s->file) - s->stream.avail_in;
- }
-
- return (gzFile)s;
-}
-
-/* ===========================================================================
- Opens a gzip (.gz) file for reading or writing.
-*/
-gzFile ZEXPORT gzopen (path, mode)
- const char *path;
- const char *mode;
-{
- return gz_open (path, mode, -1);
-}
-
-/* ===========================================================================
- Associate a gzFile with the file descriptor fd. fd is not dup'ed here
- to mimic the behavio(u)r of fdopen.
-*/
-gzFile ZEXPORT gzdopen (fd, mode)
- int fd;
- const char *mode;
-{
- char name[46]; /* allow for up to 128-bit integers */
-
- if (fd < 0) return (gzFile)Z_NULL;
- sprintf(name, "<fd:%d>", fd); /* for debugging */
-
- return gz_open (name, mode, fd);
-}
-
-/* ===========================================================================
- * Update the compression level and strategy
- */
-int ZEXPORT gzsetparams (file, level, strategy)
- gzFile file;
- int level;
- int strategy;
-{
- gz_stream *s = (gz_stream*)file;
-
- if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
-
- /* Make room to allow flushing */
- if (s->stream.avail_out == 0) {
-
- s->stream.next_out = s->outbuf;
- if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) {
- s->z_err = Z_ERRNO;
- }
- s->stream.avail_out = Z_BUFSIZE;
- }
-
- return deflateParams (&(s->stream), level, strategy);
-}
-
-/* ===========================================================================
- Read a byte from a gz_stream; update next_in and avail_in. Return EOF
- for end of file.
- IN assertion: the stream s has been sucessfully opened for reading.
-*/
-local int get_byte(s)
- gz_stream *s;
-{
- if (s->z_eof) return EOF;
- if (s->stream.avail_in == 0) {
- errno = 0;
- s->stream.avail_in = (uInt)fread(s->inbuf, 1, Z_BUFSIZE, s->file);
- if (s->stream.avail_in == 0) {
- s->z_eof = 1;
- if (ferror(s->file)) s->z_err = Z_ERRNO;
- return EOF;
- }
- s->stream.next_in = s->inbuf;
- }
- s->stream.avail_in--;
- return *(s->stream.next_in)++;
-}
-
-/* ===========================================================================
- Check the gzip header of a gz_stream opened for reading. Set the stream
- mode to transparent if the gzip magic header is not present; set s->err
- to Z_DATA_ERROR if the magic header is present but the rest of the header
- is incorrect.
- IN assertion: the stream s has already been created sucessfully;
- s->stream.avail_in is zero for the first time, but may be non-zero
- for concatenated .gz files.
-*/
-local void check_header(s)
- gz_stream *s;
-{
- int method; /* method byte */
- int flags; /* flags byte */
- uInt len;
- int c;
-
- /* Assure two bytes in the buffer so we can peek ahead -- handle case
- where first byte of header is at the end of the buffer after the last
- gzip segment */
- len = s->stream.avail_in;
- if (len < 2) {
- if (len) s->inbuf[0] = s->stream.next_in[0];
- errno = 0;
- len = (uInt)fread(s->inbuf + len, 1, Z_BUFSIZE >> len, s->file);
- if (len == 0 && ferror(s->file)) s->z_err = Z_ERRNO;
- s->stream.avail_in += len;
- s->stream.next_in = s->inbuf;
- if (s->stream.avail_in < 2) {
- s->transparent = s->stream.avail_in;
- return;
- }
- }
-
- /* Peek ahead to check the gzip magic header */
- if (s->stream.next_in[0] != gz_magic[0] ||
- s->stream.next_in[1] != gz_magic[1]) {
- s->transparent = 1;
- return;
- }
- s->stream.avail_in -= 2;
- s->stream.next_in += 2;
-
- /* Check the rest of the gzip header */
- method = get_byte(s);
- flags = get_byte(s);
- if (method != Z_DEFLATED || (flags & RESERVED) != 0) {
- s->z_err = Z_DATA_ERROR;
- return;
- }
-
- /* Discard time, xflags and OS code: */
- for (len = 0; len < 6; len++) (void)get_byte(s);
-
- if ((flags & EXTRA_FIELD) != 0) { /* skip the extra field */
- len = (uInt)get_byte(s);
- len += ((uInt)get_byte(s))<<8;
- /* len is garbage if EOF but the loop below will quit anyway */
- while (len-- != 0 && get_byte(s) != EOF) ;
- }
- if ((flags & ORIG_NAME) != 0) { /* skip the original file name */
- while ((c = get_byte(s)) != 0 && c != EOF) ;
- }
- if ((flags & COMMENT) != 0) { /* skip the .gz file comment */
- while ((c = get_byte(s)) != 0 && c != EOF) ;
- }
- if ((flags & HEAD_CRC) != 0) { /* skip the header crc */
- for (len = 0; len < 2; len++) (void)get_byte(s);
- }
- s->z_err = s->z_eof ? Z_DATA_ERROR : Z_OK;
-}
-
- /* ===========================================================================
- * Cleanup then free the given gz_stream. Return a zlib error code.
- Try freeing in the reverse order of allocations.
- */
-local int destroy (s)
- gz_stream *s;
-{
- int err = Z_OK;
-
- if (!s) return Z_STREAM_ERROR;
-
- TRYFREE(s->msg);
-
- if (s->stream.state != NULL) {
- if (s->mode == 'w') {
-#ifdef NO_GZCOMPRESS
- err = Z_STREAM_ERROR;
-#else
- err = deflateEnd(&(s->stream));
-#endif
- } else if (s->mode == 'r') {
- err = inflateEnd(&(s->stream));
- }
- }
- if (s->file != NULL && fclose(s->file)) {
-#ifdef ESPIPE
- if (errno != ESPIPE) /* fclose is broken for pipes in HP/UX */
-#endif
- err = Z_ERRNO;
- }
- if (s->z_err < 0) err = s->z_err;
-
- TRYFREE(s->inbuf);
- TRYFREE(s->outbuf);
- TRYFREE(s->path);
- TRYFREE(s);
- return err;
-}
-
-/* ===========================================================================
- Reads the given number of uncompressed bytes from the compressed file.
- gzread returns the number of bytes actually read (0 for end of file).
-*/
-int ZEXPORT gzread (file, buf, len)
- gzFile file;
- voidp buf;
- unsigned len;
-{
- gz_stream *s = (gz_stream*)file;
- Bytef *start = (Bytef*)buf; /* starting point for crc computation */
- Byte *next_out; /* == stream.next_out but not forced far (for MSDOS) */
-
- if (s == NULL || s->mode != 'r') return Z_STREAM_ERROR;
-
- if (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO) return -1;
- if (s->z_err == Z_STREAM_END) return 0; /* EOF */
-
- next_out = (Byte*)buf;
- s->stream.next_out = (Bytef*)buf;
- s->stream.avail_out = len;
-
- if (s->stream.avail_out && s->back != EOF) {
- *next_out++ = s->back;
- s->stream.next_out++;
- s->stream.avail_out--;
- s->back = EOF;
- s->out++;
- start++;
- if (s->last) {
- s->z_err = Z_STREAM_END;
- return 1;
- }
- }
-
- while (s->stream.avail_out != 0) {
-
- if (s->transparent) {
- /* Copy first the lookahead bytes: */
- uInt n = s->stream.avail_in;
- if (n > s->stream.avail_out) n = s->stream.avail_out;
- if (n > 0) {
- zmemcpy(s->stream.next_out, s->stream.next_in, n);
- next_out += n;
- s->stream.next_out = next_out;
- s->stream.next_in += n;
- s->stream.avail_out -= n;
- s->stream.avail_in -= n;
- }
- if (s->stream.avail_out > 0) {
- s->stream.avail_out -=
- (uInt)fread(next_out, 1, s->stream.avail_out, s->file);
- }
- len -= s->stream.avail_out;
- s->in += len;
- s->out += len;
- if (len == 0) s->z_eof = 1;
- return (int)len;
- }
- if (s->stream.avail_in == 0 && !s->z_eof) {
-
- errno = 0;
- s->stream.avail_in = (uInt)fread(s->inbuf, 1, Z_BUFSIZE, s->file);
- if (s->stream.avail_in == 0) {
- s->z_eof = 1;
- if (ferror(s->file)) {
- s->z_err = Z_ERRNO;
- break;
- }
- }
- s->stream.next_in = s->inbuf;
- }
- s->in += s->stream.avail_in;
- s->out += s->stream.avail_out;
- s->z_err = inflate(&(s->stream), Z_NO_FLUSH);
- s->in -= s->stream.avail_in;
- s->out -= s->stream.avail_out;
-
- if (s->z_err == Z_STREAM_END) {
- /* Check CRC and original size */
- s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start));
- start = s->stream.next_out;
-
- if (getLong(s) != s->crc) {
- s->z_err = Z_DATA_ERROR;
- } else {
- (void)getLong(s);
- /* The uncompressed length returned by above getlong() may be
- * different from s->out in case of concatenated .gz files.
- * Check for such files:
- */
- check_header(s);
- if (s->z_err == Z_OK) {
- inflateReset(&(s->stream));
- s->crc = crc32(0L, Z_NULL, 0);
- }
- }
- }
- if (s->z_err != Z_OK || s->z_eof) break;
- }
- s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start));
-
- if (len == s->stream.avail_out &&
- (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO))
- return -1;
- return (int)(len - s->stream.avail_out);
-}
-
-
-/* ===========================================================================
- Reads one byte from the compressed file. gzgetc returns this byte
- or -1 in case of end of file or error.
-*/
-int ZEXPORT gzgetc(file)
- gzFile file;
-{
- unsigned char c;
-
- return gzread(file, &c, 1) == 1 ? c : -1;
-}
-
-
-/* ===========================================================================
- Push one byte back onto the stream.
-*/
-int ZEXPORT gzungetc(c, file)
- int c;
- gzFile file;
-{
- gz_stream *s = (gz_stream*)file;
-
- if (s == NULL || s->mode != 'r' || c == EOF || s->back != EOF) return EOF;
- s->back = c;
- s->out--;
- s->last = (s->z_err == Z_STREAM_END);
- if (s->last) s->z_err = Z_OK;
- s->z_eof = 0;
- return c;
-}
-
-
-/* ===========================================================================
- Reads bytes from the compressed file until len-1 characters are
- read, or a newline character is read and transferred to buf, or an
- end-of-file condition is encountered. The string is then terminated
- with a null character.
- gzgets returns buf, or Z_NULL in case of error.
-
- The current implementation is not optimized at all.
-*/
-char * ZEXPORT gzgets(file, buf, len)
- gzFile file;
- char *buf;
- int len;
-{
- char *b = buf;
- if (buf == Z_NULL || len <= 0) return Z_NULL;
-
- while (--len > 0 && gzread(file, buf, 1) == 1 && *buf++ != '\n') ;
- *buf = '\0';
- return b == buf && len > 0 ? Z_NULL : b;
-}
-
-
-#ifndef NO_GZCOMPRESS
-/* ===========================================================================
- Writes the given number of uncompressed bytes into the compressed file.
- gzwrite returns the number of bytes actually written (0 in case of error).
-*/
-int ZEXPORT gzwrite (file, buf, len)
- gzFile file;
- voidpc buf;
- unsigned len;
-{
- gz_stream *s = (gz_stream*)file;
-
- if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
-
- s->stream.next_in = (Bytef*)buf;
- s->stream.avail_in = len;
-
- while (s->stream.avail_in != 0) {
-
- if (s->stream.avail_out == 0) {
-
- s->stream.next_out = s->outbuf;
- if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) {
- s->z_err = Z_ERRNO;
- break;
- }
- s->stream.avail_out = Z_BUFSIZE;
- }
- s->in += s->stream.avail_in;
- s->out += s->stream.avail_out;
- s->z_err = deflate(&(s->stream), Z_NO_FLUSH);
- s->in -= s->stream.avail_in;
- s->out -= s->stream.avail_out;
- if (s->z_err != Z_OK) break;
- }
- s->crc = crc32(s->crc, (const Bytef *)buf, len);
-
- return (int)(len - s->stream.avail_in);
-}
-
-
-/* ===========================================================================
- Converts, formats, and writes the args to the compressed file under
- control of the format string, as in fprintf. gzprintf returns the number of
- uncompressed bytes actually written (0 in case of error).
-*/
-#ifdef STDC
-#include <stdarg.h>
-
-int ZEXPORTVA gzprintf (gzFile file, const char *format, /* args */ ...)
-{
- char buf[Z_PRINTF_BUFSIZE];
- va_list va;
- int len;
-
- buf[sizeof(buf) - 1] = 0;
- va_start(va, format);
-#ifdef NO_vsnprintf
-# ifdef HAS_vsprintf_void
- (void)vsprintf(buf, format, va);
- va_end(va);
- for (len = 0; len < sizeof(buf); len++)
- if (buf[len] == 0) break;
-# else
- len = vsprintf(buf, format, va);
- va_end(va);
-# endif
-#else
-# ifdef HAS_vsnprintf_void
- (void)vsnprintf(buf, sizeof(buf), format, va);
- va_end(va);
- len = strlen(buf);
-# else
- len = vsnprintf(buf, sizeof(buf), format, va);
- va_end(va);
-# endif
-#endif
- if (len <= 0 || len >= (int)sizeof(buf) || buf[sizeof(buf) - 1] != 0)
- return 0;
- return gzwrite(file, buf, (unsigned)len);
-}
-#else /* not ANSI C */
-
-int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
- a11, a12, a13, a14, a15, a16, a17, a18, a19, a20)
- gzFile file;
- const char *format;
- int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
- a11, a12, a13, a14, a15, a16, a17, a18, a19, a20;
-{
- char buf[Z_PRINTF_BUFSIZE];
- int len;
-
- buf[sizeof(buf) - 1] = 0;
-#ifdef NO_snprintf
-# ifdef HAS_sprintf_void
- sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8,
- a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
- for (len = 0; len < sizeof(buf); len++)
- if (buf[len] == 0) break;
-# else
- len = sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8,
- a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
-# endif
-#else
-# ifdef HAS_snprintf_void
- snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8,
- a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
- len = strlen(buf);
-# else
- len = snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8,
- a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
-# endif
-#endif
- if (len <= 0 || len >= sizeof(buf) || buf[sizeof(buf) - 1] != 0)
- return 0;
- return gzwrite(file, buf, len);
-}
-#endif
-
-/* ===========================================================================
- Writes c, converted to an unsigned char, into the compressed file.
- gzputc returns the value that was written, or -1 in case of error.
-*/
-int ZEXPORT gzputc(file, c)
- gzFile file;
- int c;
-{
- unsigned char cc = (unsigned char) c; /* required for big endian systems */
-
- return gzwrite(file, &cc, 1) == 1 ? (int)cc : -1;
-}
-
-
-/* ===========================================================================
- Writes the given null-terminated string to the compressed file, excluding
- the terminating null character.
- gzputs returns the number of characters written, or -1 in case of error.
-*/
-int ZEXPORT gzputs(file, s)
- gzFile file;
- const char *s;
-{
- return gzwrite(file, (char*)s, (unsigned)strlen(s));
-}
-
-
-/* ===========================================================================
- Flushes all pending output into the compressed file. The parameter
- flush is as in the deflate() function.
-*/
-local int do_flush (file, flush)
- gzFile file;
- int flush;
-{
- uInt len;
- int done = 0;
- gz_stream *s = (gz_stream*)file;
-
- if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
-
- s->stream.avail_in = 0; /* should be zero already anyway */
-
- for (;;) {
- len = Z_BUFSIZE - s->stream.avail_out;
-
- if (len != 0) {
- if ((uInt)fwrite(s->outbuf, 1, len, s->file) != len) {
- s->z_err = Z_ERRNO;
- return Z_ERRNO;
- }
- s->stream.next_out = s->outbuf;
- s->stream.avail_out = Z_BUFSIZE;
- }
- if (done) break;
- s->out += s->stream.avail_out;
- s->z_err = deflate(&(s->stream), flush);
- s->out -= s->stream.avail_out;
-
- /* Ignore the second of two consecutive flushes: */
- if (len == 0 && s->z_err == Z_BUF_ERROR) s->z_err = Z_OK;
-
- /* deflate has finished flushing only when it hasn't used up
- * all the available space in the output buffer:
- */
- done = (s->stream.avail_out != 0 || s->z_err == Z_STREAM_END);
-
- if (s->z_err != Z_OK && s->z_err != Z_STREAM_END) break;
- }
- return s->z_err == Z_STREAM_END ? Z_OK : s->z_err;
-}
-
-int ZEXPORT gzflush (file, flush)
- gzFile file;
- int flush;
-{
- gz_stream *s = (gz_stream*)file;
- int err = do_flush (file, flush);
-
- if (err) return err;
- fflush(s->file);
- return s->z_err == Z_STREAM_END ? Z_OK : s->z_err;
-}
-#endif /* NO_GZCOMPRESS */
-
-/* ===========================================================================
- Sets the starting position for the next gzread or gzwrite on the given
- compressed file. The offset represents a number of bytes in the
- gzseek returns the resulting offset location as measured in bytes from
- the beginning of the uncompressed stream, or -1 in case of error.
- SEEK_END is not implemented, returns error.
- In this version of the library, gzseek can be extremely slow.
-*/
-z_off_t ZEXPORT gzseek (file, offset, whence)
- gzFile file;
- z_off_t offset;
- int whence;
-{
- gz_stream *s = (gz_stream*)file;
-
- if (s == NULL || whence == SEEK_END ||
- s->z_err == Z_ERRNO || s->z_err == Z_DATA_ERROR) {
- return -1L;
- }
-
- if (s->mode == 'w') {
-#ifdef NO_GZCOMPRESS
- return -1L;
-#else
- if (whence == SEEK_SET) {
- offset -= s->in;
- }
- if (offset < 0) return -1L;
-
- /* At this point, offset is the number of zero bytes to write. */
- if (s->inbuf == Z_NULL) {
- s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); /* for seeking */
- if (s->inbuf == Z_NULL) return -1L;
- zmemzero(s->inbuf, Z_BUFSIZE);
- }
- while (offset > 0) {
- uInt size = Z_BUFSIZE;
- if (offset < Z_BUFSIZE) size = (uInt)offset;
-
- size = gzwrite(file, s->inbuf, size);
- if (size == 0) return -1L;
-
- offset -= size;
- }
- return s->in;
-#endif
- }
- /* Rest of function is for reading only */
-
- /* compute absolute position */
- if (whence == SEEK_CUR) {
- offset += s->out;
- }
- if (offset < 0) return -1L;
-
- if (s->transparent) {
- /* map to fseek */
- s->back = EOF;
- s->stream.avail_in = 0;
- s->stream.next_in = s->inbuf;
- if (fseek(s->file, offset, SEEK_SET) < 0) return -1L;
-
- s->in = s->out = offset;
- return offset;
- }
-
- /* For a negative seek, rewind and use positive seek */
- if (offset >= s->out) {
- offset -= s->out;
- } else if (gzrewind(file) < 0) {
- return -1L;
- }
- /* offset is now the number of bytes to skip. */
-
- if (offset != 0 && s->outbuf == Z_NULL) {
- s->outbuf = (Byte*)ALLOC(Z_BUFSIZE);
- if (s->outbuf == Z_NULL) return -1L;
- }
- if (offset && s->back != EOF) {
- s->back = EOF;
- s->out++;
- offset--;
- if (s->last) s->z_err = Z_STREAM_END;
- }
- while (offset > 0) {
- int size = Z_BUFSIZE;
- if (offset < Z_BUFSIZE) size = (int)offset;
-
- size = gzread(file, s->outbuf, (uInt)size);
- if (size <= 0) return -1L;
- offset -= size;
- }
- return s->out;
-}
-
-/* ===========================================================================
- Rewinds input file.
-*/
-int ZEXPORT gzrewind (file)
- gzFile file;
-{
- gz_stream *s = (gz_stream*)file;
-
- if (s == NULL || s->mode != 'r') return -1;
-
- s->z_err = Z_OK;
- s->z_eof = 0;
- s->back = EOF;
- s->stream.avail_in = 0;
- s->stream.next_in = s->inbuf;
- s->crc = crc32(0L, Z_NULL, 0);
- if (!s->transparent) (void)inflateReset(&s->stream);
- s->in = 0;
- s->out = 0;
- return fseek(s->file, s->start, SEEK_SET);
-}
-
-/* ===========================================================================
- Returns the starting position for the next gzread or gzwrite on the
- given compressed file. This position represents a number of bytes in the
- uncompressed data stream.
-*/
-z_off_t ZEXPORT gztell (file)
- gzFile file;
-{
- return gzseek(file, 0L, SEEK_CUR);
-}
-
-/* ===========================================================================
- Returns 1 when EOF has previously been detected reading the given
- input stream, otherwise zero.
-*/
-int ZEXPORT gzeof (file)
- gzFile file;
-{
- gz_stream *s = (gz_stream*)file;
-
- /* With concatenated compressed files that can have embedded
- * crc trailers, z_eof is no longer the only/best indicator of EOF
- * on a gz_stream. Handle end-of-stream error explicitly here.
- */
- if (s == NULL || s->mode != 'r') return 0;
- if (s->z_eof) return 1;
- return s->z_err == Z_STREAM_END;
-}
-
-/* ===========================================================================
- Returns 1 if reading and doing so transparently, otherwise zero.
-*/
-int ZEXPORT gzdirect (file)
- gzFile file;
-{
- gz_stream *s = (gz_stream*)file;
-
- if (s == NULL || s->mode != 'r') return 0;
- return s->transparent;
-}
-
-/* ===========================================================================
- Outputs a long in LSB order to the given file
-*/
-local void putLong (file, x)
- FILE *file;
- uLong x;
-{
- int n;
- for (n = 0; n < 4; n++) {
- fputc((int)(x & 0xff), file);
- x >>= 8;
- }
-}
-
-/* ===========================================================================
- Reads a long in LSB order from the given gz_stream. Sets z_err in case
- of error.
-*/
-local uLong getLong (s)
- gz_stream *s;
-{
- uLong x = (uLong)get_byte(s);
- int c;
-
- x += ((uLong)get_byte(s))<<8;
- x += ((uLong)get_byte(s))<<16;
- c = get_byte(s);
- if (c == EOF) s->z_err = Z_DATA_ERROR;
- x += ((uLong)c)<<24;
- return x;
-}
-
-/* ===========================================================================
- Flushes all pending output if necessary, closes the compressed file
- and deallocates all the (de)compression state.
-*/
-int ZEXPORT gzclose (file)
- gzFile file;
-{
- gz_stream *s = (gz_stream*)file;
-
- if (s == NULL) return Z_STREAM_ERROR;
-
- if (s->mode == 'w') {
-#ifdef NO_GZCOMPRESS
- return Z_STREAM_ERROR;
-#else
- if (do_flush (file, Z_FINISH) != Z_OK)
- return destroy((gz_stream*)file);
-
- putLong (s->file, s->crc);
- putLong (s->file, (uLong)(s->in & 0xffffffff));
-#endif
- }
- return destroy((gz_stream*)file);
-}
-
-#ifdef STDC
-# define zstrerror(errnum) strerror(errnum)
-#else
-# define zstrerror(errnum) ""
-#endif
-
-/* ===========================================================================
- Returns the error message for the last error which occurred on the
- given compressed file. errnum is set to zlib error number. If an
- error occurred in the file system and not in the compression library,
- errnum is set to Z_ERRNO and the application may consult errno
- to get the exact error code.
-*/
-const char * ZEXPORT gzerror (file, errnum)
- gzFile file;
- int *errnum;
-{
- char *m;
- gz_stream *s = (gz_stream*)file;
-
- if (s == NULL) {
- *errnum = Z_STREAM_ERROR;
- return (const char*)ERR_MSG(Z_STREAM_ERROR);
- }
- *errnum = s->z_err;
- if (*errnum == Z_OK) return (const char*)"";
-
- m = (char*)(*errnum == Z_ERRNO ? zstrerror(errno) : s->stream.msg);
-
- if (m == NULL || *m == '\0') m = (char*)ERR_MSG(s->z_err);
-
- TRYFREE(s->msg);
- s->msg = (char*)ALLOC(strlen(s->path) + strlen(m) + 3);
- if (s->msg == Z_NULL) return (const char*)ERR_MSG(Z_MEM_ERROR);
- strcpy(s->msg, s->path);
- strcat(s->msg, ": ");
- strcat(s->msg, m);
- return (const char*)s->msg;
-}
-
-/* ===========================================================================
- Clear the error and end-of-file flags, and do the same for the real file.
-*/
-void ZEXPORT gzclearerr (file)
- gzFile file;
-{
- gz_stream *s = (gz_stream*)file;
-
- if (s == NULL) return;
- if (s->z_err != Z_STREAM_END) s->z_err = Z_OK;
- s->z_eof = 0;
- clearerr(s->file);
-}
diff --git a/src/misc/zlib/gzlib.c b/src/misc/zlib/gzlib.c
new file mode 100644
index 00000000..1d88baa4
--- /dev/null
+++ b/src/misc/zlib/gzlib.c
@@ -0,0 +1,517 @@
+/* gzlib.c -- zlib functions common to reading and writing gzip files
+ * Copyright (C) 2004, 2010 Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "abc_global.h"
+
+#include "gzguts.h"
+
+ABC_NAMESPACE_IMPL_START
+
+#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
+# define LSEEK lseek64
+#else
+# define LSEEK lseek
+#endif
+
+/* Local functions */
+local void gz_reset OF((gz_statep));
+local gzFile gz_open OF((const char *, int, const char *));
+
+#if defined UNDER_CE
+
+/* Map the Windows error number in ERROR to a locale-dependent error message
+ string and return a pointer to it. Typically, the values for ERROR come
+ from GetLastError.
+
+ The string pointed to shall not be modified by the application, but may be
+ overwritten by a subsequent call to gz_strwinerror
+
+ The gz_strwinerror function does not change the current setting of
+ GetLastError. */
+char ZLIB_INTERNAL *gz_strwinerror (DWORD error)
+{
+ static char buf[1024];
+
+ wchar_t *msgbuf;
+ DWORD lasterr = GetLastError();
+ DWORD chars = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM
+ | FORMAT_MESSAGE_ALLOCATE_BUFFER,
+ NULL,
+ error,
+ 0, /* Default language */
+ (LPVOID)&msgbuf,
+ 0,
+ NULL);
+ if (chars != 0) {
+ /* If there is an \r\n appended, zap it. */
+ if (chars >= 2
+ && msgbuf[chars - 2] == '\r' && msgbuf[chars - 1] == '\n') {
+ chars -= 2;
+ msgbuf[chars] = 0;
+ }
+
+ if (chars > sizeof (buf) - 1) {
+ chars = sizeof (buf) - 1;
+ msgbuf[chars] = 0;
+ }
+
+ wcstombs(buf, msgbuf, chars + 1);
+ LocalFree(msgbuf);
+ }
+ else {
+ sprintf(buf, "unknown win32 error (%ld)", error);
+ }
+
+ SetLastError(lasterr);
+ return buf;
+}
+
+#endif /* UNDER_CE */
+
+/* Reset gzip file state */
+local void gz_reset(gz_statep state)
+{
+ if (state->mode == GZ_READ) { /* for reading ... */
+ state->have = 0; /* no output data available */
+ state->eof = 0; /* not at end of file */
+ state->how = LOOK; /* look for gzip header */
+ state->direct = 1; /* default for empty file */
+ }
+ state->seek = 0; /* no seek request pending */
+ gz_error(state, Z_OK, NULL); /* clear error */
+ state->pos = 0; /* no uncompressed data yet */
+ state->strm.avail_in = 0; /* no input data yet */
+}
+
+/* Open a gzip file either by name or file descriptor. */
+local gzFile gz_open(const char *path, int fd, const char *mode)
+{
+ gz_statep state;
+
+ /* allocate gzFile structure to return */
+ state = (gz_statep)malloc(sizeof(gz_state));
+ if (state == NULL)
+ return NULL;
+ state->size = 0; /* no buffers allocated yet */
+ state->want = GZBUFSIZE; /* requested buffer size */
+ state->msg = NULL; /* no error message yet */
+
+ /* interpret mode */
+ state->mode = GZ_NONE;
+ state->level = Z_DEFAULT_COMPRESSION;
+ state->strategy = Z_DEFAULT_STRATEGY;
+ while (*mode) {
+ if (*mode >= '0' && *mode <= '9')
+ state->level = *mode - '0';
+ else
+ switch (*mode) {
+ case 'r':
+ state->mode = GZ_READ;
+ break;
+#ifndef NO_GZCOMPRESS
+ case 'w':
+ state->mode = GZ_WRITE;
+ break;
+ case 'a':
+ state->mode = GZ_APPEND;
+ break;
+#endif
+ case '+': /* can't read and write at the same time */
+ free(state);
+ return NULL;
+ case 'b': /* ignore -- will request binary anyway */
+ break;
+ case 'f':
+ state->strategy = Z_FILTERED;
+ break;
+ case 'h':
+ state->strategy = Z_HUFFMAN_ONLY;
+ break;
+ case 'R':
+ state->strategy = Z_RLE;
+ break;
+ case 'F':
+ state->strategy = Z_FIXED;
+ default: /* could consider as an error, but just ignore */
+ ;
+ }
+ mode++;
+ }
+
+ /* must provide an "r", "w", or "a" */
+ if (state->mode == GZ_NONE) {
+ free(state);
+ return NULL;
+ }
+
+ /* save the path name for error messages */
+ state->path = (char *)malloc(strlen(path) + 1);
+ if (state->path == NULL) {
+ free(state);
+ return NULL;
+ }
+ strcpy(state->path, path);
+
+ /* open the file with the appropriate mode (or just use fd) */
+ state->fd = fd != -1 ? fd :
+ open(path,
+#ifdef O_LARGEFILE
+ O_LARGEFILE |
+#endif
+#ifdef O_BINARY
+ O_BINARY |
+#endif
+ (state->mode == GZ_READ ?
+ O_RDONLY :
+ (O_WRONLY | O_CREAT | (
+ state->mode == GZ_WRITE ?
+ O_TRUNC :
+ O_APPEND))),
+ 0666);
+ if (state->fd == -1) {
+ free(state->path);
+ free(state);
+ return NULL;
+ }
+ if (state->mode == GZ_APPEND)
+ state->mode = GZ_WRITE; /* simplify later checks */
+
+ /* save the current position for rewinding (only if reading) */
+ if (state->mode == GZ_READ) {
+ state->start = LSEEK(state->fd, 0, SEEK_CUR);
+ if (state->start == -1) state->start = 0;
+ }
+
+ /* initialize stream */
+ gz_reset(state);
+
+ /* return stream */
+ return (gzFile)state;
+}
+
+/* -- see zlib.h -- */
+gzFile ZEXPORT gzopen(const char *path, const char *mode)
+{
+ return gz_open(path, -1, mode);
+}
+
+/* -- see zlib.h -- */
+gzFile ZEXPORT gzopen64(const char *path, const char *mode)
+{
+ return gz_open(path, -1, mode);
+}
+
+/* -- see zlib.h -- */
+gzFile ZEXPORT gzdopen(int fd, const char *mode)
+{
+ char *path; /* identifier for error messages */
+ gzFile gz;
+
+ if (fd == -1 || (path = (char *)malloc(7 + 3 * sizeof(int))) == NULL)
+ return NULL;
+ sprintf(path, "<fd:%d>", fd); /* for debugging */
+ gz = gz_open(path, fd, mode);
+ free(path);
+ return gz;
+}
+
+/* -- see zlib.h -- */
+int ZEXPORT gzbuffer(gzFile file, unsigned size)
+{
+ gz_statep state;
+
+ /* get internal structure and check integrity */
+ if (file == NULL)
+ return -1;
+ state = (gz_statep)file;
+ if (state->mode != GZ_READ && state->mode != GZ_WRITE)
+ return -1;
+
+ /* make sure we haven't already allocated memory */
+ if (state->size != 0)
+ return -1;
+
+ /* check and set requested size */
+ if (size == 0)
+ return -1;
+ state->want = size;
+ return 0;
+}
+
+/* -- see zlib.h -- */
+int ZEXPORT gzrewind(gzFile file)
+{
+ gz_statep state;
+
+ /* get internal structure */
+ if (file == NULL)
+ return -1;
+ state = (gz_statep)file;
+
+ /* check that we're reading and that there's no error */
+ if (state->mode != GZ_READ || state->err != Z_OK)
+ return -1;
+
+ /* back up and start over */
+ if (LSEEK(state->fd, state->start, SEEK_SET) == -1)
+ return -1;
+ gz_reset(state);
+ return 0;
+}
+
+/* -- see zlib.h -- */
+z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence)
+{
+ unsigned n;
+ z_off64_t ret;
+ gz_statep state;
+
+ /* get internal structure and check integrity */
+ if (file == NULL)
+ return -1;
+ state = (gz_statep)file;
+ if (state->mode != GZ_READ && state->mode != GZ_WRITE)
+ return -1;
+
+ /* check that there's no error */
+ if (state->err != Z_OK)
+ return -1;
+
+ /* can only seek from start or relative to current position */
+ if (whence != SEEK_SET && whence != SEEK_CUR)
+ return -1;
+
+ /* normalize offset to a SEEK_CUR specification */
+ if (whence == SEEK_SET)
+ offset -= state->pos;
+ else if (state->seek)
+ offset += state->skip;
+ state->seek = 0;
+
+ /* if within raw area while reading, just go there */
+ if (state->mode == GZ_READ && state->how == COPY &&
+ state->pos + offset >= state->raw) {
+ ret = LSEEK(state->fd, offset - state->have, SEEK_CUR);
+ if (ret == -1)
+ return -1;
+ state->have = 0;
+ state->eof = 0;
+ state->seek = 0;
+ gz_error(state, Z_OK, NULL);
+ state->strm.avail_in = 0;
+ state->pos += offset;
+ return state->pos;
+ }
+
+ /* calculate skip amount, rewinding if needed for back seek when reading */
+ if (offset < 0) {
+ if (state->mode != GZ_READ) /* writing -- can't go backwards */
+ return -1;
+ offset += state->pos;
+ if (offset < 0) /* before start of file! */
+ return -1;
+ if (gzrewind(file) == -1) /* rewind, then skip to offset */
+ return -1;
+ }
+
+ /* if reading, skip what's in output buffer (one less gzgetc() check) */
+ if (state->mode == GZ_READ) {
+ n = GT_OFF(state->have) || (z_off64_t)state->have > offset ?
+ (unsigned)offset : state->have;
+ state->have -= n;
+ state->next += n;
+ state->pos += n;
+ offset -= n;
+ }
+
+ /* request skip (if not zero) */
+ if (offset) {
+ state->seek = 1;
+ state->skip = offset;
+ }
+ return state->pos + offset;
+}
+
+/* -- see zlib.h -- */
+z_off_t ZEXPORT gzseek(gzFile file, z_off_t offset, int whence)
+{
+ z_off64_t ret;
+
+ ret = gzseek64(file, (z_off64_t)offset, whence);
+ return ret == (z_off_t)ret ? (z_off_t)ret : -1;
+}
+
+/* -- see zlib.h -- */
+z_off64_t ZEXPORT gztell64(gzFile file)
+{
+ gz_statep state;
+
+ /* get internal structure and check integrity */
+ if (file == NULL)
+ return -1;
+ state = (gz_statep)file;
+ if (state->mode != GZ_READ && state->mode != GZ_WRITE)
+ return -1;
+
+ /* return position */
+ return state->pos + (state->seek ? state->skip : 0);
+}
+
+/* -- see zlib.h -- */
+z_off_t ZEXPORT gztell(gzFile file)
+{
+ z_off64_t ret;
+
+ ret = gztell64(file);
+ return ret == (z_off_t)ret ? (z_off_t)ret : -1;
+}
+
+/* -- see zlib.h -- */
+z_off64_t ZEXPORT gzoffset64(gzFile file)
+{
+ z_off64_t offset;
+ gz_statep state;
+
+ /* get internal structure and check integrity */
+ if (file == NULL)
+ return -1;
+ state = (gz_statep)file;
+ if (state->mode != GZ_READ && state->mode != GZ_WRITE)
+ return -1;
+
+ /* compute and return effective offset in file */
+ offset = LSEEK(state->fd, 0, SEEK_CUR);
+ if (offset == -1)
+ return -1;
+ if (state->mode == GZ_READ) /* reading */
+ offset -= state->strm.avail_in; /* don't count buffered input */
+ return offset;
+}
+
+/* -- see zlib.h -- */
+z_off_t ZEXPORT gzoffset(gzFile file)
+{
+ z_off64_t ret;
+
+ ret = gzoffset64(file);
+ return ret == (z_off_t)ret ? (z_off_t)ret : -1;
+}
+
+/* -- see zlib.h -- */
+int ZEXPORT gzeof(gzFile file)
+{
+ gz_statep state;
+
+ /* get internal structure and check integrity */
+ if (file == NULL)
+ return 0;
+ state = (gz_statep)file;
+ if (state->mode != GZ_READ && state->mode != GZ_WRITE)
+ return 0;
+
+ /* return end-of-file state */
+ return state->mode == GZ_READ ?
+ (state->eof && state->strm.avail_in == 0 && state->have == 0) : 0;
+}
+
+/* -- see zlib.h -- */
+const char * ZEXPORT gzerror(gzFile file, int *errnum)
+{
+ gz_statep state;
+
+ /* get internal structure and check integrity */
+ if (file == NULL)
+ return NULL;
+ state = (gz_statep)file;
+ if (state->mode != GZ_READ && state->mode != GZ_WRITE)
+ return NULL;
+
+ /* return error information */
+ if (errnum != NULL)
+ *errnum = state->err;
+ return state->msg == NULL ? "" : state->msg;
+}
+
+/* -- see zlib.h -- */
+void ZEXPORT gzclearerr(gzFile file)
+{
+ gz_statep state;
+
+ /* get internal structure and check integrity */
+ if (file == NULL)
+ return;
+ state = (gz_statep)file;
+ if (state->mode != GZ_READ && state->mode != GZ_WRITE)
+ return;
+
+ /* clear error and end-of-file */
+ if (state->mode == GZ_READ)
+ state->eof = 0;
+ gz_error(state, Z_OK, NULL);
+}
+
+/* Create an error message in allocated memory and set state->err and
+ state->msg accordingly. Free any previous error message already there. Do
+ not try to free or allocate space if the error is Z_MEM_ERROR (out of
+ memory). Simply save the error message as a static string. If there is an
+ allocation failure constructing the error message, then convert the error to
+ out of memory. */
+void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg)
+{
+ /* free previously allocated message and clear */
+ if (state->msg != NULL) {
+ if (state->err != Z_MEM_ERROR)
+ free(state->msg);
+ state->msg = NULL;
+ }
+
+ /* set error code, and if no message, then done */
+ state->err = err;
+ if (msg == NULL)
+ return;
+
+ /* for an out of memory error, save as static string */
+ if (err == Z_MEM_ERROR) {
+ state->msg = (char *)msg;
+ return;
+ }
+
+ /* construct error message with path */
+ if ((state->msg = (char *)malloc(strlen(state->path) + strlen(msg) + 3)) == NULL) {
+ state->err = Z_MEM_ERROR;
+ state->msg = (char *)"out of memory";
+ return;
+ }
+ strcpy(state->msg, state->path);
+ strcat(state->msg, ": ");
+ strcat(state->msg, msg);
+ return;
+}
+
+#ifndef INT_MAX
+/* portably return maximum value for an int (when limits.h presumed not
+ available) -- we need to do this to cover cases where 2's complement not
+ used, since C standard permits 1's complement and sign-bit representations,
+ otherwise we could just use ((unsigned)-1) >> 1 */
+unsigned ZLIB_INTERNAL gz_intmax()
+{
+ unsigned p, q;
+
+ p = 1;
+ do {
+ q = p;
+ p <<= 1;
+ p++;
+ } while (p > q);
+ return q >> 1;
+}
+#endif
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/zlib/gzread.c b/src/misc/zlib/gzread.c
new file mode 100644
index 00000000..7abe5d9c
--- /dev/null
+++ b/src/misc/zlib/gzread.c
@@ -0,0 +1,641 @@
+/* gzread.c -- zlib functions for reading gzip files
+ * Copyright (C) 2004, 2005, 2010 Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "abc_global.h"
+
+#include "gzguts.h"
+
+ABC_NAMESPACE_IMPL_START
+
+/* Local functions */
+local int gz_load OF((gz_statep, unsigned char *, unsigned, unsigned *));
+local int gz_avail OF((gz_statep));
+local int gz_next4 OF((gz_statep, unsigned long *));
+local int gz_head OF((gz_statep));
+local int gz_decomp OF((gz_statep));
+local int gz_make OF((gz_statep));
+local int gz_skip OF((gz_statep, z_off64_t));
+
+/* Use read() to load a buffer -- return -1 on error, otherwise 0. Read from
+ state->fd, and update state->eof, state->err, and state->msg as appropriate.
+ This function needs to loop on read(), since read() is not guaranteed to
+ read the number of bytes requested, depending on the type of descriptor. */
+local int gz_load(gz_statep state, unsigned char *buf, unsigned len, unsigned *have)
+{
+ int ret;
+
+ *have = 0;
+ do {
+ ret = read(state->fd, buf + *have, len - *have);
+ if (ret <= 0)
+ break;
+ *have += ret;
+ } while (*have < len);
+ if (ret < 0) {
+ gz_error(state, Z_ERRNO, zstrerror());
+ return -1;
+ }
+ if (ret == 0)
+ state->eof = 1;
+ return 0;
+}
+
+/* Load up input buffer and set eof flag if last data loaded -- return -1 on
+ error, 0 otherwise. Note that the eof flag is set when the end of the input
+ file is reached, even though there may be unused data in the buffer. Once
+ that data has been used, no more attempts will be made to read the file.
+ gz_avail() assumes that strm->avail_in == 0. */
+local int gz_avail(gz_statep state)
+{
+ z_streamp strm = &(state->strm);
+
+ if (state->err != Z_OK)
+ return -1;
+ if (state->eof == 0) {
+ if (gz_load(state, state->in, state->size,
+ (unsigned *)&(strm->avail_in)) == -1)
+ return -1;
+ strm->next_in = state->in;
+ }
+ return 0;
+}
+
+/* Get next byte from input, or -1 if end or error. */
+#define NEXT() ((strm->avail_in == 0 && gz_avail(state) == -1) ? -1 : \
+ (strm->avail_in == 0 ? -1 : \
+ (strm->avail_in--, *(strm->next_in)++)))
+
+/* Get a four-byte little-endian integer and return 0 on success and the value
+ in *ret. Otherwise -1 is returned and *ret is not modified. */
+local int gz_next4(gz_statep state, unsigned long *ret)
+{
+ int ch;
+ unsigned long val;
+ z_streamp strm = &(state->strm);
+
+ val = NEXT();
+ val += (unsigned)NEXT() << 8;
+ val += (unsigned long)NEXT() << 16;
+ ch = NEXT();
+ if (ch == -1)
+ return -1;
+ val += (unsigned long)ch << 24;
+ *ret = val;
+ return 0;
+}
+
+/* Look for gzip header, set up for inflate or copy. state->have must be zero.
+ If this is the first time in, allocate required memory. state->how will be
+ left unchanged if there is no more input data available, will be set to COPY
+ if there is no gzip header and direct copying will be performed, or it will
+ be set to GZIP for decompression, and the gzip header will be skipped so
+ that the next available input data is the raw deflate stream. If direct
+ copying, then leftover input data from the input buffer will be copied to
+ the output buffer. In that case, all further file reads will be directly to
+ either the output buffer or a user buffer. If decompressing, the inflate
+ state and the check value will be initialized. gz_head() will return 0 on
+ success or -1 on failure. Failures may include read errors or gzip header
+ errors. */
+local int gz_head(gz_statep state)
+{
+ z_streamp strm = &(state->strm);
+ int flags;
+ unsigned len;
+
+ /* allocate read buffers and inflate memory */
+ if (state->size == 0) {
+ /* allocate buffers */
+ state->in = (unsigned char *)malloc(state->want);
+ state->out = (unsigned char *)malloc(state->want << 1);
+ if (state->in == NULL || state->out == NULL) {
+ if (state->out != NULL)
+ free(state->out);
+ if (state->in != NULL)
+ free(state->in);
+ gz_error(state, Z_MEM_ERROR, "out of memory");
+ return -1;
+ }
+ state->size = state->want;
+
+ /* allocate inflate memory */
+ state->strm.zalloc = Z_NULL;
+ state->strm.zfree = Z_NULL;
+ state->strm.opaque = Z_NULL;
+ state->strm.avail_in = 0;
+ state->strm.next_in = Z_NULL;
+ if (inflateInit2(&(state->strm), -15) != Z_OK) { /* raw inflate */
+ free(state->out);
+ free(state->in);
+ state->size = 0;
+ gz_error(state, Z_MEM_ERROR, "out of memory");
+ return -1;
+ }
+ }
+
+ /* get some data in the input buffer */
+ if (strm->avail_in == 0) {
+ if (gz_avail(state) == -1)
+ return -1;
+ if (strm->avail_in == 0)
+ return 0;
+ }
+
+ /* look for the gzip magic header bytes 31 and 139 */
+ if (strm->next_in[0] == 31) {
+ strm->avail_in--;
+ strm->next_in++;
+ if (strm->avail_in == 0 && gz_avail(state) == -1)
+ return -1;
+ if (strm->avail_in && strm->next_in[0] == 139) {
+ /* we have a gzip header, woo hoo! */
+ strm->avail_in--;
+ strm->next_in++;
+
+ /* skip rest of header */
+ if (NEXT() != 8) { /* compression method */
+ gz_error(state, Z_DATA_ERROR, "unknown compression method");
+ return -1;
+ }
+ flags = NEXT();
+ if (flags & 0xe0) { /* reserved flag bits */
+ gz_error(state, Z_DATA_ERROR, "unknown header flags set");
+ return -1;
+ }
+ NEXT(); /* modification time */
+ NEXT();
+ NEXT();
+ NEXT();
+ NEXT(); /* extra flags */
+ NEXT(); /* operating system */
+ if (flags & 4) { /* extra field */
+ len = (unsigned)NEXT();
+ len += (unsigned)NEXT() << 8;
+ while (len--)
+ if (NEXT() < 0)
+ break;
+ }
+ if (flags & 8) /* file name */
+ while (NEXT() > 0)
+ ;
+ if (flags & 16) /* comment */
+ while (NEXT() > 0)
+ ;
+ if (flags & 2) { /* header crc */
+ NEXT();
+ NEXT();
+ }
+ /* an unexpected end of file is not checked for here -- it will be
+ noticed on the first request for uncompressed data */
+
+ /* set up for decompression */
+ inflateReset(strm);
+ strm->adler = crc32(0L, Z_NULL, 0);
+ state->how = GZIP;
+ state->direct = 0;
+ return 0;
+ }
+ else {
+ /* not a gzip file -- save first byte (31) and fall to raw i/o */
+ state->out[0] = 31;
+ state->have = 1;
+ }
+ }
+
+ /* doing raw i/o, save start of raw data for seeking, copy any leftover
+ input to output -- this assumes that the output buffer is larger than
+ the input buffer, which also assures space for gzungetc() */
+ state->raw = state->pos;
+ state->next = state->out;
+ if (strm->avail_in) {
+ memcpy(state->next + state->have, strm->next_in, strm->avail_in);
+ state->have += strm->avail_in;
+ strm->avail_in = 0;
+ }
+ state->how = COPY;
+ state->direct = 1;
+ return 0;
+}
+
+/* Decompress from input to the provided next_out and avail_out in the state.
+ If the end of the compressed data is reached, then verify the gzip trailer
+ check value and length (modulo 2^32). state->have and state->next are set
+ to point to the just decompressed data, and the crc is updated. If the
+ trailer is verified, state->how is reset to LOOK to look for the next gzip
+ stream or raw data, once state->have is depleted. Returns 0 on success, -1
+ on failure. Failures may include invalid compressed data or a failed gzip
+ trailer verification. */
+local int gz_decomp(gz_statep state)
+{
+ int ret;
+ unsigned had;
+ unsigned long crc, len;
+ z_streamp strm = &(state->strm);
+
+ /* fill output buffer up to end of deflate stream */
+ had = strm->avail_out;
+ do {
+ /* get more input for inflate() */
+ if (strm->avail_in == 0 && gz_avail(state) == -1)
+ return -1;
+ if (strm->avail_in == 0) {
+ gz_error(state, Z_DATA_ERROR, "unexpected end of file");
+ return -1;
+ }
+
+ /* decompress and handle errors */
+ ret = inflate(strm, Z_NO_FLUSH);
+ if (ret == Z_STREAM_ERROR || ret == Z_NEED_DICT) {
+ gz_error(state, Z_STREAM_ERROR,
+ "internal error: inflate stream corrupt");
+ return -1;
+ }
+ if (ret == Z_MEM_ERROR) {
+ gz_error(state, Z_MEM_ERROR, "out of memory");
+ return -1;
+ }
+ if (ret == Z_DATA_ERROR) { /* deflate stream invalid */
+ gz_error(state, Z_DATA_ERROR,
+ strm->msg == NULL ? "compressed data error" : strm->msg);
+ return -1;
+ }
+ } while (strm->avail_out && ret != Z_STREAM_END);
+
+ /* update available output and crc check value */
+ state->have = had - strm->avail_out;
+ state->next = strm->next_out - state->have;
+ strm->adler = crc32(strm->adler, state->next, state->have);
+
+ /* check gzip trailer if at end of deflate stream */
+ if (ret == Z_STREAM_END) {
+ if (gz_next4(state, &crc) == -1 || gz_next4(state, &len) == -1) {
+ gz_error(state, Z_DATA_ERROR, "unexpected end of file");
+ return -1;
+ }
+ if (crc != strm->adler) {
+ gz_error(state, Z_DATA_ERROR, "incorrect data check");
+ return -1;
+ }
+ if (len != (strm->total_out & 0xffffffffL)) {
+ gz_error(state, Z_DATA_ERROR, "incorrect length check");
+ return -1;
+ }
+ state->how = LOOK; /* ready for next stream, once have is 0 (leave
+ state->direct unchanged to remember how) */
+ }
+
+ /* good decompression */
+ return 0;
+}
+
+/* Make data and put in the output buffer. Assumes that state->have == 0.
+ Data is either copied from the input file or decompressed from the input
+ file depending on state->how. If state->how is LOOK, then a gzip header is
+ looked for (and skipped if found) to determine wither to copy or decompress.
+ Returns -1 on error, otherwise 0. gz_make() will leave state->have as COPY
+ or GZIP unless the end of the input file has been reached and all data has
+ been processed. */
+local int gz_make(gz_statep state)
+{
+ z_streamp strm = &(state->strm);
+
+ if (state->how == LOOK) { /* look for gzip header */
+ if (gz_head(state) == -1)
+ return -1;
+ if (state->have) /* got some data from gz_head() */
+ return 0;
+ }
+ if (state->how == COPY) { /* straight copy */
+ if (gz_load(state, state->out, state->size << 1, &(state->have)) == -1)
+ return -1;
+ state->next = state->out;
+ }
+ else if (state->how == GZIP) { /* decompress */
+ strm->avail_out = state->size << 1;
+ strm->next_out = state->out;
+ if (gz_decomp(state) == -1)
+ return -1;
+ }
+ return 0;
+}
+
+/* Skip len uncompressed bytes of output. Return -1 on error, 0 on success. */
+local int gz_skip(gz_statep state, z_off64_t len)
+{
+ unsigned n;
+
+ /* skip over len bytes or reach end-of-file, whichever comes first */
+ while (len)
+ /* skip over whatever is in output buffer */
+ if (state->have) {
+ n = GT_OFF(state->have) || (z_off64_t)state->have > len ?
+ (unsigned)len : state->have;
+ state->have -= n;
+ state->next += n;
+ state->pos += n;
+ len -= n;
+ }
+
+ /* output buffer empty -- return if we're at the end of the input */
+ else if (state->eof && state->strm.avail_in == 0)
+ break;
+
+ /* need more data to skip -- load up output buffer */
+ else {
+ /* get more output, looking for header if required */
+ if (gz_make(state) == -1)
+ return -1;
+ }
+ return 0;
+}
+
+/* -- see zlib.h -- */
+int ZEXPORT gzread(gzFile file, voidp buf, unsigned len)
+{
+ unsigned got, n;
+ gz_statep state;
+ z_streamp strm;
+
+ /* get internal structure */
+ if (file == NULL)
+ return -1;
+ state = (gz_statep)file;
+ strm = &(state->strm);
+
+ /* check that we're reading and that there's no error */
+ if (state->mode != GZ_READ || state->err != Z_OK)
+ return -1;
+
+ /* since an int is returned, make sure len fits in one, otherwise return
+ with an error (this avoids the flaw in the interface) */
+ if ((int)len < 0) {
+ gz_error(state, Z_BUF_ERROR, "requested length does not fit in int");
+ return -1;
+ }
+
+ /* if len is zero, avoid unnecessary operations */
+ if (len == 0)
+ return 0;
+
+ /* process a skip request */
+ if (state->seek) {
+ state->seek = 0;
+ if (gz_skip(state, state->skip) == -1)
+ return -1;
+ }
+
+ /* get len bytes to buf, or less than len if at the end */
+ got = 0;
+ do {
+ /* first just try copying data from the output buffer */
+ if (state->have) {
+ n = state->have > len ? len : state->have;
+ memcpy(buf, state->next, n);
+ state->next += n;
+ state->have -= n;
+ }
+
+ /* output buffer empty -- return if we're at the end of the input */
+ else if (state->eof && strm->avail_in == 0)
+ break;
+
+ /* need output data -- for small len or new stream load up our output
+ buffer */
+ else if (state->how == LOOK || len < (state->size << 1)) {
+ /* get more output, looking for header if required */
+ if (gz_make(state) == -1)
+ return -1;
+ continue; /* no progress yet -- go back to memcpy() above */
+ /* the copy above assures that we will leave with space in the
+ output buffer, allowing at least one gzungetc() to succeed */
+ }
+
+ /* large len -- read directly into user buffer */
+ else if (state->how == COPY) { /* read directly */
+ if (gz_load(state, (unsigned char *)buf, len, &n) == -1)
+ return -1;
+ }
+
+ /* large len -- decompress directly into user buffer */
+ else { /* state->how == GZIP */
+ strm->avail_out = len;
+ strm->next_out = (unsigned char *)buf;
+ if (gz_decomp(state) == -1)
+ return -1;
+ n = state->have;
+ state->have = 0;
+ }
+
+ /* update progress */
+ len -= n;
+ buf = (char *)buf + n;
+ got += n;
+ state->pos += n;
+ } while (len);
+
+ /* return number of bytes read into user buffer (will fit in int) */
+ return (int)got;
+}
+
+/* -- see zlib.h -- */
+int ZEXPORT gzgetc(gzFile file)
+{
+ int ret;
+ unsigned char buf[1];
+ gz_statep state;
+
+ /* get internal structure */
+ if (file == NULL)
+ return -1;
+ state = (gz_statep)file;
+
+ /* check that we're reading and that there's no error */
+ if (state->mode != GZ_READ || state->err != Z_OK)
+ return -1;
+
+ /* try output buffer (no need to check for skip request) */
+ if (state->have) {
+ state->have--;
+ state->pos++;
+ return *(state->next)++;
+ }
+
+ /* nothing there -- try gzread() */
+ ret = gzread(file, buf, 1);
+ return ret < 1 ? -1 : buf[0];
+}
+
+/* -- see zlib.h -- */
+int ZEXPORT gzungetc(int c, gzFile file)
+{
+ gz_statep state;
+
+ /* get internal structure */
+ if (file == NULL)
+ return -1;
+ state = (gz_statep)file;
+
+ /* check that we're reading and that there's no error */
+ if (state->mode != GZ_READ || state->err != Z_OK)
+ return -1;
+
+ /* process a skip request */
+ if (state->seek) {
+ state->seek = 0;
+ if (gz_skip(state, state->skip) == -1)
+ return -1;
+ }
+
+ /* can't push EOF */
+ if (c < 0)
+ return -1;
+
+ /* if output buffer empty, put byte at end (allows more pushing) */
+ if (state->have == 0) {
+ state->have = 1;
+ state->next = state->out + (state->size << 1) - 1;
+ state->next[0] = c;
+ state->pos--;
+ return c;
+ }
+
+ /* if no room, give up (must have already done a gzungetc()) */
+ if (state->have == (state->size << 1)) {
+ gz_error(state, Z_BUF_ERROR, "out of room to push characters");
+ return -1;
+ }
+
+ /* slide output data if needed and insert byte before existing data */
+ if (state->next == state->out) {
+ unsigned char *src = state->out + state->have;
+ unsigned char *dest = state->out + (state->size << 1);
+ while (src > state->out)
+ *--dest = *--src;
+ state->next = dest;
+ }
+ state->have++;
+ state->next--;
+ state->next[0] = c;
+ state->pos--;
+ return c;
+}
+
+/* -- see zlib.h -- */
+char * ZEXPORT gzgets(gzFile file, char *buf, int len)
+{
+ unsigned left, n;
+ char *str;
+ unsigned char *eol;
+ gz_statep state;
+
+ /* check parameters and get internal structure */
+ if (file == NULL || buf == NULL || len < 1)
+ return NULL;
+ state = (gz_statep)file;
+
+ /* check that we're reading and that there's no error */
+ if (state->mode != GZ_READ || state->err != Z_OK)
+ return NULL;
+
+ /* process a skip request */
+ if (state->seek) {
+ state->seek = 0;
+ if (gz_skip(state, state->skip) == -1)
+ return NULL;
+ }
+
+ /* copy output bytes up to new line or len - 1, whichever comes first --
+ append a terminating zero to the string (we don't check for a zero in
+ the contents, let the user worry about that) */
+ str = buf;
+ left = (unsigned)len - 1;
+ if (left) do {
+ /* assure that something is in the output buffer */
+ if (state->have == 0) {
+ if (gz_make(state) == -1)
+ return NULL; /* error */
+ if (state->have == 0) { /* end of file */
+ if (buf == str) /* got bupkus */
+ return NULL;
+ break; /* got something -- return it */
+ }
+ }
+
+ /* look for end-of-line in current output buffer */
+ n = state->have > left ? left : state->have;
+ eol = (unsigned char *)memchr(state->next, '\n', n);
+ if (eol != NULL)
+ n = (unsigned)(eol - state->next) + 1;
+
+ /* copy through end-of-line, or remainder if not found */
+ memcpy(buf, state->next, n);
+ state->have -= n;
+ state->next += n;
+ state->pos += n;
+ left -= n;
+ buf += n;
+ } while (left && eol == NULL);
+
+ /* found end-of-line or out of space -- terminate string and return it */
+ buf[0] = 0;
+ return str;
+}
+
+/* -- see zlib.h -- */
+int ZEXPORT gzdirect(gzFile file)
+{
+ gz_statep state;
+
+ /* get internal structure */
+ if (file == NULL)
+ return 0;
+ state = (gz_statep)file;
+
+ /* check that we're reading */
+ if (state->mode != GZ_READ)
+ return 0;
+
+ /* if the state is not known, but we can find out, then do so (this is
+ mainly for right after a gzopen() or gzdopen()) */
+ if (state->how == LOOK && state->have == 0)
+ (void)gz_head(state);
+
+ /* return 1 if reading direct, 0 if decompressing a gzip stream */
+ return state->direct;
+}
+
+/* -- see zlib.h -- */
+int ZEXPORT gzclose_r(gzFile file)
+{
+ int ret;
+ gz_statep state;
+
+ /* get internal structure */
+ if (file == NULL)
+ return Z_STREAM_ERROR;
+ state = (gz_statep)file;
+
+ /* check that we're reading */
+ if (state->mode != GZ_READ)
+ return Z_STREAM_ERROR;
+
+ /* free memory and close file */
+ if (state->size) {
+ inflateEnd(&(state->strm));
+ free(state->out);
+ free(state->in);
+ }
+ gz_error(state, Z_OK, NULL);
+ free(state->path);
+ ret = close(state->fd);
+ free(state);
+ return ret ? Z_ERRNO : Z_OK;
+}
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/zlib/gzwrite.c b/src/misc/zlib/gzwrite.c
new file mode 100644
index 00000000..bf96602c
--- /dev/null
+++ b/src/misc/zlib/gzwrite.c
@@ -0,0 +1,520 @@
+/* gzwrite.c -- zlib functions for writing gzip files
+ * Copyright (C) 2004, 2005, 2010 Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "abc_global.h"
+
+#include "gzguts.h"
+
+ABC_NAMESPACE_IMPL_START
+
+/* Local functions */
+local int gz_init OF((gz_statep));
+local int gz_comp OF((gz_statep, int));
+local int gz_zero OF((gz_statep, z_off64_t));
+
+/* Initialize state for writing a gzip file. Mark initialization by setting
+ state->size to non-zero. Return -1 on failure or 0 on success. */
+local int gz_init(gz_statep state)
+{
+ int ret;
+ z_streamp strm = &(state->strm);
+
+ /* allocate input and output buffers */
+ state->in = (unsigned char *)malloc(state->want);
+ state->out = (unsigned char *)malloc(state->want);
+ if (state->in == NULL || state->out == NULL) {
+ if (state->out != NULL)
+ free(state->out);
+ if (state->in != NULL)
+ free(state->in);
+ gz_error(state, Z_MEM_ERROR, "out of memory");
+ return -1;
+ }
+
+ /* allocate deflate memory, set up for gzip compression */
+ strm->zalloc = Z_NULL;
+ strm->zfree = Z_NULL;
+ strm->opaque = Z_NULL;
+ ret = deflateInit2(strm, state->level, Z_DEFLATED,
+ 15 + 16, 8, state->strategy);
+ if (ret != Z_OK) {
+ free(state->in);
+ gz_error(state, Z_MEM_ERROR, "out of memory");
+ return -1;
+ }
+
+ /* mark state as initialized */
+ state->size = state->want;
+
+ /* initialize write buffer */
+ strm->avail_out = state->size;
+ strm->next_out = state->out;
+ state->next = strm->next_out;
+ return 0;
+}
+
+/* Compress whatever is at avail_in and next_in and write to the output file.
+ Return -1 if there is an error writing to the output file, otherwise 0.
+ flush is assumed to be a valid deflate() flush value. If flush is Z_FINISH,
+ then the deflate() state is reset to start a new gzip stream. */
+local int gz_comp(gz_statep state, int flush)
+{
+ int ret, got;
+ unsigned have;
+ z_streamp strm = &(state->strm);
+
+ /* allocate memory if this is the first time through */
+ if (state->size == 0 && gz_init(state) == -1)
+ return -1;
+
+ /* run deflate() on provided input until it produces no more output */
+ ret = Z_OK;
+ do {
+ /* write out current buffer contents if full, or if flushing, but if
+ doing Z_FINISH then don't write until we get to Z_STREAM_END */
+ if (strm->avail_out == 0 || (flush != Z_NO_FLUSH &&
+ (flush != Z_FINISH || ret == Z_STREAM_END))) {
+ have = (unsigned)(strm->next_out - state->next);
+ if (have && ((got = write(state->fd, state->next, have)) < 0 ||
+ (unsigned)got != have)) {
+ gz_error(state, Z_ERRNO, zstrerror());
+ return -1;
+ }
+ if (strm->avail_out == 0) {
+ strm->avail_out = state->size;
+ strm->next_out = state->out;
+ }
+ state->next = strm->next_out;
+ }
+
+ /* compress */
+ have = strm->avail_out;
+ ret = deflate(strm, flush);
+ if (ret == Z_STREAM_ERROR) {
+ gz_error(state, Z_STREAM_ERROR,
+ "internal error: deflate stream corrupt");
+ return -1;
+ }
+ have -= strm->avail_out;
+ } while (have);
+
+ /* if that completed a deflate stream, allow another to start */
+ if (flush == Z_FINISH)
+ deflateReset(strm);
+
+ /* all done, no errors */
+ return 0;
+}
+
+/* Compress len zeros to output. Return -1 on error, 0 on success. */
+local int gz_zero(gz_statep state, z_off64_t len)
+{
+ int first;
+ unsigned n;
+ z_streamp strm = &(state->strm);
+
+ /* consume whatever's left in the input buffer */
+ if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
+ return -1;
+
+ /* compress len zeros (len guaranteed > 0) */
+ first = 1;
+ while (len) {
+ n = GT_OFF(state->size) || (z_off64_t)state->size > len ?
+ (unsigned)len : state->size;
+ if (first) {
+ memset(state->in, 0, n);
+ first = 0;
+ }
+ strm->avail_in = n;
+ strm->next_in = state->in;
+ state->pos += n;
+ if (gz_comp(state, Z_NO_FLUSH) == -1)
+ return -1;
+ len -= n;
+ }
+ return 0;
+}
+
+/* -- see zlib.h -- */
+int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len)
+{
+ unsigned put = len;
+ unsigned n;
+ gz_statep state;
+ z_streamp strm;
+
+ /* get internal structure */
+ if (file == NULL)
+ return 0;
+ state = (gz_statep)file;
+ strm = &(state->strm);
+
+ /* check that we're writing and that there's no error */
+ if (state->mode != GZ_WRITE || state->err != Z_OK)
+ return 0;
+
+ /* since an int is returned, make sure len fits in one, otherwise return
+ with an error (this avoids the flaw in the interface) */
+ if ((int)len < 0) {
+ gz_error(state, Z_BUF_ERROR, "requested length does not fit in int");
+ return 0;
+ }
+
+ /* if len is zero, avoid unnecessary operations */
+ if (len == 0)
+ return 0;
+
+ /* allocate memory if this is the first time through */
+ if (state->size == 0 && gz_init(state) == -1)
+ return 0;
+
+ /* check for seek request */
+ if (state->seek) {
+ state->seek = 0;
+ if (gz_zero(state, state->skip) == -1)
+ return 0;
+ }
+
+ /* for small len, copy to input buffer, otherwise compress directly */
+ if (len < state->size) {
+ /* copy to input buffer, compress when full */
+ do {
+ if (strm->avail_in == 0)
+ strm->next_in = state->in;
+ n = state->size - strm->avail_in;
+ if (n > len)
+ n = len;
+ memcpy(strm->next_in + strm->avail_in, buf, n);
+ strm->avail_in += n;
+ state->pos += n;
+ buf = (char *)buf + n;
+ len -= n;
+ if (len && gz_comp(state, Z_NO_FLUSH) == -1)
+ return 0;
+ } while (len);
+ }
+ else {
+ /* consume whatever's left in the input buffer */
+ if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
+ return 0;
+
+ /* directly compress user buffer to file */
+ strm->avail_in = len;
+ strm->next_in = (unsigned char *)(voidp)buf;
+ state->pos += len;
+ if (gz_comp(state, Z_NO_FLUSH) == -1)
+ return 0;
+ }
+
+ /* input was all buffered or compressed (put will fit in int) */
+ return (int)put;
+}
+
+/* -- see zlib.h -- */
+int ZEXPORT gzputc(gzFile file, int c)
+{
+ unsigned char buf[1];
+ gz_statep state;
+ z_streamp strm;
+
+ /* get internal structure */
+ if (file == NULL)
+ return -1;
+ state = (gz_statep)file;
+ strm = &(state->strm);
+
+ /* check that we're writing and that there's no error */
+ if (state->mode != GZ_WRITE || state->err != Z_OK)
+ return -1;
+
+ /* check for seek request */
+ if (state->seek) {
+ state->seek = 0;
+ if (gz_zero(state, state->skip) == -1)
+ return -1;
+ }
+
+ /* try writing to input buffer for speed (state->size == 0 if buffer not
+ initialized) */
+ if (strm->avail_in < state->size) {
+ if (strm->avail_in == 0)
+ strm->next_in = state->in;
+ strm->next_in[strm->avail_in++] = c;
+ state->pos++;
+ return c;
+ }
+
+ /* no room in buffer or not initialized, use gz_write() */
+ buf[0] = c;
+ if (gzwrite(file, buf, 1) != 1)
+ return -1;
+ return c;
+}
+
+/* -- see zlib.h -- */
+int ZEXPORT gzputs(gzFile file, const char *str)
+{
+ int ret;
+ unsigned len;
+
+ /* write string */
+ len = (unsigned)strlen(str);
+ ret = gzwrite(file, str, len);
+ return ret == 0 && len != 0 ? -1 : ret;
+}
+
+#ifdef STDC
+#include <stdarg.h>
+
+/* -- see zlib.h -- */
+int ZEXPORTVA gzprintf (gzFile file, const char *format, ...)
+{
+ int size, len;
+ gz_statep state;
+ z_streamp strm;
+ va_list va;
+
+ /* get internal structure */
+ if (file == NULL)
+ return -1;
+ state = (gz_statep)file;
+ strm = &(state->strm);
+
+ /* check that we're writing and that there's no error */
+ if (state->mode != GZ_WRITE || state->err != Z_OK)
+ return 0;
+
+ /* make sure we have some buffer space */
+ if (state->size == 0 && gz_init(state) == -1)
+ return 0;
+
+ /* check for seek request */
+ if (state->seek) {
+ state->seek = 0;
+ if (gz_zero(state, state->skip) == -1)
+ return 0;
+ }
+
+ /* consume whatever's left in the input buffer */
+ if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
+ return 0;
+
+ /* do the printf() into the input buffer, put length in len */
+ size = (int)(state->size);
+ state->in[size - 1] = 0;
+ va_start(va, format);
+#ifdef NO_vsnprintf
+# ifdef HAS_vsprintf_void
+ (void)vsprintf(state->in, format, va);
+ va_end(va);
+ for (len = 0; len < size; len++)
+ if (state->in[len] == 0) break;
+# else
+ len = vsprintf(state->in, format, va);
+ va_end(va);
+# endif
+#else
+# ifdef HAS_vsnprintf_void
+ (void)vsnprintf(state->in, size, format, va);
+ va_end(va);
+ len = strlen(state->in);
+# else
+ len = vsnprintf((char *)(state->in), size, format, va);
+ va_end(va);
+# endif
+#endif
+
+ /* check that printf() results fit in buffer */
+ if (len <= 0 || len >= (int)size || state->in[size - 1] != 0)
+ return 0;
+
+ /* update buffer and position, defer compression until needed */
+ strm->avail_in = (unsigned)len;
+ strm->next_in = state->in;
+ state->pos += len;
+ return len;
+}
+
+#else /* !STDC */
+
+/* -- see zlib.h -- */
+int ZEXPORTVA gzprintf (gzFile file, const char *format, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9, int a10,
+ int a11, int a12, int a13, int a14, int a15, int a16, int a17, int a18, int a19, int a20)
+{
+ int size, len;
+ gz_statep state;
+ z_streamp strm;
+
+ /* get internal structure */
+ if (file == NULL)
+ return -1;
+ state = (gz_statep)file;
+ strm = &(state->strm);
+
+ /* check that we're writing and that there's no error */
+ if (state->mode != GZ_WRITE || state->err != Z_OK)
+ return 0;
+
+ /* make sure we have some buffer space */
+ if (state->size == 0 && gz_init(state) == -1)
+ return 0;
+
+ /* check for seek request */
+ if (state->seek) {
+ state->seek = 0;
+ if (gz_zero(state, state->skip) == -1)
+ return 0;
+ }
+
+ /* consume whatever's left in the input buffer */
+ if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
+ return 0;
+
+ /* do the printf() into the input buffer, put length in len */
+ size = (int)(state->size);
+ state->in[size - 1] = 0;
+#ifdef NO_snprintf
+# ifdef HAS_sprintf_void
+ sprintf(state->in, format, a1, a2, a3, a4, a5, a6, a7, a8,
+ a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
+ for (len = 0; len < size; len++)
+ if (state->in[len] == 0) break;
+# else
+ len = sprintf(state->in, format, a1, a2, a3, a4, a5, a6, a7, a8,
+ a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
+# endif
+#else
+# ifdef HAS_snprintf_void
+ snprintf(state->in, size, format, a1, a2, a3, a4, a5, a6, a7, a8,
+ a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
+ len = strlen(state->in);
+# else
+ len = snprintf(state->in, size, format, a1, a2, a3, a4, a5, a6, a7, a8,
+ a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
+# endif
+#endif
+
+ /* check that printf() results fit in buffer */
+ if (len <= 0 || len >= (int)size || state->in[size - 1] != 0)
+ return 0;
+
+ /* update buffer and position, defer compression until needed */
+ strm->avail_in = (unsigned)len;
+ strm->next_in = state->in;
+ state->pos += len;
+ return len;
+}
+
+#endif
+
+/* -- see zlib.h -- */
+int ZEXPORT gzflush(gzFile file, int flush)
+{
+ gz_statep state;
+
+ /* get internal structure */
+ if (file == NULL)
+ return -1;
+ state = (gz_statep)file;
+
+ /* check that we're writing and that there's no error */
+ if (state->mode != GZ_WRITE || state->err != Z_OK)
+ return Z_STREAM_ERROR;
+
+ /* check flush parameter */
+ if (flush < 0 || flush > Z_FINISH)
+ return Z_STREAM_ERROR;
+
+ /* check for seek request */
+ if (state->seek) {
+ state->seek = 0;
+ if (gz_zero(state, state->skip) == -1)
+ return -1;
+ }
+
+ /* compress remaining data with requested flush */
+ gz_comp(state, flush);
+ return state->err;
+}
+
+/* -- see zlib.h -- */
+int ZEXPORT gzsetparams(gzFile file, int level, int strategy)
+{
+ gz_statep state;
+ z_streamp strm;
+
+ /* get internal structure */
+ if (file == NULL)
+ return Z_STREAM_ERROR;
+ state = (gz_statep)file;
+ strm = &(state->strm);
+
+ /* check that we're writing and that there's no error */
+ if (state->mode != GZ_WRITE || state->err != Z_OK)
+ return Z_STREAM_ERROR;
+
+ /* if no change is requested, then do nothing */
+ if (level == state->level && strategy == state->strategy)
+ return Z_OK;
+
+ /* check for seek request */
+ if (state->seek) {
+ state->seek = 0;
+ if (gz_zero(state, state->skip) == -1)
+ return -1;
+ }
+
+ /* change compression parameters for subsequent input */
+ if (state->size) {
+ /* flush previous input with previous parameters before changing */
+ if (strm->avail_in && gz_comp(state, Z_PARTIAL_FLUSH) == -1)
+ return state->err;
+ deflateParams(strm, level, strategy);
+ }
+ state->level = level;
+ state->strategy = strategy;
+ return Z_OK;
+}
+
+/* -- see zlib.h -- */
+int ZEXPORT gzclose_w(gzFile file)
+{
+ int ret = 0;
+ gz_statep state;
+
+ /* get internal structure */
+ if (file == NULL)
+ return Z_STREAM_ERROR;
+ state = (gz_statep)file;
+
+ /* check that we're writing */
+ if (state->mode != GZ_WRITE)
+ return Z_STREAM_ERROR;
+
+ /* check for seek request */
+ if (state->seek) {
+ state->seek = 0;
+ ret += gz_zero(state, state->skip);
+ }
+
+ /* flush, free memory, and close file */
+ ret += gz_comp(state, Z_FINISH);
+ (void)deflateEnd(&(state->strm));
+ free(state->out);
+ free(state->in);
+ gz_error(state, Z_OK, NULL);
+ free(state->path);
+ ret += close(state->fd);
+ free(state);
+ return ret ? Z_ERRNO : Z_OK;
+}
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/zlib/infback.c b/src/misc/zlib/infback.c
index 455dbc9e..882b2492 100644
--- a/src/misc/zlib/infback.c
+++ b/src/misc/zlib/infback.c
@@ -1,5 +1,5 @@
/* infback.c -- inflate using a call-back interface
- * Copyright (C) 1995-2005 Mark Adler
+ * Copyright (C) 1995-2009 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -10,11 +10,18 @@
inflate_fast() can be used with either inflate.c or infback.c.
*/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "abc_global.h"
+
#include "zutil.h"
#include "inftrees.h"
#include "inflate.h"
#include "inffast.h"
+ABC_NAMESPACE_IMPL_START
+
/* function prototypes */
local void fixedtables OF((struct inflate_state FAR *state));
@@ -25,12 +32,7 @@ local void fixedtables OF((struct inflate_state FAR *state));
windowBits is in the range 8..15, and window is a user-supplied
window and output buffer that is 2**windowBits bytes.
*/
-int ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size)
-z_streamp strm;
-int windowBits;
-unsigned char FAR *window;
-const char *version;
-int stream_size;
+int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits, unsigned char FAR *window, const char *version, int stream_size)
{
struct inflate_state FAR *state;
@@ -55,7 +57,7 @@ int stream_size;
state->wbits = windowBits;
state->wsize = 1U << windowBits;
state->window = window;
- state->write = 0;
+ state->wnext = 0;
state->whave = 0;
return Z_OK;
}
@@ -70,8 +72,7 @@ int stream_size;
used for threaded applications, since the rewriting of the tables and virgin
may not be thread-safe.
*/
-local void fixedtables(state)
-struct inflate_state FAR *state;
+local void fixedtables(struct inflate_state FAR *state)
{
#ifdef BUILDFIXED
static int virgin = 1;
@@ -238,12 +239,7 @@ struct inflate_state FAR *state;
inflateBack() can also return Z_STREAM_ERROR if the input parameters
are not correct, i.e. strm is Z_NULL or the state was not initialized.
*/
-int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc)
-z_streamp strm;
-in_func in;
-void FAR *in_desc;
-out_func out;
-void FAR *out_desc;
+int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc, out_func out, void FAR *out_desc)
{
struct inflate_state FAR *state;
unsigned char FAR *next; /* next input */
@@ -253,7 +249,7 @@ void FAR *out_desc;
unsigned bits; /* bits in bit buffer */
unsigned copy; /* number of stored or match bytes to copy */
unsigned char FAR *from; /* where to copy match bytes from */
- code this; /* current decoding table entry */
+ code here; /* current decoding table entry */
code last; /* parent table entry */
unsigned len; /* length to copy for repeats, bits to drop */
int ret; /* return code */
@@ -389,19 +385,19 @@ void FAR *out_desc;
state->have = 0;
while (state->have < state->nlen + state->ndist) {
for (;;) {
- this = state->lencode[BITS(state->lenbits)];
- if ((unsigned)(this.bits) <= bits) break;
+ here = state->lencode[BITS(state->lenbits)];
+ if ((unsigned)(here.bits) <= bits) break;
PULLBYTE();
}
- if (this.val < 16) {
- NEEDBITS(this.bits);
- DROPBITS(this.bits);
- state->lens[state->have++] = this.val;
+ if (here.val < 16) {
+ NEEDBITS(here.bits);
+ DROPBITS(here.bits);
+ state->lens[state->have++] = here.val;
}
else {
- if (this.val == 16) {
- NEEDBITS(this.bits + 2);
- DROPBITS(this.bits);
+ if (here.val == 16) {
+ NEEDBITS(here.bits + 2);
+ DROPBITS(here.bits);
if (state->have == 0) {
strm->msg = (char *)"invalid bit length repeat";
state->mode = BAD;
@@ -411,16 +407,16 @@ void FAR *out_desc;
copy = 3 + BITS(2);
DROPBITS(2);
}
- else if (this.val == 17) {
- NEEDBITS(this.bits + 3);
- DROPBITS(this.bits);
+ else if (here.val == 17) {
+ NEEDBITS(here.bits + 3);
+ DROPBITS(here.bits);
len = 0;
copy = 3 + BITS(3);
DROPBITS(3);
}
else {
- NEEDBITS(this.bits + 7);
- DROPBITS(this.bits);
+ NEEDBITS(here.bits + 7);
+ DROPBITS(here.bits);
len = 0;
copy = 11 + BITS(7);
DROPBITS(7);
@@ -438,7 +434,16 @@ void FAR *out_desc;
/* handle error breaks in while */
if (state->mode == BAD) break;
- /* build code tables */
+ /* check for end-of-block code (better have one) */
+ if (state->lens[256] == 0) {
+ strm->msg = (char *)"invalid code -- missing end-of-block";
+ state->mode = BAD;
+ break;
+ }
+
+ /* build code tables -- note: do not change the lenbits or distbits
+ values here (9 and 6) without reading the comments in inftrees.h
+ concerning the ENOUGH constants, which depend on those values */
state->next = state->codes;
state->lencode = (code const FAR *)(state->next);
state->lenbits = 9;
@@ -474,28 +479,28 @@ void FAR *out_desc;
/* get a literal, length, or end-of-block code */
for (;;) {
- this = state->lencode[BITS(state->lenbits)];
- if ((unsigned)(this.bits) <= bits) break;
+ here = state->lencode[BITS(state->lenbits)];
+ if ((unsigned)(here.bits) <= bits) break;
PULLBYTE();
}
- if (this.op && (this.op & 0xf0) == 0) {
- last = this;
+ if (here.op && (here.op & 0xf0) == 0) {
+ last = here;
for (;;) {
- this = state->lencode[last.val +
+ here = state->lencode[last.val +
(BITS(last.bits + last.op) >> last.bits)];
- if ((unsigned)(last.bits + this.bits) <= bits) break;
+ if ((unsigned)(last.bits + here.bits) <= bits) break;
PULLBYTE();
}
DROPBITS(last.bits);
}
- DROPBITS(this.bits);
- state->length = (unsigned)this.val;
+ DROPBITS(here.bits);
+ state->length = (unsigned)here.val;
/* process literal */
- if (this.op == 0) {
- Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
+ if (here.op == 0) {
+ Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
"inflate: literal '%c'\n" :
- "inflate: literal 0x%02x\n", this.val));
+ "inflate: literal 0x%02x\n", here.val));
ROOM();
*put++ = (unsigned char)(state->length);
left--;
@@ -504,21 +509,21 @@ void FAR *out_desc;
}
/* process end of block */
- if (this.op & 32) {
+ if (here.op & 32) {
Tracevv((stderr, "inflate: end of block\n"));
state->mode = TYPE;
break;
}
/* invalid code */
- if (this.op & 64) {
+ if (here.op & 64) {
strm->msg = (char *)"invalid literal/length code";
state->mode = BAD;
break;
}
/* length code -- get extra bits, if any */
- state->extra = (unsigned)(this.op) & 15;
+ state->extra = (unsigned)(here.op) & 15;
if (state->extra != 0) {
NEEDBITS(state->extra);
state->length += BITS(state->extra);
@@ -528,30 +533,30 @@ void FAR *out_desc;
/* get distance code */
for (;;) {
- this = state->distcode[BITS(state->distbits)];
- if ((unsigned)(this.bits) <= bits) break;
+ here = state->distcode[BITS(state->distbits)];
+ if ((unsigned)(here.bits) <= bits) break;
PULLBYTE();
}
- if ((this.op & 0xf0) == 0) {
- last = this;
+ if ((here.op & 0xf0) == 0) {
+ last = here;
for (;;) {
- this = state->distcode[last.val +
+ here = state->distcode[last.val +
(BITS(last.bits + last.op) >> last.bits)];
- if ((unsigned)(last.bits + this.bits) <= bits) break;
+ if ((unsigned)(last.bits + here.bits) <= bits) break;
PULLBYTE();
}
DROPBITS(last.bits);
}
- DROPBITS(this.bits);
- if (this.op & 64) {
+ DROPBITS(here.bits);
+ if (here.op & 64) {
strm->msg = (char *)"invalid distance code";
state->mode = BAD;
break;
}
- state->offset = (unsigned)this.val;
+ state->offset = (unsigned)here.val;
/* get distance extra bits, if any */
- state->extra = (unsigned)(this.op) & 15;
+ state->extra = (unsigned)(here.op) & 15;
if (state->extra != 0) {
NEEDBITS(state->extra);
state->offset += BITS(state->extra);
@@ -611,8 +616,7 @@ void FAR *out_desc;
return ret;
}
-int ZEXPORT inflateBackEnd(strm)
-z_streamp strm;
+int ZEXPORT inflateBackEnd(z_streamp strm)
{
if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
return Z_STREAM_ERROR;
@@ -621,3 +625,7 @@ z_streamp strm;
Tracev((stderr, "inflate: end\n"));
return Z_OK;
}
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/zlib/inffast.c b/src/misc/zlib/inffast.c
index bbee92ed..22bc98d1 100644
--- a/src/misc/zlib/inffast.c
+++ b/src/misc/zlib/inffast.c
@@ -1,13 +1,20 @@
/* inffast.c -- fast decoding
- * Copyright (C) 1995-2004 Mark Adler
+ * Copyright (C) 1995-2008, 2010 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "abc_global.h"
+
#include "zutil.h"
#include "inftrees.h"
#include "inflate.h"
#include "inffast.h"
+ABC_NAMESPACE_IMPL_START
+
#ifndef ASMINF
/* Allow machine dependent optimization for post-increment or pre-increment.
@@ -64,9 +71,7 @@
requires strm->avail_out >= 258 for each loop to avoid checking for
output space.
*/
-void inflate_fast(strm, start)
-z_streamp strm;
-unsigned start; /* inflate()'s starting value for strm->avail_out */
+void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start) /* inflate()'s starting value for strm->avail_out */
{
struct inflate_state FAR *state;
unsigned char FAR *in; /* local strm->next_in */
@@ -79,7 +84,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
#endif
unsigned wsize; /* window size or zero if not using window */
unsigned whave; /* valid bytes in the window */
- unsigned write; /* window write index */
+ unsigned wnext; /* window write index */
unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */
unsigned long hold; /* local strm->hold */
unsigned bits; /* local strm->bits */
@@ -87,7 +92,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
code const FAR *dcode; /* local strm->distcode */
unsigned lmask; /* mask for first level of length codes */
unsigned dmask; /* mask for first level of distance codes */
- code this; /* retrieved table entry */
+ code here; /* retrieved table entry */
unsigned op; /* code bits, operation, extra bits, or */
/* window position, window bytes to copy */
unsigned len; /* match length, unused bytes */
@@ -106,7 +111,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
#endif
wsize = state->wsize;
whave = state->whave;
- write = state->write;
+ wnext = state->wnext;
window = state->window;
hold = state->hold;
bits = state->bits;
@@ -124,20 +129,20 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
hold += (unsigned long)(PUP(in)) << bits;
bits += 8;
}
- this = lcode[hold & lmask];
+ here = lcode[hold & lmask];
dolen:
- op = (unsigned)(this.bits);
+ op = (unsigned)(here.bits);
hold >>= op;
bits -= op;
- op = (unsigned)(this.op);
+ op = (unsigned)(here.op);
if (op == 0) { /* literal */
- Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
+ Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
"inflate: literal '%c'\n" :
- "inflate: literal 0x%02x\n", this.val));
- PUP(out) = (unsigned char)(this.val);
+ "inflate: literal 0x%02x\n", here.val));
+ PUP(out) = (unsigned char)(here.val);
}
else if (op & 16) { /* length base */
- len = (unsigned)(this.val);
+ len = (unsigned)(here.val);
op &= 15; /* number of extra bits */
if (op) {
if (bits < op) {
@@ -155,14 +160,14 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
hold += (unsigned long)(PUP(in)) << bits;
bits += 8;
}
- this = dcode[hold & dmask];
+ here = dcode[hold & dmask];
dodist:
- op = (unsigned)(this.bits);
+ op = (unsigned)(here.bits);
hold >>= op;
bits -= op;
- op = (unsigned)(this.op);
+ op = (unsigned)(here.op);
if (op & 16) { /* distance base */
- dist = (unsigned)(this.val);
+ dist = (unsigned)(here.val);
op &= 15; /* number of extra bits */
if (bits < op) {
hold += (unsigned long)(PUP(in)) << bits;
@@ -187,12 +192,34 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
if (dist > op) { /* see if copy from window */
op = dist - op; /* distance back in window */
if (op > whave) {
- strm->msg = (char *)"invalid distance too far back";
- state->mode = BAD;
- break;
+ if (state->sane) {
+ strm->msg =
+ (char *)"invalid distance too far back";
+ state->mode = BAD;
+ break;
+ }
+#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
+ if (len <= op - whave) {
+ do {
+ PUP(out) = 0;
+ } while (--len);
+ continue;
+ }
+ len -= op - whave;
+ do {
+ PUP(out) = 0;
+ } while (--op > whave);
+ if (op == 0) {
+ from = out - dist;
+ do {
+ PUP(out) = PUP(from);
+ } while (--len);
+ continue;
+ }
+#endif
}
from = window - OFF;
- if (write == 0) { /* very common case */
+ if (wnext == 0) { /* very common case */
from += wsize - op;
if (op < len) { /* some from window */
len -= op;
@@ -202,17 +229,17 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
from = out - dist; /* rest from output */
}
}
- else if (write < op) { /* wrap around window */
- from += wsize + write - op;
- op -= write;
+ else if (wnext < op) { /* wrap around window */
+ from += wsize + wnext - op;
+ op -= wnext;
if (op < len) { /* some from end of window */
len -= op;
do {
PUP(out) = PUP(from);
} while (--op);
from = window - OFF;
- if (write < len) { /* some from start of window */
- op = write;
+ if (wnext < len) { /* some from start of window */
+ op = wnext;
len -= op;
do {
PUP(out) = PUP(from);
@@ -222,7 +249,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
}
}
else { /* contiguous in window */
- from += write - op;
+ from += wnext - op;
if (op < len) { /* some from window */
len -= op;
do {
@@ -259,7 +286,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
}
}
else if ((op & 64) == 0) { /* 2nd level distance code */
- this = dcode[this.val + (hold & ((1U << op) - 1))];
+ here = dcode[here.val + (hold & ((1U << op) - 1))];
goto dodist;
}
else {
@@ -269,7 +296,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
}
}
else if ((op & 64) == 0) { /* 2nd level length code */
- this = lcode[this.val + (hold & ((1U << op) - 1))];
+ here = lcode[here.val + (hold & ((1U << op) - 1))];
goto dolen;
}
else if (op & 32) { /* end-of-block */
@@ -305,7 +332,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe):
- Using bit fields for code structure
- Different op definition to avoid & for extra bits (do & for table bits)
- - Three separate decoding do-loops for direct, window, and write == 0
+ - Three separate decoding do-loops for direct, window, and wnext == 0
- Special case for distance > 1 copies to do overlapped load and store copy
- Explicit branch predictions (based on measured branch probabilities)
- Deferring match copy and interspersed it with decoding subsequent codes
@@ -316,3 +343,9 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
*/
#endif /* !ASMINF */
+
+
+
+ABC_NAMESPACE_IMPL_END
+
+
diff --git a/src/misc/zlib/inffast.h b/src/misc/zlib/inffast.h
index 1e88d2d9..4fb86a11 100644
--- a/src/misc/zlib/inffast.h
+++ b/src/misc/zlib/inffast.h
@@ -1,5 +1,5 @@
/* inffast.h -- header to use inffast.c
- * Copyright (C) 1995-2003 Mark Adler
+ * Copyright (C) 1995-2003, 2010 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -8,4 +8,8 @@
subject to change. Applications should only use zlib.h.
*/
-void inflate_fast OF((z_streamp strm, unsigned start));
+ABC_NAMESPACE_HEADER_START
+
+void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start));
+
+ABC_NAMESPACE_HEADER_END
diff --git a/src/misc/zlib/inffixed.h b/src/misc/zlib/inffixed.h
index 75ed4b59..19befa9a 100644
--- a/src/misc/zlib/inffixed.h
+++ b/src/misc/zlib/inffixed.h
@@ -7,6 +7,8 @@
is subject to change. Applications should only use zlib.h.
*/
+//ABC_NAMESPACE_HEADER_START
+
static const code lenfix[512] = {
{96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48},
{0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128},
@@ -92,3 +94,5 @@
{16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073},
{22,5,193},{64,5,0}
};
+
+//ABC_NAMESPACE_HEADER_END
diff --git a/src/misc/zlib/inflate.c b/src/misc/zlib/inflate.c
index 792fdee8..c68c13f5 100644
--- a/src/misc/zlib/inflate.c
+++ b/src/misc/zlib/inflate.c
@@ -1,5 +1,5 @@
/* inflate.c -- zlib decompression
- * Copyright (C) 1995-2005 Mark Adler
+ * Copyright (C) 1995-2010 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -45,7 +45,7 @@
* - Rearrange window copies in inflate_fast() for speed and simplification
* - Unroll last copy for window match in inflate_fast()
* - Use local copies of window variables in inflate_fast() for speed
- * - Pull out common write == 0 case for speed in inflate_fast()
+ * - Pull out common wnext == 0 case for speed in inflate_fast()
* - Make op and len in inflate_fast() unsigned for consistency
* - Add FAR to lcode and dcode declarations in inflate_fast()
* - Simplified bad distance check in inflate_fast()
@@ -80,11 +80,18 @@
* The history for versions after 1.2.0 are in ChangeLog in zlib distribution.
*/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "abc_global.h"
+
#include "zutil.h"
#include "inftrees.h"
#include "inflate.h"
#include "inffast.h"
+ABC_NAMESPACE_IMPL_START
+
#ifdef MAKEFIXED
# ifndef BUILDFIXED
# define BUILDFIXED
@@ -100,8 +107,7 @@ local int updatewindow OF((z_streamp strm, unsigned out));
local unsigned syncsearch OF((unsigned FAR *have, unsigned char FAR *buf,
unsigned len));
-int ZEXPORT inflateReset(strm)
-z_streamp strm;
+int ZEXPORT inflateReset(z_streamp strm)
{
struct inflate_state FAR *state;
@@ -117,36 +123,55 @@ z_streamp strm;
state->head = Z_NULL;
state->wsize = 0;
state->whave = 0;
- state->write = 0;
+ state->wnext = 0;
state->hold = 0;
state->bits = 0;
state->lencode = state->distcode = state->next = state->codes;
+ state->sane = 1;
+ state->back = -1;
Tracev((stderr, "inflate: reset\n"));
return Z_OK;
}
-int ZEXPORT inflatePrime(strm, bits, value)
-z_streamp strm;
-int bits;
-int value;
+int ZEXPORT inflateReset2(z_streamp strm, int windowBits)
{
+ int wrap;
struct inflate_state FAR *state;
+ /* get the state */
if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
state = (struct inflate_state FAR *)strm->state;
- if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR;
- value &= (1L << bits) - 1;
- state->hold += value << state->bits;
- state->bits += bits;
- return Z_OK;
+
+ /* extract wrap request from windowBits parameter */
+ if (windowBits < 0) {
+ wrap = 0;
+ windowBits = -windowBits;
+ }
+ else {
+ wrap = (windowBits >> 4) + 1;
+#ifdef GUNZIP
+ if (windowBits < 48)
+ windowBits &= 15;
+#endif
+ }
+
+ /* set number of window bits, free window if different */
+ if (windowBits && (windowBits < 8 || windowBits > 15))
+ return Z_STREAM_ERROR;
+ if (state->window != Z_NULL && state->wbits != (unsigned)windowBits) {
+ ZFREE(strm, state->window);
+ state->window = Z_NULL;
+ }
+
+ /* update state and reset the rest of it */
+ state->wrap = wrap;
+ state->wbits = (unsigned)windowBits;
+ return inflateReset(strm);
}
-int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size)
-z_streamp strm;
-int windowBits;
-const char *version;
-int stream_size;
+int ZEXPORT inflateInit2_(z_streamp strm, int windowBits, const char *version, int stream_size)
{
+ int ret;
struct inflate_state FAR *state;
if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
@@ -164,34 +189,38 @@ int stream_size;
if (state == Z_NULL) return Z_MEM_ERROR;
Tracev((stderr, "inflate: allocated\n"));
strm->state = (struct internal_state FAR *)state;
- if (windowBits < 0) {
- state->wrap = 0;
- windowBits = -windowBits;
- }
- else {
- state->wrap = (windowBits >> 4) + 1;
-#ifdef GUNZIP
- if (windowBits < 48) windowBits &= 15;
-#endif
- }
- if (windowBits < 8 || windowBits > 15) {
+ state->window = Z_NULL;
+ ret = inflateReset2(strm, windowBits);
+ if (ret != Z_OK) {
ZFREE(strm, state);
strm->state = Z_NULL;
- return Z_STREAM_ERROR;
}
- state->wbits = (unsigned)windowBits;
- state->window = Z_NULL;
- return inflateReset(strm);
+ return ret;
}
-int ZEXPORT inflateInit_(strm, version, stream_size)
-z_streamp strm;
-const char *version;
-int stream_size;
+int ZEXPORT inflateInit_(z_streamp strm, const char *version, int stream_size)
{
return inflateInit2_(strm, DEF_WBITS, version, stream_size);
}
+int ZEXPORT inflatePrime(z_streamp strm, int bits, int value)
+{
+ struct inflate_state FAR *state;
+
+ if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ state = (struct inflate_state FAR *)strm->state;
+ if (bits < 0) {
+ state->hold = 0;
+ state->bits = 0;
+ return Z_OK;
+ }
+ if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR;
+ value &= (1L << bits) - 1;
+ state->hold += value << state->bits;
+ state->bits += bits;
+ return Z_OK;
+}
+
/*
Return state with length and distance decoding tables and index sizes set to
fixed code decoding. Normally this returns fixed tables from inffixed.h.
@@ -202,8 +231,7 @@ int stream_size;
used for threaded applications, since the rewriting of the tables and virgin
may not be thread-safe.
*/
-local void fixedtables(state)
-struct inflate_state FAR *state;
+local void fixedtables(struct inflate_state FAR *state)
{
#ifdef BUILDFIXED
static int virgin = 1;
@@ -320,9 +348,7 @@ void makefixed()
output will fall in the output data, making match copies simpler and faster.
The advantage may be dependent on the size of the processor's data caches.
*/
-local int updatewindow(strm, out)
-z_streamp strm;
-unsigned out;
+local int updatewindow(z_streamp strm, unsigned out)
{
struct inflate_state FAR *state;
unsigned copy, dist;
@@ -340,7 +366,7 @@ unsigned out;
/* if window not in use yet, initialize */
if (state->wsize == 0) {
state->wsize = 1U << state->wbits;
- state->write = 0;
+ state->wnext = 0;
state->whave = 0;
}
@@ -348,22 +374,22 @@ unsigned out;
copy = out - strm->avail_out;
if (copy >= state->wsize) {
zmemcpy(state->window, strm->next_out - state->wsize, state->wsize);
- state->write = 0;
+ state->wnext = 0;
state->whave = state->wsize;
}
else {
- dist = state->wsize - state->write;
+ dist = state->wsize - state->wnext;
if (dist > copy) dist = copy;
- zmemcpy(state->window + state->write, strm->next_out - copy, dist);
+ zmemcpy(state->window + state->wnext, strm->next_out - copy, dist);
copy -= dist;
if (copy) {
zmemcpy(state->window, strm->next_out - copy, copy);
- state->write = copy;
+ state->wnext = copy;
state->whave = state->wsize;
}
else {
- state->write += dist;
- if (state->write == state->wsize) state->write = 0;
+ state->wnext += dist;
+ if (state->wnext == state->wsize) state->wnext = 0;
if (state->whave < state->wsize) state->whave += dist;
}
}
@@ -551,9 +577,7 @@ unsigned out;
will return Z_BUF_ERROR if it has not reached the end of the stream.
*/
-int ZEXPORT inflate(strm, flush)
-z_streamp strm;
-int flush;
+int ZEXPORT inflate(z_streamp strm, int flush)
{
struct inflate_state FAR *state;
unsigned char FAR *next; /* next input */
@@ -564,7 +588,7 @@ int flush;
unsigned in, out; /* save starting available input and output */
unsigned copy; /* number of stored or match bytes to copy */
unsigned char FAR *from; /* where to copy match bytes from */
- code this; /* current decoding table entry */
+ code here; /* current decoding table entry */
code last; /* parent table entry */
unsigned len; /* length to copy for repeats, bits to drop */
int ret; /* return code */
@@ -619,7 +643,9 @@ int flush;
}
DROPBITS(4);
len = BITS(4) + 8;
- if (len > state->wbits) {
+ if (state->wbits == 0)
+ state->wbits = len;
+ else if (len > state->wbits) {
strm->msg = (char *)"invalid window size";
state->mode = BAD;
break;
@@ -771,7 +797,7 @@ int flush;
strm->adler = state->check = adler32(0L, Z_NULL, 0);
state->mode = TYPE;
case TYPE:
- if (flush == Z_BLOCK) goto inf_leave;
+ if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;
case TYPEDO:
if (state->last) {
BYTEBITS();
@@ -791,7 +817,11 @@ int flush;
fixedtables(state);
Tracev((stderr, "inflate: fixed codes block%s\n",
state->last ? " (last)" : ""));
- state->mode = LEN; /* decode codes */
+ state->mode = LEN_; /* decode codes */
+ if (flush == Z_TREES) {
+ DROPBITS(2);
+ goto inf_leave;
+ }
break;
case 2: /* dynamic block */
Tracev((stderr, "inflate: dynamic codes block%s\n",
@@ -816,6 +846,9 @@ int flush;
Tracev((stderr, "inflate: stored length %u\n",
state->length));
INITBITS();
+ state->mode = COPY_;
+ if (flush == Z_TREES) goto inf_leave;
+ case COPY_:
state->mode = COPY;
case COPY:
copy = state->length;
@@ -876,19 +909,19 @@ int flush;
case CODELENS:
while (state->have < state->nlen + state->ndist) {
for (;;) {
- this = state->lencode[BITS(state->lenbits)];
- if ((unsigned)(this.bits) <= bits) break;
+ here = state->lencode[BITS(state->lenbits)];
+ if ((unsigned)(here.bits) <= bits) break;
PULLBYTE();
}
- if (this.val < 16) {
- NEEDBITS(this.bits);
- DROPBITS(this.bits);
- state->lens[state->have++] = this.val;
+ if (here.val < 16) {
+ NEEDBITS(here.bits);
+ DROPBITS(here.bits);
+ state->lens[state->have++] = here.val;
}
else {
- if (this.val == 16) {
- NEEDBITS(this.bits + 2);
- DROPBITS(this.bits);
+ if (here.val == 16) {
+ NEEDBITS(here.bits + 2);
+ DROPBITS(here.bits);
if (state->have == 0) {
strm->msg = (char *)"invalid bit length repeat";
state->mode = BAD;
@@ -898,16 +931,16 @@ int flush;
copy = 3 + BITS(2);
DROPBITS(2);
}
- else if (this.val == 17) {
- NEEDBITS(this.bits + 3);
- DROPBITS(this.bits);
+ else if (here.val == 17) {
+ NEEDBITS(here.bits + 3);
+ DROPBITS(here.bits);
len = 0;
copy = 3 + BITS(3);
DROPBITS(3);
}
else {
- NEEDBITS(this.bits + 7);
- DROPBITS(this.bits);
+ NEEDBITS(here.bits + 7);
+ DROPBITS(here.bits);
len = 0;
copy = 11 + BITS(7);
DROPBITS(7);
@@ -925,7 +958,16 @@ int flush;
/* handle error breaks in while */
if (state->mode == BAD) break;
- /* build code tables */
+ /* check for end-of-block code (better have one) */
+ if (state->lens[256] == 0) {
+ strm->msg = (char *)"invalid code -- missing end-of-block";
+ state->mode = BAD;
+ break;
+ }
+
+ /* build code tables -- note: do not change the lenbits or distbits
+ values here (9 and 6) without reading the comments in inftrees.h
+ concerning the ENOUGH constants, which depend on those values */
state->next = state->codes;
state->lencode = (code const FAR *)(state->next);
state->lenbits = 9;
@@ -946,88 +988,102 @@ int flush;
break;
}
Tracev((stderr, "inflate: codes ok\n"));
+ state->mode = LEN_;
+ if (flush == Z_TREES) goto inf_leave;
+ case LEN_:
state->mode = LEN;
case LEN:
if (have >= 6 && left >= 258) {
RESTORE();
inflate_fast(strm, out);
LOAD();
+ if (state->mode == TYPE)
+ state->back = -1;
break;
}
+ state->back = 0;
for (;;) {
- this = state->lencode[BITS(state->lenbits)];
- if ((unsigned)(this.bits) <= bits) break;
+ here = state->lencode[BITS(state->lenbits)];
+ if ((unsigned)(here.bits) <= bits) break;
PULLBYTE();
}
- if (this.op && (this.op & 0xf0) == 0) {
- last = this;
+ if (here.op && (here.op & 0xf0) == 0) {
+ last = here;
for (;;) {
- this = state->lencode[last.val +
+ here = state->lencode[last.val +
(BITS(last.bits + last.op) >> last.bits)];
- if ((unsigned)(last.bits + this.bits) <= bits) break;
+ if ((unsigned)(last.bits + here.bits) <= bits) break;
PULLBYTE();
}
DROPBITS(last.bits);
+ state->back += last.bits;
}
- DROPBITS(this.bits);
- state->length = (unsigned)this.val;
- if ((int)(this.op) == 0) {
- Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
+ DROPBITS(here.bits);
+ state->back += here.bits;
+ state->length = (unsigned)here.val;
+ if ((int)(here.op) == 0) {
+ Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
"inflate: literal '%c'\n" :
- "inflate: literal 0x%02x\n", this.val));
+ "inflate: literal 0x%02x\n", here.val));
state->mode = LIT;
break;
}
- if (this.op & 32) {
+ if (here.op & 32) {
Tracevv((stderr, "inflate: end of block\n"));
+ state->back = -1;
state->mode = TYPE;
break;
}
- if (this.op & 64) {
+ if (here.op & 64) {
strm->msg = (char *)"invalid literal/length code";
state->mode = BAD;
break;
}
- state->extra = (unsigned)(this.op) & 15;
+ state->extra = (unsigned)(here.op) & 15;
state->mode = LENEXT;
case LENEXT:
if (state->extra) {
NEEDBITS(state->extra);
state->length += BITS(state->extra);
DROPBITS(state->extra);
+ state->back += state->extra;
}
Tracevv((stderr, "inflate: length %u\n", state->length));
+ state->was = state->length;
state->mode = DIST;
case DIST:
for (;;) {
- this = state->distcode[BITS(state->distbits)];
- if ((unsigned)(this.bits) <= bits) break;
+ here = state->distcode[BITS(state->distbits)];
+ if ((unsigned)(here.bits) <= bits) break;
PULLBYTE();
}
- if ((this.op & 0xf0) == 0) {
- last = this;
+ if ((here.op & 0xf0) == 0) {
+ last = here;
for (;;) {
- this = state->distcode[last.val +
+ here = state->distcode[last.val +
(BITS(last.bits + last.op) >> last.bits)];
- if ((unsigned)(last.bits + this.bits) <= bits) break;
+ if ((unsigned)(last.bits + here.bits) <= bits) break;
PULLBYTE();
}
DROPBITS(last.bits);
+ state->back += last.bits;
}
- DROPBITS(this.bits);
- if (this.op & 64) {
+ DROPBITS(here.bits);
+ state->back += here.bits;
+ if (here.op & 64) {
strm->msg = (char *)"invalid distance code";
state->mode = BAD;
break;
}
- state->offset = (unsigned)this.val;
- state->extra = (unsigned)(this.op) & 15;
+ state->offset = (unsigned)here.val;
+ state->extra = (unsigned)(here.op) & 15;
state->mode = DISTEXT;
case DISTEXT:
if (state->extra) {
NEEDBITS(state->extra);
state->offset += BITS(state->extra);
DROPBITS(state->extra);
+ state->back += state->extra;
}
#ifdef INFLATE_STRICT
if (state->offset > state->dmax) {
@@ -1036,11 +1092,6 @@ int flush;
break;
}
#endif
- if (state->offset > state->whave + out - left) {
- strm->msg = (char *)"invalid distance too far back";
- state->mode = BAD;
- break;
- }
Tracevv((stderr, "inflate: distance %u\n", state->offset));
state->mode = MATCH;
case MATCH:
@@ -1048,12 +1099,32 @@ int flush;
copy = out - left;
if (state->offset > copy) { /* copy from window */
copy = state->offset - copy;
- if (copy > state->write) {
- copy -= state->write;
+ if (copy > state->whave) {
+ if (state->sane) {
+ strm->msg = (char *)"invalid distance too far back";
+ state->mode = BAD;
+ break;
+ }
+#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
+ Trace((stderr, "inflate.c too far\n"));
+ copy -= state->whave;
+ if (copy > state->length) copy = state->length;
+ if (copy > left) copy = left;
+ left -= copy;
+ state->length -= copy;
+ do {
+ *put++ = 0;
+ } while (--copy);
+ if (state->length == 0) state->mode = LEN;
+ break;
+#endif
+ }
+ if (copy > state->wnext) {
+ copy -= state->wnext;
from = state->window + (state->wsize - copy);
}
else
- from = state->window + (state->write - copy);
+ from = state->window + (state->wnext - copy);
if (copy > state->length) copy = state->length;
}
else { /* copy from output */
@@ -1146,14 +1217,14 @@ int flush;
strm->adler = state->check =
UPDATE(state->check, strm->next_out - out, out);
strm->data_type = state->bits + (state->last ? 64 : 0) +
- (state->mode == TYPE ? 128 : 0);
+ (state->mode == TYPE ? 128 : 0) +
+ (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);
if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
ret = Z_BUF_ERROR;
return ret;
}
-int ZEXPORT inflateEnd(strm)
-z_streamp strm;
+int ZEXPORT inflateEnd(z_streamp strm)
{
struct inflate_state FAR *state;
if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
@@ -1166,10 +1237,7 @@ z_streamp strm;
return Z_OK;
}
-int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength)
-z_streamp strm;
-const Bytef *dictionary;
-uInt dictLength;
+int ZEXPORT inflateSetDictionary(z_streamp strm, const Bytef *dictionary, uInt dictLength)
{
struct inflate_state FAR *state;
unsigned long id;
@@ -1208,9 +1276,7 @@ uInt dictLength;
return Z_OK;
}
-int ZEXPORT inflateGetHeader(strm, head)
-z_streamp strm;
-gz_headerp head;
+int ZEXPORT inflateGetHeader(z_streamp strm, gz_headerp head)
{
struct inflate_state FAR *state;
@@ -1236,10 +1302,7 @@ gz_headerp head;
called again with more data and the *have state. *have is initialized to
zero for the first call.
*/
-local unsigned syncsearch(have, buf, len)
-unsigned FAR *have;
-unsigned char FAR *buf;
-unsigned len;
+local unsigned syncsearch(unsigned FAR *have, unsigned char FAR *buf, unsigned len)
{
unsigned got;
unsigned next;
@@ -1259,8 +1322,7 @@ unsigned len;
return next;
}
-int ZEXPORT inflateSync(strm)
-z_streamp strm;
+int ZEXPORT inflateSync(z_streamp strm)
{
unsigned len; /* number of bytes to look at or looked at */
unsigned long in, out; /* temporary to save total_in and total_out */
@@ -1310,8 +1372,7 @@ z_streamp strm;
block. When decompressing, PPP checks that at the end of input packet,
inflate is waiting for these length bytes.
*/
-int ZEXPORT inflateSyncPoint(strm)
-z_streamp strm;
+int ZEXPORT inflateSyncPoint(z_streamp strm)
{
struct inflate_state FAR *state;
@@ -1320,9 +1381,7 @@ z_streamp strm;
return state->mode == STORED && state->bits == 0;
}
-int ZEXPORT inflateCopy(dest, source)
-z_streamp dest;
-z_streamp source;
+int ZEXPORT inflateCopy(z_streamp dest, z_streamp source)
{
struct inflate_state FAR *state;
struct inflate_state FAR *copy;
@@ -1366,3 +1425,33 @@ z_streamp source;
dest->state = (struct internal_state FAR *)copy;
return Z_OK;
}
+
+int ZEXPORT inflateUndermine(z_streamp strm, int subvert)
+{
+ struct inflate_state FAR *state;
+
+ if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ state = (struct inflate_state FAR *)strm->state;
+ state->sane = !subvert;
+#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
+ return Z_OK;
+#else
+ state->sane = 1;
+ return Z_DATA_ERROR;
+#endif
+}
+
+long ZEXPORT inflateMark(z_streamp strm)
+{
+ struct inflate_state FAR *state;
+
+ if (strm == Z_NULL || strm->state == Z_NULL) return -1L << 16;
+ state = (struct inflate_state FAR *)strm->state;
+ return ((long)(state->back) << 16) +
+ (state->mode == COPY ? state->length :
+ (state->mode == MATCH ? state->was - state->length : 0));
+}
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/zlib/inflate.h b/src/misc/zlib/inflate.h
index 07bd3e78..e58b5776 100644
--- a/src/misc/zlib/inflate.h
+++ b/src/misc/zlib/inflate.h
@@ -1,5 +1,5 @@
/* inflate.h -- internal inflate state definition
- * Copyright (C) 1995-2004 Mark Adler
+ * Copyright (C) 1995-2009 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -8,6 +8,8 @@
subject to change. Applications should only use zlib.h.
*/
+ABC_NAMESPACE_HEADER_START
+
/* define NO_GZIP when compiling if you want to disable gzip header and
trailer decoding by inflate(). NO_GZIP would be used to avoid linking in
the crc code when it is not needed. For shared libraries, gzip decoding
@@ -32,11 +34,13 @@ typedef enum {
TYPE, /* i: waiting for type bits, including last-flag bit */
TYPEDO, /* i: same, but skip check to exit inflate on new block */
STORED, /* i: waiting for stored size (length and complement) */
+ COPY_, /* i/o: same as COPY below, but only first time in */
COPY, /* i/o: waiting for input or output to copy stored block */
TABLE, /* i: waiting for dynamic block table lengths */
LENLENS, /* i: waiting for code length code lengths */
CODELENS, /* i: waiting for length/lit and distance code lengths */
- LEN, /* i: waiting for length/lit code */
+ LEN_, /* i: same as LEN below, but only first time in */
+ LEN, /* i: waiting for length/lit/eob code */
LENEXT, /* i: waiting for length extra bits */
DIST, /* i: waiting for distance code */
DISTEXT, /* i: waiting for distance extra bits */
@@ -53,19 +57,21 @@ typedef enum {
/*
State transitions between above modes -
- (most modes can go to the BAD or MEM mode -- not shown for clarity)
+ (most modes can go to BAD or MEM on error -- not shown for clarity)
Process header:
- HEAD -> (gzip) or (zlib)
- (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME
- NAME -> COMMENT -> HCRC -> TYPE
+ HEAD -> (gzip) or (zlib) or (raw)
+ (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME -> COMMENT ->
+ HCRC -> TYPE
(zlib) -> DICTID or TYPE
DICTID -> DICT -> TYPE
+ (raw) -> TYPEDO
Read deflate blocks:
- TYPE -> STORED or TABLE or LEN or CHECK
- STORED -> COPY -> TYPE
- TABLE -> LENLENS -> CODELENS -> LEN
- Read deflate codes:
+ TYPE -> TYPEDO -> STORED or TABLE or LEN_ or CHECK
+ STORED -> COPY_ -> COPY -> TYPE
+ TABLE -> LENLENS -> CODELENS -> LEN_
+ LEN_ -> LEN
+ Read deflate codes in fixed or dynamic block:
LEN -> LENEXT or LIT or TYPE
LENEXT -> DIST -> DISTEXT -> MATCH -> LEN
LIT -> LEN
@@ -73,7 +79,7 @@ typedef enum {
CHECK -> LENGTH -> DONE
*/
-/* state maintained between inflate() calls. Approximately 7K bytes. */
+/* state maintained between inflate() calls. Approximately 10K bytes. */
struct inflate_state {
inflate_mode mode; /* current inflate mode */
int last; /* true if processing last block */
@@ -88,7 +94,7 @@ struct inflate_state {
unsigned wbits; /* log base 2 of requested window size */
unsigned wsize; /* window size or zero if not using window */
unsigned whave; /* valid bytes in the window */
- unsigned write; /* window write index */
+ unsigned wnext; /* window write index */
unsigned char FAR *window; /* allocated sliding window, if needed */
/* bit accumulator */
unsigned long hold; /* input bit accumulator */
@@ -112,4 +118,9 @@ struct inflate_state {
unsigned short lens[320]; /* temporary storage for code lengths */
unsigned short work[288]; /* work area for code table building */
code codes[ENOUGH]; /* space for code tables */
+ int sane; /* if false, allow invalid distance too far */
+ int back; /* bits back of last unprocessed length/lit */
+ unsigned was; /* initial length of match */
};
+
+ABC_NAMESPACE_HEADER_END
diff --git a/src/misc/zlib/inftrees.c b/src/misc/zlib/inftrees.c
index 8a9c13ff..ad631f85 100644
--- a/src/misc/zlib/inftrees.c
+++ b/src/misc/zlib/inftrees.c
@@ -1,15 +1,22 @@
/* inftrees.c -- generate Huffman trees for efficient decoding
- * Copyright (C) 1995-2005 Mark Adler
+ * Copyright (C) 1995-2010 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "abc_global.h"
+
#include "zutil.h"
#include "inftrees.h"
+ABC_NAMESPACE_IMPL_START
+
#define MAXBITS 15
const char inflate_copyright[] =
- " inflate 1.2.3 Copyright 1995-2005 Mark Adler ";
+ " inflate 1.2.5 Copyright 1995-2010 Mark Adler ";
/*
If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot
@@ -29,13 +36,7 @@ const char inflate_copyright[] =
table index bits. It will differ if the request is greater than the
longest code or if it is less than the shortest code.
*/
-int inflate_table(type, lens, codes, table, bits, work)
-codetype type;
-unsigned short FAR *lens;
-unsigned codes;
-code FAR * FAR *table;
-unsigned FAR *bits;
-unsigned short FAR *work;
+int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens, unsigned codes, code FAR * FAR *table, unsigned FAR *bits, unsigned short FAR *work)
{
unsigned len; /* a code's length in bits */
unsigned sym; /* index of code symbols */
@@ -50,7 +51,7 @@ unsigned short FAR *work;
unsigned fill; /* index for replicating entries */
unsigned low; /* low bits for current root entry */
unsigned mask; /* mask for low root bits */
- code this; /* table entry for duplication */
+ code here; /* table entry for duplication */
code FAR *next; /* next available space in table */
const unsigned short FAR *base; /* base value table to use */
const unsigned short FAR *extra; /* extra bits table to use */
@@ -62,7 +63,7 @@ unsigned short FAR *work;
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
- 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 201, 196};
+ 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 73, 195};
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
@@ -115,15 +116,15 @@ unsigned short FAR *work;
if (count[max] != 0) break;
if (root > max) root = max;
if (max == 0) { /* no symbols to code at all */
- this.op = (unsigned char)64; /* invalid code marker */
- this.bits = (unsigned char)1;
- this.val = (unsigned short)0;
- *(*table)++ = this; /* make a table to force an error */
- *(*table)++ = this;
+ here.op = (unsigned char)64; /* invalid code marker */
+ here.bits = (unsigned char)1;
+ here.val = (unsigned short)0;
+ *(*table)++ = here; /* make a table to force an error */
+ *(*table)++ = here;
*bits = 1;
return 0; /* no symbols, but wait for decoding to report error */
}
- for (min = 1; min <= MAXBITS; min++)
+ for (min = 1; min < max; min++)
if (count[min] != 0) break;
if (root < min) root = min;
@@ -166,11 +167,10 @@ unsigned short FAR *work;
entered in the tables.
used keeps track of how many table entries have been allocated from the
- provided *table space. It is checked when a LENS table is being made
- against the space in *table, ENOUGH, minus the maximum space needed by
- the worst case distance code, MAXD. This should never happen, but the
- sufficiency of ENOUGH has not been proven exhaustively, hence the check.
- This assumes that when type == LENS, bits == 9.
+ provided *table space. It is checked for LENS and DIST tables against
+ the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in
+ the initial root table size constants. See the comments in inftrees.h
+ for more information.
sym increments through all symbols, and the loop terminates when
all codes of length max, i.e. all codes, have been processed. This
@@ -209,24 +209,25 @@ unsigned short FAR *work;
mask = used - 1; /* mask for comparing low */
/* check available table space */
- if (type == LENS && used >= ENOUGH - MAXD)
+ if ((type == LENS && used >= ENOUGH_LENS) ||
+ (type == DISTS && used >= ENOUGH_DISTS))
return 1;
/* process all codes and make table entries */
for (;;) {
/* create table entry */
- this.bits = (unsigned char)(len - drop);
+ here.bits = (unsigned char)(len - drop);
if ((int)(work[sym]) < end) {
- this.op = (unsigned char)0;
- this.val = work[sym];
+ here.op = (unsigned char)0;
+ here.val = work[sym];
}
else if ((int)(work[sym]) > end) {
- this.op = (unsigned char)(extra[work[sym]]);
- this.val = base[work[sym]];
+ here.op = (unsigned char)(extra[work[sym]]);
+ here.val = base[work[sym]];
}
else {
- this.op = (unsigned char)(32 + 64); /* end of block */
- this.val = 0;
+ here.op = (unsigned char)(32 + 64); /* end of block */
+ here.val = 0;
}
/* replicate for those indices with low len bits equal to huff */
@@ -235,7 +236,7 @@ unsigned short FAR *work;
min = fill; /* save offset to next table */
do {
fill -= incr;
- next[(huff >> drop) + fill] = this;
+ next[(huff >> drop) + fill] = here;
} while (fill != 0);
/* backwards increment the len-bit code huff */
@@ -277,7 +278,8 @@ unsigned short FAR *work;
/* check for enough space */
used += 1U << curr;
- if (type == LENS && used >= ENOUGH - MAXD)
+ if ((type == LENS && used >= ENOUGH_LENS) ||
+ (type == DISTS && used >= ENOUGH_DISTS))
return 1;
/* point entry in root table to sub-table */
@@ -295,20 +297,20 @@ unsigned short FAR *work;
through high index bits. When the current sub-table is filled, the loop
drops back to the root table to fill in any remaining entries there.
*/
- this.op = (unsigned char)64; /* invalid code marker */
- this.bits = (unsigned char)(len - drop);
- this.val = (unsigned short)0;
+ here.op = (unsigned char)64; /* invalid code marker */
+ here.bits = (unsigned char)(len - drop);
+ here.val = (unsigned short)0;
while (huff != 0) {
/* when done with sub-table, drop back to root table */
if (drop != 0 && (huff & mask) != low) {
drop = 0;
len = root;
next = *table;
- this.bits = (unsigned char)len;
+ here.bits = (unsigned char)len;
}
/* put invalid code marker in table */
- next[huff >> drop] = this;
+ next[huff >> drop] = here;
/* backwards increment the len-bit code huff */
incr = 1U << (len - 1);
@@ -327,3 +329,9 @@ unsigned short FAR *work;
*bits = root;
return 0;
}
+
+
+
+ABC_NAMESPACE_IMPL_END
+
+
diff --git a/src/misc/zlib/inftrees.h b/src/misc/zlib/inftrees.h
index b1104c87..8aed8857 100644
--- a/src/misc/zlib/inftrees.h
+++ b/src/misc/zlib/inftrees.h
@@ -1,5 +1,5 @@
/* inftrees.h -- header to use inftrees.c
- * Copyright (C) 1995-2005 Mark Adler
+ * Copyright (C) 1995-2005, 2010 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -8,6 +8,8 @@
subject to change. Applications should only use zlib.h.
*/
+ABC_NAMESPACE_HEADER_START
+
/* Structure for decoding tables. Each entry provides either the
information needed to do the operation requested by the code that
indexed that table entry, or it provides a pointer to another
@@ -35,21 +37,30 @@ typedef struct {
01000000 - invalid code
*/
-/* Maximum size of dynamic tree. The maximum found in a long but non-
- exhaustive search was 1444 code structures (852 for length/literals
- and 592 for distances, the latter actually the result of an
- exhaustive search). The true maximum is not known, but the value
- below is more than safe. */
-#define ENOUGH 2048
-#define MAXD 592
+/* Maximum size of the dynamic table. The maximum number of code structures is
+ 1444, which is the sum of 852 for literal/length codes and 592 for distance
+ codes. These values were found by exhaustive searches using the program
+ examples/enough.c found in the zlib distribtution. The arguments to that
+ program are the number of symbols, the initial root table size, and the
+ maximum bit length of a code. "enough 286 9 15" for literal/length codes
+ returns returns 852, and "enough 30 6 15" for distance codes returns 592.
+ The initial root table size (9 or 6) is found in the fifth argument of the
+ inflate_table() calls in inflate.c and infback.c. If the root table size is
+ changed, then these maximum sizes would be need to be recalculated and
+ updated. */
+#define ENOUGH_LENS 852
+#define ENOUGH_DISTS 592
+#define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS)
-/* Type of code to build for inftable() */
+/* Type of code to build for inflate_table() */
typedef enum {
CODES,
LENS,
DISTS
} codetype;
-extern int inflate_table OF((codetype type, unsigned short FAR *lens,
+int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens,
unsigned codes, code FAR * FAR *table,
unsigned FAR *bits, unsigned short FAR *work));
+
+ABC_NAMESPACE_HEADER_END
diff --git a/src/misc/zlib/link.txt b/src/misc/zlib/link.txt
index c96e37cc..d2961a9f 100644
--- a/src/misc/zlib/link.txt
+++ b/src/misc/zlib/link.txt
@@ -1 +1 @@
-http://www.winimage.com/zLibDll/
+http://www.zlib.net/
diff --git a/src/misc/zlib/module.make b/src/misc/zlib/module.make
index 067acbaa..8b518437 100644
--- a/src/misc/zlib/module.make
+++ b/src/misc/zlib/module.make
@@ -2,7 +2,10 @@ SRC += src/misc/zlib/adler32.c \
src/misc/zlib/compress_.c \
src/misc/zlib/crc32.c \
src/misc/zlib/deflate.c \
- src/misc/zlib/gzio.c \
+ src/misc/zlib/gzclose.c \
+ src/misc/zlib/gzlib.c \
+ src/misc/zlib/gzread.c \
+ src/misc/zlib/gzwrite.c \
src/misc/zlib/infback.c \
src/misc/zlib/inffast.c \
src/misc/zlib/inflate.c \
diff --git a/src/misc/zlib/trees.c b/src/misc/zlib/trees.c
index 395e4e16..e107ba04 100644
--- a/src/misc/zlib/trees.c
+++ b/src/misc/zlib/trees.c
@@ -1,5 +1,6 @@
/* trees.c -- output deflated data using Huffman coding
- * Copyright (C) 1995-2005 Jean-loup Gailly
+ * Copyright (C) 1995-2010 Jean-loup Gailly
+ * detect_data_type() function provided freely by Cosmin Truta, 2006
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -33,12 +34,19 @@
/* #define GEN_TREES_H */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "abc_global.h"
+
#include "deflate.h"
#ifdef DEBUG
# include <ctype.h>
#endif
+ABC_NAMESPACE_IMPL_START
+
/* ===========================================================================
* Constants
*/
@@ -115,7 +123,9 @@ local int base_dist[D_CODES];
/* First normalized distance for each code (0 = distance of 1) */
#else
+ABC_NAMESPACE_IMPL_END
# include "trees.h"
+ABC_NAMESPACE_IMPL_START
#endif /* GEN_TREES_H */
struct static_tree_desc_s {
@@ -152,7 +162,7 @@ local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes,
int blcodes));
local void compress_block OF((deflate_state *s, ct_data *ltree,
ct_data *dtree));
-local void set_data_type OF((deflate_state *s));
+local int detect_data_type OF((deflate_state *s));
local unsigned bi_reverse OF((unsigned value, int length));
local void bi_windup OF((deflate_state *s));
local void bi_flush OF((deflate_state *s));
@@ -189,10 +199,7 @@ local void gen_trees_header OF((void));
#ifdef DEBUG
local void send_bits OF((deflate_state *s, int value, int length));
-local void send_bits(s, value, length)
- deflate_state *s;
- int value; /* value to send */
- int length; /* number of bits */
+local void send_bits(deflate_state *s, int value, int length)
{
Tracevv((stderr," l %2d v %4x ", length, value));
Assert(length > 0 && length <= 15, "invalid length");
@@ -203,12 +210,12 @@ local void send_bits(s, value, length)
* unused bits in value.
*/
if (s->bi_valid > (int)Buf_size - length) {
- s->bi_buf |= (value << s->bi_valid);
+ s->bi_buf |= (ush)value << s->bi_valid;
put_short(s, s->bi_buf);
s->bi_buf = (ush)value >> (Buf_size - s->bi_valid);
s->bi_valid += length - Buf_size;
} else {
- s->bi_buf |= value << s->bi_valid;
+ s->bi_buf |= (ush)value << s->bi_valid;
s->bi_valid += length;
}
}
@@ -218,12 +225,12 @@ local void send_bits(s, value, length)
{ int len = length;\
if (s->bi_valid > (int)Buf_size - len) {\
int val = value;\
- s->bi_buf |= (val << s->bi_valid);\
+ s->bi_buf |= (ush)val << s->bi_valid;\
put_short(s, s->bi_buf);\
s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\
s->bi_valid += len - Buf_size;\
} else {\
- s->bi_buf |= (value) << s->bi_valid;\
+ s->bi_buf |= (ush)(value) << s->bi_valid;\
s->bi_valid += len;\
}\
}
@@ -250,11 +257,13 @@ local void tr_static_init()
if (static_init_done) return;
/* For some embedded targets, global variables are not initialized: */
+#ifdef NO_INIT_GLOBAL_POINTERS
static_l_desc.static_tree = static_ltree;
static_l_desc.extra_bits = extra_lbits;
static_d_desc.static_tree = static_dtree;
static_d_desc.extra_bits = extra_dbits;
static_bl_desc.extra_bits = extra_blbits;
+#endif
/* Initialize the mapping length (0..255) -> length code (0..28) */
length = 0;
@@ -320,7 +329,9 @@ local void tr_static_init()
*/
#ifdef GEN_TREES_H
# ifndef DEBUG
+ABC_NAMESPACE_IMPL_END
# include <stdio.h>
+ABC_NAMESPACE_IMPL_START
# endif
# define SEPARATOR(i, last, width) \
@@ -348,13 +359,14 @@ void gen_trees_header()
static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5));
}
- fprintf(header, "const uch _dist_code[DIST_CODE_LEN] = {\n");
+ fprintf(header, "const uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = {\n");
for (i = 0; i < DIST_CODE_LEN; i++) {
fprintf(header, "%2u%s", _dist_code[i],
SEPARATOR(i, DIST_CODE_LEN-1, 20));
}
- fprintf(header, "const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {\n");
+ fprintf(header,
+ "const uch ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= {\n");
for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) {
fprintf(header, "%2u%s", _length_code[i],
SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20));
@@ -379,8 +391,7 @@ void gen_trees_header()
/* ===========================================================================
* Initialize the tree data structures for a new zlib stream.
*/
-void _tr_init(s)
- deflate_state *s;
+void ZLIB_INTERNAL _tr_init(deflate_state *s)
{
tr_static_init();
@@ -408,8 +419,7 @@ void _tr_init(s)
/* ===========================================================================
* Initialize a new block.
*/
-local void init_block(s)
- deflate_state *s;
+local void init_block(deflate_state *s)
{
int n; /* iterates over tree elements */
@@ -452,10 +462,7 @@ local void init_block(s)
* when the heap property is re-established (each father smaller than its
* two sons).
*/
-local void pqdownheap(s, tree, k)
- deflate_state *s;
- ct_data *tree; /* the tree to restore */
- int k; /* node to move down */
+local void pqdownheap(deflate_state *s, ct_data *tree, int k)
{
int v = s->heap[k];
int j = k << 1; /* left son of k */
@@ -487,9 +494,7 @@ local void pqdownheap(s, tree, k)
* The length opt_len is updated; static_len is also updated if stree is
* not null.
*/
-local void gen_bitlen(s, desc)
- deflate_state *s;
- tree_desc *desc; /* the tree descriptor */
+local void gen_bitlen(deflate_state *s, tree_desc *desc)
{
ct_data *tree = desc->dyn_tree;
int max_code = desc->max_code;
@@ -574,10 +579,10 @@ local void gen_bitlen(s, desc)
* OUT assertion: the field code is set for all tree elements of non
* zero code length.
*/
-local void gen_codes (tree, max_code, bl_count)
- ct_data *tree; /* the tree to decorate */
- int max_code; /* largest code with non zero frequency */
- ushf *bl_count; /* number of codes at each bit length */
+local void gen_codes (ct_data *tree, int max_code, ushf *bl_count)
+ /* the tree to decorate */
+ /* largest code with non zero frequency */
+ /* number of codes at each bit length */
{
ush next_code[MAX_BITS+1]; /* next code value for each bit length */
ush code = 0; /* running code value */
@@ -616,9 +621,7 @@ local void gen_codes (tree, max_code, bl_count)
* and corresponding code. The length opt_len is updated; static_len is
* also updated if stree is not null. The field max_code is set.
*/
-local void build_tree(s, desc)
- deflate_state *s;
- tree_desc *desc; /* the tree descriptor */
+local void build_tree(deflate_state *s, tree_desc *desc)
{
ct_data *tree = desc->dyn_tree;
const ct_data *stree = desc->stat_desc->static_tree;
@@ -704,10 +707,7 @@ local void build_tree(s, desc)
* Scan a literal or distance tree to determine the frequencies of the codes
* in the bit length tree.
*/
-local void scan_tree (s, tree, max_code)
- deflate_state *s;
- ct_data *tree; /* the tree to be scanned */
- int max_code; /* and its largest code of non zero frequency */
+local void scan_tree (deflate_state *s, ct_data *tree, int max_code)
{
int n; /* iterates over all tree elements */
int prevlen = -1; /* last emitted length */
@@ -749,10 +749,7 @@ local void scan_tree (s, tree, max_code)
* Send a literal or distance tree in compressed form, using the codes in
* bl_tree.
*/
-local void send_tree (s, tree, max_code)
- deflate_state *s;
- ct_data *tree; /* the tree to be scanned */
- int max_code; /* and its largest code of non zero frequency */
+local void send_tree (deflate_state *s, ct_data *tree, int max_code)
{
int n; /* iterates over all tree elements */
int prevlen = -1; /* last emitted length */
@@ -800,8 +797,7 @@ local void send_tree (s, tree, max_code)
* Construct the Huffman tree for the bit lengths and return the index in
* bl_order of the last bit length code to send.
*/
-local int build_bl_tree(s)
- deflate_state *s;
+local int build_bl_tree(deflate_state *s)
{
int max_blindex; /* index of last bit length code of non zero freq */
@@ -835,9 +831,7 @@ local int build_bl_tree(s)
* lengths of the bit length codes, the literal tree and the distance tree.
* IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.
*/
-local void send_all_trees(s, lcodes, dcodes, blcodes)
- deflate_state *s;
- int lcodes, dcodes, blcodes; /* number of codes for each tree */
+local void send_all_trees(deflate_state *s, int lcodes, int dcodes, int blcodes)
{
int rank; /* index in bl_order */
@@ -864,13 +858,9 @@ local void send_all_trees(s, lcodes, dcodes, blcodes)
/* ===========================================================================
* Send a stored block
*/
-void _tr_stored_block(s, buf, stored_len, eof)
- deflate_state *s;
- charf *buf; /* input block */
- ulg stored_len; /* length of input block */
- int eof; /* true if this is the last block for a file */
+void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf, ulg stored_len, int last)
{
- send_bits(s, (STORED_BLOCK<<1)+eof, 3); /* send block type */
+ send_bits(s, (STORED_BLOCK<<1)+last, 3); /* send block type */
#ifdef DEBUG
s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L;
s->compressed_len += (stored_len + 4) << 3;
@@ -889,8 +879,7 @@ void _tr_stored_block(s, buf, stored_len, eof)
* To simplify the code, we assume the worst case of last real code encoded
* on one bit only.
*/
-void _tr_align(s)
- deflate_state *s;
+void ZLIB_INTERNAL _tr_align(deflate_state *s)
{
send_bits(s, STATIC_TREES<<1, 3);
send_code(s, END_BLOCK, static_ltree);
@@ -918,11 +907,7 @@ void _tr_align(s)
* Determine the best encoding for the current block: dynamic trees, static
* trees or store, and output the encoded block to the zip file.
*/
-void _tr_flush_block(s, buf, stored_len, eof)
- deflate_state *s;
- charf *buf; /* input block, or NULL if too old */
- ulg stored_len; /* length of input block */
- int eof; /* true if this is the last block for a file */
+void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, charf *buf, ulg stored_len, int last)
{
ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */
int max_blindex = 0; /* index of last bit length code of non zero freq */
@@ -931,8 +916,8 @@ void _tr_flush_block(s, buf, stored_len, eof)
if (s->level > 0) {
/* Check if the file is binary or text */
- if (stored_len > 0 && s->strm->data_type == Z_UNKNOWN)
- set_data_type(s);
+ if (s->strm->data_type == Z_UNKNOWN)
+ s->strm->data_type = detect_data_type(s);
/* Construct the literal and distance trees */
build_tree(s, (tree_desc *)(&(s->l_desc)));
@@ -978,20 +963,20 @@ void _tr_flush_block(s, buf, stored_len, eof)
* successful. If LIT_BUFSIZE <= WSIZE, it is never too late to
* transform a block into a stored block.
*/
- _tr_stored_block(s, buf, stored_len, eof);
+ _tr_stored_block(s, buf, stored_len, last);
#ifdef FORCE_STATIC
} else if (static_lenb >= 0) { /* force static trees */
#else
} else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) {
#endif
- send_bits(s, (STATIC_TREES<<1)+eof, 3);
+ send_bits(s, (STATIC_TREES<<1)+last, 3);
compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree);
#ifdef DEBUG
s->compressed_len += 3 + s->static_len;
#endif
} else {
- send_bits(s, (DYN_TREES<<1)+eof, 3);
+ send_bits(s, (DYN_TREES<<1)+last, 3);
send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1,
max_blindex+1);
compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree);
@@ -1005,24 +990,21 @@ void _tr_flush_block(s, buf, stored_len, eof)
*/
init_block(s);
- if (eof) {
+ if (last) {
bi_windup(s);
#ifdef DEBUG
s->compressed_len += 7; /* align on byte boundary */
#endif
}
Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3,
- s->compressed_len-7*eof));
+ s->compressed_len-7*last));
}
/* ===========================================================================
* Save the match info and tally the frequency counts. Return true if
* the current block must be flushed.
*/
-int _tr_tally (s, dist, lc)
- deflate_state *s;
- unsigned dist; /* distance of matched string */
- unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */
+int ZLIB_INTERNAL _tr_tally (deflate_state *s, unsigned dist, unsigned lc)
{
s->d_buf[s->last_lit] = (ush)dist;
s->l_buf[s->last_lit++] = (uch)lc;
@@ -1069,10 +1051,7 @@ int _tr_tally (s, dist, lc)
/* ===========================================================================
* Send the block data compressed using the given Huffman trees
*/
-local void compress_block(s, ltree, dtree)
- deflate_state *s;
- ct_data *ltree; /* literal tree */
- ct_data *dtree; /* distance tree */
+local void compress_block(deflate_state *s, ct_data *ltree, ct_data *dtree)
{
unsigned dist; /* distance of matched string */
int lc; /* match length or unmatched char (if dist == 0) */
@@ -1118,24 +1097,44 @@ local void compress_block(s, ltree, dtree)
}
/* ===========================================================================
- * Set the data type to BINARY or TEXT, using a crude approximation:
- * set it to Z_TEXT if all symbols are either printable characters (33 to 255)
- * or white spaces (9 to 13, or 32); or set it to Z_BINARY otherwise.
+ * Check if the data type is TEXT or BINARY, using the following algorithm:
+ * - TEXT if the two conditions below are satisfied:
+ * a) There are no non-portable control characters belonging to the
+ * "black list" (0..6, 14..25, 28..31).
+ * b) There is at least one printable character belonging to the
+ * "white list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255).
+ * - BINARY otherwise.
+ * - The following partially-portable control characters form a
+ * "gray list" that is ignored in this detection algorithm:
+ * (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}).
* IN assertion: the fields Freq of dyn_ltree are set.
*/
-local void set_data_type(s)
- deflate_state *s;
+local int detect_data_type(deflate_state *s)
{
+ /* black_mask is the bit mask of black-listed bytes
+ * set bits 0..6, 14..25, and 28..31
+ * 0xf3ffc07f = binary 11110011111111111100000001111111
+ */
+ unsigned long black_mask = 0xf3ffc07fUL;
int n;
- for (n = 0; n < 9; n++)
+ /* Check for non-textual ("black-listed") bytes. */
+ for (n = 0; n <= 31; n++, black_mask >>= 1)
+ if ((black_mask & 1) && (s->dyn_ltree[n].Freq != 0))
+ return Z_BINARY;
+
+ /* Check for textual ("white-listed") bytes. */
+ if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0
+ || s->dyn_ltree[13].Freq != 0)
+ return Z_TEXT;
+ for (n = 32; n < LITERALS; n++)
if (s->dyn_ltree[n].Freq != 0)
- break;
- if (n == 9)
- for (n = 14; n < 32; n++)
- if (s->dyn_ltree[n].Freq != 0)
- break;
- s->strm->data_type = (n == 32) ? Z_TEXT : Z_BINARY;
+ return Z_TEXT;
+
+ /* There are no "black-listed" or "white-listed" bytes:
+ * this stream either is empty or has tolerated ("gray-listed") bytes only.
+ */
+ return Z_BINARY;
}
/* ===========================================================================
@@ -1143,9 +1142,7 @@ local void set_data_type(s)
* method would use a table)
* IN assertion: 1 <= len <= 15
*/
-local unsigned bi_reverse(code, len)
- unsigned code; /* the value to invert */
- int len; /* its bit length */
+local unsigned bi_reverse(unsigned code, int len)
{
register unsigned res = 0;
do {
@@ -1158,8 +1155,7 @@ local unsigned bi_reverse(code, len)
/* ===========================================================================
* Flush the bit buffer, keeping at most 7 bits in it.
*/
-local void bi_flush(s)
- deflate_state *s;
+local void bi_flush(deflate_state *s)
{
if (s->bi_valid == 16) {
put_short(s, s->bi_buf);
@@ -1175,8 +1171,7 @@ local void bi_flush(s)
/* ===========================================================================
* Flush the bit buffer and align the output on a byte boundary
*/
-local void bi_windup(s)
- deflate_state *s;
+local void bi_windup(deflate_state *s)
{
if (s->bi_valid > 8) {
put_short(s, s->bi_buf);
@@ -1194,11 +1189,7 @@ local void bi_windup(s)
* Copy a stored block, storing first the length and its
* one's complement if requested.
*/
-local void copy_block(s, buf, len, header)
- deflate_state *s;
- charf *buf; /* the input data */
- unsigned len; /* its length */
- int header; /* true if block header must be written */
+local void copy_block(deflate_state *s, charf *buf, unsigned len, int header)
{
bi_windup(s); /* align on byte boundary */
s->last_eob_len = 8; /* enough lookahead for inflate */
@@ -1217,3 +1208,9 @@ local void copy_block(s, buf, len, header)
put_byte(s, *buf++);
}
}
+
+
+
+ABC_NAMESPACE_IMPL_END
+
+
diff --git a/src/misc/zlib/trees.h b/src/misc/zlib/trees.h
index 72facf90..8629d66e 100644
--- a/src/misc/zlib/trees.h
+++ b/src/misc/zlib/trees.h
@@ -1,5 +1,7 @@
/* header created automatically with -DGEN_TREES_H */
+ABC_NAMESPACE_HEADER_START
+
local const ct_data static_ltree[L_CODES+2] = {
{{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}},
{{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}},
@@ -70,7 +72,7 @@ local const ct_data static_dtree[D_CODES] = {
{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}}
};
-const uch _dist_code[DIST_CODE_LEN] = {
+const uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = {
0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8,
8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
@@ -99,7 +101,7 @@ const uch _dist_code[DIST_CODE_LEN] = {
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29
};
-const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {
+const uch ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= {
0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12,
13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16,
17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19,
@@ -126,3 +128,5 @@ local const int base_dist[D_CODES] = {
1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576
};
+ABC_NAMESPACE_HEADER_END
+
diff --git a/src/misc/zlib/uncompr.c b/src/misc/zlib/uncompr.c
index b59e3d0d..e195ec3e 100644
--- a/src/misc/zlib/uncompr.c
+++ b/src/misc/zlib/uncompr.c
@@ -1,13 +1,20 @@
/* uncompr.c -- decompress a memory buffer
- * Copyright (C) 1995-2003 Jean-loup Gailly.
+ * Copyright (C) 1995-2003, 2010 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* @(#) $Id$ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "abc_global.h"
+
#define ZLIB_INTERNAL
#include "zlib.h"
+ABC_NAMESPACE_IMPL_START
+
/* ===========================================================================
Decompresses the source buffer into the destination buffer. sourceLen is
the byte length of the source buffer. Upon entry, destLen is the total
@@ -16,18 +23,12 @@
been saved previously by the compressor and transmitted to the decompressor
by some mechanism outside the scope of this compression library.)
Upon exit, destLen is the actual size of the compressed buffer.
- This function can be used to decompress a whole file at once if the
- input file is mmap'ed.
uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
enough memory, Z_BUF_ERROR if there was not enough room in the output
buffer, or Z_DATA_ERROR if the input data was corrupted.
*/
-int ZEXPORT uncompress (dest, destLen, source, sourceLen)
- Bytef *dest;
- uLongf *destLen;
- const Bytef *source;
- uLong sourceLen;
+int ZEXPORT uncompress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)
{
z_stream stream;
int err;
@@ -59,3 +60,8 @@ int ZEXPORT uncompress (dest, destLen, source, sourceLen)
err = inflateEnd(&stream);
return err;
}
+
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/zlib/zconf.h b/src/misc/zlib/zconf.h
index 03a9431c..30a013b7 100644
--- a/src/misc/zlib/zconf.h
+++ b/src/misc/zlib/zconf.h
@@ -1,5 +1,5 @@
/* zconf.h -- configuration of the zlib compression library
- * Copyright (C) 1995-2005 Jean-loup Gailly.
+ * Copyright (C) 1995-2010 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -11,52 +11,124 @@
/*
* If you *really* need a unique prefix for all types and library functions,
* compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
+ * Even better than compiling with -DZ_PREFIX would be to use configure to set
+ * this permanently in zconf.h using "./configure --zprefix".
*/
-#ifdef Z_PREFIX
-# define deflateInit_ z_deflateInit_
+#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */
+
+/* all linked symbols */
+# define _dist_code z__dist_code
+# define _length_code z__length_code
+# define _tr_align z__tr_align
+# define _tr_flush_block z__tr_flush_block
+# define _tr_init z__tr_init
+# define _tr_stored_block z__tr_stored_block
+# define _tr_tally z__tr_tally
+# define adler32 z_adler32
+# define adler32_combine z_adler32_combine
+# define adler32_combine64 z_adler32_combine64
+# define compress z_compress
+# define compress2 z_compress2
+# define compressBound z_compressBound
+# define crc32 z_crc32
+# define crc32_combine z_crc32_combine
+# define crc32_combine64 z_crc32_combine64
# define deflate z_deflate
+# define deflateBound z_deflateBound
+# define deflateCopy z_deflateCopy
# define deflateEnd z_deflateEnd
-# define inflateInit_ z_inflateInit_
-# define inflate z_inflate
-# define inflateEnd z_inflateEnd
# define deflateInit2_ z_deflateInit2_
-# define deflateSetDictionary z_deflateSetDictionary
-# define deflateCopy z_deflateCopy
-# define deflateReset z_deflateReset
+# define deflateInit_ z_deflateInit_
# define deflateParams z_deflateParams
-# define deflateBound z_deflateBound
# define deflatePrime z_deflatePrime
+# define deflateReset z_deflateReset
+# define deflateSetDictionary z_deflateSetDictionary
+# define deflateSetHeader z_deflateSetHeader
+# define deflateTune z_deflateTune
+# define deflate_copyright z_deflate_copyright
+# define get_crc_table z_get_crc_table
+# define gz_error z_gz_error
+# define gz_intmax z_gz_intmax
+# define gz_strwinerror z_gz_strwinerror
+# define gzbuffer z_gzbuffer
+# define gzclearerr z_gzclearerr
+# define gzclose z_gzclose
+# define gzclose_r z_gzclose_r
+# define gzclose_w z_gzclose_w
+# define gzdirect z_gzdirect
+# define gzdopen z_gzdopen
+# define gzeof z_gzeof
+# define gzerror z_gzerror
+# define gzflush z_gzflush
+# define gzgetc z_gzgetc
+# define gzgets z_gzgets
+# define gzoffset z_gzoffset
+# define gzoffset64 z_gzoffset64
+# define gzopen z_gzopen
+# define gzopen64 z_gzopen64
+# define gzprintf z_gzprintf
+# define gzputc z_gzputc
+# define gzputs z_gzputs
+# define gzread z_gzread
+# define gzrewind z_gzrewind
+# define gzseek z_gzseek
+# define gzseek64 z_gzseek64
+# define gzsetparams z_gzsetparams
+# define gztell z_gztell
+# define gztell64 z_gztell64
+# define gzungetc z_gzungetc
+# define gzwrite z_gzwrite
+# define inflate z_inflate
+# define inflateBack z_inflateBack
+# define inflateBackEnd z_inflateBackEnd
+# define inflateBackInit_ z_inflateBackInit_
+# define inflateCopy z_inflateCopy
+# define inflateEnd z_inflateEnd
+# define inflateGetHeader z_inflateGetHeader
# define inflateInit2_ z_inflateInit2_
+# define inflateInit_ z_inflateInit_
+# define inflateMark z_inflateMark
+# define inflatePrime z_inflatePrime
+# define inflateReset z_inflateReset
+# define inflateReset2 z_inflateReset2
# define inflateSetDictionary z_inflateSetDictionary
# define inflateSync z_inflateSync
# define inflateSyncPoint z_inflateSyncPoint
-# define inflateCopy z_inflateCopy
-# define inflateReset z_inflateReset
-# define inflateBack z_inflateBack
-# define inflateBackEnd z_inflateBackEnd
-# define compress z_compress
-# define compress2 z_compress2
-# define compressBound z_compressBound
+# define inflateUndermine z_inflateUndermine
+# define inflate_copyright z_inflate_copyright
+# define inflate_fast z_inflate_fast
+# define inflate_table z_inflate_table
# define uncompress z_uncompress
-# define adler32 z_adler32
-# define crc32 z_crc32
-# define get_crc_table z_get_crc_table
# define zError z_zError
+# define zcalloc z_zcalloc
+# define zcfree z_zcfree
+# define zlibCompileFlags z_zlibCompileFlags
+# define zlibVersion z_zlibVersion
+/* all zlib typedefs in zlib.h and zconf.h */
+# define Byte z_Byte
+# define Bytef z_Bytef
# define alloc_func z_alloc_func
+# define charf z_charf
# define free_func z_free_func
+# define gzFile z_gzFile
+# define gz_header z_gz_header
+# define gz_headerp z_gz_headerp
# define in_func z_in_func
+# define intf z_intf
# define out_func z_out_func
-# define Byte z_Byte
# define uInt z_uInt
-# define uLong z_uLong
-# define Bytef z_Bytef
-# define charf z_charf
-# define intf z_intf
# define uIntf z_uIntf
+# define uLong z_uLong
# define uLongf z_uLongf
-# define voidpf z_voidpf
# define voidp z_voidp
+# define voidpc z_voidpc
+# define voidpf z_voidpf
+
+/* all zlib structs in zlib.h and zconf.h */
+# define gz_header_s z_gz_header_s
+# define internal_state z_internal_state
+
#endif
#if defined(__MSDOS__) && !defined(MSDOS)
@@ -284,49 +356,77 @@ typedef uLong FAR uLongf;
typedef Byte *voidp;
#endif
-#if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */
-# include <sys/types.h> /* for off_t */
-# include <unistd.h> /* for SEEK_* and off_t */
+#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */
+# define Z_HAVE_UNISTD_H
+#endif
+
+#ifdef STDC
+# include <sys/types.h> /* for off_t */
+#endif
+
+/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
+ * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
+ * though the former does not conform to the LFS document), but considering
+ * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
+ * equivalently requesting no 64-bit operations
+ */
+#if -_LARGEFILE64_SOURCE - -1 == 1
+# undef _LARGEFILE64_SOURCE
+#endif
+
+#if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
+# include <unistd.h> /* for SEEK_* and off_t */
# ifdef VMS
-# include <unixio.h> /* for off_t */
+# include <unixio.h> /* for off_t */
+# endif
+# ifndef z_off_t
+# define z_off_t off_t
# endif
-# define z_off_t off_t
#endif
+
+ABC_NAMESPACE_HEADER_START
+
#ifndef SEEK_SET
# define SEEK_SET 0 /* Seek from beginning of file. */
# define SEEK_CUR 1 /* Seek from current position. */
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
#endif
+
#ifndef z_off_t
# define z_off_t long
#endif
+#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
+# define z_off64_t off64_t
+#else
+# define z_off64_t z_off_t
+#endif
+
#if defined(__OS400__)
# define NO_vsnprintf
#endif
#if defined(__MVS__)
# define NO_vsnprintf
-# ifdef FAR
-# undef FAR
-# endif
#endif
/* MVS linker does not support external names larger than 8 bytes */
#if defined(__MVS__)
-# pragma map(deflateInit_,"DEIN")
-# pragma map(deflateInit2_,"DEIN2")
-# pragma map(deflateEnd,"DEEND")
-# pragma map(deflateBound,"DEBND")
-# pragma map(inflateInit_,"ININ")
-# pragma map(inflateInit2_,"ININ2")
-# pragma map(inflateEnd,"INEND")
-# pragma map(inflateSync,"INSY")
-# pragma map(inflateSetDictionary,"INSEDI")
-# pragma map(compressBound,"CMBND")
-# pragma map(inflate_table,"INTABL")
-# pragma map(inflate_fast,"INFA")
-# pragma map(inflate_copyright,"INCOPY")
+ #pragma map(deflateInit_,"DEIN")
+ #pragma map(deflateInit2_,"DEIN2")
+ #pragma map(deflateEnd,"DEEND")
+ #pragma map(deflateBound,"DEBND")
+ #pragma map(inflateInit_,"ININ")
+ #pragma map(inflateInit2_,"ININ2")
+ #pragma map(inflateEnd,"INEND")
+ #pragma map(inflateSync,"INSY")
+ #pragma map(inflateSetDictionary,"INSEDI")
+ #pragma map(compressBound,"CMBND")
+ #pragma map(inflate_table,"INTABL")
+ #pragma map(inflate_fast,"INFA")
+ #pragma map(inflate_copyright,"INCOPY")
#endif
+ABC_NAMESPACE_HEADER_END
+
#endif /* ZCONF_H */
diff --git a/src/misc/zlib/zlib.h b/src/misc/zlib/zlib.h
index 02281792..58ff1d15 100644
--- a/src/misc/zlib/zlib.h
+++ b/src/misc/zlib/zlib.h
@@ -1,7 +1,7 @@
/* zlib.h -- interface of the 'zlib' general purpose compression library
- version 1.2.3, July 18th, 2005
+ version 1.2.5, April 19th, 2010
- Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler
+ Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -31,47 +31,51 @@
#ifndef ZLIB_H
#define ZLIB_H
+#include <stdio.h>
+#include "abc_global.h"
+
#include "zconf.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
+ABC_NAMESPACE_HEADER_START
-#define ZLIB_VERSION "1.2.3"
-#define ZLIB_VERNUM 0x1230
+#define ZLIB_VERSION "1.2.5"
+#define ZLIB_VERNUM 0x1250
+#define ZLIB_VER_MAJOR 1
+#define ZLIB_VER_MINOR 2
+#define ZLIB_VER_REVISION 5
+#define ZLIB_VER_SUBREVISION 0
/*
- The 'zlib' compression library provides in-memory compression and
- decompression functions, including integrity checks of the uncompressed
- data. This version of the library supports only one compression method
- (deflation) but other algorithms will be added later and will have the same
- stream interface.
-
- Compression can be done in a single step if the buffers are large
- enough (for example if an input file is mmap'ed), or can be done by
- repeated calls of the compression function. In the latter case, the
- application must provide more input and/or consume the output
+ The 'zlib' compression library provides in-memory compression and
+ decompression functions, including integrity checks of the uncompressed data.
+ This version of the library supports only one compression method (deflation)
+ but other algorithms will be added later and will have the same stream
+ interface.
+
+ Compression can be done in a single step if the buffers are large enough,
+ or can be done by repeated calls of the compression function. In the latter
+ case, the application must provide more input and/or consume the output
(providing more output space) before each call.
- The compressed data format used by default by the in-memory functions is
+ The compressed data format used by default by the in-memory functions is
the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped
around a deflate stream, which is itself documented in RFC 1951.
- The library also supports reading and writing files in gzip (.gz) format
+ The library also supports reading and writing files in gzip (.gz) format
with an interface similar to that of stdio using the functions that start
with "gz". The gzip format is different from the zlib format. gzip is a
gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.
- This library can optionally read and write gzip streams in memory as well.
+ This library can optionally read and write gzip streams in memory as well.
- The zlib format was designed to be compact and fast for use in memory
+ The zlib format was designed to be compact and fast for use in memory
and on communications channels. The gzip format was designed for single-
file compression on file systems, has a larger header than zlib to maintain
directory information, and uses a different, slower check method than zlib.
- The library does not install any signal handler. The decoder checks
- the consistency of the compressed data, so the library should never
- crash even in case of corrupted input.
+ The library does not install any signal handler. The decoder checks
+ the consistency of the compressed data, so the library should never crash
+ even in case of corrupted input.
*/
typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
@@ -126,45 +130,45 @@ typedef struct gz_header_s {
typedef gz_header FAR *gz_headerp;
/*
- The application must update next_in and avail_in when avail_in has
- dropped to zero. It must update next_out and avail_out when avail_out
- has dropped to zero. The application must initialize zalloc, zfree and
- opaque before calling the init function. All other fields are set by the
- compression library and must not be updated by the application.
-
- The opaque value provided by the application will be passed as the first
- parameter for calls of zalloc and zfree. This can be useful for custom
- memory management. The compression library attaches no meaning to the
+ The application must update next_in and avail_in when avail_in has dropped
+ to zero. It must update next_out and avail_out when avail_out has dropped
+ to zero. The application must initialize zalloc, zfree and opaque before
+ calling the init function. All other fields are set by the compression
+ library and must not be updated by the application.
+
+ The opaque value provided by the application will be passed as the first
+ parameter for calls of zalloc and zfree. This can be useful for custom
+ memory management. The compression library attaches no meaning to the
opaque value.
- zalloc must return Z_NULL if there is not enough memory for the object.
+ zalloc must return Z_NULL if there is not enough memory for the object.
If zlib is used in a multi-threaded application, zalloc and zfree must be
thread safe.
- On 16-bit systems, the functions zalloc and zfree must be able to allocate
- exactly 65536 bytes, but will not be required to allocate more than this
- if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS,
- pointers returned by zalloc for objects of exactly 65536 bytes *must*
- have their offset normalized to zero. The default allocation function
- provided by this library ensures this (see zutil.c). To reduce memory
- requirements and avoid any allocation of 64K objects, at the expense of
- compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h).
-
- The fields total_in and total_out can be used for statistics or
- progress reports. After compression, total_in holds the total size of
- the uncompressed data and may be saved for use in the decompressor
- (particularly if the decompressor wants to decompress everything in
- a single step).
+ On 16-bit systems, the functions zalloc and zfree must be able to allocate
+ exactly 65536 bytes, but will not be required to allocate more than this if
+ the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, pointers
+ returned by zalloc for objects of exactly 65536 bytes *must* have their
+ offset normalized to zero. The default allocation function provided by this
+ library ensures this (see zutil.c). To reduce memory requirements and avoid
+ any allocation of 64K objects, at the expense of compression ratio, compile
+ the library with -DMAX_WBITS=14 (see zconf.h).
+
+ The fields total_in and total_out can be used for statistics or progress
+ reports. After compression, total_in holds the total size of the
+ uncompressed data and may be saved for use in the decompressor (particularly
+ if the decompressor wants to decompress everything in a single step).
*/
/* constants */
#define Z_NO_FLUSH 0
-#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */
+#define Z_PARTIAL_FLUSH 1
#define Z_SYNC_FLUSH 2
#define Z_FULL_FLUSH 3
#define Z_FINISH 4
#define Z_BLOCK 5
+#define Z_TREES 6
/* Allowed flush values; see deflate() and inflate() below for details */
#define Z_OK 0
@@ -176,8 +180,8 @@ typedef gz_header FAR *gz_headerp;
#define Z_MEM_ERROR (-4)
#define Z_BUF_ERROR (-5)
#define Z_VERSION_ERROR (-6)
-/* Return codes for the compression/decompression functions. Negative
- * values are errors, positive values are used for special but normal events.
+/* Return codes for the compression/decompression functions. Negative values
+ * are errors, positive values are used for special but normal events.
*/
#define Z_NO_COMPRESSION 0
@@ -207,119 +211,140 @@ typedef gz_header FAR *gz_headerp;
#define zlib_version zlibVersion()
/* for compatibility with versions < 1.0.2 */
+
/* basic functions */
ZEXTERN const char * ZEXPORT zlibVersion OF((void));
/* The application can compare zlibVersion and ZLIB_VERSION for consistency.
- If the first character differs, the library code actually used is
- not compatible with the zlib.h header file used by the application.
- This check is automatically made by deflateInit and inflateInit.
+ If the first character differs, the library code actually used is not
+ compatible with the zlib.h header file used by the application. This check
+ is automatically made by deflateInit and inflateInit.
*/
/*
ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));
- Initializes the internal stream state for compression. The fields
- zalloc, zfree and opaque must be initialized before by the caller.
- If zalloc and zfree are set to Z_NULL, deflateInit updates them to
- use default allocation functions.
+ Initializes the internal stream state for compression. The fields
+ zalloc, zfree and opaque must be initialized before by the caller. If
+ zalloc and zfree are set to Z_NULL, deflateInit updates them to use default
+ allocation functions.
The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
- 1 gives best speed, 9 gives best compression, 0 gives no compression at
- all (the input data is simply copied a block at a time).
- Z_DEFAULT_COMPRESSION requests a default compromise between speed and
- compression (currently equivalent to level 6).
+ 1 gives best speed, 9 gives best compression, 0 gives no compression at all
+ (the input data is simply copied a block at a time). Z_DEFAULT_COMPRESSION
+ requests a default compromise between speed and compression (currently
+ equivalent to level 6).
- deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_STREAM_ERROR if level is not a valid compression level,
+ deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
+ memory, Z_STREAM_ERROR if level is not a valid compression level, or
Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible
- with the version assumed by the caller (ZLIB_VERSION).
- msg is set to null if there is no error message. deflateInit does not
- perform any compression: this will be done by deflate().
+ with the version assumed by the caller (ZLIB_VERSION). msg is set to null
+ if there is no error message. deflateInit does not perform any compression:
+ this will be done by deflate().
*/
ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
/*
deflate compresses as much data as possible, and stops when the input
- buffer becomes empty or the output buffer becomes full. It may introduce some
- output latency (reading input without producing any output) except when
+ buffer becomes empty or the output buffer becomes full. It may introduce
+ some output latency (reading input without producing any output) except when
forced to flush.
- The detailed semantics are as follows. deflate performs one or both of the
+ The detailed semantics are as follows. deflate performs one or both of the
following actions:
- Compress more input starting at next_in and update next_in and avail_in
- accordingly. If not all input can be processed (because there is not
+ accordingly. If not all input can be processed (because there is not
enough room in the output buffer), next_in and avail_in are updated and
processing will resume at this point for the next call of deflate().
- Provide more output starting at next_out and update next_out and avail_out
- accordingly. This action is forced if the parameter flush is non zero.
+ accordingly. This action is forced if the parameter flush is non zero.
Forcing flush frequently degrades the compression ratio, so this parameter
- should be set only when necessary (in interactive applications).
- Some output may be provided even if flush is not set.
-
- Before the call of deflate(), the application should ensure that at least
- one of the actions is possible, by providing more input and/or consuming
- more output, and updating avail_in or avail_out accordingly; avail_out
- should never be zero before the call. The application can consume the
- compressed output when it wants, for example when the output buffer is full
- (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK
- and with zero avail_out, it must be called again after making room in the
- output buffer because there might be more output pending.
+ should be set only when necessary (in interactive applications). Some
+ output may be provided even if flush is not set.
+
+ Before the call of deflate(), the application should ensure that at least
+ one of the actions is possible, by providing more input and/or consuming more
+ output, and updating avail_in or avail_out accordingly; avail_out should
+ never be zero before the call. The application can consume the compressed
+ output when it wants, for example when the output buffer is full (avail_out
+ == 0), or after each call of deflate(). If deflate returns Z_OK and with
+ zero avail_out, it must be called again after making room in the output
+ buffer because there might be more output pending.
Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to
- decide how much data to accumualte before producing output, in order to
+ decide how much data to accumulate before producing output, in order to
maximize compression.
If the parameter flush is set to Z_SYNC_FLUSH, all pending output is
flushed to the output buffer and the output is aligned on a byte boundary, so
- that the decompressor can get all input data available so far. (In particular
- avail_in is zero after the call if enough output space has been provided
- before the call.) Flushing may degrade compression for some compression
- algorithms and so it should be used only when necessary.
+ that the decompressor can get all input data available so far. (In
+ particular avail_in is zero after the call if enough output space has been
+ provided before the call.) Flushing may degrade compression for some
+ compression algorithms and so it should be used only when necessary. This
+ completes the current deflate block and follows it with an empty stored block
+ that is three bits plus filler bits to the next byte, followed by four bytes
+ (00 00 ff ff).
+
+ If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the
+ output buffer, but the output is not aligned to a byte boundary. All of the
+ input data so far will be available to the decompressor, as for Z_SYNC_FLUSH.
+ This completes the current deflate block and follows it with an empty fixed
+ codes block that is 10 bits long. This assures that enough bytes are output
+ in order for the decompressor to finish the block before the empty fixed code
+ block.
+
+ If flush is set to Z_BLOCK, a deflate block is completed and emitted, as
+ for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to
+ seven bits of the current block are held to be written as the next byte after
+ the next deflate block is completed. In this case, the decompressor may not
+ be provided enough bits at this point in order to complete decompression of
+ the data provided so far to the compressor. It may need to wait for the next
+ block to be emitted. This is for advanced applications that need to control
+ the emission of deflate blocks.
If flush is set to Z_FULL_FLUSH, all output is flushed as with
Z_SYNC_FLUSH, and the compression state is reset so that decompression can
restart from this point if previous compressed data has been damaged or if
- random access is desired. Using Z_FULL_FLUSH too often can seriously degrade
+ random access is desired. Using Z_FULL_FLUSH too often can seriously degrade
compression.
If deflate returns with avail_out == 0, this function must be called again
with the same value of the flush parameter and more output space (updated
avail_out), until the flush is complete (deflate returns with non-zero
- avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that
+ avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that
avail_out is greater than six to avoid repeated flush markers due to
avail_out == 0 on return.
If the parameter flush is set to Z_FINISH, pending input is processed,
- pending output is flushed and deflate returns with Z_STREAM_END if there
- was enough output space; if deflate returns with Z_OK, this function must be
+ pending output is flushed and deflate returns with Z_STREAM_END if there was
+ enough output space; if deflate returns with Z_OK, this function must be
called again with Z_FINISH and more output space (updated avail_out) but no
- more input data, until it returns with Z_STREAM_END or an error. After
- deflate has returned Z_STREAM_END, the only possible operations on the
- stream are deflateReset or deflateEnd.
+ more input data, until it returns with Z_STREAM_END or an error. After
+ deflate has returned Z_STREAM_END, the only possible operations on the stream
+ are deflateReset or deflateEnd.
Z_FINISH can be used immediately after deflateInit if all the compression
- is to be done in a single step. In this case, avail_out must be at least
- the value returned by deflateBound (see below). If deflate does not return
+ is to be done in a single step. In this case, avail_out must be at least the
+ value returned by deflateBound (see below). If deflate does not return
Z_STREAM_END, then it must be called again as described above.
deflate() sets strm->adler to the adler32 checksum of all input read
so far (that is, total_in bytes).
deflate() may update strm->data_type if it can make a good guess about
- the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered
- binary. This field is only for information purposes and does not affect
- the compression algorithm in any manner.
+ the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered
+ binary. This field is only for information purposes and does not affect the
+ compression algorithm in any manner.
deflate() returns Z_OK if some progress has been made (more input
processed or more output produced), Z_STREAM_END if all input has been
consumed and all output has been produced (only when flush is set to
Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
- if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible
- (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not
+ if next_in or next_out was Z_NULL), Z_BUF_ERROR if no progress is possible
+ (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not
fatal, and deflate() can be called again with more input and more output
space to continue compressing.
*/
@@ -328,13 +353,13 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
/*
All dynamically allocated data structures for this stream are freed.
- This function discards any unprocessed input and does not flush any
- pending output.
+ This function discards any unprocessed input and does not flush any pending
+ output.
deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
stream state was inconsistent, Z_DATA_ERROR if the stream was freed
- prematurely (some input or output was discarded). In the error case,
- msg may be set but then points to a static string (which must not be
+ prematurely (some input or output was discarded). In the error case, msg
+ may be set but then points to a static string (which must not be
deallocated).
*/
@@ -342,10 +367,10 @@ ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
/*
ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
- Initializes the internal stream state for decompression. The fields
+ Initializes the internal stream state for decompression. The fields
next_in, avail_in, zalloc, zfree and opaque must be initialized before by
- the caller. If next_in is not Z_NULL and avail_in is large enough (the exact
- value depends on the compression method), inflateInit determines the
+ the caller. If next_in is not Z_NULL and avail_in is large enough (the
+ exact value depends on the compression method), inflateInit determines the
compression method from the zlib header and allocates all data structures
accordingly; otherwise the allocation will be deferred to the first call of
inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to
@@ -353,95 +378,108 @@ ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
- version assumed by the caller. msg is set to null if there is no error
- message. inflateInit does not perform any decompression apart from reading
- the zlib header if present: this will be done by inflate(). (So next_in and
- avail_in may be modified, but next_out and avail_out are unchanged.)
+ version assumed by the caller, or Z_STREAM_ERROR if the parameters are
+ invalid, such as a null pointer to the structure. msg is set to null if
+ there is no error message. inflateInit does not perform any decompression
+ apart from possibly reading the zlib header if present: actual decompression
+ will be done by inflate(). (So next_in and avail_in may be modified, but
+ next_out and avail_out are unused and unchanged.) The current implementation
+ of inflateInit() does not process any header information -- that is deferred
+ until inflate() is called.
*/
ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
/*
inflate decompresses as much data as possible, and stops when the input
- buffer becomes empty or the output buffer becomes full. It may introduce
+ buffer becomes empty or the output buffer becomes full. It may introduce
some output latency (reading input without producing any output) except when
forced to flush.
- The detailed semantics are as follows. inflate performs one or both of the
+ The detailed semantics are as follows. inflate performs one or both of the
following actions:
- Decompress more input starting at next_in and update next_in and avail_in
- accordingly. If not all input can be processed (because there is not
- enough room in the output buffer), next_in is updated and processing
- will resume at this point for the next call of inflate().
+ accordingly. If not all input can be processed (because there is not
+ enough room in the output buffer), next_in is updated and processing will
+ resume at this point for the next call of inflate().
- Provide more output starting at next_out and update next_out and avail_out
- accordingly. inflate() provides as much output as possible, until there
- is no more input data or no more space in the output buffer (see below
- about the flush parameter).
-
- Before the call of inflate(), the application should ensure that at least
- one of the actions is possible, by providing more input and/or consuming
- more output, and updating the next_* and avail_* values accordingly.
- The application can consume the uncompressed output when it wants, for
- example when the output buffer is full (avail_out == 0), or after each
- call of inflate(). If inflate returns Z_OK and with zero avail_out, it
- must be called again after making room in the output buffer because there
- might be more output pending.
-
- The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH,
- Z_FINISH, or Z_BLOCK. Z_SYNC_FLUSH requests that inflate() flush as much
- output as possible to the output buffer. Z_BLOCK requests that inflate() stop
- if and when it gets to the next deflate block boundary. When decoding the
- zlib or gzip format, this will cause inflate() to return immediately after
- the header and before the first block. When doing a raw inflate, inflate()
- will go ahead and process the first block, and will return when it gets to
- the end of that block, or when it runs out of data.
+ accordingly. inflate() provides as much output as possible, until there is
+ no more input data or no more space in the output buffer (see below about
+ the flush parameter).
+
+ Before the call of inflate(), the application should ensure that at least
+ one of the actions is possible, by providing more input and/or consuming more
+ output, and updating the next_* and avail_* values accordingly. The
+ application can consume the uncompressed output when it wants, for example
+ when the output buffer is full (avail_out == 0), or after each call of
+ inflate(). If inflate returns Z_OK and with zero avail_out, it must be
+ called again after making room in the output buffer because there might be
+ more output pending.
+
+ The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH,
+ Z_BLOCK, or Z_TREES. Z_SYNC_FLUSH requests that inflate() flush as much
+ output as possible to the output buffer. Z_BLOCK requests that inflate()
+ stop if and when it gets to the next deflate block boundary. When decoding
+ the zlib or gzip format, this will cause inflate() to return immediately
+ after the header and before the first block. When doing a raw inflate,
+ inflate() will go ahead and process the first block, and will return when it
+ gets to the end of that block, or when it runs out of data.
The Z_BLOCK option assists in appending to or combining deflate streams.
Also to assist in this, on return inflate() will set strm->data_type to the
- number of unused bits in the last byte taken from strm->next_in, plus 64
- if inflate() is currently decoding the last block in the deflate stream,
- plus 128 if inflate() returned immediately after decoding an end-of-block
- code or decoding the complete header up to just before the first byte of the
- deflate stream. The end-of-block will not be indicated until all of the
- uncompressed data from that block has been written to strm->next_out. The
- number of unused bits may in general be greater than seven, except when
- bit 7 of data_type is set, in which case the number of unused bits will be
- less than eight.
+ number of unused bits in the last byte taken from strm->next_in, plus 64 if
+ inflate() is currently decoding the last block in the deflate stream, plus
+ 128 if inflate() returned immediately after decoding an end-of-block code or
+ decoding the complete header up to just before the first byte of the deflate
+ stream. The end-of-block will not be indicated until all of the uncompressed
+ data from that block has been written to strm->next_out. The number of
+ unused bits may in general be greater than seven, except when bit 7 of
+ data_type is set, in which case the number of unused bits will be less than
+ eight. data_type is set as noted here every time inflate() returns for all
+ flush options, and so can be used to determine the amount of currently
+ consumed input in bits.
+
+ The Z_TREES option behaves as Z_BLOCK does, but it also returns when the
+ end of each deflate block header is reached, before any actual data in that
+ block is decoded. This allows the caller to determine the length of the
+ deflate block header for later use in random access within a deflate block.
+ 256 is added to the value of strm->data_type when inflate() returns
+ immediately after reaching the end of the deflate block header.
inflate() should normally be called until it returns Z_STREAM_END or an
- error. However if all decompression is to be performed in a single step
- (a single call of inflate), the parameter flush should be set to
- Z_FINISH. In this case all pending input is processed and all pending
- output is flushed; avail_out must be large enough to hold all the
- uncompressed data. (The size of the uncompressed data may have been saved
- by the compressor for this purpose.) The next operation on this stream must
- be inflateEnd to deallocate the decompression state. The use of Z_FINISH
- is never required, but can be used to inform inflate that a faster approach
- may be used for the single inflate() call.
+ error. However if all decompression is to be performed in a single step (a
+ single call of inflate), the parameter flush should be set to Z_FINISH. In
+ this case all pending input is processed and all pending output is flushed;
+ avail_out must be large enough to hold all the uncompressed data. (The size
+ of the uncompressed data may have been saved by the compressor for this
+ purpose.) The next operation on this stream must be inflateEnd to deallocate
+ the decompression state. The use of Z_FINISH is never required, but can be
+ used to inform inflate that a faster approach may be used for the single
+ inflate() call.
In this implementation, inflate() always flushes as much output as
possible to the output buffer, and always uses the faster approach on the
- first call. So the only effect of the flush parameter in this implementation
+ first call. So the only effect of the flush parameter in this implementation
is on the return value of inflate(), as noted below, or when it returns early
- because Z_BLOCK is used.
+ because Z_BLOCK or Z_TREES is used.
If a preset dictionary is needed after this call (see inflateSetDictionary
below), inflate sets strm->adler to the adler32 checksum of the dictionary
chosen by the compressor and returns Z_NEED_DICT; otherwise it sets
strm->adler to the adler32 checksum of all output produced so far (that is,
total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described
- below. At the end of the stream, inflate() checks that its computed adler32
+ below. At the end of the stream, inflate() checks that its computed adler32
checksum is equal to that saved by the compressor and returns Z_STREAM_END
only if the checksum is correct.
- inflate() will decompress and check either zlib-wrapped or gzip-wrapped
- deflate data. The header type is detected automatically. Any information
- contained in the gzip header is not retained, so applications that need that
- information should instead use raw inflate, see inflateInit2() below, or
- inflateBack() and perform their own processing of the gzip header and
- trailer.
+ inflate() can decompress and check either zlib-wrapped or gzip-wrapped
+ deflate data. The header type is detected automatically, if requested when
+ initializing with inflateInit2(). Any information contained in the gzip
+ header is not retained, so applications that need that information should
+ instead use raw inflate, see inflateInit2() below, or inflateBack() and
+ perform their own processing of the gzip header and trailer.
inflate() returns Z_OK if some progress has been made (more input processed
or more output produced), Z_STREAM_END if the end of the compressed data has
@@ -449,27 +487,28 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
preset dictionary is needed at this point, Z_DATA_ERROR if the input data was
corrupted (input stream not conforming to the zlib format or incorrect check
value), Z_STREAM_ERROR if the stream structure was inconsistent (for example
- if next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory,
+ next_in or next_out was Z_NULL), Z_MEM_ERROR if there was not enough memory,
Z_BUF_ERROR if no progress is possible or if there was not enough room in the
- output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and
+ output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and
inflate() can be called again with more input and more output space to
- continue decompressing. If Z_DATA_ERROR is returned, the application may then
- call inflateSync() to look for a good compression block if a partial recovery
- of the data is desired.
+ continue decompressing. If Z_DATA_ERROR is returned, the application may
+ then call inflateSync() to look for a good compression block if a partial
+ recovery of the data is desired.
*/
ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
/*
All dynamically allocated data structures for this stream are freed.
- This function discards any unprocessed input and does not flush any
- pending output.
+ This function discards any unprocessed input and does not flush any pending
+ output.
inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state
- was inconsistent. In the error case, msg may be set but then points to a
+ was inconsistent. In the error case, msg may be set but then points to a
static string (which must not be deallocated).
*/
+
/* Advanced functions */
/*
@@ -484,55 +523,57 @@ ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
int memLevel,
int strategy));
- This is another version of deflateInit with more compression options. The
- fields next_in, zalloc, zfree and opaque must be initialized before by
- the caller.
+ This is another version of deflateInit with more compression options. The
+ fields next_in, zalloc, zfree and opaque must be initialized before by the
+ caller.
- The method parameter is the compression method. It must be Z_DEFLATED in
+ The method parameter is the compression method. It must be Z_DEFLATED in
this version of the library.
The windowBits parameter is the base two logarithm of the window size
- (the size of the history buffer). It should be in the range 8..15 for this
- version of the library. Larger values of this parameter result in better
- compression at the expense of memory usage. The default value is 15 if
+ (the size of the history buffer). It should be in the range 8..15 for this
+ version of the library. Larger values of this parameter result in better
+ compression at the expense of memory usage. The default value is 15 if
deflateInit is used instead.
- windowBits can also be -8..-15 for raw deflate. In this case, -windowBits
- determines the window size. deflate() will then generate raw deflate data
+ windowBits can also be -8..-15 for raw deflate. In this case, -windowBits
+ determines the window size. deflate() will then generate raw deflate data
with no zlib header or trailer, and will not compute an adler32 check value.
- windowBits can also be greater than 15 for optional gzip encoding. Add
+ windowBits can also be greater than 15 for optional gzip encoding. Add
16 to windowBits to write a simple gzip header and trailer around the
- compressed data instead of a zlib wrapper. The gzip header will have no
- file name, no extra data, no comment, no modification time (set to zero),
- no header crc, and the operating system will be set to 255 (unknown). If a
+ compressed data instead of a zlib wrapper. The gzip header will have no
+ file name, no extra data, no comment, no modification time (set to zero), no
+ header crc, and the operating system will be set to 255 (unknown). If a
gzip stream is being written, strm->adler is a crc32 instead of an adler32.
The memLevel parameter specifies how much memory should be allocated
- for the internal compression state. memLevel=1 uses minimum memory but
- is slow and reduces compression ratio; memLevel=9 uses maximum memory
- for optimal speed. The default value is 8. See zconf.h for total memory
- usage as a function of windowBits and memLevel.
+ for the internal compression state. memLevel=1 uses minimum memory but is
+ slow and reduces compression ratio; memLevel=9 uses maximum memory for
+ optimal speed. The default value is 8. See zconf.h for total memory usage
+ as a function of windowBits and memLevel.
- The strategy parameter is used to tune the compression algorithm. Use the
+ The strategy parameter is used to tune the compression algorithm. Use the
value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no
string match), or Z_RLE to limit match distances to one (run-length
- encoding). Filtered data consists mostly of small values with a somewhat
- random distribution. In this case, the compression algorithm is tuned to
- compress them better. The effect of Z_FILTERED is to force more Huffman
+ encoding). Filtered data consists mostly of small values with a somewhat
+ random distribution. In this case, the compression algorithm is tuned to
+ compress them better. The effect of Z_FILTERED is to force more Huffman
coding and less string matching; it is somewhat intermediate between
- Z_DEFAULT and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as fast as
- Z_HUFFMAN_ONLY, but give better compression for PNG image data. The strategy
- parameter only affects the compression ratio but not the correctness of the
- compressed output even if it is not set appropriately. Z_FIXED prevents the
- use of dynamic Huffman codes, allowing for a simpler decoder for special
- applications.
-
- deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
- memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid
- method). msg is set to null if there is no error message. deflateInit2 does
- not perform any compression: this will be done by deflate().
+ Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as
+ fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data. The
+ strategy parameter only affects the compression ratio but not the
+ correctness of the compressed output even if it is not set appropriately.
+ Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler
+ decoder for special applications.
+
+ deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
+ memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid
+ method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is
+ incompatible with the version assumed by the caller (ZLIB_VERSION). msg is
+ set to null if there is no error message. deflateInit2 does not perform any
+ compression: this will be done by deflate().
*/
ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
@@ -540,37 +581,37 @@ ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
uInt dictLength));
/*
Initializes the compression dictionary from the given byte sequence
- without producing any compressed output. This function must be called
- immediately after deflateInit, deflateInit2 or deflateReset, before any
- call of deflate. The compressor and decompressor must use exactly the same
+ without producing any compressed output. This function must be called
+ immediately after deflateInit, deflateInit2 or deflateReset, before any call
+ of deflate. The compressor and decompressor must use exactly the same
dictionary (see inflateSetDictionary).
The dictionary should consist of strings (byte sequences) that are likely
to be encountered later in the data to be compressed, with the most commonly
- used strings preferably put towards the end of the dictionary. Using a
+ used strings preferably put towards the end of the dictionary. Using a
dictionary is most useful when the data to be compressed is short and can be
predicted with good accuracy; the data can then be compressed better than
with the default empty dictionary.
Depending on the size of the compression data structures selected by
deflateInit or deflateInit2, a part of the dictionary may in effect be
- discarded, for example if the dictionary is larger than the window size in
- deflate or deflate2. Thus the strings most likely to be useful should be
- put at the end of the dictionary, not at the front. In addition, the
- current implementation of deflate will use at most the window size minus
- 262 bytes of the provided dictionary.
+ discarded, for example if the dictionary is larger than the window size
+ provided in deflateInit or deflateInit2. Thus the strings most likely to be
+ useful should be put at the end of the dictionary, not at the front. In
+ addition, the current implementation of deflate will use at most the window
+ size minus 262 bytes of the provided dictionary.
Upon return of this function, strm->adler is set to the adler32 value
of the dictionary; the decompressor may later use this value to determine
- which dictionary has been used by the compressor. (The adler32 value
+ which dictionary has been used by the compressor. (The adler32 value
applies to the whole dictionary even if only a subset of the dictionary is
actually used by the compressor.) If a raw deflate was requested, then the
adler32 value is not computed and strm->adler is not set.
deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
- parameter is invalid (such as NULL dictionary) or the stream state is
+ parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is
inconsistent (for example if deflate has already been called for this stream
- or if the compression method is bsort). deflateSetDictionary does not
+ or if the compression method is bsort). deflateSetDictionary does not
perform any compression: this will be done by deflate().
*/
@@ -581,26 +622,26 @@ ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
This function can be useful when several compression strategies will be
tried, for example when there are several ways of pre-processing the input
- data with a filter. The streams that will be discarded should then be freed
+ data with a filter. The streams that will be discarded should then be freed
by calling deflateEnd. Note that deflateCopy duplicates the internal
- compression state which can be quite large, so this strategy is slow and
- can consume lots of memory.
+ compression state which can be quite large, so this strategy is slow and can
+ consume lots of memory.
deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
- (such as zalloc being NULL). msg is left unchanged in both source and
+ (such as zalloc being Z_NULL). msg is left unchanged in both source and
destination.
*/
ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
/*
This function is equivalent to deflateEnd followed by deflateInit,
- but does not free and reallocate all the internal compression state.
- The stream will keep the same compression level and any other attributes
- that may have been set by deflateInit2.
+ but does not free and reallocate all the internal compression state. The
+ stream will keep the same compression level and any other attributes that
+ may have been set by deflateInit2.
- deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
- stream state was inconsistent (such as zalloc or state being NULL).
+ deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
+ stream state was inconsistent (such as zalloc or state being Z_NULL).
*/
ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
@@ -610,18 +651,18 @@ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
Dynamically update the compression level and compression strategy. The
interpretation of level and strategy is as in deflateInit2. This can be
used to switch between compression and straight copy of the input data, or
- to switch to a different kind of input data requiring a different
- strategy. If the compression level is changed, the input available so far
- is compressed with the old level (and may be flushed); the new level will
- take effect only at the next call of deflate().
+ to switch to a different kind of input data requiring a different strategy.
+ If the compression level is changed, the input available so far is
+ compressed with the old level (and may be flushed); the new level will take
+ effect only at the next call of deflate().
Before the call of deflateParams, the stream state must be set as for
- a call of deflate(), since the currently available input may have to
- be compressed and flushed. In particular, strm->avail_out must be non-zero.
+ a call of deflate(), since the currently available input may have to be
+ compressed and flushed. In particular, strm->avail_out must be non-zero.
deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source
- stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR
- if strm->avail_out was zero.
+ stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR if
+ strm->avail_out was zero.
*/
ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm,
@@ -645,9 +686,10 @@ ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,
uLong sourceLen));
/*
deflateBound() returns an upper bound on the compressed size after
- deflation of sourceLen bytes. It must be called after deflateInit()
- or deflateInit2(). This would be used to allocate an output buffer
- for deflation in a single pass, and so would be called before deflate().
+ deflation of sourceLen bytes. It must be called after deflateInit() or
+ deflateInit2(), and after deflateSetHeader(), if used. This would be used
+ to allocate an output buffer for deflation in a single pass, and so would be
+ called before deflate().
*/
ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,
@@ -655,21 +697,21 @@ ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,
int value));
/*
deflatePrime() inserts bits in the deflate output stream. The intent
- is that this function is used to start off the deflate output with the
- bits leftover from a previous deflate stream when appending to it. As such,
- this function can only be used for raw deflate, and must be used before the
- first deflate() call after a deflateInit2() or deflateReset(). bits must be
- less than or equal to 16, and that many of the least significant bits of
- value will be inserted in the output.
-
- deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source
+ is that this function is used to start off the deflate output with the bits
+ leftover from a previous deflate stream when appending to it. As such, this
+ function can only be used for raw deflate, and must be used before the first
+ deflate() call after a deflateInit2() or deflateReset(). bits must be less
+ than or equal to 16, and that many of the least significant bits of value
+ will be inserted in the output.
+
+ deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source
stream state was inconsistent.
*/
ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm,
gz_headerp head));
/*
- deflateSetHeader() provides gzip header information for when a gzip
+ deflateSetHeader() provides gzip header information for when a gzip
stream is requested by deflateInit2(). deflateSetHeader() may be called
after deflateInit2() or deflateReset() and before the first call of
deflate(). The text, time, os, extra field, name, and comment information
@@ -682,11 +724,11 @@ ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm,
1.3.x) do not support header crc's, and will report that it is a "multi-part
gzip file" and give up.
- If deflateSetHeader is not used, the default gzip header has text false,
+ If deflateSetHeader is not used, the default gzip header has text false,
the time set to zero, and os set to 255, with no extra, name, or comment
fields. The gzip header is returned to the default state by deflateReset().
- deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
+ deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
stream state was inconsistent.
*/
@@ -694,43 +736,50 @@ ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm,
ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
int windowBits));
- This is another version of inflateInit with an extra parameter. The
+ This is another version of inflateInit with an extra parameter. The
fields next_in, avail_in, zalloc, zfree and opaque must be initialized
before by the caller.
The windowBits parameter is the base two logarithm of the maximum window
size (the size of the history buffer). It should be in the range 8..15 for
- this version of the library. The default value is 15 if inflateInit is used
- instead. windowBits must be greater than or equal to the windowBits value
+ this version of the library. The default value is 15 if inflateInit is used
+ instead. windowBits must be greater than or equal to the windowBits value
provided to deflateInit2() while compressing, or it must be equal to 15 if
- deflateInit2() was not used. If a compressed stream with a larger window
+ deflateInit2() was not used. If a compressed stream with a larger window
size is given as input, inflate() will return with the error code
Z_DATA_ERROR instead of trying to allocate a larger window.
- windowBits can also be -8..-15 for raw inflate. In this case, -windowBits
- determines the window size. inflate() will then process raw deflate data,
+ windowBits can also be zero to request that inflate use the window size in
+ the zlib header of the compressed stream.
+
+ windowBits can also be -8..-15 for raw inflate. In this case, -windowBits
+ determines the window size. inflate() will then process raw deflate data,
not looking for a zlib or gzip header, not generating a check value, and not
- looking for any check values for comparison at the end of the stream. This
+ looking for any check values for comparison at the end of the stream. This
is for use with other formats that use the deflate compressed data format
- such as zip. Those formats provide their own check values. If a custom
+ such as zip. Those formats provide their own check values. If a custom
format is developed using the raw deflate format for compressed data, it is
recommended that a check value such as an adler32 or a crc32 be applied to
the uncompressed data as is done in the zlib, gzip, and zip formats. For
- most applications, the zlib format should be used as is. Note that comments
+ most applications, the zlib format should be used as is. Note that comments
above on the use in deflateInit2() applies to the magnitude of windowBits.
- windowBits can also be greater than 15 for optional gzip decoding. Add
+ windowBits can also be greater than 15 for optional gzip decoding. Add
32 to windowBits to enable zlib and gzip decoding with automatic header
detection, or add 16 to decode only the gzip format (the zlib format will
- return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is
- a crc32 instead of an adler32.
+ return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a
+ crc32 instead of an adler32.
inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
- memory, Z_STREAM_ERROR if a parameter is invalid (such as a null strm). msg
- is set to null if there is no error message. inflateInit2 does not perform
- any decompression apart from reading the zlib header if present: this will
- be done by inflate(). (So next_in and avail_in may be modified, but next_out
- and avail_out are unchanged.)
+ memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
+ version assumed by the caller, or Z_STREAM_ERROR if the parameters are
+ invalid, such as a null pointer to the structure. msg is set to null if
+ there is no error message. inflateInit2 does not perform any decompression
+ apart from possibly reading the zlib header if present: actual decompression
+ will be done by inflate(). (So next_in and avail_in may be modified, but
+ next_out and avail_out are unused and unchanged.) The current implementation
+ of inflateInit2() does not process any header information -- that is
+ deferred until inflate() is called.
*/
ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
@@ -738,8 +787,8 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
uInt dictLength));
/*
Initializes the decompression dictionary from the given uncompressed byte
- sequence. This function must be called immediately after a call of inflate,
- if that call returned Z_NEED_DICT. The dictionary chosen by the compressor
+ sequence. This function must be called immediately after a call of inflate,
+ if that call returned Z_NEED_DICT. The dictionary chosen by the compressor
can be determined from the adler32 value returned by that call of inflate.
The compressor and decompressor must use exactly the same dictionary (see
deflateSetDictionary). For raw inflate, this function can be called
@@ -748,26 +797,26 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
dictionary that was used for compression is provided.
inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
- parameter is invalid (such as NULL dictionary) or the stream state is
+ parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is
inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
- expected one (incorrect adler32 value). inflateSetDictionary does not
+ expected one (incorrect adler32 value). inflateSetDictionary does not
perform any decompression: this will be done by subsequent calls of
inflate().
*/
ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
/*
- Skips invalid compressed data until a full flush point (see above the
- description of deflate with Z_FULL_FLUSH) can be found, or until all
- available input is skipped. No output is provided.
-
- inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR
- if no more input was provided, Z_DATA_ERROR if no flush point has been found,
- or Z_STREAM_ERROR if the stream structure was inconsistent. In the success
- case, the application may save the current current value of total_in which
- indicates where valid compressed data was found. In the error case, the
- application may repeatedly call inflateSync, providing more input each time,
- until success or end of the input data.
+ Skips invalid compressed data until a full flush point (see above the
+ description of deflate with Z_FULL_FLUSH) can be found, or until all
+ available input is skipped. No output is provided.
+
+ inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR
+ if no more input was provided, Z_DATA_ERROR if no flush point has been
+ found, or Z_STREAM_ERROR if the stream structure was inconsistent. In the
+ success case, the application may save the current current value of total_in
+ which indicates where valid compressed data was found. In the error case,
+ the application may repeatedly call inflateSync, providing more input each
+ time, until success or end of the input data.
*/
ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,
@@ -782,18 +831,30 @@ ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,
inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
- (such as zalloc being NULL). msg is left unchanged in both source and
+ (such as zalloc being Z_NULL). msg is left unchanged in both source and
destination.
*/
ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
/*
This function is equivalent to inflateEnd followed by inflateInit,
- but does not free and reallocate all the internal decompression state.
- The stream will keep attributes that may have been set by inflateInit2.
+ but does not free and reallocate all the internal decompression state. The
+ stream will keep attributes that may have been set by inflateInit2.
+
+ inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
+ stream state was inconsistent (such as zalloc or state being Z_NULL).
+*/
+
+ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm,
+ int windowBits));
+/*
+ This function is the same as inflateReset, but it also permits changing
+ the wrap and window size requests. The windowBits parameter is interpreted
+ the same as it is for inflateInit2.
- inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
- stream state was inconsistent (such as zalloc or state being NULL).
+ inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source
+ stream state was inconsistent (such as zalloc or state being Z_NULL), or if
+ the windowBits parameter is invalid.
*/
ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm,
@@ -801,54 +862,87 @@ ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm,
int value));
/*
This function inserts bits in the inflate input stream. The intent is
- that this function is used to start inflating at a bit position in the
- middle of a byte. The provided bits will be used before any bytes are used
- from next_in. This function should only be used with raw inflate, and
- should be used before the first inflate() call after inflateInit2() or
- inflateReset(). bits must be less than or equal to 16, and that many of the
- least significant bits of value will be inserted in the input.
-
- inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source
+ that this function is used to start inflating at a bit position in the
+ middle of a byte. The provided bits will be used before any bytes are used
+ from next_in. This function should only be used with raw inflate, and
+ should be used before the first inflate() call after inflateInit2() or
+ inflateReset(). bits must be less than or equal to 16, and that many of the
+ least significant bits of value will be inserted in the input.
+
+ If bits is negative, then the input stream bit buffer is emptied. Then
+ inflatePrime() can be called again to put bits in the buffer. This is used
+ to clear out bits leftover after feeding inflate a block description prior
+ to feeding inflate codes.
+
+ inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source
stream state was inconsistent.
*/
+ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm));
+/*
+ This function returns two values, one in the lower 16 bits of the return
+ value, and the other in the remaining upper bits, obtained by shifting the
+ return value down 16 bits. If the upper value is -1 and the lower value is
+ zero, then inflate() is currently decoding information outside of a block.
+ If the upper value is -1 and the lower value is non-zero, then inflate is in
+ the middle of a stored block, with the lower value equaling the number of
+ bytes from the input remaining to copy. If the upper value is not -1, then
+ it is the number of bits back from the current bit position in the input of
+ the code (literal or length/distance pair) currently being processed. In
+ that case the lower value is the number of bytes already emitted for that
+ code.
+
+ A code is being processed if inflate is waiting for more input to complete
+ decoding of the code, or if it has completed decoding but is waiting for
+ more output space to write the literal or match data.
+
+ inflateMark() is used to mark locations in the input data for random
+ access, which may be at bit positions, and to note those cases where the
+ output of a code may span boundaries of random access blocks. The current
+ location in the input stream can be determined from avail_in and data_type
+ as noted in the description for the Z_BLOCK flush parameter for inflate.
+
+ inflateMark returns the value noted above or -1 << 16 if the provided
+ source stream state was inconsistent.
+*/
+
ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm,
gz_headerp head));
/*
- inflateGetHeader() requests that gzip header information be stored in the
+ inflateGetHeader() requests that gzip header information be stored in the
provided gz_header structure. inflateGetHeader() may be called after
inflateInit2() or inflateReset(), and before the first call of inflate().
As inflate() processes the gzip stream, head->done is zero until the header
is completed, at which time head->done is set to one. If a zlib stream is
being decoded, then head->done is set to -1 to indicate that there will be
- no gzip header information forthcoming. Note that Z_BLOCK can be used to
- force inflate() to return immediately after header processing is complete
- and before any actual data is decompressed.
+ no gzip header information forthcoming. Note that Z_BLOCK or Z_TREES can be
+ used to force inflate() to return immediately after header processing is
+ complete and before any actual data is decompressed.
- The text, time, xflags, and os fields are filled in with the gzip header
+ The text, time, xflags, and os fields are filled in with the gzip header
contents. hcrc is set to true if there is a header CRC. (The header CRC
- was valid if done is set to one.) If extra is not Z_NULL, then extra_max
+ was valid if done is set to one.) If extra is not Z_NULL, then extra_max
contains the maximum number of bytes to write to extra. Once done is true,
extra_len contains the actual extra field length, and extra contains the
extra field, or that field truncated if extra_max is less than extra_len.
If name is not Z_NULL, then up to name_max characters are written there,
terminated with a zero unless the length is greater than name_max. If
comment is not Z_NULL, then up to comm_max characters are written there,
- terminated with a zero unless the length is greater than comm_max. When
- any of extra, name, or comment are not Z_NULL and the respective field is
- not present in the header, then that field is set to Z_NULL to signal its
+ terminated with a zero unless the length is greater than comm_max. When any
+ of extra, name, or comment are not Z_NULL and the respective field is not
+ present in the header, then that field is set to Z_NULL to signal its
absence. This allows the use of deflateSetHeader() with the returned
structure to duplicate the header. However if those fields are set to
allocated memory, then the application will need to save those pointers
elsewhere so that they can be eventually freed.
- If inflateGetHeader is not used, then the header information is simply
+ If inflateGetHeader is not used, then the header information is simply
discarded. The header is always checked for validity, including the header
CRC if present. inflateReset() will reset the process to discard the header
information. The application would need to call inflateGetHeader() again to
retrieve the header from the next gzip stream.
- inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
+ inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
stream state was inconsistent.
*/
@@ -869,9 +963,9 @@ ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,
See inflateBack() for the usage of these routines.
inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of
- the paramaters are invalid, Z_MEM_ERROR if the internal state could not
- be allocated, or Z_VERSION_ERROR if the version of the library does not
- match the version of the header file.
+ the paramaters are invalid, Z_MEM_ERROR if the internal state could not be
+ allocated, or Z_VERSION_ERROR if the version of the library does not match
+ the version of the header file.
*/
typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *));
@@ -891,15 +985,15 @@ ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
inflateBackInit() must be called first to allocate the internal state
and to initialize the state with the user-provided window buffer.
inflateBack() may then be used multiple times to inflate a complete, raw
- deflate stream with each call. inflateBackEnd() is then called to free
- the allocated state.
+ deflate stream with each call. inflateBackEnd() is then called to free the
+ allocated state.
A raw deflate stream is one with no zlib or gzip header or trailer.
This routine would normally be used in a utility that reads zip or gzip
files and writes out uncompressed files. The utility would decode the
- header and process the trailer on its own, hence this routine expects
- only the raw deflate stream to decompress. This is different from the
- normal behavior of inflate(), which expects either a zlib or gzip header and
+ header and process the trailer on its own, hence this routine expects only
+ the raw deflate stream to decompress. This is different from the normal
+ behavior of inflate(), which expects either a zlib or gzip header and
trailer around the deflate stream.
inflateBack() uses two subroutines supplied by the caller that are then
@@ -925,7 +1019,7 @@ ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called
immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in
must also be initialized, and then if strm->avail_in is not zero, input will
- initially be taken from strm->next_in[0 .. strm->avail_in - 1].
+ initially be taken from strm->next_in[0 .. strm->avail_in - 1].
The in_desc and out_desc parameters of inflateBack() is passed as the
first parameter of in() and out() respectively when they are called. These
@@ -935,15 +1029,15 @@ ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
On return, inflateBack() will set strm->next_in and strm->avail_in to
pass back any unused input that was provided by the last in() call. The
return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR
- if in() or out() returned an error, Z_DATA_ERROR if there was a format
- error in the deflate stream (in which case strm->msg is set to indicate the
- nature of the error), or Z_STREAM_ERROR if the stream was not properly
- initialized. In the case of Z_BUF_ERROR, an input or output error can be
- distinguished using strm->next_in which will be Z_NULL only if in() returned
- an error. If strm->next is not Z_NULL, then the Z_BUF_ERROR was due to
- out() returning non-zero. (in() will always be called before out(), so
- strm->next_in is assured to be defined if out() returns non-zero.) Note
- that inflateBack() cannot return Z_OK.
+ if in() or out() returned an error, Z_DATA_ERROR if there was a format error
+ in the deflate stream (in which case strm->msg is set to indicate the nature
+ of the error), or Z_STREAM_ERROR if the stream was not properly initialized.
+ In the case of Z_BUF_ERROR, an input or output error can be distinguished
+ using strm->next_in which will be Z_NULL only if in() returned an error. If
+ strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning
+ non-zero. (in() will always be called before out(), so strm->next_in is
+ assured to be defined if out() returns non-zero.) Note that inflateBack()
+ cannot return Z_OK.
*/
ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm));
@@ -999,23 +1093,22 @@ ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));
/* utility functions */
/*
- The following utility functions are implemented on top of the
- basic stream-oriented functions. To simplify the interface, some
- default options are assumed (compression level and memory usage,
- standard memory allocation functions). The source code of these
- utility functions can easily be modified if you need special options.
+ The following utility functions are implemented on top of the basic
+ stream-oriented functions. To simplify the interface, some default options
+ are assumed (compression level and memory usage, standard memory allocation
+ functions). The source code of these utility functions can be modified if
+ you need special options.
*/
ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen,
const Bytef *source, uLong sourceLen));
/*
Compresses the source buffer into the destination buffer. sourceLen is
- the byte length of the source buffer. Upon entry, destLen is the total
- size of the destination buffer, which must be at least the value returned
- by compressBound(sourceLen). Upon exit, destLen is the actual size of the
+ the byte length of the source buffer. Upon entry, destLen is the total size
+ of the destination buffer, which must be at least the value returned by
+ compressBound(sourceLen). Upon exit, destLen is the actual size of the
compressed buffer.
- This function can be used to compress a whole file at once if the
- input file is mmap'ed.
+
compress returns Z_OK if success, Z_MEM_ERROR if there was not
enough memory, Z_BUF_ERROR if there was not enough room in the output
buffer.
@@ -1025,11 +1118,11 @@ ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen,
const Bytef *source, uLong sourceLen,
int level));
/*
- Compresses the source buffer into the destination buffer. The level
+ Compresses the source buffer into the destination buffer. The level
parameter has the same meaning as in deflateInit. sourceLen is the byte
- length of the source buffer. Upon entry, destLen is the total size of the
+ length of the source buffer. Upon entry, destLen is the total size of the
destination buffer, which must be at least the value returned by
- compressBound(sourceLen). Upon exit, destLen is the actual size of the
+ compressBound(sourceLen). Upon exit, destLen is the actual size of the
compressed buffer.
compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
@@ -1040,22 +1133,20 @@ ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen,
ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen));
/*
compressBound() returns an upper bound on the compressed size after
- compress() or compress2() on sourceLen bytes. It would be used before
- a compress() or compress2() call to allocate the destination buffer.
+ compress() or compress2() on sourceLen bytes. It would be used before a
+ compress() or compress2() call to allocate the destination buffer.
*/
ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
const Bytef *source, uLong sourceLen));
/*
Decompresses the source buffer into the destination buffer. sourceLen is
- the byte length of the source buffer. Upon entry, destLen is the total
- size of the destination buffer, which must be large enough to hold the
- entire uncompressed data. (The size of the uncompressed data must have
- been saved previously by the compressor and transmitted to the decompressor
- by some mechanism outside the scope of this compression library.)
- Upon exit, destLen is the actual size of the compressed buffer.
- This function can be used to decompress a whole file at once if the
- input file is mmap'ed.
+ the byte length of the source buffer. Upon entry, destLen is the total size
+ of the destination buffer, which must be large enough to hold the entire
+ uncompressed data. (The size of the uncompressed data must have been saved
+ previously by the compressor and transmitted to the decompressor by some
+ mechanism outside the scope of this compression library.) Upon exit, destLen
+ is the actual size of the uncompressed buffer.
uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
enough memory, Z_BUF_ERROR if there was not enough room in the output
@@ -1063,136 +1154,199 @@ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
*/
-typedef voidp gzFile;
+ /* gzip file access functions */
-ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
/*
- Opens a gzip (.gz) file for reading or writing. The mode parameter
- is as in fopen ("rb" or "wb") but can also include a compression level
- ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for
- Huffman only compression as in "wb1h", or 'R' for run-length encoding
- as in "wb1R". (See the description of deflateInit2 for more information
- about the strategy parameter.)
+ This library supports reading and writing files in gzip (.gz) format with
+ an interface similar to that of stdio, using the functions that start with
+ "gz". The gzip format is different from the zlib format. gzip is a gzip
+ wrapper, documented in RFC 1952, wrapped around a deflate stream.
+*/
+
+typedef voidp gzFile; /* opaque gzip file descriptor */
+
+/*
+ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
+
+ Opens a gzip (.gz) file for reading or writing. The mode parameter is as
+ in fopen ("rb" or "wb") but can also include a compression level ("wb9") or
+ a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only
+ compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F'
+ for fixed code compression as in "wb9F". (See the description of
+ deflateInit2 for more information about the strategy parameter.) Also "a"
+ can be used instead of "w" to request that the gzip stream that will be
+ written be appended to the file. "+" will result in an error, since reading
+ and writing to the same gzip file is not supported.
gzopen can be used to read a file which is not in gzip format; in this
case gzread will directly read from the file without decompression.
- gzopen returns NULL if the file could not be opened or if there was
- insufficient memory to allocate the (de)compression state; errno
- can be checked to distinguish the two cases (if errno is zero, the
- zlib error is Z_MEM_ERROR). */
+ gzopen returns NULL if the file could not be opened, if there was
+ insufficient memory to allocate the gzFile state, or if an invalid mode was
+ specified (an 'r', 'w', or 'a' was not provided, or '+' was provided).
+ errno can be checked to determine if the reason gzopen failed was that the
+ file could not be opened.
+*/
+
+ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
+/*
+ gzdopen associates a gzFile with the file descriptor fd. File descriptors
+ are obtained from calls like open, dup, creat, pipe or fileno (if the file
+ has been previously opened with fopen). The mode parameter is as in gzopen.
+
+ The next call of gzclose on the returned gzFile will also close the file
+ descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor
+ fd. If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd,
+ mode);. The duplicated descriptor should be saved to avoid a leak, since
+ gzdopen does not close fd if it fails.
+
+ gzdopen returns NULL if there was insufficient memory to allocate the
+ gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not
+ provided, or '+' was provided), or if fd is -1. The file descriptor is not
+ used until the next gz* read, write, seek, or close operation, so gzdopen
+ will not detect if fd is invalid (unless fd is -1).
+*/
-ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
+ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size));
/*
- gzdopen() associates a gzFile with the file descriptor fd. File
- descriptors are obtained from calls like open, dup, creat, pipe or
- fileno (in the file has been previously opened with fopen).
- The mode parameter is as in gzopen.
- The next call of gzclose on the returned gzFile will also close the
- file descriptor fd, just like fclose(fdopen(fd), mode) closes the file
- descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode).
- gzdopen returns NULL if there was insufficient memory to allocate
- the (de)compression state.
+ Set the internal buffer size used by this library's functions. The
+ default buffer size is 8192 bytes. This function must be called after
+ gzopen() or gzdopen(), and before any other calls that read or write the
+ file. The buffer memory allocation is always deferred to the first read or
+ write. Two buffers are allocated, either both of the specified size when
+ writing, or one of the specified size and the other twice that size when
+ reading. A larger buffer size of, for example, 64K or 128K bytes will
+ noticeably increase the speed of decompression (reading).
+
+ The new buffer size also affects the maximum length for gzprintf().
+
+ gzbuffer() returns 0 on success, or -1 on failure, such as being called
+ too late.
*/
ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
/*
- Dynamically update the compression level or strategy. See the description
+ Dynamically update the compression level or strategy. See the description
of deflateInit2 for the meaning of these parameters.
+
gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not
opened for writing.
*/
-ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
+ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
/*
- Reads the given number of uncompressed bytes from the compressed file.
- If the input file was not in gzip format, gzread copies the given number
- of bytes into the buffer.
- gzread returns the number of uncompressed bytes actually read (0 for
- end of file, -1 for error). */
+ Reads the given number of uncompressed bytes from the compressed file. If
+ the input file was not in gzip format, gzread copies the given number of
+ bytes into the buffer.
+
+ After reaching the end of a gzip stream in the input, gzread will continue
+ to read, looking for another gzip stream, or failing that, reading the rest
+ of the input file directly without decompression. The entire input file
+ will be read if gzread is called until it returns less than the requested
+ len.
+
+ gzread returns the number of uncompressed bytes actually read, less than
+ len for end of file, or -1 for error.
+*/
-ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
- voidpc buf, unsigned len));
+ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
+ voidpc buf, unsigned len));
/*
Writes the given number of uncompressed bytes into the compressed file.
- gzwrite returns the number of uncompressed bytes actually written
- (0 in case of error).
+ gzwrite returns the number of uncompressed bytes written or 0 in case of
+ error.
*/
-ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...));
+ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...));
/*
- Converts, formats, and writes the args to the compressed file under
- control of the format string, as in fprintf. gzprintf returns the number of
- uncompressed bytes actually written (0 in case of error). The number of
- uncompressed bytes written is limited to 4095. The caller should assure that
- this limit is not exceeded. If it is exceeded, then gzprintf() will return
- return an error (0) with nothing written. In this case, there may also be a
- buffer overflow with unpredictable consequences, which is possible only if
- zlib was compiled with the insecure functions sprintf() or vsprintf()
- because the secure snprintf() or vsnprintf() functions were not available.
+ Converts, formats, and writes the arguments to the compressed file under
+ control of the format string, as in fprintf. gzprintf returns the number of
+ uncompressed bytes actually written, or 0 in case of error. The number of
+ uncompressed bytes written is limited to 8191, or one less than the buffer
+ size given to gzbuffer(). The caller should assure that this limit is not
+ exceeded. If it is exceeded, then gzprintf() will return an error (0) with
+ nothing written. In this case, there may also be a buffer overflow with
+ unpredictable consequences, which is possible only if zlib was compiled with
+ the insecure functions sprintf() or vsprintf() because the secure snprintf()
+ or vsnprintf() functions were not available. This can be determined using
+ zlibCompileFlags().
*/
ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
/*
- Writes the given null-terminated string to the compressed file, excluding
+ Writes the given null-terminated string to the compressed file, excluding
the terminating null character.
- gzputs returns the number of characters written, or -1 in case of error.
+
+ gzputs returns the number of characters written, or -1 in case of error.
*/
ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
/*
- Reads bytes from the compressed file until len-1 characters are read, or
- a newline character is read and transferred to buf, or an end-of-file
- condition is encountered. The string is then terminated with a null
- character.
- gzgets returns buf, or Z_NULL in case of error.
+ Reads bytes from the compressed file until len-1 characters are read, or a
+ newline character is read and transferred to buf, or an end-of-file
+ condition is encountered. If any characters are read or if len == 1, the
+ string is terminated with a null character. If no characters are read due
+ to an end-of-file or len < 1, then the buffer is left untouched.
+
+ gzgets returns buf which is a null-terminated string, or it returns NULL
+ for end-of-file or in case of error. If there was an error, the contents at
+ buf are indeterminate.
*/
-ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));
+ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));
/*
- Writes c, converted to an unsigned char, into the compressed file.
- gzputc returns the value that was written, or -1 in case of error.
+ Writes c, converted to an unsigned char, into the compressed file. gzputc
+ returns the value that was written, or -1 in case of error.
*/
-ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
+ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
/*
- Reads one byte from the compressed file. gzgetc returns this byte
- or -1 in case of end of file or error.
+ Reads one byte from the compressed file. gzgetc returns this byte or -1
+ in case of end of file or error.
*/
-ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));
+ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));
/*
- Push one character back onto the stream to be read again later.
- Only one character of push-back is allowed. gzungetc() returns the
- character pushed, or -1 on failure. gzungetc() will fail if a
- character has been pushed but not read yet, or if c is -1. The pushed
- character will be discarded if the stream is repositioned with gzseek()
- or gzrewind().
+ Push one character back onto the stream to be read as the first character
+ on the next read. At least one character of push-back is allowed.
+ gzungetc() returns the character pushed, or -1 on failure. gzungetc() will
+ fail if c is -1, and may fail if a character has been pushed but not read
+ yet. If gzungetc is used immediately after gzopen or gzdopen, at least the
+ output buffer size of pushed characters is allowed. (See gzbuffer above.)
+ The pushed character will be discarded if the stream is repositioned with
+ gzseek() or gzrewind().
*/
-ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
+ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
/*
- Flushes all pending output into the compressed file. The parameter
- flush is as in the deflate() function. The return value is the zlib
- error number (see function gzerror below). gzflush returns Z_OK if
- the flush parameter is Z_FINISH and all output could be flushed.
- gzflush should be called only when strictly necessary because it can
- degrade compression.
+ Flushes all pending output into the compressed file. The parameter flush
+ is as in the deflate() function. The return value is the zlib error number
+ (see function gzerror below). gzflush is only permitted when writing.
+
+ If the flush parameter is Z_FINISH, the remaining data is written and the
+ gzip stream is completed in the output. If gzwrite() is called again, a new
+ gzip stream will be started in the output. gzread() is able to read such
+ concatented gzip streams.
+
+ gzflush should be called only when strictly necessary because it will
+ degrade compression if called too often.
*/
-ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
- z_off_t offset, int whence));
/*
- Sets the starting position for the next gzread or gzwrite on the
- given compressed file. The offset represents a number of bytes in the
- uncompressed data stream. The whence parameter is defined as in lseek(2);
+ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
+ z_off_t offset, int whence));
+
+ Sets the starting position for the next gzread or gzwrite on the given
+ compressed file. The offset represents a number of bytes in the
+ uncompressed data stream. The whence parameter is defined as in lseek(2);
the value SEEK_END is not supported.
+
If the file is opened for reading, this function is emulated but can be
- extremely slow. If the file is opened for writing, only forward seeks are
+ extremely slow. If the file is opened for writing, only forward seeks are
supported; gzseek then compresses a sequence of zeroes up to the new
starting position.
- gzseek returns the resulting offset location as measured in bytes from
+ gzseek returns the resulting offset location as measured in bytes from
the beginning of the uncompressed stream, or -1 in case of error, in
particular if the file is opened for writing and the new starting position
would be before the current position.
@@ -1202,68 +1356,127 @@ ZEXTERN int ZEXPORT gzrewind OF((gzFile file));
/*
Rewinds the given file. This function is supported only for reading.
- gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
+ gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
*/
+/*
ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file));
+
+ Returns the starting position for the next gzread or gzwrite on the given
+ compressed file. This position represents a number of bytes in the
+ uncompressed data stream, and is zero when starting, even if appending or
+ reading a gzip stream from the middle of a file using gzdopen().
+
+ gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
+*/
+
/*
- Returns the starting position for the next gzread or gzwrite on the
- given compressed file. This position represents a number of bytes in the
- uncompressed data stream.
+ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file));
- gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
+ Returns the current offset in the file being read or written. This offset
+ includes the count of bytes that precede the gzip stream, for example when
+ appending or when using gzdopen() for reading. When reading, the offset
+ does not include as yet unused buffered input. This information can be used
+ for a progress indicator. On error, gzoffset() returns -1.
*/
ZEXTERN int ZEXPORT gzeof OF((gzFile file));
/*
- Returns 1 when EOF has previously been detected reading the given
- input stream, otherwise zero.
+ Returns true (1) if the end-of-file indicator has been set while reading,
+ false (0) otherwise. Note that the end-of-file indicator is set only if the
+ read tried to go past the end of the input, but came up short. Therefore,
+ just like feof(), gzeof() may return false even if there is no more data to
+ read, in the event that the last read request was for the exact number of
+ bytes remaining in the input file. This will happen if the input file size
+ is an exact multiple of the buffer size.
+
+ If gzeof() returns true, then the read functions will return no more data,
+ unless the end-of-file indicator is reset by gzclearerr() and the input file
+ has grown since the previous end of file was detected.
*/
ZEXTERN int ZEXPORT gzdirect OF((gzFile file));
/*
- Returns 1 if file is being read directly without decompression, otherwise
- zero.
+ Returns true (1) if file is being copied directly while reading, or false
+ (0) if file is a gzip stream being decompressed. This state can change from
+ false to true while reading the input file if the end of a gzip stream is
+ reached, but is followed by data that is not another gzip stream.
+
+ If the input file is empty, gzdirect() will return true, since the input
+ does not contain a gzip stream.
+
+ If gzdirect() is used immediately after gzopen() or gzdopen() it will
+ cause buffers to be allocated to allow reading the file to determine if it
+ is a gzip file. Therefore if gzbuffer() is used, it should be called before
+ gzdirect().
*/
ZEXTERN int ZEXPORT gzclose OF((gzFile file));
/*
- Flushes all pending output if necessary, closes the compressed file
- and deallocates all the (de)compression state. The return value is the zlib
- error number (see function gzerror below).
+ Flushes all pending output if necessary, closes the compressed file and
+ deallocates the (de)compression state. Note that once file is closed, you
+ cannot call gzerror with file, since its structures have been deallocated.
+ gzclose must not be called more than once on the same file, just as free
+ must not be called more than once on the same allocation.
+
+ gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a
+ file operation error, or Z_OK on success.
+*/
+
+ZEXTERN int ZEXPORT gzclose_r OF((gzFile file));
+ZEXTERN int ZEXPORT gzclose_w OF((gzFile file));
+/*
+ Same as gzclose(), but gzclose_r() is only for use when reading, and
+ gzclose_w() is only for use when writing or appending. The advantage to
+ using these instead of gzclose() is that they avoid linking in zlib
+ compression or decompression code that is not used when only reading or only
+ writing respectively. If gzclose() is used, then both compression and
+ decompression code will be included the application when linking to a static
+ zlib library.
*/
ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
/*
- Returns the error message for the last error which occurred on the
- given compressed file. errnum is set to zlib error number. If an
- error occurred in the file system and not in the compression library,
- errnum is set to Z_ERRNO and the application may consult errno
- to get the exact error code.
+ Returns the error message for the last error which occurred on the given
+ compressed file. errnum is set to zlib error number. If an error occurred
+ in the file system and not in the compression library, errnum is set to
+ Z_ERRNO and the application may consult errno to get the exact error code.
+
+ The application must not modify the returned string. Future calls to
+ this function may invalidate the previously returned string. If file is
+ closed, then the string previously returned by gzerror will no longer be
+ available.
+
+ gzerror() should be used to distinguish errors from end-of-file for those
+ functions above that do not distinguish those cases in their return values.
*/
ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
/*
- Clears the error and end-of-file flags for file. This is analogous to the
- clearerr() function in stdio. This is useful for continuing to read a gzip
+ Clears the error and end-of-file flags for file. This is analogous to the
+ clearerr() function in stdio. This is useful for continuing to read a gzip
file that is being written concurrently.
*/
+
/* checksum functions */
/*
These functions are not related to compression but are exported
- anyway because they might be useful in applications using the
- compression library.
+ anyway because they might be useful in applications using the compression
+ library.
*/
ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
/*
Update a running Adler-32 checksum with the bytes buf[0..len-1] and
- return the updated checksum. If buf is NULL, this function returns
- the required initial value for the checksum.
- An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
- much faster. Usage example:
+ return the updated checksum. If buf is Z_NULL, this function returns the
+ required initial value for the checksum.
+
+ An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
+ much faster.
+
+ Usage example:
uLong adler = adler32(0L, Z_NULL, 0);
@@ -1273,9 +1486,10 @@ ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
if (adler != original_adler) error();
*/
+/*
ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,
z_off_t len2));
-/*
+
Combine two Adler-32 checksums into one. For two sequences of bytes, seq1
and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for
each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of
@@ -1285,9 +1499,11 @@ ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,
ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
/*
Update a running CRC-32 with the bytes buf[0..len-1] and return the
- updated CRC-32. If buf is NULL, this function returns the required initial
- value for the for the crc. Pre- and post-conditioning (one's complement) is
- performed within this function so it shouldn't be done by the application.
+ updated CRC-32. If buf is Z_NULL, this function returns the required
+ initial value for the for the crc. Pre- and post-conditioning (one's
+ complement) is performed within this function so it shouldn't be done by the
+ application.
+
Usage example:
uLong crc = crc32(0L, Z_NULL, 0);
@@ -1298,9 +1514,9 @@ ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
if (crc != original_crc) error();
*/
+/*
ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));
-/*
Combine two CRC-32 check values into one. For two sequences of bytes,
seq1 and seq2 with lengths len1 and len2, CRC-32 check values were
calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32
@@ -1339,19 +1555,58 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
#define inflateBackInit(strm, windowBits, window) \
inflateBackInit_((strm), (windowBits), (window), \
- ZLIB_VERSION, sizeof(z_stream))
+ ZLIB_VERSION, sizeof(z_stream))
+/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or
+ * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if
+ * both are true, the application gets the *64 functions, and the regular
+ * functions are changed to 64 bits) -- in case these are set on systems
+ * without large file support, _LFS64_LARGEFILE must also be true
+ */
+#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
+ ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
+ ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));
+ ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));
+ ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));
+ ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t));
+ ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t));
+#endif
+#if !defined(ZLIB_INTERNAL) && _FILE_OFFSET_BITS-0 == 64 && _LFS64_LARGEFILE-0
+# define gzopen gzopen64
+# define gzseek gzseek64
+# define gztell gztell64
+# define gzoffset gzoffset64
+# define adler32_combine adler32_combine64
+# define crc32_combine crc32_combine64
+# ifdef _LARGEFILE64_SOURCE
+ ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
+ ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int));
+ ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile));
+ ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile));
+ ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
+ ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
+# endif
+#else
+ ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *));
+ ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int));
+ ZEXTERN z_off_t ZEXPORT gztell OF((gzFile));
+ ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile));
+ ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
+ ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
+#endif
+
+/* hack for buggy compilers */
#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL)
- struct internal_state {int dummy;}; /* hack for buggy compilers */
+ struct internal_state {int dummy;};
#endif
+/* undocumented functions */
ZEXTERN const char * ZEXPORT zError OF((int));
-ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z));
+ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp));
ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void));
+ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int));
-#ifdef __cplusplus
-}
-#endif
+ABC_NAMESPACE_HEADER_END
#endif /* ZLIB_H */
diff --git a/src/misc/zlib/zutil.c b/src/misc/zlib/zutil.c
index d55f5948..17a906d8 100644
--- a/src/misc/zlib/zutil.c
+++ b/src/misc/zlib/zutil.c
@@ -1,12 +1,21 @@
/* zutil.c -- target dependent utility functions for the compression library
- * Copyright (C) 1995-2005 Jean-loup Gailly.
+ * Copyright (C) 1995-2005, 2010 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* @(#) $Id$ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "abc_global.h"
+
#include "zutil.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
#ifndef NO_DUMMY_DECL
struct internal_state {int dummy;}; /* for buggy compilers */
#endif
@@ -34,25 +43,25 @@ uLong ZEXPORT zlibCompileFlags()
uLong flags;
flags = 0;
- switch (sizeof(uInt)) {
+ switch ((int)(sizeof(uInt))) {
case 2: break;
case 4: flags += 1; break;
case 8: flags += 2; break;
default: flags += 3;
}
- switch (sizeof(uLong)) {
+ switch ((int)(sizeof(uLong))) {
case 2: break;
case 4: flags += 1 << 2; break;
case 8: flags += 2 << 2; break;
default: flags += 3 << 2;
}
- switch (sizeof(voidpf)) {
+ switch ((int)(sizeof(voidpf))) {
case 2: break;
case 4: flags += 1 << 4; break;
case 8: flags += 2 << 4; break;
default: flags += 3 << 4;
}
- switch (sizeof(z_off_t)) {
+ switch ((int)(sizeof(z_off_t))) {
case 2: break;
case 4: flags += 1 << 6; break;
case 8: flags += 2 << 6; break;
@@ -117,9 +126,9 @@ uLong ZEXPORT zlibCompileFlags()
# ifndef verbose
# define verbose 0
# endif
-int z_verbose = verbose;
+int ZLIB_INTERNAL z_verbose = verbose;
-void z_error (m)
+void ZLIB_INTERNAL z_error (m)
char *m;
{
fprintf(stderr, "%s\n", m);
@@ -130,8 +139,7 @@ void z_error (m)
/* exported to allow conversion of error code to string for compress() and
* uncompress()
*/
-const char * ZEXPORT zError(err)
- int err;
+const char * ZEXPORT zError(int err)
{
return ERR_MSG(err);
}
@@ -146,10 +154,7 @@ const char * ZEXPORT zError(err)
#ifndef HAVE_MEMCPY
-void zmemcpy(dest, source, len)
- Bytef* dest;
- const Bytef* source;
- uInt len;
+void ZLIB_INTERNAL zmemcpy(Bytef* dest, const Bytef* source, uInt len)
{
if (len == 0) return;
do {
@@ -157,10 +162,7 @@ void zmemcpy(dest, source, len)
} while (--len != 0);
}
-int zmemcmp(s1, s2, len)
- const Bytef* s1;
- const Bytef* s2;
- uInt len;
+int ZLIB_INTERNAL zmemcmp(const Bytef* s1, const Bytef* s2, uInt len)
{
uInt j;
@@ -170,9 +172,7 @@ int zmemcmp(s1, s2, len)
return 0;
}
-void zmemzero(dest, len)
- Bytef* dest;
- uInt len;
+void ZLIB_INTERNAL zmemzero(Bytef* dest, uInt len)
{
if (len == 0) return;
do {
@@ -213,7 +213,7 @@ local ptr_table table[MAX_PTR];
* a protected system like OS/2. Use Microsoft C instead.
*/
-voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
+voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size)
{
voidpf buf = opaque; /* just to make some compilers happy */
ulg bsize = (ulg)items*size;
@@ -237,7 +237,7 @@ voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
return buf;
}
-void zcfree (voidpf opaque, voidpf ptr)
+void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
{
int n;
if (*(ush*)&ptr != 0) { /* object < 64K */
@@ -272,13 +272,13 @@ void zcfree (voidpf opaque, voidpf ptr)
# define _hfree hfree
#endif
-voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
+voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, uInt items, uInt size)
{
if (opaque) opaque = 0; /* to make compiler happy */
return _halloc((long)items, size);
}
-void zcfree (voidpf opaque, voidpf ptr)
+void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
{
if (opaque) opaque = 0; /* to make compiler happy */
_hfree(ptr);
@@ -297,22 +297,22 @@ extern voidp calloc OF((uInt items, uInt size));
extern void free OF((voidpf ptr));
#endif
-voidpf zcalloc (opaque, items, size)
- voidpf opaque;
- unsigned items;
- unsigned size;
+voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size)
{
if (opaque) items += size - size; /* make compiler happy */
return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
(voidpf)calloc(items, size);
}
-void zcfree (opaque, ptr)
- voidpf opaque;
- voidpf ptr;
+void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
{
free(ptr);
if (opaque) return; /* make compiler happy */
}
#endif /* MY_ZCALLOC */
+
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/misc/zlib/zutil.h b/src/misc/zlib/zutil.h
index b7d5eff8..ad5dc411 100644
--- a/src/misc/zlib/zutil.h
+++ b/src/misc/zlib/zutil.h
@@ -1,5 +1,5 @@
/* zutil.h -- internal interface and configuration of the compression library
- * Copyright (C) 1995-2005 Jean-loup Gailly.
+ * Copyright (C) 1995-2010 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -13,31 +13,23 @@
#ifndef ZUTIL_H
#define ZUTIL_H
-#define ZLIB_INTERNAL
+#if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ)
+# define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
+#else
+# define ZLIB_INTERNAL
+#endif
+
#include "zlib.h"
#ifdef STDC
-# ifndef _WIN32_WCE
+# if !(defined(_WIN32_WCE) && defined(_MSC_VER))
# include <stddef.h>
# endif
# include <string.h>
# include <stdlib.h>
#endif
-#ifdef NO_ERRNO_H
-# ifdef _WIN32_WCE
- /* The Microsoft C Run-Time Library for Windows CE doesn't have
- * errno. We define it as a global variable to simplify porting.
- * Its value is always 0 and should not be used. We rename it to
- * avoid conflict with other libraries that use the same workaround.
- */
-# define errno z_errno
-# endif
- extern int errno;
-#else
-# ifndef _WIN32_WCE
-# include <errno.h>
-# endif
-#endif
+
+ABC_NAMESPACE_HEADER_START
#ifndef local
# define local static
@@ -89,15 +81,19 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
# define OS_CODE 0x00
# if defined(__TURBOC__) || defined(__BORLANDC__)
-# if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
+# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
/* Allow compilation with ANSI keywords only enabled */
void _Cdecl farfree( void *block );
void *_Cdecl farmalloc( unsigned long nbytes );
# else
+ABC_NAMESPACE_HEADER_END
# include <alloc.h>
+ABC_NAMESPACE_HEADER_START
# endif
# else /* MSC or DJGPP */
+ABC_NAMESPACE_HEADER_END
# include <malloc.h>
+ABC_NAMESPACE_HEADER_START
# endif
#endif
@@ -118,14 +114,18 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
#ifdef OS2
# define OS_CODE 0x06
# ifdef M_I86
- #include <malloc.h>
+ABC_NAMESPACE_HEADER_END
+# include <malloc.h>
+ABC_NAMESPACE_HEADER_START
# endif
#endif
#if defined(MACOS) || defined(TARGET_OS_MAC)
# define OS_CODE 0x07
# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
+ABC_NAMESPACE_HEADER_END
# include <unix.h> /* for fdopen */
+ABC_NAMESPACE_HEADER_START
# else
# ifndef fdopen
# define fdopen(fd,mode) NULL /* No fdopen() */
@@ -151,7 +151,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
# define fdopen(fd,mode) NULL /* No fdopen() */
#endif
-#if (defined(_MSC_VER) && (_MSC_VER > 600))
+#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX
# if defined(_WIN32_WCE)
# define fdopen(fd,mode) NULL /* No fdopen() */
# ifndef _PTRDIFF_T_DEFINED
@@ -163,6 +163,18 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
# endif
#endif
+#if defined(__BORLANDC__)
+ #pragma warn -8004
+ #pragma warn -8008
+ #pragma warn -8066
+#endif
+
+/* provide prototypes for these when building zlib without LFS */
+#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0
+ ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
+ ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
+#endif
+
/* common defaults */
#ifndef OS_CODE
@@ -197,7 +209,9 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
# ifdef WIN32
/* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
# if !defined(vsnprintf) && !defined(NO_vsnprintf)
-# define vsnprintf _vsnprintf
+# if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 )
+# define vsnprintf _vsnprintf
+# endif
# endif
# endif
# ifdef __SASC
@@ -232,16 +246,18 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
# define zmemzero(dest, len) memset(dest, 0, len)
# endif
#else
- extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
- extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
- extern void zmemzero OF((Bytef* dest, uInt len));
+ void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
+ int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
+ void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len));
#endif
/* Diagnostic functions */
#ifdef DEBUG
+ ABC_NAMESPACE_HEADER_END
# include <stdio.h>
- extern int z_verbose;
- extern void z_error OF((char *m));
+ABC_NAMESPACE_HEADER_START
+ extern int ZLIB_INTERNAL z_verbose;
+ extern void ZLIB_INTERNAL z_error OF((char *m));
# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
# define Trace(x) {if (z_verbose>=0) fprintf x ;}
# define Tracev(x) {if (z_verbose>0) fprintf x ;}
@@ -258,12 +274,15 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
#endif
-voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
-void zcfree OF((voidpf opaque, voidpf ptr));
+voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items,
+ unsigned size));
+void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr));
#define ZALLOC(strm, items, size) \
(*((strm)->zalloc))((strm)->opaque, (items), (size))
#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
+ABC_NAMESPACE_HEADER_END
+
#endif /* ZUTIL_H */
diff --git a/src/opt/cut/abcCut.c b/src/opt/cut/abcCut.c
index 9bbd5790..3b80fe8d 100644
--- a/src/opt/cut/abcCut.c
+++ b/src/opt/cut/abcCut.c
@@ -21,6 +21,9 @@
#include "abc.h"
#include "cut.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -102,7 +105,7 @@ Cut_Man_t * Abc_NtkCuts( Abc_Ntk_t * pNtk, Cut_Params_t * pParams )
vNodes = Abc_AigDfs( pNtk, 0, 1 ); // collects POs
vChoices = Vec_IntAlloc( 100 );
pProgress = Extra_ProgressBarStart( stdout, Vec_PtrSize(vNodes) );
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
{
// when we reached a CO, it is time to deallocate the cuts
if ( Abc_ObjIsCo(pObj) )
@@ -176,7 +179,7 @@ void Abc_NtkCutsOracle( Abc_Ntk_t * pNtk, Cut_Oracle_t * p )
// compute cuts for internal nodes
vNodes = Abc_AigDfs( pNtk, 0, 1 ); // collects POs
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
{
// when we reached a CO, it is time to deallocate the cuts
if ( Abc_ObjIsCo(pObj) )
@@ -490,3 +493,5 @@ void Abc_NtkPrintCuts_( void * p, Abc_Ntk_t * pNtk, int fSeq )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/cut/cut.h b/src/opt/cut/cut.h
index 394138db..6c497675 100644
--- a/src/opt/cut/cut.h
+++ b/src/opt/cut/cut.h
@@ -21,6 +21,7 @@
#ifndef __CUT_H__
#define __CUT_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -29,9 +30,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
#define CUT_SIZE_MIN 3 // the min K of the K-feasible cut computation
#define CUT_SIZE_MAX 12 // the max K of the K-feasible cut computation
@@ -155,9 +157,11 @@ extern int Cut_CellIsRunning();
extern void Cut_CellDumpToFile();
extern int Cut_CellTruthLookup( unsigned * pTruth, int nVars );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/opt/cut/cutApi.c b/src/opt/cut/cutApi.c
index 980c6b12..1b20437d 100644
--- a/src/opt/cut/cutApi.c
+++ b/src/opt/cut/cutApi.c
@@ -20,6 +20,9 @@
#include "cutInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -43,7 +46,7 @@ Cut_Cut_t * Cut_NodeReadCutsNew( Cut_Man_t * p, int Node )
{
if ( Node >= p->vCutsNew->nSize )
return NULL;
- return Vec_PtrEntry( p->vCutsNew, Node );
+ return (Cut_Cut_t *)Vec_PtrEntry( p->vCutsNew, Node );
}
/**Function*************************************************************
@@ -60,7 +63,7 @@ Cut_Cut_t * Cut_NodeReadCutsNew( Cut_Man_t * p, int Node )
Cut_Cut_t * Cut_NodeReadCutsOld( Cut_Man_t * p, int Node )
{
assert( Node < p->vCutsOld->nSize );
- return Vec_PtrEntry( p->vCutsOld, Node );
+ return (Cut_Cut_t *)Vec_PtrEntry( p->vCutsOld, Node );
}
/**Function*************************************************************
@@ -77,7 +80,7 @@ Cut_Cut_t * Cut_NodeReadCutsOld( Cut_Man_t * p, int Node )
Cut_Cut_t * Cut_NodeReadCutsTemp( Cut_Man_t * p, int Node )
{
assert( Node < p->vCutsTemp->nSize );
- return Vec_PtrEntry( p->vCutsTemp, Node );
+ return (Cut_Cut_t *)Vec_PtrEntry( p->vCutsTemp, Node );
}
/**Function*************************************************************
@@ -195,3 +198,5 @@ void Cut_NodeFreeCuts( Cut_Man_t * p, int Node )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/cut/cutCut.c b/src/opt/cut/cutCut.c
index 94147278..bd0a70b1 100644
--- a/src/opt/cut/cutCut.c
+++ b/src/opt/cut/cutCut.c
@@ -20,6 +20,9 @@
#include "cutInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -357,3 +360,5 @@ void Cut_CutPrintMerge( Cut_Cut_t * pCut, Cut_Cut_t * pCut0, Cut_Cut_t * pCut1 )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/cut/cutExpand.c b/src/opt/cut/cutExpand.c
index d389ef7a..4885f879 100644
--- a/src/opt/cut/cutExpand.c
+++ b/src/opt/cut/cutExpand.c
@@ -20,6 +20,9 @@
#include "cutInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -182,3 +185,5 @@ void Cut_TruthCompose( Cut_Cut_t * pCutF, int Node, Cut_Cut_t * pCutT, Cut_Cut_t
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/cut/cutInt.h b/src/opt/cut/cutInt.h
index 17f268c7..4705c019 100644
--- a/src/opt/cut/cutInt.h
+++ b/src/opt/cut/cutInt.h
@@ -21,6 +21,7 @@
#ifndef __CUT_INT_H__
#define __CUT_INT_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -31,6 +32,9 @@
#include "cut.h"
#include "cutList.h"
+ABC_NAMESPACE_HEADER_START
+
+
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
@@ -149,6 +153,10 @@ extern int Cut_TableReadTime( Cut_HashTable_t * pTable );
extern void Cut_TruthComputeOld( Cut_Cut_t * pCut, Cut_Cut_t * pCut0, Cut_Cut_t * pCut1, int fCompl0, int fCompl1 );
extern void Cut_TruthCompute( Cut_Man_t * p, Cut_Cut_t * pCut, Cut_Cut_t * pCut0, Cut_Cut_t * pCut1, int fCompl0, int fCompl1 );
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif
////////////////////////////////////////////////////////////////////////
diff --git a/src/opt/cut/cutList.h b/src/opt/cut/cutList.h
index a03ec9d5..0f0ccedf 100644
--- a/src/opt/cut/cutList.h
+++ b/src/opt/cut/cutList.h
@@ -21,6 +21,10 @@
#ifndef __CUT_LIST_H__
#define __CUT_LIST_H__
+
+ABC_NAMESPACE_HEADER_START
+
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -199,6 +203,10 @@ static inline Cut_Cut_t * Cut_ListFinish( Cut_List_t * p )
return pHead;
}
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif
////////////////////////////////////////////////////////////////////////
diff --git a/src/opt/cut/cutMan.c b/src/opt/cut/cutMan.c
index 28264e33..4a9f8f4b 100644
--- a/src/opt/cut/cutMan.c
+++ b/src/opt/cut/cutMan.c
@@ -20,6 +20,9 @@
#include "cutInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -313,3 +316,5 @@ void Cut_ManIncrementDagNodes( Cut_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/cut/cutMerge.c b/src/opt/cut/cutMerge.c
index d8a9989c..66c8cadd 100644
--- a/src/opt/cut/cutMerge.c
+++ b/src/opt/cut/cutMerge.c
@@ -20,6 +20,9 @@
#include "cutInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -655,3 +658,5 @@ Cut_Cut_t * Cut_CutMergeTwo5( Cut_Man_t * p, Cut_Cut_t * pCut0, Cut_Cut_t * pCut
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/cut/cutNode.c b/src/opt/cut/cutNode.c
index 633219fd..010e1e00 100644
--- a/src/opt/cut/cutNode.c
+++ b/src/opt/cut/cutNode.c
@@ -20,6 +20,9 @@
#include "cutInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -490,20 +493,20 @@ int Cut_NodeMapping( Cut_Man_t * p, Cut_Cut_t * pCuts, int Node, int Node0, int
// get the fanin cuts
Delay0 = Vec_IntEntry( p->vDelays2, Node0 );
Delay1 = Vec_IntEntry( p->vDelays2, Node1 );
- pCut0 = (Delay0 == 0) ? Vec_PtrEntry( p->vCutsNew, Node0 ) : Vec_PtrEntry( p->vCutsMax, Node0 );
- pCut1 = (Delay1 == 0) ? Vec_PtrEntry( p->vCutsNew, Node1 ) : Vec_PtrEntry( p->vCutsMax, Node1 );
+ pCut0 = (Delay0 == 0) ? (Cut_Cut_t *)Vec_PtrEntry( p->vCutsNew, Node0 ) : (Cut_Cut_t *)Vec_PtrEntry( p->vCutsMax, Node0 );
+ pCut1 = (Delay1 == 0) ? (Cut_Cut_t *)Vec_PtrEntry( p->vCutsNew, Node1 ) : (Cut_Cut_t *)Vec_PtrEntry( p->vCutsMax, Node1 );
if ( Delay0 == Delay1 )
Delay = (Delay0 == 0) ? Delay0 + 1: Delay0;
else if ( Delay0 > Delay1 )
{
Delay = Delay0;
- pCut1 = Vec_PtrEntry( p->vCutsNew, Node1 );
+ pCut1 = (Cut_Cut_t *)Vec_PtrEntry( p->vCutsNew, Node1 );
assert( pCut1->nLeaves == 1 );
}
else // if ( Delay0 < Delay1 )
{
Delay = Delay1;
- pCut0 = Vec_PtrEntry( p->vCutsNew, Node0 );
+ pCut0 = (Cut_Cut_t *)Vec_PtrEntry( p->vCutsNew, Node0 );
assert( pCut0->nLeaves == 1 );
}
// merge the cuts
@@ -544,7 +547,7 @@ int Cut_ManMappingArea_rec( Cut_Man_t * p, int Node )
int i, Counter;
if ( p->vCutsMax == NULL )
return 0;
- pCut = Vec_PtrEntry( p->vCutsMax, Node );
+ pCut = (Cut_Cut_t *)Vec_PtrEntry( p->vCutsMax, Node );
if ( pCut == NULL || pCut->nLeaves == 1 )
return 0;
Counter = 0;
@@ -729,7 +732,7 @@ Cut_Cut_t * Cut_NodeUnionCuts( Cut_Man_t * p, Vec_Int_t * vNodes )
Vec_IntForEachEntryStart( vNodes, Node, k, i+1 )
Cut_NodeFreeCuts( p, Node );
// recycle the saved cuts of other nodes
- Vec_PtrForEachEntry( p->vTemp, pList, k )
+ Vec_PtrForEachEntry( Cut_Cut_t *, p->vTemp, pList, k )
Cut_ListForEachCutSafe( pList, pCut, pCut2 )
Cut_CutRecycle( p, pCut );
goto finish;
@@ -737,7 +740,7 @@ Cut_Cut_t * Cut_NodeUnionCuts( Cut_Man_t * p, Vec_Int_t * vNodes )
}
}
// collect larger cuts next
- Vec_PtrForEachEntry( p->vTemp, pList, i )
+ Vec_PtrForEachEntry( Cut_Cut_t *, p->vTemp, pList, i )
{
Cut_ListForEachCutSafe( pList, pCut, pCut2 )
{
@@ -756,7 +759,7 @@ Cut_Cut_t * Cut_NodeUnionCuts( Cut_Man_t * p, Vec_Int_t * vNodes )
Cut_ListForEachCutSafe( pListStart, pCut, pCut2 )
Cut_CutRecycle( p, pCut );
// recycle the saved cuts of other nodes
- Vec_PtrForEachEntryStart( p->vTemp, pList, k, i+1 )
+ Vec_PtrForEachEntryStart( Cut_Cut_t *, p->vTemp, pList, k, i+1 )
Cut_ListForEachCutSafe( pList, pCut, pCut2 )
Cut_CutRecycle( p, pCut );
goto finish;
@@ -885,7 +888,7 @@ Cut_Cut_t * Cut_NodeUnionCutsSeq( Cut_Man_t * p, Vec_Int_t * vNodes, int CutSetN
Vec_IntForEachEntryStart( vNodes, Node, k, i+1 )
Cut_NodeFreeCuts( p, Node );
// recycle the saved cuts of other nodes
- Vec_PtrForEachEntry( p->vTemp, pList, k )
+ Vec_PtrForEachEntry( Cut_Cut_t *, p->vTemp, pList, k )
Cut_ListForEachCutSafe( pList, pCut, pCut2 )
Cut_CutRecycle( p, pCut );
goto finish;
@@ -893,7 +896,7 @@ Cut_Cut_t * Cut_NodeUnionCutsSeq( Cut_Man_t * p, Vec_Int_t * vNodes, int CutSetN
}
}
// collect larger cuts next
- Vec_PtrForEachEntry( p->vTemp, pList, i )
+ Vec_PtrForEachEntry( Cut_Cut_t *, p->vTemp, pList, i )
{
Cut_ListForEachCutSafe( pList, pCut, pCut2 )
{
@@ -925,7 +928,7 @@ Cut_Cut_t * Cut_NodeUnionCutsSeq( Cut_Man_t * p, Vec_Int_t * vNodes, int CutSetN
Cut_ListForEachCutSafe( pListStart, pCut, pCut2 )
Cut_CutRecycle( p, pCut );
// recycle the saved cuts of other nodes
- Vec_PtrForEachEntryStart( p->vTemp, pList, k, i+1 )
+ Vec_PtrForEachEntryStart( Cut_Cut_t *, p->vTemp, pList, k, i+1 )
Cut_ListForEachCutSafe( pList, pCut, pCut2 )
Cut_CutRecycle( p, pCut );
goto finish;
@@ -997,3 +1000,5 @@ int Cut_CutListVerify( Cut_Cut_t * pList )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/cut/cutOracle.c b/src/opt/cut/cutOracle.c
index 32798f4f..f7883e3f 100644
--- a/src/opt/cut/cutOracle.c
+++ b/src/opt/cut/cutOracle.c
@@ -20,6 +20,9 @@
#include "cutInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -133,7 +136,7 @@ void Cut_OracleStop( Cut_Oracle_t * p )
ABC_PRT( "Total time ", p->timeTotal );
}
- Vec_PtrForEachEntry( p->vCutsNew, pCut, i )
+ Vec_PtrForEachEntry( Cut_Cut_t *, p->vCutsNew, pCut, i )
if ( p->vCuts0 ) Vec_PtrFree( p->vCuts0 );
if ( p->vCuts1 ) Vec_PtrFree( p->vCuts1 );
@@ -327,8 +330,8 @@ Cut_Cut_t * Cut_OracleComputeCuts( Cut_Oracle_t * p, int Node, int Node0, int No
int clk = clock();
// get the cuts of the children
- pList0 = Vec_PtrEntry( p->vCutsNew, Node0 );
- pList1 = Vec_PtrEntry( p->vCutsNew, Node1 );
+ pList0 = (Cut_Cut_t *)Vec_PtrEntry( p->vCutsNew, Node0 );
+ pList1 = (Cut_Cut_t *)Vec_PtrEntry( p->vCutsNew, Node1 );
assert( pList0 && pList1 );
// get the complemented attribute of the cut
@@ -355,8 +358,8 @@ Cut_Cut_t * Cut_OracleComputeCuts( Cut_Oracle_t * p, int Node, int Node0, int No
for ( i = 1; i < nCuts; i++ )
{
Entry = Vec_IntEntry( p->vCutPairs, iCutStart + i );
- pCut0 = Vec_PtrEntry( p->vCuts0, Entry & 0xFFFF );
- pCut1 = Vec_PtrEntry( p->vCuts1, Entry >> 16 );
+ pCut0 = (Cut_Cut_t *)Vec_PtrEntry( p->vCuts0, Entry & 0xFFFF );
+ pCut1 = (Cut_Cut_t *)Vec_PtrEntry( p->vCuts1, Entry >> 16 );
pCut = Cut_CutMerge( p, pCut0, pCut1 );
*ppTail = pCut;
ppTail = &pCut->pNext;
@@ -387,7 +390,7 @@ p->timeTotal += clock() - clk;
void Cut_OracleFreeCuts( Cut_Oracle_t * p, int Node )
{
Cut_Cut_t * pList, * pCut, * pCut2;
- pList = Vec_PtrEntry( p->vCutsNew, Node );
+ pList = (Cut_Cut_t *)Vec_PtrEntry( p->vCutsNew, Node );
if ( pList == NULL )
return;
Cut_ListForEachCutSafe( pList, pCut, pCut2 )
@@ -422,3 +425,5 @@ void Cut_OracleTryDroppingCuts( Cut_Oracle_t * p, int Node )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/cut/cutPre22.c b/src/opt/cut/cutPre22.c
index bda612f7..fdb9bd8c 100644
--- a/src/opt/cut/cutPre22.c
+++ b/src/opt/cut/cutPre22.c
@@ -20,6 +20,9 @@
#include "cutInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -773,7 +776,7 @@ Cut_CMan_t * Cut_CManStart()
p = ABC_ALLOC( Cut_CMan_t, 1 );
memset( p, 0, sizeof(Cut_CMan_t) );
// start the table and the memory manager
- p->tTable = st_init_table(st_ptrcmp,st_ptrhash);
+ p->tTable = st_init_table(st_ptrcmp, st_ptrhash);;
p->pMem = Extra_MmFixedStart( sizeof(Cut_Cell_t) );
// set elementary truth tables
for ( k = 0; k < CUT_CELL_MVAR; k++ )
@@ -986,3 +989,5 @@ int Cut_CellTruthLookup( unsigned * pTruth, int nVars )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/cut/cutSeq.c b/src/opt/cut/cutSeq.c
index d36f94f7..3f671d24 100644
--- a/src/opt/cut/cutSeq.c
+++ b/src/opt/cut/cutSeq.c
@@ -20,6 +20,9 @@
#include "cutInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -225,3 +228,5 @@ void Cut_NodeOldTransferToNew( Cut_Man_t * p, int Node )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/cut/cutTruth.c b/src/opt/cut/cutTruth.c
index 6ecf20e4..3cbee3f6 100644
--- a/src/opt/cut/cutTruth.c
+++ b/src/opt/cut/cutTruth.c
@@ -20,6 +20,9 @@
#include "cutInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*
Truth tables computed in this package are represented as bit-strings
stored in the cut data structure. Cuts of any number of inputs have
@@ -225,3 +228,5 @@ void Cut_TruthCompute( Cut_Man_t * p, Cut_Cut_t * pCut, Cut_Cut_t * pCut0, Cut_C
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/dec/dec.h b/src/opt/dec/dec.h
index 4042ac65..543fabf1 100644
--- a/src/opt/dec/dec.h
+++ b/src/opt/dec/dec.h
@@ -21,6 +21,7 @@
#ifndef __DEC_H__
#define __DEC_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -29,9 +30,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -50,7 +52,8 @@ struct Dec_Node_t_
Dec_Edge_t eEdge0; // the left child of the node
Dec_Edge_t eEdge1; // the right child of the node
// other info
- void * pFunc; // the function of the node (BDD or AIG)
+ union { int iFunc; // the literal of the node (AIG)
+ void * pFunc; }; // the function of the node (BDD or AIG)
unsigned Level : 14; // the level of this node in the global AIG
// printing info
unsigned fNodeOr : 1; // marks the original OR node
@@ -177,10 +180,13 @@ static inline Dec_Edge_t Dec_IntToEdge( unsigned Edge )
SeeAlso []
***********************************************************************/
+static inline unsigned Dec_EdgeToInt_( Dec_Edge_t m ) { union { Dec_Edge_t x; unsigned y; } v; v.x = m; return v.y; }
+/*
static inline unsigned Dec_EdgeToInt_( Dec_Edge_t eEdge )
{
return *(unsigned *)&eEdge;
}
+*/
/**Function*************************************************************
@@ -193,10 +199,13 @@ static inline unsigned Dec_EdgeToInt_( Dec_Edge_t eEdge )
SeeAlso []
***********************************************************************/
+static inline Dec_Edge_t Dec_IntToEdge_( unsigned m ) { union { Dec_Edge_t x; unsigned y; } v; v.y = m; return v.x; }
+/*
static inline Dec_Edge_t Dec_IntToEdge_( unsigned Edge )
{
return *(Dec_Edge_t *)&Edge;
}
+*/
/**Function*************************************************************
@@ -702,9 +711,11 @@ static inline Dec_Edge_t Dec_GraphAddNodeMux( Dec_Graph_t * pGraph, Dec_Edge_t e
return eNode;
}
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/opt/dec/decAbc.c b/src/opt/dec/decAbc.c
index 158dc70a..24bfc9a8 100644
--- a/src/opt/dec/decAbc.c
+++ b/src/opt/dec/decAbc.c
@@ -20,6 +20,9 @@
#include "dec.h"
#include "ivy.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -50,16 +53,16 @@ Abc_Obj_t * Dec_GraphToNetwork( Abc_Ntk_t * pNtk, Dec_Graph_t * pGraph )
return Abc_ObjNotCond( Abc_AigConst1(pNtk), Dec_GraphIsComplement(pGraph) );
// check for a literal
if ( Dec_GraphIsVar(pGraph) )
- return Abc_ObjNotCond( Dec_GraphVar(pGraph)->pFunc, Dec_GraphIsComplement(pGraph) );
+ return Abc_ObjNotCond( (Abc_Obj_t *)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 = Abc_ObjNotCond( Dec_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl );
- pAnd1 = Abc_ObjNotCond( Dec_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl );
- pNode->pFunc = Abc_AigAnd( pNtk->pManFunc, pAnd0, pAnd1 );
+ pAnd0 = Abc_ObjNotCond( (Abc_Obj_t *)Dec_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl );
+ pAnd1 = Abc_ObjNotCond( (Abc_Obj_t *)Dec_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl );
+ pNode->pFunc = Abc_AigAnd( (Abc_Aig_t *)pNtk->pManFunc, pAnd0, pAnd1 );
}
// complement the result if necessary
- return Abc_ObjNotCond( pNode->pFunc, Dec_GraphIsComplement(pGraph) );
+ return Abc_ObjNotCond( (Abc_Obj_t *)pNode->pFunc, Dec_GraphIsComplement(pGraph) );
}
/**Function*************************************************************
@@ -131,20 +134,20 @@ Abc_Obj_t * Dec_GraphToNetworkNoStrash( Abc_Ntk_t * pNtk, Dec_Graph_t * pGraph )
return Abc_ObjNotCond( Abc_AigConst1(pNtk), Dec_GraphIsComplement(pGraph) );
// check for a literal
if ( Dec_GraphIsVar(pGraph) )
- return Abc_ObjNotCond( Dec_GraphVar(pGraph)->pFunc, Dec_GraphIsComplement(pGraph) );
+ return Abc_ObjNotCond( (Abc_Obj_t *)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 = Abc_ObjNotCond( Dec_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl );
- pAnd1 = Abc_ObjNotCond( Dec_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl );
-// pNode->pFunc = Abc_AigAnd( pNtk->pManFunc, pAnd0, pAnd1 );
+ pAnd0 = Abc_ObjNotCond( (Abc_Obj_t *)Dec_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl );
+ pAnd1 = Abc_ObjNotCond( (Abc_Obj_t *)Dec_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl );
+// pNode->pFunc = Abc_AigAnd( (Abc_Aig_t *)pNtk->pManFunc, pAnd0, pAnd1 );
pAnd = Abc_NtkCreateNode( pNtk );
Abc_ObjAddFanin( pAnd, pAnd0 );
Abc_ObjAddFanin( pAnd, pAnd1 );
pNode->pFunc = pAnd;
}
// complement the result if necessary
- return Abc_ObjNotCond( pNode->pFunc, Dec_GraphIsComplement(pGraph) );
+ return Abc_ObjNotCond( (Abc_Obj_t *)pNode->pFunc, Dec_GraphIsComplement(pGraph) );
}
/**Function*************************************************************
@@ -163,7 +166,7 @@ Abc_Obj_t * Dec_GraphToNetworkNoStrash( Abc_Ntk_t * pNtk, Dec_Graph_t * pGraph )
***********************************************************************/
int Dec_GraphToNetworkCount( Abc_Obj_t * pRoot, Dec_Graph_t * pGraph, int NodeMax, int LevelMax )
{
- Abc_Aig_t * pMan = pRoot->pNtk->pManFunc;
+ Abc_Aig_t * pMan = (Abc_Aig_t *)pRoot->pNtk->pManFunc;
Dec_Node_t * pNode, * pNode0, * pNode1;
Abc_Obj_t * pAnd, * pAnd0, * pAnd1;
int i, Counter, LevelNew, LevelOld;
@@ -172,7 +175,7 @@ int Dec_GraphToNetworkCount( Abc_Obj_t * pRoot, Dec_Graph_t * pGraph, int NodeMa
return 0;
// set the levels of the leaves
Dec_GraphForEachLeaf( pGraph, pNode, i )
- pNode->Level = Abc_ObjRegular(pNode->pFunc)->Level;
+ pNode->Level = Abc_ObjRegular((Abc_Obj_t *)pNode->pFunc)->Level;
// compute the AIG size after adding the internal nodes
Counter = 0;
Dec_GraphForEachNode( pGraph, pNode, i )
@@ -181,8 +184,8 @@ int Dec_GraphToNetworkCount( Abc_Obj_t * pRoot, Dec_Graph_t * pGraph, int NodeMa
pNode0 = Dec_GraphNode( pGraph, pNode->eEdge0.Node );
pNode1 = Dec_GraphNode( pGraph, pNode->eEdge1.Node );
// get the AIG nodes corresponding to the children
- pAnd0 = pNode0->pFunc;
- pAnd1 = pNode1->pFunc;
+ pAnd0 = (Abc_Obj_t *)pNode0->pFunc;
+ pAnd1 = (Abc_Obj_t *)pNode1->pFunc;
if ( pAnd0 && pAnd1 )
{
// if they are both present, find the resulting node
@@ -234,7 +237,7 @@ int Dec_GraphToNetworkCount( Abc_Obj_t * pRoot, Dec_Graph_t * pGraph, int NodeMa
SeeAlso []
***********************************************************************/
-void Dec_GraphUpdateNetwork( Abc_Obj_t * pRoot, Dec_Graph_t * pGraph, bool fUpdateLevel, int nGain )
+void Dec_GraphUpdateNetwork( Abc_Obj_t * pRoot, Dec_Graph_t * pGraph, int fUpdateLevel, int nGain )
{
extern Abc_Obj_t * Dec_GraphToNetwork( Abc_Ntk_t * pNtk, Dec_Graph_t * pGraph );
Abc_Obj_t * pRootNew;
@@ -244,7 +247,7 @@ void Dec_GraphUpdateNetwork( Abc_Obj_t * pRoot, Dec_Graph_t * pGraph, bool fUpda
// create the new structure of nodes
pRootNew = Dec_GraphToNetwork( pNtk, pGraph );
// remove the old nodes
- Abc_AigReplace( pNtk->pManFunc, pRoot, pRootNew, fUpdateLevel );
+ Abc_AigReplace( (Abc_Aig_t *)pNtk->pManFunc, pRoot, pRootNew, fUpdateLevel );
// compare the gains
nNodesNew = Abc_NtkNodeNum(pNtk);
assert( nGain <= nNodesOld - nNodesNew );
@@ -272,16 +275,16 @@ Hop_Obj_t * Dec_GraphToNetworkAig( Hop_Man_t * pMan, Dec_Graph_t * pGraph )
return Hop_NotCond( Hop_ManConst1(pMan), Dec_GraphIsComplement(pGraph) );
// check for a literal
if ( Dec_GraphIsVar(pGraph) )
- return Hop_NotCond( Dec_GraphVar(pGraph)->pFunc, Dec_GraphIsComplement(pGraph) );
+ return Hop_NotCond( (Hop_Obj_t *)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 = 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 );
+ pAnd0 = Hop_NotCond( (Hop_Obj_t *)Dec_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl );
+ pAnd1 = Hop_NotCond( (Hop_Obj_t *)Dec_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl );
pNode->pFunc = Hop_And( pMan, pAnd0, pAnd1 );
}
// complement the result if necessary
- return Hop_NotCond( pNode->pFunc, Dec_GraphIsComplement(pGraph) );
+ return Hop_NotCond( (Hop_Obj_t *)pNode->pFunc, Dec_GraphIsComplement(pGraph) );
}
/**Function*************************************************************
@@ -333,16 +336,16 @@ Ivy_Obj_t * Dec_GraphToNetworkIvy( Ivy_Man_t * pMan, Dec_Graph_t * pGraph )
return Ivy_NotCond( Ivy_ManConst1(pMan), Dec_GraphIsComplement(pGraph) );
// check for a literal
if ( Dec_GraphIsVar(pGraph) )
- return Ivy_NotCond( Dec_GraphVar(pGraph)->pFunc, Dec_GraphIsComplement(pGraph) );
+ return Ivy_NotCond( (Ivy_Obj_t *)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 = Ivy_NotCond( Dec_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl );
- pAnd1 = Ivy_NotCond( Dec_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl );
+ pAnd0 = Ivy_NotCond( (Ivy_Obj_t *)Dec_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl );
+ pAnd1 = Ivy_NotCond( (Ivy_Obj_t *)Dec_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl );
pNode->pFunc = Ivy_And( pMan, pAnd0, pAnd1 );
}
// complement the result if necessary
- return Ivy_NotCond( pNode->pFunc, Dec_GraphIsComplement(pGraph) );
+ return Ivy_NotCond( (Ivy_Obj_t *)pNode->pFunc, Dec_GraphIsComplement(pGraph) );
}
@@ -351,3 +354,5 @@ Ivy_Obj_t * Dec_GraphToNetworkIvy( Ivy_Man_t * pMan, Dec_Graph_t * pGraph )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/dec/decFactor.c b/src/opt/dec/decFactor.c
index 16e65b79..aa9d9c8a 100644
--- a/src/opt/dec/decFactor.c
+++ b/src/opt/dec/decFactor.c
@@ -21,6 +21,9 @@
#include "mvc.h"
#include "dec.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -57,7 +60,7 @@ Dec_Graph_t * Dec_Factor( char * pSop )
// derive the cover from the SOP representation
pCover = Dec_ConvertSopToMvc( pSop );
- // make sure the cover is CCS ABC_FREE (should be done before CST)
+ // make sure the cover is CCS free (should be done before CST)
Mvc_CoverContain( pCover );
// check for trivial functions
if ( Mvc_CoverIsEmpty(pCover) )
@@ -183,7 +186,7 @@ Dec_Edge_t Dec_Factor_rec( Dec_Graph_t * pFForm, Mvc_Cover_t * pCover )
***********************************************************************/
Dec_Edge_t Dec_FactorLF_rec( Dec_Graph_t * pFForm, Mvc_Cover_t * pCover, Mvc_Cover_t * pSimple )
{
- Dec_Man_t * pManDec = Abc_FrameReadManDec();
+ Dec_Man_t * pManDec = (Dec_Man_t *)Abc_FrameReadManDec();
Vec_Int_t * vEdgeLits = pManDec->vLits;
Mvc_Cover_t * pDiv, * pQuo, * pRem;
Dec_Edge_t eNodeDiv, eNodeQuo, eNodeRem;
@@ -228,7 +231,7 @@ Dec_Edge_t Dec_FactorLF_rec( Dec_Graph_t * pFForm, Mvc_Cover_t * pCover, Mvc_Cov
***********************************************************************/
Dec_Edge_t Dec_FactorTrivial( Dec_Graph_t * pFForm, Mvc_Cover_t * pCover )
{
- Dec_Man_t * pManDec = Abc_FrameReadManDec();
+ Dec_Man_t * pManDec = (Dec_Man_t *)Abc_FrameReadManDec();
Vec_Int_t * vEdgeCubes = pManDec->vCubes;
Vec_Int_t * vEdgeLits = pManDec->vLits;
Dec_Edge_t eNode;
@@ -321,8 +324,8 @@ Dec_Edge_t Dec_FactorTrivialTree_rec( Dec_Graph_t * pFForm, Dec_Edge_t * peNodes
***********************************************************************/
Mvc_Cover_t * Dec_ConvertSopToMvc( char * pSop )
{
- Dec_Man_t * pManDec = Abc_FrameReadManDec();
- Mvc_Manager_t * pMem = pManDec->pMvcMem;
+ Dec_Man_t * pManDec = (Dec_Man_t *)Abc_FrameReadManDec();
+ Mvc_Manager_t * pMem = (Mvc_Manager_t *)pManDec->pMvcMem;
Mvc_Cover_t * pMvc;
Mvc_Cube_t * pMvcCube;
char * pCube;
@@ -364,7 +367,7 @@ Mvc_Cover_t * Dec_ConvertSopToMvc( char * pSop )
int Dec_FactorVerify( char * pSop, Dec_Graph_t * pFForm )
{
extern DdNode * Dec_GraphDeriveBdd( DdManager * dd, Dec_Graph_t * pGraph );
- DdManager * dd = Abc_FrameReadManDd();
+ DdManager * dd = (DdManager *)Abc_FrameReadManDd();
DdNode * bFunc1, * bFunc2;
int RetValue;
bFunc1 = Abc_ConvertSopToBdd( dd, pSop ); Cudd_Ref( bFunc1 );
@@ -390,3 +393,5 @@ int Dec_FactorVerify( char * pSop, Dec_Graph_t * pFForm )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/dec/decMan.c b/src/opt/dec/decMan.c
index 63a96966..8b6fae65 100644
--- a/src/opt/dec/decMan.c
+++ b/src/opt/dec/decMan.c
@@ -20,6 +20,9 @@
#include "mvc.h"
#include "dec.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -66,7 +69,7 @@ Dec_Man_t * Dec_ManStart()
***********************************************************************/
void Dec_ManStop( Dec_Man_t * p )
{
- Mvc_ManagerFree( p->pMvcMem );
+ Mvc_ManagerFree( (Mvc_Manager_t *)p->pMvcMem );
Vec_IntFree( p->vCubes );
Vec_IntFree( p->vLits );
ABC_FREE( p->puCanons );
@@ -81,3 +84,5 @@ void Dec_ManStop( Dec_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/dec/decPrint.c b/src/opt/dec/decPrint.c
index 2d8f09b3..3cc0f811 100644
--- a/src/opt/dec/decPrint.c
+++ b/src/opt/dec/decPrint.c
@@ -19,6 +19,9 @@
#include "abc.h"
#include "dec.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -282,3 +285,5 @@ int Dec_GraphPrintOutputName( FILE * pFile, char * pNameOut, int fCompl )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/dec/decUtil.c b/src/opt/dec/decUtil.c
index b8ae4b8a..adf216f6 100644
--- a/src/opt/dec/decUtil.c
+++ b/src/opt/dec/decUtil.c
@@ -19,6 +19,9 @@
#include "abc.h"
#include "dec.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -64,13 +67,13 @@ DdNode * Dec_GraphDeriveBdd( DdManager * dd, Dec_Graph_t * pGraph )
{
bFunc0 = Cudd_NotCond( Dec_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl );
bFunc1 = Cudd_NotCond( Dec_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl );
- pNode->pFunc = Cudd_bddAnd( dd, bFunc0, bFunc1 ); Cudd_Ref( pNode->pFunc );
+ pNode->pFunc = Cudd_bddAnd( dd, bFunc0, bFunc1 ); Cudd_Ref( (DdNode *)pNode->pFunc );
}
// deref the intermediate results
- bFunc = pNode->pFunc; Cudd_Ref( bFunc );
+ bFunc = (DdNode *)pNode->pFunc; Cudd_Ref( bFunc );
Dec_GraphForEachNode( pGraph, pNode, i )
- Cudd_RecursiveDeref( dd, pNode->pFunc );
+ Cudd_RecursiveDeref( dd, (DdNode *)pNode->pFunc );
Cudd_Deref( bFunc );
// complement the result if necessary
@@ -133,3 +136,5 @@ unsigned Dec_GraphDeriveTruth( Dec_Graph_t * pGraph )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/fret/fretFlow.c b/src/opt/fret/fretFlow.c
index 4b2bd936..498cb962 100644
--- a/src/opt/fret/fretFlow.c
+++ b/src/opt/fret/fretFlow.c
@@ -22,6 +22,9 @@
#include "vec.h"
#include "fretime.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -60,7 +63,7 @@ void dfsfast_preorder( Abc_Ntk_t *pNtk ) {
// create reverse timing edges for backward traversal
#if !defined(IGNORE_TIMING)
if (pManMR->maxDelay) {
- Abc_NtkForEachObj( pNtk, pObj, i ) {
+ Vec_PtrForEachEntry( Abc_Obj_t *, pNtk, pObj, i ) {
Vec_PtrForEachEntry( FTIMEEDGES(pObj), pNext, j ) {
vTimeIn = FDATA(pNext)->vNodes;
if (!vTimeIn) {
@@ -77,7 +80,7 @@ void dfsfast_preorder( Abc_Ntk_t *pNtk ) {
memset(Vec_IntArray(pManMR->vSinkDistHist), 0, sizeof(int)*Vec_IntSize(pManMR->vSinkDistHist));
// seed queue : latches, PIOs, and blocks
- Abc_NtkForEachObj( pNtk, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, pNtk, pObj, i )
if (Abc_ObjIsPo(pObj) ||
Abc_ObjIsLatch(pObj) ||
(pManMR->fIsForward && FTEST(pObj, BLOCK_OR_CONS) & pManMR->constraintMask)) {
@@ -180,7 +183,7 @@ void dfsfast_preorder( Abc_Ntk_t *pNtk ) {
// free time edges
#if !defined(IGNORE_TIMING)
if (pManMR->maxDelay) {
- Abc_NtkForEachObj( pNtk, pObj, i ) {
+ Vec_PtrForEachEntry( Abc_Obj_t *, pNtk, pObj, i ) {
vTimeIn = FDATA(pObj)->vNodes;
if (vTimeIn) {
Vec_PtrFree(vTimeIn);
@@ -190,7 +193,7 @@ void dfsfast_preorder( Abc_Ntk_t *pNtk ) {
}
#endif
- Abc_NtkForEachObj( pNtk, pObj, i ) {
+ Vec_PtrForEachEntry( Abc_Obj_t *, pNtk, pObj, i ) {
Vec_IntAddToEntry(pManMR->vSinkDistHist, FDATA(pObj)->r_dist, 1);
Vec_IntAddToEntry(pManMR->vSinkDistHist, FDATA(pObj)->e_dist, 1);
@@ -695,3 +698,5 @@ int dfsplain_r( Abc_Obj_t *pObj, Abc_Obj_t *pPred ) {
#endif
return 1;
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/fret/fretInit.c b/src/opt/fret/fretInit.c
index 0c7b1e29..ce9adefa 100644
--- a/src/opt/fret/fretInit.c
+++ b/src/opt/fret/fretInit.c
@@ -25,6 +25,9 @@
#include "mio.h"
#include "hop.h"
+ABC_NAMESPACE_IMPL_START
+
+
#undef DEBUG_PRINT_INIT_NTK
@@ -698,7 +701,7 @@ void Abc_FlowRetime_UpdateBackwardInit( Abc_Ntk_t * pNtk ) {
}
// recursively build init network
- Vec_PtrForEachEntry( vBo, pOrigObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vBo, pOrigObj, i )
Abc_FlowRetime_UpdateBackwardInit_rec( pOrigObj );
// clear flags
@@ -759,9 +762,9 @@ Abc_Obj_t *Abc_FlowRetime_CopyNodeToInitNtk( Abc_Obj_t *pOrigObj ) {
fCompl[0] = pOrigObj->fCompl0 ? 1 : 0;
fCompl[1] = pOrigObj->fCompl1 ? 1 : 0;
- pData = Abc_SopCreateAnd( pInitNtk->pManFunc, 2, fCompl );
+ pData = Abc_SopCreateAnd( (Extra_MmFlex_t *)pInitNtk->pManFunc, 2, fCompl );
assert(pData);
- pInitObj->pData = Abc_SopRegister( pInitNtk->pManFunc, pData );
+ pInitObj->pData = Abc_SopRegister( (Extra_MmFlex_t *)pInitNtk->pManFunc, pData );
}
// (ii) mapped node -> SOP node
@@ -779,7 +782,7 @@ Abc_Obj_t *Abc_FlowRetime_CopyNodeToInitNtk( Abc_Obj_t *pOrigObj ) {
pData = Mio_GateReadSop(pOrigObj->pData);
assert( Abc_SopGetVarNum(pData) == Abc_ObjFaninNum(pOrigObj) );
- pInitObj->pData = Abc_SopRegister( pInitNtk->pManFunc, pData );
+ pInitObj->pData = Abc_SopRegister( (Extra_MmFlex_t *)pInitNtk->pManFunc, pData );
}
// (iii) otherwise, duplicate obj
@@ -941,7 +944,7 @@ void Abc_FlowRetime_VerifyBackwardInit_rec( Abc_Obj_t * pObj ) {
SeeAlso []
***********************************************************************/
-bool Abc_FlowRetime_PartialSat(Vec_Ptr_t *vNodes, int cut) {
+int Abc_FlowRetime_PartialSat(Vec_Ptr_t *vNodes, int cut) {
Abc_Ntk_t *pPartNtk, *pInitNtk = pManMR->pInitNtk;
Abc_Obj_t *pObj, *pNext, *pPartObj, *pPartNext, *pPo;
int i, j, result;
@@ -951,7 +954,7 @@ bool Abc_FlowRetime_PartialSat(Vec_Ptr_t *vNodes, int cut) {
pPartNtk = Abc_NtkAlloc( pInitNtk->ntkType, pInitNtk->ntkFunc, 0 );
// copy network
- Vec_PtrForEachEntry( vNodes, pObj, i ) {
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i ) {
pObj->Level = i;
assert(!Abc_ObjIsPo( pObj ));
@@ -1117,7 +1120,7 @@ void Abc_FlowRetime_RemoveInitBias( ) {
InitConstraint_t *pConstraint;
int i;
- Vec_PtrForEachEntry( pManMR->vInitConstraints, pConstraint, i ) {
+ Vec_PtrForEachEntry( Abc_Obj_t *, pManMR->vInitConstraints, pConstraint, i ) {
pBiasNode = pConstraint->pBiasNode;
pConstraint->pBiasNode = NULL;
@@ -1215,7 +1218,7 @@ void Abc_FlowRetime_AddInitBias( ) {
vprintf("\t\tcreating %d bias structures\n", nConstraints);
- Vec_PtrForEachEntry( pManMR->vInitConstraints, pConstraint, i ) {
+ Vec_PtrForEachEntry( Abc_Obj_t *, pManMR->vInitConstraints, pConstraint, i ) {
if (pConstraint->pBiasNode) continue;
// printf("\t\t\tbias %d...\n", i);
@@ -1327,3 +1330,5 @@ void Abc_FlowRetime_GetInitToOrig( Abc_Obj_t *pInit, Abc_Obj_t **pOrig, int *lag
*pOrig = Abc_NtkObj(pManMR->pNtk, origId);
*lag = pManMR->pInitToOrig[id].lag;
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/fret/fretMain.c b/src/opt/fret/fretMain.c
index 77ea8468..141baff4 100644
--- a/src/opt/fret/fretMain.c
+++ b/src/opt/fret/fretMain.c
@@ -22,6 +22,9 @@
#include "vec.h"
#include "fretime.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -475,7 +478,7 @@ Abc_FlowRetime_MarkBlocks( Abc_Ntk_t * pNtk ) {
***********************************************************************/
int
-Abc_FlowRetime_PushFlows( Abc_Ntk_t * pNtk, bool fVerbose ) {
+Abc_FlowRetime_PushFlows( Abc_Ntk_t * pNtk, int fVerbose ) {
int i, j, flow = 0, last, srcDist = 0;
Abc_Obj_t *pObj, *pObj2;
// int clk = clock();
@@ -1049,7 +1052,7 @@ Abc_ObjBetterTransferFanout( Abc_Obj_t * pFrom, Abc_Obj_t * pTo, int compl ) {
SeeAlso []
***********************************************************************/
-bool
+int
Abc_FlowRetime_IsAcrossCut( Abc_Obj_t *pObj, Abc_Obj_t *pNext ) {
if (FTEST(pObj, VISITED_R) && !FTEST(pObj, VISITED_E)) {
@@ -1083,7 +1086,7 @@ Abc_FlowRetime_IsAcrossCut( Abc_Obj_t *pObj, Abc_Obj_t *pNext ) {
SeeAlso []
***********************************************************************/
-void Abc_FlowRetime_ClearFlows( bool fClearAll ) {
+void Abc_FlowRetime_ClearFlows( int fClearAll ) {
int i;
if (fClearAll)
@@ -1180,7 +1183,7 @@ static Abc_Ntk_t* Abc_FlowRetime_NtkDup( Abc_Ntk_t * pNtk ) {
SeeAlso []
***********************************************************************/
-Abc_Ntk_t * Abc_FlowRetime_NtkSilentRestrash( Abc_Ntk_t * pNtk, bool fCleanup )
+Abc_Ntk_t * Abc_FlowRetime_NtkSilentRestrash( Abc_Ntk_t * pNtk, int fCleanup )
{
Abc_Ntk_t * pNtkAig;
Abc_Obj_t * pObj;
@@ -1190,12 +1193,12 @@ Abc_Ntk_t * Abc_FlowRetime_NtkSilentRestrash( Abc_Ntk_t * pNtk, bool fCleanup )
pNtkAig = Abc_NtkStartFrom( pNtk, ABC_NTK_STRASH, ABC_FUNC_AIG );
// 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) );
+ pObj->pCopy = Abc_AigAnd( (Abc_Aig_t *)pNtkAig->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
// finalize the network
Abc_NtkFinalize( pNtk, pNtkAig );
// perform cleanup if requested
if ( fCleanup )
- nNodes = Abc_AigCleanup(pNtkAig->pManFunc);
+ nNodes = Abc_AigCleanup((Abc_Aig_t *)pNtkAig->pManFunc);
// duplicate EXDC
if ( pNtk->pExdc )
pNtkAig->pExdc = Abc_NtkDup( pNtk->pExdc );
@@ -1378,3 +1381,5 @@ void Abc_ObjPrintNeighborhood( Abc_Obj_t *pObj, int depth ) {
Vec_PtrFree(vNodes);
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/fret/fretTime.c b/src/opt/fret/fretTime.c
index f497df60..47e90519 100644
--- a/src/opt/fret/fretTime.c
+++ b/src/opt/fret/fretTime.c
@@ -22,6 +22,9 @@
#include "vec.h"
#include "fretime.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -131,7 +134,7 @@ void Abc_FlowRetime_ConstrainConserv_forw( Abc_Ntk_t * pNtk ) {
Abc_FlowRetime_Dfs_forw( pObj, vNodes );
// ... propagate values
- Vec_PtrForEachEntryReverse(vNodes, pObj, i) {
+ Vec_PtrForEachEntryReverse( Abc_Obj_t *,vNodes, pObj, i) {
pObj->Level = 0;
Abc_ObjForEachFanin( pObj, pNext, j )
{
@@ -168,19 +171,19 @@ void Abc_FlowRetime_ConstrainConserv_forw( Abc_Ntk_t * pNtk ) {
#if defined(DEBUG_CHECK)
// DEBUG: check DFS ordering
- Vec_PtrForEachEntryReverse(vNodes, pObj, i) {
+ Vec_PtrForEachEntryReverse( Abc_Obj_t *,vNodes, pObj, i) {
pObj->fMarkB = 1;
Abc_ObjForEachFanin( pObj, pNext, j )
if ( Abc_NodeIsTravIdCurrent(pNext) && !Abc_ObjIsLatch(pNext))
assert(pNext->fMarkB);
}
- Vec_PtrForEachEntryReverse(vNodes, pObj, i)
+ Vec_PtrForEachEntryReverse( Abc_Obj_t *,vNodes, pObj, i)
pObj->fMarkB = 0;
#endif
// ... propagate values
- Vec_PtrForEachEntryReverse(vNodes, pObj, i) {
+ Vec_PtrForEachEntryReverse( Abc_Obj_t *,vNodes, pObj, i) {
pObj->Level = 0;
Abc_ObjForEachFanin( pObj, pNext, j )
{
@@ -203,7 +206,7 @@ void Abc_FlowRetime_ConstrainConserv_forw( Abc_Ntk_t * pNtk ) {
}
// ... propagate values
- Vec_PtrForEachEntryReverse(vNodes, pObj, i) {
+ Vec_PtrForEachEntryReverse( Abc_Obj_t *,vNodes, pObj, i) {
pObj->Level = 0;
Abc_ObjForEachFanin( pObj, pNext, j ) {
if ( Abc_NodeIsTravIdCurrent(pNext) &&
@@ -231,7 +234,7 @@ void Abc_FlowRetime_ConstrainConserv_forw( Abc_Ntk_t * pNtk ) {
}
// ... propagate values
- Vec_PtrForEachEntryReverse(vNodes, pObj, i) {
+ Vec_PtrForEachEntryReverse( Abc_Obj_t *,vNodes, pObj, i) {
pObj->Level = 0;
Abc_ObjForEachFanin( pObj, pNext, j ) {
if ( Abc_NodeIsTravIdCurrent(pNext) &&
@@ -269,7 +272,7 @@ void Abc_FlowRetime_ConstrainConserv_back( Abc_Ntk_t * pNtk ) {
Abc_FlowRetime_Dfs_back( pObj, vNodes );
// ... propagate values
- Vec_PtrForEachEntryReverse(vNodes, pObj, i) {
+ Vec_PtrForEachEntryReverse( Abc_Obj_t *,vNodes, pObj, i) {
pObj->Level = 0;
Abc_ObjForEachFanout( pObj, pNext, j )
{
@@ -306,19 +309,19 @@ void Abc_FlowRetime_ConstrainConserv_back( Abc_Ntk_t * pNtk ) {
#if defined(DEBUG_CHECK)
// DEBUG: check DFS ordering
- Vec_PtrForEachEntryReverse(vNodes, pObj, i) {
+ Vec_PtrForEachEntryReverse( Abc_Obj_t *,vNodes, pObj, i) {
pObj->fMarkB = 1;
Abc_ObjForEachFanout( pObj, pNext, j )
if ( Abc_NodeIsTravIdCurrent(pNext) && !Abc_ObjIsLatch(pNext))
assert(pNext->fMarkB);
}
- Vec_PtrForEachEntryReverse(vNodes, pObj, i)
+ Vec_PtrForEachEntryReverse( Abc_Obj_t *,vNodes, pObj, i)
pObj->fMarkB = 0;
#endif
// ... propagate values
- Vec_PtrForEachEntryReverse(vNodes, pObj, i) {
+ Vec_PtrForEachEntryReverse( Abc_Obj_t *,vNodes, pObj, i) {
pObj->Level = 0;
Abc_ObjForEachFanout( pObj, pNext, j )
{
@@ -341,7 +344,7 @@ void Abc_FlowRetime_ConstrainConserv_back( Abc_Ntk_t * pNtk ) {
}
// ... propagate values
- Vec_PtrForEachEntryReverse(vNodes, pObj, i) {
+ Vec_PtrForEachEntryReverse( Abc_Obj_t *,vNodes, pObj, i) {
pObj->Level = 0;
Abc_ObjForEachFanout( pObj, pNext, j ) {
l = pNext->Level + (Abc_ObjIsNode(pObj) ? 1 : 0);
@@ -371,7 +374,7 @@ void Abc_FlowRetime_ConstrainConserv_back( Abc_Ntk_t * pNtk ) {
}
// ... propagate values
- Vec_PtrForEachEntryReverse(vNodes, pObj, i) {
+ Vec_PtrForEachEntryReverse( Abc_Obj_t *,vNodes, pObj, i) {
pObj->Level = 0;
Abc_ObjForEachFanout( pObj, pNext, j ) {
l = pNext->Level + (Abc_ObjIsNode(pObj) ? 1 : 0);
@@ -462,7 +465,7 @@ void Abc_FlowRetime_ConstrainExact_forw( Abc_Obj_t * pObj ) {
// rev topo order
Abc_FlowRetime_ConstrainExact_forw_rec( pObj, vNodes, 0 );
- Vec_PtrForEachEntryReverse( vNodes, pCur, i) {
+ Vec_PtrForEachEntryReverse( Abc_Obj_t *, vNodes, pCur, i) {
pReg = Abc_ObjRegular( pCur );
if (pReg == pCur) {
@@ -474,7 +477,7 @@ void Abc_FlowRetime_ConstrainExact_forw( Abc_Obj_t * pObj ) {
pReg->fMarkA = pReg->fMarkB = 0;
}
}
- Vec_PtrForEachEntryReverse( vNodes, pCur, i) {
+ Vec_PtrForEachEntryReverse( Abc_Obj_t *, vNodes, pCur, i) {
pReg = Abc_ObjRegular( pCur );
if (pReg != pCur) {
Abc_ObjForEachFanin(pReg, pNext, j)
@@ -537,7 +540,7 @@ void Abc_FlowRetime_ConstrainExact_back( Abc_Obj_t * pObj ) {
// rev topo order
Abc_FlowRetime_ConstrainExact_back_rec( pObj, vNodes, 0 );
- Vec_PtrForEachEntryReverse( vNodes, pCur, i) {
+ Vec_PtrForEachEntryReverse( Abc_Obj_t *, vNodes, pCur, i) {
pReg = Abc_ObjRegular( pCur );
if (pReg == pCur) {
@@ -549,7 +552,7 @@ void Abc_FlowRetime_ConstrainExact_back( Abc_Obj_t * pObj ) {
pReg->fMarkA = pReg->fMarkB = 0;
}
}
- Vec_PtrForEachEntryReverse( vNodes, pCur, i) {
+ Vec_PtrForEachEntryReverse( Abc_Obj_t *, vNodes, pCur, i) {
pReg = Abc_ObjRegular( pCur );
if (pReg != pCur) {
Abc_ObjForEachFanout(pReg, pNext, j)
@@ -689,7 +692,7 @@ void Abc_FlowRetime_Dfs_back( Abc_Obj_t * pObj, Vec_Ptr_t *vNodes ) {
SeeAlso []
***********************************************************************/
-bool Abc_FlowRetime_RefineConstraints( ) {
+int Abc_FlowRetime_RefineConstraints( ) {
Abc_Ntk_t *pNtk = pManMR->pNtk;
int i, flow, count = 0;
Abc_Obj_t *pObj;
@@ -761,3 +764,5 @@ bool Abc_FlowRetime_RefineConstraints( ) {
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/fret/fretime.h b/src/opt/fret/fretime.h
index bbb79d26..2d70d7e3 100644
--- a/src/opt/fret/fretime.h
+++ b/src/opt/fret/fretime.h
@@ -21,8 +21,12 @@
#if !defined(RETIME_H_)
#define RETIME_H_
+
#include "abc.h"
+ABC_NAMESPACE_HEADER_START
+
+
// #define IGNORE_TIMING
// #define DEBUG_PRINT_FLOWS
// #define DEBUG_VISITED
@@ -89,19 +93,19 @@ typedef struct MinRegMan_t_ {
// problem description:
int maxDelay;
- bool fComputeInitState, fGuaranteeInitState, fBlockConst;
+ int fComputeInitState, fGuaranteeInitState, fBlockConst;
int nNodes, nLatches;
- bool fForwardOnly, fBackwardOnly;
- bool fConservTimingOnly;
+ int fForwardOnly, fBackwardOnly;
+ int fConservTimingOnly;
int nMaxIters;
- bool fVerbose;
+ int fVerbose;
Abc_Ntk_t *pNtk;
int nPreRefine;
// problem state
- bool fIsForward;
- bool fSinkDistTerminate;
+ int fIsForward;
+ int fSinkDistTerminate;
int nExactConstraints, nConservConstraints;
int fSolutionIsDc;
int constraintMask;
@@ -145,9 +149,9 @@ void print_node(Abc_Obj_t *pObj);
void Abc_ObjBetterTransferFanout( Abc_Obj_t * pFrom, Abc_Obj_t * pTo, int compl );
-int Abc_FlowRetime_PushFlows( Abc_Ntk_t * pNtk, bool fVerbose );
-bool Abc_FlowRetime_IsAcrossCut( Abc_Obj_t *pCur, Abc_Obj_t *pNext );
-void Abc_FlowRetime_ClearFlows( bool fClearAll );
+int Abc_FlowRetime_PushFlows( Abc_Ntk_t * pNtk, int fVerbose );
+int Abc_FlowRetime_IsAcrossCut( Abc_Obj_t *pCur, Abc_Obj_t *pNext );
+void Abc_FlowRetime_ClearFlows( int fClearAll );
int Abc_FlowRetime_GetLag( Abc_Obj_t *pObj );
void Abc_FlowRetime_SetLag( Abc_Obj_t *pObj, int lag );
@@ -156,7 +160,7 @@ void Abc_FlowRetime_UpdateLags( );
void Abc_ObjPrintNeighborhood( Abc_Obj_t *pObj, int depth );
-Abc_Ntk_t * Abc_FlowRetime_NtkSilentRestrash( Abc_Ntk_t * pNtk, bool fCleanup );
+Abc_Ntk_t * Abc_FlowRetime_NtkSilentRestrash( Abc_Ntk_t * pNtk, int fCleanup );
/*=== fretFlow.c ==========================================================*/
@@ -188,10 +192,14 @@ void Abc_FlowRetime_RemoveInitBias( );
void Abc_FlowRetime_InitTiming( Abc_Ntk_t *pNtk );
void Abc_FlowRetime_FreeTiming( Abc_Ntk_t *pNtk );
-bool Abc_FlowRetime_RefineConstraints( );
+int Abc_FlowRetime_RefineConstraints( );
void Abc_FlowRetime_ConstrainConserv( Abc_Ntk_t * pNtk );
void Abc_FlowRetime_ConstrainExact( Abc_Obj_t * pObj );
void Abc_FlowRetime_ConstrainExactAll( Abc_Ntk_t * pNtk );
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif
diff --git a/src/opt/fxu/fxu.c b/src/opt/fxu/fxu.c
index 9102d289..264a7898 100644
--- a/src/opt/fxu/fxu.c
+++ b/src/opt/fxu/fxu.c
@@ -19,6 +19,9 @@
#include "fxuInt.h"
#include "fxu.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -252,3 +255,5 @@ void Fxu_MemRecycle( Fxu_Matrix * p, char * pItem, int nBytes )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/fxu/fxu.h b/src/opt/fxu/fxu.h
index b9a56b23..db855f3b 100644
--- a/src/opt/fxu/fxu.h
+++ b/src/opt/fxu/fxu.h
@@ -19,6 +19,7 @@
#ifndef __FXU_H__
#define __FXU_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -29,31 +30,26 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// STRUCTURE DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
-#ifndef __cplusplus
-#ifndef bool
-#define bool int
-#endif
-#endif
-
typedef struct FxuDataStruct Fxu_Data_t;
// structure for the FX input/output data
struct FxuDataStruct
{
// user specified parameters
- bool fOnlyS; // set to 1 to have only single-cube divs
- bool fOnlyD; // set to 1 to have only double-cube divs
- bool fUse0; // set to 1 to have 0-weight also extracted
- bool fUseCompl; // set to 1 to have complement taken into account
- bool fVerbose; // set to 1 to have verbose output
+ int fOnlyS; // set to 1 to have only single-cube divs
+ int fOnlyD; // set to 1 to have only double-cube divs
+ int fUse0; // set to 1 to have 0-weight also extracted
+ int fUseCompl; // set to 1 to have complement taken into account
+ int fVerbose; // set to 1 to have verbose output
int nNodesExt; // the number of divisors to extract
int nSingleMax; // the max number of single-cube divisors to consider
int nPairsMax; // the max number of double-cube divisors to consider
@@ -81,9 +77,11 @@ struct FxuDataStruct
/*===== fxu.c ==========================================================*/
extern int Fxu_FastExtract( Fxu_Data_t * pData );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/opt/fxu/fxuCreate.c b/src/opt/fxu/fxuCreate.c
index 008cac46..3466b520 100644
--- a/src/opt/fxu/fxuCreate.c
+++ b/src/opt/fxu/fxuCreate.c
@@ -20,6 +20,9 @@
#include "fxuInt.h"
#include "fxu.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -71,7 +74,7 @@ Fxu_Matrix * Fxu_CreateMatrix( Fxu_Data_t * pData )
nPairsStore = 0;
nBitsMax = -1;
for ( i = 0; i < pData->nNodesOld; i++ )
- if ( (pSopCover = pData->vSops->pArray[i]) )
+ if ( (pSopCover = (char *)pData->vSops->pArray[i]) )
{
nCubes = Abc_SopGetCubeNum( pSopCover );
nFanins = Abc_SopGetVarNum( pSopCover );
@@ -109,7 +112,7 @@ Fxu_Matrix * Fxu_CreateMatrix( Fxu_Data_t * pData )
iCube = 0;
iPair = 0;
for ( i = 0; i < pData->nNodesOld; i++ )
- if ( (pSopCover = pData->vSops->pArray[i]) )
+ if ( (pSopCover = (char *)pData->vSops->pArray[i]) )
{
// get the number of cubes
nCubes = Abc_SopGetCubeNum( pSopCover );
@@ -136,14 +139,14 @@ Fxu_Matrix * Fxu_CreateMatrix( Fxu_Data_t * pData )
pOrder = ABC_ALLOC( int, nBitsMax );
// create the rows
for ( i = 0; i < pData->nNodesOld; i++ )
- if ( (pSopCover = pData->vSops->pArray[i]) )
+ if ( (pSopCover = (char *)pData->vSops->pArray[i]) )
{
// get the new var in the matrix
pVar = p->ppVars[2*i+1];
// here we sort the literals of the cover
// in the increasing order of the numbers of the corresponding nodes
// because literals should be added to the matrix in this order
- vFanins = pData->vFanins->pArray[i];
+ vFanins = (Vec_Int_t *)pData->vFanins->pArray[i];
s_pLits = vFanins->pArray;
// start the variable order
nFanins = Abc_SopGetVarNum( pSopCover );
@@ -272,7 +275,7 @@ void Fxu_CreateCovers( Fxu_Matrix * p, Fxu_Data_t * pData )
// go through the internal nodes
for ( n = 0; n < pData->nNodesOld; n++ )
- if ( (pSopCover = pData->vSops->pArray[n]) )
+ if ( (pSopCover = (char *)pData->vSops->pArray[n]) )
{
// get the number of this node
iNode = n;
@@ -358,7 +361,7 @@ void Fxu_CreateCoversNode( Fxu_Matrix * p, Fxu_Data_t * pData, int iNode, Fxu_Cu
// allocate room for the new cover
pSopCover = Abc_SopStart( pData->pManSop, nCubes, vInputsNew->nSize );
// set the correct polarity of the cover
- if ( iNode < pData->nNodesOld && Abc_SopGetPhase( pData->vSops->pArray[iNode] ) == 0 )
+ if ( iNode < pData->nNodesOld && Abc_SopGetPhase( (char *)pData->vSops->pArray[iNode] ) == 0 )
Abc_SopComplement( pSopCover );
// add the cubes
@@ -429,3 +432,5 @@ int Fxu_CreateMatrixLitCompare( int * ptrX, int * ptrY )
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/fxu/fxuHeapD.c b/src/opt/fxu/fxuHeapD.c
index 9a8eb124..cb022fc4 100644
--- a/src/opt/fxu/fxuHeapD.c
+++ b/src/opt/fxu/fxuHeapD.c
@@ -18,6 +18,9 @@
#include "fxuInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -443,3 +446,5 @@ void Fxu_HeapDoubleMoveDn( Fxu_HeapDouble * p, Fxu_Double * pDiv )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/fxu/fxuHeapS.c b/src/opt/fxu/fxuHeapS.c
index 4a9bd3a4..ead8e914 100644
--- a/src/opt/fxu/fxuHeapS.c
+++ b/src/opt/fxu/fxuHeapS.c
@@ -18,6 +18,9 @@
#include "fxuInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -442,3 +445,5 @@ void Fxu_HeapSingleMoveDn( Fxu_HeapSingle * p, Fxu_Single * pSingle )
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/fxu/fxuInt.h b/src/opt/fxu/fxuInt.h
index 7483c896..96bec083 100644
--- a/src/opt/fxu/fxuInt.h
+++ b/src/opt/fxu/fxuInt.h
@@ -19,6 +19,7 @@
#ifndef __FXU_INT_H__
#define __FXU_INT_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -26,6 +27,9 @@
#include "extra.h"
#include "vec.h"
+ABC_NAMESPACE_HEADER_START
+
+
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
@@ -531,6 +535,10 @@ extern int Fxu_HeapSingleReadMaxWeight( Fxu_HeapSingle * p );
extern Fxu_Single * Fxu_HeapSingleReadMax( Fxu_HeapSingle * p );
extern Fxu_Single * Fxu_HeapSingleGetMax( Fxu_HeapSingle * p );
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif
////////////////////////////////////////////////////////////////////////
diff --git a/src/opt/fxu/fxuList.c b/src/opt/fxu/fxuList.c
index 52995804..7a7f27c8 100644
--- a/src/opt/fxu/fxuList.c
+++ b/src/opt/fxu/fxuList.c
@@ -18,6 +18,9 @@
#include "fxuInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -520,3 +523,5 @@ void Fxu_ListDoubleAddPairPlace( Fxu_Double * pDiv, Fxu_Pair * pPair, Fxu_Pair *
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/fxu/fxuMatrix.c b/src/opt/fxu/fxuMatrix.c
index 590370c9..a53de0a3 100644
--- a/src/opt/fxu/fxuMatrix.c
+++ b/src/opt/fxu/fxuMatrix.c
@@ -18,6 +18,9 @@
#include "fxuInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -372,3 +375,5 @@ void Fxu_MatrixAddDivisor( Fxu_Matrix * p, Fxu_Cube * pCube1, Fxu_Cube * pCube2
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/fxu/fxuPair.c b/src/opt/fxu/fxuPair.c
index 62cc792b..d040abe9 100644
--- a/src/opt/fxu/fxuPair.c
+++ b/src/opt/fxu/fxuPair.c
@@ -18,6 +18,9 @@
#include "fxuInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -553,3 +556,5 @@ void Fxu_PairAdd( Fxu_Pair * pPair )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/fxu/fxuPrint.c b/src/opt/fxu/fxuPrint.c
index 652a830e..d7a4d38a 100644
--- a/src/opt/fxu/fxuPrint.c
+++ b/src/opt/fxu/fxuPrint.c
@@ -18,6 +18,9 @@
#include "fxuInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -193,3 +196,5 @@ void Fxu_MatrixPrintDivisorProfile( FILE * pFile, Fxu_Matrix * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/fxu/fxuReduce.c b/src/opt/fxu/fxuReduce.c
index 6b892971..2321ec57 100644
--- a/src/opt/fxu/fxuReduce.c
+++ b/src/opt/fxu/fxuReduce.c
@@ -20,6 +20,9 @@
#include "fxuInt.h"
#include "fxu.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -40,7 +43,7 @@ static int Fxu_CountPairDiffs( char * pCover, unsigned char pDiffs[] );
number of pairs in existence. This procedure adds to the storage of
divisors exactly the given number of pairs (nPairsMax) while taking
first those pairs that have the smallest number of literals in their
- cube-ABC_FREE form.]
+ cube-free form.]
SideEffects []
@@ -69,7 +72,7 @@ int Fxu_PreprocessCubePairs( Fxu_Matrix * p, Vec_Ptr_t * vCovers, int nPairsTota
iPair = 0;
nBitsMax = -1;
for ( c = 0; c < vCovers->nSize; c++ )
- if ( (pSopCover = vCovers->pArray[c]) )
+ if ( (pSopCover = (char *)vCovers->pArray[c]) )
{
nFanins = Abc_SopGetVarNum(pSopCover);
// precompute the differences
@@ -135,7 +138,7 @@ int Fxu_PreprocessCubePairs( Fxu_Matrix * p, Vec_Ptr_t * vCovers, int nPairsTota
// collect the corresponding pairs and add the divisors
iPair = 0;
for ( c = 0; c < vCovers->nSize; c++ )
- if ( (pSopCover = vCovers->pArray[c]) )
+ if ( (pSopCover = (char *)vCovers->pArray[c]) )
{
// get the var
pVar = p->ppVars[2*c+1];
@@ -202,3 +205,5 @@ int Fxu_CountPairDiffs( char * pCover, unsigned char pDiffs[] )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/fxu/fxuSelect.c b/src/opt/fxu/fxuSelect.c
index 20f5ab97..a4e260c7 100644
--- a/src/opt/fxu/fxuSelect.c
+++ b/src/opt/fxu/fxuSelect.c
@@ -18,6 +18,9 @@
#include "fxuInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -601,3 +604,5 @@ int Fxu_SelectSCD( Fxu_Matrix * p, int WeightLimit, Fxu_Var ** ppVar1, Fxu_Var *
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/fxu/fxuSingle.c b/src/opt/fxu/fxuSingle.c
index 6e90a2a2..b1cc2e63 100644
--- a/src/opt/fxu/fxuSingle.c
+++ b/src/opt/fxu/fxuSingle.c
@@ -19,6 +19,9 @@
#include "fxuInt.h"
#include "vec.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -100,8 +103,8 @@ void Fxu_MatrixComputeSingles( Fxu_Matrix * p, int fUse0, int nSingleMax )
for ( i = 0; i < Vec_PtrSize(vSingles); i += 3 )
{
Fxu_MatrixAddSingle( p,
- Vec_PtrEntry(vSingles,i),
- Vec_PtrEntry(vSingles,i+1),
+ (Fxu_Var *)Vec_PtrEntry(vSingles,i),
+ (Fxu_Var *)Vec_PtrEntry(vSingles,i+1),
(int)(ABC_PTRUINT_T)Vec_PtrEntry(vSingles,i+2) );
}
Vec_PtrFree( vSingles );
@@ -282,3 +285,5 @@ int Fxu_SingleCountCoincidence( Fxu_Matrix * p, Fxu_Var * pVar1, Fxu_Var * pVar2
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/fxu/fxuUpdate.c b/src/opt/fxu/fxuUpdate.c
index cdbe313d..74939896 100644
--- a/src/opt/fxu/fxuUpdate.c
+++ b/src/opt/fxu/fxuUpdate.c
@@ -18,6 +18,9 @@
#include "fxuInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -292,7 +295,7 @@ void Fxu_UpdateDoublePairs( Fxu_Matrix * p, Fxu_Double * pDouble, Fxu_Var * pVar
{
// get the pair
// pPair = p->pPairsTemp[i];
- pPair = p->vPairs->pArray[i];
+ pPair = (Fxu_Pair *)p->vPairs->pArray[i];
// out of the two cubes, select the one which comes earlier
pCubeUse = Fxu_PairMinCube( pPair );
pCubeRem = Fxu_PairMaxCube( pPair );
@@ -344,7 +347,7 @@ void Fxu_UpdateMatrixDoubleCreateCubes( Fxu_Matrix * p, Fxu_Cube * pCube1, Fxu_C
if ( pLit1 && pLit2 )
{
if ( pLit1->iVar == pLit2->iVar )
- { // skip the cube ABC_FREE part
+ { // skip the cube free part
pLit1 = pLit1->pHNext;
pLit2 = pLit2->pHNext;
nBase++;
@@ -804,3 +807,5 @@ void Fxu_UpdateAddNewSingles( Fxu_Matrix * p, Fxu_Var * pVar )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/lpk/lpk.h b/src/opt/lpk/lpk.h
index d7e4af29..498da845 100644
--- a/src/opt/lpk/lpk.h
+++ b/src/opt/lpk/lpk.h
@@ -21,6 +21,7 @@
#ifndef __LPK_H__
#define __LPK_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -29,9 +30,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -72,9 +74,11 @@ struct Lpk_Par_t_
extern int Lpk_Resynthesize( Abc_Ntk_t * pNtk, Lpk_Par_t * pPars );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/opt/lpk/lpkAbcDec.c b/src/opt/lpk/lpkAbcDec.c
index c06f0bf1..de5b66cc 100644
--- a/src/opt/lpk/lpkAbcDec.c
+++ b/src/opt/lpk/lpkAbcDec.c
@@ -20,6 +20,9 @@
#include "lpkInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -52,22 +55,22 @@ Abc_Obj_t * Lpk_ImplementFun( Lpk_Man_t * pMan, Abc_Ntk_t * pNtk, Vec_Ptr_t * vL
// create the new node
pObjNew = Abc_NtkCreateNode( pNtk );
for ( i = 0; i < (int)p->nVars; i++ )
- Abc_ObjAddFanin( pObjNew, Abc_ObjRegular(Vec_PtrEntry(vLeaves, p->pFanins[i])) );
+ Abc_ObjAddFanin( pObjNew, Abc_ObjRegular((Abc_Obj_t *)Vec_PtrEntry(vLeaves, p->pFanins[i])) );
Abc_ObjSetLevel( pObjNew, Abc_ObjLevelNew(pObjNew) );
// assign the node's function
pTruth = Lpk_FunTruth(p, 0);
if ( p->nVars == 0 )
{
- pObjNew->pData = Hop_NotCond( Hop_ManConst1(pNtk->pManFunc), !(pTruth[0] & 1) );
+ pObjNew->pData = Hop_NotCond( Hop_ManConst1((Hop_Man_t *)pNtk->pManFunc), !(pTruth[0] & 1) );
return pObjNew;
}
if ( p->nVars == 1 )
{
- pObjNew->pData = Hop_NotCond( Hop_ManPi(pNtk->pManFunc, 0), (pTruth[0] & 1) );
+ pObjNew->pData = Hop_NotCond( Hop_ManPi((Hop_Man_t *)pNtk->pManFunc, 0), (pTruth[0] & 1) );
return pObjNew;
}
// create the logic function
- pObjNew->pData = Kit_TruthToHop( pNtk->pManFunc, pTruth, p->nVars, NULL );
+ pObjNew->pData = Kit_TruthToHop( (Hop_Man_t *)pNtk->pManFunc, pTruth, p->nVars, NULL );
return pObjNew;
}
@@ -89,10 +92,10 @@ Abc_Obj_t * Lpk_Implement_rec( Lpk_Man_t * pMan, Abc_Ntk_t * pNtk, Vec_Ptr_t * v
// prepare the leaves of the function
for ( i = 0; i < (int)pFun->nVars; i++ )
{
- pFanin = Vec_PtrEntry( vLeaves, pFun->pFanins[i] );
+ pFanin = (Abc_Obj_t *)Vec_PtrEntry( vLeaves, pFun->pFanins[i] );
if ( !Abc_ObjIsComplement(pFanin) )
Lpk_Implement_rec( pMan, pNtk, vLeaves, (Lpk_Fun_t *)pFanin );
- pFanin = Vec_PtrEntry( vLeaves, pFun->pFanins[i] );
+ pFanin = (Abc_Obj_t *)Vec_PtrEntry( vLeaves, pFun->pFanins[i] );
assert( Abc_ObjIsComplement(pFanin) );
}
// construct the function
@@ -120,10 +123,10 @@ Abc_Obj_t * Lpk_Implement( Lpk_Man_t * pMan, Abc_Ntk_t * pNtk, Vec_Ptr_t * vLeav
int i;
assert( nLeavesOld < Vec_PtrSize(vLeaves) );
// mark implemented nodes
- Vec_PtrForEachEntryStop( vLeaves, pFanin, i, nLeavesOld )
+ Vec_PtrForEachEntryStop( Abc_Obj_t *, vLeaves, pFanin, i, nLeavesOld )
Vec_PtrWriteEntry( vLeaves, i, Abc_ObjNot(pFanin) );
// recursively construct starting from the first entry
- pRes = Lpk_Implement_rec( pMan, pNtk, vLeaves, Vec_PtrEntry( vLeaves, nLeavesOld ) );
+ pRes = Lpk_Implement_rec( pMan, pNtk, vLeaves, (Lpk_Fun_t *)Vec_PtrEntry( vLeaves, nLeavesOld ) );
Vec_PtrShrink( vLeaves, nLeavesOld );
return pRes;
}
@@ -236,7 +239,7 @@ void Lpk_DecomposeClean( Vec_Ptr_t * vLeaves, int nLeavesOld )
{
Lpk_Fun_t * pFunc;
int i;
- Vec_PtrForEachEntryStart( vLeaves, pFunc, i, nLeavesOld )
+ Vec_PtrForEachEntryStart( Lpk_Fun_t *, vLeaves, pFunc, i, nLeavesOld )
Lpk_FunFree( pFunc );
Vec_PtrShrink( vLeaves, nLeavesOld );
}
@@ -287,3 +290,5 @@ Abc_Obj_t * Lpk_Decompose( Lpk_Man_t * p, Abc_Ntk_t * pNtk, Vec_Ptr_t * vLeaves,
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/lpk/lpkAbcDsd.c b/src/opt/lpk/lpkAbcDsd.c
index a1cd9def..34785941 100644
--- a/src/opt/lpk/lpkAbcDsd.c
+++ b/src/opt/lpk/lpkAbcDsd.c
@@ -20,6 +20,9 @@
#include "lpkInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -610,3 +613,5 @@ Lpk_Fun_t * Lpk_DsdSplit( Lpk_Man_t * pMan, Lpk_Fun_t * p, char * pCofVars, int
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/lpk/lpkAbcMux.c b/src/opt/lpk/lpkAbcMux.c
index d6f579ee..4e9cc654 100644
--- a/src/opt/lpk/lpkAbcMux.c
+++ b/src/opt/lpk/lpkAbcMux.c
@@ -20,6 +20,9 @@
#include "lpkInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -233,3 +236,5 @@ Extra_PrintBinary( stdout, &uSupp, 16 ); printf( "\n\n" );
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/lpk/lpkAbcUtil.c b/src/opt/lpk/lpkAbcUtil.c
index ae295624..b086d35f 100644
--- a/src/opt/lpk/lpkAbcUtil.c
+++ b/src/opt/lpk/lpkAbcUtil.c
@@ -20,6 +20,9 @@
#include "lpkInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -88,7 +91,7 @@ Lpk_Fun_t * Lpk_FunCreate( Abc_Ntk_t * pNtk, Vec_Ptr_t * vLeaves, unsigned * pTr
p->nDelayLim = DelayLim;
p->uSupp = Kit_TruthSupport( pTruth, p->nVars );
Kit_TruthCopy( Lpk_FunTruth(p,0), pTruth, p->nVars );
- Vec_PtrForEachEntry( vLeaves, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pNode, i )
{
p->pFanins[i] = i;
p->pDelays[i] = pNode->Level;
@@ -242,3 +245,5 @@ int Lpk_SuppToVars( unsigned uBoundSet, char * pVars )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/lpk/lpkCore.c b/src/opt/lpk/lpkCore.c
index 7cc4b154..d3a6ba67 100644
--- a/src/opt/lpk/lpkCore.c
+++ b/src/opt/lpk/lpkCore.c
@@ -21,6 +21,9 @@
#include "lpkInt.h"
#include "cloud.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -94,10 +97,10 @@ int Lpk_NodeHasChanged( Lpk_Man_t * p, int iNode )
Vec_Ptr_t * vNodes;
Abc_Obj_t * pTemp;
int i;
- vNodes = Vec_VecEntry( p->vVisited, iNode );
+ vNodes = (Vec_Ptr_t *)Vec_VecEntry( p->vVisited, iNode );
if ( Vec_PtrSize(vNodes) == 0 )
return 1;
- Vec_PtrForEachEntry( vNodes, pTemp, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pTemp, i )
{
// check if the node has changed
pTemp = Abc_NtkObj( p->pNtk, (int)(ABC_PTRUINT_T)pTemp );
@@ -213,7 +216,7 @@ p->timeMap += clock() - clk;
If_ObjSetCopy( If_ManCi(p->pIfMan, i), pLeaf );
// get the area of mapping
pObjNew = Abc_NodeFromIf_rec( p->pNtk, p->pIfMan, If_Regular(pDriver), p->vCover );
- pObjNew->pData = Hop_NotCond( pObjNew->pData, If_IsComplement(pDriver) );
+ pObjNew->pData = Hop_NotCond( (Hop_Obj_t *)pObjNew->pData, If_IsComplement(pDriver) );
// perform replacement
Abc_NtkUpdate( p->pObj, pObjNew, p->vLevels );
//printf( "%3d : %d-%d=%d(%d) \n", p->nChanges, nNodesBef, Abc_NtkNodeNum(p->pNtk), nNodesBef-Abc_NtkNodeNum(p->pNtk), nGain );
@@ -444,7 +447,7 @@ p->timeTruth3 += clock() - clk;
int nSuppSize = Extra_TruthSupportSize( pTruth, pCut->nLeaves );
printf( " C%02d: L= %2d/%2d V= %2d/%d N= %d W= %4.2f ",
i, pCut->nLeaves, nSuppSize, pCut->nNodes, pCut->nNodesDup, pCut->nLuts, pCut->Weight );
- Vec_PtrForEachEntry( p->vLeaves, pLeaf, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vLeaves, pLeaf, k )
printf( "%c=%d ", 'a'+k, Abc_ObjLevel(pLeaf) );
printf( "\n" );
Kit_DsdPrintFromTruth( pTruth, pCut->nLeaves );
@@ -683,3 +686,5 @@ int Lpk_Resynthesize( Abc_Ntk_t * pNtk, Lpk_Par_t * pPars )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/lpk/lpkCut.c b/src/opt/lpk/lpkCut.c
index 6f0eed84..ac0a3516 100644
--- a/src/opt/lpk/lpkCut.c
+++ b/src/opt/lpk/lpkCut.c
@@ -21,6 +21,9 @@
#include "lpkInt.h"
#include "cloud.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -47,7 +50,7 @@ CloudNode * Lpk_CutTruthBdd_rec( CloudManager * dd, Hop_Man_t * pMan, Hop_Obj_t
if ( pObj->pData )
{
assert( ((unsigned)(ABC_PTRUINT_T)pObj->pData) & 0xffff0000 );
- return pObj->pData;
+ return (CloudNode *)pObj->pData;
}
// get the plan for a new truth table
if ( Hop_ObjIsConst1(pObj) )
@@ -81,7 +84,7 @@ CloudNode * Lpk_CutTruthBdd_rec( CloudManager * dd, Hop_Man_t * pMan, Hop_Obj_t
CloudNode * Lpk_CutTruthBdd( Lpk_Man_t * p, Lpk_Cut_t * pCut )
{
CloudManager * dd = p->pDsdMan->dd;
- Hop_Man_t * pManHop = p->pNtk->pManFunc;
+ Hop_Man_t * pManHop = (Hop_Man_t *)p->pNtk->pManFunc;
Hop_Obj_t * pObjHop;
Abc_Obj_t * pObj, * pFanin;
CloudNode * pTruth = NULL; // Suppress "might be used uninitialized"
@@ -97,7 +100,7 @@ CloudNode * Lpk_CutTruthBdd( Lpk_Man_t * p, Lpk_Cut_t * pCut )
Lpk_CutForEachNodeReverse( p->pNtk, pCut, pObj, i )
{
// get the local AIG
- pObjHop = Hop_Regular(pObj->pData);
+ pObjHop = Hop_Regular((Hop_Obj_t *)pObj->pData);
// clean the data field of the nodes in the AIG subgraph
Hop_ObjCleanData_rec( pObjHop );
// set the initial truth tables at the fanins
@@ -108,7 +111,7 @@ CloudNode * Lpk_CutTruthBdd( Lpk_Man_t * p, Lpk_Cut_t * pCut )
}
// compute the truth table of internal nodes
pTruth = Lpk_CutTruthBdd_rec( dd, pManHop, pObjHop, pCut->nLeaves );
- if ( Hop_IsComplement(pObj->pData) )
+ if ( Hop_IsComplement((Hop_Obj_t *)pObj->pData) )
pTruth = Cloud_Not(pTruth);
// set the truth table at the node
pObj->pCopy = (Abc_Obj_t *)pTruth;
@@ -139,10 +142,10 @@ unsigned * Lpk_CutTruth_rec( Hop_Man_t * pMan, Hop_Obj_t * pObj, int nVars, Vec_
if ( pObj->pData )
{
assert( ((unsigned)(ABC_PTRUINT_T)pObj->pData) & 0xffff0000 );
- return pObj->pData;
+ return (unsigned *)pObj->pData;
}
// get the plan for a new truth table
- pTruth = Vec_PtrEntry( vTtNodes, (*piCount)++ );
+ pTruth = (unsigned *)Vec_PtrEntry( vTtNodes, (*piCount)++ );
if ( Hop_ObjIsConst1(pObj) )
Kit_TruthFill( pTruth, nVars );
else
@@ -171,7 +174,7 @@ unsigned * Lpk_CutTruth_rec( Hop_Man_t * pMan, Hop_Obj_t * pObj, int nVars, Vec_
***********************************************************************/
unsigned * Lpk_CutTruth( Lpk_Man_t * p, Lpk_Cut_t * pCut, int fInv )
{
- Hop_Man_t * pManHop = p->pNtk->pManFunc;
+ Hop_Man_t * pManHop = (Hop_Man_t *)p->pNtk->pManFunc;
Hop_Obj_t * pObjHop;
Abc_Obj_t * pObj = NULL; // Suppress "might be used uninitialized"
Abc_Obj_t * pFanin;
@@ -182,13 +185,13 @@ unsigned * Lpk_CutTruth( Lpk_Man_t * p, Lpk_Cut_t * pCut, int fInv )
// initialize the leaves
Lpk_CutForEachLeaf( p->pNtk, pCut, pObj, i )
- pObj->pCopy = Vec_PtrEntry( p->vTtElems, fInv? pCut->nLeaves-1-i : i );
+ pObj->pCopy = (Abc_Obj_t *)Vec_PtrEntry( p->vTtElems, fInv? pCut->nLeaves-1-i : i );
// construct truth table in the topological order
Lpk_CutForEachNodeReverse( p->pNtk, pCut, pObj, i )
{
// get the local AIG
- pObjHop = Hop_Regular(pObj->pData);
+ pObjHop = Hop_Regular((Hop_Obj_t *)pObj->pData);
// clean the data field of the nodes in the AIG subgraph
Hop_ObjCleanData_rec( pObjHop );
// set the initial truth tables at the fanins
@@ -199,7 +202,7 @@ unsigned * Lpk_CutTruth( Lpk_Man_t * p, Lpk_Cut_t * pCut, int fInv )
}
// compute the truth table of internal nodes
pTruth = Lpk_CutTruth_rec( pManHop, pObjHop, pCut->nLeaves, p->vTtNodes, &iCount );
- if ( Hop_IsComplement(pObj->pData) )
+ if ( Hop_IsComplement((Hop_Obj_t *)pObj->pData) )
Kit_TruthNot( pTruth, pTruth, pCut->nLeaves );
// set the truth table at the node
pObj->pCopy = (Abc_Obj_t *)pTruth;
@@ -208,7 +211,7 @@ unsigned * Lpk_CutTruth( Lpk_Man_t * p, Lpk_Cut_t * pCut, int fInv )
// make sure direct truth table is stored elsewhere (assuming the first call for direct truth!!!)
if ( fInv == 0 )
{
- pTruth = Vec_PtrEntry( p->vTtNodes, iCount++ );
+ pTruth = (unsigned *)Vec_PtrEntry( p->vTtNodes, iCount++ );
Kit_TruthCopy( pTruth, (unsigned *)(ABC_PTRUINT_T)pObj->pCopy, pCut->nLeaves );
}
assert( iCount <= Vec_PtrSize(p->vTtNodes) );
@@ -230,7 +233,7 @@ unsigned * Lpk_CutTruth( Lpk_Man_t * p, Lpk_Cut_t * pCut, int fInv )
void Lpk_NodeRecordImpact( Lpk_Man_t * p )
{
Lpk_Cut_t * pCut;
- Vec_Ptr_t * vNodes = Vec_VecEntry( p->vVisited, p->pObj->Id );
+ Vec_Ptr_t * vNodes = (Vec_Ptr_t *)Vec_VecEntry( p->vVisited, p->pObj->Id );
Abc_Obj_t * pNode;
int i, k;
// collect the nodes that impact the given node
@@ -249,7 +252,7 @@ void Lpk_NodeRecordImpact( Lpk_Man_t * p )
}
}
// clear the marks
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
{
pNode = Abc_NtkObj( p->pNtk, (int)(ABC_PTRUINT_T)pNode );
pNode->fMarkC = 0;
@@ -281,7 +284,7 @@ int Lpk_NodeCutsCheckDsd( Lpk_Man_t * p, Lpk_Cut_t * pCut )
{
assert( pObj->fMarkA == 0 );
pObj->fMarkA = 1;
- pObj->pCopy = (void *)(ABC_PTRUINT_T)i;
+ pObj->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)i;
}
// ref leaves pointed from the internal nodes
nCands = 0;
@@ -682,3 +685,5 @@ int Lpk_NodeCuts( Lpk_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/lpk/lpkInt.h b/src/opt/lpk/lpkInt.h
index 26bb846a..5cb8c1a2 100644
--- a/src/opt/lpk/lpkInt.h
+++ b/src/opt/lpk/lpkInt.h
@@ -21,6 +21,7 @@
#ifndef __LPK_INT_H__
#define __LPK_INT_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -34,9 +35,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -234,9 +236,11 @@ extern If_Obj_t * Lpk_MapSuppRedDec_rec( Lpk_Man_t * p, unsigned * pTruth, i
/*=== lpkSets.c =========================================================*/
extern unsigned Lpk_MapSuppRedDecSelect( Lpk_Man_t * p, unsigned * pTruth, int nVars, int * piVar, int * piVarReused );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/opt/lpk/lpkMan.c b/src/opt/lpk/lpkMan.c
index 024f724a..f012ab75 100644
--- a/src/opt/lpk/lpkMan.c
+++ b/src/opt/lpk/lpkMan.c
@@ -20,6 +20,9 @@
#include "lpkInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -120,3 +123,5 @@ void Lpk_ManStop( Lpk_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/lpk/lpkMap.c b/src/opt/lpk/lpkMap.c
index f959f8f9..c6c6b233 100644
--- a/src/opt/lpk/lpkMap.c
+++ b/src/opt/lpk/lpkMap.c
@@ -20,6 +20,9 @@
#include "lpkInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -49,17 +52,17 @@ If_Obj_t * Lpk_MapPrimeInternal( If_Man_t * pIfMan, Kit_Graph_t * pGraph )
return If_ManConst1(pIfMan);
// check for a literal
if ( Kit_GraphIsVar(pGraph) )
- return Kit_GraphVar(pGraph)->pFunc;
+ return (If_Obj_t *)Kit_GraphVar(pGraph)->pFunc;
// build the AIG nodes corresponding to the AND gates of the graph
Kit_GraphForEachNode( pGraph, pNode, i )
{
- pAnd0 = Kit_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc;
- pAnd1 = Kit_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc;
+ pAnd0 = (If_Obj_t *)Kit_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc;
+ pAnd1 = (If_Obj_t *)Kit_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc;
pNode->pFunc = If_ManCreateAnd( pIfMan,
If_NotCond( If_Regular(pAnd0), If_IsComplement(pAnd0) ^ pNode->eEdge0.fCompl ),
If_NotCond( If_Regular(pAnd1), If_IsComplement(pAnd1) ^ pNode->eEdge1.fCompl ) );
}
- return pNode->pFunc;
+ return (If_Obj_t *)pNode->pFunc;
}
/**Function*************************************************************
@@ -203,3 +206,5 @@ If_Obj_t * Lpk_MapTree_rec( Lpk_Man_t * p, Kit_DsdNtk_t * pNtk, If_Obj_t ** ppLe
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/lpk/lpkMulti.c b/src/opt/lpk/lpkMulti.c
index d5f1fd11..cce154ee 100644
--- a/src/opt/lpk/lpkMulti.c
+++ b/src/opt/lpk/lpkMulti.c
@@ -20,6 +20,9 @@
#include "lpkInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -506,3 +509,5 @@ If_Obj_t * Lpk_MapTreeMulti( Lpk_Man_t * p, unsigned * pTruth, int nVars, If_Obj
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/lpk/lpkMux.c b/src/opt/lpk/lpkMux.c
index ed046ad7..01c28c8c 100644
--- a/src/opt/lpk/lpkMux.c
+++ b/src/opt/lpk/lpkMux.c
@@ -20,6 +20,9 @@
#include "lpkInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -85,8 +88,8 @@ int Lpk_MapTreeBestCofVar( Lpk_Man_t * p, unsigned * pTruth, int nVars, unsigned
***********************************************************************/
If_Obj_t * Lpk_MapTreeMux_rec( Lpk_Man_t * p, unsigned * pTruth, int nVars, If_Obj_t ** ppLeaves )
{
- unsigned * pCof0 = Vec_PtrEntry( p->vTtNodes, 0 );
- unsigned * pCof1 = Vec_PtrEntry( p->vTtNodes, 1 );
+ unsigned * pCof0 = (unsigned *)Vec_PtrEntry( p->vTtNodes, 0 );
+ unsigned * pCof1 = (unsigned *)Vec_PtrEntry( p->vTtNodes, 1 );
If_Obj_t * pObj0, * pObj1;
Kit_DsdNtk_t * ppNtks[2];
int iBestVar;
@@ -131,18 +134,18 @@ If_Obj_t * Lpk_MapSuppRedDec_rec( Lpk_Man_t * p, unsigned * pTruth, int nVars, I
{
Kit_DsdNtk_t * pNtkDec, * pNtkComp, * ppNtks[2], * pTemp;
If_Obj_t * pObjNew;
- unsigned * pCof0 = Vec_PtrEntry( p->vTtNodes, 0 );
- unsigned * pCof1 = Vec_PtrEntry( p->vTtNodes, 1 );
- unsigned * pDec0 = Vec_PtrEntry( p->vTtNodes, 2 );
- unsigned * pDec1 = Vec_PtrEntry( p->vTtNodes, 3 );
- unsigned * pDec = Vec_PtrEntry( p->vTtNodes, 4 );
- unsigned * pCo00 = Vec_PtrEntry( p->vTtNodes, 5 );
- unsigned * pCo01 = Vec_PtrEntry( p->vTtNodes, 6 );
- unsigned * pCo10 = Vec_PtrEntry( p->vTtNodes, 7 );
- unsigned * pCo11 = Vec_PtrEntry( p->vTtNodes, 8 );
- unsigned * pCo0 = Vec_PtrEntry( p->vTtNodes, 9 );
- unsigned * pCo1 = Vec_PtrEntry( p->vTtNodes, 10 );
- unsigned * pCo = Vec_PtrEntry( p->vTtNodes, 11 );
+ unsigned * pCof0 = (unsigned *)Vec_PtrEntry( p->vTtNodes, 0 );
+ unsigned * pCof1 = (unsigned *)Vec_PtrEntry( p->vTtNodes, 1 );
+ unsigned * pDec0 = (unsigned *)Vec_PtrEntry( p->vTtNodes, 2 );
+ unsigned * pDec1 = (unsigned *)Vec_PtrEntry( p->vTtNodes, 3 );
+ unsigned * pDec = (unsigned *)Vec_PtrEntry( p->vTtNodes, 4 );
+ unsigned * pCo00 = (unsigned *)Vec_PtrEntry( p->vTtNodes, 5 );
+ unsigned * pCo01 = (unsigned *)Vec_PtrEntry( p->vTtNodes, 6 );
+ unsigned * pCo10 = (unsigned *)Vec_PtrEntry( p->vTtNodes, 7 );
+ unsigned * pCo11 = (unsigned *)Vec_PtrEntry( p->vTtNodes, 8 );
+ unsigned * pCo0 = (unsigned *)Vec_PtrEntry( p->vTtNodes, 9 );
+ unsigned * pCo1 = (unsigned *)Vec_PtrEntry( p->vTtNodes, 10 );
+ unsigned * pCo = (unsigned *)Vec_PtrEntry( p->vTtNodes, 11 );
int TrueMint0, TrueMint1, FalseMint0, FalseMint1;
int uSubsets, uSubset0, uSubset1, iVar, iVarReused, i;
@@ -245,3 +248,5 @@ If_Obj_t * Lpk_MapSuppRedDec_rec( Lpk_Man_t * p, unsigned * pTruth, int nVars, I
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/lpk/lpkSets.c b/src/opt/lpk/lpkSets.c
index 90e46863..65b23ea9 100644
--- a/src/opt/lpk/lpkSets.c
+++ b/src/opt/lpk/lpkSets.c
@@ -20,6 +20,9 @@
#include "lpkInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -324,8 +327,8 @@ unsigned Lpk_MapSuppRedDecSelect( Lpk_Man_t * p, unsigned * pTruth, int nVars, i
Kit_DsdNtk_t * ppNtks[2], * pTemp;
Vec_Int_t * vSets0 = p->vSets[0];
Vec_Int_t * vSets1 = p->vSets[1];
- unsigned * pCof0 = Vec_PtrEntry( p->vTtNodes, 0 );
- unsigned * pCof1 = Vec_PtrEntry( p->vTtNodes, 1 );
+ unsigned * pCof0 = (unsigned *)Vec_PtrEntry( p->vTtNodes, 0 );
+ unsigned * pCof1 = (unsigned *)Vec_PtrEntry( p->vTtNodes, 1 );
int nSets, i, SizeMax;//, SRedMax;
unsigned Entry;
int fVerbose = p->pPars->fVeryVerbose;
@@ -438,3 +441,5 @@ unsigned Lpk_MapSuppRedDecSelect( Lpk_Man_t * p, unsigned * pTruth, int nVars, i
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/lpk/lpk_.c b/src/opt/lpk/lpk_.c
index d8555e08..8b61babd 100644
--- a/src/opt/lpk/lpk_.c
+++ b/src/opt/lpk/lpk_.c
@@ -20,6 +20,9 @@
#include "lpkInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -46,3 +49,5 @@
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/mfs/mfs.h b/src/opt/mfs/mfs.h
index 8b49345e..02fcc21b 100644
--- a/src/opt/mfs/mfs.h
+++ b/src/opt/mfs/mfs.h
@@ -21,6 +21,7 @@
#ifndef __MFS_H__
#define __MFS_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -29,9 +30,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -73,9 +75,11 @@ extern void Abc_NtkMfsParsDefault( Mfs_Par_t * pPars );
extern int Abc_NtkMfs( Abc_Ntk_t * pNtk, Mfs_Par_t * pPars );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/opt/mfs/mfsCore.c b/src/opt/mfs/mfsCore.c
index c598a19b..bda95d55 100644
--- a/src/opt/mfs/mfsCore.c
+++ b/src/opt/mfs/mfsCore.c
@@ -20,6 +20,9 @@
#include "mfsInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -148,7 +151,7 @@ int Abc_NtkMfsPowerResubNode( Mfs_Man_t * p, Abc_Obj_t * pNode )
}
*/
-Abc_NtkMfsPowerResub( Mfs_Man_t * p, Mfs_Par_t * pPars)
+void Abc_NtkMfsPowerResub( Mfs_Man_t * p, Mfs_Par_t * pPars)
{
int i, k;
Abc_Obj_t *pFanin, *pNode;
@@ -326,7 +329,7 @@ clk = clock();
p->timeCnf += clock() - clk;
// create the SAT problem
clk = clock();
- p->pSat = Cnf_DataWriteIntoSolver( p->pCnf, 1, 0 );
+ p->pSat = (sat_solver *)Cnf_DataWriteIntoSolver( p->pCnf, 1, 0 );
if ( p->pSat && p->pPars->fOneHotness )
Abc_NtkAddOneHotness( p );
if ( p->pSat == NULL )
@@ -344,8 +347,8 @@ p->timeSat += clock() - clk;
// minimize the local function of the node using bi-decomposition
assert( p->nFanins == Abc_ObjFaninNum(pNode) );
dProb = p->pPars->fPower? ((float *)p->vProbs->pArray)[pNode->Id] : -1.0;
- pObj = Abc_NodeIfNodeResyn( p->pManDec, pNode->pNtk->pManFunc, pNode->pData, p->nFanins, p->vTruth, p->uCare, dProb );
- nGain = Hop_DagSize(pNode->pData) - Hop_DagSize(pObj);
+ pObj = Abc_NodeIfNodeResyn( p->pManDec, (Hop_Man_t *)pNode->pNtk->pManFunc, (Hop_Obj_t *)pNode->pData, p->nFanins, p->vTruth, p->uCare, dProb );
+ nGain = Hop_DagSize((Hop_Obj_t *)pNode->pData) - Hop_DagSize(pObj);
if ( nGain >= 0 )
{
p->nNodesDec++;
@@ -432,12 +435,12 @@ int Abc_NtkMfs( Abc_Ntk_t * pNtk, Mfs_Par_t * pPars )
if ( pNtk->pExcare )
{
Abc_Ntk_t * pTemp;
- if ( Abc_NtkPiNum(pNtk->pExcare) != Abc_NtkCiNum(pNtk) )
+ if ( Abc_NtkPiNum((Abc_Ntk_t *)pNtk->pExcare) != Abc_NtkCiNum(pNtk) )
printf( "The PI count of careset (%d) and logic network (%d) differ. Careset is not used.\n",
- Abc_NtkPiNum(pNtk->pExcare), Abc_NtkCiNum(pNtk) );
+ Abc_NtkPiNum((Abc_Ntk_t *)pNtk->pExcare), Abc_NtkCiNum(pNtk) );
else
{
- pTemp = Abc_NtkStrash( pNtk->pExcare, 0, 0, 0 );
+ pTemp = Abc_NtkStrash( (Abc_Ntk_t *)pNtk->pExcare, 0, 0, 0 );
p->pCare = Abc_NtkToDar( pTemp, 0, 0 );
Abc_NtkDelete( pTemp );
p->vSuppsInv = Aig_ManSupportsInverse( p->pCare );
@@ -513,7 +516,7 @@ int Abc_NtkMfs( Abc_Ntk_t * pNtk, Mfs_Par_t * pPars )
p->nTotConfLevel = 0;
p->nTimeOutsLevel = 0;
clk2 = clock();
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
{
if ( p->pPars->nDepthMax && (int)pObj->Level > p->pPars->nDepthMax )
break;
@@ -584,3 +587,5 @@ int Abc_NtkMfs( Abc_Ntk_t * pNtk, Mfs_Par_t * pPars )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/mfs/mfsCore_.c b/src/opt/mfs/mfsCore_.c
index 66b497f6..69f64ae5 100644
--- a/src/opt/mfs/mfsCore_.c
+++ b/src/opt/mfs/mfsCore_.c
@@ -20,6 +20,9 @@
#include "mfsInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -386,3 +389,5 @@ int Abc_NtkMfs( Abc_Ntk_t * pNtk, Mfs_Par_t * pPars )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/mfs/mfsDiv.c b/src/opt/mfs/mfsDiv.c
index f5a07d31..1473580e 100644
--- a/src/opt/mfs/mfsDiv.c
+++ b/src/opt/mfs/mfsDiv.c
@@ -20,6 +20,9 @@
#include "mfsInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -201,7 +204,7 @@ Vec_Ptr_t * Abc_MfsComputeDivisors( Mfs_Man_t * p, Abc_Obj_t * pNode, int nLevDi
// count the number of PIs
nTrueSupp = 0;
- Vec_PtrForEachEntry( vCone, pObj, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vCone, pObj, k )
nTrueSupp += Abc_ObjIsCi(pObj);
// printf( "%d(%d) ", Vec_PtrSize(p->vSupp), m );
@@ -221,7 +224,7 @@ Vec_Ptr_t * Abc_MfsComputeDivisors( Mfs_Man_t * p, Abc_Obj_t * pNode, int nLevDi
// start collecting the divisors
vDivs = Vec_PtrAlloc( p->pPars->nDivMax );
- Vec_PtrForEachEntry( vCone, pObj, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vCone, pObj, k )
{
if ( !Abc_NodeIsTravIdPrevious(pObj) )
continue;
@@ -235,7 +238,7 @@ Vec_Ptr_t * Abc_MfsComputeDivisors( Mfs_Man_t * p, Abc_Obj_t * pNode, int nLevDi
// explore the fanouts of already collected divisors
if ( Vec_PtrSize(vDivs) < p->pPars->nDivMax )
- Vec_PtrForEachEntry( vDivs, pObj, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vDivs, pObj, k )
{
// consider fanouts of this node
Abc_ObjForEachFanout( pObj, pFanout, f )
@@ -262,7 +265,7 @@ Vec_Ptr_t * Abc_MfsComputeDivisors( Mfs_Man_t * p, Abc_Obj_t * pNode, int nLevDi
if ( m < Abc_ObjFaninNum(pFanout) )
continue;
// make sure this divisor in not among the nodes
-// Vec_PtrForEachEntry( p->vNodes, pFanin, m )
+// Vec_PtrForEachEntry( Abc_Obj_t *, p->vNodes, pFanin, m )
// assert( pFanout != pFanin );
// add the node to the divisors
Vec_PtrPush( vDivs, pFanout );
@@ -278,7 +281,7 @@ Vec_Ptr_t * Abc_MfsComputeDivisors( Mfs_Man_t * p, Abc_Obj_t * pNode, int nLevDi
}
// sort the divisors by level in the increasing order
- Vec_PtrSort( vDivs, Abc_NodeCompareLevelsIncrease );
+ Vec_PtrSort( vDivs, (int (*)(void))Abc_NodeCompareLevelsIncrease );
// add the fanins of the node
Abc_ObjForEachFanin( pNode, pFanin, k )
@@ -286,7 +289,7 @@ Vec_Ptr_t * Abc_MfsComputeDivisors( Mfs_Man_t * p, Abc_Obj_t * pNode, int nLevDi
/*
printf( "Node level = %d. ", Abc_ObjLevel(p->pNode) );
- Vec_PtrForEachEntryStart( vDivs, pObj, k, Vec_PtrSize(vDivs)-p->nDivsPlus )
+ Vec_PtrForEachEntryStart( Abc_Obj_t *, vDivs, pObj, k, Vec_PtrSize(vDivs)-p->nDivsPlus )
printf( "%d ", Abc_ObjLevel(pObj) );
printf( "\n" );
*/
@@ -301,3 +304,5 @@ Vec_Ptr_t * Abc_MfsComputeDivisors( Mfs_Man_t * p, Abc_Obj_t * pNode, int nLevDi
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/mfs/mfsGia.c b/src/opt/mfs/mfsGia.c
new file mode 100644
index 00000000..016b4ae2
--- /dev/null
+++ b/src/opt/mfs/mfsGia.c
@@ -0,0 +1,299 @@
+/**CFile****************************************************************
+
+ FileName [mfsGia.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [The good old minimization with complete don't-cares.]
+
+ Synopsis [Experimental code based on the new AIG package.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - July 29, 2009.]
+
+ Revision [$Id: mfsGia.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "mfsInt.h"
+#include "giaAig.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+static inline int Gia_ObjChild0Copy( Aig_Obj_t * pObj ) { return Gia_LitNotCond( Aig_ObjFanin0(pObj)->iData, Aig_ObjFaninC0(pObj) ); }
+static inline int Gia_ObjChild1Copy( Aig_Obj_t * pObj ) { return Gia_LitNotCond( Aig_ObjFanin1(pObj)->iData, Aig_ObjFaninC1(pObj) ); }
+
+// r i10_if6.blif; ps; mfs -v
+// r pj1_if6.blif; ps; mfs -v
+// r x/01_if6.blif; ps; mfs -v
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Derives the resubstitution miter as an GIA.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManCreateResubMiter( Aig_Man_t * p )
+{
+ Gia_Man_t * pNew;//, * pTemp;
+ Aig_Obj_t * pObj;
+ int i, * pOuts0, * pOuts1;
+ Aig_ManSetPioNumbers( p );
+ // create the new manager
+ pNew = Gia_ManStart( Aig_ManObjNum(p) );
+ pNew->pName = Gia_UtilStrsav( p->pName );
+ Gia_ManHashAlloc( pNew );
+ // create the objects
+ pOuts0 = ABC_ALLOC( int, Aig_ManPoNum(p) );
+ Aig_ManForEachObj( p, pObj, i )
+ {
+ if ( Aig_ObjIsAnd(pObj) )
+ pObj->iData = Gia_ManHashAnd( pNew, Gia_ObjChild0Copy(pObj), Gia_ObjChild1Copy(pObj) );
+ else if ( Aig_ObjIsPi(pObj) )
+ pObj->iData = Gia_ManAppendCi( pNew );
+ else if ( Aig_ObjIsPo(pObj) )
+ pOuts0[ Aig_ObjPioNum(pObj) ] = Gia_ObjChild0Copy(pObj);
+ else if ( Aig_ObjIsConst1(pObj) )
+ pObj->iData = 1;
+ else
+ assert( 0 );
+ }
+ // create the objects
+ pOuts1 = ABC_ALLOC( int, Aig_ManPoNum(p) );
+ Aig_ManForEachObj( p, pObj, i )
+ {
+ if ( Aig_ObjIsAnd(pObj) )
+ pObj->iData = Gia_ManHashAnd( pNew, Gia_ObjChild0Copy(pObj), Gia_ObjChild1Copy(pObj) );
+ else if ( Aig_ObjIsPi(pObj) )
+ pObj->iData = Gia_ManAppendCi( pNew );
+ else if ( Aig_ObjIsPo(pObj) )
+ pOuts1[ Aig_ObjPioNum(pObj) ] = Gia_ObjChild0Copy(pObj);
+ else if ( Aig_ObjIsConst1(pObj) )
+ pObj->iData = 1;
+ else
+ assert( 0 );
+ }
+ // add the outputs
+ Gia_ManAppendCo( pNew, pOuts0[0] );
+ Gia_ManAppendCo( pNew, pOuts1[0] );
+ Gia_ManAppendCo( pNew, pOuts0[1] );
+ Gia_ManAppendCo( pNew, Gia_LitNot(pOuts1[1]) );
+ for ( i = 2; i < Aig_ManPoNum(p); i++ )
+ Gia_ManAppendCo( pNew, Gia_LitNot( Gia_ManHashXor(pNew, pOuts0[i], pOuts1[i]) ) );
+ Gia_ManHashStop( pNew );
+ ABC_FREE( pOuts0 );
+ ABC_FREE( pOuts1 );
+// pNew = Gia_ManCleanup( pTemp = pNew );
+// Gia_ManStop( pTemp );
+ return pNew;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Abc_NtkMfsConstructGia( Mfs_Man_t * p )
+{
+ int nBTLimit = 500;
+ // prepare AIG
+ assert( p->pGia == NULL );
+ p->pGia = Gia_ManCreateResubMiter( p->pAigWin );
+ // prepare AIG
+ Gia_ManCreateRefs( p->pGia );
+ Gia_ManCleanMark0( p->pGia );
+ Gia_ManCleanMark1( p->pGia );
+ Gia_ManFillValue ( p->pGia ); // maps nodes into trail ids
+ Gia_ManCleanPhase( p->pGia );
+ // prepare solver
+ p->pTas = Tas_ManAlloc( p->pGia, nBTLimit );
+ p->vCex = Tas_ReadModel( p->pTas );
+ p->vGiaLits = Vec_PtrAlloc( 100 );
+}
+
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Abc_NtkMfsDeconstructGia( Mfs_Man_t * p )
+{
+ assert( p->pGia != NULL );
+ Gia_ManStop( p->pGia ); p->pGia = NULL;
+ Tas_ManStop( p->pTas ); p->pTas = NULL;
+ Vec_PtrFree( p->vGiaLits );
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Abc_NtkMfsResimulate( Gia_Man_t * p, Vec_Int_t * vCex )
+{
+ Gia_Obj_t * pObj;
+ int i, Entry;
+// Gia_ManCleanMark1( p );
+ Gia_ManConst0(p)->fMark1 = 0;
+ Gia_ManForEachCi( p, pObj, i )
+ pObj->fMark1 = 0;
+// pObj->fMark1 = Gia_ManRandom(0);
+ Vec_IntForEachEntry( vCex, Entry, i )
+ {
+ pObj = Gia_ManCi( p, Gia_Lit2Var(Entry) );
+ pObj->fMark1 = !Gia_LitIsCompl(Entry);
+ }
+ Gia_ManForEachAnd( p, pObj, i )
+ pObj->fMark1 = (Gia_ObjFanin0(pObj)->fMark1 ^ Gia_ObjFaninC0(pObj)) &
+ (Gia_ObjFanin1(pObj)->fMark1 ^ Gia_ObjFaninC1(pObj));
+ Gia_ManForEachCo( p, pObj, i )
+ pObj->fMark1 = Gia_ObjFanin0(pObj)->fMark1 ^ Gia_ObjFaninC0(pObj);
+}
+
+
+
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_NtkMfsTryResubOnceGia( Mfs_Man_t * p, int * pCands, int nCands )
+{
+ int fVeryVerbose = 0;
+ int fUseGia = 1;
+ unsigned * pData;
+ int i, iVar, status, iOut, clk = clock();
+ p->nSatCalls++;
+// return -1;
+ assert( p->pGia != NULL );
+ assert( p->pTas != NULL );
+ // convert to literals
+ Vec_PtrClear( p->vGiaLits );
+ // create the first four literals
+ Vec_PtrPush( p->vGiaLits, Gia_ObjChild0(Gia_ManPo(p->pGia, 0)) );
+ Vec_PtrPush( p->vGiaLits, Gia_ObjChild0(Gia_ManPo(p->pGia, 1)) );
+ Vec_PtrPush( p->vGiaLits, Gia_ObjChild0(Gia_ManPo(p->pGia, 2)) );
+ Vec_PtrPush( p->vGiaLits, Gia_ObjChild0(Gia_ManPo(p->pGia, 3)) );
+ for ( i = 0; i < nCands; i++ )
+ {
+ // get the output number
+ iOut = Gia_Lit2Var(pCands[i]) - 2 * p->pCnf->nVars;
+ // write the literal
+ Vec_PtrPush( p->vGiaLits, Gia_ObjChild0(Gia_ManPo(p->pGia, 4 + iOut)) );
+ }
+ // perform SAT solving
+ status = Tas_ManSolveArray( p->pTas, p->vGiaLits );
+ if ( status == -1 )
+ {
+ p->nTimeOuts++;
+ if ( fVeryVerbose )
+ printf( "t" );
+// p->nSatUndec++;
+// p->nConfUndec += p->Pars.nBTThis;
+// Cec_ManSatAddToStore( vCexStore, NULL, i ); // timeout
+// p->timeSatUndec += clock() - clk;
+ }
+ else if ( status == 1 )
+ {
+ if ( fVeryVerbose )
+ printf( "u" );
+// p->nSatUnsat++;
+// p->nConfUnsat += p->Pars.nBTThis;
+// p->timeSatUnsat += clock() - clk;
+ }
+ else
+ {
+ p->nSatCexes++;
+ if ( fVeryVerbose )
+ printf( "s" );
+// p->nSatSat++;
+// p->nConfSat += p->Pars.nBTThis;
+// Gia_SatVerifyPattern( pAig, pRoot, vCex, vVisit );
+// Cec_ManSatAddToStore( vCexStore, vCex, i );
+// p->timeSatSat += clock() - clk;
+
+ // resimulate the counter-example
+ Abc_NtkMfsResimulate( p->pGia, Tas_ReadModel(p->pTas) );
+
+ if ( fUseGia )
+ {
+/*
+ int Val0 = Gia_ManPo(p->pGia, 0)->fMark1;
+ int Val1 = Gia_ManPo(p->pGia, 1)->fMark1;
+ int Val2 = Gia_ManPo(p->pGia, 2)->fMark1;
+ int Val3 = Gia_ManPo(p->pGia, 3)->fMark1;
+ assert( Val0 == 1 );
+ assert( Val1 == 1 );
+ assert( Val2 == 1 );
+ assert( Val3 == 1 );
+*/
+ // store the counter-example
+ Vec_IntForEachEntry( p->vProjVars, iVar, i )
+ {
+ pData = (unsigned *)Vec_PtrEntry( p->vDivCexes, i );
+ iOut = iVar - 2 * p->pCnf->nVars;
+// if ( !Gia_ManPo( p->pGia, 4 + iOut )->fMark1 ) // remove 0s!!!
+ if ( Gia_ManPo( p->pGia, 4 + iOut )->fMark1 ) // remove 0s!!! - rememeber complemented attribute
+ {
+ assert( Aig_InfoHasBit(pData, p->nCexes) );
+ Aig_InfoXorBit( pData, p->nCexes );
+ }
+ }
+ p->nCexes++;
+ }
+
+ }
+ return status;
+}
+
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/mfs/mfsInt.h b/src/opt/mfs/mfsInt.h
index 8adffd44..5611afa0 100644
--- a/src/opt/mfs/mfsInt.h
+++ b/src/opt/mfs/mfsInt.h
@@ -21,6 +21,7 @@
#ifndef __MFS_INT_H__
#define __MFS_INT_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -38,9 +39,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
#define MFS_FANIN_MAX 12
@@ -168,9 +170,11 @@ extern void Abc_NtkMfsConstructGia( Mfs_Man_t * p );
extern void Abc_NtkMfsDeconstructGia( Mfs_Man_t * p );
extern int Abc_NtkMfsTryResubOnceGia( Mfs_Man_t * p, int * pCands, int nCands );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/opt/mfs/mfsInter.c b/src/opt/mfs/mfsInter.c
index 9cacd021..1b3f2415 100644
--- a/src/opt/mfs/mfsInter.c
+++ b/src/opt/mfs/mfsInter.c
@@ -21,6 +21,9 @@
#include "mfsInt.h"
#include "kit.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -94,7 +97,7 @@ sat_solver * Abc_MfsCreateSolverResub( Mfs_Man_t * p, int * pCands, int nCands,
// collect the outputs of the divisors
Vec_IntClear( p->vProjVars );
- Vec_PtrForEachEntryStart( p->pAigWin->vPos, pObjPo, i, Aig_ManPoNum(p->pAigWin) - Vec_PtrSize(p->vDivs) )
+ Vec_PtrForEachEntryStart( Aig_Obj_t *, p->pAigWin->vPos, pObjPo, i, Aig_ManPoNum(p->pAigWin) - Vec_PtrSize(p->vDivs) )
{
assert( p->pCnf->pVarNums[pObjPo->Id] >= 0 );
Vec_IntPush( p->vProjVars, p->pCnf->pVarNums[pObjPo->Id] );
@@ -246,7 +249,7 @@ unsigned * Abc_NtkMfsInterplateTruth( Mfs_Man_t * p, int * pCands, int nCands, i
return NULL;
}
// get the learned clauses
- pCnf = sat_solver_store_release( pSat );
+ pCnf = (Sto_Man_t *)sat_solver_store_release( pSat );
sat_solver_delete( pSat );
// set the global variables
@@ -349,7 +352,7 @@ Hop_Obj_t * Abc_NtkMfsInterplate( Mfs_Man_t * p, int * pCands, int nCands )
//printf( "%d\n", pSat->stats.conflicts );
// ABC_PRT( "S", clock() - clk );
// get the learned clauses
- pCnf = sat_solver_store_release( pSat );
+ pCnf = (Sto_Man_t *)sat_solver_store_release( pSat );
sat_solver_delete( pSat );
// set the global variables
@@ -369,7 +372,7 @@ Hop_Obj_t * Abc_NtkMfsInterplate( Mfs_Man_t * p, int * pCands, int nCands )
// transform interpolant into AIG
pGraph = Kit_TruthToGraph( puTruth, nFanins, p->vMem );
- pFunc = Kit_GraphToHop( p->pNtk->pManFunc, pGraph );
+ pFunc = Kit_GraphToHop( (Hop_Man_t *)p->pNtk->pManFunc, pGraph );
Kit_GraphFree( pGraph );
return pFunc;
}
@@ -379,3 +382,5 @@ Hop_Obj_t * Abc_NtkMfsInterplate( Mfs_Man_t * p, int * pCands, int nCands )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/mfs/mfsMan.c b/src/opt/mfs/mfsMan.c
index 96a43368..74889c45 100644
--- a/src/opt/mfs/mfsMan.c
+++ b/src/opt/mfs/mfsMan.c
@@ -20,6 +20,9 @@
#include "mfsInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -210,3 +213,5 @@ void Mfs_ManStop( Mfs_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/mfs/mfsResub.c b/src/opt/mfs/mfsResub.c
index 49ce6901..38004089 100644
--- a/src/opt/mfs/mfsResub.c
+++ b/src/opt/mfs/mfsResub.c
@@ -20,6 +20,9 @@
#include "mfsInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -46,7 +49,7 @@ void Abc_NtkMfsUpdateNetwork( Mfs_Man_t * p, Abc_Obj_t * pObj, Vec_Ptr_t * vFani
// create the new node
pObjNew = Abc_NtkCreateNode( pObj->pNtk );
pObjNew->pData = pFunc;
- Vec_PtrForEachEntry( vFanins, pFanin, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vFanins, pFanin, k )
Abc_ObjAddFanin( pObjNew, pFanin );
// replace the old node by the new node
//printf( "Replacing node " ); Abc_ObjPrint( stdout, pObj );
@@ -136,7 +139,7 @@ p->timeGia += clock() - clk;
// store the counter-example
Vec_IntForEachEntry( p->vProjVars, iVar, i )
{
- pData = Vec_PtrEntry( p->vDivCexes, i );
+ pData = (unsigned *)Vec_PtrEntry( p->vDivCexes, i );
if ( !sat_solver_var_value( p->pSat, iVar ) ) // remove 0s!!!
{
assert( Aig_InfoHasBit(pData, p->nCexes) );
@@ -238,7 +241,7 @@ p->timeInt += clock() - clk;
printf( "%3d: %2d ", p->nCexes, iVar );
for ( i = 0; i < Vec_PtrSize(p->vDivs); i++ )
{
- pData = Vec_PtrEntry( p->vDivCexes, i );
+ pData = (unsigned *)Vec_PtrEntry( p->vDivCexes, i );
printf( "%d", Aig_InfoHasBit(pData, p->nCexes-1) );
}
printf( "\n" );
@@ -251,12 +254,12 @@ p->timeInt += clock() - clk;
{
if ( p->pPars->fPower )
{
- Abc_Obj_t * pDiv = Vec_PtrEntry(p->vDivs, iVar);
+ Abc_Obj_t * pDiv = (Abc_Obj_t *)Vec_PtrEntry(p->vDivs, iVar);
// only accept the divisor if it is "cool"
if ( Abc_MfsObjProb(p, pDiv) >= 0.15 )
continue;
}
- pData = Vec_PtrEntry( p->vDivCexes, iVar );
+ pData = (unsigned *)Vec_PtrEntry( p->vDivCexes, iVar );
for ( w = 0; w < nWords; w++ )
if ( pData[w] != ~0 )
break;
@@ -383,7 +386,7 @@ p->timeInt += clock() - clk;
printf( "%3d: %2d %2d ", p->nCexes, iVar, iVar2 );
for ( i = 0; i < Vec_PtrSize(p->vDivs); i++ )
{
- pData = Vec_PtrEntry( p->vDivCexes, i );
+ pData = (unsigned *)Vec_PtrEntry( p->vDivCexes, i );
printf( "%d", Aig_InfoHasBit(pData, p->nCexes-1) );
}
printf( "\n" );
@@ -395,11 +398,11 @@ p->timeInt += clock() - clk;
fBreak = 0;
for ( iVar = 1; iVar < Vec_PtrSize(p->vDivs)-Abc_ObjFaninNum(pNode); iVar++ )
{
- pData = Vec_PtrEntry( p->vDivCexes, iVar );
+ pData = (unsigned *)Vec_PtrEntry( p->vDivCexes, iVar );
#if 1 // sjang
if ( p->pPars->fPower )
{
- Abc_Obj_t * pDiv = Vec_PtrEntry(p->vDivs, iVar);
+ Abc_Obj_t * pDiv = (Abc_Obj_t *)Vec_PtrEntry(p->vDivs, iVar);
// only accept the divisor if it is "cool"
if ( Abc_MfsObjProb(p, pDiv) >= 0.12 )
continue;
@@ -407,11 +410,11 @@ p->timeInt += clock() - clk;
#endif
for ( iVar2 = 0; iVar2 < iVar; iVar2++ )
{
- pData2 = Vec_PtrEntry( p->vDivCexes, iVar2 );
+ pData2 = (unsigned *)Vec_PtrEntry( p->vDivCexes, iVar2 );
#if 1 // sjang
if ( p->pPars->fPower )
{
- Abc_Obj_t * pDiv = Vec_PtrEntry(p->vDivs, iVar2);
+ Abc_Obj_t * pDiv = (Abc_Obj_t *)Vec_PtrEntry(p->vDivs, iVar2);
// only accept the divisor if it is "cool"
if ( Abc_MfsObjProb(p, pDiv) >= 0.12 )
continue;
@@ -607,3 +610,5 @@ int Abc_NtkMfsResubNode2( Mfs_Man_t * p, Abc_Obj_t * pNode )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/mfs/mfsResub_.c b/src/opt/mfs/mfsResub_.c
index 47600b30..bca1285d 100644
--- a/src/opt/mfs/mfsResub_.c
+++ b/src/opt/mfs/mfsResub_.c
@@ -20,6 +20,9 @@
#include "mfsInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -558,3 +561,5 @@ int Abc_NtkMfsResubNode2( Mfs_Man_t * p, Abc_Obj_t * pNode )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/mfs/mfsSat.c b/src/opt/mfs/mfsSat.c
index eab80c53..c5806f2a 100644
--- a/src/opt/mfs/mfsSat.c
+++ b/src/opt/mfs/mfsSat.c
@@ -20,6 +20,9 @@
#include "mfsInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -95,7 +98,7 @@ int Abc_NtkMfsSolveSat( Mfs_Man_t * p, Abc_Obj_t * pNode )
int RetValue, i;
// collect projection variables
Vec_IntClear( p->vProjVars );
- Vec_PtrForEachEntryStart( p->pAigWin->vPos, pObjPo, i, Aig_ManPoNum(p->pAigWin) - Abc_ObjFaninNum(pNode) )
+ Vec_PtrForEachEntryStart( Aig_Obj_t *, p->pAigWin->vPos, pObjPo, i, Aig_ManPoNum(p->pAigWin) - Abc_ObjFaninNum(pNode) )
{
assert( p->pCnf->pVarNums[pObjPo->Id] >= 0 );
Vec_IntPush( p->vProjVars, p->pCnf->pVarNums[pObjPo->Id] );
@@ -175,3 +178,5 @@ int Abc_NtkAddOneHotness( Mfs_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/mfs/mfsStrash.c b/src/opt/mfs/mfsStrash.c
index 7e6c25da..a5c7b987 100644
--- a/src/opt/mfs/mfsStrash.c
+++ b/src/opt/mfs/mfsStrash.c
@@ -20,6 +20,8 @@
#include "mfsInt.h"
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -47,7 +49,7 @@ void Abc_MfsConvertAigToHop_rec( Aig_Obj_t * pObj, Hop_Man_t * pHop )
Abc_MfsConvertAigToHop_rec( Aig_ObjFanin0(pObj), pHop );
Abc_MfsConvertAigToHop_rec( Aig_ObjFanin1(pObj), pHop );
pObj->pData = Hop_And( pHop, (Hop_Obj_t *)Aig_ObjChild0Copy(pObj), (Hop_Obj_t *)Aig_ObjChild1Copy(pObj) );
- assert( !Hop_IsComplement(pObj->pData) );
+ assert( !Hop_IsComplement((Hop_Obj_t *)pObj->pData) );
}
/**Function*************************************************************
@@ -77,7 +79,7 @@ Hop_Obj_t * Abc_MfsConvertAigToHop( Aig_Man_t * pMan, Hop_Man_t * pHop )
pObj->pData = Hop_IthVar( pHop, i );
// construct the AIG
Abc_MfsConvertAigToHop_rec( Aig_ObjFanin0(pRoot), pHop );
- return Hop_NotCond( Aig_ObjFanin0(pRoot)->pData, Aig_ObjFaninC0(pRoot) );
+ return Hop_NotCond( (Hop_Obj_t *)Aig_ObjFanin0(pRoot)->pData, Aig_ObjFaninC0(pRoot) );
}
// should be called as follows: pNodeNew->pData = Abc_MfsConvertAigToHop( pAigManInterpol, pNodeNew->pNtk->pManFunc );
@@ -123,8 +125,8 @@ void Abc_MfsConvertHopToAig( Abc_Obj_t * pObjOld, Aig_Man_t * pMan )
Abc_Obj_t * pFanin;
int i;
// get the local AIG
- pHopMan = pObjOld->pNtk->pManFunc;
- pRoot = pObjOld->pData;
+ pHopMan = (Hop_Man_t *)pObjOld->pNtk->pManFunc;
+ pRoot = (Hop_Obj_t *)pObjOld->pData;
// check the case of a constant
if ( Hop_ObjIsConst1( Hop_Regular(pRoot) ) )
{
@@ -138,7 +140,7 @@ void Abc_MfsConvertHopToAig( Abc_Obj_t * pObjOld, Aig_Man_t * pMan )
Hop_ManPi(pHopMan, i)->pData = pFanin->pCopy;
// construct the AIG
Abc_MfsConvertHopToAig_rec( Hop_Regular(pRoot), pMan );
- pObjOld->pCopy = (Abc_Obj_t *)Aig_NotCond( Hop_Regular(pRoot)->pData, Hop_IsComplement(pRoot) );
+ pObjOld->pCopy = (Abc_Obj_t *)Aig_NotCond( (Aig_Obj_t *)Hop_Regular(pRoot)->pData, Hop_IsComplement(pRoot) );
Hop_ConeUnmark_rec( Hop_Regular(pRoot) );
// assign the fanin nodes
@@ -146,7 +148,7 @@ void Abc_MfsConvertHopToAig( Abc_Obj_t * pObjOld, Aig_Man_t * pMan )
Hop_ManPi(pHopMan, i)->pData = pFanin->pNext;
// construct the AIG
Abc_MfsConvertHopToAig_rec( Hop_Regular(pRoot), pMan );
- pObjOld->pNext = (Abc_Obj_t *)Aig_NotCond( Hop_Regular(pRoot)->pData, Hop_IsComplement(pRoot) );
+ pObjOld->pNext = (Abc_Obj_t *)Aig_NotCond( (Aig_Obj_t *)Hop_Regular(pRoot)->pData, Hop_IsComplement(pRoot) );
Hop_ConeUnmark_rec( Hop_Regular(pRoot) );
}
@@ -167,11 +169,11 @@ Aig_Obj_t * Abc_NtkConstructAig_rec( Mfs_Man_t * p, Abc_Obj_t * pNode, Aig_Man_t
Abc_Obj_t * pObj;
int i;
// assign AIG nodes to the leaves
- Vec_PtrForEachEntry( p->vSupp, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vSupp, pObj, i )
pObj->pCopy = pObj->pNext = (Abc_Obj_t *)Aig_ObjCreatePi( pMan );
// strash intermediate nodes
Abc_NtkIncrementTravId( pNode->pNtk );
- Vec_PtrForEachEntry( p->vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vNodes, pObj, i )
{
Abc_MfsConvertHopToAig( pObj, pMan );
if ( pObj == pNode )
@@ -179,7 +181,7 @@ Aig_Obj_t * Abc_NtkConstructAig_rec( Mfs_Man_t * p, Abc_Obj_t * pNode, Aig_Man_t
}
// create the observability condition
pRoot = Aig_ManConst0(pMan);
- Vec_PtrForEachEntry( p->vRoots, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vRoots, pObj, i )
{
pExor = Aig_Exor( pMan, (Aig_Obj_t *)pObj->pCopy, (Aig_Obj_t *)pObj->pNext );
pRoot = Aig_Or( pMan, pRoot, pExor );
@@ -202,19 +204,19 @@ Aig_Obj_t * Abc_NtkConstructCare_rec( Aig_Man_t * pCare, Aig_Obj_t * pObj, Aig_M
{
Aig_Obj_t * pObj0, * pObj1;
if ( Aig_ObjIsTravIdCurrent( pCare, pObj ) )
- return pObj->pData;
+ return (Aig_Obj_t *)pObj->pData;
Aig_ObjSetTravIdCurrent( pCare, pObj );
if ( Aig_ObjIsPi(pObj) )
- return pObj->pData = NULL;
+ return (Aig_Obj_t *)(pObj->pData = NULL);
pObj0 = Abc_NtkConstructCare_rec( pCare, Aig_ObjFanin0(pObj), pMan );
if ( pObj0 == NULL )
- return pObj->pData = NULL;
+ return (Aig_Obj_t *)(pObj->pData = NULL);
pObj1 = Abc_NtkConstructCare_rec( pCare, Aig_ObjFanin1(pObj), pMan );
if ( pObj1 == NULL )
- return pObj->pData = NULL;
+ return (Aig_Obj_t *)(pObj->pData = NULL);
pObj0 = Aig_NotCond( pObj0, Aig_ObjFaninC0(pObj) );
pObj1 = Aig_NotCond( pObj1, Aig_ObjFaninC1(pObj) );
- return pObj->pData = Aig_And( pMan, pObj0, pObj1 );
+ return (Aig_Obj_t *)(pObj->pData = Aig_And( pMan, pObj0, pObj1 ));
}
/**Function*************************************************************
@@ -245,16 +247,16 @@ Aig_Man_t * Abc_NtkConstructAig( Mfs_Man_t * p, Abc_Obj_t * pNode )
{
// mark the care set
Aig_ManIncrementTravId( p->pCare );
- Vec_PtrForEachEntry( p->vSupp, pFanin, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vSupp, pFanin, i )
{
pPi = Aig_ManPi( p->pCare, (int)(ABC_PTRUINT_T)pFanin->pData );
Aig_ObjSetTravIdCurrent( p->pCare, pPi );
pPi->pData = pFanin->pCopy;
}
// construct the constraints
- Vec_PtrForEachEntry( p->vSupp, pFanin, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vSupp, pFanin, i )
{
- vOuts = Vec_PtrEntry( p->vSuppsInv, (int)(ABC_PTRUINT_T)pFanin->pData );
+ vOuts = (Vec_Int_t *)Vec_PtrEntry( p->vSuppsInv, (int)(ABC_PTRUINT_T)pFanin->pData );
Vec_IntForEachEntry( vOuts, iOut, k )
{
pPo = Aig_ManPo( p->pCare, iOut );
@@ -290,7 +292,7 @@ Aig_Man_t * Abc_NtkConstructAig( Mfs_Man_t * p, Abc_Obj_t * pNode )
pObjAig = (Aig_Obj_t *)pNode->pCopy;
Aig_ObjCreatePo( pMan, pObjAig );
// construct the divisors
- Vec_PtrForEachEntry( p->vDivs, pFanin, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vDivs, pFanin, i )
{
pObjAig = (Aig_Obj_t *)pFanin->pCopy;
Aig_ObjCreatePo( pMan, pObjAig );
@@ -332,7 +334,7 @@ Aig_Man_t * Abc_NtkAigForConstraints( Mfs_Man_t * p, Abc_Obj_t * pNode )
pMan = Aig_ManStart( 1000 );
// mark the care set
Aig_ManIncrementTravId( p->pCare );
- Vec_PtrForEachEntry( p->vSupp, pFanin, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vSupp, pFanin, i )
{
pPi = Aig_ManPi( p->pCare, (int)(ABC_PTRUINT_T)pFanin->pData );
Aig_ObjSetTravIdCurrent( p->pCare, pPi );
@@ -340,9 +342,9 @@ Aig_Man_t * Abc_NtkAigForConstraints( Mfs_Man_t * p, Abc_Obj_t * pNode )
}
// construct the constraints
pObjRoot = Aig_ManConst1(pMan);
- Vec_PtrForEachEntry( p->vSupp, pFanin, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vSupp, pFanin, i )
{
- vOuts = Vec_PtrEntry( p->vSuppsInv, (int)(ABC_PTRUINT_T)pFanin->pData );
+ vOuts = (Vec_Int_t *)Vec_PtrEntry( p->vSuppsInv, (int)(ABC_PTRUINT_T)pFanin->pData );
Vec_IntForEachEntry( vOuts, iOut, k )
{
pPo = Aig_ManPo( p->pCare, iOut );
@@ -363,8 +365,13 @@ Aig_Man_t * Abc_NtkAigForConstraints( Mfs_Man_t * p, Abc_Obj_t * pNode )
return pMan;
}
+ABC_NAMESPACE_IMPL_END
+
#include "fra.h"
+ABC_NAMESPACE_IMPL_START
+
+
/**Function*************************************************************
Synopsis [Compute the ratio of don't-cares.]
@@ -395,3 +402,5 @@ double Abc_NtkConstraintRatio( Mfs_Man_t * p, Abc_Obj_t * pNode )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/mfs/mfsWin.c b/src/opt/mfs/mfsWin.c
index e3e5e24e..2ed996be 100644
--- a/src/opt/mfs/mfsWin.c
+++ b/src/opt/mfs/mfsWin.c
@@ -20,6 +20,9 @@
#include "mfsInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -110,3 +113,5 @@ Vec_Ptr_t * Abc_MfsComputeRoots( Abc_Obj_t * pNode, int nWinTfoMax, int nFanoutL
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/mfs/mfs_.c b/src/opt/mfs/mfs_.c
index 32caf7ff..2682fa42 100644
--- a/src/opt/mfs/mfs_.c
+++ b/src/opt/mfs/mfs_.c
@@ -20,6 +20,9 @@
#include "mfsInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -45,3 +48,5 @@
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/res/res.h b/src/opt/res/res.h
index 88d985a3..bd328d54 100644
--- a/src/opt/res/res.h
+++ b/src/opt/res/res.h
@@ -21,6 +21,7 @@
#ifndef __RES_H__
#define __RES_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -29,9 +30,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -63,9 +65,11 @@ struct Res_Par_t_
extern int Abc_NtkResynthesize( Abc_Ntk_t * pNtk, Res_Par_t * pPars );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/opt/res/resCore.c b/src/opt/res/resCore.c
index cce3b48a..c27b3874 100644
--- a/src/opt/res/resCore.c
+++ b/src/opt/res/resCore.c
@@ -23,6 +23,9 @@
#include "kit.h"
#include "satStore.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -187,7 +190,7 @@ void Res_UpdateNetwork( Abc_Obj_t * pObj, Vec_Ptr_t * vFanins, Hop_Obj_t * pFunc
// create the new node
pObjNew = Abc_NtkCreateNode( pObj->pNtk );
pObjNew->pData = pFunc;
- Vec_PtrForEachEntry( vFanins, pFanin, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vFanins, pFanin, k )
Abc_ObjAddFanin( pObjNew, pFanin );
// replace the old node by the new node
//printf( "Replacing node " ); Abc_ObjPrint( stdout, pObj );
@@ -316,8 +319,8 @@ p->timeSim += clock() - clk;
{
p->nConstsUsed++;
- pFunc = p->pSim->fConst1? Hop_ManConst1(pNtk->pManFunc) : Hop_ManConst0(pNtk->pManFunc);
- vFanins = Vec_VecEntry( p->vResubsW, 0 );
+ pFunc = p->pSim->fConst1? Hop_ManConst1((Hop_Man_t *)pNtk->pManFunc) : Hop_ManConst0((Hop_Man_t *)pNtk->pManFunc);
+ vFanins = (Vec_Ptr_t *)Vec_VecEntry( p->vResubsW, 0 );
Vec_PtrClear( vFanins );
Res_UpdateNetwork( pObj, vFanins, pFunc, p->vLevels );
continue;
@@ -349,7 +352,7 @@ p->timeCand += clock() - clk;
// solve the SAT problem and get clauses
clk = clock();
if ( p->pCnf ) Sto_ManFree( p->pCnf );
- p->pCnf = Res_SatProveUnsat( p->pAig, vFanins );
+ p->pCnf = (Sto_Man_t *)Res_SatProveUnsat( p->pAig, vFanins );
if ( p->pCnf == NULL )
{
p->timeSatSat += clock() - clk;
@@ -381,12 +384,12 @@ p->timeInt += clock() - clk;
pGraph = Kit_TruthToGraph( puTruth, nFanins, p->vMem );
// derive the AIG for the decomposition tree
- pFunc = Kit_GraphToHop( pNtk->pManFunc, pGraph );
+ pFunc = Kit_GraphToHop( (Hop_Man_t *)pNtk->pManFunc, pGraph );
Kit_GraphFree( pGraph );
// update the network
clk = clock();
- Res_UpdateNetwork( pObj, Vec_VecEntry(p->vResubsW, k), pFunc, p->vLevels );
+ Res_UpdateNetwork( pObj, (Vec_Ptr_t *)Vec_VecEntry(p->vResubsW, k), pFunc, p->vLevels );
p->timeUpd += clock() - clk;
break;
}
@@ -420,3 +423,5 @@ s_ResynTime += clock() - clkTotal;
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/res/resDivs.c b/src/opt/res/resDivs.c
index f6c8a801..6d9ffd9f 100644
--- a/src/opt/res/resDivs.c
+++ b/src/opt/res/resDivs.c
@@ -21,6 +21,9 @@
#include "abc.h"
#include "resInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -70,7 +73,7 @@ void Res_WinDivisors( Res_Win_t * p, int nLevDivMax )
// start collecting the divisors
Vec_PtrClear( p->vDivs );
- Vec_PtrForEachEntry( p->vLeaves, pObj, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vLeaves, pObj, k )
{
assert( (int)pObj->Level >= p->nLevLeafMin );
if ( !Abc_NodeIsTravIdPrevious(pObj) )
@@ -80,7 +83,7 @@ void Res_WinDivisors( Res_Win_t * p, int nLevDivMax )
Vec_PtrPush( p->vDivs, pObj );
}
// add the internal nodes to the data structure
- Vec_PtrForEachEntry( p->vNodes, pObj, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vNodes, pObj, k )
{
if ( !Abc_NodeIsTravIdPrevious(pObj) )
continue;
@@ -91,7 +94,7 @@ void Res_WinDivisors( Res_Win_t * p, int nLevDivMax )
// explore the fanouts of already collected divisors
p->nDivsPlus = 0;
- Vec_PtrForEachEntry( p->vDivs, pObj, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vDivs, pObj, k )
{
// consider fanouts of this node
Abc_ObjForEachFanout( pObj, pFanout, f )
@@ -126,7 +129,7 @@ void Res_WinDivisors( Res_Win_t * p, int nLevDivMax )
}
/*
printf( "Node level = %d. ", Abc_ObjLevel(p->pNode) );
- Vec_PtrForEachEntryStart( p->vDivs, pObj, k, Vec_PtrSize(p->vDivs)-p->nDivsPlus )
+ Vec_PtrForEachEntryStart( Abc_Obj_t *, p->vDivs, pObj, k, Vec_PtrSize(p->vDivs)-p->nDivsPlus )
printf( "%d ", Abc_ObjLevel(pObj) );
printf( "\n" );
*/
@@ -173,7 +176,7 @@ void Res_WinMarkTfi( Res_Win_t * p )
Abc_Obj_t * pObj;
int i;
// mark the leaves
- Vec_PtrForEachEntry( p->vLeaves, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vLeaves, pObj, i )
Abc_NodeSetTravIdCurrent( pObj );
// start from the node
Res_WinMarkTfi_rec( p, p->pNode );
@@ -283,3 +286,5 @@ int Res_WinVisitMffc( Abc_Obj_t * pNode )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/res/resFilter.c b/src/opt/res/resFilter.c
index f2ca41d3..b9d62dd8 100644
--- a/src/opt/res/resFilter.c
+++ b/src/opt/res/resFilter.c
@@ -21,6 +21,9 @@
#include "abc.h"
#include "resInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -50,7 +53,7 @@ int Res_FilterCandidates( Res_Win_t * pWin, Abc_Ntk_t * pAig, Res_Sim_t * pSim,
int Counter, RetValue, i, i2, d, d2, iDiv, iDiv2, k;
// check that the info the node is one
- pInfo = Vec_PtrEntry( pSim->vOuts, 1 );
+ pInfo = (unsigned *)Vec_PtrEntry( pSim->vOuts, 1 );
RetValue = Abc_InfoIsOne( pInfo, pSim->nWordsOut );
if ( RetValue == 0 )
{
@@ -109,7 +112,7 @@ int Res_FilterCandidates( Res_Win_t * pWin, Abc_Ntk_t * pAig, Res_Sim_t * pSim,
// go over the set of divisors
for ( d = Abc_ObjFaninNum(pWin->pNode) + 2; d < Abc_NtkPoNum(pAig); d++ )
{
- pInfoDiv = Vec_PtrEntry( pSim->vOuts, d );
+ pInfoDiv = (unsigned *)Vec_PtrEntry( pSim->vOuts, d );
iDiv = d - (Abc_ObjFaninNum(pWin->pNode) + 2);
if ( !Abc_InfoIsOrOne( pInfo, pInfoDiv, pSim->nWordsOut ) )
continue;
@@ -147,12 +150,12 @@ int Res_FilterCandidates( Res_Win_t * pWin, Abc_Ntk_t * pAig, Res_Sim_t * pSim,
// go over the set of divisors
for ( d = Abc_ObjFaninNum(pWin->pNode) + 2; d < Abc_NtkPoNum(pAig); d++ )
{
- pInfoDiv = Vec_PtrEntry( pSim->vOuts, d );
+ pInfoDiv = (unsigned *)Vec_PtrEntry( pSim->vOuts, d );
iDiv = d - (Abc_ObjFaninNum(pWin->pNode) + 2);
// go through the second divisor
for ( d2 = d + 1; d2 < Abc_NtkPoNum(pAig); d2++ )
{
- pInfoDiv2 = Vec_PtrEntry( pSim->vOuts, d2 );
+ pInfoDiv2 = (unsigned *)Vec_PtrEntry( pSim->vOuts, d2 );
iDiv2 = d2 - (Abc_ObjFaninNum(pWin->pNode) + 2);
if ( !Abc_InfoIsOrOne3( pInfo, pInfoDiv, pInfoDiv2, pSim->nWordsOut ) )
continue;
@@ -194,7 +197,7 @@ int Res_FilterCandidates( Res_Win_t * pWin, Abc_Ntk_t * pAig, Res_Sim_t * pSim,
// go over the set of divisors
for ( d = Abc_ObjFaninNum(pWin->pNode) + 2; d < Abc_NtkPoNum(pAig); d++ )
{
- pInfoDiv = Vec_PtrEntry( pSim->vOuts, d );
+ pInfoDiv = (unsigned *)Vec_PtrEntry( pSim->vOuts, d );
iDiv = d - (Abc_ObjFaninNum(pWin->pNode) + 2);
if ( !Abc_InfoIsOrOne( pInfo, pInfoDiv, pSim->nWordsOut ) )
continue;
@@ -242,7 +245,7 @@ int Res_FilterCandidatesArea( Res_Win_t * pWin, Abc_Ntk_t * pAig, Res_Sim_t * pS
int Counter, RetValue, d, d2, k, iDiv, iDiv2, iBest;
// check that the info the node is one
- pInfo = Vec_PtrEntry( pSim->vOuts, 1 );
+ pInfo = (unsigned *)Vec_PtrEntry( pSim->vOuts, 1 );
RetValue = Abc_InfoIsOne( pInfo, pSim->nWordsOut );
if ( RetValue == 0 )
{
@@ -294,7 +297,7 @@ int Res_FilterCandidatesArea( Res_Win_t * pWin, Abc_Ntk_t * pAig, Res_Sim_t * pS
// go through the divisors
for ( d = Abc_ObjFaninNum(pWin->pNode) + 2; d < Abc_NtkPoNum(pAig); d++ )
{
- pInfoDiv = Vec_PtrEntry( pSim->vOuts, d );
+ pInfoDiv = (unsigned *)Vec_PtrEntry( pSim->vOuts, d );
iDiv = d - (Abc_ObjFaninNum(pWin->pNode) + 2);
if ( !Abc_InfoIsOrOne( pInfo, pInfoDiv, pSim->nWordsOut ) )
continue;
@@ -327,12 +330,12 @@ int Res_FilterCandidatesArea( Res_Win_t * pWin, Abc_Ntk_t * pAig, Res_Sim_t * pS
// try to find the node pairs
for ( d = Abc_ObjFaninNum(pWin->pNode) + 2; d < Abc_NtkPoNum(pAig); d++ )
{
- pInfoDiv = Vec_PtrEntry( pSim->vOuts, d );
+ pInfoDiv = (unsigned *)Vec_PtrEntry( pSim->vOuts, d );
iDiv = d - (Abc_ObjFaninNum(pWin->pNode) + 2);
// go through the second divisor
for ( d2 = d + 1; d2 < Abc_NtkPoNum(pAig); d2++ )
{
- pInfoDiv2 = Vec_PtrEntry( pSim->vOuts, d2 );
+ pInfoDiv2 = (unsigned *)Vec_PtrEntry( pSim->vOuts, d2 );
iDiv2 = d2 - (Abc_ObjFaninNum(pWin->pNode) + 2);
if ( !Abc_InfoIsOrOne3( pInfo, pInfoDiv, pInfoDiv2, pSim->nWordsOut ) )
@@ -382,12 +385,12 @@ unsigned * Res_FilterCollectFaninInfo( Res_Win_t * pWin, Res_Sim_t * pSim, unsig
Abc_Obj_t * pFanin;
unsigned * pInfo;
int i;
- pInfo = Vec_PtrEntry( pSim->vOuts, 0 );
+ pInfo = (unsigned *)Vec_PtrEntry( pSim->vOuts, 0 );
Abc_InfoClear( pInfo, pSim->nWordsOut );
Abc_ObjForEachFanin( pWin->pNode, pFanin, i )
{
if ( uMask & (1 << i) )
- Abc_InfoOr( pInfo, Vec_PtrEntry(pSim->vOuts, 2+i), pSim->nWordsOut );
+ Abc_InfoOr( pInfo, (unsigned *)Vec_PtrEntry(pSim->vOuts, 2+i), pSim->nWordsOut );
}
return pInfo;
}
@@ -432,3 +435,5 @@ int Res_FilterCriticalFanin( Abc_Obj_t * pNode )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/res/resInt.h b/src/opt/res/resInt.h
index 172b5369..ae238359 100644
--- a/src/opt/res/resInt.h
+++ b/src/opt/res/resInt.h
@@ -21,6 +21,7 @@
#ifndef __RES_INT_H__
#define __RES_INT_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -31,9 +32,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -125,9 +127,11 @@ extern int Res_WinIsTrivial( Res_Win_t * p );
extern int Res_WinCompute( Abc_Obj_t * pNode, int nWinTfiMax, int nWinTfoMax, Res_Win_t * p );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/opt/res/resSat.c b/src/opt/res/resSat.c
index d5983942..a17f92fa 100644
--- a/src/opt/res/resSat.c
+++ b/src/opt/res/resSat.c
@@ -23,6 +23,9 @@
#include "hop.h"
#include "satSolver.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -55,7 +58,7 @@ void * Res_SatProveUnsat( Abc_Ntk_t * pAig, Vec_Ptr_t * vFanins )
int i, nNodes, status;
// make sure fanins contain POs of the AIG
- pObj = Vec_PtrEntry( vFanins, 0 );
+ pObj = (Abc_Obj_t *)Vec_PtrEntry( vFanins, 0 );
assert( pObj->pNtk == pAig && Abc_ObjIsPo(pObj) );
// collect reachable nodes
@@ -63,13 +66,13 @@ void * Res_SatProveUnsat( Abc_Ntk_t * pAig, Vec_Ptr_t * vFanins )
// assign unique numbers to each node
nNodes = 0;
- Abc_AigConst1(pAig)->pCopy = (void *)(ABC_PTRUINT_T)nNodes++;
+ Abc_AigConst1(pAig)->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)nNodes++;
Abc_NtkForEachPi( pAig, pObj, i )
- pObj->pCopy = (void *)(ABC_PTRUINT_T)nNodes++;
- Vec_PtrForEachEntry( vNodes, pObj, i )
- pObj->pCopy = (void *)(ABC_PTRUINT_T)nNodes++;
- Vec_PtrForEachEntry( vFanins, pObj, i ) // useful POs
- pObj->pCopy = (void *)(ABC_PTRUINT_T)nNodes++;
+ pObj->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)nNodes++;
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
+ pObj->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)nNodes++;
+ Vec_PtrForEachEntry( Abc_Obj_t *, vFanins, pObj, i ) // useful POs
+ pObj->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)nNodes++;
// start the solver
pSat = sat_solver_new();
@@ -78,28 +81,28 @@ void * Res_SatProveUnsat( Abc_Ntk_t * pAig, Vec_Ptr_t * vFanins )
// add clause for the constant node
Res_SatAddConst1( pSat, (int)(ABC_PTRUINT_T)Abc_AigConst1(pAig)->pCopy, 0 );
// add clauses for AND gates
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
Res_SatAddAnd( pSat, (int)(ABC_PTRUINT_T)pObj->pCopy,
(int)(ABC_PTRUINT_T)Abc_ObjFanin0(pObj)->pCopy, (int)(ABC_PTRUINT_T)Abc_ObjFanin1(pObj)->pCopy, Abc_ObjFaninC0(pObj), Abc_ObjFaninC1(pObj) );
Vec_PtrFree( vNodes );
// add clauses for POs
- Vec_PtrForEachEntry( vFanins, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vFanins, pObj, i )
Res_SatAddEqual( pSat, (int)(ABC_PTRUINT_T)pObj->pCopy,
(int)(ABC_PTRUINT_T)Abc_ObjFanin0(pObj)->pCopy, Abc_ObjFaninC0(pObj) );
// add trivial clauses
- pObj = Vec_PtrEntry(vFanins, 0);
+ pObj = (Abc_Obj_t *)Vec_PtrEntry(vFanins, 0);
Res_SatAddConst1( pSat, (int)(ABC_PTRUINT_T)pObj->pCopy, 0 ); // care-set
- pObj = Vec_PtrEntry(vFanins, 1);
+ pObj = (Abc_Obj_t *)Vec_PtrEntry(vFanins, 1);
Res_SatAddConst1( pSat, (int)(ABC_PTRUINT_T)pObj->pCopy, 0 ); // on-set
// bookmark the clauses of A
sat_solver_store_mark_clauses_a( pSat );
// duplicate the clauses
- pObj = Vec_PtrEntry(vFanins, 1);
+ pObj = (Abc_Obj_t *)Vec_PtrEntry(vFanins, 1);
Sat_SolverDoubleClauses( pSat, (int)(ABC_PTRUINT_T)pObj->pCopy );
// add the equality constraints
- Vec_PtrForEachEntryStart( vFanins, pObj, i, 2 )
+ Vec_PtrForEachEntryStart( Abc_Obj_t *, vFanins, pObj, i, 2 )
Res_SatAddEqual( pSat, (int)(ABC_PTRUINT_T)pObj->pCopy, ((int)(ABC_PTRUINT_T)pObj->pCopy) + nNodes, 0 );
// bookmark the roots
@@ -155,13 +158,13 @@ void * Res_SatSimulateConstr( Abc_Ntk_t * pAig, int fOnSet )
// assign unique numbers to each node
nNodes = 0;
- Abc_AigConst1(pAig)->pCopy = (void *)(ABC_PTRUINT_T)nNodes++;
+ Abc_AigConst1(pAig)->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)nNodes++;
Abc_NtkForEachPi( pAig, pObj, i )
- pObj->pCopy = (void *)(ABC_PTRUINT_T)nNodes++;
- Vec_PtrForEachEntry( vNodes, pObj, i )
- pObj->pCopy = (void *)(ABC_PTRUINT_T)nNodes++;
- Vec_PtrForEachEntry( vFanins, pObj, i ) // useful POs
- pObj->pCopy = (void *)(ABC_PTRUINT_T)nNodes++;
+ pObj->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)nNodes++;
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
+ pObj->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)nNodes++;
+ Vec_PtrForEachEntry( Abc_Obj_t *, vFanins, pObj, i ) // useful POs
+ pObj->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)nNodes++;
// start the solver
pSat = sat_solver_new();
@@ -169,7 +172,7 @@ void * Res_SatSimulateConstr( Abc_Ntk_t * pAig, int fOnSet )
// add clause for the constant node
Res_SatAddConst1( pSat, (int)(ABC_PTRUINT_T)Abc_AigConst1(pAig)->pCopy, 0 );
// add clauses for AND gates
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
Res_SatAddAnd( pSat, (int)(ABC_PTRUINT_T)pObj->pCopy,
(int)(ABC_PTRUINT_T)Abc_ObjFanin0(pObj)->pCopy, (int)(ABC_PTRUINT_T)Abc_ObjFanin1(pObj)->pCopy, Abc_ObjFaninC0(pObj), Abc_ObjFaninC1(pObj) );
Vec_PtrFree( vNodes );
@@ -232,7 +235,7 @@ int Res_SatSimulate( Res_Sim_t * p, int nPatsLimit, int fOnSet )
assert( iPat < nPatsLimit );
// derive the SAT solver
- pSat = Res_SatSimulateConstr( p->pAig, fOnSet );
+ pSat = (sat_solver *)Res_SatSimulateConstr( p->pAig, fOnSet );
pSat->fSkipSimplify = 1;
status = sat_solver_simplify( pSat );
if ( status == 0 )
@@ -278,7 +281,7 @@ int Res_SatSimulate( Res_Sim_t * p, int nPatsLimit, int fOnSet )
Var = (int)(ABC_PTRUINT_T)Abc_NtkPi(p->pAig,i)->pCopy;
value = (int)(pSat->model.ptr[Var] == l_True);
if ( value )
- Abc_InfoSetBit( Vec_PtrEntry(vPats, i), k );
+ Abc_InfoSetBit( (unsigned *)Vec_PtrEntry(vPats, i), k );
Lit = toLitCond( Var, value );
Vec_IntPush( vLits, Lit );
// printf( "%d", value );
@@ -406,3 +409,5 @@ int Res_SatAddAnd( sat_solver * pSat, int iVar, int iVar0, int iVar1, int fCompl
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/res/resSim.c b/src/opt/res/resSim.c
index 59b2b6ea..560acc43 100644
--- a/src/opt/res/resSim.c
+++ b/src/opt/res/resSim.c
@@ -21,6 +21,9 @@
#include "abc.h"
#include "resInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -102,8 +105,8 @@ void Res_SimAdjust( Res_Sim_t * p, Abc_Ntk_t * pAig, int nTruePis )
p->vOuts = Vec_PtrAllocSimInfo( Abc_NtkPoNum(pAig), p->nWordsOut );
}
// clean storage info for patterns
- Abc_InfoClear( Vec_PtrEntry(p->vPats0,0), p->nWords * nTruePis );
- Abc_InfoClear( Vec_PtrEntry(p->vPats1,0), p->nWords * nTruePis );
+ Abc_InfoClear( (unsigned *)Vec_PtrEntry(p->vPats0,0), p->nWords * nTruePis );
+ Abc_InfoClear( (unsigned *)Vec_PtrEntry(p->vPats1,0), p->nWords * nTruePis );
p->nPats0 = 0;
p->nPats1 = 0;
p->fConst0 = 0;
@@ -175,7 +178,7 @@ void Res_SimSetRandomBytes( Res_Sim_t * p )
int i;
Abc_NtkForEachPi( p->pAig, pObj, i )
{
- pInfo = Vec_PtrEntry( p->vPats, pObj->Id );
+ pInfo = (unsigned *)Vec_PtrEntry( p->vPats, pObj->Id );
if ( i < p->nTruePis )
Abc_InfoRandomBytes( pInfo, p->nWordsIn );
else
@@ -220,7 +223,7 @@ void Res_SimSetDerivedBytes( Res_Sim_t * p, int fUseWalk )
{
if ( i == p->nTruePis )
break;
- Abc_InfoRandomBytes( Vec_PtrEntry(p->vPats, pObj->Id), nPats/4 );
+ Abc_InfoRandomBytes( (unsigned *)Vec_PtrEntry(p->vPats, pObj->Id), nPats/4 );
}
// set special patterns
@@ -283,7 +286,7 @@ void Res_SimSetDerivedBytes( Res_Sim_t * p, int fUseWalk )
if ( i == p->nTruePis )
break;
pInfo = (unsigned char *)Vec_PtrEntry( p->vPats, pObj->Id );
- if ( (i == k) ^ Abc_InfoHasBit( Vec_PtrEntry(vPatsSource[z], i), s ) )
+ if ( (i == k) ^ Abc_InfoHasBit( (unsigned *)Vec_PtrEntry(vPatsSource[z], i), s ) )
{
pInfo[nPats] = 0xff;
// if ( s == 0 )
@@ -347,8 +350,8 @@ void Res_SimSetGiven( Res_Sim_t * p, Vec_Ptr_t * vInfo )
{
if ( i == p->nTruePis )
break;
- pInfo = Vec_PtrEntry( p->vPats, pObj->Id );
- pInfo2 = Vec_PtrEntry( vInfo, i );
+ pInfo = (unsigned *)Vec_PtrEntry( p->vPats, pObj->Id );
+ pInfo2 = (unsigned *)Vec_PtrEntry( vInfo, i );
for ( w = 0; w < p->nWords; w++ )
pInfo[w] = pInfo2[w];
}
@@ -371,9 +374,9 @@ void Res_SimPerformOne( Abc_Obj_t * pNode, Vec_Ptr_t * vSimInfo, int nSimWords )
int k, fComp1, fComp2;
// simulate the internal nodes
assert( Abc_ObjIsNode(pNode) );
- pInfo = Vec_PtrEntry(vSimInfo, pNode->Id);
- pInfo1 = Vec_PtrEntry(vSimInfo, Abc_ObjFaninId0(pNode));
- pInfo2 = Vec_PtrEntry(vSimInfo, Abc_ObjFaninId1(pNode));
+ pInfo = (unsigned *)Vec_PtrEntry(vSimInfo, pNode->Id);
+ pInfo1 = (unsigned *)Vec_PtrEntry(vSimInfo, Abc_ObjFaninId0(pNode));
+ pInfo2 = (unsigned *)Vec_PtrEntry(vSimInfo, Abc_ObjFaninId1(pNode));
fComp1 = Abc_ObjFaninC0(pNode);
fComp2 = Abc_ObjFaninC1(pNode);
if ( fComp1 && fComp2 )
@@ -407,8 +410,8 @@ void Res_SimTransferOne( Abc_Obj_t * pNode, Vec_Ptr_t * vSimInfo, int nSimWords
int k, fComp1;
// simulate the internal nodes
assert( Abc_ObjIsCo(pNode) );
- pInfo = Vec_PtrEntry(vSimInfo, pNode->Id);
- pInfo1 = Vec_PtrEntry(vSimInfo, Abc_ObjFaninId0(pNode));
+ pInfo = (unsigned *)Vec_PtrEntry(vSimInfo, pNode->Id);
+ pInfo1 = (unsigned *)Vec_PtrEntry(vSimInfo, Abc_ObjFaninId0(pNode));
fComp1 = Abc_ObjFaninC0(pNode);
if ( fComp1 )
for ( k = 0; k < nSimWords; k++ )
@@ -433,7 +436,7 @@ void Res_SimPerformRound( Res_Sim_t * p, int nWords )
{
Abc_Obj_t * pObj;
int i;
- Abc_InfoFill( Vec_PtrEntry(p->vPats,0), nWords );
+ Abc_InfoFill( (unsigned *)Vec_PtrEntry(p->vPats,0), nWords );
Abc_AigForEachAnd( p->pAig, pObj, i )
Res_SimPerformOne( pObj, p->vPats, nWords );
Abc_NtkForEachPo( p->pAig, pObj, i )
@@ -460,14 +463,14 @@ void Res_SimPadSimInfo( Vec_Ptr_t * vPats, int nPats, int nWords )
// pad the first word
if ( nPats < 8 * sizeof(unsigned) )
{
- Vec_PtrForEachEntry( vPats, pInfo, i )
+ Vec_PtrForEachEntry( unsigned *, vPats, pInfo, i )
if ( pInfo[0] & 1 )
pInfo[0] |= ((~0) << nPats);
nPats = 8 * sizeof(unsigned);
}
// pad the empty words
iWords = nPats / (8 * sizeof(unsigned));
- Vec_PtrForEachEntry( vPats, pInfo, i )
+ Vec_PtrForEachEntry( unsigned *, vPats, pInfo, i )
{
for ( w = iWords; w < nWords; w++ )
pInfo[w] = pInfo[0];
@@ -492,8 +495,8 @@ void Res_SimDeriveInfoReplicate( Res_Sim_t * p )
int i, j, w;
Abc_NtkForEachPo( p->pAig, pObj, i )
{
- pInfo = Vec_PtrEntry( p->vPats, pObj->Id );
- pInfo2 = Vec_PtrEntry( p->vOuts, i );
+ pInfo = (unsigned *)Vec_PtrEntry( p->vPats, pObj->Id );
+ pInfo2 = (unsigned *)Vec_PtrEntry( p->vOuts, i );
for ( j = 0; j < p->nPats; j++ )
for ( w = 0; w < p->nWords; w++ )
*pInfo2++ = pInfo[w];
@@ -518,8 +521,8 @@ void Res_SimDeriveInfoComplement( Res_Sim_t * p )
int i, j, w;
Abc_NtkForEachPo( p->pAig, pObj, i )
{
- pInfo = Vec_PtrEntry( p->vPats, pObj->Id );
- pInfo2 = Vec_PtrEntry( p->vOuts, i );
+ pInfo = (unsigned *)Vec_PtrEntry( p->vPats, pObj->Id );
+ pInfo2 = (unsigned *)Vec_PtrEntry( p->vOuts, i );
for ( j = 0; j < p->nPats; j++, pInfo2 += p->nWords )
if ( Abc_InfoHasBit( pInfo, j ) )
for ( w = 0; w < p->nWords; w++ )
@@ -545,7 +548,7 @@ void Res_SimPrintOutPatterns( Res_Sim_t * p, Abc_Ntk_t * pAig )
int i;
Abc_NtkForEachPo( pAig, pObj, i )
{
- pInfo2 = Vec_PtrEntry( p->vOuts, i );
+ pInfo2 = (unsigned *)Vec_PtrEntry( p->vOuts, i );
Extra_PrintBinary( stdout, pInfo2, p->nPatsOut );
printf( "\n" );
}
@@ -565,7 +568,7 @@ void Res_SimPrintOutPatterns( Res_Sim_t * p, Abc_Ntk_t * pAig )
void Res_SimPrintNodePatterns( Res_Sim_t * p, Abc_Ntk_t * pAig )
{
unsigned * pInfo;
- pInfo = Vec_PtrEntry( p->vPats, Abc_NtkPo(p->pAig, 1)->Id );
+ pInfo = (unsigned *)Vec_PtrEntry( p->vPats, Abc_NtkPo(p->pAig, 1)->Id );
Extra_PrintBinary( stdout, pInfo, p->nPats );
printf( "\n" );
}
@@ -643,7 +646,7 @@ void Res_SimCollectPatterns( Res_Sim_t * p, int fVerbose )
pInfo = (unsigned char *)Vec_PtrEntry( p->vPats, pObj->Id );
assert( pInfo[i] == 0 || pInfo[i] == 0xff );
if ( pInfo[i] )
- Abc_InfoSetBit( Vec_PtrEntry(p->vPats0, j), p->nPats0 );
+ Abc_InfoSetBit( (unsigned *)Vec_PtrEntry(p->vPats0, j), p->nPats0 );
}
p->nPats0++;
}
@@ -658,7 +661,7 @@ void Res_SimCollectPatterns( Res_Sim_t * p, int fVerbose )
pInfo = (unsigned char *)Vec_PtrEntry( p->vPats, pObj->Id );
assert( pInfo[i] == 0 || pInfo[i] == 0xff );
if ( pInfo[i] )
- Abc_InfoSetBit( Vec_PtrEntry(p->vPats1, j), p->nPats1 );
+ Abc_InfoSetBit( (unsigned *)Vec_PtrEntry(p->vPats1, j), p->nPats1 );
}
p->nPats1++;
}
@@ -696,20 +699,20 @@ int Res_SimVerifyValue( Res_Sim_t * p, int fOnSet )
break;
if ( fOnSet )
{
- pInfo2 = Vec_PtrEntry( p->vPats1, i );
+ pInfo2 = (unsigned *)Vec_PtrEntry( p->vPats1, i );
value = Abc_InfoHasBit( pInfo2, p->nPats1 - 1 );
}
else
{
- pInfo2 = Vec_PtrEntry( p->vPats0, i );
+ pInfo2 = (unsigned *)Vec_PtrEntry( p->vPats0, i );
value = Abc_InfoHasBit( pInfo2, p->nPats0 - 1 );
}
- pInfo = Vec_PtrEntry( p->vPats, pObj->Id );
+ pInfo = (unsigned *)Vec_PtrEntry( p->vPats, pObj->Id );
pInfo[0] = value ? ~0 : 0;
}
Res_SimPerformRound( p, 1 );
pObj = Abc_NtkPo( p->pAig, 1 );
- pInfo = Vec_PtrEntry( p->vPats, pObj->Id );
+ pInfo = (unsigned *)Vec_PtrEntry( p->vPats, pObj->Id );
assert( pInfo[0] == 0 || pInfo[0] == ~0 );
return pInfo[0] > 0;
}
@@ -788,3 +791,5 @@ int Res_SimPrepare( Res_Sim_t * p, Abc_Ntk_t * pAig, int nTruePis, int fVerbose
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/res/resSim_old.c b/src/opt/res/resSim_old.c
index 23ce29e4..ebadeec0 100644
--- a/src/opt/res/resSim_old.c
+++ b/src/opt/res/resSim_old.c
@@ -21,6 +21,9 @@
#include "abc.h"
#include "resInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -327,14 +330,14 @@ void Res_SimPadSimInfo( Vec_Ptr_t * vPats, int nPats, int nWords )
// pad the first word
if ( nPats < 8 * sizeof(unsigned) )
{
- Vec_PtrForEachEntry( vPats, pInfo, i )
+ Vec_PtrForEachEntry( unsigned *, vPats, pInfo, i )
if ( pInfo[0] & 1 )
pInfo[0] |= ((~0) << nPats);
nPats = 8 * sizeof(unsigned);
}
// pad the empty words
iWords = nPats / (8 * sizeof(unsigned));
- Vec_PtrForEachEntry( vPats, pInfo, i )
+ Vec_PtrForEachEntry( unsigned *, vPats, pInfo, i )
{
for ( w = iWords; w < nWords; w++ )
pInfo[w] = pInfo[0];
@@ -519,3 +522,5 @@ int Res_SimPrepare( Res_Sim_t * p, Abc_Ntk_t * pAig, int nTruePis, int fVerbose
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/res/resStrash.c b/src/opt/res/resStrash.c
index a75b84cc..9740af4c 100644
--- a/src/opt/res/resStrash.c
+++ b/src/opt/res/resStrash.c
@@ -21,6 +21,9 @@
#include "abc.h"
#include "resInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -55,12 +58,12 @@ Abc_Ntk_t * Res_WndStrash( Res_Win_t * p )
pAig = Abc_NtkAlloc( ABC_NTK_STRASH, ABC_FUNC_AIG, 1 );
pAig->pName = Extra_UtilStrsav( "window" );
// create the inputs
- Vec_PtrForEachEntry( p->vLeaves, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vLeaves, pObj, i )
pObj->pCopy = Abc_NtkCreatePi( pAig );
- Vec_PtrForEachEntry( p->vBranches, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vBranches, pObj, i )
pObj->pCopy = Abc_NtkCreatePi( pAig );
// go through the nodes in the topological order
- Vec_PtrForEachEntry( p->vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vNodes, pObj, i )
{
pObj->pCopy = Abc_ConvertAigToAig( pAig, pObj );
if ( pObj == p->pNode )
@@ -68,7 +71,7 @@ Abc_Ntk_t * Res_WndStrash( Res_Win_t * p )
}
// collect the POs
vPairs = Vec_PtrAlloc( 2 * Vec_PtrSize(p->vRoots) );
- Vec_PtrForEachEntry( p->vRoots, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vRoots, pObj, i )
{
Vec_PtrPush( vPairs, pObj->pCopy );
Vec_PtrPush( vPairs, NULL );
@@ -80,16 +83,16 @@ Abc_Ntk_t * Res_WndStrash( Res_Win_t * p )
p->pNode->pCopy = Abc_ObjNot( p->pNode->pCopy );
Abc_NodeSetTravIdPrevious( p->pNode );
// redo strashing in the TFO
- Vec_PtrForEachEntry( p->vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vNodes, pObj, i )
{
if ( Abc_NodeIsTravIdCurrent(pObj) )
pObj->pCopy = Abc_ConvertAigToAig( pAig, pObj );
}
// collect the POs
- Vec_PtrForEachEntry( p->vRoots, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vRoots, pObj, i )
Vec_PtrWriteEntry( vPairs, 2 * i + 1, pObj->pCopy );
// add the miter
- pMiter = Abc_AigMiter( pAig->pManFunc, vPairs, 0 );
+ pMiter = Abc_AigMiter( (Abc_Aig_t *)pAig->pManFunc, vPairs, 0 );
Abc_ObjAddFanin( Abc_NtkCreatePo(pAig), pMiter );
Vec_PtrFree( vPairs );
// add the node
@@ -98,7 +101,7 @@ Abc_Ntk_t * Res_WndStrash( Res_Win_t * p )
Abc_ObjForEachFanin( p->pNode, pObj, i )
Abc_ObjAddFanin( Abc_NtkCreatePo(pAig), pObj->pCopy );
// add the divisors
- Vec_PtrForEachEntry( p->vDivs, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vDivs, pObj, i )
Abc_ObjAddFanin( Abc_NtkCreatePo(pAig), pObj->pCopy );
// add the names
Abc_NtkAddDummyPiNames( pAig );
@@ -115,3 +118,5 @@ Abc_Ntk_t * Res_WndStrash( Res_Win_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/res/resWin.c b/src/opt/res/resWin.c
index e46fdc70..a26e7831 100644
--- a/src/opt/res/resWin.c
+++ b/src/opt/res/resWin.c
@@ -21,6 +21,9 @@
#include "abc.h"
#include "resInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -113,7 +116,7 @@ int Res_WinCollectLeavesAndNodes( Res_Win_t * p )
Vec_PtrClear( p->vLeaves );
Vec_VecForEachLevelStartStop( p->vMatrix, vFront, i, 0, p->nWinTfiMax )
{
- Vec_PtrForEachEntry( vFront, pObj, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vFront, pObj, k )
{
Abc_ObjForEachFanin( pObj, pTemp, m )
{
@@ -134,14 +137,14 @@ int Res_WinCollectLeavesAndNodes( Res_Win_t * p )
Vec_PtrClear( p->vNodes );
Vec_VecForEachLevelReverseStartStop( p->vMatrix, vFront, i, p->nWinTfiMax, 0 )
{
- Vec_PtrForEachEntry( vFront, pObj, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vFront, pObj, k )
Vec_PtrPush( p->vNodes, pObj );
Vec_PtrClear( vFront );
}
// get the lowest leaf level
p->nLevLeafMin = ABC_INFINITY;
- Vec_PtrForEachEntry( p->vLeaves, pObj, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vLeaves, pObj, k )
p->nLevLeafMin = ABC_MIN( p->nLevLeafMin, (int)pObj->Level );
// set minimum traversal level
@@ -284,12 +287,12 @@ void Res_WinMarkPaths( Res_Win_t * p )
// mark the leaves
Abc_NtkIncrementTravId( p->pNode->pNtk );
Abc_NtkIncrementTravId( p->pNode->pNtk );
- Vec_PtrForEachEntry( p->vLeaves, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vLeaves, pObj, i )
Abc_NodeSetTravIdCurrent( pObj );
// traverse from the roots and mark the nodes that can reach leaves
// the nodes that do not reach leaves have previous trav ID
// the nodes that reach leaves have current trav ID
- Vec_PtrForEachEntry( p->vRoots, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vRoots, pObj, i )
Res_WinMarkPaths_rec( pObj, p->pNode, p->nLevTravMin );
}
@@ -404,14 +407,14 @@ void Res_WinAddMissing( Res_Win_t * p )
int i;
// mark the leaves
Abc_NtkIncrementTravId( p->pNode->pNtk );
- Vec_PtrForEachEntry( p->vLeaves, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vLeaves, pObj, i )
Abc_NodeSetTravIdCurrent( pObj );
// mark the already collected nodes
- Vec_PtrForEachEntry( p->vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vNodes, pObj, i )
Abc_NodeSetTravIdCurrent( pObj );
// explore from the roots
Vec_PtrClear( p->vBranches );
- Vec_PtrForEachEntry( p->vRoots, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vRoots, pObj, i )
Res_WinAddMissing_rec( p, pObj, p->nLevTravMin );
}
@@ -483,3 +486,5 @@ int Res_WinCompute( Abc_Obj_t * pNode, int nWinTfiMax, int nWinTfoMax, Res_Win_t
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/res/res_.c b/src/opt/res/res_.c
index a50affd7..ffbc4946 100644
--- a/src/opt/res/res_.c
+++ b/src/opt/res/res_.c
@@ -21,6 +21,9 @@
#include "abc.h"
#include "res.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -48,3 +51,5 @@
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/ret/retArea.c b/src/opt/ret/retArea.c
index 63503916..38f95c22 100644
--- a/src/opt/ret/retArea.c
+++ b/src/opt/ret/retArea.c
@@ -20,6 +20,9 @@
#include "retInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -227,7 +230,7 @@ void Abc_NtkRetimeMinAreaPrepare( Abc_Ntk_t * pNtk, int fForward )
if ( !pFanin->fMarkA )
Vec_PtrPush( vNodes, pFanin );
// mark these nodes
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
pObj->fMarkA = 1;
Vec_PtrFree( vNodes );
}
@@ -270,7 +273,7 @@ int Abc_NtkRetimeMinAreaInitValues_rec( Abc_Obj_t * pObj )
if ( Abc_ObjIsBo(pObj) )
{
assert( Abc_ObjIsLatch(Abc_ObjFanin0(pObj)) );
- pObj->pCopy = (void *)(ABC_PTRUINT_T)Abc_NtkRetimeMinAreaInitValues_rec( Abc_ObjFanin0(pObj) );
+ pObj->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)Abc_NtkRetimeMinAreaInitValues_rec( Abc_ObjFanin0(pObj) );
return (int)(ABC_PTRUINT_T)pObj->pCopy;
}
assert( Abc_ObjIsNode(pObj) );
@@ -278,7 +281,7 @@ int Abc_NtkRetimeMinAreaInitValues_rec( Abc_Obj_t * pObj )
Abc_ObjForEachFanin( pObj, pFanin, i )
Abc_NtkRetimeMinAreaInitValues_rec( pFanin );
// compute the value of the node
- pObj->pCopy = (void *)(ABC_PTRUINT_T)Abc_ObjSopSimulate(pObj);
+ pObj->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)Abc_ObjSopSimulate(pObj);
return (int)(ABC_PTRUINT_T)pObj->pCopy;
}
@@ -301,11 +304,11 @@ void Abc_NtkRetimeMinAreaInitValues( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut )
Abc_NtkIncrementTravId(pNtk);
Abc_NtkForEachLatch( pNtk, pObj, i )
{
- pObj->pCopy = (void *)(ABC_PTRUINT_T)Abc_LatchIsInit1(pObj);
+ pObj->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)Abc_LatchIsInit1(pObj);
Abc_NodeSetTravIdCurrent( pObj );
}
// propagate initial values
- Vec_PtrForEachEntry( vMinCut, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vMinCut, pObj, i )
Abc_NtkRetimeMinAreaInitValues_rec( pObj );
// unmark the latches
Abc_NtkForEachLatch( pNtk, pObj, i )
@@ -368,7 +371,7 @@ Abc_Ntk_t * Abc_NtkRetimeMinAreaConstructNtk( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMin
pNtkNew = Abc_NtkAlloc( ABC_NTK_LOGIC, ABC_FUNC_SOP, 1 );
// map new latches into PIs of the new network
Abc_NtkIncrementTravId(pNtk);
- Vec_PtrForEachEntry( vMinCut, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vMinCut, pObj, i )
{
pObj->pCopy = Abc_NtkCreatePi(pNtkNew);
Abc_NodeSetTravIdCurrent( pObj );
@@ -380,7 +383,7 @@ Abc_Ntk_t * Abc_NtkRetimeMinAreaConstructNtk( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMin
Abc_ObjAddFanin( Abc_NtkCreatePo(pNtkNew), pObjNew );
}
// unmark the nodes in the cut
- Vec_PtrForEachEntry( vMinCut, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vMinCut, pObj, i )
Abc_NodeSetTravIdPrevious( pObj );
// unmark the latches
Abc_NtkForEachLatch( pNtk, pObj, i )
@@ -418,13 +421,13 @@ void Abc_NtkRetimeMinAreaUpdateLatches( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut, i
vBoxes = pNtk->vBoxes; pNtk->vBoxes = NULL;
// transfer boxes
vBoxesNew = Vec_PtrAlloc(100);
- Vec_PtrForEachEntry( vBoxes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vBoxes, pObj, i )
if ( !Abc_ObjIsLatch(pObj) )
Vec_PtrPush( vBoxesNew, pObj );
// create or reuse latches
vNodes = Vec_PtrAlloc( 100 );
vBuffers = Vec_PtrAlloc( 100 );
- Vec_PtrForEachEntry( vMinCut, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vMinCut, pObj, i )
{
if ( Abc_ObjIsCi(pObj) && fForward )
{
@@ -448,7 +451,7 @@ void Abc_NtkRetimeMinAreaUpdateLatches( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut, i
Vec_PtrPush( vBuffers, pBuffer );
// redirect edges to the unvisited fanouts of the node
Abc_NodeCollectFanouts( pObj, vNodes );
- Vec_PtrForEachEntry( vNodes, pNext, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNext, k )
if ( pNext->fMarkA )
Abc_ObjPatchFanin( pNext, pObj, pBuffer );
}
@@ -481,7 +484,7 @@ void Abc_NtkRetimeMinAreaUpdateLatches( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut, i
pLatch->pData = (void *)(ABC_PTRUINT_T)(pObj->pCopy? ABC_INIT_ONE : ABC_INIT_ZERO);
// redirect edges to the unvisited fanouts of the node
Abc_NodeCollectFanouts( pObj, vNodes );
- Vec_PtrForEachEntry( vNodes, pNext, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNext, k )
if ( !pNext->fMarkA )
Abc_ObjPatchFanin( pNext, pObj, pLatchOut );
}
@@ -489,7 +492,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 )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNext, k )
if ( pNext->fMarkA )
Abc_ObjPatchFanin( pNext, pObj, pLatchOut );
}
@@ -502,14 +505,14 @@ void Abc_NtkRetimeMinAreaUpdateLatches( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut, i
}
Vec_PtrFree( vNodes );
// remove buffers
- Vec_PtrForEachEntry( vBuffers, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vBuffers, pObj, i )
{
Abc_ObjTransferFanout( pObj, Abc_ObjFanin0(pObj) );
Abc_NtkDeleteObj( pObj );
}
Vec_PtrFree( vBuffers );
// remove useless latches
- Vec_PtrForEachEntry( vBoxes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vBoxes, pObj, i )
{
if ( !Abc_ObjIsLatch(pObj) )
continue;
@@ -537,3 +540,5 @@ void Abc_NtkRetimeMinAreaUpdateLatches( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut, i
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/ret/retCore.c b/src/opt/ret/retCore.c
index 9de1b723..1b574001 100644
--- a/src/opt/ret/retCore.c
+++ b/src/opt/ret/retCore.c
@@ -20,6 +20,9 @@
#include "retInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -41,7 +44,7 @@ int timeRetime = 0;
SeeAlso []
***********************************************************************/
-int Abc_NtkRetime( Abc_Ntk_t * pNtk, int Mode, int fForwardOnly, int fBackwardOnly, int fOneStep, int fVerbose )
+int Abc_NtkRetime( Abc_Ntk_t * pNtk, int Mode, int nDelayLim, int fForwardOnly, int fBackwardOnly, int fOneStep, int fVerbose )
{
int nLatches = Abc_NtkLatchNum(pNtk);
int nLevels = Abc_NtkLevel(pNtk);
@@ -62,26 +65,26 @@ int Abc_NtkRetime( Abc_Ntk_t * pNtk, int Mode, int fForwardOnly, int fBackwardOn
switch ( Mode )
{
case 1: // forward
- RetValue = Abc_NtkRetimeIncremental( pNtk, 1, 0, 0, fVerbose );
+ RetValue = Abc_NtkRetimeIncremental( pNtk, nDelayLim, 1, 0, 0, fVerbose );
break;
case 2: // backward
- RetValue = Abc_NtkRetimeIncremental( pNtk, 0, 0, 0, fVerbose );
+ RetValue = Abc_NtkRetimeIncremental( pNtk, nDelayLim, 0, 0, 0, fVerbose );
break;
case 3: // min-area
RetValue = Abc_NtkRetimeMinArea( pNtk, fForwardOnly, fBackwardOnly, fVerbose );
break;
case 4: // min-delay
if ( !fBackwardOnly )
- RetValue += Abc_NtkRetimeIncremental( pNtk, 1, 1, fOneStep, fVerbose );
+ RetValue += Abc_NtkRetimeIncremental( pNtk, nDelayLim, 1, 1, fOneStep, fVerbose );
if ( !fForwardOnly )
- RetValue += Abc_NtkRetimeIncremental( pNtk, 0, 1, fOneStep, fVerbose );
+ RetValue += Abc_NtkRetimeIncremental( pNtk, nDelayLim, 0, 1, fOneStep, fVerbose );
break;
case 5: // min-area + min-delay
RetValue = Abc_NtkRetimeMinArea( pNtk, fForwardOnly, fBackwardOnly, fVerbose );
if ( !fBackwardOnly )
- RetValue += Abc_NtkRetimeIncremental( pNtk, 1, 1, 0, fVerbose );
+ RetValue += Abc_NtkRetimeIncremental( pNtk, nDelayLim, 1, 1, 0, fVerbose );
if ( !fForwardOnly )
- RetValue += Abc_NtkRetimeIncremental( pNtk, 0, 1, 0, fVerbose );
+ RetValue += Abc_NtkRetimeIncremental( pNtk, nDelayLim, 0, 1, 0, fVerbose );
break;
case 6: // Pan's algorithm
RetValue = Abc_NtkRetimeLValue( pNtk, 500, fVerbose );
@@ -121,7 +124,7 @@ int Abc_NtkRetimeDebug( Abc_Ntk_t * 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, 0 ); // debugging backward flow
+ Abc_NtkRetime( pNtkRet, 3, 0, 0, 1, 0, 0 ); // debugging backward flow
return !Abc_NtkSecFraig( pNtk, pNtkRet, 10000, 3, 0 );
}
@@ -130,3 +133,5 @@ int Abc_NtkRetimeDebug( Abc_Ntk_t * pNtk )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/ret/retDelay.c b/src/opt/ret/retDelay.c
index 0f3c3daa..0263c92f 100644
--- a/src/opt/ret/retDelay.c
+++ b/src/opt/ret/retDelay.c
@@ -20,11 +20,14 @@
#include "retInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
-static int Abc_NtkRetimeMinDelayTry( Abc_Ntk_t * pNtk, int fForward, int fInitial, int nIterLimit, int * pIterBest, int fVerbose );
+static int Abc_NtkRetimeMinDelayTry( Abc_Ntk_t * pNtk, int nDelayLim, int fForward, int fInitial, int nIterLimit, int * pIterBest, int fVerbose );
static int Abc_NtkRetimeTiming( Abc_Ntk_t * pNtk, int fForward, Vec_Ptr_t * vCritical );
static int Abc_NtkRetimeTiming_rec( Abc_Obj_t * pObj, int fForward );
@@ -44,16 +47,16 @@ static int Abc_NtkRetimeTiming_rec( Abc_Obj_t * pObj, int fForward );
SeeAlso []
***********************************************************************/
-int Abc_NtkRetimeMinDelay( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkCopy, int nIterLimit, int fForward, int fVerbose )
+int Abc_NtkRetimeMinDelay( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkCopy, int nDelayLim, int nIterLimit, int fForward, int fVerbose )
{
int IterBest, DelayBest;
int IterBest2, DelayBest2;
// try to find the best delay iteration on a copy
- DelayBest = Abc_NtkRetimeMinDelayTry( pNtkCopy, fForward, 0, nIterLimit, &IterBest, fVerbose );
+ DelayBest = Abc_NtkRetimeMinDelayTry( pNtkCopy, nDelayLim, fForward, 0, nIterLimit, &IterBest, fVerbose );
if ( IterBest == 0 )
return 1;
// perform the given number of iterations on the original network
- DelayBest2 = Abc_NtkRetimeMinDelayTry( pNtk, fForward, 1, IterBest, &IterBest2, fVerbose );
+ DelayBest2 = Abc_NtkRetimeMinDelayTry( pNtk, nDelayLim, fForward, 1, IterBest, &IterBest2, fVerbose );
assert( DelayBest == DelayBest2 );
assert( IterBest == IterBest2 );
return 1;
@@ -70,7 +73,7 @@ int Abc_NtkRetimeMinDelay( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkCopy, int nIterLimi
SeeAlso []
***********************************************************************/
-int Abc_NtkRetimeMinDelayTry( Abc_Ntk_t * pNtk, int fForward, int fInitial, int nIterLimit, int * pIterBest, int fVerbose )
+int Abc_NtkRetimeMinDelayTry( Abc_Ntk_t * pNtk, int nDelayLim, int fForward, int fInitial, int nIterLimit, int * pIterBest, int fVerbose )
{
Abc_Ntk_t * pNtkNew = NULL;
Vec_Ptr_t * vCritical;
@@ -123,8 +126,11 @@ if ( fVerbose && !fInitial )
// skip if 10 interations did not give improvement
if ( i - IterBest > 20 )
break;
+ // skip if delay limit is reached
+ if ( nDelayLim > 0 && DelayCur <= nDelayLim )
+ break;
// try retiming to improve the delay
- Vec_PtrForEachEntry( vCritical, pObj, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vCritical, pObj, k )
if ( Abc_NtkRetimeNodeIsEnabled(pObj, fForward) )
Abc_NtkRetimeNode( pObj, fForward, fInitial );
// share latches
@@ -183,7 +189,7 @@ int Abc_NtkRetimeTiming( Abc_Ntk_t * pNtk, int fForward, Vec_Ptr_t * vCritical )
// perform analysis from CIs/COs
if ( fForward )
{
- Vec_PtrForEachEntry( vLatches, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLatches, pObj, i )
{
Abc_ObjForEachFanout( pObj, pNext, k )
{
@@ -204,7 +210,7 @@ int Abc_NtkRetimeTiming( Abc_Ntk_t * pNtk, int fForward, Vec_Ptr_t * vCritical )
}
else
{
- Vec_PtrForEachEntry( vLatches, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLatches, pObj, i )
{
LevelCur = Abc_NtkRetimeTiming_rec( Abc_ObjFanin0(pObj), fForward );
if ( LevelMax < LevelCur )
@@ -222,7 +228,7 @@ int Abc_NtkRetimeTiming( Abc_Ntk_t * pNtk, int fForward, Vec_Ptr_t * vCritical )
Abc_NtkIncrementTravId(pNtk);
if ( fForward )
{
- Vec_PtrForEachEntry( vLatches, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLatches, pObj, i )
{
Abc_ObjForEachFanout( pObj, pNext, k )
{
@@ -238,7 +244,7 @@ int Abc_NtkRetimeTiming( Abc_Ntk_t * pNtk, int fForward, Vec_Ptr_t * vCritical )
}
else
{
- Vec_PtrForEachEntry( vLatches, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLatches, pObj, i )
{
Abc_ObjForEachFanin( pObj, pNext, k )
{
@@ -305,3 +311,5 @@ int Abc_NtkRetimeTiming_rec( Abc_Obj_t * pObj, int fForward )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/ret/retFlow.c b/src/opt/ret/retFlow.c
index 7c17c1f6..f684939c 100644
--- a/src/opt/ret/retFlow.c
+++ b/src/opt/ret/retFlow.c
@@ -20,6 +20,9 @@
#include "retInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -261,7 +264,7 @@ int Abc_NtkMaxFlowBwdPath_rec( Abc_Obj_t * pObj )
{
// start the path if we reached a terminal node
if ( pObj->fMarkA )
- return Abc_ObjSetPath( pObj, (void *)1 );
+ return Abc_ObjSetPath( pObj, (Abc_Obj_t *)1 );
// explore the fanins
Abc_ObjForEachFanin( pObj, pNext, i )
if ( pNext != pPred && !Abc_ObjIsLatch(pNext) && Abc_NtkMaxFlowBwdPath_rec(pNext) )
@@ -313,7 +316,7 @@ int Abc_NtkMaxFlowFwdPath_rec( Abc_Obj_t * pObj )
{
// start the path if we reached a terminal node
if ( pObj->fMarkA )
- return Abc_ObjSetPath( pObj, (void *)1 );
+ return Abc_ObjSetPath( pObj, (Abc_Obj_t *)1 );
// explore the fanins
Abc_ObjForEachFanout( pObj, pNext, i )
if ( pNext != pPred && !Abc_ObjIsLatch(pNext) && Abc_NtkMaxFlowFwdPath_rec(pNext) )
@@ -367,7 +370,7 @@ int Abc_NtkMaxFlowFwdPath3_rec( Abc_Obj_t * pObj, Abc_Obj_t * pPrev, int fFanin
{
// start the path if we reached a terminal node
if ( pObj->fMarkA )
- return Abc_ObjSetPath( pObj, (void *)1 );
+ return Abc_ObjSetPath( pObj, (Abc_Obj_t *)1 );
// try to push flow through the fanouts
Abc_ObjForEachFanout( pObj, pFanout, i )
if ( Abc_NtkMaxFlowFwdPath3_rec(pFanout, pObj, 1) )
@@ -404,7 +407,7 @@ int Abc_NtkMaxFlowBwdPath2_rec( Abc_Obj_t * pObj )
{
// start the path if we reached a terminal node
if ( pObj->fMarkA )
- return Abc_ObjSetPath( pObj, (void *)1 );
+ return Abc_ObjSetPath( pObj, (Abc_Obj_t *)1 );
// explore the fanins
Abc_ObjForEachFanin( pObj, pFanin, i )
if ( Abc_NtkMaxFlowBwdPath2_rec(pFanin) )
@@ -449,7 +452,7 @@ int Abc_NtkMaxFlowFwdPath2_rec( Abc_Obj_t * pObj )
{
// start the path if we reached a terminal node
if ( pObj->fMarkA )
- return Abc_ObjSetPath( pObj, (void *)1 );
+ return Abc_ObjSetPath( pObj, (Abc_Obj_t *)1 );
// explore the fanins
Abc_ObjForEachFanout( pObj, pFanout, i )
if ( Abc_NtkMaxFlowFwdPath2_rec(pFanout) )
@@ -575,7 +578,7 @@ void Abc_NtkMaxFlowMinCutUpdate( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut, int fFor
Abc_NtkForEachLatch( pNtk, pObj, i )
Abc_ObjFanout0(pObj)->fMarkA = 1;
// traverse from cut nodes
- Vec_PtrForEachEntry( vMinCut, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vMinCut, pObj, i )
Abc_NtkMaxFlowMarkCut_rec( pObj );
if ( fForward )
{
@@ -605,7 +608,7 @@ void Abc_NtkMaxFlowMinCutUpdate( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut, int fFor
Abc_NtkForEachObj( pNtk, pObj, i )
pObj->fMarkA = Abc_NodeIsTravIdCurrent(pObj);
// unmark the cut nodes
- Vec_PtrForEachEntry( vMinCut, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vMinCut, pObj, i )
pObj->fMarkA = 0;
}
}
@@ -668,7 +671,7 @@ int Abc_NtkMaxFlowVerifyCut( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut, int fForward
int i;
// mark the cut with the current traversal ID
Abc_NtkIncrementTravId(pNtk);
- Vec_PtrForEachEntry( vMinCut, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vMinCut, pObj, i )
Abc_NodeSetTravIdCurrent( pObj );
// search from the latches for a path to the COs/CIs
Abc_NtkForEachLatch( pNtk, pObj, i )
@@ -714,7 +717,7 @@ void Abc_NtkMaxFlowPrintFlow( Abc_Ntk_t * pNtk, int fForward )
int i;
if ( fForward )
{
- Vec_PtrForEachEntry( pNtk->vBoxes, pLatch, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, pNtk->vBoxes, pLatch, i )
{
assert( !Abc_ObjFanout0(pLatch)->fMarkA );
if ( Abc_ObjGetPath(Abc_ObjFanout0(pLatch)) == NULL ) // no flow through this latch
@@ -732,7 +735,7 @@ void Abc_NtkMaxFlowPrintFlow( Abc_Ntk_t * pNtk, int fForward )
}
else
{
- Vec_PtrForEachEntry( pNtk->vBoxes, pLatch, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, pNtk->vBoxes, pLatch, i )
{
assert( !Abc_ObjFanin0(pLatch)->fMarkA );
if ( Abc_ObjGetPath(Abc_ObjFanin0(pLatch)) == NULL ) // no flow through this latch
@@ -766,7 +769,7 @@ 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 )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vMinCut, pObj, i )
printf( "%s(%d) ", Abc_ObjName(pObj), pObj->Id );
printf( "\n" );
printf( "Marked nodes: " );
@@ -782,3 +785,5 @@ void Abc_NtkMaxFlowPrintCut( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/ret/retIncrem.c b/src/opt/ret/retIncrem.c
index 1866e4c9..80b26914 100644
--- a/src/opt/ret/retIncrem.c
+++ b/src/opt/ret/retIncrem.c
@@ -20,6 +20,9 @@
#include "retInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -41,7 +44,7 @@ static int Abc_NtkRetimeOneWay( Abc_Ntk_t * pNtk, int fForward, int fVerbose );
SeeAlso []
***********************************************************************/
-int Abc_NtkRetimeIncremental( Abc_Ntk_t * pNtk, int fForward, int fMinDelay, int fOneStep, int fVerbose )
+int Abc_NtkRetimeIncremental( Abc_Ntk_t * pNtk, int nDelayLim, int fForward, int fMinDelay, int fOneStep, int fVerbose )
{
Abc_Ntk_t * pNtkCopy = NULL;
Vec_Ptr_t * vBoxes;
@@ -69,7 +72,7 @@ int Abc_NtkRetimeIncremental( Abc_Ntk_t * pNtk, int fForward, int fMinDelay, int
vBoxes = pNtk->vBoxes; pNtk->vBoxes = NULL;
// perform the retiming
if ( fMinDelay )
- Abc_NtkRetimeMinDelay( pNtk, pNtkCopy, nIterLimit, fForward, fVerbose );
+ Abc_NtkRetimeMinDelay( pNtk, pNtkCopy, nDelayLim, nIterLimit, fForward, fVerbose );
else
Abc_NtkRetimeOneWay( pNtk, fForward, fVerbose );
if ( fMinDelay )
@@ -113,7 +116,7 @@ st_table * Abc_NtkRetimePrepareLatches( Abc_Ntk_t * pNtk )
Abc_NtkForEachLatch( pNtk, pLatch, i )
{
// map latch into its true number
- st_insert( tLatches, (void *)(ABC_PTRUINT_T)pLatch, (void *)(ABC_PTRUINT_T)(i-nOffSet) );
+ st_insert( tLatches, (char *)(ABC_PTRUINT_T)pLatch, (char *)(ABC_PTRUINT_T)(i-nOffSet) );
// disconnect LI
pLatchIn = Abc_ObjFanin0(pLatch);
pFanin = Abc_ObjFanin0(pLatchIn);
@@ -150,11 +153,11 @@ int Abc_NtkRetimeFinalizeLatches( Abc_Ntk_t * pNtk, st_table * tLatches, int nId
vCosOld = pNtk->vCos; pNtk->vCos = NULL; vCosNew = Vec_PtrAlloc( 100 );
vBoxesOld = pNtk->vBoxes; pNtk->vBoxes = NULL; vBoxesNew = Vec_PtrAlloc( 100 );
// copy boxes and their CIs/COs
- Vec_PtrForEachEntryStop( vCisOld, pObj, i, Vec_PtrSize(vCisOld) - st_count(tLatches) )
+ Vec_PtrForEachEntryStop( Abc_Obj_t *, vCisOld, pObj, i, Vec_PtrSize(vCisOld) - st_count(tLatches) )
Vec_PtrPush( vCisNew, pObj );
- Vec_PtrForEachEntryStop( vCosOld, pObj, i, Vec_PtrSize(vCosOld) - st_count(tLatches) )
+ Vec_PtrForEachEntryStop( Abc_Obj_t *, vCosOld, pObj, i, Vec_PtrSize(vCosOld) - st_count(tLatches) )
Vec_PtrPush( vCosNew, pObj );
- Vec_PtrForEachEntryStop( vBoxesOld, pObj, i, Vec_PtrSize(vBoxesOld) - st_count(tLatches) )
+ Vec_PtrForEachEntryStop( Abc_Obj_t *, vBoxesOld, pObj, i, Vec_PtrSize(vBoxesOld) - st_count(tLatches) )
Vec_PtrPush( vBoxesNew, pObj );
// go through the latches
Abc_NtkForEachObj( pNtk, pLatch, i )
@@ -180,8 +183,8 @@ int Abc_NtkRetimeFinalizeLatches( Abc_Ntk_t * pNtk, st_table * tLatches, int nId
}
assert( pLatch == Vec_PtrEntry(vBoxesOld, Vec_PtrSize(vBoxesOld) - st_count(tLatches) + Index) );
// reconnect with the old LIs/LOs
- pLatchIn = Vec_PtrEntry( vCosOld, Vec_PtrSize(vCosOld) - st_count(tLatches) + Index );
- pLatchOut = Vec_PtrEntry( vCisOld, Vec_PtrSize(vCisOld) - st_count(tLatches) + Index );
+ pLatchIn = (Abc_Obj_t *)Vec_PtrEntry( vCosOld, Vec_PtrSize(vCosOld) - st_count(tLatches) + Index );
+ pLatchOut = (Abc_Obj_t *)Vec_PtrEntry( vCisOld, Vec_PtrSize(vCisOld) - st_count(tLatches) + Index );
}
// connect
Abc_ObjAddFanin( pLatchIn, Abc_ObjFanin0(pLatch) );
@@ -195,10 +198,10 @@ int Abc_NtkRetimeFinalizeLatches( Abc_Ntk_t * pNtk, st_table * tLatches, int nId
Vec_PtrPush( vBoxesNew, pLatch );
}
// free useless Cis/Cos
- Vec_PtrForEachEntry( vCisOld, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vCisOld, pObj, i )
if ( !Abc_ObjIsPi(pObj) && Abc_ObjFaninNum(pObj) == 0 && Abc_ObjFanoutNum(pObj) == 0 )
Abc_NtkDeleteObj(pObj);
- Vec_PtrForEachEntry( vCosOld, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vCosOld, pObj, i )
if ( !Abc_ObjIsPo(pObj) && Abc_ObjFaninNum(pObj) == 0 && Abc_ObjFanoutNum(pObj) == 0 )
Abc_NtkDeleteObj(pObj);
// set the new arrays
@@ -316,15 +319,15 @@ void Abc_NtkRetimeNode( Abc_Obj_t * pObj, int fForward, int fInitial )
Abc_Obj_t * pNext, * pLatch;
int i;
vNodes = Vec_PtrAlloc( 10 );
- if ( fForward )
+ if ( fForward )
{
// compute the initial value
if ( fInitial )
- pObj->pCopy = (void *)(ABC_PTRUINT_T)Abc_ObjSopSimulate( pObj );
+ pObj->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)Abc_ObjSopSimulate( pObj );
// collect fanins
Abc_NodeCollectFanins( pObj, vNodes );
// make the node point to the fanins fanins
- Vec_PtrForEachEntry( vNodes, pNext, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNext, i )
{
assert( Abc_ObjIsLatch(pNext) );
Abc_ObjPatchFanin( pObj, pNext, Abc_ObjFanin0(pNext) );
@@ -356,7 +359,7 @@ void Abc_NtkRetimeNode( Abc_Obj_t * pObj, int fForward, int fInitial )
// collect fanouts
Abc_NodeCollectFanouts( pObj, vNodes );
// make the fanouts fanouts point to the node
- Vec_PtrForEachEntry( vNodes, pNext, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNext, i )
{
assert( Abc_ObjIsLatch(pNext) );
Abc_ObjTransferFanout( pNext, pObj );
@@ -439,7 +442,7 @@ void Abc_NtkRetimeShareLatches( Abc_Ntk_t * pNtk, int fInitial )
assert( pLatchTop && Abc_ObjIsLatch(pLatchTop) );
// redirect compatible fanout latches to the first latch
Abc_NodeCollectFanouts( pFanin, vNodes );
- Vec_PtrForEachEntry( vNodes, pLatchCur, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pLatchCur, k )
{
if ( !Abc_ObjIsLatch(pLatchCur) )
continue;
@@ -463,3 +466,5 @@ void Abc_NtkRetimeShareLatches( Abc_Ntk_t * pNtk, int fInitial )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/ret/retInit.c b/src/opt/ret/retInit.c
index 72b384d9..44331e72 100644
--- a/src/opt/ret/retInit.c
+++ b/src/opt/ret/retInit.c
@@ -20,6 +20,9 @@
#include "retInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -88,7 +91,7 @@ Vec_Int_t * Abc_NtkRetimeInitialValues( Abc_Ntk_t * pNtkCone, Vec_Int_t * vValue
***********************************************************************/
int Abc_ObjSopSimulate( Abc_Obj_t * pObj )
{
- char * pCube, * pSop = pObj->pData;
+ char * pCube, * pSop = (char *)pObj->pData;
int nVars, Value, v, ResOr, ResAnd, ResVar;
assert( pSop && !Abc_SopIsExorType(pSop) );
// simulate the SOP of the node
@@ -134,11 +137,11 @@ int Abc_NtkRetimeVerifyModel( Abc_Ntk_t * pNtkCone, Vec_Int_t * vValues, int * p
assert( Abc_NtkIsSopLogic(pNtkCone) );
// set the PIs
Abc_NtkForEachPi( pNtkCone, pObj, i )
- pObj->pCopy = (void *)(ABC_PTRUINT_T)pModel[i];
+ pObj->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)pModel[i];
// simulate the internal nodes
vNodes = Abc_NtkDfs( pNtkCone, 0 );
- Vec_PtrForEachEntry( vNodes, pObj, i )
- pObj->pCopy = (void *)(ABC_PTRUINT_T)Abc_ObjSopSimulate( pObj );
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
+ pObj->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)Abc_ObjSopSimulate( pObj );
Vec_PtrFree( vNodes );
// compare the outputs
Abc_NtkForEachPo( pNtkCone, pObj, i )
@@ -167,7 +170,7 @@ void Abc_NtkRetimeTranferToCopy( Abc_Ntk_t * pNtk )
int i;
Abc_NtkForEachObj( pNtk, pObj, i )
if ( Abc_ObjIsLatch(pObj) )
- pObj->pCopy = (void *)(ABC_PTRUINT_T)Abc_LatchIsInit1(pObj);
+ pObj->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)Abc_LatchIsInit1(pObj);
}
/**Function*************************************************************
@@ -230,10 +233,10 @@ void Abc_NtkRetimeInsertLatchValues( Abc_Ntk_t * pNtk, Vec_Int_t * vValues )
int i, Counter = 0;
Abc_NtkForEachObj( pNtk, pObj, i )
if ( Abc_ObjIsLatch(pObj) )
- pObj->pCopy = (void *)(ABC_PTRUINT_T)Counter++;
+ pObj->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)Counter++;
Abc_NtkForEachObj( pNtk, pObj, i )
if ( Abc_ObjIsLatch(pObj) )
- pObj->pData = (void *)(ABC_PTRUINT_T)(vValues? (Vec_IntEntry(vValues,(int)(ABC_PTRUINT_T)pObj->pCopy)? ABC_INIT_ONE : ABC_INIT_ZERO) : ABC_INIT_DC);
+ pObj->pData = (Abc_Obj_t *)(ABC_PTRUINT_T)(vValues? (Vec_IntEntry(vValues,(int)(ABC_PTRUINT_T)pObj->pCopy)? ABC_INIT_ONE : ABC_INIT_ZERO) : ABC_INIT_DC);
}
/**Function*************************************************************
@@ -316,22 +319,22 @@ void Abc_NtkCycleInitStateSop( Abc_Ntk_t * pNtk, int nFrames, int fVerbose )
srand( 0x12341234 );
// initialize the values
Abc_NtkForEachPi( pNtk, pObj, i )
- pObj->pCopy = (void *)(ABC_PTRUINT_T)(rand() & 1);
+ pObj->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)(rand() & 1);
Abc_NtkForEachLatch( pNtk, pObj, i )
- pObj->pCopy = (void *)(ABC_PTRUINT_T)Abc_LatchIsInit1(pObj);
+ pObj->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)Abc_LatchIsInit1(pObj);
// simulate for the given number of timeframes
vNodes = Abc_NtkDfs( pNtk, 0 );
for ( f = 0; f < nFrames; f++ )
{
// simulate internal nodes
- Vec_PtrForEachEntry( vNodes, pObj, i )
- pObj->pCopy = (void *)(ABC_PTRUINT_T)Abc_ObjSopSimulate( pObj );
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
+ pObj->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)Abc_ObjSopSimulate( pObj );
// bring the results to the COs
Abc_NtkForEachCo( pNtk, pObj, i )
pObj->pCopy = Abc_ObjFanin0(pObj)->pCopy;
// assign PI values
Abc_NtkForEachPi( pNtk, pObj, i )
- pObj->pCopy = (void *)(ABC_PTRUINT_T)(rand() & 1);
+ pObj->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)(rand() & 1);
// transfer the latch values
Abc_NtkForEachLatch( pNtk, pObj, i )
Abc_ObjFanout0(pObj)->pCopy = Abc_ObjFanin0(pObj)->pCopy;
@@ -347,3 +350,5 @@ void Abc_NtkCycleInitStateSop( Abc_Ntk_t * pNtk, int nFrames, int fVerbose )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/ret/retInt.h b/src/opt/ret/retInt.h
index 51428bce..39a6296e 100644
--- a/src/opt/ret/retInt.h
+++ b/src/opt/ret/retInt.h
@@ -21,12 +21,16 @@
#ifndef __RET_INT_H__
#define __RET_INT_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
#include "abc.h"
+ABC_NAMESPACE_HEADER_START
+
+
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
@@ -46,11 +50,11 @@
/*=== retArea.c ========================================================*/
extern int Abc_NtkRetimeMinArea( Abc_Ntk_t * pNtk, int fForwardOnly, int fBackwardOnly, int fVerbose );
/*=== retCore.c ========================================================*/
-extern int Abc_NtkRetime( Abc_Ntk_t * pNtk, int Mode, int fForwardOnly, int fBackwardOnly, int fOneStep, int fVerbose );
+extern int Abc_NtkRetime( Abc_Ntk_t * pNtk, int Mode, int nDelayLim, int fForwardOnly, int fBackwardOnly, int fOneStep, int fVerbose );
/*=== retDelay.c ========================================================*/
-extern int Abc_NtkRetimeMinDelay( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkCopy, int nIterLimit, int fForward, int fVerbose );
+extern int Abc_NtkRetimeMinDelay( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkCopy, int nDelayLim, int nIterLimit, int fForward, int fVerbose );
/*=== retDirect.c ========================================================*/
-extern int Abc_NtkRetimeIncremental( Abc_Ntk_t * pNtk, int fForward, int fMinDelay, int fOneStep, int fVerbose );
+extern int Abc_NtkRetimeIncremental( Abc_Ntk_t * pNtk, int nDelayLim, int fForward, int fMinDelay, int fOneStep, int fVerbose );
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 );
@@ -71,6 +75,10 @@ extern void Abc_NtkRetimeBackwardInitialFinish( Abc_Ntk_t * pNtk, Abc_Ntk
/*=== retLvalue.c ========================================================*/
extern int Abc_NtkRetimeLValue( Abc_Ntk_t * pNtk, int nIterLimit, int fVerbose );
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif
////////////////////////////////////////////////////////////////////////
diff --git a/src/opt/ret/retLvalue.c b/src/opt/ret/retLvalue.c
index 02d9cac2..7d32dd7d 100644
--- a/src/opt/ret/retLvalue.c
+++ b/src/opt/ret/retLvalue.c
@@ -20,6 +20,9 @@
#include "retInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -38,7 +41,7 @@ static int Abc_NtkRetimeUsingLags( Abc_Ntk_t * pNtk, Vec_Int_t * vLags,
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)(ABC_PTRUINT_T)pNode->pCopy; }
-static inline void Abc_NodeSetLValue( Abc_Obj_t * pNode, int Value ) { pNode->pCopy = (void *)(ABC_PTRUINT_T)Value; }
+static inline void Abc_NodeSetLValue( Abc_Obj_t * pNode, int Value ) { pNode->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)Value; }
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
@@ -247,7 +250,7 @@ int Abc_NtkRetimeUpdateLValue( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t *
int i, k, lValueNew, fChange;
// go through the nodes and detect change
fChange = 0;
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
{
assert( Abc_ObjIsNode(pObj) );
lValueNew = -ABC_INFINITY;
@@ -264,7 +267,7 @@ int Abc_NtkRetimeUpdateLValue( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t *
}
}
// propagate values through the latches
- Vec_PtrForEachEntry( vLatches, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLatches, pObj, i )
Abc_NodeSetLValue( Abc_ObjFanout0(pObj), Abc_NodeGetLValue(Abc_ObjFanin0(Abc_ObjFanin0(pObj))) - Fi );
return fChange;
}
@@ -393,3 +396,5 @@ int Abc_NtkRetimeUsingLags( Abc_Ntk_t * pNtk, Vec_Int_t * vLags, int fVerbose )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/ret/ret_.c b/src/opt/ret/ret_.c
index 89625e17..1ee46e4a 100644
--- a/src/opt/ret/ret_.c
+++ b/src/opt/ret/ret_.c
@@ -20,6 +20,9 @@
#include "retInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -46,3 +49,5 @@
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/rwr/rwr.h b/src/opt/rwr/rwr.h
index 5adc3b4b..ed05d4a3 100644
--- a/src/opt/rwr/rwr.h
+++ b/src/opt/rwr/rwr.h
@@ -21,6 +21,7 @@
#ifndef __RWR_H__
#define __RWR_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -32,9 +33,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -111,7 +113,7 @@ struct Rwr_Node_t_ // 24 bytes
};
// manipulation of complemented attributes
-static inline bool Rwr_IsComplement( Rwr_Node_t * p ) { return (bool)(((ABC_PTRUINT_T)p) & 01); }
+static inline int Rwr_IsComplement( Rwr_Node_t * p ) { return (int )(((ABC_PTRUINT_T)p) & 01); }
static inline Rwr_Node_t * Rwr_Regular( Rwr_Node_t * p ) { return (Rwr_Node_t *)((ABC_PTRUINT_T)(p) & ~01); }
static inline Rwr_Node_t * Rwr_Not( Rwr_Node_t * p ) { return (Rwr_Node_t *)((ABC_PTRUINT_T)(p) ^ 01); }
static inline Rwr_Node_t * Rwr_NotCond( Rwr_Node_t * p, int c ) { return (Rwr_Node_t *)((ABC_PTRUINT_T)(p) ^ (c)); }
@@ -137,7 +139,7 @@ extern Rwr_Node_t * Rwr_ManAddNode( Rwr_Man_t * p, Rwr_Node_t * p0, Rwr_Nod
extern int Rwr_ManNodeVolume( Rwr_Man_t * p, Rwr_Node_t * p0, Rwr_Node_t * p1 );
extern void Rwr_ManIncTravId( Rwr_Man_t * p );
/*=== rwrMan.c ========================================================*/
-extern Rwr_Man_t * Rwr_ManStart( bool fPrecompute );
+extern Rwr_Man_t * Rwr_ManStart( int fPrecompute );
extern void Rwr_ManStop( Rwr_Man_t * p );
extern void Rwr_ManPrintStats( Rwr_Man_t * p );
extern void Rwr_ManPrintStatsFile( Rwr_Man_t * p );
@@ -157,9 +159,11 @@ extern void Rwr_ManLoadFromFile( Rwr_Man_t * p, char * pFileName );
extern void Rwr_ListAddToTail( Rwr_Node_t ** ppList, Rwr_Node_t * pNode );
extern char * Rwr_ManGetPractical( Rwr_Man_t * p );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/opt/rwr/rwrDec.c b/src/opt/rwr/rwrDec.c
index 81c7e307..76d8ac51 100644
--- a/src/opt/rwr/rwrDec.c
+++ b/src/opt/rwr/rwrDec.c
@@ -21,6 +21,9 @@
#include "rwr.h"
#include "dec.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -66,7 +69,7 @@ void Rwr_ManPreprocess( Rwr_Man_t * p )
}
}
// compute decomposition forms for each node and verify them
- Vec_VecForEachEntry( p->vClasses, pNode, i, k )
+ Vec_VecForEachEntry( Rwr_Node_t *, p->vClasses, pNode, i, k )
{
pGraph = Rwr_NodePreprocess( p, pNode );
pNode->pNext = (Rwr_Node_t *)pGraph;
@@ -148,3 +151,5 @@ Dec_Edge_t Rwr_TravCollect_rec( Rwr_Man_t * p, Rwr_Node_t * pNode, Dec_Graph_t *
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/rwr/rwrEva.c b/src/opt/rwr/rwrEva.c
index 42c370ab..8f0c1821 100644
--- a/src/opt/rwr/rwrEva.c
+++ b/src/opt/rwr/rwrEva.c
@@ -20,6 +20,10 @@
#include "rwr.h"
#include "dec.h"
+#include "ivy.h"
+
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -117,7 +121,7 @@ clk = clock();
{
int Counter = 0;
- Vec_PtrForEachEntry( p->vFaninsCur, pFanin, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vFaninsCur, pFanin, i )
if ( Abc_ObjFanoutNum(Abc_ObjRegular(pFanin)) == 1 )
Counter++;
if ( Counter > 2 )
@@ -127,19 +131,19 @@ clk = clock();
clk2 = clock();
/*
printf( "Considering: (" );
- Vec_PtrForEachEntry( p->vFaninsCur, pFanin, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vFaninsCur, pFanin, i )
printf( "%d ", Abc_ObjFanoutNum(Abc_ObjRegular(pFanin)) );
printf( ")\n" );
*/
// mark the fanin boundary
- Vec_PtrForEachEntry( p->vFaninsCur, pFanin, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vFaninsCur, pFanin, i )
Abc_ObjRegular(pFanin)->vFanouts.nSize++;
// label MFFC with current ID
Abc_NtkIncrementTravId( pNode->pNtk );
nNodesSaved = Abc_NodeMffcLabelAig( pNode );
// unmark the fanin boundary
- Vec_PtrForEachEntry( p->vFaninsCur, pFanin, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vFaninsCur, pFanin, i )
Abc_ObjRegular(pFanin)->vFanouts.nSize--;
p->timeMffc += clock() - clk2;
@@ -159,7 +163,7 @@ p->timeEval += clock() - clk2;
uTruthBest = 0xFFFF & *Cut_CutReadTruth(pCut);
// collect fanins in the
Vec_PtrClear( p->vFanins );
- Vec_PtrForEachEntry( p->vFaninsCur, pFanin, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vFaninsCur, pFanin, i )
Vec_PtrPush( p->vFanins, pFanin );
}
}
@@ -172,7 +176,7 @@ p->timeRes += clock() - clk;
{
printf( "Class %d ", p->pMap[uTruthBest] );
printf( "Gain = %d. Node %d : ", GainBest, pNode->Id );
- Vec_PtrForEachEntry( p->vFanins, pFanin, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vFanins, pFanin, i )
printf( "%d ", Abc_ObjRegular(pFanin)->Id );
Dec_GraphPrint( stdout, p->pGraph, NULL, NULL );
printf( "\n" );
@@ -188,7 +192,7 @@ p->timeRes += clock() - clk;
else
{
printf( "Node %d : ", pNode->Id );
- Vec_PtrForEachEntry( p->vFanins, pFanin, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vFanins, pFanin, i )
printf( "%d ", Abc_ObjRegular(pFanin)->Id );
printf( "a" );
}
@@ -203,11 +207,11 @@ p->timeRes += clock() - clk;
*/
// copy the leaves
- Vec_PtrForEachEntry( p->vFanins, pFanin, i )
- Dec_GraphNode(p->pGraph, i)->pFunc = pFanin;
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vFanins, pFanin, i )
+ Dec_GraphNode((Dec_Graph_t *)p->pGraph, i)->pFunc = pFanin;
/*
printf( "(" );
- Vec_PtrForEachEntry( p->vFanins, pFanin, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vFanins, pFanin, i )
printf( " %d", Abc_ObjRegular(pFanin)->vFanouts.nSize - 1 );
printf( " ) " );
*/
@@ -228,7 +232,7 @@ p->timeRes += clock() - clk;
printf( "Save = %d. ", nNodesSaveCur );
printf( "Add = %d. ", nNodesSaveCur-GainBest );
printf( "GAIN = %d. ", GainBest );
- printf( "Cone = %d. ", p->pGraph? Dec_GraphNodeNum(p->pGraph) : 0 );
+ printf( "Cone = %d. ", p->pGraph? Dec_GraphNodeNum((Dec_Graph_t *)p->pGraph) : 0 );
printf( "Class = %d. ", p->pMap[uTruthBest] );
printf( "\n" );
}
@@ -258,17 +262,17 @@ Dec_Graph_t * Rwr_CutEvaluate( Rwr_Man_t * p, Abc_Obj_t * pRoot, Cut_Cut_t * pCu
float CostBest;//, CostCur;
// find the matching class of subgraphs
uTruth = 0xFFFF & *Cut_CutReadTruth(pCut);
- vSubgraphs = Vec_VecEntry( p->vClasses, p->pMap[uTruth] );
+ vSubgraphs = (Vec_Ptr_t *)Vec_VecEntry( p->vClasses, p->pMap[uTruth] );
p->nSubgraphs += vSubgraphs->nSize;
// determine the best subgraph
GainBest = -1;
CostBest = ABC_INFINITY;
- Vec_PtrForEachEntry( vSubgraphs, pNode, i )
+ Vec_PtrForEachEntry( Rwr_Node_t *, vSubgraphs, pNode, i )
{
// get the current graph
pGraphCur = (Dec_Graph_t *)pNode->pNext;
// copy the leaves
- Vec_PtrForEachEntry( vFaninsCur, pFanin, k )
+ Vec_PtrForEachEntry( Rwr_Node_t *, vFaninsCur, pFanin, k )
Dec_GraphNode(pGraphCur, k)->pFunc = pFanin;
// detect how many unlabeled nodes will be reused
nNodesAdded = Dec_GraphToNetworkCount( pRoot, pGraphCur, nNodesSaved, LevelMax );
@@ -376,7 +380,7 @@ int Rwr_CutIsBoolean( Abc_Obj_t * pObj, Vec_Ptr_t * vLeaves )
{
Abc_Obj_t * pTemp;
int i, RetValue;
- Vec_PtrForEachEntry( vLeaves, pTemp, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pTemp, i )
{
pTemp = Abc_ObjRegular(pTemp);
assert( !pTemp->fMarkA && !pTemp->fMarkB );
@@ -384,7 +388,7 @@ int Rwr_CutIsBoolean( Abc_Obj_t * pObj, Vec_Ptr_t * vLeaves )
Rwr_CutIsBoolean_rec( Abc_ObjFanin0(pObj), vLeaves, 1 );
Rwr_CutIsBoolean_rec( Abc_ObjFanin1(pObj), vLeaves, 0 );
RetValue = 0;
- Vec_PtrForEachEntry( vLeaves, pTemp, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pTemp, i )
{
pTemp = Abc_ObjRegular(pTemp);
RetValue |= pTemp->fMarkA && pTemp->fMarkB;
@@ -451,7 +455,7 @@ int Rwr_CutCountNumNodes( Abc_Obj_t * pObj, Cut_Cut_t * pCut )
for ( pCut = pCut->pNext; pCut; pCut = pCut->pNext )
Rwr_CutCountNumNodes_rec( pObj, pCut, vNodes );
// clean all nodes
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
pObj->fMarkC = 0;
// delete and return
Counter = Vec_PtrSize(vNodes);
@@ -477,7 +481,7 @@ int Rwr_NodeGetDepth_rec( Abc_Obj_t * pObj, Vec_Ptr_t * vLeaves )
int i, Depth0, Depth1;
if ( Abc_ObjIsCi(pObj) )
return 0;
- Vec_PtrForEachEntry( vLeaves, pLeaf, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLeaves, pLeaf, i )
if ( pObj == Abc_ObjRegular(pLeaf) )
return 0;
Depth0 = Rwr_NodeGetDepth_rec( Abc_ObjFanin0(pObj), vLeaves );
@@ -504,8 +508,8 @@ void Rwr_ScoresClean( Rwr_Man_t * p )
int i, k;
for ( i = 0; i < p->vClasses->nSize; i++ )
{
- vSubgraphs = Vec_VecEntry( p->vClasses, i );
- Vec_PtrForEachEntry( vSubgraphs, pNode, k )
+ vSubgraphs = (Vec_Ptr_t *)Vec_VecEntry( p->vClasses, i );
+ Vec_PtrForEachEntry( Rwr_Node_t *, vSubgraphs, pNode, k )
pNode->nScore = pNode->nGain = pNode->nAdded = 0;
}
}
@@ -557,8 +561,8 @@ void Rwr_ScoresReport( Rwr_Man_t * p )
{
Perm[i] = i;
Gains[i] = 0;
- vSubgraphs = Vec_VecEntry( p->vClasses, i );
- Vec_PtrForEachEntry( vSubgraphs, pNode, k )
+ vSubgraphs = (Vec_Ptr_t *)Vec_VecEntry( p->vClasses, i );
+ Vec_PtrForEachEntry( Rwr_Node_t *, vSubgraphs, pNode, k )
Gains[i] += pNode->nGain;
}
// sort the gains
@@ -570,13 +574,13 @@ void Rwr_ScoresReport( Rwr_Man_t * p )
iNew = Perm[i];
if ( Gains[iNew] == 0 )
break;
- vSubgraphs = Vec_VecEntry( p->vClasses, iNew );
+ vSubgraphs = (Vec_Ptr_t *)Vec_VecEntry( p->vClasses, iNew );
printf( "CLASS %3d: Subgr = %3d. Total gain = %6d. ", iNew, Vec_PtrSize(vSubgraphs), Gains[iNew] );
uTruth = (unsigned)p->pMapInv[iNew];
Extra_PrintBinary( stdout, &uTruth, 16 );
printf( " " );
Ivy_TruthDsdComputePrint( (unsigned)p->pMapInv[iNew] | ((unsigned)p->pMapInv[iNew] << 16) );
- Vec_PtrForEachEntry( vSubgraphs, pNode, k )
+ Vec_PtrForEachEntry( Rwr_Node_t *, vSubgraphs, pNode, k )
{
if ( pNode->nScore == 0 )
continue;
@@ -591,3 +595,5 @@ void Rwr_ScoresReport( Rwr_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/rwr/rwrExp.c b/src/opt/rwr/rwrExp.c
index 543cae07..c4664fbf 100644
--- a/src/opt/rwr/rwrExp.c
+++ b/src/opt/rwr/rwrExp.c
@@ -20,6 +20,9 @@
#include "rwr.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -149,7 +152,7 @@ void Rwt_Man4ExplorePrint()
for ( i = 0; i < s_pManRwrExp4->nFuncs; i++ )
if ( s_pManRwrExp4->pnCounts[i] > 0 )
{
- Extra_PrintHex( pFile, i, 4 );
+ Extra_PrintHex( pFile, (unsigned *)&i, 4 );
fprintf( pFile, " %10d\n", s_pManRwrExp4->pnCounts[i] );
// fprintf( pFile, "%d ", i );
CountWrite++;
@@ -275,7 +278,7 @@ void Rwt_Man5ExplorePrint()
{
assert( 0 );
}
- Extra_PrintHex( pFile, uTruth, 5 );
+ Extra_PrintHex( pFile, &uTruth, 5 );
fprintf( pFile, " %10d\n", Counter );
}
fclose( pFile );
@@ -313,7 +316,7 @@ ABC_PRT( "Computing NPN classes", clock() - clk );
{
assert( 0 );
}
- Extra_PrintHex( pFile, uTruth, 5 );
+ Extra_PrintHex( pFile, &uTruth, 5 );
fprintf( pFile, " %10d\n", Counter );
}
fclose( pFile );
@@ -329,3 +332,5 @@ ABC_PRT( "Computing NPN classes", clock() - clk );
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/rwr/rwrLib.c b/src/opt/rwr/rwrLib.c
index 1cdf350e..731871d0 100644
--- a/src/opt/rwr/rwrLib.c
+++ b/src/opt/rwr/rwrLib.c
@@ -20,6 +20,9 @@
#include "rwr.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -49,8 +52,8 @@ void Rwr_ManPrecompute( Rwr_Man_t * p )
int LevelOld = -1;
int nNodes;
- Vec_PtrForEachEntryStart( p->vForest, p0, i, 1 )
- Vec_PtrForEachEntryStart( p->vForest, p1, k, 1 )
+ Vec_PtrForEachEntryStart( Rwr_Node_t *, p->vForest, p0, i, 1 )
+ Vec_PtrForEachEntryStart( Rwr_Node_t *, p->vForest, p1, k, 1 )
{
if ( LevelOld < (int)p0->Level )
{
@@ -99,7 +102,7 @@ save :
Rwr_ManIncTravId( p );
k = 5;
nNodes = 0;
- Vec_PtrForEachEntryStart( p->vForest, p0, i, 5 )
+ Vec_PtrForEachEntryStart( Rwr_Node_t *, p->vForest, p0, i, 5 )
if ( p0->uTruth == p->puCanons[p0->uTruth] )
{
Rwr_MarkUsed_rec( p, p0 );
@@ -108,7 +111,7 @@ save :
// compact the array by throwing away non-canonical
k = 5;
- Vec_PtrForEachEntryStart( p->vForest, p0, i, 5 )
+ Vec_PtrForEachEntryStart( Rwr_Node_t *, p->vForest, p0, i, 5 )
if ( p0->fUsed )
{
p->vForest->pArray[k] = p0;
@@ -350,7 +353,7 @@ void Rwr_ManIncTravId( Rwr_Man_t * p )
int i;
if ( p->nTravIds++ < 0x8FFFFFFF )
return;
- Vec_PtrForEachEntry( p->vForest, pNode, i )
+ Vec_PtrForEachEntry( Rwr_Node_t *, p->vForest, pNode, i )
pNode->TravId = 0;
p->nTravIds = 1;
}
@@ -360,3 +363,5 @@ void Rwr_ManIncTravId( Rwr_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/rwr/rwrMan.c b/src/opt/rwr/rwrMan.c
index e7d21164..ffc5fcae 100644
--- a/src/opt/rwr/rwrMan.c
+++ b/src/opt/rwr/rwrMan.c
@@ -22,6 +22,9 @@
#include "main.h"
#include "dec.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -41,7 +44,7 @@
SeeAlso []
***********************************************************************/
-Rwr_Man_t * Rwr_ManStart( bool fPrecompute )
+Rwr_Man_t * Rwr_ManStart( int fPrecompute )
{
Dec_Man_t * pManDec;
Rwr_Man_t * p;
@@ -50,7 +53,7 @@ clk = clock();
p = ABC_ALLOC( Rwr_Man_t, 1 );
memset( p, 0, sizeof(Rwr_Man_t) );
p->nFuncs = (1<<16);
- pManDec = Abc_FrameReadManDec();
+ pManDec = (Dec_Man_t *)Abc_FrameReadManDec();
p->puCanons = pManDec->puCanons;
p->pPhases = pManDec->pPhases;
p->pPerms = pManDec->pPerms;
@@ -109,7 +112,7 @@ void Rwr_ManStop( Rwr_Man_t * p )
{
Rwr_Node_t * pNode;
int i, k;
- Vec_VecForEachEntry( p->vClasses, pNode, i, k )
+ Vec_VecForEachEntry( Rwr_Node_t *, p->vClasses, pNode, i, k )
Dec_GraphFree( (Dec_Graph_t *)pNode->pNext );
}
if ( p->vClasses ) Vec_VecFree( p->vClasses );
@@ -316,3 +319,5 @@ void Rwr_Precompute()
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/rwr/rwrPrint.c b/src/opt/rwr/rwrPrint.c
index 82ad2a90..11a084d3 100644
--- a/src/opt/rwr/rwrPrint.c
+++ b/src/opt/rwr/rwrPrint.c
@@ -20,6 +20,9 @@
#include "rwr.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -206,9 +209,9 @@ void Rwr_NodePrint( FILE * pFile, Rwr_Man_t * p, Rwr_Node_t * pNode )
{
unsigned uTruth;
fprintf( pFile, "%5d : ", pNode->Id );
- Extra_PrintHex( pFile, pNode->uTruth, 4 );
- fprintf( pFile, " tt=" );
uTruth = pNode->uTruth;
+ Extra_PrintHex( pFile, &uTruth, 4 );
+ fprintf( pFile, " tt=" );
Extra_PrintBinary( pFile, &uTruth, 16 );
// fprintf( pFile, " cn=", pNode->Id );
// uTruth = p->puCanons[pNode->uTruth];
@@ -264,3 +267,5 @@ void Rwr_ManPrint( Rwr_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/rwr/rwrTemp.c b/src/opt/rwr/rwrTemp.c
index 3ffbd408..6a670c3a 100644
--- a/src/opt/rwr/rwrTemp.c
+++ b/src/opt/rwr/rwrTemp.c
@@ -20,6 +20,9 @@
#include "rwr.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -106,7 +109,7 @@ void Rwr_Temp()
for ( k = 0; k < 32; k++ )
if ( uTruth & (1 << k) )
{
- Extra_PrintBinary( pFile, &k, 5 );
+ Extra_PrintBinary( pFile, (unsigned *)&k, 5 );
fprintf( pFile, " 1\n" );
}
}
@@ -119,3 +122,5 @@ void Rwr_Temp()
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/rwr/rwrUtil.c b/src/opt/rwr/rwrUtil.c
index 8da3b6eb..7a836d63 100644
--- a/src/opt/rwr/rwrUtil.c
+++ b/src/opt/rwr/rwrUtil.c
@@ -20,18 +20,393 @@
#include "rwr.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
// precomputed data
-#ifdef _WIN32
-unsigned short s_RwrPracticalClasses[];
-unsigned short s_RwtAigSubgraphs[];
-#else
-static unsigned short s_RwrPracticalClasses[];
-static unsigned short s_RwtAigSubgraphs[];
-#endif
+// the following 135 practical NPN classes of 4-variable functions were computed
+// by considering all 4-input cuts appearing in IWLS, MCNC, and ISCAS benchmarks
+static unsigned short s_RwrPracticalClasses[] =
+{
+ 0x0000, 0x0001, 0x0003, 0x0006, 0x0007, 0x000f, 0x0016, 0x0017, 0x0018, 0x0019, 0x001b,
+ 0x001e, 0x001f, 0x003c, 0x003d, 0x003f, 0x0069, 0x006b, 0x006f, 0x007e, 0x007f, 0x00ff,
+ 0x0116, 0x0118, 0x0119, 0x011a, 0x011b, 0x011e, 0x011f, 0x012c, 0x012d, 0x012f, 0x013c,
+ 0x013d, 0x013e, 0x013f, 0x0168, 0x0169, 0x016f, 0x017f, 0x0180, 0x0181, 0x0182, 0x0183,
+ 0x0186, 0x0189, 0x018b, 0x018f, 0x0198, 0x0199, 0x019b, 0x01a8, 0x01a9, 0x01aa, 0x01ab,
+ 0x01ac, 0x01ad, 0x01ae, 0x01af, 0x01bf, 0x01e9, 0x01ea, 0x01eb, 0x01ee, 0x01ef, 0x01fe,
+ 0x033c, 0x033d, 0x033f, 0x0356, 0x0357, 0x0358, 0x0359, 0x035a, 0x035b, 0x035f, 0x0368,
+ 0x0369, 0x036c, 0x036e, 0x037d, 0x03c0, 0x03c1, 0x03c3, 0x03c7, 0x03cf, 0x03d4, 0x03d5,
+ 0x03d7, 0x03d8, 0x03d9, 0x03dc, 0x03dd, 0x03de, 0x03fc, 0x0660, 0x0661, 0x0666, 0x0669,
+ 0x066f, 0x0676, 0x067e, 0x0690, 0x0696, 0x0697, 0x069f, 0x06b1, 0x06b6, 0x06f0, 0x06f2,
+ 0x06f6, 0x06f9, 0x0776, 0x0778, 0x07b0, 0x07b1, 0x07b4, 0x07bc, 0x07f0, 0x07f2, 0x07f8,
+ 0x0ff0, 0x1683, 0x1696, 0x1698, 0x169e, 0x16e9, 0x178e, 0x17e8, 0x18e7, 0x19e6, 0x1be4,
+ 0x1ee1, 0x3cc3, 0x6996, 0x0000
+};
+
+static unsigned short s_RwtAigSubgraphs[] =
+{
+ 0x0008,0x0002, 0x000a,0x0002, 0x0008,0x0003, 0x000a,0x0003, 0x0009,0x0002,
+ 0x000c,0x0002, 0x000e,0x0002, 0x000c,0x0003, 0x000e,0x0003, 0x000d,0x0002,
+ 0x000c,0x0004, 0x000e,0x0004, 0x000c,0x0005, 0x000e,0x0005, 0x000d,0x0004,
+ 0x0010,0x0002, 0x0012,0x0002, 0x0010,0x0003, 0x0012,0x0003, 0x0011,0x0002,
+ 0x0010,0x0004, 0x0012,0x0004, 0x0010,0x0005, 0x0012,0x0005, 0x0011,0x0004,
+ 0x0010,0x0006, 0x0012,0x0006, 0x0010,0x0007, 0x0012,0x0007, 0x0011,0x0006,
+ 0x0016,0x0005, 0x0014,0x0006, 0x0016,0x0006, 0x0014,0x0007, 0x0016,0x0007,
+ 0x0015,0x0006, 0x0014,0x0008, 0x0016,0x0008, 0x0014,0x0009, 0x0016,0x0009,
+ 0x0015,0x0008, 0x0018,0x0006, 0x001a,0x0006, 0x0018,0x0007, 0x001a,0x0007,
+ 0x0019,0x0006, 0x0018,0x0009, 0x001a,0x0009, 0x0019,0x0008, 0x001e,0x0005,
+ 0x001c,0x0006, 0x001e,0x0006, 0x001c,0x0007, 0x001e,0x0007, 0x001d,0x0006,
+ 0x001c,0x0008, 0x001e,0x0008, 0x001c,0x0009, 0x001e,0x0009, 0x001d,0x0008,
+ 0x0020,0x0006, 0x0022,0x0006, 0x0020,0x0007, 0x0022,0x0007, 0x0021,0x0006,
+ 0x0020,0x0008, 0x0022,0x0008, 0x0020,0x0009, 0x0022,0x0009, 0x0021,0x0008,
+ 0x0024,0x0006, 0x0026,0x0006, 0x0024,0x0007, 0x0026,0x0007, 0x0025,0x0006,
+ 0x0026,0x0008, 0x0024,0x0009, 0x0026,0x0009, 0x0025,0x0008, 0x0028,0x0004,
+ 0x002a,0x0004, 0x0028,0x0005, 0x002a,0x0007, 0x0028,0x0008, 0x002a,0x0009,
+ 0x0029,0x0008, 0x002a,0x000b, 0x0029,0x000a, 0x002a,0x000f, 0x0029,0x000e,
+ 0x002a,0x0011, 0x002a,0x0013, 0x002c,0x0004, 0x002e,0x0004, 0x002c,0x0005,
+ 0x002c,0x0009, 0x002e,0x0009, 0x002d,0x0008, 0x002d,0x000c, 0x002e,0x000f,
+ 0x002e,0x0011, 0x002e,0x0012, 0x0030,0x0004, 0x0032,0x0007, 0x0032,0x0009,
+ 0x0031,0x0008, 0x0032,0x000b, 0x0032,0x000d, 0x0032,0x000f, 0x0031,0x000e,
+ 0x0032,0x0013, 0x0034,0x0004, 0x0036,0x0004, 0x0034,0x0005, 0x0036,0x0005,
+ 0x0035,0x0004, 0x0036,0x0008, 0x0034,0x0009, 0x0036,0x0009, 0x0035,0x0008,
+ 0x0036,0x000b, 0x0036,0x000d, 0x0036,0x0011, 0x0035,0x0010, 0x0036,0x0013,
+ 0x0038,0x0004, 0x0039,0x0004, 0x0038,0x0009, 0x003a,0x0009, 0x0039,0x0008,
+ 0x0038,0x000b, 0x003a,0x000b, 0x003a,0x000d, 0x003a,0x0011, 0x003a,0x0012,
+ 0x0038,0x0013, 0x003a,0x0013, 0x003c,0x0002, 0x003e,0x0002, 0x003c,0x0003,
+ 0x003e,0x0005, 0x003e,0x0007, 0x003c,0x0008, 0x003e,0x0008, 0x003c,0x0009,
+ 0x003e,0x0009, 0x003d,0x0008, 0x003e,0x000d, 0x003e,0x0011, 0x003e,0x0013,
+ 0x003e,0x0017, 0x003e,0x001b, 0x003e,0x001d, 0x0040,0x0002, 0x0042,0x0002,
+ 0x0042,0x0005, 0x0041,0x0006, 0x0042,0x0008, 0x0041,0x0008, 0x0042,0x000d,
+ 0x0042,0x0011, 0x0042,0x0015, 0x0042,0x0019, 0x0042,0x001b, 0x0042,0x001c,
+ 0x0041,0x001c, 0x0044,0x0002, 0x0046,0x0003, 0x0045,0x0004, 0x0046,0x0007,
+ 0x0045,0x0008, 0x0046,0x000b, 0x0046,0x000f, 0x0046,0x0013, 0x0045,0x0012,
+ 0x0046,0x0017, 0x0046,0x001b, 0x0046,0x0021, 0x0048,0x0002, 0x004a,0x0002,
+ 0x0048,0x0003, 0x004a,0x0003, 0x0049,0x0002, 0x0048,0x0008, 0x004a,0x0008,
+ 0x0048,0x0009, 0x004a,0x0009, 0x0049,0x0008, 0x004a,0x000b, 0x004a,0x000f,
+ 0x004a,0x0011, 0x004a,0x0012, 0x004a,0x0013, 0x004a,0x0015, 0x004a,0x0019,
+ 0x004a,0x001b, 0x004a,0x001d, 0x004c,0x0002, 0x004c,0x0003, 0x004d,0x0002,
+ 0x004c,0x0008, 0x004e,0x0008, 0x004c,0x0009, 0x004e,0x0009, 0x004d,0x0008,
+ 0x004c,0x000b, 0x004e,0x000b, 0x004c,0x000f, 0x004e,0x000f, 0x004e,0x0011,
+ 0x004c,0x0012, 0x004c,0x0013, 0x004e,0x0013, 0x004e,0x0015, 0x004c,0x0017,
+ 0x004e,0x0019, 0x004c,0x001b, 0x004e,0x001b, 0x004c,0x001c, 0x004c,0x001d,
+ 0x004e,0x001d, 0x0050,0x0004, 0x0052,0x0004, 0x0050,0x0006, 0x0052,0x0009,
+ 0x0052,0x000d, 0x0052,0x000f, 0x0052,0x0013, 0x0052,0x0017, 0x0052,0x0019,
+ 0x0052,0x001d, 0x0052,0x001f, 0x0052,0x0021, 0x0052,0x0023, 0x0052,0x0024,
+ 0x0052,0x0025, 0x0051,0x0024, 0x0052,0x0027, 0x0054,0x0004, 0x0056,0x0004,
+ 0x0054,0x0005, 0x0056,0x0006, 0x0054,0x0007, 0x0056,0x0011, 0x0056,0x001b,
+ 0x0056,0x001e, 0x0054,0x001f, 0x0056,0x001f, 0x0056,0x0020, 0x0054,0x0021,
+ 0x0055,0x0020, 0x0056,0x0024, 0x0054,0x0025, 0x0056,0x0025, 0x0055,0x0024,
+ 0x0054,0x0027, 0x0056,0x0027, 0x0055,0x0026, 0x005a,0x0007, 0x005a,0x0009,
+ 0x005a,0x000b, 0x005a,0x0015, 0x005a,0x001f, 0x0059,0x0020, 0x0058,0x0024,
+ 0x005a,0x0024, 0x005a,0x0027, 0x0059,0x0026, 0x005c,0x0004, 0x005e,0x0004,
+ 0x005c,0x0005, 0x005e,0x0006, 0x005c,0x0007, 0x005d,0x0006, 0x005e,0x000d,
+ 0x005e,0x0013, 0x005e,0x0017, 0x005c,0x001f, 0x005d,0x001e, 0x005e,0x0020,
+ 0x005e,0x0021, 0x005e,0x0022, 0x005e,0x0023, 0x005c,0x0024, 0x005e,0x0024,
+ 0x005c,0x0025, 0x005e,0x0025, 0x005d,0x0024, 0x005e,0x0026, 0x005e,0x0027,
+ 0x0062,0x0004, 0x0061,0x0004, 0x0062,0x0006, 0x0061,0x0006, 0x0060,0x000f,
+ 0x0060,0x0013, 0x0062,0x0013, 0x0060,0x0019, 0x0062,0x001c, 0x0060,0x001d,
+ 0x0062,0x001d, 0x0062,0x001f, 0x0060,0x0021, 0x0060,0x0023, 0x0062,0x0024,
+ 0x0060,0x0027, 0x0061,0x0026, 0x0064,0x0002, 0x0066,0x0002, 0x0064,0x0006,
+ 0x0066,0x0007, 0x0066,0x0009, 0x0066,0x000d, 0x0066,0x0013, 0x0066,0x0015,
+ 0x0066,0x0017, 0x0066,0x0019, 0x0066,0x001a, 0x0065,0x001a, 0x0066,0x001f,
+ 0x0066,0x0023, 0x0066,0x0027, 0x0066,0x002f, 0x0066,0x0030, 0x006a,0x0002,
+ 0x0068,0x0003, 0x0068,0x0006, 0x006a,0x0006, 0x006a,0x0011, 0x0068,0x0016,
+ 0x0068,0x0017, 0x006a,0x0017, 0x006a,0x001a, 0x006a,0x001b, 0x006a,0x0025,
+ 0x006a,0x002d, 0x006e,0x0003, 0x006e,0x0007, 0x006e,0x0009, 0x006e,0x000b,
+ 0x006e,0x0015, 0x006e,0x0016, 0x006e,0x0017, 0x006c,0x001a, 0x006e,0x001a,
+ 0x006e,0x001f, 0x006e,0x002b, 0x006e,0x0035, 0x0070,0x0002, 0x0070,0x0003,
+ 0x0072,0x0006, 0x0070,0x0007, 0x0071,0x0006, 0x0072,0x000b, 0x0072,0x000f,
+ 0x0072,0x0013, 0x0070,0x0015, 0x0071,0x0014, 0x0072,0x0017, 0x0072,0x0018,
+ 0x0070,0x0019, 0x0072,0x0019, 0x0070,0x001a, 0x0070,0x001b, 0x0072,0x001b,
+ 0x0071,0x001a, 0x0072,0x0021, 0x0072,0x0029, 0x0076,0x0002, 0x0076,0x0003,
+ 0x0075,0x0002, 0x0076,0x0006, 0x0074,0x0007, 0x0076,0x0007, 0x0075,0x0006,
+ 0x0076,0x000d, 0x0076,0x0011, 0x0076,0x0013, 0x0075,0x0014, 0x0076,0x0019,
+ 0x0076,0x001a, 0x0076,0x001b, 0x0075,0x001c, 0x0074,0x0023, 0x0075,0x0022,
+ 0x0074,0x0026, 0x0076,0x0026, 0x0074,0x0027, 0x0076,0x002b, 0x0076,0x002f,
+ 0x0078,0x0002, 0x0078,0x0004, 0x007a,0x0004, 0x007a,0x0005, 0x0079,0x0004,
+ 0x007a,0x0009, 0x007a,0x000a, 0x007a,0x000b, 0x007a,0x000d, 0x007a,0x000f,
+ 0x007a,0x0010, 0x007a,0x0011, 0x007a,0x0012, 0x007a,0x0013, 0x007a,0x0017,
+ 0x007a,0x001b, 0x007a,0x0021, 0x007a,0x0027, 0x007a,0x002b, 0x007a,0x002f,
+ 0x007a,0x0030, 0x0079,0x0034, 0x007a,0x0039, 0x007a,0x003a, 0x007e,0x0002,
+ 0x007c,0x0004, 0x007e,0x0004, 0x007e,0x000c, 0x007c,0x000d, 0x007e,0x0011,
+ 0x007e,0x0013, 0x007e,0x001b, 0x007e,0x0025, 0x007e,0x002d, 0x007e,0x0037,
+ 0x0082,0x0003, 0x0082,0x0005, 0x0082,0x0009, 0x0082,0x000b, 0x0080,0x0010,
+ 0x0082,0x0010, 0x0082,0x0012, 0x0082,0x0015, 0x0082,0x001f, 0x0082,0x002b,
+ 0x0082,0x0035, 0x0082,0x0039, 0x0082,0x003f, 0x0084,0x0002, 0x0086,0x0002,
+ 0x0084,0x0003, 0x0086,0x0003, 0x0085,0x0002, 0x0086,0x0004, 0x0084,0x0005,
+ 0x0085,0x0004, 0x0086,0x000a, 0x0084,0x000b, 0x0085,0x000a, 0x0086,0x000d,
+ 0x0086,0x000e, 0x0086,0x000f, 0x0084,0x0010, 0x0084,0x0011, 0x0086,0x0011,
+ 0x0085,0x0010, 0x0084,0x0012, 0x0084,0x0013, 0x0086,0x0013, 0x0085,0x0012,
+ 0x0086,0x0019, 0x0086,0x0023, 0x0086,0x0029, 0x0086,0x0033, 0x0086,0x0039,
+ 0x008a,0x0003, 0x0089,0x0002, 0x0088,0x0004, 0x008a,0x0004, 0x0088,0x0005,
+ 0x0089,0x0004, 0x008a,0x000b, 0x008a,0x0010, 0x0088,0x0011, 0x008a,0x0011,
+ 0x0089,0x0010, 0x0088,0x0012, 0x008a,0x0012, 0x0089,0x0012, 0x008a,0x0017,
+ 0x008a,0x001b, 0x0089,0x0020, 0x008a,0x0025, 0x0088,0x0027, 0x008a,0x002b,
+ 0x008a,0x002f, 0x008a,0x0039, 0x0088,0x003a, 0x008d,0x0044, 0x0092,0x0009,
+ 0x0092,0x0025, 0x0092,0x0029, 0x0092,0x002d, 0x0092,0x0033, 0x0092,0x0037,
+ 0x0092,0x003d, 0x0092,0x0041, 0x0095,0x0002, 0x0095,0x0004, 0x0095,0x0010,
+ 0x0095,0x0012, 0x0096,0x0021, 0x0096,0x0029, 0x0095,0x002e, 0x0096,0x0030,
+ 0x0096,0x0033, 0x0096,0x003a, 0x0096,0x0043, 0x009a,0x0008, 0x009a,0x0009,
+ 0x0099,0x0008, 0x009a,0x0011, 0x009a,0x0023, 0x009a,0x0033, 0x009a,0x003d,
+ 0x009a,0x0044, 0x009a,0x0045, 0x0099,0x0044, 0x009d,0x0002, 0x009e,0x0008,
+ 0x009c,0x0009, 0x009e,0x0009, 0x009d,0x0008, 0x009e,0x0011, 0x009d,0x0010,
+ 0x009e,0x001f, 0x009e,0x003f, 0x00a0,0x0009, 0x00a0,0x0011, 0x00a2,0x0030,
+ 0x00a2,0x0033, 0x00a6,0x0006, 0x00a6,0x0007, 0x00a6,0x0011, 0x00a6,0x0044,
+ 0x00a6,0x004b, 0x00aa,0x0007, 0x00aa,0x0015, 0x00ae,0x0006, 0x00ae,0x0011,
+ 0x00ae,0x001b, 0x00ae,0x0025, 0x00ae,0x003d, 0x00ae,0x0041, 0x00ae,0x0043,
+ 0x00ae,0x0045, 0x00b2,0x0006, 0x00b0,0x0007, 0x00b1,0x0006, 0x00b2,0x0017,
+ 0x00b1,0x0016, 0x00b0,0x0019, 0x00b2,0x0021, 0x00b2,0x003d, 0x00b5,0x004a,
+ 0x00ba,0x0009, 0x00ba,0x000f, 0x00bc,0x0009, 0x00be,0x0009, 0x00be,0x000f,
+ 0x00bd,0x000e, 0x00be,0x0017, 0x00c2,0x0009, 0x00c2,0x0019, 0x00c2,0x001f,
+ 0x00c2,0x0033, 0x00c6,0x0009, 0x00c5,0x000e, 0x00c6,0x0015, 0x00c6,0x0023,
+ 0x00c4,0x002d, 0x00c6,0x002f, 0x00c5,0x002e, 0x00c6,0x0045, 0x00ce,0x0007,
+ 0x00ce,0x0021, 0x00ce,0x0023, 0x00ce,0x0025, 0x00ce,0x0027, 0x00ce,0x0033,
+ 0x00ce,0x003d, 0x00d2,0x0006, 0x00d0,0x0015, 0x00d0,0x001b, 0x00d2,0x001b,
+ 0x00d1,0x001a, 0x00d0,0x001f, 0x00d2,0x0025, 0x00d1,0x0024, 0x00d2,0x0037,
+ 0x00d2,0x0041, 0x00d2,0x0045, 0x00d9,0x0044, 0x00e1,0x0004, 0x00e2,0x000d,
+ 0x00e2,0x0021, 0x00e0,0x003a, 0x00e6,0x003d, 0x00e6,0x0061, 0x00e6,0x0067,
+ 0x00e9,0x0004, 0x00ea,0x0008, 0x00ea,0x0009, 0x00ea,0x0039, 0x00e9,0x0038,
+ 0x00ea,0x003f, 0x00ec,0x000d, 0x00ee,0x000d, 0x00ee,0x0037, 0x00f2,0x003d,
+ 0x00f2,0x0062, 0x00f5,0x0002, 0x00fa,0x0017, 0x00fa,0x003d, 0x00fe,0x0006,
+ 0x00fd,0x0006, 0x00fc,0x0015, 0x00fe,0x001b, 0x00fc,0x0025, 0x00fe,0x0025,
+ 0x00fd,0x0024, 0x00fe,0x0041, 0x00fe,0x004d, 0x00fd,0x004e, 0x0101,0x0014,
+ 0x0106,0x004d, 0x010a,0x0009, 0x010a,0x000b, 0x0109,0x000a, 0x010a,0x004f,
+ 0x010a,0x0058, 0x010e,0x0008, 0x010c,0x0009, 0x010e,0x0009, 0x010d,0x0008,
+ 0x010e,0x000b, 0x010e,0x002b, 0x010d,0x002a, 0x010e,0x0035, 0x010e,0x003d,
+ 0x010e,0x003f, 0x010e,0x0049, 0x010e,0x0057, 0x010d,0x0056, 0x010d,0x0058,
+ 0x0111,0x0004, 0x0111,0x0006, 0x0110,0x0009, 0x0112,0x0009, 0x0111,0x0008,
+ 0x0112,0x002f, 0x0110,0x0035, 0x0110,0x0037, 0x0112,0x0039, 0x0112,0x003d,
+ 0x0112,0x003f, 0x0112,0x0045, 0x0111,0x0044, 0x0112,0x004b, 0x0112,0x0059,
+ 0x0112,0x0069, 0x0112,0x007f, 0x0116,0x0009, 0x0115,0x0008, 0x0114,0x000b,
+ 0x0116,0x000b, 0x0116,0x0058, 0x011a,0x0015, 0x011a,0x001f, 0x011a,0x002b,
+ 0x011a,0x003f, 0x011a,0x0049, 0x011a,0x0085, 0x011e,0x0007, 0x011e,0x0019,
+ 0x011e,0x001b, 0x011e,0x0023, 0x011e,0x0027, 0x011e,0x002f, 0x011e,0x0043,
+ 0x011e,0x004b, 0x011e,0x004e, 0x011e,0x004f, 0x011e,0x005f, 0x011e,0x0061,
+ 0x011e,0x0065, 0x011e,0x0083, 0x0122,0x0006, 0x0120,0x0007, 0x0122,0x0007,
+ 0x0121,0x0006, 0x0122,0x0049, 0x0121,0x004e, 0x0122,0x008f, 0x0125,0x0004,
+ 0x0124,0x0007, 0x0125,0x0006, 0x0124,0x001b, 0x0126,0x001b, 0x0126,0x0045,
+ 0x0126,0x0087, 0x0128,0x0007, 0x0129,0x0006, 0x012a,0x0019, 0x012a,0x003d,
+ 0x012a,0x0051, 0x012a,0x0065, 0x012a,0x0083, 0x012d,0x005a, 0x0132,0x0009,
+ 0x0132,0x008f, 0x0134,0x0009, 0x0135,0x003e, 0x013a,0x003d, 0x013a,0x0044,
+ 0x0139,0x0044, 0x013e,0x0009, 0x013d,0x0008, 0x013c,0x003d, 0x013c,0x0044,
+ 0x013c,0x0053, 0x013e,0x008f, 0x013e,0x0095, 0x0142,0x0044, 0x0142,0x0097,
+ 0x0142,0x009e, 0x0144,0x0007, 0x0148,0x0015, 0x0148,0x001c, 0x0148,0x001f,
+ 0x0148,0x0026, 0x0149,0x0086, 0x014d,0x0006, 0x014e,0x0044, 0x014d,0x0048,
+ 0x014e,0x009e, 0x0152,0x0009, 0x0151,0x00a6, 0x0155,0x0030, 0x015d,0x003a,
+ 0x0162,0x009e, 0x0164,0x000f, 0x0164,0x0013, 0x0169,0x000e, 0x0174,0x0009,
+ 0x0179,0x0008, 0x0180,0x0009, 0x0181,0x0044, 0x0186,0x0044, 0x0185,0x0044,
+ 0x018a,0x0068, 0x0195,0x004e, 0x01a6,0x0009, 0x01a5,0x0008, 0x01b1,0x003a,
+ 0x01c4,0x0029, 0x01c4,0x0030, 0x01ca,0x008f, 0x01ca,0x0095, 0x01cc,0x0029,
+ 0x01cc,0x0033, 0x01ce,0x003d, 0x01d6,0x00b2, 0x01d8,0x0009, 0x01d9,0x002a,
+ 0x01d9,0x0056, 0x01d9,0x00a4, 0x01dd,0x003a, 0x01e2,0x00b2, 0x01e6,0x0013,
+ 0x01e6,0x009f, 0x01e6,0x00ba, 0x01e6,0x00c0, 0x01e6,0x00d3, 0x01e6,0x00d5,
+ 0x01e6,0x00e5, 0x01e8,0x0005, 0x01f2,0x0013, 0x01f2,0x0095, 0x01f2,0x009f,
+ 0x01f2,0x00ba, 0x01f2,0x00c0, 0x01f2,0x00d3, 0x0202,0x008f, 0x0202,0x0095,
+ 0x0202,0x00f3, 0x0202,0x00f9, 0x020a,0x0044, 0x0209,0x00b4, 0x020e,0x0009,
+ 0x020d,0x0008, 0x020c,0x003d, 0x020c,0x0044, 0x020c,0x0053, 0x020e,0x008f,
+ 0x020e,0x0095, 0x020c,0x00b1, 0x020e,0x00f3, 0x020e,0x00f9, 0x0210,0x0013,
+ 0x0211,0x0024, 0x0210,0x0026, 0x0219,0x0004, 0x021e,0x008f, 0x021e,0x0095,
+ 0x0221,0x003a, 0x0230,0x0009, 0x0236,0x0009, 0x0234,0x0029, 0x0234,0x0030,
+ 0x0234,0x0033, 0x0234,0x003a, 0x0234,0x003d, 0x0234,0x0044, 0x0235,0x00a6,
+ 0x023a,0x0009, 0x023d,0x003a, 0x0245,0x0044, 0x0249,0x003a, 0x024e,0x009e,
+ 0x024e,0x0106, 0x0251,0x0026, 0x0258,0x0013, 0x0259,0x0024, 0x0258,0x0061,
+ 0x0259,0x0086, 0x0258,0x00c7, 0x0258,0x00df, 0x0259,0x00ec, 0x0258,0x00fc,
+ 0x025d,0x0024, 0x025d,0x00de, 0x0260,0x00f6, 0x0268,0x0009, 0x0269,0x0044,
+ 0x0268,0x00f3, 0x0268,0x00f9, 0x026d,0x003a, 0x0270,0x0068, 0x0275,0x003a,
+ 0x027a,0x0044, 0x0279,0x0044, 0x027e,0x007e, 0x0281,0x0044, 0x0285,0x0008,
+ 0x028d,0x0006, 0x028d,0x00d2, 0x0295,0x00cc, 0x0296,0x00f6, 0x0295,0x00f8,
+ 0x0299,0x0030, 0x029e,0x007e, 0x029d,0x0080, 0x02a6,0x008f, 0x02a6,0x0095,
+ 0x02aa,0x0029, 0x02aa,0x0030, 0x02b5,0x0008, 0x02b9,0x003a, 0x02bd,0x0004,
+ 0x02bd,0x00fc, 0x02c2,0x00b2, 0x02c1,0x00b4, 0x02c4,0x0029, 0x02c8,0x0029,
+ 0x02c8,0x0033, 0x02ca,0x003d, 0x02ce,0x0029, 0x02ce,0x0030, 0x02d2,0x0068,
+ 0x02d1,0x006a, 0x02d5,0x006a, 0x02d9,0x0008, 0x02de,0x012c, 0x02e2,0x012c,
+ 0x02e4,0x0009, 0x02e5,0x002a, 0x02e5,0x0056, 0x02e5,0x012c, 0x02ea,0x0029,
+ 0x02ea,0x0030, 0x02e9,0x0030, 0x02ec,0x0029, 0x02ec,0x0030, 0x02ee,0x012c,
+ 0x02f1,0x0068, 0x02f1,0x00b2, 0x02f1,0x0108, 0x02f1,0x012c, 0x02f6,0x0013,
+ 0x02f6,0x0015, 0x02f6,0x001f, 0x02f6,0x0030, 0x02f6,0x0065, 0x02f6,0x0067,
+ 0x02f6,0x009f, 0x02f6,0x00b6, 0x02f6,0x00b9, 0x02f6,0x00c0, 0x02f6,0x00cf,
+ 0x02f6,0x0107, 0x02f6,0x010b, 0x02f6,0x010f, 0x02f6,0x0115, 0x02f6,0x012d,
+ 0x02f6,0x0134, 0x02f6,0x0153, 0x02f6,0x0171, 0x02f6,0x0176, 0x02f8,0x0003,
+ 0x02fa,0x017b, 0x02fc,0x00ba, 0x02fc,0x00d3, 0x0302,0x0013, 0x0302,0x001f,
+ 0x0302,0x0030, 0x0302,0x005d, 0x0302,0x0065, 0x0302,0x0067, 0x0302,0x0099,
+ 0x0302,0x009f, 0x0302,0x00ad, 0x0302,0x00b9, 0x0302,0x00c0, 0x0302,0x00cf,
+ 0x0301,0x00d2, 0x0301,0x00fe, 0x0302,0x0107, 0x0302,0x010b, 0x0302,0x010f,
+ 0x0302,0x0117, 0x0302,0x0134, 0x0302,0x0153, 0x0302,0x0157, 0x0302,0x0176,
+ 0x0306,0x0029, 0x0308,0x00b2, 0x0309,0x00dc, 0x030d,0x00f8, 0x0312,0x00f3,
+ 0x0318,0x007e, 0x031d,0x0080, 0x0321,0x0008, 0x0321,0x0094, 0x0326,0x017b,
+ 0x0326,0x0181, 0x0329,0x012e, 0x032a,0x017b, 0x032a,0x0181, 0x032e,0x008f,
+ 0x032e,0x0095, 0x032e,0x00f3, 0x032e,0x00f9, 0x0332,0x0009, 0x0331,0x0008,
+ 0x0330,0x003d, 0x0330,0x0044, 0x0330,0x0053, 0x0332,0x008f, 0x0332,0x0095,
+ 0x0330,0x00b1, 0x0332,0x00f3, 0x0332,0x00f9, 0x0330,0x0127, 0x0332,0x017b,
+ 0x0332,0x0181, 0x033c,0x0013, 0x033c,0x001c, 0x033d,0x0086, 0x033d,0x00ec,
+ 0x033d,0x0172, 0x033e,0x019d, 0x0345,0x0002, 0x0344,0x008f, 0x0344,0x00f3,
+ 0x034d,0x0030, 0x0352,0x0033, 0x0354,0x0029, 0x0354,0x0030, 0x035a,0x0009,
+ 0x035a,0x017b, 0x035a,0x019b, 0x035a,0x01a2, 0x035e,0x0181, 0x0360,0x0009,
+ 0x0366,0x0009, 0x0364,0x0029, 0x0364,0x0030, 0x0364,0x0033, 0x0364,0x003a,
+ 0x0364,0x003d, 0x0364,0x0044, 0x0369,0x0030, 0x0370,0x0029, 0x0370,0x0030,
+ 0x0376,0x0033, 0x037a,0x0009, 0x037a,0x019b, 0x037a,0x01a2, 0x037c,0x0009,
+ 0x0382,0x0181, 0x0386,0x0009, 0x0384,0x0029, 0x0384,0x0030, 0x0384,0x0033,
+ 0x0384,0x003a, 0x0384,0x003d, 0x0384,0x0044, 0x038a,0x0044, 0x038a,0x009e,
+ 0x038a,0x0106, 0x038a,0x0198, 0x038d,0x010e, 0x038d,0x0152, 0x038d,0x0158,
+ 0x0392,0x009e, 0x0392,0x0106, 0x0392,0x0198, 0x0395,0x0086, 0x0395,0x009a,
+ 0x0395,0x00ec, 0x0395,0x0172, 0x0398,0x014e, 0x0398,0x0175, 0x0398,0x018d,
+ 0x039c,0x0023, 0x039c,0x0027, 0x039c,0x00ef, 0x039c,0x0139, 0x039c,0x0168,
+ 0x03a0,0x0019, 0x03a0,0x001d, 0x03a0,0x0023, 0x03a0,0x0027, 0x03a1,0x004e,
+ 0x03a4,0x0162, 0x03a4,0x0183, 0x03a8,0x0013, 0x03a8,0x0027, 0x03a8,0x0133,
+ 0x03a8,0x0148, 0x03a8,0x0181, 0x03ac,0x0013, 0x03ac,0x0027, 0x03b0,0x017b,
+ 0x03b0,0x0181, 0x03b4,0x004b, 0x03b4,0x00e0, 0x03b4,0x00fb, 0x03b8,0x000f,
+ 0x03b8,0x0013, 0x03b8,0x00ab, 0x03b8,0x00bf, 0x03b8,0x00d0, 0x03bd,0x00da,
+ 0x03bd,0x012c, 0x03c8,0x000f, 0x03c8,0x0013, 0x03c8,0x0019, 0x03c8,0x001d,
+ 0x03cd,0x0086, 0x03cd,0x00ec, 0x03cd,0x0172, 0x03d2,0x00e0, 0x03d2,0x00ef,
+ 0x03d2,0x0112, 0x03d2,0x0139, 0x03d2,0x0168, 0x03d6,0x017b, 0x03d6,0x0181,
+ 0x03da,0x0133, 0x03da,0x0148, 0x03e2,0x0023, 0x03e2,0x0027, 0x03e6,0x0027,
+ 0x03e6,0x0181, 0x03ee,0x017b, 0x03ee,0x0181, 0x03fe,0x003d, 0x0401,0x012a,
+ 0x0401,0x019e, 0x0405,0x01a0, 0x040a,0x000d, 0x040a,0x011f, 0x040a,0x016f,
+ 0x040d,0x012a, 0x0412,0x017b, 0x041a,0x0033, 0x041a,0x003d, 0x041a,0x0181,
+ 0x0421,0x0086, 0x0421,0x009a, 0x0421,0x00ec, 0x0421,0x0172, 0x042e,0x0205,
+ 0x043a,0x0205, 0x043e,0x017b, 0x0442,0x01f5, 0x044c,0x0007, 0x0452,0x0033,
+ 0x0452,0x01ce, 0x0452,0x01d0, 0x0452,0x01f1, 0x0452,0x01fb, 0x0452,0x0225,
+ 0x0454,0x0005, 0x045a,0x0033, 0x045a,0x0181, 0x045a,0x01ce, 0x045a,0x01d0,
+ 0x045a,0x01f1, 0x0469,0x01de, 0x046e,0x0181, 0x047a,0x01ce, 0x047a,0x01f1,
+ 0x0485,0x012c, 0x0489,0x012c, 0x0490,0x01d8, 0x0496,0x0033, 0x0496,0x003d,
+ 0x0498,0x008f, 0x0498,0x00f3, 0x049e,0x0044, 0x049e,0x0221, 0x04a1,0x0006,
+ 0x04a2,0x0044, 0x04a6,0x0221, 0x04a9,0x0004, 0x04ac,0x0027, 0x04b1,0x009a,
+ 0x04b6,0x0097, 0x04b8,0x0027, 0x04c6,0x0219, 0x04ca,0x017b, 0x04cc,0x004b,
+ 0x04d0,0x00ab, 0x04d6,0x017b, 0x04d8,0x000f, 0x04d8,0x0019, 0x04d8,0x0033,
+ 0x04d8,0x003d, 0x04de,0x003d, 0x04de,0x0103, 0x04de,0x018b, 0x04de,0x0231,
+ 0x04e2,0x0044, 0x04e2,0x009e, 0x04e2,0x0106, 0x04e2,0x0198, 0x04e5,0x01a4,
+ 0x04e5,0x01b6, 0x04ea,0x009e, 0x04ea,0x0106, 0x04ea,0x0198, 0x04ed,0x002e,
+ 0x04ed,0x0038, 0x04ed,0x00a2, 0x04f1,0x0086, 0x04f1,0x009a, 0x04f1,0x00ec,
+ 0x04f1,0x0172, 0x04f9,0x004e, 0x04f8,0x0229, 0x04f8,0x022d, 0x0500,0x023e,
+ 0x0504,0x0217, 0x0510,0x00f3, 0x0514,0x0043, 0x0514,0x004d, 0x0514,0x00c3,
+ 0x0514,0x013d, 0x0514,0x0215, 0x0514,0x0232, 0x0515,0x0260, 0x0519,0x002a,
+ 0x0518,0x0030, 0x0518,0x0067, 0x0518,0x00c9, 0x0518,0x01eb, 0x0518,0x01ef,
+ 0x051c,0x0139, 0x051c,0x0168, 0x0520,0x0027, 0x0526,0x014e, 0x0526,0x0175,
+ 0x0526,0x018d, 0x052d,0x0200, 0x0532,0x0021, 0x0532,0x00bf, 0x0532,0x00d0,
+ 0x0532,0x0239, 0x0532,0x0266, 0x053d,0x0024, 0x053d,0x00da, 0x054a,0x000f,
+ 0x054a,0x00ab, 0x054a,0x023a, 0x054e,0x0043, 0x054e,0x004d, 0x054e,0x00c3,
+ 0x054e,0x013d, 0x054e,0x0215, 0x054e,0x0232, 0x054e,0x029d, 0x0552,0x014e,
+ 0x0552,0x018d, 0x0556,0x00f3, 0x0556,0x01e4, 0x055a,0x0299, 0x055d,0x0086,
+ 0x055d,0x009a, 0x055d,0x00ec, 0x055d,0x0172, 0x0566,0x01dc, 0x0566,0x02a5,
+ 0x056d,0x020a, 0x057a,0x003d, 0x057a,0x01d4, 0x057a,0x01f3, 0x0579,0x025e,
+ 0x057e,0x0139, 0x057e,0x0168, 0x0581,0x0006, 0x0586,0x017b, 0x0586,0x0181,
+ 0x0586,0x028c, 0x0588,0x0007, 0x058e,0x0033, 0x058e,0x008f, 0x058e,0x01d0,
+ 0x058e,0x027c, 0x0590,0x0003, 0x0596,0x0033, 0x0596,0x008f, 0x0596,0x0095,
+ 0x0596,0x01d0, 0x0596,0x027c, 0x05a2,0x026f, 0x05a5,0x0284, 0x05aa,0x017b,
+ 0x05ac,0x0205, 0x05b2,0x008f, 0x05b6,0x017b, 0x05b8,0x01da, 0x05c1,0x0276,
+ 0x05c6,0x0248, 0x05c8,0x0247, 0x05c8,0x027e, 0x05cc,0x003d, 0x05cc,0x01d4,
+ 0x05cc,0x01f3, 0x05d0,0x014e, 0x05d0,0x018d, 0x05da,0x00f9, 0x05dd,0x0006,
+ 0x05de,0x0044, 0x05e5,0x002e, 0x05e6,0x02f1, 0x05ea,0x01d4, 0x05ea,0x01f3,
+ 0x05ea,0x022d, 0x05ed,0x0002, 0x05f6,0x0027, 0x05fa,0x0097, 0x05fc,0x003d,
+ 0x0602,0x003d, 0x0606,0x00f3, 0x060a,0x0027, 0x060e,0x003d, 0x060e,0x0103,
+ 0x060e,0x018b, 0x060e,0x0231, 0x060e,0x02d1, 0x0611,0x01fc, 0x0611,0x0234,
+ 0x061a,0x0287, 0x061d,0x0214, 0x0621,0x01d4, 0x062a,0x0027, 0x062a,0x022d,
+ 0x062e,0x009e, 0x062e,0x0106, 0x062e,0x0198, 0x0632,0x009e, 0x0632,0x0106,
+ 0x0632,0x0198, 0x0639,0x0042, 0x0639,0x00b2, 0x0639,0x0108, 0x063d,0x01f8,
+ 0x0641,0x0086, 0x0641,0x009a, 0x0641,0x00ec, 0x0641,0x0172, 0x0645,0x0044,
+ 0x0649,0x0042, 0x0648,0x0087, 0x0648,0x00ed, 0x0648,0x0173, 0x0649,0x01a0,
+ 0x0648,0x0241, 0x0648,0x026f, 0x0648,0x02df, 0x0648,0x0307, 0x064c,0x023a,
+ 0x064c,0x02b3, 0x0651,0x0062, 0x0650,0x0217, 0x0651,0x02ac, 0x0650,0x02d6,
+ 0x0655,0x0042, 0x065d,0x0042, 0x0664,0x02b1, 0x0664,0x02ce, 0x0669,0x0238,
+ 0x066d,0x002a, 0x066c,0x0039, 0x066d,0x01f6, 0x066c,0x0213, 0x066c,0x022e,
+ 0x066d,0x02a2, 0x066c,0x02e1, 0x0671,0x002a, 0x0670,0x0030, 0x0670,0x0067,
+ 0x0670,0x00c9, 0x0670,0x01eb, 0x0670,0x01ef, 0x0670,0x02c3, 0x0675,0x0020,
+ 0x0678,0x0133, 0x0678,0x0148, 0x067c,0x0027, 0x0681,0x023a, 0x0684,0x0021,
+ 0x0684,0x00bf, 0x0684,0x00d0, 0x0689,0x01fc, 0x068e,0x0162, 0x068e,0x0183,
+ 0x0691,0x0200, 0x0696,0x0023, 0x0696,0x00e0, 0x0696,0x00fb, 0x0696,0x0268,
+ 0x069a,0x0282, 0x069d,0x007e, 0x06a2,0x004b, 0x06a2,0x023e, 0x06a2,0x02dc,
+ 0x06a6,0x0097, 0x06aa,0x02b1, 0x06aa,0x02ce, 0x06ae,0x0039, 0x06ae,0x0213,
+ 0x06ae,0x022e, 0x06ae,0x02e1, 0x06b2,0x0162, 0x06b2,0x0183, 0x06b6,0x0023,
+ 0x06b6,0x00e0, 0x06b6,0x00fb, 0x06ba,0x008f, 0x06ba,0x01e4, 0x06be,0x034b,
+ 0x06c1,0x0086, 0x06c1,0x009a, 0x06c1,0x00ec, 0x06c1,0x0172, 0x06c6,0x01da,
+ 0x06c6,0x0280, 0x06c6,0x0351, 0x06ce,0x008f, 0x06d2,0x01e3, 0x06d2,0x0287,
+ 0x06d2,0x0353, 0x06d6,0x027a, 0x06d6,0x029b, 0x06da,0x0033, 0x06da,0x01ce,
+ 0x06da,0x01f1, 0x06de,0x0133, 0x06de,0x0148, 0x06e2,0x0021, 0x06e2,0x00bf,
+ 0x06e2,0x00d0, 0x06e5,0x023a, 0x06e9,0x0004, 0x06ee,0x028c, 0x06ee,0x0338,
+ 0x06f2,0x0328, 0x06f2,0x0330, 0x06f4,0x0005, 0x06f9,0x01e0, 0x06fe,0x0328,
+ 0x06fe,0x0330, 0x0702,0x003d, 0x0702,0x00f3, 0x0702,0x0330, 0x0704,0x0003,
+ 0x070a,0x003d, 0x070a,0x00f3, 0x070a,0x01d4, 0x070a,0x01f3, 0x070a,0x0330,
+ 0x0711,0x032a, 0x0711,0x032e, 0x0716,0x003d, 0x0718,0x0205, 0x0718,0x0282,
+ 0x071e,0x00f3, 0x0720,0x01dc, 0x0720,0x02a5, 0x0726,0x0324, 0x072a,0x028a,
+ 0x072a,0x02a7, 0x0729,0x031c, 0x0729,0x032a, 0x072e,0x003d, 0x072e,0x00f9,
+ 0x072e,0x022d, 0x072e,0x0248, 0x072e,0x02e4, 0x0730,0x003d, 0x0730,0x0247,
+ 0x0730,0x02e3, 0x0730,0x0324, 0x0732,0x0324, 0x0739,0x032e, 0x073e,0x003d,
+ 0x0740,0x003d, 0x0744,0x027a, 0x0744,0x029b, 0x0748,0x0033, 0x0748,0x01ce,
+ 0x0748,0x01f1, 0x074c,0x0162, 0x074c,0x0183, 0x0750,0x0023, 0x0750,0x00e0,
+ 0x0750,0x00fb, 0x0755,0x0246, 0x075a,0x0095, 0x075a,0x0397, 0x075d,0x0004,
+ 0x076a,0x03b3, 0x076d,0x0002, 0x0772,0x02fb, 0x0772,0x0301, 0x0772,0x0315,
+ 0x0772,0x0397, 0x0776,0x008f, 0x077e,0x0027, 0x078a,0x00a1, 0x0792,0x009d,
+ 0x0792,0x00c3, 0x0792,0x02fb, 0x0792,0x0301, 0x0792,0x0315, 0x0792,0x03bd,
+ 0x0796,0x0027, 0x0796,0x024f, 0x079e,0x009d, 0x07a6,0x009d, 0x07a6,0x02fb,
+ 0x07a6,0x0301, 0x07a6,0x0315, 0x07a6,0x03bd, 0x07aa,0x0027, 0x07aa,0x024f,
+ 0x07ae,0x009d, 0x07b9,0x004e, 0x07b8,0x0087, 0x07b8,0x00ed, 0x07b8,0x0173,
+ 0x07b8,0x0197, 0x07b9,0x021a, 0x07b9,0x02b8, 0x07b9,0x0364, 0x07be,0x0029,
+ 0x07be,0x0030, 0x07c0,0x017b, 0x07c6,0x017b, 0x07c8,0x00f3, 0x07ce,0x00f3,
+ 0x07d0,0x008f, 0x07d6,0x008f, 0x07d9,0x01e8, 0x07dd,0x0292, 0x07e2,0x0053,
+ 0x07e6,0x008f, 0x07e6,0x00f3, 0x07e6,0x017b, 0x07e8,0x0029, 0x07e8,0x0030,
+ 0x07ec,0x0021, 0x07ec,0x02ad, 0x07f2,0x0181, 0x07f2,0x0315, 0x07f4,0x0021,
+ 0x07f8,0x020f, 0x07fd,0x002e, 0x0800,0x008f, 0x0805,0x0006, 0x0809,0x03c2,
+ 0x080d,0x0084, 0x0812,0x0009, 0x0811,0x0008, 0x0812,0x00f3, 0x0812,0x00f9,
+ 0x0812,0x017b, 0x0812,0x0181, 0x0814,0x0033, 0x0818,0x0023, 0x081c,0x0285,
+ 0x0826,0x03bd, 0x082c,0x008f, 0x082c,0x017b, 0x0832,0x0043, 0x0832,0x011b,
+ 0x0832,0x01b3, 0x0832,0x01c3, 0x0835,0x032a, 0x0838,0x0085, 0x0839,0x032a,
+ 0x083e,0x0049, 0x083d,0x0084, 0x083e,0x02fb, 0x083e,0x0301, 0x083e,0x0315,
+ 0x083e,0x0397, 0x0842,0x0009, 0x0841,0x0008, 0x0844,0x0009, 0x0846,0x008f,
+ 0x084a,0x0033, 0x084e,0x0285, 0x0851,0x009a, 0x0856,0x00a1, 0x0859,0x031c,
+ 0x085d,0x00b2, 0x0861,0x0012, 0x0861,0x02cc, 0x0865,0x0058, 0x0865,0x007e,
+ 0x0869,0x004a, 0x0871,0x0010, 0x0876,0x003d, 0x0879,0x032c, 0x087e,0x0089,
+ 0x0882,0x0229, 0x0882,0x022d, 0x0882,0x02c7, 0x0882,0x02cb, 0x0886,0x0021,
+ 0x0886,0x02ad, 0x0885,0x0356, 0x088a,0x0017, 0x088a,0x020f, 0x0889,0x0354,
+ 0x088d,0x009c, 0x0892,0x0089, 0x0895,0x0246, 0x089a,0x03bd, 0x089e,0x008f,
+ 0x089e,0x02f9, 0x089e,0x0313, 0x08a1,0x032a, 0x08a6,0x0053, 0x08a6,0x0095,
+ 0x08a6,0x0397, 0x08a8,0x017b, 0x08ad,0x031a, 0x08b2,0x017b, 0x08b4,0x00f3,
+ 0x08b5,0x02a0, 0x08b8,0x0089, 0x08c1,0x0024, 0x08c4,0x00f3, 0x08c9,0x007e,
+ 0x08cd,0x007c, 0x08cd,0x0222, 0x08cd,0x0294, 0x08d1,0x003a, 0x08d6,0x0009,
+ 0x08d9,0x003a, 0x08dc,0x001f, 0x08e0,0x008f, 0x08e0,0x017b, 0x08e4,0x0009,
+ 0x08e8,0x01ed, 0x08ed,0x031c, 0x08f2,0x003d, 0x08f6,0x008f, 0x08f6,0x017b,
+ 0x08fa,0x0009, 0x08fe,0x003d, 0x0902,0x01e9, 0x0904,0x01e9, 0x0904,0x0381,
+ 0x090a,0x03b1, 0x090d,0x031a, 0x0910,0x0299, 0x0914,0x034b, 0x0919,0x0008,
+ 0x091c,0x0033, 0x091c,0x003d, 0x0920,0x0027, 0x0924,0x0027, 0x0924,0x01fb,
+ 0x092a,0x01ce, 0x092a,0x01f1, 0x092d,0x031c, 0x0930,0x001f, 0x0936,0x00c5,
+ 0x0938,0x00c5, 0x0938,0x0381, 0x093c,0x001b, 0x0942,0x017d, 0x094a,0x0027,
+ 0x094e,0x0027, 0x094e,0x01fb, 0x0952,0x03b1, 0x095a,0x0029, 0x095a,0x0030,
+ 0x095d,0x0030, 0x0961,0x0030, 0x0966,0x02f9, 0x0966,0x0313, 0x0968,0x02eb,
+ 0x096d,0x0008, 0x0970,0x017b, 0x0974,0x0033, 0x0979,0x0150, 0x097d,0x009a,
+ 0x0982,0x0293, 0x0984,0x0293, 0x0984,0x0379, 0x098a,0x02eb, 0x098e,0x0009,
+ 0x0992,0x003d, 0x0996,0x003d, 0x0999,0x0062, 0x099e,0x003d, 0x09a0,0x0027,
+ 0x09a5,0x0144, 0x09a8,0x02b5, 0x09ae,0x008f, 0x09ae,0x009d, 0x09b2,0x004d,
+ 0x09b2,0x0053, 0x09b2,0x00c3, 0x09b2,0x013d, 0x09b2,0x01c5, 0x09b2,0x0271,
+ 0x09b4,0x0025, 0x09ba,0x0033, 0x09ba,0x0079, 0x09bc,0x0015, 0x09c2,0x013f,
+ 0x09c4,0x013f, 0x09c4,0x0379, 0x09ca,0x02b5, 0x09cd,0x0006, 0x09da,0x0009,
+ 0x09d9,0x0008, 0x09dc,0x000b, 0x09dc,0x004f, 0x09dd,0x0086, 0x09e0,0x0009,
+ 0x09e6,0x00a1, 0x09e8,0x0009, 0x09ed,0x0086, 0x09f2,0x001f, 0x09f2,0x002f,
+ 0x09f2,0x0049, 0x09f2,0x006f, 0x09f2,0x0085, 0x09f2,0x0091, 0x09f2,0x00a9,
+ 0x09f2,0x00d3, 0x09f2,0x00d7, 0x09f2,0x011d, 0x09f2,0x0121, 0x09f2,0x0235,
+ 0x09f2,0x0393, 0x09f6,0x0324, 0x09f8,0x0049, 0x09f8,0x00a9, 0x09f8,0x011d,
+ 0x09fe,0x001f, 0x09fe,0x0029, 0x09fe,0x0033, 0x09fe,0x003d, 0x09fe,0x0085,
+ 0x09fe,0x008f, 0x09fe,0x00d3, 0x0a00,0x003d, 0x0a06,0x012d, 0x0a0e,0x00b3,
+ 0x0a10,0x000b, 0x0a10,0x0387, 0x0a16,0x0059, 0x0a18,0x0009, 0x0a1e,0x0043,
+ 0x0a24,0x0085, 0x0a2a,0x0009, 0x0a2d,0x0008, 0x0a32,0x028a, 0x0a32,0x02a7,
+ 0x0a31,0x031c, 0x0a35,0x032e, 0x0a39,0x0006, 0x0a3a,0x0105, 0x0a3a,0x024f,
+ 0x0a3c,0x0299, 0x0a42,0x01ed, 0x0a46,0x0299, 0x0a48,0x01ed, 0x0a4c,0x0059,
+ 0x0a52,0x000b, 0x0a52,0x0387, 0x0a56,0x000b, 0x0a5e,0x0009, 0x0a60,0x003d,
+ 0x0a66,0x0105, 0x0a6a,0x0195, 0x0a6c,0x000b, 0x0a76,0x0053, 0x0a78,0x0009,
+ 0x0a7a,0x008f, 0x0a82,0x0299, 0x0a86,0x01ed, 0x0a8a,0x0027, 0x0a8e,0x004b,
+ 0x0a92,0x003d, 0x0a95,0x0322, 0x0a99,0x0038, 0x0a99,0x0090, 0x0a9c,0x0061,
+ 0x0a9c,0x00c7, 0x0a9c,0x012d, 0x0a9c,0x016f, 0x0a9c,0x017d, 0x0a9c,0x02c9,
+ 0x0a9c,0x0383, 0x0aa1,0x0010, 0x0aa4,0x00b3, 0x0aa8,0x002f, 0x0aac,0x0027,
+ 0x0ab0,0x004b, 0x0ab4,0x0043, 0x0ab9,0x0090, 0x0abd,0x0010, 0x0ac4,0x0019,
+ 0x0acc,0x00f5, 0x0acc,0x022b, 0x0acc,0x037b, 0x0ad2,0x008f, 0x0ad2,0x01f1,
+ 0x0ad6,0x0324, 0x0ad9,0x0330, 0x0ade,0x008f, 0x0ade,0x01f1, 0x0ae0,0x017b,
+ 0x0ae4,0x008f, 0x0ae9,0x004e, 0x0aee,0x0027, 0x0af2,0x028a, 0x0af2,0x02a7,
+ 0x0af1,0x031c, 0x0af6,0x0027, 0x0af9,0x031c, 0x0afe,0x00e9, 0x0afe,0x02bb,
+ 0x0b02,0x000b, 0x0b06,0x00f5, 0x0b06,0x022b, 0x0b06,0x037b, 0x0b0a,0x003d,
+ 0x0000,0x0000
+};
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
@@ -62,20 +437,21 @@ void Rwr_ManWriteToArray( Rwr_Man_t * p )
{
if ( i % 5 == 0 )
fprintf( pFile, "\n " );
- pNode = p->vForest->pArray[i+5];
+ pNode = (Rwr_Node_t *)p->vForest->pArray[i+5];
Entry0 = (Rwr_Regular(pNode->p0)->Id << 1) | Rwr_IsComplement(pNode->p0);
Entry1 = (Rwr_Regular(pNode->p1)->Id << 1) | Rwr_IsComplement(pNode->p1);
Entry0 = (Entry0 << 1) | pNode->fExor;
- Extra_PrintHex( pFile, Entry0, 4 );
+ Extra_PrintHex( pFile, &Entry0, 4 );
fprintf( pFile, "," );
- Extra_PrintHex( pFile, Entry1, 4 );
+ Extra_PrintHex( pFile, &Entry1, 4 );
fprintf( pFile, ", " );
}
if ( i % 5 == 0 )
fprintf( pFile, "\n " );
- Extra_PrintHex( pFile, 0, 4 );
+ Entry0 = 0;
+ Extra_PrintHex( pFile, &Entry0, 4 );
fprintf( pFile, "," );
- Extra_PrintHex( pFile, 0, 4 );
+ Extra_PrintHex( pFile, &Entry0, 4 );
fprintf( pFile, " \n};\n" );
fclose( pFile );
printf( "The number of nodes saved = %d. ", nEntries ); ABC_PRT( "Saving", clock() - clk );
@@ -111,8 +487,8 @@ void Rwr_ManLoadFromArray( Rwr_Man_t * p, int fVerbose )
fExor = (Entry0 & 1);
Entry0 >>= 1;
// get the nodes
- p0 = p->vForest->pArray[Entry0 >> 1];
- p1 = p->vForest->pArray[Entry1 >> 1];
+ p0 = (Rwr_Node_t *)p->vForest->pArray[Entry0 >> 1];
+ p1 = (Rwr_Node_t *)p->vForest->pArray[Entry1 >> 1];
// compute the level and volume of the new nodes
Level = 1 + ABC_MAX( p0->Level, p1->Level );
Volume = 1 + Rwr_ManNodeVolume( p, p0, p1 );
@@ -154,7 +530,7 @@ void Rwr_ManWriteToFile( Rwr_Man_t * p, char * pFileName )
pBuffer = ABC_ALLOC( unsigned, nEntries * 2 );
for ( i = 0; i < nEntries; i++ )
{
- pNode = p->vForest->pArray[i+5];
+ pNode = (Rwr_Node_t *)p->vForest->pArray[i+5];
pBuffer[2*i + 0] = (Rwr_Regular(pNode->p0)->Id << 1) | Rwr_IsComplement(pNode->p0);
pBuffer[2*i + 1] = (Rwr_Regular(pNode->p1)->Id << 1) | Rwr_IsComplement(pNode->p1);
// save EXOR flag
@@ -206,8 +582,8 @@ void Rwr_ManLoadFromFile( Rwr_Man_t * p, char * pFileName )
fExor = (pBuffer[2*i + 0] & 1);
pBuffer[2*i + 0] = (pBuffer[2*i + 0] >> 1);
// get the nodes
- p0 = p->vForest->pArray[pBuffer[2*i + 0] >> 1];
- p1 = p->vForest->pArray[pBuffer[2*i + 1] >> 1];
+ p0 = (Rwr_Node_t *)p->vForest->pArray[pBuffer[2*i + 0] >> 1];
+ p1 = (Rwr_Node_t *)p->vForest->pArray[pBuffer[2*i + 1] >> 1];
// compute the level and volume of the new nodes
Level = 1 + ABC_MAX( p0->Level, p1->Level );
Volume = 1 + Rwr_ManNodeVolume( p, p0, p1 );
@@ -276,384 +652,5 @@ char * Rwr_ManGetPractical( Rwr_Man_t * p )
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
-// the following 135 practical NPN classes of 4-variable functions were computed
-// by considering all 4-input cuts appearing in IWLS, MCNC, and ISCAS benchmarks
-static unsigned short s_RwrPracticalClasses[] =
-{
- 0x0000, 0x0001, 0x0003, 0x0006, 0x0007, 0x000f, 0x0016, 0x0017, 0x0018, 0x0019, 0x001b,
- 0x001e, 0x001f, 0x003c, 0x003d, 0x003f, 0x0069, 0x006b, 0x006f, 0x007e, 0x007f, 0x00ff,
- 0x0116, 0x0118, 0x0119, 0x011a, 0x011b, 0x011e, 0x011f, 0x012c, 0x012d, 0x012f, 0x013c,
- 0x013d, 0x013e, 0x013f, 0x0168, 0x0169, 0x016f, 0x017f, 0x0180, 0x0181, 0x0182, 0x0183,
- 0x0186, 0x0189, 0x018b, 0x018f, 0x0198, 0x0199, 0x019b, 0x01a8, 0x01a9, 0x01aa, 0x01ab,
- 0x01ac, 0x01ad, 0x01ae, 0x01af, 0x01bf, 0x01e9, 0x01ea, 0x01eb, 0x01ee, 0x01ef, 0x01fe,
- 0x033c, 0x033d, 0x033f, 0x0356, 0x0357, 0x0358, 0x0359, 0x035a, 0x035b, 0x035f, 0x0368,
- 0x0369, 0x036c, 0x036e, 0x037d, 0x03c0, 0x03c1, 0x03c3, 0x03c7, 0x03cf, 0x03d4, 0x03d5,
- 0x03d7, 0x03d8, 0x03d9, 0x03dc, 0x03dd, 0x03de, 0x03fc, 0x0660, 0x0661, 0x0666, 0x0669,
- 0x066f, 0x0676, 0x067e, 0x0690, 0x0696, 0x0697, 0x069f, 0x06b1, 0x06b6, 0x06f0, 0x06f2,
- 0x06f6, 0x06f9, 0x0776, 0x0778, 0x07b0, 0x07b1, 0x07b4, 0x07bc, 0x07f0, 0x07f2, 0x07f8,
- 0x0ff0, 0x1683, 0x1696, 0x1698, 0x169e, 0x16e9, 0x178e, 0x17e8, 0x18e7, 0x19e6, 0x1be4,
- 0x1ee1, 0x3cc3, 0x6996, 0x0000
-};
-
-static unsigned short s_RwtAigSubgraphs[] =
-{
- 0x0008,0x0002, 0x000a,0x0002, 0x0008,0x0003, 0x000a,0x0003, 0x0009,0x0002,
- 0x000c,0x0002, 0x000e,0x0002, 0x000c,0x0003, 0x000e,0x0003, 0x000d,0x0002,
- 0x000c,0x0004, 0x000e,0x0004, 0x000c,0x0005, 0x000e,0x0005, 0x000d,0x0004,
- 0x0010,0x0002, 0x0012,0x0002, 0x0010,0x0003, 0x0012,0x0003, 0x0011,0x0002,
- 0x0010,0x0004, 0x0012,0x0004, 0x0010,0x0005, 0x0012,0x0005, 0x0011,0x0004,
- 0x0010,0x0006, 0x0012,0x0006, 0x0010,0x0007, 0x0012,0x0007, 0x0011,0x0006,
- 0x0016,0x0005, 0x0014,0x0006, 0x0016,0x0006, 0x0014,0x0007, 0x0016,0x0007,
- 0x0015,0x0006, 0x0014,0x0008, 0x0016,0x0008, 0x0014,0x0009, 0x0016,0x0009,
- 0x0015,0x0008, 0x0018,0x0006, 0x001a,0x0006, 0x0018,0x0007, 0x001a,0x0007,
- 0x0019,0x0006, 0x0018,0x0009, 0x001a,0x0009, 0x0019,0x0008, 0x001e,0x0005,
- 0x001c,0x0006, 0x001e,0x0006, 0x001c,0x0007, 0x001e,0x0007, 0x001d,0x0006,
- 0x001c,0x0008, 0x001e,0x0008, 0x001c,0x0009, 0x001e,0x0009, 0x001d,0x0008,
- 0x0020,0x0006, 0x0022,0x0006, 0x0020,0x0007, 0x0022,0x0007, 0x0021,0x0006,
- 0x0020,0x0008, 0x0022,0x0008, 0x0020,0x0009, 0x0022,0x0009, 0x0021,0x0008,
- 0x0024,0x0006, 0x0026,0x0006, 0x0024,0x0007, 0x0026,0x0007, 0x0025,0x0006,
- 0x0026,0x0008, 0x0024,0x0009, 0x0026,0x0009, 0x0025,0x0008, 0x0028,0x0004,
- 0x002a,0x0004, 0x0028,0x0005, 0x002a,0x0007, 0x0028,0x0008, 0x002a,0x0009,
- 0x0029,0x0008, 0x002a,0x000b, 0x0029,0x000a, 0x002a,0x000f, 0x0029,0x000e,
- 0x002a,0x0011, 0x002a,0x0013, 0x002c,0x0004, 0x002e,0x0004, 0x002c,0x0005,
- 0x002c,0x0009, 0x002e,0x0009, 0x002d,0x0008, 0x002d,0x000c, 0x002e,0x000f,
- 0x002e,0x0011, 0x002e,0x0012, 0x0030,0x0004, 0x0032,0x0007, 0x0032,0x0009,
- 0x0031,0x0008, 0x0032,0x000b, 0x0032,0x000d, 0x0032,0x000f, 0x0031,0x000e,
- 0x0032,0x0013, 0x0034,0x0004, 0x0036,0x0004, 0x0034,0x0005, 0x0036,0x0005,
- 0x0035,0x0004, 0x0036,0x0008, 0x0034,0x0009, 0x0036,0x0009, 0x0035,0x0008,
- 0x0036,0x000b, 0x0036,0x000d, 0x0036,0x0011, 0x0035,0x0010, 0x0036,0x0013,
- 0x0038,0x0004, 0x0039,0x0004, 0x0038,0x0009, 0x003a,0x0009, 0x0039,0x0008,
- 0x0038,0x000b, 0x003a,0x000b, 0x003a,0x000d, 0x003a,0x0011, 0x003a,0x0012,
- 0x0038,0x0013, 0x003a,0x0013, 0x003c,0x0002, 0x003e,0x0002, 0x003c,0x0003,
- 0x003e,0x0005, 0x003e,0x0007, 0x003c,0x0008, 0x003e,0x0008, 0x003c,0x0009,
- 0x003e,0x0009, 0x003d,0x0008, 0x003e,0x000d, 0x003e,0x0011, 0x003e,0x0013,
- 0x003e,0x0017, 0x003e,0x001b, 0x003e,0x001d, 0x0040,0x0002, 0x0042,0x0002,
- 0x0042,0x0005, 0x0041,0x0006, 0x0042,0x0008, 0x0041,0x0008, 0x0042,0x000d,
- 0x0042,0x0011, 0x0042,0x0015, 0x0042,0x0019, 0x0042,0x001b, 0x0042,0x001c,
- 0x0041,0x001c, 0x0044,0x0002, 0x0046,0x0003, 0x0045,0x0004, 0x0046,0x0007,
- 0x0045,0x0008, 0x0046,0x000b, 0x0046,0x000f, 0x0046,0x0013, 0x0045,0x0012,
- 0x0046,0x0017, 0x0046,0x001b, 0x0046,0x0021, 0x0048,0x0002, 0x004a,0x0002,
- 0x0048,0x0003, 0x004a,0x0003, 0x0049,0x0002, 0x0048,0x0008, 0x004a,0x0008,
- 0x0048,0x0009, 0x004a,0x0009, 0x0049,0x0008, 0x004a,0x000b, 0x004a,0x000f,
- 0x004a,0x0011, 0x004a,0x0012, 0x004a,0x0013, 0x004a,0x0015, 0x004a,0x0019,
- 0x004a,0x001b, 0x004a,0x001d, 0x004c,0x0002, 0x004c,0x0003, 0x004d,0x0002,
- 0x004c,0x0008, 0x004e,0x0008, 0x004c,0x0009, 0x004e,0x0009, 0x004d,0x0008,
- 0x004c,0x000b, 0x004e,0x000b, 0x004c,0x000f, 0x004e,0x000f, 0x004e,0x0011,
- 0x004c,0x0012, 0x004c,0x0013, 0x004e,0x0013, 0x004e,0x0015, 0x004c,0x0017,
- 0x004e,0x0019, 0x004c,0x001b, 0x004e,0x001b, 0x004c,0x001c, 0x004c,0x001d,
- 0x004e,0x001d, 0x0050,0x0004, 0x0052,0x0004, 0x0050,0x0006, 0x0052,0x0009,
- 0x0052,0x000d, 0x0052,0x000f, 0x0052,0x0013, 0x0052,0x0017, 0x0052,0x0019,
- 0x0052,0x001d, 0x0052,0x001f, 0x0052,0x0021, 0x0052,0x0023, 0x0052,0x0024,
- 0x0052,0x0025, 0x0051,0x0024, 0x0052,0x0027, 0x0054,0x0004, 0x0056,0x0004,
- 0x0054,0x0005, 0x0056,0x0006, 0x0054,0x0007, 0x0056,0x0011, 0x0056,0x001b,
- 0x0056,0x001e, 0x0054,0x001f, 0x0056,0x001f, 0x0056,0x0020, 0x0054,0x0021,
- 0x0055,0x0020, 0x0056,0x0024, 0x0054,0x0025, 0x0056,0x0025, 0x0055,0x0024,
- 0x0054,0x0027, 0x0056,0x0027, 0x0055,0x0026, 0x005a,0x0007, 0x005a,0x0009,
- 0x005a,0x000b, 0x005a,0x0015, 0x005a,0x001f, 0x0059,0x0020, 0x0058,0x0024,
- 0x005a,0x0024, 0x005a,0x0027, 0x0059,0x0026, 0x005c,0x0004, 0x005e,0x0004,
- 0x005c,0x0005, 0x005e,0x0006, 0x005c,0x0007, 0x005d,0x0006, 0x005e,0x000d,
- 0x005e,0x0013, 0x005e,0x0017, 0x005c,0x001f, 0x005d,0x001e, 0x005e,0x0020,
- 0x005e,0x0021, 0x005e,0x0022, 0x005e,0x0023, 0x005c,0x0024, 0x005e,0x0024,
- 0x005c,0x0025, 0x005e,0x0025, 0x005d,0x0024, 0x005e,0x0026, 0x005e,0x0027,
- 0x0062,0x0004, 0x0061,0x0004, 0x0062,0x0006, 0x0061,0x0006, 0x0060,0x000f,
- 0x0060,0x0013, 0x0062,0x0013, 0x0060,0x0019, 0x0062,0x001c, 0x0060,0x001d,
- 0x0062,0x001d, 0x0062,0x001f, 0x0060,0x0021, 0x0060,0x0023, 0x0062,0x0024,
- 0x0060,0x0027, 0x0061,0x0026, 0x0064,0x0002, 0x0066,0x0002, 0x0064,0x0006,
- 0x0066,0x0007, 0x0066,0x0009, 0x0066,0x000d, 0x0066,0x0013, 0x0066,0x0015,
- 0x0066,0x0017, 0x0066,0x0019, 0x0066,0x001a, 0x0065,0x001a, 0x0066,0x001f,
- 0x0066,0x0023, 0x0066,0x0027, 0x0066,0x002f, 0x0066,0x0030, 0x006a,0x0002,
- 0x0068,0x0003, 0x0068,0x0006, 0x006a,0x0006, 0x006a,0x0011, 0x0068,0x0016,
- 0x0068,0x0017, 0x006a,0x0017, 0x006a,0x001a, 0x006a,0x001b, 0x006a,0x0025,
- 0x006a,0x002d, 0x006e,0x0003, 0x006e,0x0007, 0x006e,0x0009, 0x006e,0x000b,
- 0x006e,0x0015, 0x006e,0x0016, 0x006e,0x0017, 0x006c,0x001a, 0x006e,0x001a,
- 0x006e,0x001f, 0x006e,0x002b, 0x006e,0x0035, 0x0070,0x0002, 0x0070,0x0003,
- 0x0072,0x0006, 0x0070,0x0007, 0x0071,0x0006, 0x0072,0x000b, 0x0072,0x000f,
- 0x0072,0x0013, 0x0070,0x0015, 0x0071,0x0014, 0x0072,0x0017, 0x0072,0x0018,
- 0x0070,0x0019, 0x0072,0x0019, 0x0070,0x001a, 0x0070,0x001b, 0x0072,0x001b,
- 0x0071,0x001a, 0x0072,0x0021, 0x0072,0x0029, 0x0076,0x0002, 0x0076,0x0003,
- 0x0075,0x0002, 0x0076,0x0006, 0x0074,0x0007, 0x0076,0x0007, 0x0075,0x0006,
- 0x0076,0x000d, 0x0076,0x0011, 0x0076,0x0013, 0x0075,0x0014, 0x0076,0x0019,
- 0x0076,0x001a, 0x0076,0x001b, 0x0075,0x001c, 0x0074,0x0023, 0x0075,0x0022,
- 0x0074,0x0026, 0x0076,0x0026, 0x0074,0x0027, 0x0076,0x002b, 0x0076,0x002f,
- 0x0078,0x0002, 0x0078,0x0004, 0x007a,0x0004, 0x007a,0x0005, 0x0079,0x0004,
- 0x007a,0x0009, 0x007a,0x000a, 0x007a,0x000b, 0x007a,0x000d, 0x007a,0x000f,
- 0x007a,0x0010, 0x007a,0x0011, 0x007a,0x0012, 0x007a,0x0013, 0x007a,0x0017,
- 0x007a,0x001b, 0x007a,0x0021, 0x007a,0x0027, 0x007a,0x002b, 0x007a,0x002f,
- 0x007a,0x0030, 0x0079,0x0034, 0x007a,0x0039, 0x007a,0x003a, 0x007e,0x0002,
- 0x007c,0x0004, 0x007e,0x0004, 0x007e,0x000c, 0x007c,0x000d, 0x007e,0x0011,
- 0x007e,0x0013, 0x007e,0x001b, 0x007e,0x0025, 0x007e,0x002d, 0x007e,0x0037,
- 0x0082,0x0003, 0x0082,0x0005, 0x0082,0x0009, 0x0082,0x000b, 0x0080,0x0010,
- 0x0082,0x0010, 0x0082,0x0012, 0x0082,0x0015, 0x0082,0x001f, 0x0082,0x002b,
- 0x0082,0x0035, 0x0082,0x0039, 0x0082,0x003f, 0x0084,0x0002, 0x0086,0x0002,
- 0x0084,0x0003, 0x0086,0x0003, 0x0085,0x0002, 0x0086,0x0004, 0x0084,0x0005,
- 0x0085,0x0004, 0x0086,0x000a, 0x0084,0x000b, 0x0085,0x000a, 0x0086,0x000d,
- 0x0086,0x000e, 0x0086,0x000f, 0x0084,0x0010, 0x0084,0x0011, 0x0086,0x0011,
- 0x0085,0x0010, 0x0084,0x0012, 0x0084,0x0013, 0x0086,0x0013, 0x0085,0x0012,
- 0x0086,0x0019, 0x0086,0x0023, 0x0086,0x0029, 0x0086,0x0033, 0x0086,0x0039,
- 0x008a,0x0003, 0x0089,0x0002, 0x0088,0x0004, 0x008a,0x0004, 0x0088,0x0005,
- 0x0089,0x0004, 0x008a,0x000b, 0x008a,0x0010, 0x0088,0x0011, 0x008a,0x0011,
- 0x0089,0x0010, 0x0088,0x0012, 0x008a,0x0012, 0x0089,0x0012, 0x008a,0x0017,
- 0x008a,0x001b, 0x0089,0x0020, 0x008a,0x0025, 0x0088,0x0027, 0x008a,0x002b,
- 0x008a,0x002f, 0x008a,0x0039, 0x0088,0x003a, 0x008d,0x0044, 0x0092,0x0009,
- 0x0092,0x0025, 0x0092,0x0029, 0x0092,0x002d, 0x0092,0x0033, 0x0092,0x0037,
- 0x0092,0x003d, 0x0092,0x0041, 0x0095,0x0002, 0x0095,0x0004, 0x0095,0x0010,
- 0x0095,0x0012, 0x0096,0x0021, 0x0096,0x0029, 0x0095,0x002e, 0x0096,0x0030,
- 0x0096,0x0033, 0x0096,0x003a, 0x0096,0x0043, 0x009a,0x0008, 0x009a,0x0009,
- 0x0099,0x0008, 0x009a,0x0011, 0x009a,0x0023, 0x009a,0x0033, 0x009a,0x003d,
- 0x009a,0x0044, 0x009a,0x0045, 0x0099,0x0044, 0x009d,0x0002, 0x009e,0x0008,
- 0x009c,0x0009, 0x009e,0x0009, 0x009d,0x0008, 0x009e,0x0011, 0x009d,0x0010,
- 0x009e,0x001f, 0x009e,0x003f, 0x00a0,0x0009, 0x00a0,0x0011, 0x00a2,0x0030,
- 0x00a2,0x0033, 0x00a6,0x0006, 0x00a6,0x0007, 0x00a6,0x0011, 0x00a6,0x0044,
- 0x00a6,0x004b, 0x00aa,0x0007, 0x00aa,0x0015, 0x00ae,0x0006, 0x00ae,0x0011,
- 0x00ae,0x001b, 0x00ae,0x0025, 0x00ae,0x003d, 0x00ae,0x0041, 0x00ae,0x0043,
- 0x00ae,0x0045, 0x00b2,0x0006, 0x00b0,0x0007, 0x00b1,0x0006, 0x00b2,0x0017,
- 0x00b1,0x0016, 0x00b0,0x0019, 0x00b2,0x0021, 0x00b2,0x003d, 0x00b5,0x004a,
- 0x00ba,0x0009, 0x00ba,0x000f, 0x00bc,0x0009, 0x00be,0x0009, 0x00be,0x000f,
- 0x00bd,0x000e, 0x00be,0x0017, 0x00c2,0x0009, 0x00c2,0x0019, 0x00c2,0x001f,
- 0x00c2,0x0033, 0x00c6,0x0009, 0x00c5,0x000e, 0x00c6,0x0015, 0x00c6,0x0023,
- 0x00c4,0x002d, 0x00c6,0x002f, 0x00c5,0x002e, 0x00c6,0x0045, 0x00ce,0x0007,
- 0x00ce,0x0021, 0x00ce,0x0023, 0x00ce,0x0025, 0x00ce,0x0027, 0x00ce,0x0033,
- 0x00ce,0x003d, 0x00d2,0x0006, 0x00d0,0x0015, 0x00d0,0x001b, 0x00d2,0x001b,
- 0x00d1,0x001a, 0x00d0,0x001f, 0x00d2,0x0025, 0x00d1,0x0024, 0x00d2,0x0037,
- 0x00d2,0x0041, 0x00d2,0x0045, 0x00d9,0x0044, 0x00e1,0x0004, 0x00e2,0x000d,
- 0x00e2,0x0021, 0x00e0,0x003a, 0x00e6,0x003d, 0x00e6,0x0061, 0x00e6,0x0067,
- 0x00e9,0x0004, 0x00ea,0x0008, 0x00ea,0x0009, 0x00ea,0x0039, 0x00e9,0x0038,
- 0x00ea,0x003f, 0x00ec,0x000d, 0x00ee,0x000d, 0x00ee,0x0037, 0x00f2,0x003d,
- 0x00f2,0x0062, 0x00f5,0x0002, 0x00fa,0x0017, 0x00fa,0x003d, 0x00fe,0x0006,
- 0x00fd,0x0006, 0x00fc,0x0015, 0x00fe,0x001b, 0x00fc,0x0025, 0x00fe,0x0025,
- 0x00fd,0x0024, 0x00fe,0x0041, 0x00fe,0x004d, 0x00fd,0x004e, 0x0101,0x0014,
- 0x0106,0x004d, 0x010a,0x0009, 0x010a,0x000b, 0x0109,0x000a, 0x010a,0x004f,
- 0x010a,0x0058, 0x010e,0x0008, 0x010c,0x0009, 0x010e,0x0009, 0x010d,0x0008,
- 0x010e,0x000b, 0x010e,0x002b, 0x010d,0x002a, 0x010e,0x0035, 0x010e,0x003d,
- 0x010e,0x003f, 0x010e,0x0049, 0x010e,0x0057, 0x010d,0x0056, 0x010d,0x0058,
- 0x0111,0x0004, 0x0111,0x0006, 0x0110,0x0009, 0x0112,0x0009, 0x0111,0x0008,
- 0x0112,0x002f, 0x0110,0x0035, 0x0110,0x0037, 0x0112,0x0039, 0x0112,0x003d,
- 0x0112,0x003f, 0x0112,0x0045, 0x0111,0x0044, 0x0112,0x004b, 0x0112,0x0059,
- 0x0112,0x0069, 0x0112,0x007f, 0x0116,0x0009, 0x0115,0x0008, 0x0114,0x000b,
- 0x0116,0x000b, 0x0116,0x0058, 0x011a,0x0015, 0x011a,0x001f, 0x011a,0x002b,
- 0x011a,0x003f, 0x011a,0x0049, 0x011a,0x0085, 0x011e,0x0007, 0x011e,0x0019,
- 0x011e,0x001b, 0x011e,0x0023, 0x011e,0x0027, 0x011e,0x002f, 0x011e,0x0043,
- 0x011e,0x004b, 0x011e,0x004e, 0x011e,0x004f, 0x011e,0x005f, 0x011e,0x0061,
- 0x011e,0x0065, 0x011e,0x0083, 0x0122,0x0006, 0x0120,0x0007, 0x0122,0x0007,
- 0x0121,0x0006, 0x0122,0x0049, 0x0121,0x004e, 0x0122,0x008f, 0x0125,0x0004,
- 0x0124,0x0007, 0x0125,0x0006, 0x0124,0x001b, 0x0126,0x001b, 0x0126,0x0045,
- 0x0126,0x0087, 0x0128,0x0007, 0x0129,0x0006, 0x012a,0x0019, 0x012a,0x003d,
- 0x012a,0x0051, 0x012a,0x0065, 0x012a,0x0083, 0x012d,0x005a, 0x0132,0x0009,
- 0x0132,0x008f, 0x0134,0x0009, 0x0135,0x003e, 0x013a,0x003d, 0x013a,0x0044,
- 0x0139,0x0044, 0x013e,0x0009, 0x013d,0x0008, 0x013c,0x003d, 0x013c,0x0044,
- 0x013c,0x0053, 0x013e,0x008f, 0x013e,0x0095, 0x0142,0x0044, 0x0142,0x0097,
- 0x0142,0x009e, 0x0144,0x0007, 0x0148,0x0015, 0x0148,0x001c, 0x0148,0x001f,
- 0x0148,0x0026, 0x0149,0x0086, 0x014d,0x0006, 0x014e,0x0044, 0x014d,0x0048,
- 0x014e,0x009e, 0x0152,0x0009, 0x0151,0x00a6, 0x0155,0x0030, 0x015d,0x003a,
- 0x0162,0x009e, 0x0164,0x000f, 0x0164,0x0013, 0x0169,0x000e, 0x0174,0x0009,
- 0x0179,0x0008, 0x0180,0x0009, 0x0181,0x0044, 0x0186,0x0044, 0x0185,0x0044,
- 0x018a,0x0068, 0x0195,0x004e, 0x01a6,0x0009, 0x01a5,0x0008, 0x01b1,0x003a,
- 0x01c4,0x0029, 0x01c4,0x0030, 0x01ca,0x008f, 0x01ca,0x0095, 0x01cc,0x0029,
- 0x01cc,0x0033, 0x01ce,0x003d, 0x01d6,0x00b2, 0x01d8,0x0009, 0x01d9,0x002a,
- 0x01d9,0x0056, 0x01d9,0x00a4, 0x01dd,0x003a, 0x01e2,0x00b2, 0x01e6,0x0013,
- 0x01e6,0x009f, 0x01e6,0x00ba, 0x01e6,0x00c0, 0x01e6,0x00d3, 0x01e6,0x00d5,
- 0x01e6,0x00e5, 0x01e8,0x0005, 0x01f2,0x0013, 0x01f2,0x0095, 0x01f2,0x009f,
- 0x01f2,0x00ba, 0x01f2,0x00c0, 0x01f2,0x00d3, 0x0202,0x008f, 0x0202,0x0095,
- 0x0202,0x00f3, 0x0202,0x00f9, 0x020a,0x0044, 0x0209,0x00b4, 0x020e,0x0009,
- 0x020d,0x0008, 0x020c,0x003d, 0x020c,0x0044, 0x020c,0x0053, 0x020e,0x008f,
- 0x020e,0x0095, 0x020c,0x00b1, 0x020e,0x00f3, 0x020e,0x00f9, 0x0210,0x0013,
- 0x0211,0x0024, 0x0210,0x0026, 0x0219,0x0004, 0x021e,0x008f, 0x021e,0x0095,
- 0x0221,0x003a, 0x0230,0x0009, 0x0236,0x0009, 0x0234,0x0029, 0x0234,0x0030,
- 0x0234,0x0033, 0x0234,0x003a, 0x0234,0x003d, 0x0234,0x0044, 0x0235,0x00a6,
- 0x023a,0x0009, 0x023d,0x003a, 0x0245,0x0044, 0x0249,0x003a, 0x024e,0x009e,
- 0x024e,0x0106, 0x0251,0x0026, 0x0258,0x0013, 0x0259,0x0024, 0x0258,0x0061,
- 0x0259,0x0086, 0x0258,0x00c7, 0x0258,0x00df, 0x0259,0x00ec, 0x0258,0x00fc,
- 0x025d,0x0024, 0x025d,0x00de, 0x0260,0x00f6, 0x0268,0x0009, 0x0269,0x0044,
- 0x0268,0x00f3, 0x0268,0x00f9, 0x026d,0x003a, 0x0270,0x0068, 0x0275,0x003a,
- 0x027a,0x0044, 0x0279,0x0044, 0x027e,0x007e, 0x0281,0x0044, 0x0285,0x0008,
- 0x028d,0x0006, 0x028d,0x00d2, 0x0295,0x00cc, 0x0296,0x00f6, 0x0295,0x00f8,
- 0x0299,0x0030, 0x029e,0x007e, 0x029d,0x0080, 0x02a6,0x008f, 0x02a6,0x0095,
- 0x02aa,0x0029, 0x02aa,0x0030, 0x02b5,0x0008, 0x02b9,0x003a, 0x02bd,0x0004,
- 0x02bd,0x00fc, 0x02c2,0x00b2, 0x02c1,0x00b4, 0x02c4,0x0029, 0x02c8,0x0029,
- 0x02c8,0x0033, 0x02ca,0x003d, 0x02ce,0x0029, 0x02ce,0x0030, 0x02d2,0x0068,
- 0x02d1,0x006a, 0x02d5,0x006a, 0x02d9,0x0008, 0x02de,0x012c, 0x02e2,0x012c,
- 0x02e4,0x0009, 0x02e5,0x002a, 0x02e5,0x0056, 0x02e5,0x012c, 0x02ea,0x0029,
- 0x02ea,0x0030, 0x02e9,0x0030, 0x02ec,0x0029, 0x02ec,0x0030, 0x02ee,0x012c,
- 0x02f1,0x0068, 0x02f1,0x00b2, 0x02f1,0x0108, 0x02f1,0x012c, 0x02f6,0x0013,
- 0x02f6,0x0015, 0x02f6,0x001f, 0x02f6,0x0030, 0x02f6,0x0065, 0x02f6,0x0067,
- 0x02f6,0x009f, 0x02f6,0x00b6, 0x02f6,0x00b9, 0x02f6,0x00c0, 0x02f6,0x00cf,
- 0x02f6,0x0107, 0x02f6,0x010b, 0x02f6,0x010f, 0x02f6,0x0115, 0x02f6,0x012d,
- 0x02f6,0x0134, 0x02f6,0x0153, 0x02f6,0x0171, 0x02f6,0x0176, 0x02f8,0x0003,
- 0x02fa,0x017b, 0x02fc,0x00ba, 0x02fc,0x00d3, 0x0302,0x0013, 0x0302,0x001f,
- 0x0302,0x0030, 0x0302,0x005d, 0x0302,0x0065, 0x0302,0x0067, 0x0302,0x0099,
- 0x0302,0x009f, 0x0302,0x00ad, 0x0302,0x00b9, 0x0302,0x00c0, 0x0302,0x00cf,
- 0x0301,0x00d2, 0x0301,0x00fe, 0x0302,0x0107, 0x0302,0x010b, 0x0302,0x010f,
- 0x0302,0x0117, 0x0302,0x0134, 0x0302,0x0153, 0x0302,0x0157, 0x0302,0x0176,
- 0x0306,0x0029, 0x0308,0x00b2, 0x0309,0x00dc, 0x030d,0x00f8, 0x0312,0x00f3,
- 0x0318,0x007e, 0x031d,0x0080, 0x0321,0x0008, 0x0321,0x0094, 0x0326,0x017b,
- 0x0326,0x0181, 0x0329,0x012e, 0x032a,0x017b, 0x032a,0x0181, 0x032e,0x008f,
- 0x032e,0x0095, 0x032e,0x00f3, 0x032e,0x00f9, 0x0332,0x0009, 0x0331,0x0008,
- 0x0330,0x003d, 0x0330,0x0044, 0x0330,0x0053, 0x0332,0x008f, 0x0332,0x0095,
- 0x0330,0x00b1, 0x0332,0x00f3, 0x0332,0x00f9, 0x0330,0x0127, 0x0332,0x017b,
- 0x0332,0x0181, 0x033c,0x0013, 0x033c,0x001c, 0x033d,0x0086, 0x033d,0x00ec,
- 0x033d,0x0172, 0x033e,0x019d, 0x0345,0x0002, 0x0344,0x008f, 0x0344,0x00f3,
- 0x034d,0x0030, 0x0352,0x0033, 0x0354,0x0029, 0x0354,0x0030, 0x035a,0x0009,
- 0x035a,0x017b, 0x035a,0x019b, 0x035a,0x01a2, 0x035e,0x0181, 0x0360,0x0009,
- 0x0366,0x0009, 0x0364,0x0029, 0x0364,0x0030, 0x0364,0x0033, 0x0364,0x003a,
- 0x0364,0x003d, 0x0364,0x0044, 0x0369,0x0030, 0x0370,0x0029, 0x0370,0x0030,
- 0x0376,0x0033, 0x037a,0x0009, 0x037a,0x019b, 0x037a,0x01a2, 0x037c,0x0009,
- 0x0382,0x0181, 0x0386,0x0009, 0x0384,0x0029, 0x0384,0x0030, 0x0384,0x0033,
- 0x0384,0x003a, 0x0384,0x003d, 0x0384,0x0044, 0x038a,0x0044, 0x038a,0x009e,
- 0x038a,0x0106, 0x038a,0x0198, 0x038d,0x010e, 0x038d,0x0152, 0x038d,0x0158,
- 0x0392,0x009e, 0x0392,0x0106, 0x0392,0x0198, 0x0395,0x0086, 0x0395,0x009a,
- 0x0395,0x00ec, 0x0395,0x0172, 0x0398,0x014e, 0x0398,0x0175, 0x0398,0x018d,
- 0x039c,0x0023, 0x039c,0x0027, 0x039c,0x00ef, 0x039c,0x0139, 0x039c,0x0168,
- 0x03a0,0x0019, 0x03a0,0x001d, 0x03a0,0x0023, 0x03a0,0x0027, 0x03a1,0x004e,
- 0x03a4,0x0162, 0x03a4,0x0183, 0x03a8,0x0013, 0x03a8,0x0027, 0x03a8,0x0133,
- 0x03a8,0x0148, 0x03a8,0x0181, 0x03ac,0x0013, 0x03ac,0x0027, 0x03b0,0x017b,
- 0x03b0,0x0181, 0x03b4,0x004b, 0x03b4,0x00e0, 0x03b4,0x00fb, 0x03b8,0x000f,
- 0x03b8,0x0013, 0x03b8,0x00ab, 0x03b8,0x00bf, 0x03b8,0x00d0, 0x03bd,0x00da,
- 0x03bd,0x012c, 0x03c8,0x000f, 0x03c8,0x0013, 0x03c8,0x0019, 0x03c8,0x001d,
- 0x03cd,0x0086, 0x03cd,0x00ec, 0x03cd,0x0172, 0x03d2,0x00e0, 0x03d2,0x00ef,
- 0x03d2,0x0112, 0x03d2,0x0139, 0x03d2,0x0168, 0x03d6,0x017b, 0x03d6,0x0181,
- 0x03da,0x0133, 0x03da,0x0148, 0x03e2,0x0023, 0x03e2,0x0027, 0x03e6,0x0027,
- 0x03e6,0x0181, 0x03ee,0x017b, 0x03ee,0x0181, 0x03fe,0x003d, 0x0401,0x012a,
- 0x0401,0x019e, 0x0405,0x01a0, 0x040a,0x000d, 0x040a,0x011f, 0x040a,0x016f,
- 0x040d,0x012a, 0x0412,0x017b, 0x041a,0x0033, 0x041a,0x003d, 0x041a,0x0181,
- 0x0421,0x0086, 0x0421,0x009a, 0x0421,0x00ec, 0x0421,0x0172, 0x042e,0x0205,
- 0x043a,0x0205, 0x043e,0x017b, 0x0442,0x01f5, 0x044c,0x0007, 0x0452,0x0033,
- 0x0452,0x01ce, 0x0452,0x01d0, 0x0452,0x01f1, 0x0452,0x01fb, 0x0452,0x0225,
- 0x0454,0x0005, 0x045a,0x0033, 0x045a,0x0181, 0x045a,0x01ce, 0x045a,0x01d0,
- 0x045a,0x01f1, 0x0469,0x01de, 0x046e,0x0181, 0x047a,0x01ce, 0x047a,0x01f1,
- 0x0485,0x012c, 0x0489,0x012c, 0x0490,0x01d8, 0x0496,0x0033, 0x0496,0x003d,
- 0x0498,0x008f, 0x0498,0x00f3, 0x049e,0x0044, 0x049e,0x0221, 0x04a1,0x0006,
- 0x04a2,0x0044, 0x04a6,0x0221, 0x04a9,0x0004, 0x04ac,0x0027, 0x04b1,0x009a,
- 0x04b6,0x0097, 0x04b8,0x0027, 0x04c6,0x0219, 0x04ca,0x017b, 0x04cc,0x004b,
- 0x04d0,0x00ab, 0x04d6,0x017b, 0x04d8,0x000f, 0x04d8,0x0019, 0x04d8,0x0033,
- 0x04d8,0x003d, 0x04de,0x003d, 0x04de,0x0103, 0x04de,0x018b, 0x04de,0x0231,
- 0x04e2,0x0044, 0x04e2,0x009e, 0x04e2,0x0106, 0x04e2,0x0198, 0x04e5,0x01a4,
- 0x04e5,0x01b6, 0x04ea,0x009e, 0x04ea,0x0106, 0x04ea,0x0198, 0x04ed,0x002e,
- 0x04ed,0x0038, 0x04ed,0x00a2, 0x04f1,0x0086, 0x04f1,0x009a, 0x04f1,0x00ec,
- 0x04f1,0x0172, 0x04f9,0x004e, 0x04f8,0x0229, 0x04f8,0x022d, 0x0500,0x023e,
- 0x0504,0x0217, 0x0510,0x00f3, 0x0514,0x0043, 0x0514,0x004d, 0x0514,0x00c3,
- 0x0514,0x013d, 0x0514,0x0215, 0x0514,0x0232, 0x0515,0x0260, 0x0519,0x002a,
- 0x0518,0x0030, 0x0518,0x0067, 0x0518,0x00c9, 0x0518,0x01eb, 0x0518,0x01ef,
- 0x051c,0x0139, 0x051c,0x0168, 0x0520,0x0027, 0x0526,0x014e, 0x0526,0x0175,
- 0x0526,0x018d, 0x052d,0x0200, 0x0532,0x0021, 0x0532,0x00bf, 0x0532,0x00d0,
- 0x0532,0x0239, 0x0532,0x0266, 0x053d,0x0024, 0x053d,0x00da, 0x054a,0x000f,
- 0x054a,0x00ab, 0x054a,0x023a, 0x054e,0x0043, 0x054e,0x004d, 0x054e,0x00c3,
- 0x054e,0x013d, 0x054e,0x0215, 0x054e,0x0232, 0x054e,0x029d, 0x0552,0x014e,
- 0x0552,0x018d, 0x0556,0x00f3, 0x0556,0x01e4, 0x055a,0x0299, 0x055d,0x0086,
- 0x055d,0x009a, 0x055d,0x00ec, 0x055d,0x0172, 0x0566,0x01dc, 0x0566,0x02a5,
- 0x056d,0x020a, 0x057a,0x003d, 0x057a,0x01d4, 0x057a,0x01f3, 0x0579,0x025e,
- 0x057e,0x0139, 0x057e,0x0168, 0x0581,0x0006, 0x0586,0x017b, 0x0586,0x0181,
- 0x0586,0x028c, 0x0588,0x0007, 0x058e,0x0033, 0x058e,0x008f, 0x058e,0x01d0,
- 0x058e,0x027c, 0x0590,0x0003, 0x0596,0x0033, 0x0596,0x008f, 0x0596,0x0095,
- 0x0596,0x01d0, 0x0596,0x027c, 0x05a2,0x026f, 0x05a5,0x0284, 0x05aa,0x017b,
- 0x05ac,0x0205, 0x05b2,0x008f, 0x05b6,0x017b, 0x05b8,0x01da, 0x05c1,0x0276,
- 0x05c6,0x0248, 0x05c8,0x0247, 0x05c8,0x027e, 0x05cc,0x003d, 0x05cc,0x01d4,
- 0x05cc,0x01f3, 0x05d0,0x014e, 0x05d0,0x018d, 0x05da,0x00f9, 0x05dd,0x0006,
- 0x05de,0x0044, 0x05e5,0x002e, 0x05e6,0x02f1, 0x05ea,0x01d4, 0x05ea,0x01f3,
- 0x05ea,0x022d, 0x05ed,0x0002, 0x05f6,0x0027, 0x05fa,0x0097, 0x05fc,0x003d,
- 0x0602,0x003d, 0x0606,0x00f3, 0x060a,0x0027, 0x060e,0x003d, 0x060e,0x0103,
- 0x060e,0x018b, 0x060e,0x0231, 0x060e,0x02d1, 0x0611,0x01fc, 0x0611,0x0234,
- 0x061a,0x0287, 0x061d,0x0214, 0x0621,0x01d4, 0x062a,0x0027, 0x062a,0x022d,
- 0x062e,0x009e, 0x062e,0x0106, 0x062e,0x0198, 0x0632,0x009e, 0x0632,0x0106,
- 0x0632,0x0198, 0x0639,0x0042, 0x0639,0x00b2, 0x0639,0x0108, 0x063d,0x01f8,
- 0x0641,0x0086, 0x0641,0x009a, 0x0641,0x00ec, 0x0641,0x0172, 0x0645,0x0044,
- 0x0649,0x0042, 0x0648,0x0087, 0x0648,0x00ed, 0x0648,0x0173, 0x0649,0x01a0,
- 0x0648,0x0241, 0x0648,0x026f, 0x0648,0x02df, 0x0648,0x0307, 0x064c,0x023a,
- 0x064c,0x02b3, 0x0651,0x0062, 0x0650,0x0217, 0x0651,0x02ac, 0x0650,0x02d6,
- 0x0655,0x0042, 0x065d,0x0042, 0x0664,0x02b1, 0x0664,0x02ce, 0x0669,0x0238,
- 0x066d,0x002a, 0x066c,0x0039, 0x066d,0x01f6, 0x066c,0x0213, 0x066c,0x022e,
- 0x066d,0x02a2, 0x066c,0x02e1, 0x0671,0x002a, 0x0670,0x0030, 0x0670,0x0067,
- 0x0670,0x00c9, 0x0670,0x01eb, 0x0670,0x01ef, 0x0670,0x02c3, 0x0675,0x0020,
- 0x0678,0x0133, 0x0678,0x0148, 0x067c,0x0027, 0x0681,0x023a, 0x0684,0x0021,
- 0x0684,0x00bf, 0x0684,0x00d0, 0x0689,0x01fc, 0x068e,0x0162, 0x068e,0x0183,
- 0x0691,0x0200, 0x0696,0x0023, 0x0696,0x00e0, 0x0696,0x00fb, 0x0696,0x0268,
- 0x069a,0x0282, 0x069d,0x007e, 0x06a2,0x004b, 0x06a2,0x023e, 0x06a2,0x02dc,
- 0x06a6,0x0097, 0x06aa,0x02b1, 0x06aa,0x02ce, 0x06ae,0x0039, 0x06ae,0x0213,
- 0x06ae,0x022e, 0x06ae,0x02e1, 0x06b2,0x0162, 0x06b2,0x0183, 0x06b6,0x0023,
- 0x06b6,0x00e0, 0x06b6,0x00fb, 0x06ba,0x008f, 0x06ba,0x01e4, 0x06be,0x034b,
- 0x06c1,0x0086, 0x06c1,0x009a, 0x06c1,0x00ec, 0x06c1,0x0172, 0x06c6,0x01da,
- 0x06c6,0x0280, 0x06c6,0x0351, 0x06ce,0x008f, 0x06d2,0x01e3, 0x06d2,0x0287,
- 0x06d2,0x0353, 0x06d6,0x027a, 0x06d6,0x029b, 0x06da,0x0033, 0x06da,0x01ce,
- 0x06da,0x01f1, 0x06de,0x0133, 0x06de,0x0148, 0x06e2,0x0021, 0x06e2,0x00bf,
- 0x06e2,0x00d0, 0x06e5,0x023a, 0x06e9,0x0004, 0x06ee,0x028c, 0x06ee,0x0338,
- 0x06f2,0x0328, 0x06f2,0x0330, 0x06f4,0x0005, 0x06f9,0x01e0, 0x06fe,0x0328,
- 0x06fe,0x0330, 0x0702,0x003d, 0x0702,0x00f3, 0x0702,0x0330, 0x0704,0x0003,
- 0x070a,0x003d, 0x070a,0x00f3, 0x070a,0x01d4, 0x070a,0x01f3, 0x070a,0x0330,
- 0x0711,0x032a, 0x0711,0x032e, 0x0716,0x003d, 0x0718,0x0205, 0x0718,0x0282,
- 0x071e,0x00f3, 0x0720,0x01dc, 0x0720,0x02a5, 0x0726,0x0324, 0x072a,0x028a,
- 0x072a,0x02a7, 0x0729,0x031c, 0x0729,0x032a, 0x072e,0x003d, 0x072e,0x00f9,
- 0x072e,0x022d, 0x072e,0x0248, 0x072e,0x02e4, 0x0730,0x003d, 0x0730,0x0247,
- 0x0730,0x02e3, 0x0730,0x0324, 0x0732,0x0324, 0x0739,0x032e, 0x073e,0x003d,
- 0x0740,0x003d, 0x0744,0x027a, 0x0744,0x029b, 0x0748,0x0033, 0x0748,0x01ce,
- 0x0748,0x01f1, 0x074c,0x0162, 0x074c,0x0183, 0x0750,0x0023, 0x0750,0x00e0,
- 0x0750,0x00fb, 0x0755,0x0246, 0x075a,0x0095, 0x075a,0x0397, 0x075d,0x0004,
- 0x076a,0x03b3, 0x076d,0x0002, 0x0772,0x02fb, 0x0772,0x0301, 0x0772,0x0315,
- 0x0772,0x0397, 0x0776,0x008f, 0x077e,0x0027, 0x078a,0x00a1, 0x0792,0x009d,
- 0x0792,0x00c3, 0x0792,0x02fb, 0x0792,0x0301, 0x0792,0x0315, 0x0792,0x03bd,
- 0x0796,0x0027, 0x0796,0x024f, 0x079e,0x009d, 0x07a6,0x009d, 0x07a6,0x02fb,
- 0x07a6,0x0301, 0x07a6,0x0315, 0x07a6,0x03bd, 0x07aa,0x0027, 0x07aa,0x024f,
- 0x07ae,0x009d, 0x07b9,0x004e, 0x07b8,0x0087, 0x07b8,0x00ed, 0x07b8,0x0173,
- 0x07b8,0x0197, 0x07b9,0x021a, 0x07b9,0x02b8, 0x07b9,0x0364, 0x07be,0x0029,
- 0x07be,0x0030, 0x07c0,0x017b, 0x07c6,0x017b, 0x07c8,0x00f3, 0x07ce,0x00f3,
- 0x07d0,0x008f, 0x07d6,0x008f, 0x07d9,0x01e8, 0x07dd,0x0292, 0x07e2,0x0053,
- 0x07e6,0x008f, 0x07e6,0x00f3, 0x07e6,0x017b, 0x07e8,0x0029, 0x07e8,0x0030,
- 0x07ec,0x0021, 0x07ec,0x02ad, 0x07f2,0x0181, 0x07f2,0x0315, 0x07f4,0x0021,
- 0x07f8,0x020f, 0x07fd,0x002e, 0x0800,0x008f, 0x0805,0x0006, 0x0809,0x03c2,
- 0x080d,0x0084, 0x0812,0x0009, 0x0811,0x0008, 0x0812,0x00f3, 0x0812,0x00f9,
- 0x0812,0x017b, 0x0812,0x0181, 0x0814,0x0033, 0x0818,0x0023, 0x081c,0x0285,
- 0x0826,0x03bd, 0x082c,0x008f, 0x082c,0x017b, 0x0832,0x0043, 0x0832,0x011b,
- 0x0832,0x01b3, 0x0832,0x01c3, 0x0835,0x032a, 0x0838,0x0085, 0x0839,0x032a,
- 0x083e,0x0049, 0x083d,0x0084, 0x083e,0x02fb, 0x083e,0x0301, 0x083e,0x0315,
- 0x083e,0x0397, 0x0842,0x0009, 0x0841,0x0008, 0x0844,0x0009, 0x0846,0x008f,
- 0x084a,0x0033, 0x084e,0x0285, 0x0851,0x009a, 0x0856,0x00a1, 0x0859,0x031c,
- 0x085d,0x00b2, 0x0861,0x0012, 0x0861,0x02cc, 0x0865,0x0058, 0x0865,0x007e,
- 0x0869,0x004a, 0x0871,0x0010, 0x0876,0x003d, 0x0879,0x032c, 0x087e,0x0089,
- 0x0882,0x0229, 0x0882,0x022d, 0x0882,0x02c7, 0x0882,0x02cb, 0x0886,0x0021,
- 0x0886,0x02ad, 0x0885,0x0356, 0x088a,0x0017, 0x088a,0x020f, 0x0889,0x0354,
- 0x088d,0x009c, 0x0892,0x0089, 0x0895,0x0246, 0x089a,0x03bd, 0x089e,0x008f,
- 0x089e,0x02f9, 0x089e,0x0313, 0x08a1,0x032a, 0x08a6,0x0053, 0x08a6,0x0095,
- 0x08a6,0x0397, 0x08a8,0x017b, 0x08ad,0x031a, 0x08b2,0x017b, 0x08b4,0x00f3,
- 0x08b5,0x02a0, 0x08b8,0x0089, 0x08c1,0x0024, 0x08c4,0x00f3, 0x08c9,0x007e,
- 0x08cd,0x007c, 0x08cd,0x0222, 0x08cd,0x0294, 0x08d1,0x003a, 0x08d6,0x0009,
- 0x08d9,0x003a, 0x08dc,0x001f, 0x08e0,0x008f, 0x08e0,0x017b, 0x08e4,0x0009,
- 0x08e8,0x01ed, 0x08ed,0x031c, 0x08f2,0x003d, 0x08f6,0x008f, 0x08f6,0x017b,
- 0x08fa,0x0009, 0x08fe,0x003d, 0x0902,0x01e9, 0x0904,0x01e9, 0x0904,0x0381,
- 0x090a,0x03b1, 0x090d,0x031a, 0x0910,0x0299, 0x0914,0x034b, 0x0919,0x0008,
- 0x091c,0x0033, 0x091c,0x003d, 0x0920,0x0027, 0x0924,0x0027, 0x0924,0x01fb,
- 0x092a,0x01ce, 0x092a,0x01f1, 0x092d,0x031c, 0x0930,0x001f, 0x0936,0x00c5,
- 0x0938,0x00c5, 0x0938,0x0381, 0x093c,0x001b, 0x0942,0x017d, 0x094a,0x0027,
- 0x094e,0x0027, 0x094e,0x01fb, 0x0952,0x03b1, 0x095a,0x0029, 0x095a,0x0030,
- 0x095d,0x0030, 0x0961,0x0030, 0x0966,0x02f9, 0x0966,0x0313, 0x0968,0x02eb,
- 0x096d,0x0008, 0x0970,0x017b, 0x0974,0x0033, 0x0979,0x0150, 0x097d,0x009a,
- 0x0982,0x0293, 0x0984,0x0293, 0x0984,0x0379, 0x098a,0x02eb, 0x098e,0x0009,
- 0x0992,0x003d, 0x0996,0x003d, 0x0999,0x0062, 0x099e,0x003d, 0x09a0,0x0027,
- 0x09a5,0x0144, 0x09a8,0x02b5, 0x09ae,0x008f, 0x09ae,0x009d, 0x09b2,0x004d,
- 0x09b2,0x0053, 0x09b2,0x00c3, 0x09b2,0x013d, 0x09b2,0x01c5, 0x09b2,0x0271,
- 0x09b4,0x0025, 0x09ba,0x0033, 0x09ba,0x0079, 0x09bc,0x0015, 0x09c2,0x013f,
- 0x09c4,0x013f, 0x09c4,0x0379, 0x09ca,0x02b5, 0x09cd,0x0006, 0x09da,0x0009,
- 0x09d9,0x0008, 0x09dc,0x000b, 0x09dc,0x004f, 0x09dd,0x0086, 0x09e0,0x0009,
- 0x09e6,0x00a1, 0x09e8,0x0009, 0x09ed,0x0086, 0x09f2,0x001f, 0x09f2,0x002f,
- 0x09f2,0x0049, 0x09f2,0x006f, 0x09f2,0x0085, 0x09f2,0x0091, 0x09f2,0x00a9,
- 0x09f2,0x00d3, 0x09f2,0x00d7, 0x09f2,0x011d, 0x09f2,0x0121, 0x09f2,0x0235,
- 0x09f2,0x0393, 0x09f6,0x0324, 0x09f8,0x0049, 0x09f8,0x00a9, 0x09f8,0x011d,
- 0x09fe,0x001f, 0x09fe,0x0029, 0x09fe,0x0033, 0x09fe,0x003d, 0x09fe,0x0085,
- 0x09fe,0x008f, 0x09fe,0x00d3, 0x0a00,0x003d, 0x0a06,0x012d, 0x0a0e,0x00b3,
- 0x0a10,0x000b, 0x0a10,0x0387, 0x0a16,0x0059, 0x0a18,0x0009, 0x0a1e,0x0043,
- 0x0a24,0x0085, 0x0a2a,0x0009, 0x0a2d,0x0008, 0x0a32,0x028a, 0x0a32,0x02a7,
- 0x0a31,0x031c, 0x0a35,0x032e, 0x0a39,0x0006, 0x0a3a,0x0105, 0x0a3a,0x024f,
- 0x0a3c,0x0299, 0x0a42,0x01ed, 0x0a46,0x0299, 0x0a48,0x01ed, 0x0a4c,0x0059,
- 0x0a52,0x000b, 0x0a52,0x0387, 0x0a56,0x000b, 0x0a5e,0x0009, 0x0a60,0x003d,
- 0x0a66,0x0105, 0x0a6a,0x0195, 0x0a6c,0x000b, 0x0a76,0x0053, 0x0a78,0x0009,
- 0x0a7a,0x008f, 0x0a82,0x0299, 0x0a86,0x01ed, 0x0a8a,0x0027, 0x0a8e,0x004b,
- 0x0a92,0x003d, 0x0a95,0x0322, 0x0a99,0x0038, 0x0a99,0x0090, 0x0a9c,0x0061,
- 0x0a9c,0x00c7, 0x0a9c,0x012d, 0x0a9c,0x016f, 0x0a9c,0x017d, 0x0a9c,0x02c9,
- 0x0a9c,0x0383, 0x0aa1,0x0010, 0x0aa4,0x00b3, 0x0aa8,0x002f, 0x0aac,0x0027,
- 0x0ab0,0x004b, 0x0ab4,0x0043, 0x0ab9,0x0090, 0x0abd,0x0010, 0x0ac4,0x0019,
- 0x0acc,0x00f5, 0x0acc,0x022b, 0x0acc,0x037b, 0x0ad2,0x008f, 0x0ad2,0x01f1,
- 0x0ad6,0x0324, 0x0ad9,0x0330, 0x0ade,0x008f, 0x0ade,0x01f1, 0x0ae0,0x017b,
- 0x0ae4,0x008f, 0x0ae9,0x004e, 0x0aee,0x0027, 0x0af2,0x028a, 0x0af2,0x02a7,
- 0x0af1,0x031c, 0x0af6,0x0027, 0x0af9,0x031c, 0x0afe,0x00e9, 0x0afe,0x02bb,
- 0x0b02,0x000b, 0x0b06,0x00f5, 0x0b06,0x022b, 0x0b06,0x037b, 0x0b0a,0x003d,
- 0x0000,0x0000
-};
-
+ABC_NAMESPACE_IMPL_END
diff --git a/src/opt/sim/sim.h b/src/opt/sim/sim.h
index 89eaafac..e1a34273 100644
--- a/src/opt/sim/sim.h
+++ b/src/opt/sim/sim.h
@@ -21,6 +21,7 @@
#ifndef __SIM_H__
#define __SIM_H__
+
/*
The ideas realized in this package are described in the paper:
"Detecting Symmetries in Boolean Functions using Circuit Representation,
@@ -35,9 +36,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -197,15 +199,15 @@ extern void Sim_SymmsStructCompute( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMa
/*=== simSymSim.c ==========================================================*/
extern void Sim_SymmsSimulate( Sym_Man_t * p, unsigned * pPatRand, Vec_Ptr_t * vMatrsNonSym );
/*=== simUtil.c ==========================================================*/
-extern Vec_Ptr_t * Sim_UtilInfoAlloc( int nSize, int nWords, bool fClean );
+extern Vec_Ptr_t * Sim_UtilInfoAlloc( int nSize, int nWords, int fClean );
extern void Sim_UtilInfoFree( Vec_Ptr_t * p );
extern void Sim_UtilInfoAdd( unsigned * pInfo1, unsigned * pInfo2, int nWords );
extern void Sim_UtilInfoDetectDiffs( unsigned * pInfo1, unsigned * pInfo2, int nWords, Vec_Int_t * vDiffs );
extern void Sim_UtilInfoDetectNews( unsigned * pInfo1, unsigned * pInfo2, int nWords, Vec_Int_t * vDiffs );
extern void Sim_UtilInfoFlip( Sim_Man_t * p, Abc_Obj_t * pNode );
-extern bool Sim_UtilInfoCompare( Sim_Man_t * p, Abc_Obj_t * pNode );
-extern void Sim_UtilSimulate( Sim_Man_t * p, bool fFirst );
-extern void Sim_UtilSimulateNode( Sim_Man_t * p, Abc_Obj_t * pNode, bool fType, bool fType1, bool fType2 );
+extern int Sim_UtilInfoCompare( Sim_Man_t * p, Abc_Obj_t * pNode );
+extern void Sim_UtilSimulate( Sim_Man_t * p, int fFirst );
+extern void Sim_UtilSimulateNode( Sim_Man_t * p, Abc_Obj_t * pNode, int fType, int fType1, int fType2 );
extern void Sim_UtilSimulateNodeOne( Abc_Obj_t * pNode, Vec_Ptr_t * vSimInfo, int nSimWords, int nOffset );
extern void Sim_UtilTransferNodeOne( Abc_Obj_t * pNode, Vec_Ptr_t * vSimInfo, int nSimWords, int nOffset, int fShift );
extern int Sim_UtilCountSuppSizes( Sim_Man_t * p, int fStruct );
@@ -221,9 +223,11 @@ extern int Sim_UtilCountAllPairs( Vec_Ptr_t * vSuppFun, int nSimWord
extern void Sim_UtilCountPairsAll( Sym_Man_t * p );
extern int Sim_UtilMatrsAreDisjoint( Sym_Man_t * p );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/opt/sim/simMan.c b/src/opt/sim/simMan.c
index 6a86e25f..234aa412 100644
--- a/src/opt/sim/simMan.c
+++ b/src/opt/sim/simMan.c
@@ -21,6 +21,9 @@
#include "abc.h"
#include "sim.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -102,8 +105,8 @@ void Sym_ManStop( Sym_Man_t * p )
if ( p->vSupports ) Vec_VecFree( p->vSupports );
for ( i = 0; i < p->nOutputs; i++ )
{
- Extra_BitMatrixStop( p->vMatrSymms->pArray[i] );
- Extra_BitMatrixStop( p->vMatrNonSymms->pArray[i] );
+ Extra_BitMatrixStop( (Extra_BitMat_t *)p->vMatrSymms->pArray[i] );
+ Extra_BitMatrixStop( (Extra_BitMat_t *)p->vMatrNonSymms->pArray[i] );
}
Vec_IntFree( p->vVarsU );
Vec_IntFree( p->vVarsV );
@@ -286,3 +289,5 @@ void Sim_ManPatFree( Sim_Man_t * p, Sim_Pat_t * pPat )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/sim/simSat.c b/src/opt/sim/simSat.c
index d514f7f2..29fc6975 100644
--- a/src/opt/sim/simSat.c
+++ b/src/opt/sim/simSat.c
@@ -21,6 +21,9 @@
#include "abc.h"
#include "sim.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -46,3 +49,5 @@
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/sim/simSeq.c b/src/opt/sim/simSeq.c
index 49fb939f..db05226f 100644
--- a/src/opt/sim/simSeq.c
+++ b/src/opt/sim/simSeq.c
@@ -21,6 +21,9 @@
#include "abc.h"
#include "sim.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -169,3 +172,5 @@ void Sim_SimulateSeqFrame( Vec_Ptr_t * vInfo, Abc_Ntk_t * pNtk, int iFrames, int
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/sim/simSupp.c b/src/opt/sim/simSupp.c
index f84fedc4..563f98ac 100644
--- a/src/opt/sim/simSupp.c
+++ b/src/opt/sim/simSupp.c
@@ -22,12 +22,15 @@
#include "fraig.h"
#include "sim.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
-static int Sim_ComputeSuppRound( Sim_Man_t * p, bool fUseTargets );
-static int Sim_ComputeSuppRoundNode( Sim_Man_t * p, int iNumCi, bool fUseTargets );
+static int Sim_ComputeSuppRound( Sim_Man_t * p, int fUseTargets );
+static int Sim_ComputeSuppRoundNode( Sim_Man_t * p, int iNumCi, int fUseTargets );
static void Sim_ComputeSuppSetTargets( Sim_Man_t * p );
static void Sim_UtilAssignRandom( Sim_Man_t * p );
@@ -68,17 +71,17 @@ Vec_Ptr_t * Sim_ComputeStrSupp( Abc_Ntk_t * pNtk )
{
// if ( Abc_NodeIsConst(pNode) )
// continue;
- pSimmNode = vSuppStr->pArray[ pNode->Id ];
- pSimmNode1 = vSuppStr->pArray[ Abc_ObjFaninId0(pNode) ];
- pSimmNode2 = vSuppStr->pArray[ Abc_ObjFaninId1(pNode) ];
+ pSimmNode = (unsigned *)vSuppStr->pArray[ pNode->Id ];
+ pSimmNode1 = (unsigned *)vSuppStr->pArray[ Abc_ObjFaninId0(pNode) ];
+ pSimmNode2 = (unsigned *)vSuppStr->pArray[ Abc_ObjFaninId1(pNode) ];
for ( k = 0; k < nSuppWords; k++ )
pSimmNode[k] = pSimmNode1[k] | pSimmNode2[k];
}
// set the structural supports of the PO nodes
Abc_NtkForEachCo( pNtk, pNode, i )
{
- pSimmNode = vSuppStr->pArray[ pNode->Id ];
- pSimmNode1 = vSuppStr->pArray[ Abc_ObjFaninId0(pNode) ];
+ pSimmNode = (unsigned *)vSuppStr->pArray[ pNode->Id ];
+ pSimmNode1 = (unsigned *)vSuppStr->pArray[ Abc_ObjFaninId0(pNode) ];
for ( k = 0; k < nSuppWords; k++ )
pSimmNode[k] = pSimmNode1[k];
}
@@ -165,7 +168,7 @@ p->timeTotal = clock() - clk;
SeeAlso []
***********************************************************************/
-int Sim_ComputeSuppRound( Sim_Man_t * p, bool fUseTargets )
+int Sim_ComputeSuppRound( Sim_Man_t * p, int fUseTargets )
{
Vec_Int_t * vTargets;
int i, Counter = 0;
@@ -177,7 +180,7 @@ p->timeSim += clock() - clk;
// iterate through the CIs and detect COs that depend on them
for ( i = p->iInput; i < p->nInputs; i++ )
{
- vTargets = p->vSuppTargs->pArray[i];
+ vTargets = (Vec_Int_t *)p->vSuppTargs->pArray[i];
if ( fUseTargets && vTargets->nSize == 0 )
continue;
Counter += Sim_ComputeSuppRoundNode( p, i, fUseTargets );
@@ -196,7 +199,7 @@ p->timeSim += clock() - clk;
SeeAlso []
***********************************************************************/
-int Sim_ComputeSuppRoundNode( Sim_Man_t * p, int iNumCi, bool fUseTargets )
+int Sim_ComputeSuppRoundNode( Sim_Man_t * p, int iNumCi, int fUseTargets )
{
int fVerbose = 0;
Sim_Pat_t * pPat;
@@ -217,7 +220,7 @@ p->timeTrav += clock() - clk;
// complement the simulation info of the selected CI
Sim_UtilInfoFlip( p, pNodeCi );
// simulate the levelized structure of nodes
- Vec_VecForEachEntry( vNodesByLevel, pNode, i, k )
+ Vec_VecForEachEntry( Abc_Obj_t *, vNodesByLevel, pNode, i, k )
{
fType0 = Abc_NodeIsTravIdCurrent( Abc_ObjFanin0(pNode) );
fType1 = Abc_NodeIsTravIdCurrent( Abc_ObjFanin1(pNode) );
@@ -228,7 +231,7 @@ p->timeSim += clock() - clk;
// set the simulation info of the affected COs
if ( fUseTargets )
{
- vTargets = p->vSuppTargs->pArray[iNumCi];
+ vTargets = (Vec_Int_t *)p->vSuppTargs->pArray[iNumCi];
for ( i = vTargets->nSize - 1; i >= 0; i-- )
{
// get the target output
@@ -253,7 +256,7 @@ if ( fVerbose )
Sim_SuppFunSetVar( p->vSuppFun, Output, iNumCi );
// detect the differences in the simulation info
- Sim_UtilInfoDetectDiffs( p->vSim0->pArray[pNode->Id], p->vSim1->pArray[pNode->Id], p->nSimWords, p->vDiffs );
+ Sim_UtilInfoDetectDiffs( (unsigned *)p->vSim0->pArray[pNode->Id], (unsigned *)p->vSim1->pArray[pNode->Id], p->nSimWords, p->vDiffs );
// create new patterns
if ( !fFirst && p->vFifo->nSize > 1000 )
continue;
@@ -314,8 +317,8 @@ void Sim_ComputeSuppSetTargets( Sim_Man_t * p )
int i, k, Num;
Abc_NtkForEachCo( p->pNtk, pNode, i )
{
- pSuppStr = p->vSuppStr->pArray[pNode->Id];
- pSuppFun = p->vSuppFun->pArray[i];
+ pSuppStr = (unsigned *)p->vSuppStr->pArray[pNode->Id];
+ pSuppFun = (unsigned *)p->vSuppFun->pArray[i];
// find vars in the structural support that are not in the functional support
Sim_UtilInfoDetectNews( pSuppFun, pSuppStr, p->nSuppWords, p->vDiffs );
Vec_IntForEachEntry( p->vDiffs, Num, k )
@@ -342,7 +345,7 @@ void Sim_UtilAssignRandom( Sim_Man_t * p )
// assign the random/systematic simulation info to the PIs
Abc_NtkForEachCi( p->pNtk, pNode, i )
{
- pSimInfo = p->vSim0->pArray[pNode->Id];
+ pSimInfo = (unsigned *)p->vSim0->pArray[pNode->Id];
for ( k = 0; k < p->nSimWords; k++ )
pSimInfo[k] = SIM_RANDOM_UNSIGNED;
}
@@ -373,7 +376,7 @@ void Sim_UtilAssignFromFifo( Sim_Man_t * p )
{
++Counter;
// get the pattern
- pPat = Vec_PtrPop( p->vFifo );
+ pPat = (Sim_Pat_t *)Vec_PtrPop( p->vFifo );
if ( fUseOneWord )
{
// get the first word of the next series
@@ -385,7 +388,7 @@ void Sim_UtilAssignFromFifo( Sim_Man_t * p )
Abc_NtkForEachCi( p->pNtk, pNode, i )
{
pNode = Abc_NtkCi(p->pNtk,i);
- pSimInfo = p->vSim0->pArray[pNode->Id];
+ pSimInfo = (unsigned *)p->vSim0->pArray[pNode->Id];
if ( Sim_HasBit(pPat->pData, i) )
pSimInfo[iWord] = SIM_MASK_FULL;
else
@@ -405,7 +408,7 @@ void Sim_UtilAssignFromFifo( Sim_Man_t * p )
// set the pattern for all CIs from iWord to iWord + nWordsNew
Abc_NtkForEachCi( p->pNtk, pNode, i )
{
- pSimInfo = p->vSim0->pArray[pNode->Id];
+ pSimInfo = (unsigned *)p->vSim0->pArray[pNode->Id];
if ( Sim_HasBit(pPat->pData, i) )
{
for ( w = iWord; w < iWordLim; w++ )
@@ -457,7 +460,7 @@ void Sim_SolveTargetsUsingSat( Sim_Man_t * p, int Limit )
p->nSatRuns = 0;
// put targets into one array
- Vec_VecForEachEntryReverse( p->vSuppTargs, pEntry, Input, k )
+ Vec_VecForEachEntryReverse( void *, p->vSuppTargs, pEntry, Input, k )
{
p->nSatRuns++;
Output = (int)(ABC_PTRUINT_T)pEntry;
@@ -470,7 +473,7 @@ void Sim_SolveTargetsUsingSat( Sim_Man_t * p, int Limit )
Params.nSeconds = ABC_INFINITY;
Params.fInternal = 1;
clk = clock();
- pMan = Abc_NtkToFraig( pMiter, &Params, 0, 0 );
+ pMan = (Fraig_Man_t *)Abc_NtkToFraig( pMiter, &Params, 0, 0 );
p->timeFraig += clock() - clk;
clk = clock();
Fraig_ManProveMiter( pMan );
@@ -483,7 +486,7 @@ p->timeSat += clock() - clk;
{
p->nSatRunsUnsat++;
pModel = NULL;
- Vec_PtrRemove( p->vSuppTargs->pArray[Input], pEntry );
+ Vec_PtrRemove( (Vec_Ptr_t *)p->vSuppTargs->pArray[Input], pEntry );
}
else // sat
{
@@ -595,3 +598,5 @@ int Sim_SolveSuppModelVerify( Abc_Ntk_t * pNtk, int * pModel, int Input, int Out
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/sim/simSwitch.c b/src/opt/sim/simSwitch.c
index baabc320..4f675082 100644
--- a/src/opt/sim/simSwitch.c
+++ b/src/opt/sim/simSwitch.c
@@ -21,6 +21,9 @@
#include "abc.h"
#include "sim.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -64,15 +67,15 @@ Vec_Int_t * Sim_NtkComputeSwitching( Abc_Ntk_t * pNtk, int nPatterns )
pSwitching = (float *)vSwitching->pArray;
Abc_NtkForEachCi( pNtk, pNode, i )
{
- pSimInfo = Vec_PtrEntry(vSimInfo, pNode->Id);
+ pSimInfo = (unsigned *)Vec_PtrEntry(vSimInfo, pNode->Id);
Sim_UtilSetRandom( pSimInfo, nSimWords );
pSwitching[pNode->Id] = Sim_ComputeSwitching( pSimInfo, nSimWords );
}
// simulate the internal nodes
vNodes = Abc_AigDfs( pNtk, 1, 0 );
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
{
- pSimInfo = Vec_PtrEntry(vSimInfo, pNode->Id);
+ pSimInfo = (unsigned *)Vec_PtrEntry(vSimInfo, pNode->Id);
Sim_UtilSimulateNodeOne( pNode, vSimInfo, nSimWords, 0 );
pSwitching[pNode->Id] = Sim_ComputeSwitching( pSimInfo, nSimWords );
}
@@ -105,3 +108,5 @@ float Sim_ComputeSwitching( unsigned * pSimInfo, int nSimWords )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/sim/simSym.c b/src/opt/sim/simSym.c
index 71de5b05..d8a1eb4f 100644
--- a/src/opt/sim/simSym.c
+++ b/src/opt/sim/simSym.c
@@ -21,6 +21,9 @@
#include "abc.h"
#include "sim.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -140,3 +143,5 @@ p->timeTotal = clock() - clkTotal;
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/sim/simSymSat.c b/src/opt/sim/simSymSat.c
index 7690a891..4f6690e5 100644
--- a/src/opt/sim/simSymSat.c
+++ b/src/opt/sim/simSymSat.c
@@ -22,6 +22,9 @@
#include "sim.h"
#include "fraig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -55,11 +58,11 @@ int Sim_SymmsGetPatternUsingSat( Sym_Man_t * p, unsigned * pPattern )
// iterate through outputs
for ( out = p->iOutput; out < p->nOutputs; out++ )
{
- pMatSym = Vec_PtrEntry( p->vMatrSymms, out );
- pMatNonSym = Vec_PtrEntry( p->vMatrNonSymms, out );
+ pMatSym = (Extra_BitMat_t *)Vec_PtrEntry( p->vMatrSymms, out );
+ pMatNonSym = (Extra_BitMat_t *)Vec_PtrEntry( p->vMatrNonSymms, out );
// go through the remaining variable pairs
- vSupport = Vec_VecEntry( p->vSupports, out );
+ vSupport = (Vec_Int_t *)Vec_VecEntry( p->vSupports, out );
Vec_IntForEachEntry( vSupport, v, Index1 )
Vec_IntForEachEntryStart( vSupport, u, Index2, Index1+1 )
{
@@ -147,7 +150,7 @@ int Sim_SymmsSatProveOne( Sym_Man_t * p, int Out, int Var1, int Var2, unsigned *
Params.nSeconds = ABC_INFINITY;
clk = clock();
- pMan = Abc_NtkToFraig( pMiter, &Params, 0, 0 );
+ pMan = (Fraig_Man_t *)Abc_NtkToFraig( pMiter, &Params, 0, 0 );
p->timeFraig += clock() - clk;
clk = clock();
Fraig_ManProveMiter( pMan );
@@ -197,3 +200,5 @@ p->timeSat += clock() - clk;
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/sim/simSymSim.c b/src/opt/sim/simSymSim.c
index 2282825b..85ba56fb 100644
--- a/src/opt/sim/simSymSim.c
+++ b/src/opt/sim/simSymSim.c
@@ -21,6 +21,9 @@
#include "abc.h"
#include "sim.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -53,7 +56,7 @@ void Sim_SymmsSimulate( Sym_Man_t * p, unsigned * pPat, Vec_Ptr_t * vMatrsNonSym
Sim_SymmsCreateSquare( p, pPat );
// simulate each node in the DFS order
clk = clock();
- Vec_PtrForEachEntry( p->vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, p->vNodes, pNode, i )
{
// if ( Abc_NodeIsConst(pNode) )
// continue;
@@ -97,7 +100,7 @@ void Sim_SymmsCreateSquare( Sym_Man_t * p, unsigned * pPat )
// for each PI var copy the pattern
Abc_NtkForEachCi( p->pNtk, pNode, i )
{
- pSimInfo = Vec_PtrEntry( p->vSim, pNode->Id );
+ pSimInfo = (unsigned *)Vec_PtrEntry( p->vSim, pNode->Id );
if ( Sim_HasBit(pPat, i) )
{
for ( w = 0; w < p->nSimWords; w++ )
@@ -132,10 +135,10 @@ void Sim_SymmsDeriveInfo( Sym_Man_t * p, unsigned * pPat, Abc_Obj_t * pNode, Vec
unsigned * pSimInfo;
int i, w, Index;
// get the matrix, the support, and the simulation info
- pMat = Vec_PtrEntry( vMatrsNonSym, Output );
- vSupport = Vec_VecEntry( p->vSupports, Output );
- pSupport = Vec_PtrEntry( p->vSuppFun, Output );
- pSimInfo = Vec_PtrEntry( p->vSim, pNode->Id );
+ pMat = (Extra_BitMat_t *)Vec_PtrEntry( vMatrsNonSym, Output );
+ vSupport = (Vec_Int_t *)Vec_VecEntry( p->vSupports, Output );
+ pSupport = (unsigned *)Vec_PtrEntry( p->vSuppFun, Output );
+ pSimInfo = (unsigned *)Vec_PtrEntry( p->vSim, pNode->Id );
// generate vectors A1 and A2
for ( w = 0; w < p->nSimWords; w++ )
{
@@ -171,3 +174,5 @@ void Sim_SymmsDeriveInfo( Sym_Man_t * p, unsigned * pPat, Abc_Obj_t * pNode, Vec
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/sim/simSymStr.c b/src/opt/sim/simSymStr.c
index 9ff2f590..e9a25905 100644
--- a/src/opt/sim/simSymStr.c
+++ b/src/opt/sim/simSymStr.c
@@ -21,6 +21,9 @@
#include "abc.h"
#include "sim.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -72,7 +75,7 @@ void Sim_SymmsStructCompute( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMatrs, Vec_Ptr_t * v
pMap = Sim_SymmsCreateMap( pNtk );
// collect the nodes in the TFI cone of this output
vNodes = Abc_NtkDfs( pNtk, 0 );
- Vec_PtrForEachEntry( vNodes, pTemp, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pTemp, i )
{
// if ( Abc_NodeIsConst(pTemp) )
// continue;
@@ -85,14 +88,14 @@ void Sim_SymmsStructCompute( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMatrs, Vec_Ptr_t * v
pTemp = Abc_ObjFanin0(pTemp);
if ( Abc_ObjIsCi(pTemp) || Abc_AigNodeIsConst(pTemp) )
continue;
- Sim_SymmsTransferToMatrix( Vec_PtrEntry(vMatrs, i), SIM_READ_SYMMS(pTemp), Vec_PtrEntry(vSuppFun, i) );
+ Sim_SymmsTransferToMatrix( (Extra_BitMat_t *)Vec_PtrEntry(vMatrs, i), SIM_READ_SYMMS(pTemp), (unsigned *)Vec_PtrEntry(vSuppFun, i) );
}
// clean the intermediate results
Sim_UtilInfoFree( pNtk->vSupps );
pNtk->vSupps = NULL;
Abc_NtkForEachCi( pNtk, pTemp, i )
Vec_IntFree( SIM_READ_SYMMS(pTemp) );
- Vec_PtrForEachEntry( vNodes, pTemp, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pTemp, i )
// if ( !Abc_NodeIsConst(pTemp) )
Vec_IntFree( SIM_READ_SYMMS(pTemp) );
Vec_PtrFree( vNodes );
@@ -137,7 +140,7 @@ void Sim_SymmsStructComputeOne( Abc_Ntk_t * pNtk, Abc_Obj_t * pNode, int * pMap
// add symmetries from other inputs
for ( i = 0; i < vNodesOther->nSize; i++ )
{
- pTemp = Abc_ObjRegular(vNodesOther->pArray[i]);
+ pTemp = Abc_ObjRegular((Abc_Obj_t *)vNodesOther->pArray[i]);
Sim_SymmsAppendFromNode( pNtk, SIM_READ_SYMMS(pTemp), vNodesOther, vNodesPi0, vNodesPi1, vSymms, pMap );
}
Vec_PtrFree( vNodes );
@@ -196,7 +199,7 @@ void Sim_SymmsPartitionNodes( Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesPis0,
{
Abc_Obj_t * pNode;
int i;
- Vec_PtrForEachEntry( vNodes, pNode, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
{
if ( !Abc_ObjIsCi(Abc_ObjRegular(pNode)) )
Vec_PtrPush( vNodesOther, pNode );
@@ -232,8 +235,8 @@ void Sim_SymmsAppendFromGroup( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodesPi, Vec_Ptr_t
for ( k = i+1; k < vNodesPi->nSize; k++ )
{
// get the two PI nodes
- pNode1 = Abc_ObjRegular(vNodesPi->pArray[i]);
- pNode2 = Abc_ObjRegular(vNodesPi->pArray[k]);
+ pNode1 = Abc_ObjRegular((Abc_Obj_t *)vNodesPi->pArray[i]);
+ pNode2 = Abc_ObjRegular((Abc_Obj_t *)vNodesPi->pArray[k]);
assert( pMap[pNode1->Id] != pMap[pNode2->Id] );
assert( pMap[pNode1->Id] >= 0 );
assert( pMap[pNode2->Id] >= 0 );
@@ -310,7 +313,7 @@ int Sim_SymmsIsCompatibleWithNodes( Abc_Ntk_t * pNtk, unsigned uSymm, Vec_Ptr_t
// if they belong, but are not part of symmetry, quit
for ( i = 0; i < vNodesOther->nSize; i++ )
{
- pNode = Abc_ObjRegular(vNodesOther->pArray[i]);
+ pNode = Abc_ObjRegular((Abc_Obj_t *)vNodesOther->pArray[i]);
fIsVar1 = Sim_SuppStrHasVar( pNtk->vSupps, pNode, Ind1 );
fIsVar2 = Sim_SuppStrHasVar( pNtk->vSupps, pNode, Ind2 );
@@ -357,7 +360,7 @@ int Sim_SymmsIsCompatibleWithGroup( unsigned uSymm, Vec_Ptr_t * vNodesPi, int *
fHasVar1 = fHasVar2 = 0;
for ( i = 0; i < vNodesPi->nSize; i++ )
{
- pNode = Abc_ObjRegular(vNodesPi->pArray[i]);
+ pNode = Abc_ObjRegular((Abc_Obj_t *)vNodesPi->pArray[i]);
if ( pMap[pNode->Id] == Ind1 )
fHasVar1 = 1;
else if ( pMap[pNode->Id] == Ind2 )
@@ -486,3 +489,5 @@ int * Sim_SymmsCreateMap( Abc_Ntk_t * pNtk )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/sim/simUtils.c b/src/opt/sim/simUtils.c
index dba487d8..25d4cd44 100644
--- a/src/opt/sim/simUtils.c
+++ b/src/opt/sim/simUtils.c
@@ -21,6 +21,9 @@
#include "abc.h"
#include "sim.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -51,7 +54,7 @@ static int bit_count[256] = {
SeeAlso []
***********************************************************************/
-Vec_Ptr_t * Sim_UtilInfoAlloc( int nSize, int nWords, bool fClean )
+Vec_Ptr_t * Sim_UtilInfoAlloc( int nSize, int nWords, int fClean )
{
Vec_Ptr_t * vInfo;
int i;
@@ -162,8 +165,8 @@ void Sim_UtilInfoFlip( Sim_Man_t * p, Abc_Obj_t * pNode )
{
unsigned * pSimInfo1, * pSimInfo2;
int k;
- pSimInfo1 = p->vSim0->pArray[pNode->Id];
- pSimInfo2 = p->vSim1->pArray[pNode->Id];
+ pSimInfo1 = (unsigned *)p->vSim0->pArray[pNode->Id];
+ pSimInfo2 = (unsigned *)p->vSim1->pArray[pNode->Id];
for ( k = 0; k < p->nSimWords; k++ )
pSimInfo2[k] = ~pSimInfo1[k];
}
@@ -179,12 +182,12 @@ void Sim_UtilInfoFlip( Sim_Man_t * p, Abc_Obj_t * pNode )
SeeAlso []
***********************************************************************/
-bool Sim_UtilInfoCompare( Sim_Man_t * p, Abc_Obj_t * pNode )
+int Sim_UtilInfoCompare( Sim_Man_t * p, Abc_Obj_t * pNode )
{
unsigned * pSimInfo1, * pSimInfo2;
int k;
- pSimInfo1 = p->vSim0->pArray[pNode->Id];
- pSimInfo2 = p->vSim1->pArray[pNode->Id];
+ pSimInfo1 = (unsigned *)p->vSim0->pArray[pNode->Id];
+ pSimInfo2 = (unsigned *)p->vSim1->pArray[pNode->Id];
for ( k = 0; k < p->nSimWords; k++ )
if ( pSimInfo2[k] != pSimInfo1[k] )
return 0;
@@ -202,7 +205,7 @@ bool Sim_UtilInfoCompare( Sim_Man_t * p, Abc_Obj_t * pNode )
SeeAlso []
***********************************************************************/
-void Sim_UtilSimulate( Sim_Man_t * p, bool fType )
+void Sim_UtilSimulate( Sim_Man_t * p, int fType )
{
Abc_Obj_t * pNode;
int i;
@@ -225,7 +228,7 @@ void Sim_UtilSimulate( Sim_Man_t * p, bool fType )
SeeAlso []
***********************************************************************/
-void Sim_UtilSimulateNode( Sim_Man_t * p, Abc_Obj_t * pNode, bool fType, bool fType1, bool fType2 )
+void Sim_UtilSimulateNode( Sim_Man_t * p, Abc_Obj_t * pNode, int fType, int fType1, int fType2 )
{
unsigned * pSimmNode, * pSimmNode1, * pSimmNode2;
int k, fComp1, fComp2;
@@ -233,19 +236,19 @@ void Sim_UtilSimulateNode( Sim_Man_t * p, Abc_Obj_t * pNode, bool fType, bool fT
if ( Abc_ObjIsNode(pNode) )
{
if ( fType )
- pSimmNode = p->vSim1->pArray[ pNode->Id ];
+ pSimmNode = (unsigned *)p->vSim1->pArray[ pNode->Id ];
else
- pSimmNode = p->vSim0->pArray[ pNode->Id ];
+ pSimmNode = (unsigned *)p->vSim0->pArray[ pNode->Id ];
if ( fType1 )
- pSimmNode1 = p->vSim1->pArray[ Abc_ObjFaninId0(pNode) ];
+ pSimmNode1 = (unsigned *)p->vSim1->pArray[ Abc_ObjFaninId0(pNode) ];
else
- pSimmNode1 = p->vSim0->pArray[ Abc_ObjFaninId0(pNode) ];
+ pSimmNode1 = (unsigned *)p->vSim0->pArray[ Abc_ObjFaninId0(pNode) ];
if ( fType2 )
- pSimmNode2 = p->vSim1->pArray[ Abc_ObjFaninId1(pNode) ];
+ pSimmNode2 = (unsigned *)p->vSim1->pArray[ Abc_ObjFaninId1(pNode) ];
else
- pSimmNode2 = p->vSim0->pArray[ Abc_ObjFaninId1(pNode) ];
+ pSimmNode2 = (unsigned *)p->vSim0->pArray[ Abc_ObjFaninId1(pNode) ];
fComp1 = Abc_ObjFaninC0(pNode);
fComp2 = Abc_ObjFaninC1(pNode);
@@ -266,14 +269,14 @@ void Sim_UtilSimulateNode( Sim_Man_t * p, Abc_Obj_t * pNode, bool fType, bool fT
{
assert( Abc_ObjFaninNum(pNode) == 1 );
if ( fType )
- pSimmNode = p->vSim1->pArray[ pNode->Id ];
+ pSimmNode = (unsigned *)p->vSim1->pArray[ pNode->Id ];
else
- pSimmNode = p->vSim0->pArray[ pNode->Id ];
+ pSimmNode = (unsigned *)p->vSim0->pArray[ pNode->Id ];
if ( fType1 )
- pSimmNode1 = p->vSim1->pArray[ Abc_ObjFaninId0(pNode) ];
+ pSimmNode1 = (unsigned *)p->vSim1->pArray[ Abc_ObjFaninId0(pNode) ];
else
- pSimmNode1 = p->vSim0->pArray[ Abc_ObjFaninId0(pNode) ];
+ pSimmNode1 = (unsigned *)p->vSim0->pArray[ Abc_ObjFaninId0(pNode) ];
fComp1 = Abc_ObjFaninC0(pNode);
if ( fComp1 )
@@ -302,9 +305,9 @@ void Sim_UtilSimulateNodeOne( Abc_Obj_t * pNode, Vec_Ptr_t * vSimInfo, int nSimW
int k, fComp1, fComp2;
// simulate the internal nodes
assert( Abc_ObjIsNode(pNode) );
- pSimmNode = Vec_PtrEntry(vSimInfo, pNode->Id);
- pSimmNode1 = Vec_PtrEntry(vSimInfo, Abc_ObjFaninId0(pNode));
- pSimmNode2 = Vec_PtrEntry(vSimInfo, Abc_ObjFaninId1(pNode));
+ pSimmNode = (unsigned *)Vec_PtrEntry(vSimInfo, pNode->Id);
+ pSimmNode1 = (unsigned *)Vec_PtrEntry(vSimInfo, Abc_ObjFaninId0(pNode));
+ pSimmNode2 = (unsigned *)Vec_PtrEntry(vSimInfo, Abc_ObjFaninId1(pNode));
pSimmNode += nOffset;
pSimmNode1 += nOffset;
pSimmNode2 += nOffset;
@@ -341,8 +344,8 @@ void Sim_UtilTransferNodeOne( Abc_Obj_t * pNode, Vec_Ptr_t * vSimInfo, int nSimW
int k, fComp1;
// simulate the internal nodes
assert( Abc_ObjIsCo(pNode) );
- pSimmNode = Vec_PtrEntry(vSimInfo, pNode->Id);
- pSimmNode1 = Vec_PtrEntry(vSimInfo, Abc_ObjFaninId0(pNode));
+ pSimmNode = (unsigned *)Vec_PtrEntry(vSimInfo, pNode->Id);
+ pSimmNode1 = (unsigned *)Vec_PtrEntry(vSimInfo, Abc_ObjFaninId0(pNode));
pSimmNode += nOffset + (fShift > 0)*nSimWords;
pSimmNode1 += nOffset;
fComp1 = Abc_ObjFaninC0(pNode);
@@ -425,7 +428,7 @@ Vec_Int_t * Sim_UtilCountOnesArray( Vec_Ptr_t * vInfo, int nSimWords )
unsigned * pSimInfo;
int i;
vCounters = Vec_IntStart( Vec_PtrSize(vInfo) );
- Vec_PtrForEachEntry( vInfo, pSimInfo, i )
+ Vec_PtrForEachEntry( unsigned *, vInfo, pSimInfo, i )
Vec_IntWriteEntry( vCounters, i, Sim_UtilCountOnes(pSimInfo, nSimWords) );
return vCounters;
}
@@ -562,7 +565,7 @@ int Sim_UtilCountAllPairs( Vec_Ptr_t * vSuppFun, int nSimWords, Vec_Int_t * vCou
unsigned * pSupp;
int Counter, nOnes, nPairs, i;
Counter = 0;
- Vec_PtrForEachEntry( vSuppFun, pSupp, i )
+ Vec_PtrForEachEntry( unsigned *, vSuppFun, pSupp, i )
{
nOnes = Sim_UtilCountOnes( pSupp, nSimWords );
nPairs = nOnes * (nOnes - 1) / 2;
@@ -635,7 +638,7 @@ clk = clock();
for ( i = 0; i < p->nOutputs; i++ )
{
printf( "Output %2d :", i );
- Sim_UtilCountPairsOnePrint( Vec_PtrEntry(p->vMatrSymms, i), Vec_VecEntry(p->vSupports, i) );
+ Sim_UtilCountPairsOnePrint( (Extra_BitMat_t *)Vec_PtrEntry(p->vMatrSymms, i), (Vec_Int_t *)Vec_VecEntry(p->vSupports, i) );
printf( "\n" );
}
p->timeCount += clock() - clk;
@@ -670,8 +673,8 @@ clk = clock();
p->nPairsNonSymm += nPairsNonSym;
continue;
}
- nPairsSym = Sim_UtilCountPairsOne( Vec_PtrEntry(p->vMatrSymms, i), Vec_VecEntry(p->vSupports, i) );
- nPairsNonSym = Sim_UtilCountPairsOne( Vec_PtrEntry(p->vMatrNonSymms,i), Vec_VecEntry(p->vSupports, i) );
+ nPairsSym = Sim_UtilCountPairsOne( (Extra_BitMat_t *)Vec_PtrEntry(p->vMatrSymms, i), (Vec_Int_t *)Vec_VecEntry(p->vSupports, i) );
+ nPairsNonSym = Sim_UtilCountPairsOne( (Extra_BitMat_t *)Vec_PtrEntry(p->vMatrNonSymms,i), (Vec_Int_t *)Vec_VecEntry(p->vSupports, i) );
assert( nPairsTotal >= nPairsSym + nPairsNonSym );
Vec_IntWriteEntry( p->vPairsSym, i, nPairsSym );
Vec_IntWriteEntry( p->vPairsNonSym, i, nPairsNonSym );
@@ -699,7 +702,7 @@ int Sim_UtilMatrsAreDisjoint( Sym_Man_t * p )
{
int i;
for ( i = 0; i < p->nOutputs; i++ )
- if ( !Extra_BitMatrixIsDisjoint( Vec_PtrEntry(p->vMatrSymms,i), Vec_PtrEntry(p->vMatrNonSymms,i) ) )
+ if ( !Extra_BitMatrixIsDisjoint( (Extra_BitMat_t *)Vec_PtrEntry(p->vMatrSymms,i), (Extra_BitMat_t *)Vec_PtrEntry(p->vMatrNonSymms,i) ) )
return 0;
return 1;
}
@@ -709,3 +712,5 @@ int Sim_UtilMatrsAreDisjoint( Sym_Man_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/phys/place/libhmetis.h b/src/phys/place/libhmetis.h
index 051079d4..277299b8 100644
--- a/src/phys/place/libhmetis.h
+++ b/src/phys/place/libhmetis.h
@@ -3,6 +3,10 @@
#ifndef LIBHMETIS_H_
#define LIBHMETIS_H_
+
+ABC_NAMESPACE_HEADER_START
+
+
static void HMETIS_PartRecursive(int nvtxs,
int nhedges,
int *vwgts,
@@ -28,4 +32,8 @@ static void HMETIS_PartKway(int nvtxs,
int *part,
int *edgecnt ) {} //;
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif
diff --git a/src/phys/place/place_base.c b/src/phys/place/place_base.c
index 4e38f1d1..ef5aca56 100644
--- a/src/phys/place/place_base.c
+++ b/src/phys/place/place_base.c
@@ -15,6 +15,9 @@
#include "place_base.h"
#include "place_gordian.h"
+ABC_NAMESPACE_IMPL_START
+
+
// --------------------------------------------------------------------
// Global variables
//
@@ -343,3 +346,5 @@ int cellSortByID(const void *a, const void *b) {
if (pa->m_id > pb->m_id) return 1;
return 0;
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/phys/place/place_base.h b/src/phys/place/place_base.h
index e5e7ecef..ed15ef22 100644
--- a/src/phys/place/place_base.h
+++ b/src/phys/place/place_base.h
@@ -10,6 +10,10 @@
#if !defined(PLACE_BASE_H_)
#define PLACE_BASE_H_
+
+ABC_NAMESPACE_HEADER_START
+
+
// --------------------------------------------------------------------
// Data structures
//
@@ -134,4 +138,8 @@ int cellSortByX(const void *a, const void *b);
int cellSortByY(const void *a, const void *b);
int cellSortByID(const void *a, const void *b);
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif
diff --git a/src/phys/place/place_bin.c b/src/phys/place/place_bin.c
index 86ec3506..92b283cc 100644
--- a/src/phys/place/place_bin.c
+++ b/src/phys/place/place_bin.c
@@ -17,6 +17,9 @@
#include "place_base.h"
+ABC_NAMESPACE_IMPL_START
+
+
// --------------------------------------------------------------------
// Global variables
//
@@ -275,3 +278,5 @@ void spreadDensityY(int numBins, float maxMovement) {
free(binCells);
free(allCells);
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/phys/place/place_genqp.c b/src/phys/place/place_genqp.c
index 5b6c7027..3418ffcf 100644
--- a/src/phys/place/place_genqp.c
+++ b/src/phys/place/place_genqp.c
@@ -17,6 +17,9 @@
#include "place_qpsolver.h"
#include "place_gordian.h"
+ABC_NAMESPACE_IMPL_START
+
+
// --------------------------------------------------------------------
// Global variables
//
@@ -181,7 +184,7 @@ typedef struct reverseCOG {
//
// --------------------------------------------------------------------
int generateCoGConstraints(reverseCOG COG_rev[]) {
- int numConstraints = 0; // actual num contraints
+ int numConstraints = 0; // actual num constraints
int cogRevNum = 0;
Partition **stack = malloc(sizeof(Partition*)*g_place_numPartitions*2);
int stackPtr = 0;
@@ -307,3 +310,5 @@ void solveQuadraticProblem(bool useCOG) {
free(COG_rev);
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/phys/place/place_gordian.c b/src/phys/place/place_gordian.c
index 2929bf95..0fd27e46 100644
--- a/src/phys/place/place_gordian.c
+++ b/src/phys/place/place_gordian.c
@@ -16,6 +16,9 @@
#include "place_gordian.h"
#include "place_base.h"
+ABC_NAMESPACE_IMPL_START
+
+
// --------------------------------------------------------------------
// Global variables
@@ -158,3 +161,5 @@ void sanitizePlacement() {
cell->m_y = y;
}
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/phys/place/place_gordian.h b/src/phys/place/place_gordian.h
index 67eb1479..6be6d907 100644
--- a/src/phys/place/place_gordian.h
+++ b/src/phys/place/place_gordian.h
@@ -10,9 +10,13 @@
#if !defined(PLACE_GORDIAN_H_)
#define PLACE_GORDIAN_H_
+
#include "place_base.h"
#include "place_qpsolver.h"
+ABC_NAMESPACE_HEADER_START
+
+
// Parameters for analytic placement
#define CLIQUE_PENALTY 1.0
#define IGNORE_NETSIZE 20
@@ -75,4 +79,8 @@ void sanitizePlacement();
void constructQuadraticProblem();
void solveQuadraticProblem(bool useCOG);
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif
diff --git a/src/phys/place/place_inc.c b/src/phys/place/place_inc.c
index 7e2d847c..70eacbe9 100644
--- a/src/phys/place/place_inc.c
+++ b/src/phys/place/place_inc.c
@@ -15,6 +15,9 @@
#include "place_base.h"
#include "place_gordian.h"
+ABC_NAMESPACE_IMPL_START
+
+
inline int sqHashId(int id, int max) {
return ((id * (id+17)) % max);
}
@@ -104,3 +107,5 @@ float fastEstimate(ConcreteCell *cell,
return len;
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/phys/place/place_io.c b/src/phys/place/place_io.c
index 8e24ef4a..16ad5339 100644
--- a/src/phys/place/place_io.c
+++ b/src/phys/place/place_io.c
@@ -15,6 +15,9 @@
#include "place_base.h"
+ABC_NAMESPACE_IMPL_START
+
+
// --------------------------------------------------------------------
// writeBookshelfNodes()
@@ -92,3 +95,5 @@ void writeBookshelf(const char *filename) {
writeBookshelfNodes("out.nodes");
writeBookshelfPl("out.pl");
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/phys/place/place_legalize.c b/src/phys/place/place_legalize.c
index 950902f4..4b1e28ea 100644
--- a/src/phys/place/place_legalize.c
+++ b/src/phys/place/place_legalize.c
@@ -12,6 +12,9 @@
#include "place_base.h"
+ABC_NAMESPACE_IMPL_START
+
+
// --------------------------------------------------------------------
// legalize()
@@ -21,3 +24,5 @@ void legalize() {
// UNIMPLEMENTED
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/phys/place/place_pads.c b/src/phys/place/place_pads.c
index 361fac7f..bf0922e7 100644
--- a/src/phys/place/place_pads.c
+++ b/src/phys/place/place_pads.c
@@ -14,6 +14,9 @@
#include "place_base.h"
+ABC_NAMESPACE_IMPL_START
+
+
// --------------------------------------------------------------------
// globalPreplace()
//
@@ -139,3 +142,5 @@ void globalPreplace(float utilization) {
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/phys/place/place_partition.c b/src/phys/place/place_partition.c
index ea57cd1c..eeef7037 100644
--- a/src/phys/place/place_partition.c
+++ b/src/phys/place/place_partition.c
@@ -21,6 +21,9 @@
#if !defined(NO_HMETIS)
#include "libhmetis.h"
+
+ABC_NAMESPACE_IMPL_START
+
#endif
// --------------------------------------------------------------------
@@ -1133,3 +1136,5 @@ void incrementalPartition() {
free(allCells);
free(newCells);
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/phys/place/place_qpsolver.c b/src/phys/place/place_qpsolver.c
index 9df9c6dc..29e41bd4 100644
--- a/src/phys/place/place_qpsolver.c
+++ b/src/phys/place/place_qpsolver.c
@@ -14,6 +14,9 @@
#include "place_qpsolver.h"
+ABC_NAMESPACE_IMPL_START
+
+
#undef QPS_DEBUG
#define QPS_TOL 1.0e-3
@@ -1268,3 +1271,5 @@ qps_clean(qps_problem_t * p)
}
/**********************************************************************/
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/phys/place/place_qpsolver.h b/src/phys/place/place_qpsolver.h
index 08771d6b..f859a6ff 100644
--- a/src/phys/place/place_qpsolver.h
+++ b/src/phys/place/place_qpsolver.h
@@ -10,8 +10,12 @@
#if !defined(_QPS_H)
#define _QPS_H
+
#include <stdio.h>
+ABC_NAMESPACE_HEADER_START
+
+
#if defined(__cplusplus)
extern "C" {
#endif /* __cplusplus */
@@ -137,4 +141,8 @@ extern "C" {
#if defined(__cplusplus)
}
#endif /* __cplusplus */
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif /* _QPS_H */
diff --git a/src/phys/place/place_test.c b/src/phys/place/place_test.c
index ea706a09..93f762f8 100644
--- a/src/phys/place/place_test.c
+++ b/src/phys/place/place_test.c
@@ -13,6 +13,9 @@
#include <assert.h>
#include "place_base.h"
+ABC_NAMESPACE_IMPL_START
+
+
// --------------------------------------------------------------------
// Hash type/functions
@@ -358,3 +361,5 @@ int main(int argc, char **argv) {
return 0;
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/python/abc.sh b/src/python/abc.sh
new file mode 100644
index 00000000..688cf567
--- /dev/null
+++ b/src/python/abc.sh
@@ -0,0 +1,78 @@
+#!/bin/sh
+#
+# Setup the ABC/Py environment and run the ABC/Py executable
+# (ABC/Py stands for ABC with embedded Python)
+#
+# ABC/Py expects the following directory structure
+#
+# abc_root/
+# bin/
+# abc - this script
+# abc_exe - the ABC executable
+# ... - Other scripts
+# lib/
+# pyabc.py - support file for pyabc extension
+# python_library.zip - The Python standard library. Only if not using the system Python interpreter.
+# *.so - Python extensions, Only if not using the system Python interpreter.
+# scripts/
+# *.py - default directory for python scripts
+#
+
+# usage: abspath <dir>
+# get the absolute path of <dir>
+abspath()
+{
+ cwd="$(pwd)"
+ cd "$1"
+ echo "$(pwd)"
+ cd "${cwd}"
+}
+
+self=$0
+
+self_dir=$(dirname "${self}")
+self_dir=$(abspath "${self_dir}")
+
+abc_root=$(dirname "${self_dir}")
+
+abc_exe="${abc_root}/bin/abc_exe"
+
+PYTHONPATH="${abc_root}/lib":"${PYTHONPATH}"
+export PYTHONPATH
+
+if [ -d "${abc_root}/scripts" ] ; then
+ ABC_PYTHON_SCRIPTS="${abc_root}/scripts"
+ export ABC_PYTHON_SCRIPTS
+
+ PYTHONPATH="${ABC_PYTHON_SCRIPTS}":"${PYTHONPATH}"
+ export PYTHONPATH
+fi
+
+if [ -f "${abc_root}/scripts/abc.rc" ] ; then
+ ABC_PYTHON_ABC_RC="${abc_root}/scripts/abc.rc"
+ export ABC_PYTHON_ABC_RC
+fi
+
+if [ -f "${abc_root}/lib/python_library.zip" ] ; then
+ PYTHONHOME="${abc_root}"
+ export PYTHONHOME
+
+ PYTHONPATH="${abc_root}/lib/python_library.zip":"${PYTHONPATH}"
+ export PYTHONPATH
+fi
+
+PATH="${abc_root}/bin:$PATH"
+export PATH
+
+if [ "$1" = "--debug" ]; then
+ shift
+ abc_debugger="$1"
+ shift
+
+ echo export PYTHONHOME=$PYTHONHOME
+ echo export PYTHONPATH=$PYTHONPATH
+ echo export ABC_PYTHON_SCRIPTS=$ABC_PYTHON_SCRIPTS
+ echo export ABC_PYTHON_ABC_RC=$ABC_PYTHON_ABC_RC
+fi
+
+exec ${abc_debugger} "${abc_exe}" "$@"
diff --git a/src/python/abcpy_test.py b/src/python/abcpy_test.py
new file mode 100644
index 00000000..912cae9f
--- /dev/null
+++ b/src/python/abcpy_test.py
@@ -0,0 +1,54 @@
+# You can use 'from pyabc import *' and then not need the pyabc. prefix everywhere
+import pyabc
+
+# A new command is just a function that accepts a list of string arguments
+# The first argument is always the name of the command
+# It MUST return an integer. -1: user quits, -2: error. Return 0 for success.
+
+# a simple command that just prints its arguments and returns success
+def pytest1_cmd(args):
+ print args
+ return 0
+
+# registers the command:
+# The first argument is the function
+# The second argument is the category (mainly for the ABC help command)
+# The third argument is the new command name
+# Keet the fourth argument 0, or consult with Alan
+pyabc.add_abc_command(pytest1_cmd, "Python-Test", "pytest1", 0)
+
+# a simple command that just prints its arguments and runs the command 'scorr -h'
+def pytest2_cmd(args):
+ print args
+ pyabc.run_command('scorr -h')
+ return 0
+
+pyabc.add_abc_command(pytest2_cmd, "Python-Test", "pytest2", 0)
+
+# Now a more complicated command with argument parsing
+# This command gets two command line arguments -c and -v. -c cmd runs the command 'cmd -h' and -v prints the python version
+# for more details see the optparse module: http://docs.python.org/library/optparse.html
+
+import optparse
+
+def pytest3_cmd(args):
+ usage = "usage: %prog [options]"
+
+ parser = optparse.OptionParser(usage)
+
+ parser.add_option("-c", "--cmd", dest="cmd", help="command to ask help for")
+ parser.add_option("-v", "--version", action="store_true", dest="version", help="display Python Version")
+
+ options, args = parser.parse_args(args)
+
+ if options.version:
+ print sys.version
+ return 0
+
+ if options.cmd:
+ pyabc.run_command("%s -h"%options.cmd)
+ return 0
+
+ return 0
+
+pyabc.add_abc_command(pytest3_cmd, "Python-Test", "pytest3", 0)
diff --git a/src/python/build.txt b/src/python/build.txt
new file mode 100644
index 00000000..60a3a9ba
--- /dev/null
+++ b/src/python/build.txt
@@ -0,0 +1,32 @@
+On Windows:
+
+python setup.py build
+python setup.py bdist_wininst
+
+On Linux (from the main abc directory)
+
+To build the extensions (make sure -fPIC is added to OPTFLAG in the main ABC Makefile first)
+
+make ABC_PYTHON=/usr/bin/python pyabc_extension_install
+
+To build the ABC with embedded python
+
+make pyabc.tgz
+
+
+
+
+Updating the latest version on mima:
+
+alanmi@mima:~/abc_60$ cp ./src/python/build/lib.linux-x86_64-2.6/_pyabc.so /hd/common/pyabc/builds/101030/_pyabc.so
+alanmi@mima:~/abc_60$ cp ./src/python/build/lib.linux-x86_64-2.6/pyabc.py /hd/common/pyabc/builds/101030/pyabc.py
+
+alanmi@mima:/hd/common/pyabc$ rm current
+alanmi@mima:/hd/common/pyabc$ ln -s builds/101030 current
+alanmi@mima:/hd/common/pyabc$ ls -l
+total 4
+lrwxrwxrwx 1 alanmi common 13 2010-10-30 14:55 current -> builds/101030
+
+
+Latest documentation:
+http://goo.gl/jNV2 \ No newline at end of file
diff --git a/src/python/module.make b/src/python/module.make
new file mode 100644
index 00000000..ac56208d
--- /dev/null
+++ b/src/python/module.make
@@ -0,0 +1,64 @@
+# To compile with the embedded python interpreter set
+# the variable ABC_PYTHON to point to the python executable
+#
+# Examples:
+# make ABC_PYTHON=/usr/bin/python
+# make ABC_PYTHON=/usr/bin/python2.5
+#
+# To build the Python extension build the target pyabc
+# To create a package of ABC with embedded Python use the target pyabc.tgz
+
+ifdef ABC_PYTHON
+
+ # get the directory containing this file
+ ABC_PYTHON_FILES_PREFIX := $(CURDIR)/src/python
+
+ ABC_SWIG := swig
+ ABC_PYTHON_CONFIG := $(ABC_PYTHON)-config
+ ABC_PYTHON_CFLAGS := $(shell $(ABC_PYTHON_CONFIG) --includes) -DABC_PYTHON_EMBED=1
+ ABC_PYTHON_LDFLAGS := $(shell $(ABC_PYTHON_CONFIG) --ldflags)
+
+ CFLAGS += $(ABC_PYTHON_CFLAGS)
+ CXXFLAGS += $(ABC_PYTHON_CFLAGS)
+ LIBS += $(ABC_PYTHON_LDFLAGS)
+
+ ABC_PYTHON_SRC := $(ABC_PYTHON_FILES_PREFIX)/pyabc_wrap.c
+
+ SRC += $(ABC_PYTHON_SRC)
+
+ GARBAGE += \
+ $(ABC_PYTHON_SRC) \
+ $(ABC_PYTHON_SRC:_wrap.c=.py) \
+ $(ABC_PYTHON_SRC:_wrap.c=.pyc) \
+ $(ABC_PYTHON_FILES_PREFIX)/build \
+ $(ABC_PYTHON_FILES_PREFIX)/dist \
+ pyabc.tgz
+
+%_wrap.c %.py : %.i
+ $(ABC_SWIG) -python -outdir $(<D) $<
+
+.PHONY: pyabc_extension_build
+
+pyabc_extension_build : lib$(PROG).a $(ABC_PYTHON_SRC) $(ABC_PYTHON_SRC:_wrap.c=.py)
+ ( cd $(ABC_PYTHON_FILES_PREFIX) && rm -rf build/ )
+ ( cd $(ABC_PYTHON_FILES_PREFIX) && $(ABC_PYTHON) setup.py build )
+
+.PHONY: pyabc_extension_install
+
+pyabc_extension_install : pyabc_extension_build
+ ( cd $(ABC_PYTHON_FILES_PREFIX) && $(ABC_PYTHON) setup.py install --user )
+
+.PHONY: pyabc_extension_bdist
+
+pyabc_extension_bdist : pyabc_extension_build
+ ( cd $(ABC_PYTHON_FILES_PREFIX) && python setup.py bdist )
+
+pyabc.tgz : $(PROG) $(ABC_PYTHON_SRC:_wrap.c=.py) $(ABC_PYTHON_FILES_PREFIX)/abc.sh $(ABC_PYTHON_FILES_PREFIX)/package.py
+ $(ABC_PYTHON) $(ABC_PYTHON_FILES_PREFIX)/package.py \
+ --abc=$(PROG) \
+ --abc_sh=$(ABC_PYTHON_FILES_PREFIX)/abc.sh \
+ --pyabc=$(ABC_PYTHON_SRC:_wrap.c=.py) \
+ --out=$@ \
+ $(ABC_PYTHON_OPTIONS)
+
+endif
diff --git a/src/python/package.py b/src/python/package.py
new file mode 100644
index 00000000..9c79a944
--- /dev/null
+++ b/src/python/package.py
@@ -0,0 +1,124 @@
+import os
+import sys
+import optparse
+import zipfile
+import tarfile
+import tempfile
+import time
+
+def zip_library(f, extra_files = []):
+ lib = "%s/lib/python%s/"%(sys.prefix,sys.version[:3])
+
+ zf = zipfile.ZipFile(f, "w", zipfile.ZIP_DEFLATED)
+
+ for root, _, files in os.walk(lib):
+ arcroot = os.path.relpath(root, lib)
+ for f in files:
+ _, ext = os.path.splitext(f)
+ if ext in ['.py', '.pyo', '.pyc']:
+ zf.write(os.path.join(root,f), os.path.join(arcroot, f))
+
+ for s, r in extra_files:
+ zf.write( s, r )
+
+ zf.close()
+
+def add_dir(tf, dir, mtime):
+ ti = tarfile.TarInfo(dir)
+ ti.mode = 0777
+ ti.mtime = mtime
+ ti.type = tarfile.DIRTYPE
+
+ tf.addfile(ti)
+
+def add_fileobj(tf, f, arcname, mode, mtime):
+ ti = tarfile.TarInfo(arcname)
+ ti.mode = mode
+ ti.mtime = mtime
+
+ f.seek(0, os.SEEK_END)
+ ti.size = f.tell()
+
+ f.seek(0, os.SEEK_SET)
+ tf.addfile(ti, f)
+
+def add_file(tf, fname, arcname, mode, mtime):
+ f = open(fname, "rb")
+ add_fileobj(tf, f, arcname, mode, mtime)
+ f.close()
+
+def package(abc_exe, abc_sh, pyabc, ofname, scripts_dir, use_sys):
+ mtime = time.time()
+
+ tf = tarfile.open(ofname, "w:gz")
+
+ add_dir(tf, "pyabc", mtime)
+
+ add_dir(tf, "pyabc/bin", mtime)
+
+ add_file(tf, abc_exe, "pyabc/bin/abc_exe", 0777, mtime)
+ add_file(tf, abc_sh, "pyabc/bin/abc", 0777, mtime)
+
+ if scripts_dir:
+ for fn in os.listdir(scripts_dir):
+ fullname = os.path.join(scripts_dir, fn)
+ if os.path.isfile(fullname):
+ fnroot, fnext = os.path.splitext(fn)
+ if fnext==".sh":
+ add_file( tf, fullname, os.path.join("pyabc/bin", fnroot), 0777, mtime)
+ else:
+ add_file( tf, fullname, os.path.join("pyabc/scripts", fn), 0666, mtime)
+
+ add_dir(tf, "pyabc/lib", mtime)
+ add_file( tf, pyabc, "pyabc/lib/pyabc.py", 0666, mtime)
+
+ if not use_sys:
+ # ZIP standard library
+ zf = tempfile.NamedTemporaryFile("w+b")
+ #zip_library(zf, [(pyabc, "pyabc.py")])
+ zip_library(zf, [])
+ zf.flush()
+
+ add_fileobj(tf, zf, "pyabc/lib/python_library.zip", 0666, mtime)
+
+ zf.close()
+
+ # add all extensions
+
+ lib_dynload = os.path.join(sys.exec_prefix,"lib", "python%s"%sys.version[:3], "lib-dynload")
+
+ for fn in os.listdir(lib_dynload):
+ fullname = os.path.join(lib_dynload, fn)
+ if os.path.isfile(fullname):
+ add_file( tf, fullname, os.path.join("pyabc/lib", fn), 0666, mtime)
+
+ tf.close()
+
+
+def main(args):
+
+ usage = "usage: %prog [options]"
+
+ parser = optparse.OptionParser(usage)
+
+ parser.add_option("-a", "--abc", dest="abc", help="location of the ABC exeutable")
+ parser.add_option("-s", "--abc_sh", dest="abc_sh", help="location of the ABC setup script")
+ parser.add_option("-p", "--pyabc", dest="pyabc", help="location of pyabc.py")
+ parser.add_option("-o", "--out", dest="out", help="location of output tar gzipped file")
+ parser.add_option("-x", "--scripts", dest="scripts", default="scripts", help="location of scripts")
+ parser.add_option("-S", "--system", action="store_false", dest="sys", default=True, help="use default python installation")
+
+ options, args = parser.parse_args(args)
+
+ if len(args) > 1:
+ parser.print_help()
+ return 1
+
+ if not options.abc or not options.abc_sh or not options.pyabc or not options.out:
+ parser.print_help()
+ return 1
+
+ return package(options.abc, options.abc_sh, options.pyabc, options.out, options.scripts, options.sys)
+
+if __name__=="__main__":
+ main(sys.argv)
diff --git a/src/python/pyabc.i b/src/python/pyabc.i
new file mode 100644
index 00000000..9dabc3db
--- /dev/null
+++ b/src/python/pyabc.i
@@ -0,0 +1,330 @@
+%module pyabc
+
+// -------------------------------------------------------------------
+// SWIG typemap allowing us to grab a Python callable object
+// -------------------------------------------------------------------
+
+#ifdef SWIG<Python>
+
+%typemap(in) PyObject *PyFunc
+{
+
+ if ( !PyCallable_Check($source) )
+ {
+ PyErr_SetString(PyExc_TypeError, "Need a callable object!");
+ return NULL;
+ }
+
+ $target = $source;
+}
+
+#endif /* #ifdef SWIG<Python> */
+
+%{
+
+#include <main.h>
+#include <stdlib.h>
+#include <signal.h>
+
+void sigint_signal_handler(int sig)
+{
+ _exit(1);
+}
+
+
+int n_ands()
+{
+ Abc_Frame_t* pAbc = Abc_FrameGetGlobalFrame();
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+
+ if ( pNtk && Abc_NtkIsStrash(pNtk) )
+ {
+ return Abc_NtkNodeNum(pNtk);
+ }
+
+ return -1;
+}
+
+int n_pis()
+{
+ Abc_Frame_t* pAbc = Abc_FrameGetGlobalFrame();
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+
+ if ( pNtk && Abc_NtkIsStrash(pNtk) )
+ {
+ return Abc_NtkPiNum(pNtk);
+ }
+
+ return -1;
+}
+
+
+int n_pos()
+{
+ Abc_Frame_t* pAbc = Abc_FrameGetGlobalFrame();
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+
+ if ( pNtk && Abc_NtkIsStrash(pNtk) )
+ {
+ return Abc_NtkPoNum(pNtk);
+ }
+
+ return -1;
+}
+
+int n_latches()
+{
+ Abc_Frame_t* pAbc = Abc_FrameGetGlobalFrame();
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+
+ if ( pNtk && Abc_NtkIsStrash(pNtk) )
+ {
+ return Abc_NtkLatchNum(pNtk);
+ }
+
+ return -1;
+}
+
+int run_command(char* cmd)
+{
+ Abc_Frame_t* pAbc = Abc_FrameGetGlobalFrame();
+ int fStatus = Cmd_CommandExecute(pAbc, cmd);
+
+ return fStatus;
+}
+
+bool has_comb_model()
+{
+ Abc_Frame_t* pAbc = Abc_FrameGetGlobalFrame();
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+
+ return pNtk && pNtk->pModel;
+}
+
+bool has_seq_model()
+{
+ Abc_Frame_t* pAbc = Abc_FrameGetGlobalFrame();
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+
+ return pNtk && pNtk->pSeqModel;
+}
+
+int n_bmc_frames()
+{
+ Abc_Frame_t* pAbc = Abc_FrameGetGlobalFrame();
+ return Abc_FrameReadBmcFrames(pAbc);
+}
+
+int prob_status()
+{
+ Abc_Frame_t* pAbc = Abc_FrameGetGlobalFrame();
+ return Abc_FrameReadProbStatus(pAbc);
+}
+
+bool is_valid_cex()
+{
+ Abc_Frame_t* pAbc = Abc_FrameGetGlobalFrame();
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+
+ return pNtk && Abc_FrameReadCex(pAbc) && Abc_NtkIsValidCex( pNtk, Abc_FrameReadCex(pAbc) );
+}
+
+bool is_true_cex()
+{
+ Abc_Frame_t* pAbc = Abc_FrameGetGlobalFrame();
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+
+ return pNtk && Abc_FrameReadCex(pAbc) && Abc_NtkIsTrueCex( pNtk, Abc_FrameReadCex(pAbc) );
+}
+
+int n_cex_pis()
+{
+ Abc_Frame_t* pAbc = Abc_FrameGetGlobalFrame();
+
+ return Abc_FrameReadCex(pAbc) ? Abc_FrameReadCexPiNum( Abc_FrameReadCex(pAbc) ) : -1;
+}
+
+int n_cex_regs()
+{
+ Abc_Frame_t* pAbc = Abc_FrameGetGlobalFrame();
+
+ return Abc_FrameReadCex(pAbc) ? Abc_FrameReadCexRegNum( Abc_FrameReadCex(pAbc) ) : -1;
+}
+
+int cex_po()
+{
+ Abc_Frame_t* pAbc = Abc_FrameGetGlobalFrame();
+
+ return Abc_FrameReadCex(pAbc) ? Abc_FrameReadCexPo( Abc_FrameReadCex(pAbc) ) : -1;
+}
+
+int cex_frame()
+{
+ Abc_Frame_t* pAbc = Abc_FrameGetGlobalFrame();
+
+ return Abc_FrameReadCex(pAbc) ? Abc_FrameReadCexFrame( Abc_FrameReadCex(pAbc) ) : -1;
+}
+
+int n_phases()
+{
+ Abc_Frame_t* pAbc = Abc_FrameGetGlobalFrame();
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
+
+ return pNtk ? Abc_NtkPhaseFrameNum(pNtk) : 1;
+}
+
+static PyObject* pyabc_internal_python_command_callback = 0;
+
+void pyabc_internal_set_command_callback( PyObject* callback )
+{
+ Py_XINCREF(callback);
+ Py_XDECREF(pyabc_internal_python_command_callback);
+
+ pyabc_internal_python_command_callback = callback;
+}
+
+static int pyabc_internal_abc_command_callback(Abc_Frame_t * pAbc, int argc, char ** argv)
+{
+ int i;
+
+ PyObject* args;
+ PyObject* arglist;
+ PyObject* res;
+ long lres;
+
+ if ( !pyabc_internal_python_command_callback )
+ return 0;
+
+ args = PyList_New(argc);
+
+ for( i=0 ; i<argc ; i++ )
+ PyList_SetItem(args, i, PyString_FromString(argv[i]) );
+
+ arglist = Py_BuildValue("(O)", args);
+ Py_INCREF(arglist);
+
+ res = PyEval_CallObject( pyabc_internal_python_command_callback, arglist );
+ Py_DECREF(arglist);
+
+ lres = PyInt_AsLong(res);
+ Py_DECREF(res);
+
+ return lres;
+}
+
+void pyabc_internal_register_command( char * sGroup, char * sName, int fChanges )
+{
+ Abc_Frame_t* pAbc = Abc_FrameGetGlobalFrame();
+
+ Cmd_CommandAdd( pAbc, sGroup, sName, (void*)pyabc_internal_abc_command_callback, fChanges);
+}
+
+%}
+
+%init
+%{
+ Abc_Start();
+ signal(SIGINT, sigint_signal_handler);
+%}
+
+int n_ands();
+int n_pis();
+int n_pos();
+int n_latches();
+
+int run_command(char* cmd);
+
+bool has_comb_model();
+bool has_seq_model();
+
+int n_bmc_frames();
+int prob_status();
+
+bool is_valid_cex();
+bool is_true_cex();
+int n_cex_pis();
+int n_cex_regs();
+int cex_po();
+int cex_frame();
+
+int n_phases();
+
+void pyabc_internal_set_command_callback( PyObject* callback );
+void pyabc_internal_register_command( char * sGroup, char * sName, int fChanges );
+
+%pythoncode
+%{
+
+_registered_commands = {}
+
+def _cmd_callback(args):
+ try:
+ assert len(args) > 0
+
+ cmd = args[0]
+ assert cmd in _registered_commands
+
+ res = _registered_commands[cmd](args)
+
+ assert type(res) == int, "User-defined Python command must return an integer."
+
+ return res
+
+ except Exception, e:
+ print "Python error: ", e
+
+ except SystemExit, se:
+ pass
+
+ return 0
+
+pyabc_internal_set_command_callback( _cmd_callback )
+
+def add_abc_command(fcmd, group, cmd, change):
+ _registered_commands[ cmd ] = fcmd
+ pyabc_internal_register_command( group, cmd, change)
+
+import sys
+import optparse
+import os.path
+
+import __main__
+
+def cmd_python(cmd_args):
+ global __main__
+
+ usage = "usage: %prog [options] <Python files>"
+
+ parser = optparse.OptionParser(usage)
+
+ parser.add_option("-c", "--cmd", dest="cmd", help="Execute Python command directly")
+ parser.add_option("-v", "--version", action="store_true", dest="version", help="Display Python Version")
+
+ options, args = parser.parse_args(cmd_args)
+
+ if options.version:
+ print sys.version
+ return 0
+
+ if options.cmd:
+ exec options.cmd in __main__.__dict__
+ return 0
+
+ scripts_dir = os.getenv('ABC_PYTHON_SCRIPTS', ".")
+ scripts_dirs = scripts_dir.split(':')
+
+ for fname in args[1:]:
+ if os.path.isabs(fname):
+ execfile(fname, __main__.__dict__)
+ else:
+ for d in scripts_dirs:
+ fname = os.path.join(scripts_dir, fname)
+ if os.path.exists(fname):
+ execfile(fname, __main__.__dict__)
+ break
+
+ return 0
+
+add_abc_command(cmd_python, "Python", "python", 0)
+
+%}
diff --git a/src/python/setup.py b/src/python/setup.py
new file mode 100644
index 00000000..abc07afa
--- /dev/null
+++ b/src/python/setup.py
@@ -0,0 +1,64 @@
+import sys
+
+from distutils.core import setup, Extension
+from distutils.sysconfig import get_config_vars
+from distutils import util
+
+include_dirs = [
+ '../aig/hop',
+ '../base/abc',
+ '../base/cmd',
+ '../base/io',
+ '../base/main',
+ '../bdd/cudd',
+ '../bdd/epd',
+ '../bdd/mtr',
+ '../misc/extra',
+ '../misc/nm',
+ '../misc/st',
+ '../misc/util',
+ '../misc/vec',
+ ]
+
+define_macros = []
+libraries = []
+library_dirs = []
+
+if sys.platform == "win32":
+
+ src_file = [ 'pyabc.i' ]
+
+ define_macros.append( ('WIN32', 1) )
+ define_macros.append( ('ABC_DLL', 'ABC_DLLEXPORT') )
+
+ libraries.append('abcr')
+ library_dirs.append('./../../lib')
+
+else:
+
+ src_file = [ 'pyabc_wrap.c' ]
+
+ if get_config_vars()['SIZEOF_VOID_P'] > 4:
+ define_macros.append( ('LIN64', 1) )
+ else:
+ define_macros.append( ('LIN', 1) )
+
+ libraries.append( 'abc' )
+ libraries.append( 'readline' )
+ library_dirs.append('./../../')
+
+ext = Extension(
+ '_pyabc',
+ src_file,
+ define_macros=define_macros,
+ include_dirs = include_dirs,
+ library_dirs=library_dirs,
+ libraries=libraries
+ )
+
+setup(
+ name='pyabc',
+ version='1.0',
+ ext_modules=[ext],
+ py_modules=['pyabc']
+)
diff --git a/src/sat/bsat/satChecker.c b/src/sat/bsat/satChecker.c
index 1488fe2f..041bc9ed 100644
--- a/src/sat/bsat/satChecker.c
+++ b/src/sat/bsat/satChecker.c
@@ -25,6 +25,9 @@
#include <time.h>
#include "vec.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -185,3 +188,5 @@ void Sat_ProofChecker( char * pFileName )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/bsat/satInter.c b/src/sat/bsat/satInter.c
index 849ceb71..8617def9 100644
--- a/src/sat/bsat/satInter.c
+++ b/src/sat/bsat/satInter.c
@@ -25,6 +25,9 @@
#include <time.h>
#include "satStore.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -222,7 +225,7 @@ void Int_ManResize( Int_Man_t * p )
p->pWatches = ABC_REALLOC(Sto_Cls_t *, p->pWatches, p->nVarsAlloc*2 );
}
- // clean the ABC_FREE space
+ // clean the free space
memset( p->pAssigns , 0xff, sizeof(lit) * p->pCnf->nVars );
memset( p->pSeens , 0, sizeof(char) * p->pCnf->nVars );
memset( p->pVarTypes, 0, sizeof(int) * p->pCnf->nVars );
@@ -1070,3 +1073,5 @@ p->timeTotal += clock() - clkTotal;
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/bsat/satInterA.c b/src/sat/bsat/satInterA.c
index 5dcc7f0b..a635516c 100644
--- a/src/sat/bsat/satInterA.c
+++ b/src/sat/bsat/satInterA.c
@@ -26,6 +26,9 @@
#include "satStore.h"
#include "aig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -186,6 +189,7 @@ int Inta_ManGlobalVars( Inta_Man_t * p )
***********************************************************************/
void Inta_ManResize( Inta_Man_t * p )
{
+ p->Counter = 0;
// check if resizing is needed
if ( p->nVarsAlloc < p->pCnf->nVars )
{
@@ -203,7 +207,7 @@ void Inta_ManResize( Inta_Man_t * p )
p->pWatches = ABC_REALLOC(Sto_Cls_t *, p->pWatches, p->nVarsAlloc*2 );
}
- // clean the ABC_FREE space
+ // clean the free space
memset( p->pAssigns , 0xff, sizeof(lit) * p->pCnf->nVars );
memset( p->pSeens , 0, sizeof(char) * p->pCnf->nVars );
memset( p->pVarTypes, 0, sizeof(int) * p->pCnf->nVars );
@@ -956,7 +960,7 @@ void * Inta_ManInterpolate( Inta_Man_t * p, Sto_Man_t * pCnf, void * vVarsAB, in
assert( pCnf->nVars > 0 && pCnf->nClauses > 0 );
p->pCnf = pCnf;
p->fVerbose = fVerbose;
- p->vVarsAB = vVarsAB;
+ p->vVarsAB = (Vec_Int_t *)vVarsAB;
p->pAig = pRes = Aig_ManStart( 10000 );
Aig_IthVar( p->pAig, Vec_IntSize(p->vVarsAB) - 1 );
@@ -1071,3 +1075,5 @@ Aig_Man_t * Inta_ManDeriveClauses( Inta_Man_t * pMan, Sto_Man_t * pCnf, int fCla
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/bsat/satInterA_mod.c b/src/sat/bsat/satInterA_mod.c
index faf396a6..199e9bd3 100644
--- a/src/sat/bsat/satInterA_mod.c
+++ b/src/sat/bsat/satInterA_mod.c
@@ -26,6 +26,9 @@
#include "satStore.h"
#include "aig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -1102,3 +1105,5 @@ Aig_Man_t * Inta_ManDeriveClauses( Inta_Man_t * pMan, Sto_Man_t * pCnf, int fCla
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/bsat/satInterA_old.c b/src/sat/bsat/satInterA_old.c
index 57628989..02db6c79 100644
--- a/src/sat/bsat/satInterA_old.c
+++ b/src/sat/bsat/satInterA_old.c
@@ -26,6 +26,9 @@
#include "satStore.h"
#include "aig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -1045,3 +1048,5 @@ Aig_Man_t * Inta_ManDeriveClauses( Inta_Man_t * pMan, Sto_Man_t * pCnf, int fCla
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/bsat/satInterA_yu_hu.c b/src/sat/bsat/satInterA_yu_hu.c
index aa2289f2..9afd2dd8 100644
--- a/src/sat/bsat/satInterA_yu_hu.c
+++ b/src/sat/bsat/satInterA_yu_hu.c
@@ -26,6 +26,9 @@
#include "satStore.h"
#include "aig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -1079,3 +1082,5 @@ Aig_Man_t * Inta_ManDeriveClauses( Inta_Man_t * pMan, Sto_Man_t * pCnf, int fCla
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/bsat/satInterB.c b/src/sat/bsat/satInterB.c
index cb7f7828..1ffb0dc5 100644
--- a/src/sat/bsat/satInterB.c
+++ b/src/sat/bsat/satInterB.c
@@ -26,6 +26,9 @@
#include "satStore.h"
#include "aig.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -188,6 +191,7 @@ int Intb_ManGlobalVars( Intb_Man_t * p )
***********************************************************************/
void Intb_ManResize( Intb_Man_t * p )
{
+ p->Counter = 0;
// check if resizing is needed
if ( p->nVarsAlloc < p->pCnf->nVars )
{
@@ -205,7 +209,7 @@ void Intb_ManResize( Intb_Man_t * p )
p->pWatches = ABC_REALLOC(Sto_Cls_t *, p->pWatches, p->nVarsAlloc*2 );
}
- // clean the ABC_FREE space
+ // clean the free space
memset( p->pAssigns , 0xff, sizeof(lit) * p->pCnf->nVars );
memset( p->pSeens , 0, sizeof(char) * p->pCnf->nVars );
memset( p->pVarTypes, 0, sizeof(int) * p->pCnf->nVars );
@@ -232,7 +236,7 @@ void Intb_ManResize( Intb_Man_t * p )
if ( p->nIntersAlloc < p->pCnf->nClauses )
{
p->nIntersAlloc = p->pCnf->nClauses;
- p->pInters = ABC_REALLOC(Aig_Obj_t *, p->pInters, p->nIntersAlloc );
+ p->pInters = ABC_REALLOC( Aig_Obj_t *, p->pInters, p->nIntersAlloc );
}
memset( p->pInters, 0, sizeof(Aig_Obj_t *) * p->pCnf->nClauses );
}
@@ -550,7 +554,6 @@ int Intb_ManGetGlobalVar( Intb_Man_t * p, int Var )
return VarAB;
}
-
/**Function*************************************************************
Synopsis [Traces the proof for one clause.]
@@ -608,7 +611,6 @@ int Intb_ManProofTraceOne( Intb_Man_t * p, Sto_Cls_t * pConflict, Sto_Cls_t * pF
for ( v = 1; v < (int)pReason->nLits; v++ )
p->pSeens[lit_var(pReason->pLits[v])] = 1;
-
// record the reason clause
assert( Intb_ManProofGet(p, pReason) > 0 );
p->Counter++;
@@ -677,7 +679,6 @@ int Intb_ManProofTraceOne( Intb_Man_t * p, Sto_Cls_t * pConflict, Sto_Cls_t * pF
printf( "Recording clause %d: Trying to resolve the clause with more than one opposite literal.\n", pFinal->Id );
}
}
-
// Vec_PtrPush( pFinal->pAntis, pReason );
}
@@ -710,6 +711,27 @@ int Intb_ManProofTraceOne( Intb_Man_t * p, Sto_Cls_t * pConflict, Sto_Cls_t * pF
Intb_ManPrintResolvent( p->pResLits, p->nResLits );
Intb_ManPrintClause( p, pFinal );
}
+
+ // if there are literals in the clause that are not in the resolvent
+ // it means that the derived resolvent is stronger than the clause
+ // we can replace the clause with the resolvent by removing these literals
+ if ( p->nResLits != (int)pFinal->nLits )
+ {
+ for ( v1 = 0; v1 < (int)pFinal->nLits; v1++ )
+ {
+ for ( v2 = 0; v2 < p->nResLits; v2++ )
+ if ( pFinal->pLits[v1] == p->pResLits[v2] )
+ break;
+ if ( v2 < p->nResLits )
+ continue;
+ // remove literal v1 from the final clause
+ pFinal->nLits--;
+ for ( v2 = v1; v2 < (int)pFinal->nLits; v2++ )
+ pFinal->pLits[v2] = pFinal->pLits[v2+1];
+ v1--;
+ }
+ assert( p->nResLits == (int)pFinal->nLits );
+ }
}
p->timeTrace += clock() - clk;
@@ -719,6 +741,10 @@ p->timeTrace += clock() - clk;
// Intb_ManPrintInterOne( p, pFinal );
}
Intb_ManProofSet( p, pFinal, p->Counter );
+ // make sure the same proof ID is not asssigned to two consecutive clauses
+ assert( p->pProofNums[pFinal->Id-1] != p->Counter );
+// if ( p->pProofNums[pFinal->Id] == p->pProofNums[pFinal->Id-1] )
+// p->pProofNums[pFinal->Id] = p->pProofNums[pConflict->Id];
return p->Counter;
}
@@ -743,9 +769,16 @@ int Intb_ManProofRecordOne( Intb_Man_t * p, Sto_Cls_t * pClause )
if ( pClause->nLits == 0 )
printf( "Error: Empty clause is attempted.\n" );
- // add assumptions to the trail
assert( !pClause->fRoot );
assert( p->nTrailSize == p->nRootSize );
+
+ // if any of the clause literals are already assumed
+ // it means that the clause is redundant and can be skipped
+ for ( i = 0; i < (int)pClause->nLits; i++ )
+ if ( p->pAssigns[lit_var(pClause->pLits[i])] == pClause->pLits[i] )
+ return 1;
+
+ // add assumptions to the trail
for ( i = 0; i < (int)pClause->nLits; i++ )
if ( !Intb_ManEnqueue( p, lit_neg(pClause->pLits[i]), NULL ) )
{
@@ -759,6 +792,27 @@ int Intb_ManProofRecordOne( Intb_Man_t * p, Sto_Cls_t * pClause )
{
assert( 0 ); // cannot prove
return 0;
+ }
+
+ // skip the clause if it is weaker or the same as the conflict clause
+ if ( pClause->nLits >= pConflict->nLits )
+ {
+ // check if every literal of conflict clause can be found in the given clause
+ int j;
+ for ( i = 0; i < (int)pConflict->nLits; i++ )
+ {
+ for ( j = 0; j < (int)pClause->nLits; j++ )
+ if ( pConflict->pLits[i] == pClause->pLits[j] )
+ break;
+ if ( j == (int)pClause->nLits ) // literal pConflict->pLits[i] is not found
+ break;
+ }
+ if ( i == (int)pConflict->nLits ) // all lits are found
+ {
+ // undo to the root level
+ Intb_ManCancelUntil( p, p->nRootSize );
+ return 1;
+ }
}
// construct the proof
@@ -846,8 +900,12 @@ int Intb_ManProcessRoots( Intb_Man_t * p )
if ( !Intb_ManEnqueue( p, pClause->pLits[0], pClause ) )
{
// detected root level conflict
- printf( "Error in Intb_ManProcessRoots(): Detected a root-level conflict too early!\n" );
- assert( 0 );
+// printf( "Error in Intb_ManProcessRoots(): Detected a root-level conflict too early!\n" );
+// assert( 0 );
+ // detected root level conflict
+ Intb_ManProofTraceOne( p, pClause, p->pCnf->pEmpty );
+ if ( p->fVerbose )
+ printf( "Found root level conflict!\n" );
return 0;
}
}
@@ -895,7 +953,6 @@ void Intb_ManPrepareInter( Intb_Man_t * p )
}
// clause of A
Intb_ManAigClear( p, Intb_ManAigRead(p, pClause) );
-
for ( v = 0; v < (int)pClause->nLits; v++ )
{
Var = lit_var(pClause->pLits[v]);
@@ -909,7 +966,6 @@ void Intb_ManPrepareInter( Intb_Man_t * p )
Intb_ManAigOrVar( p, Intb_ManAigRead(p, pClause), VarAB );
}
}
-
// Intb_ManPrintInterOne( p, pClause );
}
}
@@ -940,7 +996,7 @@ void * Intb_ManInterpolate( Intb_Man_t * p, Sto_Man_t * pCnf, void * vVarsAB, in
assert( pCnf->nVars > 0 && pCnf->nClauses > 0 );
p->pCnf = pCnf;
p->fVerbose = fVerbose;
- p->vVarsAB = vVarsAB;
+ p->vVarsAB = (Vec_Int_t *)vVarsAB;
p->pAig = pRes = Aig_ManStart( 10000 );
Aig_IthVar( p->pAig, Vec_IntSize(p->vVarsAB) - 1 );
@@ -980,8 +1036,9 @@ void * Intb_ManInterpolate( Intb_Man_t * p, Sto_Man_t * pCnf, void * vVarsAB, in
// stop the proof
if ( p->fProofWrite )
- {
+ {
fclose( p->pFile );
+// Sat_ProofChecker( "proof.cnf_" );
p->pFile = NULL;
}
@@ -1004,6 +1061,7 @@ p->timeTotal += clock() - clkTotal;
}
+
/**Function*************************************************************
Synopsis []
@@ -1053,3 +1111,5 @@ Aig_Man_t * Intb_ManDeriveClauses( Intb_Man_t * pMan, Sto_Man_t * pCnf, int fCla
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/bsat/satInterB_.c b/src/sat/bsat/satInterB_.c
new file mode 100644
index 00000000..ac005422
--- /dev/null
+++ b/src/sat/bsat/satInterB_.c
@@ -0,0 +1,1060 @@
+/**CFile****************************************************************
+
+ FileName [satInter.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [SAT sat_solver.]
+
+ Synopsis [Interpolation package.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: satInter.c,v 1.4 2005/09/16 22:55:03 casem Exp $]
+
+***********************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <time.h>
+#include "satStore.h"
+#include "aig.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+// variable assignments
+static const lit LIT_UNDEF = 0xffffffff;
+
+// interpolation manager
+struct Inta_Man_t_
+{
+ // clauses of the problems
+ Sto_Man_t * pCnf; // the set of CNF clauses for A and B
+ Vec_Int_t * vVarsAB; // the array of global variables
+ // various parameters
+ int fVerbose; // verbosiness flag
+ int fProofVerif; // verifies the proof
+ int fProofWrite; // writes the proof file
+ int nVarsAlloc; // the allocated size of var arrays
+ int nClosAlloc; // the allocated size of clause arrays
+ // internal BCP
+ int nRootSize; // the number of root level assignments
+ int nTrailSize; // the number of assignments made
+ lit * pTrail; // chronological order of assignments (size nVars)
+ lit * pAssigns; // assignments by variable (size nVars)
+ char * pSeens; // temporary mark (size nVars)
+ Sto_Cls_t ** pReasons; // reasons for each assignment (size nVars)
+ Sto_Cls_t ** pWatches; // watched clauses for each literal (size 2*nVars)
+ // interpolation data
+ Aig_Man_t * pAig; // the AIG manager for recording the interpolant
+ int * pVarTypes; // variable type (size nVars) [1=A, 0=B, <0=AB]
+ Aig_Obj_t ** pInters; // storage for interpolants as truth tables (size nClauses)
+ int nIntersAlloc; // the allocated size of truth table array
+ // proof recording
+ int Counter; // counter of resolved clauses
+ int * pProofNums; // the proof numbers for each clause (size nClauses)
+ FILE * pFile; // the file for proof recording
+ // internal verification
+ lit * pResLits; // the literals of the resolvent
+ int nResLits; // the number of literals of the resolvent
+ int nResLitsAlloc;// the number of literals of the resolvent
+ // runtime stats
+ int timeBcp; // the runtime for BCP
+ int timeTrace; // the runtime of trace construction
+ int timeTotal; // the total runtime of interpolation
+};
+
+// procedure to get hold of the clauses' truth table
+static inline Aig_Obj_t ** Inta_ManAigRead( Inta_Man_t * pMan, Sto_Cls_t * pCls ) { return pMan->pInters + pCls->Id; }
+static inline void Inta_ManAigClear( Inta_Man_t * pMan, Aig_Obj_t ** p ) { *p = Aig_ManConst0(pMan->pAig); }
+static inline void Inta_ManAigFill( Inta_Man_t * pMan, Aig_Obj_t ** p ) { *p = Aig_ManConst1(pMan->pAig); }
+static inline void Inta_ManAigCopy( Inta_Man_t * pMan, Aig_Obj_t ** p, Aig_Obj_t ** q ) { *p = *q; }
+static inline void Inta_ManAigAnd( Inta_Man_t * pMan, Aig_Obj_t ** p, Aig_Obj_t ** q ) { *p = Aig_And(pMan->pAig, *p, *q); }
+static inline void Inta_ManAigOr( Inta_Man_t * pMan, Aig_Obj_t ** p, Aig_Obj_t ** q ) { *p = Aig_Or(pMan->pAig, *p, *q); }
+static inline void Inta_ManAigOrNot( Inta_Man_t * pMan, Aig_Obj_t ** p, Aig_Obj_t ** q ) { *p = Aig_Or(pMan->pAig, *p, Aig_Not(*q)); }
+static inline void Inta_ManAigOrVar( Inta_Man_t * pMan, Aig_Obj_t ** p, int v ) { *p = Aig_Or(pMan->pAig, *p, Aig_IthVar(pMan->pAig, v)); }
+static inline void Inta_ManAigOrNotVar( Inta_Man_t * pMan, Aig_Obj_t ** p, int v ) { *p = Aig_Or(pMan->pAig, *p, Aig_Not(Aig_IthVar(pMan->pAig, v))); }
+static inline void Inta_ManAigMux0( Inta_Man_t * pMan, Aig_Obj_t ** p, Aig_Obj_t ** q, int v){ *p = Aig_Mux(pMan->pAig, Aig_IthVar(pMan->pAig, v), *q, *p); }
+static inline void Inta_ManAigMux1( Inta_Man_t * pMan, Aig_Obj_t ** p, Aig_Obj_t ** q, int v){ *p = Aig_Mux(pMan->pAig, Aig_IthVar(pMan->pAig, v), *p, *q); }
+
+// reading/writing the proof for a clause
+static inline int Inta_ManProofGet( Inta_Man_t * p, Sto_Cls_t * pCls ) { return p->pProofNums[pCls->Id]; }
+static inline void Inta_ManProofSet( Inta_Man_t * p, Sto_Cls_t * pCls, int n ) { p->pProofNums[pCls->Id] = n; }
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Allocate proof manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Inta_Man_t * Inta_ManAlloc()
+{
+ Inta_Man_t * p;
+ // allocate the manager
+ p = (Inta_Man_t *)ABC_ALLOC( char, sizeof(Inta_Man_t) );
+ memset( p, 0, sizeof(Inta_Man_t) );
+ // verification
+ p->nResLitsAlloc = (1<<16);
+ p->pResLits = ABC_ALLOC( lit, p->nResLitsAlloc );
+ // parameters
+ p->fProofWrite = 0;
+ p->fProofVerif = 1;
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Count common variables in the clauses of A and B.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Inta_ManGlobalVars( Inta_Man_t * p )
+{
+ Sto_Cls_t * pClause;
+ int LargeNum = -100000000;
+ int Var, nVarsAB, v;
+
+ // mark the variable encountered in the clauses of A
+ Sto_ManForEachClauseRoot( p->pCnf, pClause )
+ {
+ if ( !pClause->fA )
+ break;
+ for ( v = 0; v < (int)pClause->nLits; v++ )
+ p->pVarTypes[lit_var(pClause->pLits[v])] = 1;
+ }
+
+ // check variables that appear in clauses of B
+ nVarsAB = 0;
+ Sto_ManForEachClauseRoot( p->pCnf, pClause )
+ {
+ if ( pClause->fA )
+ continue;
+ for ( v = 0; v < (int)pClause->nLits; v++ )
+ {
+ Var = lit_var(pClause->pLits[v]);
+ if ( p->pVarTypes[Var] == 1 ) // var of A
+ {
+ // change it into a global variable
+ nVarsAB++;
+ p->pVarTypes[Var] = LargeNum;
+ }
+ }
+ }
+ assert( nVarsAB <= Vec_IntSize(p->vVarsAB) );
+
+ // order global variables
+ nVarsAB = 0;
+ Vec_IntForEachEntry( p->vVarsAB, Var, v )
+ p->pVarTypes[Var] = -(1+nVarsAB++);
+
+ // check that there is no extra global variables
+ for ( v = 0; v < p->pCnf->nVars; v++ )
+ assert( p->pVarTypes[v] != LargeNum );
+ return nVarsAB;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Resize proof manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Inta_ManResize( Inta_Man_t * p )
+{
+ // check if resizing is needed
+ if ( p->nVarsAlloc < p->pCnf->nVars )
+ {
+ // find the new size
+ if ( p->nVarsAlloc == 0 )
+ p->nVarsAlloc = 1;
+ while ( p->nVarsAlloc < p->pCnf->nVars )
+ p->nVarsAlloc *= 2;
+ // resize the arrays
+ p->pTrail = ABC_REALLOC(lit, p->pTrail, p->nVarsAlloc );
+ p->pAssigns = ABC_REALLOC(lit, p->pAssigns, p->nVarsAlloc );
+ p->pSeens = ABC_REALLOC(char, p->pSeens, p->nVarsAlloc );
+ p->pVarTypes = ABC_REALLOC(int, p->pVarTypes, p->nVarsAlloc );
+ p->pReasons = ABC_REALLOC(Sto_Cls_t *, p->pReasons, p->nVarsAlloc );
+ p->pWatches = ABC_REALLOC(Sto_Cls_t *, p->pWatches, p->nVarsAlloc*2 );
+ }
+
+ // clean the free space
+ memset( p->pAssigns , 0xff, sizeof(lit) * p->pCnf->nVars );
+ memset( p->pSeens , 0, sizeof(char) * p->pCnf->nVars );
+ memset( p->pVarTypes, 0, sizeof(int) * p->pCnf->nVars );
+ memset( p->pReasons , 0, sizeof(Sto_Cls_t *) * p->pCnf->nVars );
+ memset( p->pWatches , 0, sizeof(Sto_Cls_t *) * p->pCnf->nVars*2 );
+
+ // compute the number of common variables
+ Inta_ManGlobalVars( p );
+
+ // check if resizing of clauses is needed
+ if ( p->nClosAlloc < p->pCnf->nClauses )
+ {
+ // find the new size
+ if ( p->nClosAlloc == 0 )
+ p->nClosAlloc = 1;
+ while ( p->nClosAlloc < p->pCnf->nClauses )
+ p->nClosAlloc *= 2;
+ // resize the arrays
+ p->pProofNums = ABC_REALLOC( int, p->pProofNums, p->nClosAlloc );
+ }
+ memset( p->pProofNums, 0, sizeof(int) * p->pCnf->nClauses );
+
+ // check if resizing of truth tables is needed
+ if ( p->nIntersAlloc < p->pCnf->nClauses )
+ {
+ p->nIntersAlloc = p->pCnf->nClauses;
+ p->pInters = ABC_REALLOC(Aig_Obj_t *, p->pInters, p->nIntersAlloc );
+ }
+ memset( p->pInters, 0, sizeof(Aig_Obj_t *) * p->pCnf->nClauses );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Deallocate proof manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Inta_ManFree( Inta_Man_t * p )
+{
+/*
+ printf( "Runtime stats:\n" );
+ABC_PRT( "BCP ", p->timeBcp );
+ABC_PRT( "Trace ", p->timeTrace );
+ABC_PRT( "TOTAL ", p->timeTotal );
+*/
+ ABC_FREE( p->pInters );
+ ABC_FREE( p->pProofNums );
+ ABC_FREE( p->pTrail );
+ ABC_FREE( p->pAssigns );
+ ABC_FREE( p->pSeens );
+ ABC_FREE( p->pVarTypes );
+ ABC_FREE( p->pReasons );
+ ABC_FREE( p->pWatches );
+ ABC_FREE( p->pResLits );
+ ABC_FREE( p );
+}
+
+
+
+
+/**Function*************************************************************
+
+ Synopsis [Prints the clause.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Inta_ManPrintClause( Inta_Man_t * p, Sto_Cls_t * pClause )
+{
+ int i;
+ printf( "Clause ID = %d. Proof = %d. {", pClause->Id, Inta_ManProofGet(p, pClause) );
+ for ( i = 0; i < (int)pClause->nLits; i++ )
+ printf( " %d", pClause->pLits[i] );
+ printf( " }\n" );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Prints the resolvent.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Inta_ManPrintResolvent( lit * pResLits, int nResLits )
+{
+ int i;
+ printf( "Resolvent: {" );
+ for ( i = 0; i < nResLits; i++ )
+ printf( " %d", pResLits[i] );
+ printf( " }\n" );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Prints the interpolant for one clause.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Inta_ManPrintInterOne( Inta_Man_t * p, Sto_Cls_t * pClause )
+{
+ printf( "Clause %2d : ", pClause->Id );
+// Extra_PrintBinary___( stdout, Inta_ManAigRead(p, pClause), (1 << p->nVarsAB) );
+ printf( "\n" );
+}
+
+
+
+/**Function*************************************************************
+
+ Synopsis [Adds one clause to the watcher list.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Inta_ManWatchClause( Inta_Man_t * p, Sto_Cls_t * pClause, lit Lit )
+{
+ assert( lit_check(Lit, p->pCnf->nVars) );
+ if ( pClause->pLits[0] == Lit )
+ pClause->pNext0 = p->pWatches[lit_neg(Lit)];
+ else
+ {
+ assert( pClause->pLits[1] == Lit );
+ pClause->pNext1 = p->pWatches[lit_neg(Lit)];
+ }
+ p->pWatches[lit_neg(Lit)] = pClause;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Records implication.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Inta_ManEnqueue( Inta_Man_t * p, lit Lit, Sto_Cls_t * pReason )
+{
+ int Var = lit_var(Lit);
+ if ( p->pAssigns[Var] != LIT_UNDEF )
+ return p->pAssigns[Var] == Lit;
+ p->pAssigns[Var] = Lit;
+ p->pReasons[Var] = pReason;
+ p->pTrail[p->nTrailSize++] = Lit;
+//printf( "assigning var %d value %d\n", Var, !lit_sign(Lit) );
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Records implication.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Inta_ManCancelUntil( Inta_Man_t * p, int Level )
+{
+ lit Lit;
+ int i, Var;
+ for ( i = p->nTrailSize - 1; i >= Level; i-- )
+ {
+ Lit = p->pTrail[i];
+ Var = lit_var( Lit );
+ p->pReasons[Var] = NULL;
+ p->pAssigns[Var] = LIT_UNDEF;
+//printf( "cancelling var %d\n", Var );
+ }
+ p->nTrailSize = Level;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Propagate one assignment.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline Sto_Cls_t * Inta_ManPropagateOne( Inta_Man_t * p, lit Lit )
+{
+ Sto_Cls_t ** ppPrev, * pCur, * pTemp;
+ lit LitF = lit_neg(Lit);
+ int i;
+ // iterate through the literals
+ ppPrev = p->pWatches + Lit;
+ for ( pCur = p->pWatches[Lit]; pCur; pCur = *ppPrev )
+ {
+ // make sure the false literal is in the second literal of the clause
+ if ( pCur->pLits[0] == LitF )
+ {
+ pCur->pLits[0] = pCur->pLits[1];
+ pCur->pLits[1] = LitF;
+ pTemp = pCur->pNext0;
+ pCur->pNext0 = pCur->pNext1;
+ pCur->pNext1 = pTemp;
+ }
+ assert( pCur->pLits[1] == LitF );
+
+ // if the first literal is true, the clause is satisfied
+ if ( pCur->pLits[0] == p->pAssigns[lit_var(pCur->pLits[0])] )
+ {
+ ppPrev = &pCur->pNext1;
+ continue;
+ }
+
+ // look for a new literal to watch
+ for ( i = 2; i < (int)pCur->nLits; i++ )
+ {
+ // skip the case when the literal is false
+ if ( lit_neg(pCur->pLits[i]) == p->pAssigns[lit_var(pCur->pLits[i])] )
+ continue;
+ // the literal is either true or unassigned - watch it
+ pCur->pLits[1] = pCur->pLits[i];
+ pCur->pLits[i] = LitF;
+ // remove this clause from the watch list of Lit
+ *ppPrev = pCur->pNext1;
+ // add this clause to the watch list of pCur->pLits[i] (now it is pCur->pLits[1])
+ Inta_ManWatchClause( p, pCur, pCur->pLits[1] );
+ break;
+ }
+ if ( i < (int)pCur->nLits ) // found new watch
+ continue;
+
+ // clause is unit - enqueue new implication
+ if ( Inta_ManEnqueue(p, pCur->pLits[0], pCur) )
+ {
+ ppPrev = &pCur->pNext1;
+ continue;
+ }
+
+ // conflict detected - return the conflict clause
+ return pCur;
+ }
+ return NULL;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Propagate the current assignments.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Sto_Cls_t * Inta_ManPropagate( Inta_Man_t * p, int Start )
+{
+ Sto_Cls_t * pClause;
+ int i;
+ int clk = clock();
+ for ( i = Start; i < p->nTrailSize; i++ )
+ {
+ pClause = Inta_ManPropagateOne( p, p->pTrail[i] );
+ if ( pClause )
+ {
+p->timeBcp += clock() - clk;
+ return pClause;
+ }
+ }
+p->timeBcp += clock() - clk;
+ return NULL;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Writes one root clause into a file.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Inta_ManProofWriteOne( Inta_Man_t * p, Sto_Cls_t * pClause )
+{
+ Inta_ManProofSet( p, pClause, ++p->Counter );
+
+ if ( p->fProofWrite )
+ {
+ int v;
+ fprintf( p->pFile, "%d", Inta_ManProofGet(p, pClause) );
+ for ( v = 0; v < (int)pClause->nLits; v++ )
+ fprintf( p->pFile, " %d", lit_print(pClause->pLits[v]) );
+ fprintf( p->pFile, " 0 0\n" );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Traces the proof for one clause.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Inta_ManGetGlobalVar( Inta_Man_t * p, int Var )
+{
+ int VarAB;
+ if ( p->pVarTypes[Var] >= 0 ) // global var
+ return -1;
+ VarAB = -p->pVarTypes[Var]-1;
+ assert( VarAB >= 0 && VarAB < Vec_IntSize(p->vVarsAB) );
+ return VarAB;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Traces the proof for one clause.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Inta_ManProofTraceOne( Inta_Man_t * p, Sto_Cls_t * pConflict, Sto_Cls_t * pFinal )
+{
+ Sto_Cls_t * pReason;
+ int i, v, Var, PrevId;
+ int fPrint = 0;
+ int clk = clock();
+
+ // collect resolvent literals
+ if ( p->fProofVerif )
+ {
+ assert( (int)pConflict->nLits <= p->nResLitsAlloc );
+ memcpy( p->pResLits, pConflict->pLits, sizeof(lit) * pConflict->nLits );
+ p->nResLits = pConflict->nLits;
+ }
+
+ // mark all the variables in the conflict as seen
+ for ( v = 0; v < (int)pConflict->nLits; v++ )
+ p->pSeens[lit_var(pConflict->pLits[v])] = 1;
+
+ // start the anticedents
+// pFinal->pAntis = Vec_PtrAlloc( 32 );
+// Vec_PtrPush( pFinal->pAntis, pConflict );
+
+ if ( p->pCnf->nClausesA )
+ Inta_ManAigCopy( p, Inta_ManAigRead(p, pFinal), Inta_ManAigRead(p, pConflict) );
+
+ // follow the trail backwards
+ PrevId = Inta_ManProofGet(p, pConflict);
+ for ( i = p->nTrailSize - 1; i >= 0; i-- )
+ {
+ // skip literals that are not involved
+ Var = lit_var(p->pTrail[i]);
+ if ( !p->pSeens[Var] )
+ continue;
+ p->pSeens[Var] = 0;
+
+ // skip literals of the resulting clause
+ pReason = p->pReasons[Var];
+ if ( pReason == NULL )
+ continue;
+ assert( p->pTrail[i] == pReason->pLits[0] );
+
+ // add the variables to seen
+ for ( v = 1; v < (int)pReason->nLits; v++ )
+ p->pSeens[lit_var(pReason->pLits[v])] = 1;
+
+
+ // record the reason clause
+ assert( Inta_ManProofGet(p, pReason) > 0 );
+ p->Counter++;
+ if ( p->fProofWrite )
+ fprintf( p->pFile, "%d * %d %d 0\n", p->Counter, PrevId, Inta_ManProofGet(p, pReason) );
+ PrevId = p->Counter;
+
+ if ( p->pCnf->nClausesA )
+ {
+ if ( p->pVarTypes[Var] == 1 )// || rand() % 10 == 0 ) // var of A
+ Inta_ManAigOr( p, Inta_ManAigRead(p, pFinal), Inta_ManAigRead(p, pReason) );
+ else if ( p->pVarTypes[Var] == 0 ) // var of B
+ Inta_ManAigAnd( p, Inta_ManAigRead(p, pFinal), Inta_ManAigRead(p, pReason) );
+ else
+ {
+ int VarAB = Inta_ManGetGlobalVar(p, Var);
+ // check that the var is present in the reason
+ for ( v = 0; v < (int)pReason->nLits; v++ )
+ if ( lit_var(pReason->pLits[v]) == Var )
+ break;
+ assert( v < (int)pReason->nLits );
+ if ( lit_sign(pReason->pLits[v]) ) // negative polarity
+ Inta_ManAigMux0( p, Inta_ManAigRead(p, pFinal), Inta_ManAigRead(p, pReason), VarAB );
+ else
+ Inta_ManAigMux1( p, Inta_ManAigRead(p, pFinal), Inta_ManAigRead(p, pReason), VarAB );
+ }
+ }
+
+ // resolve the temporary resolvent with the reason clause
+ if ( p->fProofVerif )
+ {
+ int v1, v2;
+ if ( fPrint )
+ Inta_ManPrintResolvent( p->pResLits, p->nResLits );
+ // check that the var is present in the resolvent
+ for ( v1 = 0; v1 < p->nResLits; v1++ )
+ if ( lit_var(p->pResLits[v1]) == Var )
+ break;
+ if ( v1 == p->nResLits )
+ printf( "Recording clause %d: Cannot find variable %d in the temporary resolvent.\n", pFinal->Id, Var );
+ if ( p->pResLits[v1] != lit_neg(pReason->pLits[0]) )
+ printf( "Recording clause %d: The resolved variable %d is in the wrong polarity.\n", pFinal->Id, Var );
+ // remove this variable from the resolvent
+ assert( lit_var(p->pResLits[v1]) == Var );
+ p->nResLits--;
+ for ( ; v1 < p->nResLits; v1++ )
+ p->pResLits[v1] = p->pResLits[v1+1];
+ // add variables of the reason clause
+ for ( v2 = 1; v2 < (int)pReason->nLits; v2++ )
+ {
+ for ( v1 = 0; v1 < p->nResLits; v1++ )
+ if ( lit_var(p->pResLits[v1]) == lit_var(pReason->pLits[v2]) )
+ break;
+ // if it is a new variable, add it to the resolvent
+ if ( v1 == p->nResLits )
+ {
+ if ( p->nResLits == p->nResLitsAlloc )
+ printf( "Recording clause %d: Ran out of space for intermediate resolvent.\n", pFinal->Id );
+ p->pResLits[ p->nResLits++ ] = pReason->pLits[v2];
+ continue;
+ }
+ // if the variable is the same, the literal should be the same too
+ if ( p->pResLits[v1] == pReason->pLits[v2] )
+ continue;
+ // the literal is different
+ printf( "Recording clause %d: Trying to resolve the clause with more than one opposite literal.\n", pFinal->Id );
+ }
+ }
+
+// Vec_PtrPush( pFinal->pAntis, pReason );
+ }
+
+ // unmark all seen variables
+// for ( i = p->nTrailSize - 1; i >= 0; i-- )
+// p->pSeens[lit_var(p->pTrail[i])] = 0;
+ // check that the literals are unmarked
+// for ( i = p->nTrailSize - 1; i >= 0; i-- )
+// assert( p->pSeens[lit_var(p->pTrail[i])] == 0 );
+
+ // use the resulting clause to check the correctness of resolution
+ if ( p->fProofVerif )
+ {
+ int v1, v2;
+ if ( fPrint )
+ Inta_ManPrintResolvent( p->pResLits, p->nResLits );
+ for ( v1 = 0; v1 < p->nResLits; v1++ )
+ {
+ for ( v2 = 0; v2 < (int)pFinal->nLits; v2++ )
+ if ( pFinal->pLits[v2] == p->pResLits[v1] )
+ break;
+ if ( v2 < (int)pFinal->nLits )
+ continue;
+ break;
+ }
+ if ( v1 < p->nResLits )
+ {
+ printf( "Recording clause %d: The final resolvent is wrong.\n", pFinal->Id );
+ Inta_ManPrintClause( p, pConflict );
+ Inta_ManPrintResolvent( p->pResLits, p->nResLits );
+ Inta_ManPrintClause( p, pFinal );
+ }
+ }
+p->timeTrace += clock() - clk;
+
+ // return the proof pointer
+ if ( p->pCnf->nClausesA )
+ {
+// Inta_ManPrintInterOne( p, pFinal );
+ }
+ Inta_ManProofSet( p, pFinal, p->Counter );
+ return p->Counter;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Records the proof for one clause.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Inta_ManProofRecordOne( Inta_Man_t * p, Sto_Cls_t * pClause )
+{
+ Sto_Cls_t * pConflict;
+ int i;
+
+ // empty clause never ends up there
+ assert( pClause->nLits > 0 );
+ if ( pClause->nLits == 0 )
+ printf( "Error: Empty clause is attempted.\n" );
+
+ // add assumptions to the trail
+ assert( !pClause->fRoot );
+ assert( p->nTrailSize == p->nRootSize );
+ for ( i = 0; i < (int)pClause->nLits; i++ )
+ if ( !Inta_ManEnqueue( p, lit_neg(pClause->pLits[i]), NULL ) )
+ {
+ assert( 0 ); // impossible
+ return 0;
+ }
+
+ // propagate the assumptions
+ pConflict = Inta_ManPropagate( p, p->nRootSize );
+ if ( pConflict == NULL )
+ {
+ assert( 0 ); // cannot prove
+ return 0;
+ }
+
+ // construct the proof
+ Inta_ManProofTraceOne( p, pConflict, pClause );
+
+ // undo to the root level
+ Inta_ManCancelUntil( p, p->nRootSize );
+
+ // add large clauses to the watched lists
+ if ( pClause->nLits > 1 )
+ {
+ Inta_ManWatchClause( p, pClause, pClause->pLits[0] );
+ Inta_ManWatchClause( p, pClause, pClause->pLits[1] );
+ return 1;
+ }
+ assert( pClause->nLits == 1 );
+
+ // if the clause proved is unit, add it and propagate
+ if ( !Inta_ManEnqueue( p, pClause->pLits[0], pClause ) )
+ {
+ assert( 0 ); // impossible
+ return 0;
+ }
+
+ // propagate the assumption
+ pConflict = Inta_ManPropagate( p, p->nRootSize );
+ if ( pConflict )
+ {
+ // construct the proof
+ Inta_ManProofTraceOne( p, pConflict, p->pCnf->pEmpty );
+// if ( p->fVerbose )
+// printf( "Found last conflict after adding unit clause number %d!\n", pClause->Id );
+ return 0;
+ }
+
+ // update the root level
+ p->nRootSize = p->nTrailSize;
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Propagate the root clauses.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Inta_ManProcessRoots( Inta_Man_t * p )
+{
+ Sto_Cls_t * pClause;
+ int Counter;
+
+ // make sure the root clauses are preceeding the learnt clauses
+ Counter = 0;
+ Sto_ManForEachClause( p->pCnf, pClause )
+ {
+ assert( (int)pClause->fA == (Counter < (int)p->pCnf->nClausesA) );
+ assert( (int)pClause->fRoot == (Counter < (int)p->pCnf->nRoots) );
+ Counter++;
+ }
+ assert( p->pCnf->nClauses == Counter );
+
+ // make sure the last clause if empty
+ assert( p->pCnf->pTail->nLits == 0 );
+
+ // go through the root unit clauses
+ p->nTrailSize = 0;
+ Sto_ManForEachClauseRoot( p->pCnf, pClause )
+ {
+ // create watcher lists for the root clauses
+ if ( pClause->nLits > 1 )
+ {
+ Inta_ManWatchClause( p, pClause, pClause->pLits[0] );
+ Inta_ManWatchClause( p, pClause, pClause->pLits[1] );
+ }
+ // empty clause and large clauses
+ if ( pClause->nLits != 1 )
+ continue;
+ // unit clause
+ assert( lit_check(pClause->pLits[0], p->pCnf->nVars) );
+ if ( !Inta_ManEnqueue( p, pClause->pLits[0], pClause ) )
+ {
+ // detected root level conflict
+ printf( "Error in Inta_ManProcessRoots(): Detected a root-level conflict too early!\n" );
+ assert( 0 );
+ return 0;
+ }
+ }
+
+ // propagate the root unit clauses
+ pClause = Inta_ManPropagate( p, 0 );
+ if ( pClause )
+ {
+ // detected root level conflict
+ Inta_ManProofTraceOne( p, pClause, p->pCnf->pEmpty );
+ if ( p->fVerbose )
+ printf( "Found root level conflict!\n" );
+ return 0;
+ }
+
+ // set the root level
+ p->nRootSize = p->nTrailSize;
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Records the proof.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Inta_ManPrepareInter( Inta_Man_t * p )
+{
+ Sto_Cls_t * pClause;
+ int Var, VarAB, v;
+
+ // set interpolants for root clauses
+ Sto_ManForEachClauseRoot( p->pCnf, pClause )
+ {
+ if ( !pClause->fA ) // clause of B
+ {
+ Inta_ManAigFill( p, Inta_ManAigRead(p, pClause) );
+// Inta_ManPrintInterOne( p, pClause );
+ continue;
+ }
+ // clause of A
+ Inta_ManAigClear( p, Inta_ManAigRead(p, pClause) );
+
+ for ( v = 0; v < (int)pClause->nLits; v++ )
+ {
+ Var = lit_var(pClause->pLits[v]);
+ if ( p->pVarTypes[Var] < 0 ) // global var
+ {
+ VarAB = -p->pVarTypes[Var]-1;
+ assert( VarAB >= 0 && VarAB < Vec_IntSize(p->vVarsAB) );
+ if ( lit_sign(pClause->pLits[v]) ) // negative var
+ Inta_ManAigOrNotVar( p, Inta_ManAigRead(p, pClause), VarAB );
+ else
+ Inta_ManAigOrVar( p, Inta_ManAigRead(p, pClause), VarAB );
+ }
+ }
+
+// Inta_ManPrintInterOne( p, pClause );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes interpolant for the given CNF.]
+
+ Description [Takes the interpolation manager, the CNF deriving by the SAT
+ solver, which includes ClausesA, ClausesB, and learned clauses. Additional
+ arguments are the vector of variables common to AB and the verbosiness flag.
+ Returns the AIG manager with a single output, containing the interpolant.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void * Inta_ManInterpolate( Inta_Man_t * p, Sto_Man_t * pCnf, void * vVarsAB, int fVerbose )
+{
+ Aig_Man_t * pRes;
+ Aig_Obj_t * pObj;
+ Sto_Cls_t * pClause;
+ int RetValue = 1;
+ int clkTotal = clock();
+
+ // check that the CNF makes sense
+ assert( pCnf->nVars > 0 && pCnf->nClauses > 0 );
+ p->pCnf = pCnf;
+ p->fVerbose = fVerbose;
+ p->vVarsAB = vVarsAB;
+ p->pAig = pRes = Aig_ManStart( 10000 );
+ Aig_IthVar( p->pAig, Vec_IntSize(p->vVarsAB) - 1 );
+
+ // adjust the manager
+ Inta_ManResize( p );
+
+ // prepare the interpolant computation
+ Inta_ManPrepareInter( p );
+
+ // construct proof for each clause
+ // start the proof
+ if ( p->fProofWrite )
+ {
+ p->pFile = fopen( "proof.cnf_", "w" );
+ p->Counter = 0;
+ }
+
+ // write the root clauses
+ Sto_ManForEachClauseRoot( p->pCnf, pClause )
+ Inta_ManProofWriteOne( p, pClause );
+
+ // propagate root level assignments
+ if ( Inta_ManProcessRoots( p ) )
+ {
+ // if there is no conflict, consider learned clauses
+ Sto_ManForEachClause( p->pCnf, pClause )
+ {
+ if ( pClause->fRoot )
+ continue;
+ if ( !Inta_ManProofRecordOne( p, pClause ) )
+ {
+ RetValue = 0;
+ break;
+ }
+ }
+ }
+
+ // stop the proof
+ if ( p->fProofWrite )
+ {
+ fclose( p->pFile );
+ p->pFile = NULL;
+ }
+
+ if ( fVerbose )
+ {
+// ABC_PRT( "Interpo", clock() - clkTotal );
+ printf( "Vars = %d. Roots = %d. Learned = %d. Resol steps = %d. Ave = %.2f. Mem = %.2f Mb\n",
+ p->pCnf->nVars, p->pCnf->nRoots, p->pCnf->nClauses-p->pCnf->nRoots, p->Counter,
+ 1.0*(p->Counter-p->pCnf->nRoots)/(p->pCnf->nClauses-p->pCnf->nRoots),
+ 1.0*Sto_ManMemoryReport(p->pCnf)/(1<<20) );
+p->timeTotal += clock() - clkTotal;
+ }
+
+ pObj = *Inta_ManAigRead( p, p->pCnf->pTail );
+ Aig_ObjCreatePo( pRes, pObj );
+ Aig_ManCleanup( pRes );
+
+ p->pAig = NULL;
+ return pRes;
+
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Man_t * Inta_ManDeriveClauses( Inta_Man_t * pMan, Sto_Man_t * pCnf, int fClausesA )
+{
+ Aig_Man_t * p;
+ Aig_Obj_t * pMiter, * pSum, * pLit;
+ Sto_Cls_t * pClause;
+ int Var, VarAB, v;
+ p = Aig_ManStart( 10000 );
+ pMiter = Aig_ManConst1(p);
+ Sto_ManForEachClauseRoot( pCnf, pClause )
+ {
+ if ( fClausesA ^ pClause->fA ) // clause of B
+ continue;
+ // clause of A
+ pSum = Aig_ManConst0(p);
+ for ( v = 0; v < (int)pClause->nLits; v++ )
+ {
+ Var = lit_var(pClause->pLits[v]);
+ if ( pMan->pVarTypes[Var] < 0 ) // global var
+ {
+ VarAB = -pMan->pVarTypes[Var]-1;
+ assert( VarAB >= 0 && VarAB < Vec_IntSize(pMan->vVarsAB) );
+ pLit = Aig_NotCond( Aig_IthVar(p, VarAB), lit_sign(pClause->pLits[v]) );
+ }
+ else
+ pLit = Aig_NotCond( Aig_IthVar(p, Vec_IntSize(pMan->vVarsAB)+1+Var), lit_sign(pClause->pLits[v]) );
+ pSum = Aig_Or( p, pSum, pLit );
+ }
+ pMiter = Aig_And( p, pMiter, pSum );
+ }
+ Aig_ObjCreatePo( p, pMiter );
+ return p;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/bsat/satInterB_new.c b/src/sat/bsat/satInterB_new.c
new file mode 100644
index 00000000..f6f54c8c
--- /dev/null
+++ b/src/sat/bsat/satInterB_new.c
@@ -0,0 +1,1115 @@
+/**CFile****************************************************************
+
+ FileName [satInter.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [SAT sat_solver.]
+
+ Synopsis [Interpolation package.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: satInter.c,v 1.4 2005/09/16 22:55:03 casem Exp $]
+
+***********************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <time.h>
+#include "satStore.h"
+#include "aig.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+// variable assignments
+static const lit LIT_UNDEF = 0xffffffff;
+
+// interpolation manager
+struct Intb_Man_t_
+{
+ // clauses of the problems
+ Sto_Man_t * pCnf; // the set of CNF clauses for A and B
+ Vec_Int_t * vVarsAB; // the array of global variables
+ // various parameters
+ int fVerbose; // verbosiness flag
+ int fProofVerif; // verifies the proof
+ int fProofWrite; // writes the proof file
+ int nVarsAlloc; // the allocated size of var arrays
+ int nClosAlloc; // the allocated size of clause arrays
+ // internal BCP
+ int nRootSize; // the number of root level assignments
+ int nTrailSize; // the number of assignments made
+ lit * pTrail; // chronological order of assignments (size nVars)
+ lit * pAssigns; // assignments by variable (size nVars)
+ char * pSeens; // temporary mark (size nVars)
+ Sto_Cls_t ** pReasons; // reasons for each assignment (size nVars)
+ Sto_Cls_t ** pWatches; // watched clauses for each literal (size 2*nVars)
+ // interpolation data
+ Aig_Man_t * pAig; // the AIG manager for recording the interpolant
+ int * pVarTypes; // variable type (size nVars) [1=A, 0=B, <0=AB]
+ Aig_Obj_t ** pInters; // storage for interpolants as truth tables (size nClauses)
+ int nIntersAlloc; // the allocated size of truth table array
+ // proof recording
+ int Counter; // counter of resolved clauses
+ int * pProofNums; // the proof numbers for each clause (size nClauses)
+ FILE * pFile; // the file for proof recording
+ // internal verification
+ lit * pResLits; // the literals of the resolvent
+ int nResLits; // the number of literals of the resolvent
+ int nResLitsAlloc;// the number of literals of the resolvent
+ // runtime stats
+ int timeBcp; // the runtime for BCP
+ int timeTrace; // the runtime of trace construction
+ int timeTotal; // the total runtime of interpolation
+};
+
+// procedure to get hold of the clauses' truth table
+static inline Aig_Obj_t ** Intb_ManAigRead( Intb_Man_t * pMan, Sto_Cls_t * pCls ) { return pMan->pInters + pCls->Id; }
+static inline void Intb_ManAigClear( Intb_Man_t * pMan, Aig_Obj_t ** p ) { *p = Aig_ManConst0(pMan->pAig); }
+static inline void Intb_ManAigFill( Intb_Man_t * pMan, Aig_Obj_t ** p ) { *p = Aig_ManConst1(pMan->pAig); }
+static inline void Intb_ManAigCopy( Intb_Man_t * pMan, Aig_Obj_t ** p, Aig_Obj_t ** q ) { *p = *q; }
+static inline void Intb_ManAigAnd( Intb_Man_t * pMan, Aig_Obj_t ** p, Aig_Obj_t ** q ) { *p = Aig_And(pMan->pAig, *p, *q); }
+static inline void Intb_ManAigOr( Intb_Man_t * pMan, Aig_Obj_t ** p, Aig_Obj_t ** q ) { *p = Aig_Or(pMan->pAig, *p, *q); }
+static inline void Intb_ManAigOrNot( Intb_Man_t * pMan, Aig_Obj_t ** p, Aig_Obj_t ** q ) { *p = Aig_Or(pMan->pAig, *p, Aig_Not(*q)); }
+static inline void Intb_ManAigOrVar( Intb_Man_t * pMan, Aig_Obj_t ** p, int v ) { *p = Aig_Or(pMan->pAig, *p, Aig_IthVar(pMan->pAig, v)); }
+static inline void Intb_ManAigOrNotVar( Intb_Man_t * pMan, Aig_Obj_t ** p, int v ) { *p = Aig_Or(pMan->pAig, *p, Aig_Not(Aig_IthVar(pMan->pAig, v))); }
+static inline void Intb_ManAigMux0( Intb_Man_t * pMan, Aig_Obj_t ** p, Aig_Obj_t ** q, int v){ *p = Aig_Mux(pMan->pAig, Aig_IthVar(pMan->pAig, v), *q, *p); }
+static inline void Intb_ManAigMux1( Intb_Man_t * pMan, Aig_Obj_t ** p, Aig_Obj_t ** q, int v){ *p = Aig_Mux(pMan->pAig, Aig_IthVar(pMan->pAig, v), *p, *q); }
+
+// reading/writing the proof for a clause
+static inline int Intb_ManProofGet( Intb_Man_t * p, Sto_Cls_t * pCls ) { return p->pProofNums[pCls->Id]; }
+static inline void Intb_ManProofSet( Intb_Man_t * p, Sto_Cls_t * pCls, int n ) { p->pProofNums[pCls->Id] = n; }
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Allocate proof manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Intb_Man_t * Intb_ManAlloc()
+{
+ Intb_Man_t * p;
+ // allocate the manager
+ p = (Intb_Man_t *)ABC_ALLOC( char, sizeof(Intb_Man_t) );
+ memset( p, 0, sizeof(Intb_Man_t) );
+ // verification
+ p->nResLitsAlloc = (1<<16);
+ p->pResLits = ABC_ALLOC( lit, p->nResLitsAlloc );
+ // parameters
+ p->fProofWrite = 0;
+ p->fProofVerif = 1;
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Count common variables in the clauses of A and B.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Intb_ManGlobalVars( Intb_Man_t * p )
+{
+ Sto_Cls_t * pClause;
+ int LargeNum = -100000000;
+ int Var, nVarsAB, v;
+
+ // mark the variable encountered in the clauses of A
+ Sto_ManForEachClauseRoot( p->pCnf, pClause )
+ {
+ if ( !pClause->fA )
+ break;
+ for ( v = 0; v < (int)pClause->nLits; v++ )
+ p->pVarTypes[lit_var(pClause->pLits[v])] = 1;
+ }
+
+ // check variables that appear in clauses of B
+ nVarsAB = 0;
+ Sto_ManForEachClauseRoot( p->pCnf, pClause )
+ {
+ if ( pClause->fA )
+ continue;
+ for ( v = 0; v < (int)pClause->nLits; v++ )
+ {
+ Var = lit_var(pClause->pLits[v]);
+ if ( p->pVarTypes[Var] == 1 ) // var of A
+ {
+ // change it into a global variable
+ nVarsAB++;
+ p->pVarTypes[Var] = LargeNum;
+ }
+ }
+ }
+ assert( nVarsAB <= Vec_IntSize(p->vVarsAB) );
+
+ // order global variables
+ nVarsAB = 0;
+ Vec_IntForEachEntry( p->vVarsAB, Var, v )
+ p->pVarTypes[Var] = -(1+nVarsAB++);
+
+ // check that there is no extra global variables
+ for ( v = 0; v < p->pCnf->nVars; v++ )
+ assert( p->pVarTypes[v] != LargeNum );
+ return nVarsAB;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Resize proof manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Intb_ManResize( Intb_Man_t * p )
+{
+ p->Counter = 0;
+ // check if resizing is needed
+ if ( p->nVarsAlloc < p->pCnf->nVars )
+ {
+ // find the new size
+ if ( p->nVarsAlloc == 0 )
+ p->nVarsAlloc = 1;
+ while ( p->nVarsAlloc < p->pCnf->nVars )
+ p->nVarsAlloc *= 2;
+ // resize the arrays
+ p->pTrail = ABC_REALLOC(lit, p->pTrail, p->nVarsAlloc );
+ p->pAssigns = ABC_REALLOC(lit, p->pAssigns, p->nVarsAlloc );
+ p->pSeens = ABC_REALLOC(char, p->pSeens, p->nVarsAlloc );
+ p->pVarTypes = ABC_REALLOC(int, p->pVarTypes, p->nVarsAlloc );
+ p->pReasons = ABC_REALLOC(Sto_Cls_t *, p->pReasons, p->nVarsAlloc );
+ p->pWatches = ABC_REALLOC(Sto_Cls_t *, p->pWatches, p->nVarsAlloc*2 );
+ }
+
+ // clean the free space
+ memset( p->pAssigns , 0xff, sizeof(lit) * p->pCnf->nVars );
+ memset( p->pSeens , 0, sizeof(char) * p->pCnf->nVars );
+ memset( p->pVarTypes, 0, sizeof(int) * p->pCnf->nVars );
+ memset( p->pReasons , 0, sizeof(Sto_Cls_t *) * p->pCnf->nVars );
+ memset( p->pWatches , 0, sizeof(Sto_Cls_t *) * p->pCnf->nVars*2 );
+
+ // compute the number of common variables
+ Intb_ManGlobalVars( p );
+
+ // check if resizing of clauses is needed
+ if ( p->nClosAlloc < p->pCnf->nClauses )
+ {
+ // find the new size
+ if ( p->nClosAlloc == 0 )
+ p->nClosAlloc = 1;
+ while ( p->nClosAlloc < p->pCnf->nClauses )
+ p->nClosAlloc *= 2;
+ // resize the arrays
+ p->pProofNums = ABC_REALLOC( int, p->pProofNums, p->nClosAlloc );
+ }
+ memset( p->pProofNums, 0, sizeof(int) * p->pCnf->nClauses );
+
+ // check if resizing of truth tables is needed
+ if ( p->nIntersAlloc < p->pCnf->nClauses )
+ {
+ p->nIntersAlloc = p->pCnf->nClauses;
+ p->pInters = ABC_REALLOC( Aig_Obj_t *, p->pInters, p->nIntersAlloc );
+ }
+ memset( p->pInters, 0, sizeof(Aig_Obj_t *) * p->pCnf->nClauses );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Deallocate proof manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Intb_ManFree( Intb_Man_t * p )
+{
+/*
+ printf( "Runtime stats:\n" );
+ABC_PRT( "BCP ", p->timeBcp );
+ABC_PRT( "Trace ", p->timeTrace );
+ABC_PRT( "TOTAL ", p->timeTotal );
+*/
+ ABC_FREE( p->pInters );
+ ABC_FREE( p->pProofNums );
+ ABC_FREE( p->pTrail );
+ ABC_FREE( p->pAssigns );
+ ABC_FREE( p->pSeens );
+ ABC_FREE( p->pVarTypes );
+ ABC_FREE( p->pReasons );
+ ABC_FREE( p->pWatches );
+ ABC_FREE( p->pResLits );
+ ABC_FREE( p );
+}
+
+
+
+
+/**Function*************************************************************
+
+ Synopsis [Prints the clause.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Intb_ManPrintClause( Intb_Man_t * p, Sto_Cls_t * pClause )
+{
+ int i;
+ printf( "Clause ID = %d. Proof = %d. {", pClause->Id, Intb_ManProofGet(p, pClause) );
+ for ( i = 0; i < (int)pClause->nLits; i++ )
+ printf( " %d", pClause->pLits[i] );
+ printf( " }\n" );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Prints the resolvent.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Intb_ManPrintResolvent( lit * pResLits, int nResLits )
+{
+ int i;
+ printf( "Resolvent: {" );
+ for ( i = 0; i < nResLits; i++ )
+ printf( " %d", pResLits[i] );
+ printf( " }\n" );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Prints the interpolant for one clause.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Intb_ManPrintInterOne( Intb_Man_t * p, Sto_Cls_t * pClause )
+{
+ printf( "Clause %2d : ", pClause->Id );
+// Extra_PrintBinary___( stdout, Intb_ManAigRead(p, pClause), (1 << p->nVarsAB) );
+ printf( "\n" );
+}
+
+
+
+/**Function*************************************************************
+
+ Synopsis [Adds one clause to the watcher list.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Intb_ManWatchClause( Intb_Man_t * p, Sto_Cls_t * pClause, lit Lit )
+{
+ assert( lit_check(Lit, p->pCnf->nVars) );
+ if ( pClause->pLits[0] == Lit )
+ pClause->pNext0 = p->pWatches[lit_neg(Lit)];
+ else
+ {
+ assert( pClause->pLits[1] == Lit );
+ pClause->pNext1 = p->pWatches[lit_neg(Lit)];
+ }
+ p->pWatches[lit_neg(Lit)] = pClause;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Records implication.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Intb_ManEnqueue( Intb_Man_t * p, lit Lit, Sto_Cls_t * pReason )
+{
+ int Var = lit_var(Lit);
+ if ( p->pAssigns[Var] != LIT_UNDEF )
+ return p->pAssigns[Var] == Lit;
+ p->pAssigns[Var] = Lit;
+ p->pReasons[Var] = pReason;
+ p->pTrail[p->nTrailSize++] = Lit;
+//printf( "assigning var %d value %d\n", Var, !lit_sign(Lit) );
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Records implication.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Intb_ManCancelUntil( Intb_Man_t * p, int Level )
+{
+ lit Lit;
+ int i, Var;
+ for ( i = p->nTrailSize - 1; i >= Level; i-- )
+ {
+ Lit = p->pTrail[i];
+ Var = lit_var( Lit );
+ p->pReasons[Var] = NULL;
+ p->pAssigns[Var] = LIT_UNDEF;
+//printf( "cancelling var %d\n", Var );
+ }
+ p->nTrailSize = Level;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Propagate one assignment.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline Sto_Cls_t * Intb_ManPropagateOne( Intb_Man_t * p, lit Lit )
+{
+ Sto_Cls_t ** ppPrev, * pCur, * pTemp;
+ lit LitF = lit_neg(Lit);
+ int i;
+ // iterate through the literals
+ ppPrev = p->pWatches + Lit;
+ for ( pCur = p->pWatches[Lit]; pCur; pCur = *ppPrev )
+ {
+ // make sure the false literal is in the second literal of the clause
+ if ( pCur->pLits[0] == LitF )
+ {
+ pCur->pLits[0] = pCur->pLits[1];
+ pCur->pLits[1] = LitF;
+ pTemp = pCur->pNext0;
+ pCur->pNext0 = pCur->pNext1;
+ pCur->pNext1 = pTemp;
+ }
+ assert( pCur->pLits[1] == LitF );
+
+ // if the first literal is true, the clause is satisfied
+ if ( pCur->pLits[0] == p->pAssigns[lit_var(pCur->pLits[0])] )
+ {
+ ppPrev = &pCur->pNext1;
+ continue;
+ }
+
+ // look for a new literal to watch
+ for ( i = 2; i < (int)pCur->nLits; i++ )
+ {
+ // skip the case when the literal is false
+ if ( lit_neg(pCur->pLits[i]) == p->pAssigns[lit_var(pCur->pLits[i])] )
+ continue;
+ // the literal is either true or unassigned - watch it
+ pCur->pLits[1] = pCur->pLits[i];
+ pCur->pLits[i] = LitF;
+ // remove this clause from the watch list of Lit
+ *ppPrev = pCur->pNext1;
+ // add this clause to the watch list of pCur->pLits[i] (now it is pCur->pLits[1])
+ Intb_ManWatchClause( p, pCur, pCur->pLits[1] );
+ break;
+ }
+ if ( i < (int)pCur->nLits ) // found new watch
+ continue;
+
+ // clause is unit - enqueue new implication
+ if ( Intb_ManEnqueue(p, pCur->pLits[0], pCur) )
+ {
+ ppPrev = &pCur->pNext1;
+ continue;
+ }
+
+ // conflict detected - return the conflict clause
+ return pCur;
+ }
+ return NULL;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Propagate the current assignments.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Sto_Cls_t * Intb_ManPropagate( Intb_Man_t * p, int Start )
+{
+ Sto_Cls_t * pClause;
+ int i;
+ int clk = clock();
+ for ( i = Start; i < p->nTrailSize; i++ )
+ {
+ pClause = Intb_ManPropagateOne( p, p->pTrail[i] );
+ if ( pClause )
+ {
+p->timeBcp += clock() - clk;
+ return pClause;
+ }
+ }
+p->timeBcp += clock() - clk;
+ return NULL;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Writes one root clause into a file.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Intb_ManProofWriteOne( Intb_Man_t * p, Sto_Cls_t * pClause )
+{
+ Intb_ManProofSet( p, pClause, ++p->Counter );
+
+ if ( p->fProofWrite )
+ {
+ int v;
+ fprintf( p->pFile, "%d", Intb_ManProofGet(p, pClause) );
+ for ( v = 0; v < (int)pClause->nLits; v++ )
+ fprintf( p->pFile, " %d", lit_print(pClause->pLits[v]) );
+ fprintf( p->pFile, " 0 0\n" );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Traces the proof for one clause.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Intb_ManGetGlobalVar( Intb_Man_t * p, int Var )
+{
+ int VarAB;
+ if ( p->pVarTypes[Var] >= 0 ) // global var
+ return -1;
+ VarAB = -p->pVarTypes[Var]-1;
+ assert( VarAB >= 0 && VarAB < Vec_IntSize(p->vVarsAB) );
+ return VarAB;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Traces the proof for one clause.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Intb_ManProofTraceOne( Intb_Man_t * p, Sto_Cls_t * pConflict, Sto_Cls_t * pFinal )
+{
+ Sto_Cls_t * pReason;
+ int i, v, Var, PrevId;
+ int fPrint = 0;
+ int clk = clock();
+
+ // collect resolvent literals
+ if ( p->fProofVerif )
+ {
+ assert( (int)pConflict->nLits <= p->nResLitsAlloc );
+ memcpy( p->pResLits, pConflict->pLits, sizeof(lit) * pConflict->nLits );
+ p->nResLits = pConflict->nLits;
+ }
+
+ // mark all the variables in the conflict as seen
+ for ( v = 0; v < (int)pConflict->nLits; v++ )
+ p->pSeens[lit_var(pConflict->pLits[v])] = 1;
+
+ // start the anticedents
+// pFinal->pAntis = Vec_PtrAlloc( 32 );
+// Vec_PtrPush( pFinal->pAntis, pConflict );
+
+ if ( p->pCnf->nClausesA )
+ Intb_ManAigCopy( p, Intb_ManAigRead(p, pFinal), Intb_ManAigRead(p, pConflict) );
+
+ // follow the trail backwards
+ PrevId = Intb_ManProofGet(p, pConflict);
+ for ( i = p->nTrailSize - 1; i >= 0; i-- )
+ {
+ // skip literals that are not involved
+ Var = lit_var(p->pTrail[i]);
+ if ( !p->pSeens[Var] )
+ continue;
+ p->pSeens[Var] = 0;
+
+ // skip literals of the resulting clause
+ pReason = p->pReasons[Var];
+ if ( pReason == NULL )
+ continue;
+ assert( p->pTrail[i] == pReason->pLits[0] );
+
+ // add the variables to seen
+ for ( v = 1; v < (int)pReason->nLits; v++ )
+ p->pSeens[lit_var(pReason->pLits[v])] = 1;
+
+ // record the reason clause
+ assert( Intb_ManProofGet(p, pReason) > 0 );
+ p->Counter++;
+ if ( p->fProofWrite )
+ fprintf( p->pFile, "%d * %d %d 0\n", p->Counter, PrevId, Intb_ManProofGet(p, pReason) );
+ PrevId = p->Counter;
+
+ if ( p->pCnf->nClausesA )
+ {
+ if ( p->pVarTypes[Var] == 1 )// || rand() % 10 == 0 ) // var of A
+ Intb_ManAigOr( p, Intb_ManAigRead(p, pFinal), Intb_ManAigRead(p, pReason) );
+ else if ( p->pVarTypes[Var] == 0 ) // var of B
+ Intb_ManAigAnd( p, Intb_ManAigRead(p, pFinal), Intb_ManAigRead(p, pReason) );
+ else
+ {
+ int VarAB = Intb_ManGetGlobalVar(p, Var);
+ // check that the var is present in the reason
+ for ( v = 0; v < (int)pReason->nLits; v++ )
+ if ( lit_var(pReason->pLits[v]) == Var )
+ break;
+ assert( v < (int)pReason->nLits );
+ if ( lit_sign(pReason->pLits[v]) ) // negative polarity
+ Intb_ManAigMux0( p, Intb_ManAigRead(p, pFinal), Intb_ManAigRead(p, pReason), VarAB );
+ else
+ Intb_ManAigMux1( p, Intb_ManAigRead(p, pFinal), Intb_ManAigRead(p, pReason), VarAB );
+ }
+ }
+
+ // resolve the temporary resolvent with the reason clause
+ if ( p->fProofVerif )
+ {
+ int v1, v2;
+ if ( fPrint )
+ Intb_ManPrintResolvent( p->pResLits, p->nResLits );
+ // check that the var is present in the resolvent
+ for ( v1 = 0; v1 < p->nResLits; v1++ )
+ if ( lit_var(p->pResLits[v1]) == Var )
+ break;
+ if ( v1 == p->nResLits )
+ printf( "Recording clause %d: Cannot find variable %d in the temporary resolvent.\n", pFinal->Id, Var );
+ if ( p->pResLits[v1] != lit_neg(pReason->pLits[0]) )
+ printf( "Recording clause %d: The resolved variable %d is in the wrong polarity.\n", pFinal->Id, Var );
+ // remove this variable from the resolvent
+ assert( lit_var(p->pResLits[v1]) == Var );
+ p->nResLits--;
+ for ( ; v1 < p->nResLits; v1++ )
+ p->pResLits[v1] = p->pResLits[v1+1];
+ // add variables of the reason clause
+ for ( v2 = 1; v2 < (int)pReason->nLits; v2++ )
+ {
+ for ( v1 = 0; v1 < p->nResLits; v1++ )
+ if ( lit_var(p->pResLits[v1]) == lit_var(pReason->pLits[v2]) )
+ break;
+ // if it is a new variable, add it to the resolvent
+ if ( v1 == p->nResLits )
+ {
+ if ( p->nResLits == p->nResLitsAlloc )
+ printf( "Recording clause %d: Ran out of space for intermediate resolvent.\n", pFinal->Id );
+ p->pResLits[ p->nResLits++ ] = pReason->pLits[v2];
+ continue;
+ }
+ // if the variable is the same, the literal should be the same too
+ if ( p->pResLits[v1] == pReason->pLits[v2] )
+ continue;
+ // the literal is different
+ printf( "Recording clause %d: Trying to resolve the clause with more than one opposite literal.\n", pFinal->Id );
+ }
+ }
+// Vec_PtrPush( pFinal->pAntis, pReason );
+ }
+
+ // unmark all seen variables
+// for ( i = p->nTrailSize - 1; i >= 0; i-- )
+// p->pSeens[lit_var(p->pTrail[i])] = 0;
+ // check that the literals are unmarked
+// for ( i = p->nTrailSize - 1; i >= 0; i-- )
+// assert( p->pSeens[lit_var(p->pTrail[i])] == 0 );
+
+ // use the resulting clause to check the correctness of resolution
+ if ( p->fProofVerif )
+ {
+ int v1, v2;
+ if ( fPrint )
+ Intb_ManPrintResolvent( p->pResLits, p->nResLits );
+ for ( v1 = 0; v1 < p->nResLits; v1++ )
+ {
+ for ( v2 = 0; v2 < (int)pFinal->nLits; v2++ )
+ if ( pFinal->pLits[v2] == p->pResLits[v1] )
+ break;
+ if ( v2 < (int)pFinal->nLits )
+ continue;
+ break;
+ }
+ if ( v1 < p->nResLits )
+ {
+ printf( "Recording clause %d: The final resolvent is wrong.\n", pFinal->Id );
+ Intb_ManPrintClause( p, pConflict );
+ Intb_ManPrintResolvent( p->pResLits, p->nResLits );
+ Intb_ManPrintClause( p, pFinal );
+ }
+
+ // if there are literals in the clause that are not in the resolvent
+ // it means that the derived resolvent is stronger than the clause
+ // we can replace the clause with the resolvent by removing these literals
+ if ( p->nResLits != (int)pFinal->nLits )
+ {
+ for ( v1 = 0; v1 < (int)pFinal->nLits; v1++ )
+ {
+ for ( v2 = 0; v2 < p->nResLits; v2++ )
+ if ( pFinal->pLits[v1] == p->pResLits[v2] )
+ break;
+ if ( v2 < p->nResLits )
+ continue;
+ // remove literal v1 from the final clause
+ pFinal->nLits--;
+ for ( v2 = v1; v2 < (int)pFinal->nLits; v2++ )
+ pFinal->pLits[v2] = pFinal->pLits[v2+1];
+ v1--;
+ }
+ assert( p->nResLits == (int)pFinal->nLits );
+ }
+ }
+p->timeTrace += clock() - clk;
+
+ // return the proof pointer
+ if ( p->pCnf->nClausesA )
+ {
+// Intb_ManPrintInterOne( p, pFinal );
+ }
+ Intb_ManProofSet( p, pFinal, p->Counter );
+ // make sure the same proof ID is not asssigned to two consecutive clauses
+ assert( p->pProofNums[pFinal->Id-1] != p->Counter );
+// if ( p->pProofNums[pFinal->Id] == p->pProofNums[pFinal->Id-1] )
+// p->pProofNums[pFinal->Id] = p->pProofNums[pConflict->Id];
+ return p->Counter;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Records the proof for one clause.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Intb_ManProofRecordOne( Intb_Man_t * p, Sto_Cls_t * pClause )
+{
+ Sto_Cls_t * pConflict;
+ int i;
+
+ // empty clause never ends up there
+ assert( pClause->nLits > 0 );
+ if ( pClause->nLits == 0 )
+ printf( "Error: Empty clause is attempted.\n" );
+
+ assert( !pClause->fRoot );
+ assert( p->nTrailSize == p->nRootSize );
+
+ // if any of the clause literals are already assumed
+ // it means that the clause is redundant and can be skipped
+ for ( i = 0; i < (int)pClause->nLits; i++ )
+ if ( p->pAssigns[lit_var(pClause->pLits[i])] == pClause->pLits[i] )
+ return 1;
+
+ // add assumptions to the trail
+ for ( i = 0; i < (int)pClause->nLits; i++ )
+ if ( !Intb_ManEnqueue( p, lit_neg(pClause->pLits[i]), NULL ) )
+ {
+ assert( 0 ); // impossible
+ return 0;
+ }
+
+ // propagate the assumptions
+ pConflict = Intb_ManPropagate( p, p->nRootSize );
+ if ( pConflict == NULL )
+ {
+ assert( 0 ); // cannot prove
+ return 0;
+ }
+
+ // skip the clause if it is weaker or the same as the conflict clause
+ if ( pClause->nLits >= pConflict->nLits )
+ {
+ // check if every literal of conflict clause can be found in the given clause
+ int j;
+ for ( i = 0; i < (int)pConflict->nLits; i++ )
+ {
+ for ( j = 0; j < (int)pClause->nLits; j++ )
+ if ( pConflict->pLits[i] == pClause->pLits[j] )
+ break;
+ if ( j == (int)pClause->nLits ) // literal pConflict->pLits[i] is not found
+ break;
+ }
+ if ( i == (int)pConflict->nLits ) // all lits are found
+ {
+ // undo to the root level
+ Intb_ManCancelUntil( p, p->nRootSize );
+ return 1;
+ }
+ }
+
+ // construct the proof
+ Intb_ManProofTraceOne( p, pConflict, pClause );
+
+ // undo to the root level
+ Intb_ManCancelUntil( p, p->nRootSize );
+
+ // add large clauses to the watched lists
+ if ( pClause->nLits > 1 )
+ {
+ Intb_ManWatchClause( p, pClause, pClause->pLits[0] );
+ Intb_ManWatchClause( p, pClause, pClause->pLits[1] );
+ return 1;
+ }
+ assert( pClause->nLits == 1 );
+
+ // if the clause proved is unit, add it and propagate
+ if ( !Intb_ManEnqueue( p, pClause->pLits[0], pClause ) )
+ {
+ assert( 0 ); // impossible
+ return 0;
+ }
+
+ // propagate the assumption
+ pConflict = Intb_ManPropagate( p, p->nRootSize );
+ if ( pConflict )
+ {
+ // construct the proof
+ Intb_ManProofTraceOne( p, pConflict, p->pCnf->pEmpty );
+// if ( p->fVerbose )
+// printf( "Found last conflict after adding unit clause number %d!\n", pClause->Id );
+ return 0;
+ }
+
+ // update the root level
+ p->nRootSize = p->nTrailSize;
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Propagate the root clauses.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Intb_ManProcessRoots( Intb_Man_t * p )
+{
+ Sto_Cls_t * pClause;
+ int Counter;
+
+ // make sure the root clauses are preceeding the learnt clauses
+ Counter = 0;
+ Sto_ManForEachClause( p->pCnf, pClause )
+ {
+ assert( (int)pClause->fA == (Counter < (int)p->pCnf->nClausesA) );
+ assert( (int)pClause->fRoot == (Counter < (int)p->pCnf->nRoots) );
+ Counter++;
+ }
+ assert( p->pCnf->nClauses == Counter );
+
+ // make sure the last clause if empty
+ assert( p->pCnf->pTail->nLits == 0 );
+
+ // go through the root unit clauses
+ p->nTrailSize = 0;
+ Sto_ManForEachClauseRoot( p->pCnf, pClause )
+ {
+ // create watcher lists for the root clauses
+ if ( pClause->nLits > 1 )
+ {
+ Intb_ManWatchClause( p, pClause, pClause->pLits[0] );
+ Intb_ManWatchClause( p, pClause, pClause->pLits[1] );
+ }
+ // empty clause and large clauses
+ if ( pClause->nLits != 1 )
+ continue;
+ // unit clause
+ assert( lit_check(pClause->pLits[0], p->pCnf->nVars) );
+ if ( !Intb_ManEnqueue( p, pClause->pLits[0], pClause ) )
+ {
+ // detected root level conflict
+// printf( "Error in Intb_ManProcessRoots(): Detected a root-level conflict too early!\n" );
+// assert( 0 );
+ // detected root level conflict
+ Intb_ManProofTraceOne( p, pClause, p->pCnf->pEmpty );
+ if ( p->fVerbose )
+ printf( "Found root level conflict!\n" );
+ return 0;
+ }
+ }
+
+ // propagate the root unit clauses
+ pClause = Intb_ManPropagate( p, 0 );
+ if ( pClause )
+ {
+ // detected root level conflict
+ Intb_ManProofTraceOne( p, pClause, p->pCnf->pEmpty );
+ if ( p->fVerbose )
+ printf( "Found root level conflict!\n" );
+ return 0;
+ }
+
+ // set the root level
+ p->nRootSize = p->nTrailSize;
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Records the proof.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Intb_ManPrepareInter( Intb_Man_t * p )
+{
+ Sto_Cls_t * pClause;
+ int Var, VarAB, v;
+
+ // set interpolants for root clauses
+ Sto_ManForEachClauseRoot( p->pCnf, pClause )
+ {
+ if ( !pClause->fA ) // clause of B
+ {
+ Intb_ManAigFill( p, Intb_ManAigRead(p, pClause) );
+// Intb_ManPrintInterOne( p, pClause );
+ continue;
+ }
+ // clause of A
+ Intb_ManAigClear( p, Intb_ManAigRead(p, pClause) );
+ for ( v = 0; v < (int)pClause->nLits; v++ )
+ {
+ Var = lit_var(pClause->pLits[v]);
+ if ( p->pVarTypes[Var] < 0 ) // global var
+ {
+ VarAB = -p->pVarTypes[Var]-1;
+ assert( VarAB >= 0 && VarAB < Vec_IntSize(p->vVarsAB) );
+ if ( lit_sign(pClause->pLits[v]) ) // negative var
+ Intb_ManAigOrNotVar( p, Intb_ManAigRead(p, pClause), VarAB );
+ else
+ Intb_ManAigOrVar( p, Intb_ManAigRead(p, pClause), VarAB );
+ }
+ }
+// Intb_ManPrintInterOne( p, pClause );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes interpolant for the given CNF.]
+
+ Description [Takes the interpolation manager, the CNF deriving by the SAT
+ solver, which includes ClausesA, ClausesB, and learned clauses. Additional
+ arguments are the vector of variables common to AB and the verbosiness flag.
+ Returns the AIG manager with a single output, containing the interpolant.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void * Intb_ManInterpolate( Intb_Man_t * p, Sto_Man_t * pCnf, void * vVarsAB, int fVerbose )
+{
+ Aig_Man_t * pRes;
+ Aig_Obj_t * pObj;
+ Sto_Cls_t * pClause;
+ int RetValue = 1;
+ int clkTotal = clock();
+
+ // check that the CNF makes sense
+ assert( pCnf->nVars > 0 && pCnf->nClauses > 0 );
+ p->pCnf = pCnf;
+ p->fVerbose = fVerbose;
+ p->vVarsAB = vVarsAB;
+ p->pAig = pRes = Aig_ManStart( 10000 );
+ Aig_IthVar( p->pAig, Vec_IntSize(p->vVarsAB) - 1 );
+
+ // adjust the manager
+ Intb_ManResize( p );
+
+ // prepare the interpolant computation
+ Intb_ManPrepareInter( p );
+
+ // construct proof for each clause
+ // start the proof
+ if ( p->fProofWrite )
+ {
+ p->pFile = fopen( "proof.cnf_", "w" );
+ p->Counter = 0;
+ }
+
+ // write the root clauses
+ Sto_ManForEachClauseRoot( p->pCnf, pClause )
+ Intb_ManProofWriteOne( p, pClause );
+
+ // propagate root level assignments
+ if ( Intb_ManProcessRoots( p ) )
+ {
+ // if there is no conflict, consider learned clauses
+ Sto_ManForEachClause( p->pCnf, pClause )
+ {
+ if ( pClause->fRoot )
+ continue;
+ if ( !Intb_ManProofRecordOne( p, pClause ) )
+ {
+ RetValue = 0;
+ break;
+ }
+ }
+ }
+
+ // stop the proof
+ if ( p->fProofWrite )
+ {
+ fclose( p->pFile );
+// Sat_ProofChecker( "proof.cnf_" );
+ p->pFile = NULL;
+ }
+
+ if ( fVerbose )
+ {
+// ABC_PRT( "Interpo", clock() - clkTotal );
+ printf( "Vars = %d. Roots = %d. Learned = %d. Resol steps = %d. Ave = %.2f. Mem = %.2f Mb\n",
+ p->pCnf->nVars, p->pCnf->nRoots, p->pCnf->nClauses-p->pCnf->nRoots, p->Counter,
+ 1.0*(p->Counter-p->pCnf->nRoots)/(p->pCnf->nClauses-p->pCnf->nRoots),
+ 1.0*Sto_ManMemoryReport(p->pCnf)/(1<<20) );
+p->timeTotal += clock() - clkTotal;
+ }
+
+ pObj = *Intb_ManAigRead( p, p->pCnf->pTail );
+ Aig_ObjCreatePo( pRes, pObj );
+ Aig_ManCleanup( pRes );
+
+ p->pAig = NULL;
+ return pRes;
+
+}
+
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Man_t * Intb_ManDeriveClauses( Intb_Man_t * pMan, Sto_Man_t * pCnf, int fClausesA )
+{
+ Aig_Man_t * p;
+ Aig_Obj_t * pMiter, * pSum, * pLit;
+ Sto_Cls_t * pClause;
+ int Var, VarAB, v;
+ p = Aig_ManStart( 10000 );
+ pMiter = Aig_ManConst1(p);
+ Sto_ManForEachClauseRoot( pCnf, pClause )
+ {
+ if ( fClausesA ^ pClause->fA ) // clause of B
+ continue;
+ // clause of A
+ pSum = Aig_ManConst0(p);
+ for ( v = 0; v < (int)pClause->nLits; v++ )
+ {
+ Var = lit_var(pClause->pLits[v]);
+ if ( pMan->pVarTypes[Var] < 0 ) // global var
+ {
+ VarAB = -pMan->pVarTypes[Var]-1;
+ assert( VarAB >= 0 && VarAB < Vec_IntSize(pMan->vVarsAB) );
+ pLit = Aig_NotCond( Aig_IthVar(p, VarAB), lit_sign(pClause->pLits[v]) );
+ }
+ else
+ pLit = Aig_NotCond( Aig_IthVar(p, Vec_IntSize(pMan->vVarsAB)+1+Var), lit_sign(pClause->pLits[v]) );
+ pSum = Aig_Or( p, pSum, pLit );
+ }
+ pMiter = Aig_And( p, pMiter, pSum );
+ }
+ Aig_ObjCreatePo( p, pMiter );
+ return p;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/bsat/satInterB_old.c b/src/sat/bsat/satInterB_old.c
new file mode 100644
index 00000000..2afc9855
--- /dev/null
+++ b/src/sat/bsat/satInterB_old.c
@@ -0,0 +1,1061 @@
+/**CFile****************************************************************
+
+ FileName [satInter.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [SAT sat_solver.]
+
+ Synopsis [Interpolation package.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - June 20, 2005.]
+
+ Revision [$Id: satInter.c,v 1.4 2005/09/16 22:55:03 casem Exp $]
+
+***********************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <time.h>
+#include "satStore.h"
+#include "aig.h"
+
+ABC_NAMESPACE_IMPL_START
+
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+// variable assignments
+static const lit LIT_UNDEF = 0xffffffff;
+
+// interpolation manager
+struct Intb_Man_t_
+{
+ // clauses of the problems
+ Sto_Man_t * pCnf; // the set of CNF clauses for A and B
+ Vec_Int_t * vVarsAB; // the array of global variables
+ // various parameters
+ int fVerbose; // verbosiness flag
+ int fProofVerif; // verifies the proof
+ int fProofWrite; // writes the proof file
+ int nVarsAlloc; // the allocated size of var arrays
+ int nClosAlloc; // the allocated size of clause arrays
+ // internal BCP
+ int nRootSize; // the number of root level assignments
+ int nTrailSize; // the number of assignments made
+ lit * pTrail; // chronological order of assignments (size nVars)
+ lit * pAssigns; // assignments by variable (size nVars)
+ char * pSeens; // temporary mark (size nVars)
+ Sto_Cls_t ** pReasons; // reasons for each assignment (size nVars)
+ Sto_Cls_t ** pWatches; // watched clauses for each literal (size 2*nVars)
+ // interpolation data
+ Aig_Man_t * pAig; // the AIG manager for recording the interpolant
+ int * pVarTypes; // variable type (size nVars) [1=A, 0=B, <0=AB]
+ Aig_Obj_t ** pInters; // storage for interpolants as truth tables (size nClauses)
+ int nIntersAlloc; // the allocated size of truth table array
+ // proof recording
+ int Counter; // counter of resolved clauses
+ int * pProofNums; // the proof numbers for each clause (size nClauses)
+ FILE * pFile; // the file for proof recording
+ // internal verification
+ lit * pResLits; // the literals of the resolvent
+ int nResLits; // the number of literals of the resolvent
+ int nResLitsAlloc;// the number of literals of the resolvent
+ // runtime stats
+ int timeBcp; // the runtime for BCP
+ int timeTrace; // the runtime of trace construction
+ int timeTotal; // the total runtime of interpolation
+};
+
+// procedure to get hold of the clauses' truth table
+static inline Aig_Obj_t ** Intb_ManAigRead( Intb_Man_t * pMan, Sto_Cls_t * pCls ) { return pMan->pInters + pCls->Id; }
+static inline void Intb_ManAigClear( Intb_Man_t * pMan, Aig_Obj_t ** p ) { *p = Aig_ManConst0(pMan->pAig); }
+static inline void Intb_ManAigFill( Intb_Man_t * pMan, Aig_Obj_t ** p ) { *p = Aig_ManConst1(pMan->pAig); }
+static inline void Intb_ManAigCopy( Intb_Man_t * pMan, Aig_Obj_t ** p, Aig_Obj_t ** q ) { *p = *q; }
+static inline void Intb_ManAigAnd( Intb_Man_t * pMan, Aig_Obj_t ** p, Aig_Obj_t ** q ) { *p = Aig_And(pMan->pAig, *p, *q); }
+static inline void Intb_ManAigOr( Intb_Man_t * pMan, Aig_Obj_t ** p, Aig_Obj_t ** q ) { *p = Aig_Or(pMan->pAig, *p, *q); }
+static inline void Intb_ManAigOrNot( Intb_Man_t * pMan, Aig_Obj_t ** p, Aig_Obj_t ** q ) { *p = Aig_Or(pMan->pAig, *p, Aig_Not(*q)); }
+static inline void Intb_ManAigOrVar( Intb_Man_t * pMan, Aig_Obj_t ** p, int v ) { *p = Aig_Or(pMan->pAig, *p, Aig_IthVar(pMan->pAig, v)); }
+static inline void Intb_ManAigOrNotVar( Intb_Man_t * pMan, Aig_Obj_t ** p, int v ) { *p = Aig_Or(pMan->pAig, *p, Aig_Not(Aig_IthVar(pMan->pAig, v))); }
+static inline void Intb_ManAigMux0( Intb_Man_t * pMan, Aig_Obj_t ** p, Aig_Obj_t ** q, int v){ *p = Aig_Mux(pMan->pAig, Aig_IthVar(pMan->pAig, v), *q, *p); }
+static inline void Intb_ManAigMux1( Intb_Man_t * pMan, Aig_Obj_t ** p, Aig_Obj_t ** q, int v){ *p = Aig_Mux(pMan->pAig, Aig_IthVar(pMan->pAig, v), *p, *q); }
+
+// reading/writing the proof for a clause
+static inline int Intb_ManProofGet( Intb_Man_t * p, Sto_Cls_t * pCls ) { return p->pProofNums[pCls->Id]; }
+static inline void Intb_ManProofSet( Intb_Man_t * p, Sto_Cls_t * pCls, int n ) { p->pProofNums[pCls->Id] = n; }
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis [Allocate proof manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Intb_Man_t * Intb_ManAlloc()
+{
+ Intb_Man_t * p;
+ // allocate the manager
+ p = (Intb_Man_t *)ABC_ALLOC( char, sizeof(Intb_Man_t) );
+ memset( p, 0, sizeof(Intb_Man_t) );
+ // verification
+ p->nResLitsAlloc = (1<<16);
+ p->pResLits = ABC_ALLOC( lit, p->nResLitsAlloc );
+ // parameters
+ p->fProofWrite = 0;
+ p->fProofVerif = 1;
+ return p;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Count common variables in the clauses of A and B.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Intb_ManGlobalVars( Intb_Man_t * p )
+{
+ Sto_Cls_t * pClause;
+ int LargeNum = -100000000;
+ int Var, nVarsAB, v;
+
+ // mark the variable encountered in the clauses of A
+ Sto_ManForEachClauseRoot( p->pCnf, pClause )
+ {
+ if ( !pClause->fA )
+ break;
+ for ( v = 0; v < (int)pClause->nLits; v++ )
+ p->pVarTypes[lit_var(pClause->pLits[v])] = 1;
+ }
+
+ // check variables that appear in clauses of B
+ nVarsAB = 0;
+ Sto_ManForEachClauseRoot( p->pCnf, pClause )
+ {
+ if ( pClause->fA )
+ continue;
+ for ( v = 0; v < (int)pClause->nLits; v++ )
+ {
+ Var = lit_var(pClause->pLits[v]);
+ if ( p->pVarTypes[Var] == 1 ) // var of A
+ {
+ // change it into a global variable
+ nVarsAB++;
+ p->pVarTypes[Var] = LargeNum;
+ }
+ }
+ }
+ assert( nVarsAB <= Vec_IntSize(p->vVarsAB) );
+
+ // order global variables
+ nVarsAB = 0;
+ Vec_IntForEachEntry( p->vVarsAB, Var, v )
+ p->pVarTypes[Var] = -(1+nVarsAB++);
+
+ // check that there is no extra global variables
+ for ( v = 0; v < p->pCnf->nVars; v++ )
+ assert( p->pVarTypes[v] != LargeNum );
+ return nVarsAB;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Resize proof manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Intb_ManResize( Intb_Man_t * p )
+{
+ p->Counter = 0;
+ // check if resizing is needed
+ if ( p->nVarsAlloc < p->pCnf->nVars )
+ {
+ // find the new size
+ if ( p->nVarsAlloc == 0 )
+ p->nVarsAlloc = 1;
+ while ( p->nVarsAlloc < p->pCnf->nVars )
+ p->nVarsAlloc *= 2;
+ // resize the arrays
+ p->pTrail = ABC_REALLOC(lit, p->pTrail, p->nVarsAlloc );
+ p->pAssigns = ABC_REALLOC(lit, p->pAssigns, p->nVarsAlloc );
+ p->pSeens = ABC_REALLOC(char, p->pSeens, p->nVarsAlloc );
+ p->pVarTypes = ABC_REALLOC(int, p->pVarTypes, p->nVarsAlloc );
+ p->pReasons = ABC_REALLOC(Sto_Cls_t *, p->pReasons, p->nVarsAlloc );
+ p->pWatches = ABC_REALLOC(Sto_Cls_t *, p->pWatches, p->nVarsAlloc*2 );
+ }
+
+ // clean the free space
+ memset( p->pAssigns , 0xff, sizeof(lit) * p->pCnf->nVars );
+ memset( p->pSeens , 0, sizeof(char) * p->pCnf->nVars );
+ memset( p->pVarTypes, 0, sizeof(int) * p->pCnf->nVars );
+ memset( p->pReasons , 0, sizeof(Sto_Cls_t *) * p->pCnf->nVars );
+ memset( p->pWatches , 0, sizeof(Sto_Cls_t *) * p->pCnf->nVars*2 );
+
+ // compute the number of common variables
+ Intb_ManGlobalVars( p );
+
+ // check if resizing of clauses is needed
+ if ( p->nClosAlloc < p->pCnf->nClauses )
+ {
+ // find the new size
+ if ( p->nClosAlloc == 0 )
+ p->nClosAlloc = 1;
+ while ( p->nClosAlloc < p->pCnf->nClauses )
+ p->nClosAlloc *= 2;
+ // resize the arrays
+ p->pProofNums = ABC_REALLOC( int, p->pProofNums, p->nClosAlloc );
+ }
+ memset( p->pProofNums, 0, sizeof(int) * p->pCnf->nClauses );
+
+ // check if resizing of truth tables is needed
+ if ( p->nIntersAlloc < p->pCnf->nClauses )
+ {
+ p->nIntersAlloc = p->pCnf->nClauses;
+ p->pInters = ABC_REALLOC(Aig_Obj_t *, p->pInters, p->nIntersAlloc );
+ }
+ memset( p->pInters, 0, sizeof(Aig_Obj_t *) * p->pCnf->nClauses );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Deallocate proof manager.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Intb_ManFree( Intb_Man_t * p )
+{
+/*
+ printf( "Runtime stats:\n" );
+ABC_PRT( "BCP ", p->timeBcp );
+ABC_PRT( "Trace ", p->timeTrace );
+ABC_PRT( "TOTAL ", p->timeTotal );
+*/
+ ABC_FREE( p->pInters );
+ ABC_FREE( p->pProofNums );
+ ABC_FREE( p->pTrail );
+ ABC_FREE( p->pAssigns );
+ ABC_FREE( p->pSeens );
+ ABC_FREE( p->pVarTypes );
+ ABC_FREE( p->pReasons );
+ ABC_FREE( p->pWatches );
+ ABC_FREE( p->pResLits );
+ ABC_FREE( p );
+}
+
+
+
+
+/**Function*************************************************************
+
+ Synopsis [Prints the clause.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Intb_ManPrintClause( Intb_Man_t * p, Sto_Cls_t * pClause )
+{
+ int i;
+ printf( "Clause ID = %d. Proof = %d. {", pClause->Id, Intb_ManProofGet(p, pClause) );
+ for ( i = 0; i < (int)pClause->nLits; i++ )
+ printf( " %d", pClause->pLits[i] );
+ printf( " }\n" );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Prints the resolvent.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Intb_ManPrintResolvent( lit * pResLits, int nResLits )
+{
+ int i;
+ printf( "Resolvent: {" );
+ for ( i = 0; i < nResLits; i++ )
+ printf( " %d", pResLits[i] );
+ printf( " }\n" );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Prints the interpolant for one clause.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Intb_ManPrintInterOne( Intb_Man_t * p, Sto_Cls_t * pClause )
+{
+ printf( "Clause %2d : ", pClause->Id );
+// Extra_PrintBinary___( stdout, Intb_ManAigRead(p, pClause), (1 << p->nVarsAB) );
+ printf( "\n" );
+}
+
+
+
+/**Function*************************************************************
+
+ Synopsis [Adds one clause to the watcher list.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Intb_ManWatchClause( Intb_Man_t * p, Sto_Cls_t * pClause, lit Lit )
+{
+ assert( lit_check(Lit, p->pCnf->nVars) );
+ if ( pClause->pLits[0] == Lit )
+ pClause->pNext0 = p->pWatches[lit_neg(Lit)];
+ else
+ {
+ assert( pClause->pLits[1] == Lit );
+ pClause->pNext1 = p->pWatches[lit_neg(Lit)];
+ }
+ p->pWatches[lit_neg(Lit)] = pClause;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Records implication.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline int Intb_ManEnqueue( Intb_Man_t * p, lit Lit, Sto_Cls_t * pReason )
+{
+ int Var = lit_var(Lit);
+ if ( p->pAssigns[Var] != LIT_UNDEF )
+ return p->pAssigns[Var] == Lit;
+ p->pAssigns[Var] = Lit;
+ p->pReasons[Var] = pReason;
+ p->pTrail[p->nTrailSize++] = Lit;
+//printf( "assigning var %d value %d\n", Var, !lit_sign(Lit) );
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Records implication.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline void Intb_ManCancelUntil( Intb_Man_t * p, int Level )
+{
+ lit Lit;
+ int i, Var;
+ for ( i = p->nTrailSize - 1; i >= Level; i-- )
+ {
+ Lit = p->pTrail[i];
+ Var = lit_var( Lit );
+ p->pReasons[Var] = NULL;
+ p->pAssigns[Var] = LIT_UNDEF;
+//printf( "cancelling var %d\n", Var );
+ }
+ p->nTrailSize = Level;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Propagate one assignment.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+static inline Sto_Cls_t * Intb_ManPropagateOne( Intb_Man_t * p, lit Lit )
+{
+ Sto_Cls_t ** ppPrev, * pCur, * pTemp;
+ lit LitF = lit_neg(Lit);
+ int i;
+ // iterate through the literals
+ ppPrev = p->pWatches + Lit;
+ for ( pCur = p->pWatches[Lit]; pCur; pCur = *ppPrev )
+ {
+ // make sure the false literal is in the second literal of the clause
+ if ( pCur->pLits[0] == LitF )
+ {
+ pCur->pLits[0] = pCur->pLits[1];
+ pCur->pLits[1] = LitF;
+ pTemp = pCur->pNext0;
+ pCur->pNext0 = pCur->pNext1;
+ pCur->pNext1 = pTemp;
+ }
+ assert( pCur->pLits[1] == LitF );
+
+ // if the first literal is true, the clause is satisfied
+ if ( pCur->pLits[0] == p->pAssigns[lit_var(pCur->pLits[0])] )
+ {
+ ppPrev = &pCur->pNext1;
+ continue;
+ }
+
+ // look for a new literal to watch
+ for ( i = 2; i < (int)pCur->nLits; i++ )
+ {
+ // skip the case when the literal is false
+ if ( lit_neg(pCur->pLits[i]) == p->pAssigns[lit_var(pCur->pLits[i])] )
+ continue;
+ // the literal is either true or unassigned - watch it
+ pCur->pLits[1] = pCur->pLits[i];
+ pCur->pLits[i] = LitF;
+ // remove this clause from the watch list of Lit
+ *ppPrev = pCur->pNext1;
+ // add this clause to the watch list of pCur->pLits[i] (now it is pCur->pLits[1])
+ Intb_ManWatchClause( p, pCur, pCur->pLits[1] );
+ break;
+ }
+ if ( i < (int)pCur->nLits ) // found new watch
+ continue;
+
+ // clause is unit - enqueue new implication
+ if ( Intb_ManEnqueue(p, pCur->pLits[0], pCur) )
+ {
+ ppPrev = &pCur->pNext1;
+ continue;
+ }
+
+ // conflict detected - return the conflict clause
+ return pCur;
+ }
+ return NULL;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Propagate the current assignments.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Sto_Cls_t * Intb_ManPropagate( Intb_Man_t * p, int Start )
+{
+ Sto_Cls_t * pClause;
+ int i;
+ int clk = clock();
+ for ( i = Start; i < p->nTrailSize; i++ )
+ {
+ pClause = Intb_ManPropagateOne( p, p->pTrail[i] );
+ if ( pClause )
+ {
+p->timeBcp += clock() - clk;
+ return pClause;
+ }
+ }
+p->timeBcp += clock() - clk;
+ return NULL;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Writes one root clause into a file.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Intb_ManProofWriteOne( Intb_Man_t * p, Sto_Cls_t * pClause )
+{
+ Intb_ManProofSet( p, pClause, ++p->Counter );
+
+ if ( p->fProofWrite )
+ {
+ int v;
+ fprintf( p->pFile, "%d", Intb_ManProofGet(p, pClause) );
+ for ( v = 0; v < (int)pClause->nLits; v++ )
+ fprintf( p->pFile, " %d", lit_print(pClause->pLits[v]) );
+ fprintf( p->pFile, " 0 0\n" );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Traces the proof for one clause.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Intb_ManGetGlobalVar( Intb_Man_t * p, int Var )
+{
+ int VarAB;
+ if ( p->pVarTypes[Var] >= 0 ) // global var
+ return -1;
+ VarAB = -p->pVarTypes[Var]-1;
+ assert( VarAB >= 0 && VarAB < Vec_IntSize(p->vVarsAB) );
+ return VarAB;
+}
+
+
+/**Function*************************************************************
+
+ Synopsis [Traces the proof for one clause.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Intb_ManProofTraceOne( Intb_Man_t * p, Sto_Cls_t * pConflict, Sto_Cls_t * pFinal )
+{
+ Sto_Cls_t * pReason;
+ int i, v, Var, PrevId;
+ int fPrint = 0;
+ int clk = clock();
+
+ // collect resolvent literals
+ if ( p->fProofVerif )
+ {
+ assert( (int)pConflict->nLits <= p->nResLitsAlloc );
+ memcpy( p->pResLits, pConflict->pLits, sizeof(lit) * pConflict->nLits );
+ p->nResLits = pConflict->nLits;
+ }
+
+ // mark all the variables in the conflict as seen
+ for ( v = 0; v < (int)pConflict->nLits; v++ )
+ p->pSeens[lit_var(pConflict->pLits[v])] = 1;
+
+ // start the anticedents
+// pFinal->pAntis = Vec_PtrAlloc( 32 );
+// Vec_PtrPush( pFinal->pAntis, pConflict );
+
+ if ( p->pCnf->nClausesA )
+ Intb_ManAigCopy( p, Intb_ManAigRead(p, pFinal), Intb_ManAigRead(p, pConflict) );
+
+ // follow the trail backwards
+ PrevId = Intb_ManProofGet(p, pConflict);
+ for ( i = p->nTrailSize - 1; i >= 0; i-- )
+ {
+ // skip literals that are not involved
+ Var = lit_var(p->pTrail[i]);
+ if ( !p->pSeens[Var] )
+ continue;
+ p->pSeens[Var] = 0;
+
+ // skip literals of the resulting clause
+ pReason = p->pReasons[Var];
+ if ( pReason == NULL )
+ continue;
+ assert( p->pTrail[i] == pReason->pLits[0] );
+
+ // add the variables to seen
+ for ( v = 1; v < (int)pReason->nLits; v++ )
+ p->pSeens[lit_var(pReason->pLits[v])] = 1;
+
+
+ // record the reason clause
+ assert( Intb_ManProofGet(p, pReason) > 0 );
+ p->Counter++;
+ if ( p->fProofWrite )
+ fprintf( p->pFile, "%d * %d %d 0\n", p->Counter, PrevId, Intb_ManProofGet(p, pReason) );
+ PrevId = p->Counter;
+
+ if ( p->pCnf->nClausesA )
+ {
+ if ( p->pVarTypes[Var] == 1 )// || rand() % 10 == 0 ) // var of A
+ Intb_ManAigOr( p, Intb_ManAigRead(p, pFinal), Intb_ManAigRead(p, pReason) );
+ else if ( p->pVarTypes[Var] == 0 ) // var of B
+ Intb_ManAigAnd( p, Intb_ManAigRead(p, pFinal), Intb_ManAigRead(p, pReason) );
+ else
+ {
+ int VarAB = Intb_ManGetGlobalVar(p, Var);
+ // check that the var is present in the reason
+ for ( v = 0; v < (int)pReason->nLits; v++ )
+ if ( lit_var(pReason->pLits[v]) == Var )
+ break;
+ assert( v < (int)pReason->nLits );
+ if ( lit_sign(pReason->pLits[v]) ) // negative polarity
+ Intb_ManAigMux0( p, Intb_ManAigRead(p, pFinal), Intb_ManAigRead(p, pReason), VarAB );
+ else
+ Intb_ManAigMux1( p, Intb_ManAigRead(p, pFinal), Intb_ManAigRead(p, pReason), VarAB );
+ }
+ }
+
+ // resolve the temporary resolvent with the reason clause
+ if ( p->fProofVerif )
+ {
+ int v1, v2;
+ if ( fPrint )
+ Intb_ManPrintResolvent( p->pResLits, p->nResLits );
+ // check that the var is present in the resolvent
+ for ( v1 = 0; v1 < p->nResLits; v1++ )
+ if ( lit_var(p->pResLits[v1]) == Var )
+ break;
+ if ( v1 == p->nResLits )
+ printf( "Recording clause %d: Cannot find variable %d in the temporary resolvent.\n", pFinal->Id, Var );
+ if ( p->pResLits[v1] != lit_neg(pReason->pLits[0]) )
+ printf( "Recording clause %d: The resolved variable %d is in the wrong polarity.\n", pFinal->Id, Var );
+ // remove this variable from the resolvent
+ assert( lit_var(p->pResLits[v1]) == Var );
+ p->nResLits--;
+ for ( ; v1 < p->nResLits; v1++ )
+ p->pResLits[v1] = p->pResLits[v1+1];
+ // add variables of the reason clause
+ for ( v2 = 1; v2 < (int)pReason->nLits; v2++ )
+ {
+ for ( v1 = 0; v1 < p->nResLits; v1++ )
+ if ( lit_var(p->pResLits[v1]) == lit_var(pReason->pLits[v2]) )
+ break;
+ // if it is a new variable, add it to the resolvent
+ if ( v1 == p->nResLits )
+ {
+ if ( p->nResLits == p->nResLitsAlloc )
+ printf( "Recording clause %d: Ran out of space for intermediate resolvent.\n", pFinal->Id );
+ p->pResLits[ p->nResLits++ ] = pReason->pLits[v2];
+ continue;
+ }
+ // if the variable is the same, the literal should be the same too
+ if ( p->pResLits[v1] == pReason->pLits[v2] )
+ continue;
+ // the literal is different
+ printf( "Recording clause %d: Trying to resolve the clause with more than one opposite literal.\n", pFinal->Id );
+ }
+ }
+
+// Vec_PtrPush( pFinal->pAntis, pReason );
+ }
+
+ // unmark all seen variables
+// for ( i = p->nTrailSize - 1; i >= 0; i-- )
+// p->pSeens[lit_var(p->pTrail[i])] = 0;
+ // check that the literals are unmarked
+// for ( i = p->nTrailSize - 1; i >= 0; i-- )
+// assert( p->pSeens[lit_var(p->pTrail[i])] == 0 );
+
+ // use the resulting clause to check the correctness of resolution
+ if ( p->fProofVerif )
+ {
+ int v1, v2;
+ if ( fPrint )
+ Intb_ManPrintResolvent( p->pResLits, p->nResLits );
+ for ( v1 = 0; v1 < p->nResLits; v1++ )
+ {
+ for ( v2 = 0; v2 < (int)pFinal->nLits; v2++ )
+ if ( pFinal->pLits[v2] == p->pResLits[v1] )
+ break;
+ if ( v2 < (int)pFinal->nLits )
+ continue;
+ break;
+ }
+ if ( v1 < p->nResLits )
+ {
+ printf( "Recording clause %d: The final resolvent is wrong.\n", pFinal->Id );
+ Intb_ManPrintClause( p, pConflict );
+ Intb_ManPrintResolvent( p->pResLits, p->nResLits );
+ Intb_ManPrintClause( p, pFinal );
+ }
+ }
+p->timeTrace += clock() - clk;
+
+ // return the proof pointer
+ if ( p->pCnf->nClausesA )
+ {
+// Intb_ManPrintInterOne( p, pFinal );
+ }
+ Intb_ManProofSet( p, pFinal, p->Counter );
+ return p->Counter;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Records the proof for one clause.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Intb_ManProofRecordOne( Intb_Man_t * p, Sto_Cls_t * pClause )
+{
+ Sto_Cls_t * pConflict;
+ int i;
+
+ // empty clause never ends up there
+ assert( pClause->nLits > 0 );
+ if ( pClause->nLits == 0 )
+ printf( "Error: Empty clause is attempted.\n" );
+
+ // add assumptions to the trail
+ assert( !pClause->fRoot );
+ assert( p->nTrailSize == p->nRootSize );
+ for ( i = 0; i < (int)pClause->nLits; i++ )
+ if ( !Intb_ManEnqueue( p, lit_neg(pClause->pLits[i]), NULL ) )
+ {
+ assert( 0 ); // impossible
+ return 0;
+ }
+
+ // propagate the assumptions
+ pConflict = Intb_ManPropagate( p, p->nRootSize );
+ if ( pConflict == NULL )
+ {
+ assert( 0 ); // cannot prove
+ return 0;
+ }
+
+ // construct the proof
+ Intb_ManProofTraceOne( p, pConflict, pClause );
+
+ // undo to the root level
+ Intb_ManCancelUntil( p, p->nRootSize );
+
+ // add large clauses to the watched lists
+ if ( pClause->nLits > 1 )
+ {
+ Intb_ManWatchClause( p, pClause, pClause->pLits[0] );
+ Intb_ManWatchClause( p, pClause, pClause->pLits[1] );
+ return 1;
+ }
+ assert( pClause->nLits == 1 );
+
+ // if the clause proved is unit, add it and propagate
+ if ( !Intb_ManEnqueue( p, pClause->pLits[0], pClause ) )
+ {
+ assert( 0 ); // impossible
+ return 0;
+ }
+
+ // propagate the assumption
+ pConflict = Intb_ManPropagate( p, p->nRootSize );
+ if ( pConflict )
+ {
+ // construct the proof
+ Intb_ManProofTraceOne( p, pConflict, p->pCnf->pEmpty );
+// if ( p->fVerbose )
+// printf( "Found last conflict after adding unit clause number %d!\n", pClause->Id );
+ return 0;
+ }
+
+ // update the root level
+ p->nRootSize = p->nTrailSize;
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Propagate the root clauses.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Intb_ManProcessRoots( Intb_Man_t * p )
+{
+ Sto_Cls_t * pClause;
+ int Counter;
+
+ // make sure the root clauses are preceeding the learnt clauses
+ Counter = 0;
+ Sto_ManForEachClause( p->pCnf, pClause )
+ {
+ assert( (int)pClause->fA == (Counter < (int)p->pCnf->nClausesA) );
+ assert( (int)pClause->fRoot == (Counter < (int)p->pCnf->nRoots) );
+ Counter++;
+ }
+ assert( p->pCnf->nClauses == Counter );
+
+ // make sure the last clause if empty
+ assert( p->pCnf->pTail->nLits == 0 );
+
+ // go through the root unit clauses
+ p->nTrailSize = 0;
+ Sto_ManForEachClauseRoot( p->pCnf, pClause )
+ {
+ // create watcher lists for the root clauses
+ if ( pClause->nLits > 1 )
+ {
+ Intb_ManWatchClause( p, pClause, pClause->pLits[0] );
+ Intb_ManWatchClause( p, pClause, pClause->pLits[1] );
+ }
+ // empty clause and large clauses
+ if ( pClause->nLits != 1 )
+ continue;
+ // unit clause
+ assert( lit_check(pClause->pLits[0], p->pCnf->nVars) );
+ if ( !Intb_ManEnqueue( p, pClause->pLits[0], pClause ) )
+ {
+ // detected root level conflict
+ printf( "Error in Intb_ManProcessRoots(): Detected a root-level conflict too early!\n" );
+ assert( 0 );
+ return 0;
+ }
+ }
+
+ // propagate the root unit clauses
+ pClause = Intb_ManPropagate( p, 0 );
+ if ( pClause )
+ {
+ // detected root level conflict
+ Intb_ManProofTraceOne( p, pClause, p->pCnf->pEmpty );
+ if ( p->fVerbose )
+ printf( "Found root level conflict!\n" );
+ return 0;
+ }
+
+ // set the root level
+ p->nRootSize = p->nTrailSize;
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Records the proof.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void Intb_ManPrepareInter( Intb_Man_t * p )
+{
+ Sto_Cls_t * pClause;
+ int Var, VarAB, v;
+
+ // set interpolants for root clauses
+ Sto_ManForEachClauseRoot( p->pCnf, pClause )
+ {
+ if ( !pClause->fA ) // clause of B
+ {
+ Intb_ManAigFill( p, Intb_ManAigRead(p, pClause) );
+// Intb_ManPrintInterOne( p, pClause );
+ continue;
+ }
+ // clause of A
+ Intb_ManAigClear( p, Intb_ManAigRead(p, pClause) );
+
+ for ( v = 0; v < (int)pClause->nLits; v++ )
+ {
+ Var = lit_var(pClause->pLits[v]);
+ if ( p->pVarTypes[Var] < 0 ) // global var
+ {
+ VarAB = -p->pVarTypes[Var]-1;
+ assert( VarAB >= 0 && VarAB < Vec_IntSize(p->vVarsAB) );
+ if ( lit_sign(pClause->pLits[v]) ) // negative var
+ Intb_ManAigOrNotVar( p, Intb_ManAigRead(p, pClause), VarAB );
+ else
+ Intb_ManAigOrVar( p, Intb_ManAigRead(p, pClause), VarAB );
+ }
+ }
+
+// Intb_ManPrintInterOne( p, pClause );
+ }
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes interpolant for the given CNF.]
+
+ Description [Takes the interpolation manager, the CNF deriving by the SAT
+ solver, which includes ClausesA, ClausesB, and learned clauses. Additional
+ arguments are the vector of variables common to AB and the verbosiness flag.
+ Returns the AIG manager with a single output, containing the interpolant.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void * Intb_ManInterpolate( Intb_Man_t * p, Sto_Man_t * pCnf, void * vVarsAB, int fVerbose )
+{
+ Aig_Man_t * pRes;
+ Aig_Obj_t * pObj;
+ Sto_Cls_t * pClause;
+ int RetValue = 1;
+ int clkTotal = clock();
+
+ // check that the CNF makes sense
+ assert( pCnf->nVars > 0 && pCnf->nClauses > 0 );
+ p->pCnf = pCnf;
+ p->fVerbose = fVerbose;
+ p->vVarsAB = vVarsAB;
+ p->pAig = pRes = Aig_ManStart( 10000 );
+ Aig_IthVar( p->pAig, Vec_IntSize(p->vVarsAB) - 1 );
+
+ // adjust the manager
+ Intb_ManResize( p );
+
+ // prepare the interpolant computation
+ Intb_ManPrepareInter( p );
+
+ // construct proof for each clause
+ // start the proof
+ if ( p->fProofWrite )
+ {
+ p->pFile = fopen( "proof.cnf_", "w" );
+ p->Counter = 0;
+ }
+
+ // write the root clauses
+ Sto_ManForEachClauseRoot( p->pCnf, pClause )
+ Intb_ManProofWriteOne( p, pClause );
+
+ // propagate root level assignments
+ if ( Intb_ManProcessRoots( p ) )
+ {
+ // if there is no conflict, consider learned clauses
+ Sto_ManForEachClause( p->pCnf, pClause )
+ {
+ if ( pClause->fRoot )
+ continue;
+ if ( !Intb_ManProofRecordOne( p, pClause ) )
+ {
+ RetValue = 0;
+ break;
+ }
+ }
+ }
+
+ // stop the proof
+ if ( p->fProofWrite )
+ {
+ fclose( p->pFile );
+ p->pFile = NULL;
+ }
+
+ if ( fVerbose )
+ {
+// ABC_PRT( "Interpo", clock() - clkTotal );
+ printf( "Vars = %d. Roots = %d. Learned = %d. Resol steps = %d. Ave = %.2f. Mem = %.2f Mb\n",
+ p->pCnf->nVars, p->pCnf->nRoots, p->pCnf->nClauses-p->pCnf->nRoots, p->Counter,
+ 1.0*(p->Counter-p->pCnf->nRoots)/(p->pCnf->nClauses-p->pCnf->nRoots),
+ 1.0*Sto_ManMemoryReport(p->pCnf)/(1<<20) );
+p->timeTotal += clock() - clkTotal;
+ }
+
+ pObj = *Intb_ManAigRead( p, p->pCnf->pTail );
+ Aig_ObjCreatePo( pRes, pObj );
+ Aig_ManCleanup( pRes );
+
+ p->pAig = NULL;
+ return pRes;
+
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Aig_Man_t * Intb_ManDeriveClauses( Intb_Man_t * pMan, Sto_Man_t * pCnf, int fClausesA )
+{
+ Aig_Man_t * p;
+ Aig_Obj_t * pMiter, * pSum, * pLit;
+ Sto_Cls_t * pClause;
+ int Var, VarAB, v;
+ p = Aig_ManStart( 10000 );
+ pMiter = Aig_ManConst1(p);
+ Sto_ManForEachClauseRoot( pCnf, pClause )
+ {
+ if ( fClausesA ^ pClause->fA ) // clause of B
+ continue;
+ // clause of A
+ pSum = Aig_ManConst0(p);
+ for ( v = 0; v < (int)pClause->nLits; v++ )
+ {
+ Var = lit_var(pClause->pLits[v]);
+ if ( pMan->pVarTypes[Var] < 0 ) // global var
+ {
+ VarAB = -pMan->pVarTypes[Var]-1;
+ assert( VarAB >= 0 && VarAB < Vec_IntSize(pMan->vVarsAB) );
+ pLit = Aig_NotCond( Aig_IthVar(p, VarAB), lit_sign(pClause->pLits[v]) );
+ }
+ else
+ pLit = Aig_NotCond( Aig_IthVar(p, Vec_IntSize(pMan->vVarsAB)+1+Var), lit_sign(pClause->pLits[v]) );
+ pSum = Aig_Or( p, pSum, pLit );
+ }
+ pMiter = Aig_And( p, pMiter, pSum );
+ }
+ Aig_ObjCreatePo( p, pMiter );
+ return p;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/bsat/satInterP.c b/src/sat/bsat/satInterP.c
index 57fb79d2..76f6982d 100644
--- a/src/sat/bsat/satInterP.c
+++ b/src/sat/bsat/satInterP.c
@@ -27,6 +27,9 @@
#include "satStore.h"
#include "vec.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -54,8 +57,10 @@ struct Intp_Man_t_
Sto_Cls_t ** pReasons; // reasons for each assignment (size nVars)
Sto_Cls_t ** pWatches; // watched clauses for each literal (size 2*nVars)
// proof data
- Vec_Int_t * vAnties; // anticedents for all clauses
- Vec_Int_t * vBreaks; // beginnings of anticedents for each clause
+// Vec_Int_t * vAnties; // anticedents for all clauses
+// Vec_Int_t * vBreaks; // beginnings of anticedents for each clause
+ Vec_Ptr_t * vAntClas; // anticedant clauses
+ int nAntStart; // starting antecedant clause
// proof recording
int Counter; // counter of resolved clauses
int * pProofNums; // the proof numbers for each clause (size nClauses)
@@ -99,8 +104,10 @@ Intp_Man_t * Intp_ManAlloc()
p->nResLitsAlloc = (1<<16);
p->pResLits = ABC_ALLOC( lit, p->nResLitsAlloc );
// proof recording
- p->vAnties = Vec_IntAlloc( 1000 );
- p->vBreaks = Vec_IntAlloc( 1000 );
+// p->vAnties = Vec_IntAlloc( 1000 );
+// p->vBreaks = Vec_IntAlloc( 1000 );
+ p->vAntClas = Vec_PtrAlloc( 1000 );
+ p->nAntStart = 0;
// parameters
p->fProofWrite = 0;
p->fProofVerif = 1;
@@ -137,7 +144,7 @@ void Intp_ManResize( Intp_Man_t * p )
p->pWatches = ABC_REALLOC(Sto_Cls_t *, p->pWatches, p->nVarsAlloc*2 );
}
- // clean the ABC_FREE space
+ // clean the free space
memset( p->pAssigns , 0xff, sizeof(lit) * p->pCnf->nVars );
memset( p->pSeens , 0, sizeof(char) * p->pCnf->nVars );
// memset( p->pVarTypes, 0, sizeof(int) * p->pCnf->nVars );
@@ -177,8 +184,9 @@ ABC_PRT( "BCP ", p->timeBcp );
ABC_PRT( "Trace ", p->timeTrace );
ABC_PRT( "TOTAL ", p->timeTotal );
*/
- Vec_IntFree( p->vAnties );
- Vec_IntFree( p->vBreaks );
+// Vec_IntFree( p->vAnties );
+// Vec_IntFree( p->vBreaks );
+ Vec_VecFree( (Vec_Vec_t *)p->vAntClas );
// ABC_FREE( p->pInters );
ABC_FREE( p->pProofNums );
ABC_FREE( p->pTrail );
@@ -485,9 +493,16 @@ int Intp_ManProofTraceOne( Intp_Man_t * p, Sto_Cls_t * pConflict, Sto_Cls_t * pF
// start the anticedents
// pFinal->pAntis = Vec_PtrAlloc( 32 );
// Vec_PtrPush( pFinal->pAntis, pConflict );
- assert( pFinal->Id == Vec_IntSize(p->vBreaks) );
- Vec_IntPush( p->vBreaks, Vec_IntSize(p->vAnties) );
- Vec_IntPush( p->vAnties, pConflict->Id );
+
+// assert( pFinal->Id == Vec_IntSize(p->vBreaks) );
+// Vec_IntPush( p->vBreaks, Vec_IntSize(p->vAnties) );
+// Vec_IntPush( p->vAnties, pConflict->Id );
+ {
+ Vec_Int_t * vAnts = Vec_IntAlloc( 16 );
+ assert( Vec_PtrSize(p->vAntClas) == pFinal->Id - p->nAntStart );
+ Vec_IntPush( vAnts, pConflict->Id );
+ Vec_PtrPush( p->vAntClas, vAnts );
+ }
// if ( p->pCnf->nClausesA )
// Intp_ManAigCopy( p, Intp_ManAigRead(p, pFinal), Intp_ManAigRead(p, pConflict) );
@@ -570,7 +585,8 @@ int Intp_ManProofTraceOne( Intp_Man_t * p, Sto_Cls_t * pConflict, Sto_Cls_t * pF
}
// Vec_PtrPush( pFinal->pAntis, pReason );
- Vec_IntPush( p->vAnties, pReason->Id );
+// Vec_IntPush( p->vAnties, pReason->Id );
+ Vec_IntPush( (Vec_Int_t *)Vec_PtrEntryLast(p->vAntClas), pReason->Id );
}
// unmark all seen variables
@@ -668,7 +684,8 @@ int Intp_ManProofRecordOne( Intp_Man_t * p, Sto_Cls_t * pClause )
for ( i = 0; i < (int)pClause->nLits; i++ )
if ( p->pAssigns[lit_var(pClause->pLits[i])] == pClause->pLits[i] )
{
- Vec_IntPush( p->vBreaks, Vec_IntSize(p->vAnties) );
+// Vec_IntPush( p->vBreaks, Vec_IntSize(p->vAnties) );
+ Vec_PtrPush( p->vAntClas, Vec_IntAlloc(0) );
return 1;
}
@@ -705,7 +722,8 @@ int Intp_ManProofRecordOne( Intp_Man_t * p, Sto_Cls_t * pClause )
{
// undo to the root level
Intp_ManCancelUntil( p, p->nRootSize );
- Vec_IntPush( p->vBreaks, Vec_IntSize(p->vAnties) );
+// Vec_IntPush( p->vBreaks, Vec_IntSize(p->vAnties) );
+ Vec_PtrPush( p->vAntClas, Vec_IntAlloc(0) );
return 1;
}
}
@@ -736,7 +754,10 @@ int Intp_ManProofRecordOne( Intp_Man_t * p, Sto_Cls_t * pClause )
pConflict = Intp_ManPropagate( p, p->nRootSize );
if ( pConflict )
{
- // construct the proof
+ // insert place-holders till the empty clause
+ while ( Vec_PtrSize(p->vAntClas) < p->pCnf->pEmpty->Id - p->nAntStart )
+ Vec_PtrPush( p->vAntClas, Vec_IntAlloc(0) );
+ // construct the proof for the empty clause
Intp_ManProofTraceOne( p, pConflict, p->pCnf->pEmpty );
// if ( p->fVerbose )
// printf( "Found last conflict after adding unit clause number %d!\n", pClause->Id );
@@ -856,7 +877,7 @@ void Intp_ManUnsatCoreVerify( Sto_Man_t * pCnf, Vec_Int_t * vCore )
// sat_solver_setnvars( pSat, nSatVars );
Vec_IntForEachEntry( vCore, iClause, i )
{
- pClause = Vec_PtrEntry( vClauses, iClause );
+ pClause = (Sto_Cls_t *)Vec_PtrEntry( vClauses, iClause );
if ( !sat_solver_addclause( pSat, pClause->pLits, pClause->pLits+pClause->nLits ) )
{
printf( "The core verification problem is trivially UNSAT.\n" );
@@ -895,9 +916,11 @@ void Intp_ManUnsatCoreVerify( Sto_Man_t * pCnf, Vec_Int_t * vCore )
SeeAlso []
***********************************************************************/
-void Intp_ManUnsatCore_rec( Vec_Int_t * vAnties, Vec_Int_t * vBreaks, int iThis, Vec_Int_t * vCore, int nRoots, Vec_Int_t * vVisited )
+void Intp_ManUnsatCore_rec( Vec_Ptr_t * vAntClas, int iThis, Vec_Int_t * vCore, int nRoots, Vec_Int_t * vVisited )
{
- int i, iStop, iStart;
+// int i, iStop, iStart;
+ Vec_Int_t * vAnt;
+ int i, Entry;
// skip visited clauses
if ( Vec_IntEntry( vVisited, iThis ) )
return;
@@ -906,14 +929,17 @@ void Intp_ManUnsatCore_rec( Vec_Int_t * vAnties, Vec_Int_t * vBreaks, int iThis,
if ( iThis < nRoots )
{
Vec_IntPush( vCore, iThis );
- return;
+ return;
}
// iterate through the clauses
- iStart = Vec_IntEntry( vBreaks, iThis );
- iStop = Vec_IntEntry( vBreaks, iThis+1 );
- assert( iStop != -1 );
- for ( i = iStart; i < iStop; i++ )
- Intp_ManUnsatCore_rec( vAnties, vBreaks, Vec_IntEntry(vAnties, i), vCore, nRoots, vVisited );
+// iStart = Vec_IntEntry( vBreaks, iThis );
+// iStop = Vec_IntEntry( vBreaks, iThis+1 );
+// assert( iStop != -1 );
+// for ( i = iStart; i < iStop; i++ )
+ vAnt = (Vec_Int_t *)Vec_PtrEntry( vAntClas, iThis - nRoots );
+ Vec_IntForEachEntry( vAnt, Entry, i )
+// Intp_ManUnsatCore_rec( vAntClas, Vec_IntEntry(vAnties, i), vCore, nRoots, vVisited );
+ Intp_ManUnsatCore_rec( vAntClas, Entry, vCore, nRoots, vVisited );
}
/**Function*************************************************************
@@ -944,7 +970,7 @@ void * Intp_ManUnsatCore( Intp_Man_t * p, Sto_Man_t * pCnf, int fVerbose )
p->fVerbose = fVerbose;
// adjust the manager
- Intp_ManResize( p );
+ Intp_ManResize( p );
// construct proof for each clause
// start the proof
@@ -955,8 +981,11 @@ void * Intp_ManUnsatCore( Intp_Man_t * p, Sto_Man_t * pCnf, int fVerbose )
}
// write the root clauses
- Vec_IntClear( p->vAnties );
- Vec_IntFill( p->vBreaks, p->pCnf->nRoots, 0 );
+// Vec_IntClear( p->vAnties );
+// Vec_IntFill( p->vBreaks, p->pCnf->nRoots, 0 );
+ Vec_PtrClear( p->vAntClas );
+ p->nAntStart = p->pCnf->nRoots;
+
Sto_ManForEachClauseRoot( p->pCnf, pClause )
Intp_ManProofWriteOne( p, pClause );
@@ -977,8 +1006,10 @@ void * Intp_ManUnsatCore( Intp_Man_t * p, Sto_Man_t * pCnf, int fVerbose )
}
// add the last breaker
- assert( p->pCnf->pEmpty->Id == Vec_IntSize(p->vBreaks) - 1 );
- Vec_IntPush( p->vBreaks, Vec_IntSize(p->vAnties) );
+// assert( p->pCnf->pEmpty->Id == Vec_IntSize(p->vBreaks) - 1 );
+// Vec_IntPush( p->vBreaks, Vec_IntSize(p->vAnties) );
+ assert( p->pCnf->pEmpty->Id - p->nAntStart == Vec_PtrSize(p->vAntClas) - 1 );
+ Vec_PtrPush( p->vAntClas, Vec_IntAlloc(0) );
// stop the proof
if ( p->fProofWrite )
@@ -1001,7 +1032,7 @@ p->timeTotal += clock() - clkTotal;
// derive the UNSAT core
vCore = Vec_IntAlloc( 1000 );
vVisited = Vec_IntStart( p->pCnf->pEmpty->Id+1 );
- Intp_ManUnsatCore_rec( p->vAnties, p->vBreaks, p->pCnf->pEmpty->Id, vCore, p->pCnf->nRoots, vVisited );
+ Intp_ManUnsatCore_rec( p->vAntClas, p->pCnf->pEmpty->Id, vCore, p->pCnf->nRoots, vVisited );
Vec_IntFree( vVisited );
if ( fVerbose )
printf( "Root clauses = %d. Learned clauses = %d. UNSAT core size = %d.\n",
@@ -1015,3 +1046,5 @@ p->timeTotal += clock() - clkTotal;
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/bsat/satMem.c b/src/sat/bsat/satMem.c
index f789f927..30861993 100644
--- a/src/sat/bsat/satMem.c
+++ b/src/sat/bsat/satMem.c
@@ -21,9 +21,11 @@
#include <string.h>
#include <assert.h>
-#include "abc_global.h"
#include "satMem.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -35,7 +37,7 @@ struct Sat_MmFixed_t_
int nEntriesAlloc; // the total number of entries allocated
int nEntriesUsed; // the number of entries in use
int nEntriesMax; // the max number of entries in use
- char * pEntriesFree; // the linked list of ABC_FREE entries
+ char * pEntriesFree; // the linked list of free entries
// this is where the memory is stored
int nChunkSize; // the size of one chunk
@@ -52,8 +54,8 @@ struct Sat_MmFlex_t_
{
// information about individual entries
int nEntriesUsed; // the number of entries allocated
- char * pCurrent; // the current pointer to ABC_FREE memory
- char * pEnd; // the first entry outside the ABC_FREE memory
+ char * pCurrent; // the current pointer to free memory
+ char * pEnd; // the first entry outside the free memory
// this is where the memory is stored
int nChunkSize; // the size of one chunk
@@ -167,7 +169,7 @@ char * Sat_MmFixedEntryFetch( Sat_MmFixed_t * p )
char * pTemp;
int i;
- // check if there are still ABC_FREE entries
+ // check if there are still free entries
if ( p->nEntriesUsed == p->nEntriesAlloc )
{ // need to allocate more entries
assert( p->pEntriesFree == NULL );
@@ -196,7 +198,7 @@ char * Sat_MmFixedEntryFetch( Sat_MmFixed_t * p )
p->nEntriesUsed++;
if ( p->nEntriesMax < p->nEntriesUsed )
p->nEntriesMax = p->nEntriesUsed;
- // return the first entry in the ABC_FREE entry list
+ // return the first entry in the free entry list
pTemp = p->pEntriesFree;
p->pEntriesFree = *((char **)pTemp);
return pTemp;
@@ -217,7 +219,7 @@ void Sat_MmFixedEntryRecycle( Sat_MmFixed_t * p, char * pEntry )
{
// decrement the counter of used entries
p->nEntriesUsed--;
- // add the entry to the linked list of ABC_FREE entries
+ // add the entry to the linked list of free entries
*((char **)pEntry) = p->pEntriesFree;
p->pEntriesFree = pEntry;
}
@@ -251,7 +253,7 @@ void Sat_MmFixedRestart( Sat_MmFixed_t * p )
}
// set the last link
*((char **)pTemp) = NULL;
- // set the ABC_FREE entry list
+ // set the free entry list
p->pEntriesFree = p->pChunks[0];
// set the correct statistics
p->nMemoryAlloc = p->nEntrySize * p->nChunkSize;
@@ -353,7 +355,7 @@ void Sat_MmFlexStop( Sat_MmFlex_t * p, int fVerbose )
char * Sat_MmFlexEntryFetch( Sat_MmFlex_t * p, int nBytes )
{
char * pTemp;
- // check if there are still ABC_FREE entries
+ // check if there are still free entries
if ( p->pCurrent == NULL || p->pCurrent + nBytes > p->pEnd )
{ // need to allocate more entries
if ( p->nChunks == p->nChunksAlloc )
@@ -548,3 +550,5 @@ int Sat_MmStepReadMemUsage( Sat_MmStep_t * p )
nMemTotal += p->pMems[i]->nMemoryAlloc;
return nMemTotal;
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/bsat/satMem.h b/src/sat/bsat/satMem.h
index b6d93807..13afa9b9 100644
--- a/src/sat/bsat/satMem.h
+++ b/src/sat/bsat/satMem.h
@@ -23,6 +23,10 @@
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
+#include "abc_global.h"
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
@@ -66,6 +70,10 @@ extern char * Sat_MmStepEntryFetch( Sat_MmStep_t * p, int nBytes );
extern void Sat_MmStepEntryRecycle( Sat_MmStep_t * p, char * pEntry, int nBytes );
extern int Sat_MmStepReadMemUsage( Sat_MmStep_t * p );
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif
////////////////////////////////////////////////////////////////////////
diff --git a/src/sat/bsat/satSolver.c b/src/sat/bsat/satSolver.c
index df04cd1f..10dea1e3 100644
--- a/src/sat/bsat/satSolver.c
+++ b/src/sat/bsat/satSolver.c
@@ -2,7 +2,7 @@
MiniSat -- Copyright (c) 2005, Niklas Sorensson
http://www.cs.chalmers.se/Cs/Research/FormalMethods/MiniSat/
-Permission is hereby granted, ABC_FREE of charge, to any person obtaining a copy of this software and
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
@@ -25,7 +25,21 @@ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWA
#include <math.h>
#include "satSolver.h"
-
+#include "satStore.h"
+
+ABC_NAMESPACE_IMPL_START
+/*
+extern int Sto_ManAddClause( void * p, lit * pBeg, lit * pEnd );
+extern int Sto_ManAddClause( void * p, lit * pBeg, lit * pEnd );
+extern int Sto_ManAddClause( void * p, lit * pBeg, lit * pEnd );
+extern int Sto_ManAddClause( void * p, lit * pBeg, lit * pEnd );
+extern void * Sto_ManAlloc();
+extern void Sto_ManDumpClauses( void * p, char * pFileName );
+extern void Sto_ManFree( void * p );
+extern int Sto_ManChangeLastClause( void * p );
+extern void Sto_ManMarkRoots( void * p );
+extern void Sto_ManMarkClausesA( void * p );
+*/
//#define SAT_USE_SYSTEM_MEMORY_MANAGEMENT
//=================================================================================================
@@ -91,7 +105,7 @@ static inline void clause_setactivity(clause* c, float a) { *((float*)&c->lits[
// Encode literals in clause pointers:
static inline clause* clause_from_lit (lit l) { return (clause*)((ABC_PTRUINT_T)l + (ABC_PTRUINT_T)l + 1); }
-static inline bool clause_is_lit (clause* c) { return ((ABC_PTRUINT_T)c & 1); }
+static inline int clause_is_lit (clause* c) { return ((ABC_PTRUINT_T)c & 1); }
static inline lit clause_read_lit (clause* c) { return (lit)((ABC_PTRUINT_T)c >> 1); }
//=================================================================================================
@@ -386,6 +400,7 @@ void sat_solver_setnvars(sat_solver* s,int n)
s->levels = ABC_REALLOC(int, s->levels, s->cap);
s->tags = ABC_REALLOC(lbool, s->tags, s->cap);
s->trail = ABC_REALLOC(lit, s->trail, s->cap);
+ s->polarity = ABC_REALLOC(char, s->polarity, s->cap);
}
for (var = s->size; var < n; var++){
@@ -398,6 +413,7 @@ void sat_solver_setnvars(sat_solver* s,int n)
s->reasons [var] = (clause*)0;
s->levels [var] = 0;
s->tags [var] = l_Undef;
+ s->polarity [var] = 0;
/* does not hold because variables enqueued at top level will not be reinserted in the heap
assert(veci_size(&s->order) == var);
@@ -410,7 +426,7 @@ void sat_solver_setnvars(sat_solver* s,int n)
}
-static inline bool enqueue(sat_solver* s, lit l, clause* from)
+static inline int enqueue(sat_solver* s, lit l, clause* from)
{
lbool* values = s->assigns;
int v = lit_var(l);
@@ -457,6 +473,7 @@ static void sat_solver_canceluntil(sat_solver* s, int level) {
lbool* values;
clause** reasons;
int bound;
+ int lastLev;
int c;
if (sat_solver_dlevel(s) <= level)
@@ -466,6 +483,7 @@ static void sat_solver_canceluntil(sat_solver* s, int level) {
values = s->assigns;
reasons = s->reasons;
bound = (veci_begin(&s->trail_lim))[level];
+ lastLev = (veci_begin(&s->trail_lim))[veci_size(&s->trail_lim)-1];
////////////////////////////////////////
// added to cancel all assignments
@@ -477,6 +495,8 @@ static void sat_solver_canceluntil(sat_solver* s, int level) {
int x = lit_var(trail[c]);
values [x] = l_Undef;
reasons[x] = (clause*)0;
+ if ( c < lastLev )
+ s->polarity[x] = !lit_sign(trail[c]);
}
for (c = s->qhead-1; c >= bound; c--)
@@ -497,8 +517,7 @@ static void sat_solver_record(sat_solver* s, veci* cls)
// add clause to internal storage
if ( s->pStore )
{
- extern int Sto_ManAddClause( void * p, lit * pBeg, lit * pEnd );
- int RetValue = Sto_ManAddClause( s->pStore, begin, end );
+ int RetValue = Sto_ManAddClause( (Sto_Man_t *)s->pStore, begin, end );
assert( RetValue );
}
///////////////////////////////////
@@ -531,7 +550,7 @@ static double sat_solver_progress(sat_solver* s)
//=================================================================================================
// Major methods:
-static bool sat_solver_lit_removable(sat_solver* s, lit l, int minl)
+static int sat_solver_lit_removable(sat_solver* s, lit l, int minl)
{
lbool* tags = s->tags;
clause** reasons = s->reasons;
@@ -594,6 +613,92 @@ static bool sat_solver_lit_removable(sat_solver* s, lit l, int minl)
return true;
}
+
+/*_________________________________________________________________________________________________
+|
+| analyzeFinal : (p : Lit) -> [void]
+|
+| Description:
+| Specialized analysis procedure to express the final conflict in terms of assumptions.
+| Calculates the (possibly empty) set of assumptions that led to the assignment of 'p', and
+| stores the result in 'out_conflict'.
+|________________________________________________________________________________________________@*/
+/*
+void Solver::analyzeFinal(Lit p, vec<Lit>& out_conflict)
+{
+ out_conflict.clear();
+ out_conflict.push(p);
+
+ if (decisionLevel() == 0)
+ return;
+
+ seen[var(p)] = 1;
+
+ for (int i = trail.size()-1; i >= trail_lim[0]; i--){
+ Var x = var(trail[i]);
+ if (seen[x]){
+ if (reason(x) == GClause_NULL){
+ assert(level(x) > 0);
+ out_conflict.push(~trail[i]);
+ }else{
+ Clause& c = ca.deref(smartReason(x));
+ for (int j = 1; j < c.size(); j++)
+ if (level(var(c[j])) > 0)
+ seen[var(c[j])] = 1;
+ }
+ seen[x] = 0;
+ }
+ }
+
+ seen[var(p)] = 0;
+}
+*/
+
+static void sat_solver_analyze_final(sat_solver* s, lit p, veci* out_conflict)
+{
+ int i, j;
+ veci_resize(out_conflict,0);
+// veci_push(out_conflict,p); // do not write conflict literal
+ if ( sat_solver_dlevel(s) == 0 )
+ return;
+ assert( veci_size(&s->tagged) == 0 );
+ assert( s->tags[lit_var(p)] == l_Undef );
+ s->tags[lit_var(p)] = l_True;
+ for (i = s->qtail-1; i >= (veci_begin(&s->trail_lim))[0]; i--){
+ int x = lit_var(s->trail[i]);
+ if (s->tags[x] == l_True){
+ if (s->reasons[x] == NULL){
+ assert(s->levels[x] > 0);
+ veci_push(out_conflict,lit_neg(s->trail[i]));
+ }else{
+ clause* c = s->reasons[x];
+ if (clause_is_lit(c)){
+ lit q = clause_read_lit(c);
+ assert(lit_var(q) >= 0 && lit_var(q) < s->size);
+ if (s->levels[lit_var(q)] > 0)
+ {
+ s->tags[lit_var(q)] = l_True;
+ veci_push(&s->tagged,lit_var(q));
+ }
+ }
+ else{
+ int* lits = clause_begin(c);
+ for (j = 1; j < clause_size(c); j++)
+ if (s->levels[lit_var(lits[j])] > 0)
+ {
+ s->tags[lit_var(lits[j])] = l_True;
+ veci_push(&s->tagged,lit_var(lits[j]));
+ }
+ }
+ }
+ }
+ }
+ for (i = 0; i < veci_size(&s->tagged); i++)
+ s->tags[veci_begin(&s->tagged)[i]] = l_Undef;
+ veci_resize(&s->tagged,0);
+}
+
+
static void sat_solver_analyze(sat_solver* s, clause* c, veci* learnt)
{
lit* trail = s->trail;
@@ -871,6 +976,8 @@ static lbool sat_solver_search(sat_solver* s, ABC_INT64_T nof_conflicts, ABC_INT
#endif
s->stats.conflicts++; conflictC++;
if (sat_solver_dlevel(s) == s->root_level){
+// lit p = clause_is_lit(confl)? clause_read_lit(confl) : clause_begin(confl)[0];
+// sat_solver_analyze_final(s, lit_neg(p), &s->conf_final);
veci_delete(&learnt_clause);
return l_False;
}
@@ -896,7 +1003,8 @@ static lbool sat_solver_search(sat_solver* s, ABC_INT64_T nof_conflicts, ABC_INT
return l_Undef; }
if ( (s->nConfLimit && s->stats.conflicts > s->nConfLimit) ||
- (s->nInsLimit && s->stats.inspects > s->nInsLimit) )
+// (s->nInsLimit && s->stats.inspects > s->nInsLimit) )
+ (s->nInsLimit && s->stats.propagations > s->nInsLimit) )
{
// Reached bound on number of conflicts:
s->progress_estimate = sat_solver_progress(s);
@@ -938,7 +1046,10 @@ static lbool sat_solver_search(sat_solver* s, ABC_INT64_T nof_conflicts, ABC_INT
return l_True;
}
- assume(s,lit_neg(toLit(next)));
+ if ( s->polarity[next] ) // positive polarity
+ assume(s,toLit(next));
+ else
+ assume(s,lit_neg(toLit(next)));
}
}
@@ -963,6 +1074,7 @@ sat_solver* sat_solver_new(void)
veci_new(&s->model);
veci_new(&s->act_vars);
veci_new(&s->temp_clause);
+ veci_new(&s->conf_final);
// initialize arrays
s->wlists = 0;
@@ -1038,6 +1150,7 @@ void sat_solver_delete(sat_solver* s)
veci_delete(&s->model);
veci_delete(&s->act_vars);
veci_delete(&s->temp_clause);
+ veci_delete(&s->conf_final);
ABC_FREE(s->binary);
// delete arrays
@@ -1056,6 +1169,7 @@ void sat_solver_delete(sat_solver* s)
ABC_FREE(s->levels );
ABC_FREE(s->trail );
ABC_FREE(s->tags );
+ ABC_FREE(s->polarity );
}
sat_solver_store_free(s);
@@ -1063,7 +1177,7 @@ void sat_solver_delete(sat_solver* s)
}
-bool sat_solver_addclause(sat_solver* s, lit* begin, lit* end)
+int sat_solver_addclause(sat_solver* s, lit* begin, lit* end)
{
lit *i,*j;
int maxvar;
@@ -1096,8 +1210,7 @@ bool sat_solver_addclause(sat_solver* s, lit* begin, lit* end)
// add clause to internal storage
if ( s->pStore )
{
- extern int Sto_ManAddClause( void * p, lit * pBeg, lit * pEnd );
- int RetValue = Sto_ManAddClause( s->pStore, begin, end );
+ int RetValue = Sto_ManAddClause( (Sto_Man_t *)s->pStore, begin, end );
assert( RetValue );
}
///////////////////////////////////
@@ -1135,7 +1248,7 @@ bool sat_solver_addclause(sat_solver* s, lit* begin, lit* end)
}
-bool sat_solver_simplify(sat_solver* s)
+int sat_solver_simplify(sat_solver* s)
{
clause** reasons;
int type;
@@ -1171,10 +1284,30 @@ bool sat_solver_simplify(sat_solver* s)
return true;
}
+double luby(double y, int x)
+{
+ int size, seq;
+ for (size = 1, seq = 0; size < x+1; seq++, size = 2*size + 1);
+ while (size-1 != x){
+ size = (size-1) >> 1;
+ seq--;
+ x = x % size;
+ }
+ return pow(y, (double)seq);
+}
+
+void luby_test()
+{
+ int i;
+ for ( i = 0; i < 20; i++ )
+ printf( "%d ", (int)luby(2,i) );
+ printf( "\n" );
+}
int sat_solver_solve(sat_solver* s, lit* begin, lit* end, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, ABC_INT64_T nConfLimitGlobal, ABC_INT64_T nInsLimitGlobal)
{
- ABC_INT64_T nof_conflicts = 100;
+ int restart_iter = 0;
+ ABC_INT64_T nof_conflicts;
ABC_INT64_T nof_learnts = sat_solver_nclauses(s) / 3;
lbool status = l_Undef;
lbool* values = s->assigns;
@@ -1185,8 +1318,7 @@ int sat_solver_solve(sat_solver* s, lit* begin, lit* end, ABC_INT64_T nConfLimit
{
if ( s->pStore )
{
- extern int Sto_ManAddClause( void * p, lit * pBeg, lit * pEnd );
- int RetValue = Sto_ManAddClause( s->pStore, NULL, NULL );
+ int RetValue = Sto_ManAddClause( (Sto_Man_t *)s->pStore, NULL, NULL );
assert( RetValue );
}
return l_False;
@@ -1201,7 +1333,8 @@ int sat_solver_solve(sat_solver* s, lit* begin, lit* end, ABC_INT64_T nConfLimit
if ( nConfLimit )
s->nConfLimit = s->stats.conflicts + nConfLimit;
if ( nInsLimit )
- s->nInsLimit = s->stats.inspects + nInsLimit;
+// s->nInsLimit = s->stats.inspects + nInsLimit;
+ s->nInsLimit = s->stats.propagations + nInsLimit;
if ( nConfLimitGlobal && (s->nConfLimit == 0 || s->nConfLimit > nConfLimitGlobal) )
s->nConfLimit = nConfLimitGlobal;
if ( nInsLimitGlobal && (s->nInsLimit == 0 || s->nInsLimit > nInsLimitGlobal) )
@@ -1250,9 +1383,11 @@ int sat_solver_solve(sat_solver* s, lit* begin, lit* end, ABC_INT64_T nConfLimit
s->progress_estimate*100);
fflush(stdout);
}
+ nof_conflicts = (ABC_INT64_T)( 100 * luby(2, restart_iter++) );
+//printf( "%d ", (int)nof_conflicts );
status = sat_solver_search(s, nof_conflicts, nof_learnts);
- nof_conflicts = nof_conflicts * 3 / 2; //*= 1.5;
- nof_learnts = nof_learnts * 11 / 10; //*= 1.1;
+// nof_conflicts = nof_conflicts * 3 / 2; //*= 1.5;
+ nof_learnts = nof_learnts * 11 / 10; //*= 1.1;
// quit the loop if reached an external limit
if ( s->nConfLimit && s->stats.conflicts > s->nConfLimit )
@@ -1260,7 +1395,8 @@ int sat_solver_solve(sat_solver* s, lit* begin, lit* end, ABC_INT64_T nConfLimit
// printf( "Reached the limit on the number of conflicts (%d).\n", s->nConfLimit );
break;
}
- if ( s->nInsLimit && s->stats.inspects > s->nInsLimit )
+// if ( s->nInsLimit && s->stats.inspects > s->nInsLimit )
+ if ( s->nInsLimit && s->stats.propagations > s->nInsLimit )
{
// printf( "Reached the limit on the number of implications (%d).\n", s->nInsLimit );
break;
@@ -1274,8 +1410,7 @@ int sat_solver_solve(sat_solver* s, lit* begin, lit* end, ABC_INT64_T nConfLimit
////////////////////////////////////////////////
if ( status == l_False && s->pStore )
{
- extern int Sto_ManAddClause( void * p, lit * pBeg, lit * pEnd );
- int RetValue = Sto_ManAddClause( s->pStore, NULL, NULL );
+ int RetValue = Sto_ManAddClause( (Sto_Man_t *)s->pStore, NULL, NULL );
assert( RetValue );
}
////////////////////////////////////////////////
@@ -1305,41 +1440,35 @@ int sat_solver_nconflicts(sat_solver* s)
void sat_solver_store_alloc( sat_solver * s )
{
- extern void * Sto_ManAlloc();
assert( s->pStore == NULL );
s->pStore = Sto_ManAlloc();
}
void sat_solver_store_write( sat_solver * s, char * pFileName )
{
- extern void Sto_ManDumpClauses( void * p, char * pFileName );
- if ( s->pStore ) Sto_ManDumpClauses( s->pStore, pFileName );
+ if ( s->pStore ) Sto_ManDumpClauses( (Sto_Man_t *)s->pStore, pFileName );
}
void sat_solver_store_free( sat_solver * s )
{
- extern void Sto_ManFree( void * p );
- if ( s->pStore ) Sto_ManFree( s->pStore );
+ if ( s->pStore ) Sto_ManFree( (Sto_Man_t *)s->pStore );
s->pStore = NULL;
}
int sat_solver_store_change_last( sat_solver * s )
{
- extern int Sto_ManChangeLastClause( void * p );
- if ( s->pStore ) return Sto_ManChangeLastClause( s->pStore );
+ if ( s->pStore ) return Sto_ManChangeLastClause( (Sto_Man_t *)s->pStore );
return -1;
}
void sat_solver_store_mark_roots( sat_solver * s )
{
- extern void Sto_ManMarkRoots( void * p );
- if ( s->pStore ) Sto_ManMarkRoots( s->pStore );
+ if ( s->pStore ) Sto_ManMarkRoots( (Sto_Man_t *)s->pStore );
}
void sat_solver_store_mark_clauses_a( sat_solver * s )
{
- extern void Sto_ManMarkClausesA( void * p );
- if ( s->pStore ) Sto_ManMarkClausesA( s->pStore );
+ if ( s->pStore ) Sto_ManMarkClausesA( (Sto_Man_t *)s->pStore );
}
void * sat_solver_store_release( sat_solver * s )
@@ -1404,3 +1533,5 @@ void sat_solver_sort(void** array, int size, int(*comp)(const void *, const void
// for ( i = 1; i < size; i++ )
// assert(comp(array[i-1], array[i])<0);
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/bsat/satSolver.h b/src/sat/bsat/satSolver.h
index f37c1738..2e435c59 100644
--- a/src/sat/bsat/satSolver.h
+++ b/src/sat/bsat/satSolver.h
@@ -2,7 +2,7 @@
MiniSat -- Copyright (c) 2005, Niklas Sorensson
http://www.cs.chalmers.se/Cs/Research/FormalMethods/MiniSat/
-Permission is hereby granted, ABC_FREE of charge, to any person obtaining a copy of this software and
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
@@ -22,28 +22,29 @@ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWA
#ifndef satSolver_h
#define satSolver_h
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
-#include "abc_global.h"
#include "satVec.h"
#include "satMem.h"
+ABC_NAMESPACE_HEADER_START
+
+
//=================================================================================================
// Simple types:
-// does not work for c++
-//typedef int bool;
#ifndef __cplusplus
-#ifndef bool
-#define bool int
+#ifndef false
+# define false 0
+#endif
+#ifndef true
+# define true 1
#endif
#endif
-
-static const bool true = 1;
-static const bool false = 0;
typedef int lit;
typedef char lbool;
@@ -74,8 +75,8 @@ typedef struct sat_solver_t sat_solver;
extern sat_solver* sat_solver_new(void);
extern void sat_solver_delete(sat_solver* s);
-extern bool sat_solver_addclause(sat_solver* s, lit* begin, lit* end);
-extern bool sat_solver_simplify(sat_solver* s);
+extern int sat_solver_addclause(sat_solver* s, lit* begin, lit* end);
+extern int sat_solver_simplify(sat_solver* s);
extern int sat_solver_solve(sat_solver* s, lit* begin, lit* end, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, ABC_INT64_T nConfLimitGlobal, ABC_INT64_T nInsLimitGlobal);
extern int sat_solver_nvars(sat_solver* s);
@@ -89,7 +90,7 @@ struct stats_t
ABC_INT64_T starts, decisions, propagations, inspects, conflicts;
ABC_INT64_T clauses, clauses_literals, learnts, learnts_literals, max_literals, tot_literals;
};
-typedef struct stats_t stats;
+typedef struct stats_t stats_t;
extern void Sat_SolverWriteDimacs( sat_solver * p, char * pFileName, lit* assumptionsBegin, lit* assumptionsEnd, int incrementVars );
extern void Sat_SolverPrintStats( FILE * pFile, sat_solver * p );
@@ -139,6 +140,7 @@ struct sat_solver_t
clause** reasons; //
int* levels; //
lit* trail;
+ char* polarity;
clause* binary; // A temporary binary clause
lbool* tags; //
@@ -148,6 +150,8 @@ struct sat_solver_t
veci order; // Variable order. (heap) (contains: var)
veci trail_lim; // Separator indices for different decision levels in 'trail'. (contains: int)
veci model; // If problem is solved, this vector contains the model (contains: lbool).
+ veci conf_final; // If problem is unsatisfiable (possibly under assumptions),
+ // this vector represent the final conflict clause expressed in the assumptions.
int root_level; // Level of first proper decision.
int simpdb_assigns;// Number of top-level assignments at last 'simplifyDB()'.
@@ -156,7 +160,7 @@ struct sat_solver_t
double progress_estimate;
int verbosity; // Verbosity level. 0=silent, 1=some progress report, 2=everything
- stats stats;
+ stats_t stats;
ABC_INT64_T nConfLimit; // external limit on the number of conflicts
ABC_INT64_T nInsLimit; // external limit on the number of implications
@@ -210,4 +214,8 @@ static void sat_solver_compress(sat_solver* s)
}
}
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif
diff --git a/src/sat/bsat/satStore.c b/src/sat/bsat/satStore.c
index fff8a836..ac74c4a6 100644
--- a/src/sat/bsat/satStore.c
+++ b/src/sat/bsat/satStore.c
@@ -26,6 +26,9 @@
#include "satStore.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -185,6 +188,7 @@ int Sto_ManAddClause( Sto_Man_t * p, lit * pBeg, lit * pEnd )
// get memory for the clause
nSize = sizeof(Sto_Cls_t) + sizeof(lit) * (pEnd - pBeg);
+ nSize = (nSize / sizeof(char*) + ((nSize % sizeof(char*)) > 0)) * sizeof(char*); // added by Saurabh on Sep 3, 2009
pClause = (Sto_Cls_t *)Sto_ManMemoryFetch( p, nSize );
memset( pClause, 0, sizeof(Sto_Cls_t) );
@@ -192,6 +196,7 @@ int Sto_ManAddClause( Sto_Man_t * p, lit * pBeg, lit * pEnd )
pClause->Id = p->nClauses++;
pClause->nLits = pEnd - pBeg;
memcpy( pClause->pLits, pBeg, sizeof(lit) * (pEnd - pBeg) );
+// assert( pClause->pLits[0] >= 0 );
// add the clause to the list
if ( p->pHead == NULL )
@@ -461,3 +466,5 @@ Sto_Man_t * Sto_ManLoadClauses( char * pFileName )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/bsat/satStore.h b/src/sat/bsat/satStore.h
index ea11f46a..0293aea7 100644
--- a/src/sat/bsat/satStore.h
+++ b/src/sat/bsat/satStore.h
@@ -21,6 +21,7 @@
#ifndef __SAT_STORE_H__
#define __SAT_STORE_H__
+
/*
The trace of SAT solving contains the original clauses of the problem
along with the learned clauses derived during SAT solving.
@@ -38,9 +39,7 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+ABC_NAMESPACE_HEADER_START
#ifdef _WIN32
#define inline __inline // compatible with MS VS 6.0
@@ -116,8 +115,10 @@ extern int Sto_ManMemoryReport( Sto_Man_t * p );
extern void Sto_ManMarkRoots( Sto_Man_t * p );
extern void Sto_ManMarkClausesA( Sto_Man_t * p );
extern void Sto_ManDumpClauses( Sto_Man_t * p, char * pFileName );
+extern int Sto_ManChangeLastClause( Sto_Man_t * p );
extern Sto_Man_t * Sto_ManLoadClauses( char * pFileName );
+
/*=== satInter.c ==========================================================*/
typedef struct Int_Man_t_ Int_Man_t;
extern Int_Man_t * Int_ManAlloc();
@@ -143,9 +144,11 @@ extern Intp_Man_t * Intp_ManAlloc();
extern void Intp_ManFree( Intp_Man_t * p );
extern void * Intp_ManUnsatCore( Intp_Man_t * p, Sto_Man_t * pCnf, int fVerbose );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/sat/bsat/satTrace.c b/src/sat/bsat/satTrace.c
index 08cfadf6..ae701ce9 100644
--- a/src/sat/bsat/satTrace.c
+++ b/src/sat/bsat/satTrace.c
@@ -20,6 +20,9 @@
#include "satSolver.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*
The trace of SAT solving contains the original clause of the problem
along with the learned clauses derived during SAT solving.
@@ -105,3 +108,5 @@ void Sat_SolverTraceWrite( sat_solver * pSat, int * pBeg, int * pEnd, int fRoot
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/bsat/satUtil.c b/src/sat/bsat/satUtil.c
index 5f8008bb..0ce40acd 100644
--- a/src/sat/bsat/satUtil.c
+++ b/src/sat/bsat/satUtil.c
@@ -22,6 +22,9 @@
#include <assert.h>
#include "satSolver.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -35,7 +38,7 @@ struct clause_t
static inline int clause_size( clause* c ) { return c->size_learnt >> 1; }
static inline lit* clause_begin( clause* c ) { return c->lits; }
-static void Sat_SolverClauseWriteDimacs( FILE * pFile, clause * pC, bool fIncrement );
+static void Sat_SolverClauseWriteDimacs( FILE * pFile, clause * pC, int fIncrement );
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
@@ -78,13 +81,13 @@ void Sat_SolverWriteDimacs( sat_solver * p, char * pFileName, lit* assumptionsBe
nClauses = p->clauses.size;
pClauses = p->clauses.ptr;
for ( i = 0; i < nClauses; i++ )
- Sat_SolverClauseWriteDimacs( pFile, pClauses[i], incrementVars );
+ Sat_SolverClauseWriteDimacs( pFile, (clause *)pClauses[i], incrementVars );
// write the learned clauses
nClauses = p->learnts.size;
pClauses = p->learnts.ptr;
for ( i = 0; i < nClauses; i++ )
- Sat_SolverClauseWriteDimacs( pFile, pClauses[i], incrementVars );
+ Sat_SolverClauseWriteDimacs( pFile, (clause *)pClauses[i], incrementVars );
// write zero-level assertions
for ( i = 0; i < p->size; i++ )
@@ -119,14 +122,14 @@ void Sat_SolverWriteDimacs( sat_solver * p, char * pFileName, lit* assumptionsBe
SeeAlso []
***********************************************************************/
-void Sat_SolverClauseWriteDimacs( FILE * pFile, clause * pC, bool fIncrement )
+void Sat_SolverClauseWriteDimacs( FILE * pFile, clause * pC, int fIncrement )
{
lit * pLits = clause_begin(pC);
int nLits = clause_size(pC);
int i;
for ( i = 0; i < nLits; i++ )
- fprintf( pFile, "%s%d ", (lit_sign(pLits[i])? "-": ""), lit_var(pLits[i]) + (int)(fIncrement>0) );
+ fprintf( pFile, "%s%d ", (lit_sign(pLits[i])? "-": ""), lit_var(pLits[i]) + (fIncrement>0) );
if ( fIncrement )
fprintf( pFile, "0" );
fprintf( pFile, "\n" );
@@ -169,7 +172,7 @@ int * Sat_SolverGetModel( sat_solver * p, int * pVars, int nVars )
{
int * pModel;
int i;
- pModel = ABC_ALLOC( int, nVars+1 );
+ pModel = ABC_CALLOC( int, nVars+1 );
for ( i = 0; i < nVars; i++ )
{
assert( pVars[i] >= 0 && pVars[i] < p->size );
@@ -213,7 +216,7 @@ void Sat_SolverDoubleClauses( sat_solver * p, int iVar )
nClauses = vecp_size(&p->clauses);
for ( c = 0; c < nClauses; c++ )
{
- pClause = p->clauses.ptr[c];
+ pClause = (clause *)p->clauses.ptr[c];
nLits = clause_size(pClause);
pLits = clause_begin(pClause);
for ( v = 0; v < nLits; v++ )
@@ -231,3 +234,5 @@ void Sat_SolverDoubleClauses( sat_solver * p, int iVar )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/bsat/satVec.h b/src/sat/bsat/satVec.h
index f017c90b..4c3763e3 100644
--- a/src/sat/bsat/satVec.h
+++ b/src/sat/bsat/satVec.h
@@ -2,7 +2,7 @@
MiniSat -- Copyright (c) 2005, Niklas Sorensson
http://www.cs.chalmers.se/Cs/Research/FormalMethods/MiniSat/
-Permission is hereby granted, ABC_FREE of charge, to any person obtaining a copy of this software and
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
@@ -22,6 +22,11 @@ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWA
#ifndef satVec_h
#define satVec_h
+#include "abc_global.h"
+
+ABC_NAMESPACE_HEADER_START
+
+
// vector of 32-bit intergers (added for 64-bit portability)
struct veci_t {
int size;
@@ -78,4 +83,8 @@ static inline void vecp_push (vecp* v, void* e)
}
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif
diff --git a/src/sat/csat/csat_apis.c b/src/sat/csat/csat_apis.c
index ecad9d37..d49f75c0 100644
--- a/src/sat/csat/csat_apis.c
+++ b/src/sat/csat/csat_apis.c
@@ -19,6 +19,11 @@
#include "abc.h"
#include "fraig.h"
#include "csat_apis.h"
+#include "stmm.h"
+#include "main.h"
+
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -56,7 +61,7 @@ extern void Abc_Start();
extern void Abc_Stop();
// some external procedures
-extern int Io_WriteBench( Abc_Ntk_t * pNtk, char * FileName );
+extern int Io_WriteBench( Abc_Ntk_t * pNtk, const char * FileName );
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
@@ -215,51 +220,51 @@ int ABC_AddGate( ABC_Manager mng, enum GateType type, char * name, int nofi, cha
case CSAT_CONST:
if ( nofi != 0 )
{ printf( "ABC_AddGate: The constant gate \"%s\" has fanins.\n", name ); return 0; }
- pSop = Abc_SopCreateConst1( mng->pNtk->pManFunc );
+ pSop = Abc_SopCreateConst1( (Extra_MmFlex_t *)mng->pNtk->pManFunc );
break;
case CSAT_BAND:
if ( nofi < 1 )
{ printf( "ABC_AddGate: The AND gate \"%s\" no fanins.\n", name ); return 0; }
- pSop = Abc_SopCreateAnd( mng->pNtk->pManFunc, nofi, NULL );
+ pSop = Abc_SopCreateAnd( (Extra_MmFlex_t *)mng->pNtk->pManFunc, nofi, NULL );
break;
case CSAT_BNAND:
if ( nofi < 1 )
{ printf( "ABC_AddGate: The NAND gate \"%s\" no fanins.\n", name ); return 0; }
- pSop = Abc_SopCreateNand( mng->pNtk->pManFunc, nofi );
+ pSop = Abc_SopCreateNand( (Extra_MmFlex_t *)mng->pNtk->pManFunc, nofi );
break;
case CSAT_BOR:
if ( nofi < 1 )
{ printf( "ABC_AddGate: The OR gate \"%s\" no fanins.\n", name ); return 0; }
- pSop = Abc_SopCreateOr( mng->pNtk->pManFunc, nofi, NULL );
+ pSop = Abc_SopCreateOr( (Extra_MmFlex_t *)mng->pNtk->pManFunc, nofi, NULL );
break;
case CSAT_BNOR:
if ( nofi < 1 )
{ printf( "ABC_AddGate: The NOR gate \"%s\" no fanins.\n", name ); return 0; }
- pSop = Abc_SopCreateNor( mng->pNtk->pManFunc, nofi );
+ pSop = Abc_SopCreateNor( (Extra_MmFlex_t *)mng->pNtk->pManFunc, nofi );
break;
case CSAT_BXOR:
if ( nofi < 1 )
{ printf( "ABC_AddGate: The XOR gate \"%s\" no fanins.\n", name ); return 0; }
if ( nofi > 2 )
{ printf( "ABC_AddGate: The XOR gate \"%s\" has more than two fanins.\n", name ); return 0; }
- pSop = Abc_SopCreateXor( mng->pNtk->pManFunc, nofi );
+ pSop = Abc_SopCreateXor( (Extra_MmFlex_t *)mng->pNtk->pManFunc, nofi );
break;
case CSAT_BXNOR:
if ( nofi < 1 )
{ printf( "ABC_AddGate: The XNOR gate \"%s\" no fanins.\n", name ); return 0; }
if ( nofi > 2 )
{ printf( "ABC_AddGate: The XNOR gate \"%s\" has more than two fanins.\n", name ); return 0; }
- pSop = Abc_SopCreateNxor( mng->pNtk->pManFunc, nofi );
+ pSop = Abc_SopCreateNxor( (Extra_MmFlex_t *)mng->pNtk->pManFunc, nofi );
break;
case CSAT_BINV:
if ( nofi != 1 )
{ printf( "ABC_AddGate: The inverter gate \"%s\" does not have exactly one fanin.\n", name ); return 0; }
- pSop = Abc_SopCreateInv( mng->pNtk->pManFunc );
+ pSop = Abc_SopCreateInv( (Extra_MmFlex_t *)mng->pNtk->pManFunc );
break;
case CSAT_BBUF:
if ( nofi != 1 )
{ printf( "ABC_AddGate: The buffer gate \"%s\" does not have exactly one fanin.\n", name ); return 0; }
- pSop = Abc_SopCreateBuf( mng->pNtk->pManFunc );
+ pSop = Abc_SopCreateBuf( (Extra_MmFlex_t *)mng->pNtk->pManFunc );
break;
default :
break;
@@ -675,7 +680,7 @@ CSAT_Target_ResultT * ABC_Get_Target_Result( ABC_Manager mng, int TargetID )
void ABC_Dump_Bench_File( ABC_Manager mng )
{
Abc_Ntk_t * pNtkTemp, * pNtkAig;
- char * pFileName;
+ const char * pFileName;
// derive the netlist
pNtkAig = Abc_NtkStrash( mng->pNtk, 0, 0, 0 );
@@ -769,3 +774,5 @@ char * ABC_GetNodeName( ABC_Manager mng, Abc_Obj_t * pNode )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/csat/csat_apis.h b/src/sat/csat/csat_apis.h
index 337056a3..a6c1b18a 100644
--- a/src/sat/csat/csat_apis.h
+++ b/src/sat/csat/csat_apis.h
@@ -19,6 +19,7 @@
#ifndef __ABC_APIS_H__
#define __ABC_APIS_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -27,9 +28,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// STRUCTURE DEFINITIONS ///
@@ -211,9 +213,11 @@ extern void ABC_TargetResFree( CSAT_Target_ResultT * p );
extern void CSAT_SetCaller(ABC_Manager mng, enum CSAT_CallerT caller);
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/sat/fraig/fraig.h b/src/sat/fraig/fraig.h
index ce686cef..2b499967 100644
--- a/src/sat/fraig/fraig.h
+++ b/src/sat/fraig/fraig.h
@@ -19,6 +19,7 @@
#ifndef __FRAIG_H__
#define __FRAIG_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -27,9 +28,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// STRUCTURE DEFINITIONS ///
@@ -249,8 +251,10 @@ extern Fraig_NodeVec_t * Fraig_CollectSupergate( Fraig_Node_t * pNode, int fSt
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/sat/fraig/fraigApi.c b/src/sat/fraig/fraigApi.c
index 79a7c224..6e0ab959 100644
--- a/src/sat/fraig/fraigApi.c
+++ b/src/sat/fraig/fraigApi.c
@@ -18,6 +18,9 @@
#include "fraigInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -295,3 +298,5 @@ void Fraig_NodeSetChoice( Fraig_Man_t * pMan, Fraig_Node_t * pNodeOld, Fraig_Nod
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/fraig/fraigCanon.c b/src/sat/fraig/fraigCanon.c
index 89bc924f..47539db2 100644
--- a/src/sat/fraig/fraigCanon.c
+++ b/src/sat/fraig/fraigCanon.c
@@ -19,6 +19,9 @@
#include <limits.h>
#include "fraigInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -216,3 +219,5 @@ Fraig_Node_t * Fraig_NodeAndCanon( Fraig_Man_t * pMan, Fraig_Node_t * p1, Fraig_
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/fraig/fraigChoice.c b/src/sat/fraig/fraigChoice.c
index 896e5d2d..21d4fe10 100644
--- a/src/sat/fraig/fraigChoice.c
+++ b/src/sat/fraig/fraigChoice.c
@@ -18,6 +18,9 @@
#include "fraigInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -239,3 +242,5 @@ Fraig_ManCheckConsistency( pMan );
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/fraig/fraigFanout.c b/src/sat/fraig/fraigFanout.c
index 789bffca..0e6c86f8 100644
--- a/src/sat/fraig/fraigFanout.c
+++ b/src/sat/fraig/fraigFanout.c
@@ -18,6 +18,9 @@
#include "fraigInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
#ifdef FRAIG_ENABLE_FANOUTS
////////////////////////////////////////////////////////////////////////
@@ -173,3 +176,5 @@ int Fraig_NodeGetFanoutNum( Fraig_Node_t * pNode )
#endif
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/fraig/fraigFeed.c b/src/sat/fraig/fraigFeed.c
index 7977824d..47f946e1 100644
--- a/src/sat/fraig/fraigFeed.c
+++ b/src/sat/fraig/fraigFeed.c
@@ -18,6 +18,9 @@
#include "fraigInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -736,7 +739,7 @@ void Fraig_ReallocateSimulationInfo( Fraig_Man_t * p )
// signatures remain without changes
}
- // replace the manager to ABC_FREE up some memory
+ // replace the manager to free up some memory
Fraig_MemFixedStop( p->mmSims, 0 );
p->mmSims = mmSimsNew;
@@ -906,3 +909,5 @@ printf( "\n" );
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/fraig/fraigInt.h b/src/sat/fraig/fraigInt.h
index ac6ea873..7cc2194a 100644
--- a/src/sat/fraig/fraigInt.h
+++ b/src/sat/fraig/fraigInt.h
@@ -19,6 +19,7 @@
#ifndef __FRAIG_INT_H__
#define __FRAIG_INT_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -33,6 +34,9 @@
#include "fraig.h"
#include "msat.h"
+ABC_NAMESPACE_HEADER_START
+
+
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
@@ -57,9 +61,9 @@
#define FRAIG_MAX_PRIMES 1024 // the maximum number of primes used for hashing
// this parameter determines when simulation info is extended
-// it will be extended when the ABC_FREE storage in the dynamic simulation
+// it will be extended when the free storage in the dynamic simulation
// info is less or equal to this number of words (FRAIG_WORDS_STORE)
-// this is done because if the ABC_FREE storage for dynamic simulation info
+// this is done because if the free storage for dynamic simulation info
// is not sufficient, computation becomes inefficient
#define FRAIG_WORDS_STORE 5
@@ -419,6 +423,10 @@ extern int Fraig_NodeIsTravIdPrevious( Fraig_Man_t * pMan, Fraig
/*=== fraigVec.c ===============================================================*/
extern void Fraig_NodeVecSortByRefCount( Fraig_NodeVec_t * p );
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif
////////////////////////////////////////////////////////////////////////
diff --git a/src/sat/fraig/fraigMan.c b/src/sat/fraig/fraigMan.c
index b71262d8..ba08d793 100644
--- a/src/sat/fraig/fraigMan.c
+++ b/src/sat/fraig/fraigMan.c
@@ -18,6 +18,9 @@
#include "fraigInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -42,7 +45,7 @@ int timeAssign;
***********************************************************************/
void Prove_ParamsSetDefault( Prove_Params_t * pParams )
{
- // clean the parameter structure
+ // clean the parameter structure
memset( pParams, 0, sizeof(Prove_Params_t) );
// general parameters
pParams->fUseFraiging = 1; // enables fraiging
@@ -52,7 +55,7 @@ void Prove_ParamsSetDefault( Prove_Params_t * pParams )
// iterations
pParams->nItersMax = 6; // the number of iterations
// mitering
- pParams->nMiteringLimitStart = 300; // starting mitering limit
+ pParams->nMiteringLimitStart = 5000; // starting mitering limit
pParams->nMiteringLimitMulti = 2.0; // multiplicative coefficient to increase the limit in each iteration
// rewriting (currently not used)
pParams->nRewritingLimitStart = 3; // the number of rewriting iterations
@@ -382,7 +385,7 @@ void Fraig_ManPrintStats( Fraig_Man_t * p )
SeeAlso []
***********************************************************************/
-Fraig_NodeVec_t * Fraig_UtilInfoAlloc( int nSize, int nWords, bool fClean )
+Fraig_NodeVec_t * Fraig_UtilInfoAlloc( int nSize, int nWords, int fClean )
{
Fraig_NodeVec_t * vInfo;
unsigned * pUnsigned;
@@ -538,3 +541,5 @@ void Fraig_ManAddClause( Fraig_Man_t * p, Fraig_Node_t ** ppNodes, int nNodes )
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/fraig/fraigMem.c b/src/sat/fraig/fraigMem.c
index 1cc99790..ef52765e 100644
--- a/src/sat/fraig/fraigMem.c
+++ b/src/sat/fraig/fraigMem.c
@@ -18,6 +18,9 @@
#include "fraigInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -29,7 +32,7 @@ struct Fraig_MemFixed_t_
int nEntriesAlloc; // the total number of entries allocated
int nEntriesUsed; // the number of entries in use
int nEntriesMax; // the max number of entries in use
- char * pEntriesFree; // the linked list of ABC_FREE entries
+ char * pEntriesFree; // the linked list of free entries
// this is where the memory is stored
int nChunkSize; // the size of one chunk
@@ -130,7 +133,7 @@ char * Fraig_MemFixedEntryFetch( Fraig_MemFixed_t * p )
char * pTemp;
int i;
- // check if there are still ABC_FREE entries
+ // check if there are still free entries
if ( p->nEntriesUsed == p->nEntriesAlloc )
{ // need to allocate more entries
assert( p->pEntriesFree == NULL );
@@ -159,7 +162,7 @@ char * Fraig_MemFixedEntryFetch( Fraig_MemFixed_t * p )
p->nEntriesUsed++;
if ( p->nEntriesMax < p->nEntriesUsed )
p->nEntriesMax = p->nEntriesUsed;
- // return the first entry in the ABC_FREE entry list
+ // return the first entry in the free entry list
pTemp = p->pEntriesFree;
p->pEntriesFree = *((char **)pTemp);
return pTemp;
@@ -180,7 +183,7 @@ void Fraig_MemFixedEntryRecycle( Fraig_MemFixed_t * p, char * pEntry )
{
// decrement the counter of used entries
p->nEntriesUsed--;
- // add the entry to the linked list of ABC_FREE entries
+ // add the entry to the linked list of free entries
*((char **)pEntry) = p->pEntriesFree;
p->pEntriesFree = pEntry;
}
@@ -214,7 +217,7 @@ void Fraig_MemFixedRestart( Fraig_MemFixed_t * p )
}
// set the last link
*((char **)pTemp) = NULL;
- // set the ABC_FREE entry list
+ // set the free entry list
p->pEntriesFree = p->pChunks[0];
// set the correct statistics
p->nMemoryAlloc = p->nEntrySize * p->nChunkSize;
@@ -244,3 +247,5 @@ int Fraig_MemFixedReadMemUsage( Fraig_MemFixed_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/fraig/fraigNode.c b/src/sat/fraig/fraigNode.c
index 4cfe035d..9f95cd46 100644
--- a/src/sat/fraig/fraigNode.c
+++ b/src/sat/fraig/fraigNode.c
@@ -18,6 +18,9 @@
#include "fraigInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -311,3 +314,5 @@ void Fraig_NodeSimulate( Fraig_Node_t * pNode, int iWordStart, int iWordStop, in
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/fraig/fraigPrime.c b/src/sat/fraig/fraigPrime.c
index 127ad478..42a079fd 100644
--- a/src/sat/fraig/fraigPrime.c
+++ b/src/sat/fraig/fraigPrime.c
@@ -18,6 +18,9 @@
#include "fraigInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -142,3 +145,5 @@ unsigned int Cudd_PrimeFraig( unsigned int p)
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/fraig/fraigSat.c b/src/sat/fraig/fraigSat.c
index 084d1538..b96bc5a1 100644
--- a/src/sat/fraig/fraigSat.c
+++ b/src/sat/fraig/fraigSat.c
@@ -16,8 +16,12 @@
***********************************************************************/
+#include <math.h>
#include "fraigInt.h"
-#include "math.h"
+#include "msatInt.h"
+
+ABC_NAMESPACE_IMPL_START
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
@@ -36,8 +40,6 @@ static void Fraig_SupergateAddClausesMux( Fraig_Man_t * pMan, Fraig_Node_t * pNo
static void Fraig_DetectFanoutFreeConeMux( Fraig_Man_t * pMan, Fraig_Node_t * pNode );
static void Fraig_SetActivity( Fraig_Man_t * pMan, Fraig_Node_t * pOld, Fraig_Node_t * pNew );
-extern void * Msat_ClauseVecReadEntry( void * p, int i );
-
// The lesson learned seems to be that variable should be in reverse topological order
// from the output of the miter. The ordering of adjacency lists is very important.
// The best way seems to be fanins followed by fanouts. Slight changes to this order
@@ -318,7 +320,7 @@ int Fraig_NodeIsEquivalent( Fraig_Man_t * p, Fraig_Node_t * pOld, Fraig_Node_t *
// nBTLimit /= 10;
if ( nBTLimit <= 10 )
return 0;
- nBTLimit = (int)sqrt(nBTLimit);
+ nBTLimit = (int)sqrt((double)nBTLimit);
// fSwitch = 1;
}
@@ -907,7 +909,7 @@ void Fraig_OrderVariables( Fraig_Man_t * pMan, Fraig_Node_t * pOld, Fraig_Node_t
{
// create the fanins of the supergate
assert( pNode->fClauses == 0 );
- // detecting a fanout-ABC_FREE cone (experiment only)
+ // detecting a fanout-free cone (experiment only)
// Fraig_DetectFanoutFreeCone( pMan, pNode );
if ( fUseMuxes && Fraig_NodeIsMuxType(pNode) )
@@ -1453,3 +1455,5 @@ void Fraig_SetActivity( Fraig_Man_t * pMan, Fraig_Node_t * pOld, Fraig_Node_t *
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/fraig/fraigTable.c b/src/sat/fraig/fraigTable.c
index 55d92b4a..79ab7ffc 100644
--- a/src/sat/fraig/fraigTable.c
+++ b/src/sat/fraig/fraigTable.c
@@ -18,6 +18,9 @@
#include "fraigInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -655,3 +658,5 @@ int Fraig_TableRehashF0( Fraig_Man_t * pMan, int fLinkEquiv )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/fraig/fraigUtil.c b/src/sat/fraig/fraigUtil.c
index 0930edbd..0d4cdfaf 100644
--- a/src/sat/fraig/fraigUtil.c
+++ b/src/sat/fraig/fraigUtil.c
@@ -19,6 +19,9 @@
#include "fraigInt.h"
#include <limits.h>
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -237,7 +240,7 @@ int Fraig_CheckTfi2( Fraig_Man_t * pMan, Fraig_Node_t * pOld, Fraig_Node_t * pNe
Description [This procedure collects the nodes reachable from
the POs of the AIG and sets the type of fanout counter (none, one,
or many) for each node. This procedure is useful to determine
- fanout-ABC_FREE cones of AND-nodes, which is helpful for rebalancing
+ fanout-free cones of AND-nodes, which is helpful for rebalancing
the AIG (see procedure Fraig_ManRebalance, or something like that).]
SideEffects []
@@ -1032,3 +1035,5 @@ int Fraig_NodeIsTravIdPrevious( Fraig_Man_t * pMan, Fraig_Node_t * pNode )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/fraig/fraigVec.c b/src/sat/fraig/fraigVec.c
index b47c6a2f..25d50bf3 100644
--- a/src/sat/fraig/fraigVec.c
+++ b/src/sat/fraig/fraigVec.c
@@ -18,6 +18,9 @@
#include "fraigInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -543,3 +546,5 @@ void Fraig_NodeVecSortByRefCount( Fraig_NodeVec_t * p )
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/lsat/solver.h b/src/sat/lsat/solver.h
index 8d198cb2..a50c4abe 100644
--- a/src/sat/lsat/solver.h
+++ b/src/sat/lsat/solver.h
@@ -2,7 +2,7 @@
Copyright (c) 2008, Niklas Sorensson
2008, Koen Claessen
-Permission is hereby granted, ABC_FREE of charge, to any person obtaining a copy of this software and
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
@@ -21,6 +21,10 @@ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWA
#ifndef Minisat_solver_h
#define Minisat_solver_h
+
+ABC_NAMESPACE_HEADER_START
+
+
// SolverTypes:
//
typedef struct solver_t solver;
@@ -104,8 +108,8 @@ int solver_num_conflicts (solver *s);
double random_seed;
double restart_luby_start; // The factor with which the values of the luby sequence is multiplied to get the restart (default 100)
double restart_luby_inc; // The constant that the luby sequence uses powers of (default 2)
- bool expensive_ccmin; // FIXME: describe.
- bool rnd_pol; // FIXME: describe.
+ int expensive_ccmin; // FIXME: describe.
+ int rnd_pol; // FIXME: describe.
int restart_first; // The initial restart limit. (default 100)
double restart_inc; // The factor with which the restart limit is multiplied in each restart. (default 1.5)
@@ -121,4 +125,8 @@ int solver_num_conflicts (solver *s);
uint64_t dec_vars, clauses_literals, learnts_literals, max_literals, tot_literals;
*/
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif
diff --git a/src/sat/msat/msat.h b/src/sat/msat/msat.h
index 2b28700c..6dc68cf8 100644
--- a/src/sat/msat/msat.h
+++ b/src/sat/msat/msat.h
@@ -21,6 +21,7 @@
#ifndef __MSAT_H__
#define __MSAT_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -29,22 +30,15 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// STRUCTURE DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
-#ifdef bool
-#undef bool
-#endif
-
-#ifndef __MVTYPES_H__
-typedef int bool;
-#endif
-
typedef struct Msat_Solver_t_ Msat_Solver_t;
// the vector of intergers and of clauses
@@ -77,13 +71,13 @@ typedef enum { MSAT_FALSE = -1, MSAT_UNKNOWN = 0, MSAT_TRUE = 1 } Msat_Type_t;
////////////////////////////////////////////////////////////////////////
/*=== satRead.c ============================================================*/
-extern bool Msat_SolverParseDimacs( FILE * pFile, Msat_Solver_t ** p, int fVerbose );
+extern int Msat_SolverParseDimacs( FILE * pFile, Msat_Solver_t ** p, int fVerbose );
/*=== satSolver.c ===========================================================*/
// adding vars, clauses, simplifying the database, and solving
-extern bool Msat_SolverAddVar( Msat_Solver_t * p, int Level );
-extern bool Msat_SolverAddClause( Msat_Solver_t * p, Msat_IntVec_t * pLits );
-extern bool Msat_SolverSimplifyDB( Msat_Solver_t * p );
-extern bool Msat_SolverSolve( Msat_Solver_t * p, Msat_IntVec_t * pVecAssumps, int nBackTrackLimit, int nTimeLimit );
+extern int Msat_SolverAddVar( Msat_Solver_t * p, int Level );
+extern int Msat_SolverAddClause( Msat_Solver_t * p, Msat_IntVec_t * pLits );
+extern int Msat_SolverSimplifyDB( Msat_Solver_t * p );
+extern int Msat_SolverSolve( Msat_Solver_t * p, Msat_IntVec_t * pVecAssumps, int nBackTrackLimit, int nTimeLimit );
// printing stats, assignments, and clauses
extern void Msat_SolverPrintStats( Msat_Solver_t * p );
extern void Msat_SolverPrintAssignment( Msat_Solver_t * p );
@@ -116,7 +110,7 @@ extern void Msat_SolverRemoveLearned( Msat_Solver_t * p );
extern void Msat_SolverRemoveMarked( Msat_Solver_t * p );
/*=== satSolverApi.c ===========================================================*/
// allocation, cleaning, and freeing the solver
-extern Msat_Solver_t * Msat_SolverAlloc( int nVars, double dClaInc, double dClaDecay, double dVarInc, double dVarDecay, bool fVerbose );
+extern Msat_Solver_t * Msat_SolverAlloc( int nVars, double dClaInc, double dClaDecay, double dVarInc, double dVarDecay, int fVerbose );
extern void Msat_SolverResize( Msat_Solver_t * pMan, int nVarsAlloc );
extern void Msat_SolverClean( Msat_Solver_t * p, int nVars );
extern void Msat_SolverPrepare( Msat_Solver_t * pSat, Msat_IntVec_t * vVars );
@@ -161,9 +155,11 @@ extern int Msat_VarHeapCountNodes( Msat_VarHeap_t * p, double Weigh
extern int Msat_VarHeapReadMax( Msat_VarHeap_t * p );
extern int Msat_VarHeapGetMax( Msat_VarHeap_t * p );
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/sat/msat/msatActivity.c b/src/sat/msat/msatActivity.c
index 1cd795bd..6ac27e2c 100644
--- a/src/sat/msat/msatActivity.c
+++ b/src/sat/msat/msatActivity.c
@@ -20,6 +20,9 @@
#include "msatInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -158,3 +161,5 @@ void Msat_SolverClaRescaleActivity( Msat_Solver_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/msat/msatClause.c b/src/sat/msat/msatClause.c
index ca698866..a464f23a 100644
--- a/src/sat/msat/msatClause.c
+++ b/src/sat/msat/msatClause.c
@@ -20,6 +20,9 @@
#include "msatInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -52,7 +55,7 @@ struct Msat_Clause_t_
SeeAlso []
***********************************************************************/
-bool Msat_ClauseCreate( Msat_Solver_t * p, Msat_IntVec_t * vLits, bool fLearned, Msat_Clause_t ** pClause_out )
+int Msat_ClauseCreate( Msat_Solver_t * p, Msat_IntVec_t * vLits, int fLearned, Msat_Clause_t ** pClause_out )
{
int * pAssigns = Msat_SolverReadAssignsArray(p);
Msat_ClauseVec_t ** pvWatched;
@@ -61,7 +64,7 @@ bool Msat_ClauseCreate( Msat_Solver_t * p, Msat_IntVec_t * vLits, bool fLearned,
int nLits, i, j;
int nBytes;
Msat_Var_t Var;
- bool Sign;
+ int Sign;
*pClause_out = NULL;
@@ -217,7 +220,7 @@ bool Msat_ClauseCreate( Msat_Solver_t * p, Msat_IntVec_t * vLits, bool fLearned,
SeeAlso []
***********************************************************************/
-void Msat_ClauseFree( Msat_Solver_t * p, Msat_Clause_t * pC, bool fRemoveWatched )
+void Msat_ClauseFree( Msat_Solver_t * p, Msat_Clause_t * pC, int fRemoveWatched )
{
if ( fRemoveWatched )
{
@@ -249,16 +252,16 @@ void Msat_ClauseFree( Msat_Solver_t * p, Msat_Clause_t * pC, bool fRemoveWatched
SeeAlso []
***********************************************************************/
-bool Msat_ClauseReadLearned( Msat_Clause_t * pC ) { return pC->fLearned; }
+int Msat_ClauseReadLearned( Msat_Clause_t * pC ) { return pC->fLearned; }
int Msat_ClauseReadSize( Msat_Clause_t * pC ) { return pC->nSize; }
int * Msat_ClauseReadLits( Msat_Clause_t * pC ) { return pC->pData; }
-bool Msat_ClauseReadMark( Msat_Clause_t * pC ) { return pC->fMark; }
+int Msat_ClauseReadMark( Msat_Clause_t * pC ) { return pC->fMark; }
int Msat_ClauseReadNum( Msat_Clause_t * pC ) { return pC->Num; }
-bool Msat_ClauseReadTypeA( Msat_Clause_t * pC ) { return pC->fTypeA; }
+int Msat_ClauseReadTypeA( Msat_Clause_t * pC ) { return pC->fTypeA; }
-void Msat_ClauseSetMark( Msat_Clause_t * pC, bool fMark ) { pC->fMark = fMark; }
+void Msat_ClauseSetMark( Msat_Clause_t * pC, int fMark ) { pC->fMark = fMark; }
void Msat_ClauseSetNum( Msat_Clause_t * pC, int Num ) { pC->Num = Num; }
-void Msat_ClauseSetTypeA( Msat_Clause_t * pC, bool fTypeA ) { pC->fTypeA = fTypeA; }
+void Msat_ClauseSetTypeA( Msat_Clause_t * pC, int fTypeA ) { pC->fTypeA = fTypeA; }
/**Function*************************************************************
@@ -272,10 +275,10 @@ void Msat_ClauseSetTypeA( Msat_Clause_t * pC, bool fTypeA ) { pC->fTypeA = fTy
SeeAlso []
***********************************************************************/
-bool Msat_ClauseIsLocked( Msat_Solver_t * p, Msat_Clause_t * pC )
+int Msat_ClauseIsLocked( Msat_Solver_t * p, Msat_Clause_t * pC )
{
Msat_Clause_t ** pReasons = Msat_SolverReadReasonArray( p );
- return (bool)(pReasons[MSAT_LIT2VAR(pC->pData[0])] == pC);
+ return (int )(pReasons[MSAT_LIT2VAR(pC->pData[0])] == pC);
}
/**Function*************************************************************
@@ -326,7 +329,7 @@ void Msat_ClauseWriteActivity( Msat_Clause_t * pC, float Num )
SeeAlso []
***********************************************************************/
-bool Msat_ClausePropagate( Msat_Clause_t * pC, Msat_Lit_t Lit, int * pAssigns, Msat_Lit_t * pLit_out )
+int Msat_ClausePropagate( Msat_Clause_t * pC, Msat_Lit_t Lit, int * pAssigns, Msat_Lit_t * pLit_out )
{
// make sure the false literal is pC->pData[1]
Msat_Lit_t LitF = MSAT_LITNOT(Lit);
@@ -365,7 +368,7 @@ bool Msat_ClausePropagate( Msat_Clause_t * pC, Msat_Lit_t Lit, int * pAssigns, M
SeeAlso []
***********************************************************************/
-bool Msat_ClauseSimplify( Msat_Clause_t * pC, int * pAssigns )
+int Msat_ClauseSimplify( Msat_Clause_t * pC, int * pAssigns )
{
Msat_Var_t Var;
int i, j;
@@ -485,7 +488,7 @@ void Msat_ClausePrint( Msat_Clause_t * pC )
SeeAlso []
***********************************************************************/
-void Msat_ClauseWriteDimacs( FILE * pFile, Msat_Clause_t * pC, bool fIncrement )
+void Msat_ClauseWriteDimacs( FILE * pFile, Msat_Clause_t * pC, int fIncrement )
{
int i;
for ( i = 0; i < (int)pC->nSize; i++ )
@@ -527,3 +530,5 @@ void Msat_ClausePrintSymbols( Msat_Clause_t * pC )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/msat/msatClauseVec.c b/src/sat/msat/msatClauseVec.c
index f29de389..71895711 100644
--- a/src/sat/msat/msatClauseVec.c
+++ b/src/sat/msat/msatClauseVec.c
@@ -20,6 +20,9 @@
#include "msatInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -230,3 +233,5 @@ Msat_Clause_t * Msat_ClauseVecReadEntry( Msat_ClauseVec_t * p, int i )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/msat/msatInt.h b/src/sat/msat/msatInt.h
index b6759a0f..b4b5ff77 100644
--- a/src/sat/msat/msatInt.h
+++ b/src/sat/msat/msatInt.h
@@ -21,6 +21,7 @@
#ifndef __MSAT_INT_H__
#define __MSAT_INT_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -31,9 +32,13 @@
#include <assert.h>
#include <time.h>
#include <math.h>
+
#include "abc_global.h"
#include "msat.h"
+ABC_NAMESPACE_HEADER_START
+
+
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
@@ -120,7 +125,7 @@ struct Msat_Solver_t_
double dRandSeed; // For the internal random number generator (makes solver deterministic over different platforms).
- bool fVerbose; // the verbosity flag
+ int fVerbose; // the verbosity flag
double dProgress; // Set by 'search()'.
// the variable cone and variable connectivity
@@ -197,10 +202,10 @@ extern void Msat_SolverClausesIncrementL( Msat_Solver_t * p );
extern void Msat_SolverClausesDecrementL( Msat_Solver_t * p );
extern void Msat_SolverVarBumpActivity( Msat_Solver_t * p, Msat_Lit_t Lit );
extern void Msat_SolverClaBumpActivity( Msat_Solver_t * p, Msat_Clause_t * pC );
-extern bool Msat_SolverEnqueue( Msat_Solver_t * p, Msat_Lit_t Lit, Msat_Clause_t * pC );
+extern int Msat_SolverEnqueue( Msat_Solver_t * p, Msat_Lit_t Lit, Msat_Clause_t * pC );
extern double Msat_SolverProgressEstimate( Msat_Solver_t * p );
/*=== satSolverSearch.c ===========================================================*/
-extern bool Msat_SolverAssume( Msat_Solver_t * p, Msat_Lit_t Lit );
+extern int Msat_SolverAssume( Msat_Solver_t * p, Msat_Lit_t Lit );
extern Msat_Clause_t * Msat_SolverPropagate( Msat_Solver_t * p );
extern void Msat_SolverCancelUntil( Msat_Solver_t * p, int Level );
extern Msat_Type_t Msat_SolverSearch( Msat_Solver_t * p, int nConfLimit, int nLearnedLimit, int nBackTrackLimit, Msat_SearchParams_t * pPars );
@@ -222,29 +227,29 @@ extern void Msat_OrderVarAssigned( Msat_Order_t * p, int Var );
extern void Msat_OrderVarUnassigned( Msat_Order_t * p, int Var );
extern void Msat_OrderUpdate( Msat_Order_t * p, int Var );
/*=== satClause.c ===========================================================*/
-extern bool Msat_ClauseCreate( Msat_Solver_t * p, Msat_IntVec_t * vLits, bool fLearnt, Msat_Clause_t ** pClause_out );
+extern int Msat_ClauseCreate( Msat_Solver_t * p, Msat_IntVec_t * vLits, int fLearnt, Msat_Clause_t ** pClause_out );
extern Msat_Clause_t * Msat_ClauseCreateFake( Msat_Solver_t * p, Msat_IntVec_t * vLits );
extern Msat_Clause_t * Msat_ClauseCreateFakeLit( Msat_Solver_t * p, Msat_Lit_t Lit );
-extern bool Msat_ClauseReadLearned( Msat_Clause_t * pC );
+extern int Msat_ClauseReadLearned( Msat_Clause_t * pC );
extern int Msat_ClauseReadSize( Msat_Clause_t * pC );
extern int * Msat_ClauseReadLits( Msat_Clause_t * pC );
-extern bool Msat_ClauseReadMark( Msat_Clause_t * pC );
-extern void Msat_ClauseSetMark( Msat_Clause_t * pC, bool fMark );
+extern int Msat_ClauseReadMark( Msat_Clause_t * pC );
+extern void Msat_ClauseSetMark( Msat_Clause_t * pC, int fMark );
extern int Msat_ClauseReadNum( Msat_Clause_t * pC );
extern void Msat_ClauseSetNum( Msat_Clause_t * pC, int Num );
-extern bool Msat_ClauseReadTypeA( Msat_Clause_t * pC );
-extern void Msat_ClauseSetTypeA( Msat_Clause_t * pC, bool fTypeA );
-extern bool Msat_ClauseIsLocked( Msat_Solver_t * p, Msat_Clause_t * pC );
+extern int Msat_ClauseReadTypeA( Msat_Clause_t * pC );
+extern void Msat_ClauseSetTypeA( Msat_Clause_t * pC, int fTypeA );
+extern int Msat_ClauseIsLocked( Msat_Solver_t * p, Msat_Clause_t * pC );
extern float Msat_ClauseReadActivity( Msat_Clause_t * pC );
extern void Msat_ClauseWriteActivity( Msat_Clause_t * pC, float Num );
-extern void Msat_ClauseFree( Msat_Solver_t * p, Msat_Clause_t * pC, bool fRemoveWatched );
-extern bool Msat_ClausePropagate( Msat_Clause_t * pC, Msat_Lit_t Lit, int * pAssigns, Msat_Lit_t * pLit_out );
-extern bool Msat_ClauseSimplify( Msat_Clause_t * pC, int * pAssigns );
+extern void Msat_ClauseFree( Msat_Solver_t * p, Msat_Clause_t * pC, int fRemoveWatched );
+extern int Msat_ClausePropagate( Msat_Clause_t * pC, Msat_Lit_t Lit, int * pAssigns, Msat_Lit_t * pLit_out );
+extern int Msat_ClauseSimplify( Msat_Clause_t * pC, int * pAssigns );
extern void Msat_ClauseCalcReason( Msat_Solver_t * p, Msat_Clause_t * pC, Msat_Lit_t Lit, Msat_IntVec_t * vLits_out );
extern void Msat_ClauseRemoveWatch( Msat_ClauseVec_t * vClauses, Msat_Clause_t * pC );
extern void Msat_ClausePrint( Msat_Clause_t * pC );
extern void Msat_ClausePrintSymbols( Msat_Clause_t * pC );
-extern void Msat_ClauseWriteDimacs( FILE * pFile, Msat_Clause_t * pC, bool fIncrement );
+extern void Msat_ClauseWriteDimacs( FILE * pFile, Msat_Clause_t * pC, int fIncrement );
extern unsigned Msat_ClauseComputeTruth( Msat_Solver_t * p, Msat_Clause_t * pC );
/*=== satSort.c ===========================================================*/
extern void Msat_SolverSortDB( Msat_Solver_t * p );
@@ -284,4 +289,8 @@ extern int Msat_MmStepReadMemUsage( Msat_MmStep_t * p );
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif
diff --git a/src/sat/msat/msatMem.c b/src/sat/msat/msatMem.c
index 439661f4..7e0dc0dd 100644
--- a/src/sat/msat/msatMem.c
+++ b/src/sat/msat/msatMem.c
@@ -20,6 +20,9 @@
#include "msatInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -31,7 +34,7 @@ struct Msat_MmFixed_t_
int nEntriesAlloc; // the total number of entries allocated
int nEntriesUsed; // the number of entries in use
int nEntriesMax; // the max number of entries in use
- char * pEntriesFree; // the linked list of ABC_FREE entries
+ char * pEntriesFree; // the linked list of free entries
// this is where the memory is stored
int nChunkSize; // the size of one chunk
@@ -48,8 +51,8 @@ struct Msat_MmFlex_t_
{
// information about individual entries
int nEntriesUsed; // the number of entries allocated
- char * pCurrent; // the current pointer to ABC_FREE memory
- char * pEnd; // the first entry outside the ABC_FREE memory
+ char * pCurrent; // the current pointer to free memory
+ char * pEnd; // the first entry outside the free memory
// this is where the memory is stored
int nChunkSize; // the size of one chunk
@@ -160,7 +163,7 @@ char * Msat_MmFixedEntryFetch( Msat_MmFixed_t * p )
char * pTemp;
int i;
- // check if there are still ABC_FREE entries
+ // check if there are still free entries
if ( p->nEntriesUsed == p->nEntriesAlloc )
{ // need to allocate more entries
assert( p->pEntriesFree == NULL );
@@ -189,7 +192,7 @@ char * Msat_MmFixedEntryFetch( Msat_MmFixed_t * p )
p->nEntriesUsed++;
if ( p->nEntriesMax < p->nEntriesUsed )
p->nEntriesMax = p->nEntriesUsed;
- // return the first entry in the ABC_FREE entry list
+ // return the first entry in the free entry list
pTemp = p->pEntriesFree;
p->pEntriesFree = *((char **)pTemp);
return pTemp;
@@ -210,7 +213,7 @@ void Msat_MmFixedEntryRecycle( Msat_MmFixed_t * p, char * pEntry )
{
// decrement the counter of used entries
p->nEntriesUsed--;
- // add the entry to the linked list of ABC_FREE entries
+ // add the entry to the linked list of free entries
*((char **)pEntry) = p->pEntriesFree;
p->pEntriesFree = pEntry;
}
@@ -244,7 +247,7 @@ void Msat_MmFixedRestart( Msat_MmFixed_t * p )
}
// set the last link
*((char **)pTemp) = NULL;
- // set the ABC_FREE entry list
+ // set the free entry list
p->pEntriesFree = p->pChunks[0];
// set the correct statistics
p->nMemoryAlloc = p->nEntrySize * p->nChunkSize;
@@ -346,7 +349,7 @@ void Msat_MmFlexStop( Msat_MmFlex_t * p, int fVerbose )
char * Msat_MmFlexEntryFetch( Msat_MmFlex_t * p, int nBytes )
{
char * pTemp;
- // check if there are still ABC_FREE entries
+ // check if there are still free entries
if ( p->pCurrent == NULL || p->pCurrent + nBytes > p->pEnd )
{ // need to allocate more entries
if ( p->nChunks == p->nChunksAlloc )
@@ -527,3 +530,5 @@ int Msat_MmStepReadMemUsage( Msat_MmStep_t * p )
nMemTotal += p->pMems[i]->nMemoryAlloc;
return nMemTotal;
}
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/msat/msatOrderH.c b/src/sat/msat/msatOrderH.c
index 7d8484d5..2904607f 100644
--- a/src/sat/msat/msatOrderH.c
+++ b/src/sat/msat/msatOrderH.c
@@ -20,6 +20,9 @@
#include "msatInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -403,3 +406,5 @@ void Msat_HeapPercolateDown( Msat_Order_t * p, int i )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/msat/msatOrderJ.c b/src/sat/msat/msatOrderJ.c
index 4db7ff7b..2be6b47b 100644
--- a/src/sat/msat/msatOrderJ.c
+++ b/src/sat/msat/msatOrderJ.c
@@ -20,6 +20,9 @@
#include "msatInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
/*
The J-boundary (justification boundary) is defined as a set of unassigned
variables belonging to the cone of interest, such that for each of them,
@@ -470,3 +473,5 @@ void Msat_OrderRingRemove( Msat_OrderRing_t * pRing, Msat_OrderVar_t * pVar )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/msat/msatQueue.c b/src/sat/msat/msatQueue.c
index 0bcaf6b2..f025920b 100644
--- a/src/sat/msat/msatQueue.c
+++ b/src/sat/msat/msatQueue.c
@@ -20,6 +20,9 @@
#include "msatInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -155,3 +158,5 @@ void Msat_QueueClear( Msat_Queue_t * p )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/msat/msatRead.c b/src/sat/msat/msatRead.c
index ba33278c..b2cae898 100644
--- a/src/sat/msat/msatRead.c
+++ b/src/sat/msat/msatRead.c
@@ -20,6 +20,9 @@
#include "msatInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -133,7 +136,7 @@ static void skipLine( char ** pIn )
static int Msat_ReadInt( char ** pIn )
{
int val = 0;
- bool neg = 0;
+ int neg = 0;
Msat_ReadWhitespace( pIn );
if ( **pIn == '-' )
@@ -194,7 +197,7 @@ static void Msat_ReadClause( char ** pIn, Msat_Solver_t * p, Msat_IntVec_t * pLi
SeeAlso []
***********************************************************************/
-static bool Msat_ReadDimacs( char * pText, Msat_Solver_t ** pS, bool fVerbose )
+static int Msat_ReadDimacs( char * pText, Msat_Solver_t ** pS, int fVerbose )
{
Msat_Solver_t * p = NULL; // Suppress "might be used uninitialized"
Msat_IntVec_t * pLits = NULL; // Suppress "might be used uninitialized"
@@ -251,10 +254,10 @@ static bool Msat_ReadDimacs( char * pText, Msat_Solver_t ** pS, bool fVerbose )
SeeAlso []
***********************************************************************/
-bool Msat_SolverParseDimacs( FILE * pFile, Msat_Solver_t ** p, int fVerbose )
+int Msat_SolverParseDimacs( FILE * pFile, Msat_Solver_t ** p, int fVerbose )
{
char * pText;
- bool Value;
+ int Value;
pText = Msat_FileRead( pFile );
Value = Msat_ReadDimacs( pText, p, fVerbose );
ABC_FREE( pText );
@@ -266,3 +269,5 @@ bool Msat_SolverParseDimacs( FILE * pFile, Msat_Solver_t ** p, int fVerbose )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/msat/msatSolverApi.c b/src/sat/msat/msatSolverApi.c
index 6a518212..622e94aa 100644
--- a/src/sat/msat/msatSolverApi.c
+++ b/src/sat/msat/msatSolverApi.c
@@ -20,6 +20,9 @@
#include "msatInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -47,7 +50,7 @@ int Msat_SolverReadVarAllocNum( Msat_Solver_t * p ) {
int Msat_SolverReadDecisionLevel( Msat_Solver_t * p ) { return Msat_IntVecReadSize(p->vTrailLim); }
int * Msat_SolverReadDecisionLevelArray( Msat_Solver_t * p ) { return p->pLevel; }
Msat_Clause_t ** Msat_SolverReadReasonArray( Msat_Solver_t * p ) { return p->pReasons; }
-Msat_Lit_t Msat_SolverReadVarValue( Msat_Solver_t * p, Msat_Var_t Var ) { return p->pAssigns[Var]; }
+Msat_Type_t Msat_SolverReadVarValue( Msat_Solver_t * p, Msat_Var_t Var ) { return (Msat_Type_t)p->pAssigns[Var]; }
Msat_ClauseVec_t * Msat_SolverReadLearned( Msat_Solver_t * p ) { return p->vLearned; }
Msat_ClauseVec_t ** Msat_SolverReadWatchedArray( Msat_Solver_t * p ) { return p->pvWatched; }
int * Msat_SolverReadAssignsArray( Msat_Solver_t * p ) { return p->pAssigns; }
@@ -151,7 +154,7 @@ Msat_IntVec_t * Msat_SolverReadVarsUsed( Msat_Solver_t * p )
Msat_Solver_t * Msat_SolverAlloc( int nVarsAlloc,
double dClaInc, double dClaDecay,
double dVarInc, double dVarDecay,
- bool fVerbose )
+ int fVerbose )
{
Msat_Solver_t * p;
int i;
@@ -498,3 +501,5 @@ void Msat_SolverSetupTruthTables( unsigned uTruths[][2] )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/msat/msatSolverCore.c b/src/sat/msat/msatSolverCore.c
index 0462f11b..3312c23d 100644
--- a/src/sat/msat/msatSolverCore.c
+++ b/src/sat/msat/msatSolverCore.c
@@ -20,6 +20,9 @@
#include "msatInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -39,7 +42,7 @@
SeeAlso []
***********************************************************************/
-bool Msat_SolverAddVar( Msat_Solver_t * p, int Level )
+int Msat_SolverAddVar( Msat_Solver_t * p, int Level )
{
if ( p->nVars == p->nVarsAlloc )
Msat_SolverResize( p, 2 * p->nVarsAlloc );
@@ -59,10 +62,10 @@ bool Msat_SolverAddVar( Msat_Solver_t * p, int Level )
SeeAlso []
***********************************************************************/
-bool Msat_SolverAddClause( Msat_Solver_t * p, Msat_IntVec_t * vLits )
+int Msat_SolverAddClause( Msat_Solver_t * p, Msat_IntVec_t * vLits )
{
Msat_Clause_t * pC;
- bool Value;
+ int Value;
Value = Msat_ClauseCreate( p, vLits, 0, &pC );
if ( pC != NULL )
Msat_ClauseVecPush( p->vClauses, pC );
@@ -132,7 +135,7 @@ void Msat_SolverPrintStats( Msat_Solver_t * p )
SeeAlso []
***********************************************************************/
-bool Msat_SolverSolve( Msat_Solver_t * p, Msat_IntVec_t * vAssumps, int nBackTrackLimit, int nTimeLimit )
+int Msat_SolverSolve( Msat_Solver_t * p, Msat_IntVec_t * vAssumps, int nBackTrackLimit, int nTimeLimit )
{
Msat_SearchParams_t Params = { 0.95, 0.999 };
double nConflictsLimit, nLearnedLimit;
@@ -208,3 +211,5 @@ bool Msat_SolverSolve( Msat_Solver_t * p, Msat_IntVec_t * vAssumps, int nBackTra
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/msat/msatSolverIo.c b/src/sat/msat/msatSolverIo.c
index 05b7f6a9..38610b4d 100644
--- a/src/sat/msat/msatSolverIo.c
+++ b/src/sat/msat/msatSolverIo.c
@@ -20,6 +20,9 @@
#include "msatInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -175,3 +178,5 @@ char * Msat_TimeStamp()
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/msat/msatSolverSearch.c b/src/sat/msat/msatSolverSearch.c
index 11a6540c..b3190e39 100644
--- a/src/sat/msat/msatSolverSearch.c
+++ b/src/sat/msat/msatSolverSearch.c
@@ -20,6 +20,9 @@
#include "msatInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -45,7 +48,7 @@ static void Msat_SolverReduceDB( Msat_Solver_t * p );
SeeAlso []
***********************************************************************/
-bool Msat_SolverAssume( Msat_Solver_t * p, Msat_Lit_t Lit )
+int Msat_SolverAssume( Msat_Solver_t * p, Msat_Lit_t Lit )
{
assert( Msat_QueueReadSize(p->pQueue) == 0 );
if ( p->fVerbose )
@@ -167,7 +170,7 @@ Msat_Clause_t * Msat_SolverRecord( Msat_Solver_t * p, Msat_IntVec_t * vLits )
SeeAlso []
***********************************************************************/
-bool Msat_SolverEnqueue( Msat_Solver_t * p, Msat_Lit_t Lit, Msat_Clause_t * pC )
+int Msat_SolverEnqueue( Msat_Solver_t * p, Msat_Lit_t Lit, Msat_Clause_t * pC )
{
Msat_Var_t Var = MSAT_LIT2VAR(Lit);
@@ -276,7 +279,7 @@ Msat_Clause_t * Msat_SolverPropagate( Msat_Solver_t * p )
SeeAlso []
***********************************************************************/
-bool Msat_SolverSimplifyDB( Msat_Solver_t * p )
+int Msat_SolverSimplifyDB( Msat_Solver_t * p )
{
Msat_ClauseVec_t * vClauses;
Msat_Clause_t ** pClauses;
@@ -627,3 +630,5 @@ Msat_Type_t Msat_SolverSearch( Msat_Solver_t * p, int nConfLimit, int nLearnedLi
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/msat/msatSort.c b/src/sat/msat/msatSort.c
index 3b89d102..a4b34030 100644
--- a/src/sat/msat/msatSort.c
+++ b/src/sat/msat/msatSort.c
@@ -20,6 +20,9 @@
#include "msatInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -171,3 +174,5 @@ void Msat_SolverSort( Msat_Clause_t ** array, int size, double seed )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/msat/msatVec.c b/src/sat/msat/msatVec.c
index 3716dbf7..7144b213 100644
--- a/src/sat/msat/msatVec.c
+++ b/src/sat/msat/msatVec.c
@@ -20,6 +20,9 @@
#include "msatInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -493,3 +496,5 @@ int Msat_IntVecSortCompare2( int * pp1, int * pp2 )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/proof/pr.c b/src/sat/proof/pr.c
index a951071a..0da16eaf 100644
--- a/src/sat/proof/pr.c
+++ b/src/sat/proof/pr.c
@@ -23,10 +23,14 @@
#include <string.h>
#include <assert.h>
#include <time.h>
+
//#include "vec.h"
#include "abc_global.h"
#include "pr.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -186,7 +190,7 @@ void Pr_ManResize( Pr_Man_t * p, int nVarsNew )
p->pVarTypes = ABC_REALLOC(char, p->pVarTypes, p->nVarsAlloc );
p->pReasons = ABC_REALLOC(Pr_Cls_t *, p->pReasons, p->nVarsAlloc );
p->pWatches = ABC_REALLOC(Pr_Cls_t *, p->pWatches, p->nVarsAlloc*2 );
- // clean the ABC_FREE space
+ // clean the free space
memset( p->pAssigns + nVarsAllocOld, 0xff, sizeof(lit) * (p->nVarsAlloc - nVarsAllocOld) );
memset( p->pSeens + nVarsAllocOld, 0, sizeof(char) * (p->nVarsAlloc - nVarsAllocOld) );
memset( p->pVarTypes + nVarsAllocOld, 0, sizeof(char) * (p->nVarsAlloc - nVarsAllocOld) );
@@ -649,10 +653,10 @@ void Pr_ManProofWriteOne( Pr_Man_t * p, Pr_Cls_t * pClause )
if ( p->fProofWrite )
{
int v;
- fprintf( p->pManProof, "%d", (int)pClause->pProof );
+ fprintf( (FILE *)p->pManProof, "%d", (int)pClause->pProof );
for ( v = 0; v < (int)pClause->nLits; v++ )
- fprintf( p->pManProof, " %d", lit_print(pClause->pLits[v]) );
- fprintf( p->pManProof, " 0 0\n" );
+ fprintf( (FILE *)p->pManProof, " %d", lit_print(pClause->pLits[v]) );
+ fprintf( (FILE *)p->pManProof, " 0 0\n" );
}
}
@@ -718,7 +722,7 @@ int Pr_ManProofTraceOne( Pr_Man_t * p, Pr_Cls_t * pConflict, Pr_Cls_t * pFinal )
assert( pReason->pProof > 0 );
p->Counter++;
if ( p->fProofWrite )
- fprintf( p->pManProof, "%d * %d %d 0\n", p->Counter, PrevId, (int)pReason->pProof );
+ fprintf( (FILE *)p->pManProof, "%d * %d %d 0\n", p->Counter, PrevId, (int)pReason->pProof );
PrevId = p->Counter;
if ( p->nClausesA )
@@ -1086,7 +1090,7 @@ int Pr_ManProofWrite( Pr_Man_t * p )
// stop the proof
if ( p->fProofWrite )
{
- fclose( p->pManProof );
+ fclose( (FILE *)p->pManProof );
p->pManProof = NULL;
}
return RetValue;
@@ -1162,7 +1166,7 @@ Pr_Man_t * Pr_ManProofRead( char * pFileName )
for ( ; *pCur && *pCur != ' '; pCur++ );
}
// add the clause
- if ( !Pr_ManAddClause( p, pArray, pArray + nNumbers, Counter < nRoots, Counter < nClausesA ) )
+ if ( !Pr_ManAddClause( p, (unsigned *)pArray, (unsigned *)pArray + nNumbers, Counter < nRoots, Counter < nClausesA ) )
{
printf( "Bad clause number %d.\n", Counter );
return NULL;
@@ -1204,7 +1208,7 @@ int Pr_ManProofCount_rec( Pr_Cls_t * pClause )
pClause->fVisit = 1;
// count the number of visited clauses
Counter = 1;
- Vec_PtrForEachEntry( pClause->pAntis, pNext, i )
+ Vec_PtrForEachEntry( Pr_Cls_t *, pClause->pAntis, pNext, i )
Counter += Pr_ManProofCount_rec( pNext );
return Counter;
}
@@ -1258,3 +1262,5 @@ p->timeTotal = clock() - clkTotal;
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/sat/proof/pr.h b/src/sat/proof/pr.h
index bc55e016..9088c89b 100644
--- a/src/sat/proof/pr.h
+++ b/src/sat/proof/pr.h
@@ -21,6 +21,7 @@
#ifndef __PR_H__
#define __PR_H__
+
#ifdef _WIN32
#define inline __inline // compatible with MS VS 6.0
#endif
@@ -33,9 +34,10 @@
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
-#ifdef __cplusplus
-extern "C" {
-#endif
+
+
+ABC_NAMESPACE_HEADER_START
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
@@ -53,9 +55,11 @@ typedef struct Pr_Man_t_ Pr_Man_t;
/*=== pr.c ==========================================================*/
-#ifdef __cplusplus
-}
-#endif
+
+
+ABC_NAMESPACE_HEADER_END
+
+
#endif
diff --git a/src/sat/psat/m114p.h b/src/sat/psat/m114p.h
index 5050cb4b..9319d918 100644
--- a/src/sat/psat/m114p.h
+++ b/src/sat/psat/m114p.h
@@ -3,8 +3,12 @@
#ifndef m114p_h
#define m114p_h
+
#include "m114p_types.h"
+ABC_NAMESPACE_HEADER_START
+
+
// SAT solver APIs
extern M114p_Solver_t M114p_SolverNew( int fRecordProof );
extern void M114p_SolverDelete( M114p_Solver_t s );
@@ -36,4 +40,8 @@ extern int M114p_SolverGetNextChain( M114p_Solver_t s, int ** ppClaus
for ( i = 0, nVars = M114p_SolverGetFirstChain(s, ppClauses, ppVars); nVars; \
i++, nVars = M114p_SolverGetNextChain(s, ppClauses, ppVars) )
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif \ No newline at end of file
diff --git a/src/sat/psat/m114p_types.h b/src/sat/psat/m114p_types.h
index 54a20c5c..29d70a87 100644
--- a/src/sat/psat/m114p_types.h
+++ b/src/sat/psat/m114p_types.h
@@ -3,7 +3,11 @@
#ifndef m114p_types_h
#define m114p_types_h
+
+ABC_NAMESPACE_HEADER_START
+
typedef int M114p_Solver_t;
-typedef int lit;
-#endif \ No newline at end of file
+ABC_NAMESPACE_HEADER_END
+
+#endif